diff options
author | Richard Nelson <richard@lindenlab.com> | 2009-08-04 01:12:59 +0000 |
---|---|---|
committer | Richard Nelson <richard@lindenlab.com> | 2009-08-04 01:12:59 +0000 |
commit | eb853f55c07ae4a3c3f2aa05fbabcf2e4b4dc115 (patch) | |
tree | 7707fccb8d0946b6257d5ed7c5dfd3941c53eec0 /indra/newview/llfloateravatarpicker.cpp | |
parent | db5cda26676f376f18816013c0c5e3fbad5b20d0 (diff) |
svn merge -r 128442:129343 svn+ssh://svn.lindenlab.com/svn/linden/branches/skinning/skinning-18 into svn+ssh://svn.lindenlab.com/svn/linden/branches/viewer/viewer-2.0.0-3
Diffstat (limited to 'indra/newview/llfloateravatarpicker.cpp')
-rw-r--r-- | indra/newview/llfloateravatarpicker.cpp | 75 |
1 files changed, 29 insertions, 46 deletions
diff --git a/indra/newview/llfloateravatarpicker.cpp b/indra/newview/llfloateravatarpicker.cpp index 92ce44fa42..91b9bcfe72 100644 --- a/indra/newview/llfloateravatarpicker.cpp +++ b/indra/newview/llfloateravatarpicker.cpp @@ -36,6 +36,7 @@ // Viewer includes #include "llagent.h" #include "llfocusmgr.h" +#include "llfloaterreg.h" #include "llfloaterinventory.h" #include "llfoldervieweventlistener.h" #include "llinventorymodel.h" @@ -53,49 +54,33 @@ #include "lluictrlfactory.h" #include "message.h" -// static -LLFloaterAvatarPicker* LLFloaterAvatarPicker::sInstance = NULL; - - LLFloaterAvatarPicker* LLFloaterAvatarPicker::show(callback_t callback, void* userdata, BOOL allow_multiple, BOOL closeOnSelect) { - // TODO: This class should not be a singleton as it's used in multiple places - // and therefore can't be used simultaneously. -MG - if (!sInstance) - { - sInstance = new LLFloaterAvatarPicker(); - sInstance->mCallback = callback; - sInstance->mCallbackUserdata = userdata; - sInstance->mCloseOnSelect = FALSE; - - sInstance->openFloater(); - sInstance->center(); - sInstance->setAllowMultiple(allow_multiple); - } - else - { - sInstance->openFloater(); - sInstance->mCallback = callback; - sInstance->mCallbackUserdata = userdata; - sInstance->setAllowMultiple(allow_multiple); - } + // *TODO: Use a key to allow this not to be an effective singleton + LLFloaterAvatarPicker* floater = LLFloaterReg::showTypedInstance<LLFloaterAvatarPicker>("avatar_picker"); + + floater->mCallback = callback; + floater->mCallbackUserdata = userdata; + floater->setAllowMultiple(allow_multiple); + floater->mNearMeListComplete = FALSE; + floater->mCloseOnSelect = closeOnSelect; - sInstance->mNearMeListComplete = FALSE; - sInstance->mCloseOnSelect = closeOnSelect; - return sInstance; + return floater; } // Default constructor -LLFloaterAvatarPicker::LLFloaterAvatarPicker() - : LLFloater(), +LLFloaterAvatarPicker::LLFloaterAvatarPicker(const LLSD& key) + : LLFloater(key), mResultsReturned(FALSE), mCallback(NULL), - mCallbackUserdata(NULL) + mCallbackUserdata(NULL), + mNearMeListComplete(FALSE), + mCloseOnSelect(FALSE) { - LLUICtrlFactory::getInstance()->buildFloater(this, "floater_avatar_picker.xml"); +// LLUICtrlFactory::getInstance()->buildFloater(this, "floater_avatar_picker.xml"); } BOOL LLFloaterAvatarPicker::postBuild() @@ -143,7 +128,9 @@ BOOL LLFloaterAvatarPicker::postBuild() boost::bind(&LLFloaterAvatarPicker::onTabChanged, this)); setAllowMultiple(FALSE); - + + center(); + return TRUE; } @@ -156,8 +143,6 @@ void LLFloaterAvatarPicker::onTabChanged() LLFloaterAvatarPicker::~LLFloaterAvatarPicker() { gFocusMgr.releaseFocusIfNeeded( this ); - - sInstance = NULL; } void LLFloaterAvatarPicker::onBtnFind(void* userdata) @@ -408,23 +393,21 @@ void LLFloaterAvatarPicker::processAvatarPickerReply(LLMessageSystem* msg, void* // Not for us if (agent_id != gAgent.getID()) return; - - // Dialog already closed - LLFloaterAvatarPicker *self = sInstance; - if (!self) return; + + LLFloaterAvatarPicker* floater = LLFloaterReg::findTypedInstance<LLFloaterAvatarPicker>("avatar_picker"); // these are not results from our last request - if (query_id != self->mQueryID) + if (query_id != floater->mQueryID) { return; } - LLScrollListCtrl* search_results = self->getChild<LLScrollListCtrl>("SearchResults"); + LLScrollListCtrl* search_results = floater->getChild<LLScrollListCtrl>("SearchResults"); // clear "Searching" label on first results search_results->deleteAllItems(); - self->mResultsReturned = TRUE; + floater->mResultsReturned = TRUE; BOOL found_one = FALSE; S32 num_new_rows = msg->getNumberOfBlocks("Data"); @@ -438,10 +421,10 @@ void LLFloaterAvatarPicker::processAvatarPickerReply(LLMessageSystem* msg, void* if (avatar_id.isNull()) { LLStringUtil::format_map_t map; - map["[TEXT]"] = self->childGetText("Edit"); - avatar_name = self->getString("not_found", map); + map["[TEXT]"] = floater->childGetText("Edit"); + avatar_name = floater->getString("not_found", map); search_results->setEnabled(FALSE); - self->childDisable("Select"); + floater->childDisable("Select"); } else { @@ -457,9 +440,9 @@ void LLFloaterAvatarPicker::processAvatarPickerReply(LLMessageSystem* msg, void* if (found_one) { - self->childEnable("Select"); + floater->childEnable("Select"); search_results->selectFirstItem(); - self->onList(search_results, self); + floater->onList(search_results, floater); search_results->setFocus(TRUE); } } |