diff options
author | Tofu Linden <tofu.linden@lindenlab.com> | 2010-05-20 11:47:15 +0100 |
---|---|---|
committer | Tofu Linden <tofu.linden@lindenlab.com> | 2010-05-20 11:47:15 +0100 |
commit | 9c779e222eb6f929003e2cce446850dfbc306063 (patch) | |
tree | 2837aacd1966ea429ea450bb7869e5b6595db309 /indra/newview/llsidepanelappearance.cpp | |
parent | 02fe5d60c0a6664bb86254347ce31467da2d90c3 (diff) | |
parent | ae0dbecb1c93347f7d83760117496048af3148da (diff) |
merge from viewer-public
Diffstat (limited to 'indra/newview/llsidepanelappearance.cpp')
-rw-r--r-- | indra/newview/llsidepanelappearance.cpp | 139 |
1 files changed, 80 insertions, 59 deletions
diff --git a/indra/newview/llsidepanelappearance.cpp b/indra/newview/llsidepanelappearance.cpp index 658a7b52e3..3f05e05fd4 100644 --- a/indra/newview/llsidepanelappearance.cpp +++ b/indra/newview/llsidepanelappearance.cpp @@ -97,7 +97,8 @@ LLSidepanelAppearance::LLSidepanelAppearance() : mFilterSubString(LLStringUtil::null), mFilterEditor(NULL), mOutfitEdit(NULL), - mCurrOutfitPanel(NULL) + mCurrOutfitPanel(NULL), + mOpened(false) { } @@ -116,7 +117,7 @@ BOOL LLSidepanelAppearance::postBuild() mEditAppearanceBtn = getChild<LLButton>("editappearance_btn"); mEditAppearanceBtn->setClickedCallback(boost::bind(&LLSidepanelAppearance::onEditAppearanceButtonClicked, this)); - childSetAction("edit_outfit_btn", boost::bind(&LLSidepanelAppearance::onEditOutfitButtonClicked, this)); + childSetAction("edit_outfit_btn", boost::bind(&LLSidepanelAppearance::showOutfitEditPanel, this)); mNewOutfitBtn = getChild<LLButton>("newlook_btn"); mNewOutfitBtn->setClickedCallback(boost::bind(&LLSidepanelAppearance::onNewOutfitButtonClicked, this)); @@ -148,7 +149,7 @@ BOOL LLSidepanelAppearance::postBuild() LLButton* edit_wearable_back_btn = mEditWearable->getChild<LLButton>("back_btn"); if (edit_wearable_back_btn) { - edit_wearable_back_btn->setClickedCallback(boost::bind(&LLSidepanelAppearance::onEditWearBackClicked, this)); + edit_wearable_back_btn->setClickedCallback(boost::bind(&LLSidepanelAppearance::showOutfitEditPanel, this)); } } @@ -167,27 +168,36 @@ BOOL LLSidepanelAppearance::postBuild() // virtual void LLSidepanelAppearance::onOpen(const LLSD& key) { - fetchInventory(); - refreshCurrentOutfitName(); - - if (mPanelOutfitsInventory) - { - mPanelOutfitsInventory->onOpen(key); - } - if (!key.has("type")) - return; - - // Switch to the requested panel. - std::string type = key["type"].asString(); - if (type == "my_outfits") { - showOutfitsInventoryPanel(); + // No specific panel requested. + // If we're opened for the first time then show My Outfits. + // Else do nothing. + if (!mOpened) + { + showOutfitsInventoryPanel(); + } } - else if (type == "edit_outfit") + else { - showOutfitEditPanel(/*update = */ true); + // Switch to the requested panel. + // *TODO: replace this crap with LLSideTrayPanelContainer + std::string type = key["type"].asString(); + if (type == "my_outfits") + { + showOutfitsInventoryPanel(); + } + else if (type == "edit_outfit") + { + showOutfitEditPanel(); + } + else if (type == "edit_shape") + { + showWearableEditPanel(); + } } + + mOpened = true; } void LLSidepanelAppearance::onFilterEdit(const std::string& search_string) @@ -239,13 +249,6 @@ void LLSidepanelAppearance::onEditAppearanceButtonClicked() } } -void LLSidepanelAppearance::onEditOutfitButtonClicked() -{ - LLSD key; - key["type"] = "edit_outfit"; - LLSideTray::getInstance()->showPanel("sidepanel_appearance", key); -} - void LLSidepanelAppearance::onNewOutfitButtonClicked() { if (!mOutfitEdit->getVisible()) @@ -254,52 +257,68 @@ void LLSidepanelAppearance::onNewOutfitButtonClicked() } } -void LLSidepanelAppearance::onEditWearBackClicked() +void LLSidepanelAppearance::showOutfitsInventoryPanel() { - showOutfitEditPanel(/* update = */ false); + toggleWearableEditPanel(FALSE); + toggleOutfitEditPanel(FALSE); + togglMyOutfitsPanel(TRUE); } -void LLSidepanelAppearance::showOutfitsInventoryPanel() +void LLSidepanelAppearance::showOutfitEditPanel() { + togglMyOutfitsPanel(FALSE); toggleWearableEditPanel(FALSE); + toggleOutfitEditPanel(TRUE); +} + +void LLSidepanelAppearance::showWearableEditPanel(LLWearable *wearable /* = NULL*/) +{ + togglMyOutfitsPanel(FALSE); toggleOutfitEditPanel(FALSE); + toggleWearableEditPanel(TRUE, wearable); } -void LLSidepanelAppearance::showOutfitEditPanel(bool update) +void LLSidepanelAppearance::togglMyOutfitsPanel(BOOL visible) { - if (!mOutfitEdit) + if (!mPanelOutfitsInventory || mPanelOutfitsInventory->getVisible() == visible) + { + // visibility isn't changing, hence nothing to do return; + } - toggleWearableEditPanel(FALSE); - toggleOutfitEditPanel(TRUE); + mPanelOutfitsInventory->setVisible(visible); + + // *TODO: Move these controls to panel_outfits_inventory.xml + // so that we don't need to toggle them explicitly. + mFilterEditor->setVisible(visible); + mNewOutfitBtn->setVisible(visible); + mCurrOutfitPanel->setVisible(visible); - if (update) + if (visible) { - mOutfitEdit->displayCurrentOutfit(); + mPanelOutfitsInventory->onOpen(LLSD()); } } void LLSidepanelAppearance::toggleOutfitEditPanel(BOOL visible) { - if (!mOutfitEdit) - return; - - if (mOutfitEdit->getVisible() == visible) + if (!mOutfitEdit || mOutfitEdit->getVisible() == visible) { // visibility isn't changing, hence nothing to do return; } mOutfitEdit->setVisible(visible); - if (mPanelOutfitsInventory) mPanelOutfitsInventory->setVisible(!visible); - mFilterEditor->setVisible(!visible); - mNewOutfitBtn->setVisible(!visible); - mCurrOutfitPanel->setVisible(!visible); + + if (visible) + { + mOutfitEdit->onOpen(LLSD()); + } } void LLSidepanelAppearance::toggleWearableEditPanel(BOOL visible, LLWearable *wearable) { - if (mEditWearable->getVisible() == visible) + if (!mEditWearable || mEditWearable->getVisible() == visible) { // visibility isn't changing, hence nothing to do return; @@ -309,24 +328,24 @@ void LLSidepanelAppearance::toggleWearableEditPanel(BOOL visible, LLWearable *we { wearable = gAgentWearables.getWearable(LLWearableType::WT_SHAPE, 0); } - if (!mEditWearable || !wearable) + if (!wearable) { return; } - // Save changes if closing. - if (!visible) - { - mEditWearable->saveChanges(); - } - // Toggle panel visibility. - mCurrOutfitPanel->setVisible(!visible); - mEditWearable->setVisible(visible); mEditWearable->setWearable(wearable); - mFilterEditor->setVisible(!visible); - mPanelOutfitsInventory->setVisible(!visible); + + if (visible) + { + mEditWearable->onOpen(LLSD()); // currently no-op, just for consistency + } + else + { + // Save changes if closing. + mEditWearable->saveChanges(); + } } void LLSidepanelAppearance::refreshCurrentOutfitName(const std::string& name) @@ -356,11 +375,13 @@ void LLSidepanelAppearance::refreshCurrentOutfitName(const std::string& name) } //static -void LLSidepanelAppearance::editWearable(LLWearable *wearable, void *data) +void LLSidepanelAppearance::editWearable(LLWearable *wearable, LLView *data) { - LLSidepanelAppearance *panel = (LLSidepanelAppearance*) data; - panel->toggleOutfitEditPanel(FALSE); - panel->toggleWearableEditPanel(TRUE, wearable); + LLSidepanelAppearance *panel = dynamic_cast<LLSidepanelAppearance*>(data); + if (panel) + { + panel->showWearableEditPanel(wearable); + } } // Fetch currently worn items and only enable the New Look button after everything's been |