summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorVadim Savchuk <vsavchuk@productengine.com>2010-05-19 14:03:29 +0300
committerVadim Savchuk <vsavchuk@productengine.com>2010-05-19 14:03:29 +0300
commit9aacdbc155b894532a85b18912288691ecb3832c (patch)
treee225e4e9e76d668e999472811c5535d39c9076a7 /indra
parent2c817f0b40aa22209b498e5e42dca8eab6439f4e (diff)
EXT-7242 FIXED Added a new "Edit my Shape" link to avatar self-click context menu and made it open the shape editing panel.
Again, as in EXT-7241, I tried to improve the way the appearance panels (outfits / edit outfit / edit wearables) are switched, this time aiming to eliminate redundant time-consuming operations (fetches/updated/etc). I'm not particularly satisfied with the resulting code but it seems to work. A better solution might be to wrap the panels with LLSideTrayPanelContainer. Additional minor changes: - Fixed unsafe pointer cast in LLSidepanelAppearance::editWearable(). - Removed redundant onEditOutfitButtonClicked() and onEditWearBackClicked() methods from LLSidepanelAppearance. Reviewed by Nyx at https://codereview.productengine.com/secondlife/r/395/ --HG-- branch : product-engine
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llpaneloutfitedit.cpp13
-rw-r--r--indra/newview/llpaneloutfitedit.h3
-rw-r--r--indra/newview/llpaneloutfitsinventory.cpp26
-rw-r--r--indra/newview/llpaneloutfitsinventory.h4
-rw-r--r--indra/newview/llsidepanelappearance.cpp139
-rw-r--r--indra/newview/llsidepanelappearance.h13
-rw-r--r--indra/newview/llviewermenu.cpp15
-rw-r--r--indra/newview/skins/default/xui/en/menu_avatar_self.xml9
-rw-r--r--indra/newview/skins/default/xui/en/sidepanel_appearance.xml1
9 files changed, 155 insertions, 68 deletions
diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp
index 44832ac496..c1623a4fa7 100644
--- a/indra/newview/llpaneloutfitedit.cpp
+++ b/indra/newview/llpaneloutfitedit.cpp
@@ -210,7 +210,8 @@ LLPanelOutfitEdit::LLPanelOutfitEdit()
mCOFWearables(NULL),
mInventoryItemsPanel(NULL),
mCOFObserver(NULL),
- mCOFDragAndDropObserver(NULL)
+ mCOFDragAndDropObserver(NULL),
+ mInitialized(false)
{
mSavedFolderState = new LLSaveFolderState();
mSavedFolderState->setApply(FALSE);
@@ -307,6 +308,16 @@ BOOL LLPanelOutfitEdit::postBuild()
return TRUE;
}
+// virtual
+void LLPanelOutfitEdit::onOpen(const LLSD& key)
+{
+ if (!mInitialized)
+ {
+ displayCurrentOutfit();
+ mInitialized = true;
+ }
+}
+
void LLPanelOutfitEdit::moveWearable(bool closer_to_body)
{
LLUUID item_id = mCOFWearables->getSelectedUUID();
diff --git a/indra/newview/llpaneloutfitedit.h b/indra/newview/llpaneloutfitedit.h
index 953a70785c..a08dc653ef 100644
--- a/indra/newview/llpaneloutfitedit.h
+++ b/indra/newview/llpaneloutfitedit.h
@@ -61,6 +61,7 @@ class LLFilteredWearableListManager;
class LLPanelOutfitEdit : public LLPanel
{
+ LOG_CLASS(LLPanelOutfitEdit);
public:
// NOTE: initialize mLookItemTypes at the index of any new enum you add in the LLPanelOutfitEdit() constructor
@@ -83,6 +84,7 @@ public:
/*virtual*/ ~LLPanelOutfitEdit();
/*virtual*/ BOOL postBuild();
+ /*virtual*/ void onOpen(const LLSD& key);
void moveWearable(bool closer_to_body);
@@ -146,6 +148,7 @@ private:
std::vector<LLLookItemType> mLookItemTypes;
LLCOFWearables* mCOFWearables;
+ bool mInitialized;
};
#endif // LL_LLPANELOUTFITEDIT_H
diff --git a/indra/newview/llpaneloutfitsinventory.cpp b/indra/newview/llpaneloutfitsinventory.cpp
index ea75c16c56..0760c57f8e 100644
--- a/indra/newview/llpaneloutfitsinventory.cpp
+++ b/indra/newview/llpaneloutfitsinventory.cpp
@@ -73,7 +73,8 @@ static LLRegisterPanelClassWrapper<LLPanelOutfitsInventory> t_inventory("panel_o
LLPanelOutfitsInventory::LLPanelOutfitsInventory() :
mMyOutfitsPanel(NULL),
mCurrentOutfitPanel(NULL),
- mParent(NULL)
+ mParent(NULL),
+ mInitialized(false)
{
mSavedFolderState = new LLSaveFolderState();
mSavedFolderState->setApply(FALSE);
@@ -106,6 +107,18 @@ BOOL LLPanelOutfitsInventory::postBuild()
// virtual
void LLPanelOutfitsInventory::onOpen(const LLSD& key)
{
+ if (!mInitialized)
+ {
+ LLSidepanelAppearance* panel_appearance = getAppearanceSP();
+ if (panel_appearance)
+ {
+ // *TODO: move these methods to LLPanelOutfitsInventory?
+ panel_appearance->fetchInventory();
+ panel_appearance->refreshCurrentOutfitName();
+ }
+ mInitialized = true;
+ }
+
// Make sure we know which tab is selected, update the filter,
// and update verbs.
onTabChange();
@@ -249,8 +262,7 @@ bool LLPanelOutfitsInventory::onSaveCommit(const LLSD& notification, const LLSD&
{
LLUUID outfit_folder = LLAppearanceMgr::getInstance()->makeNewOutfitLinks(outfit_name);
- LLSidepanelAppearance* panel_appearance =
- dynamic_cast<LLSidepanelAppearance *>(LLSideTray::getInstance()->getPanel("sidepanel_appearance"));
+ LLSidepanelAppearance* panel_appearance = getAppearanceSP();
if (panel_appearance)
{
panel_appearance->showOutfitsInventoryPanel();
@@ -661,3 +673,11 @@ void LLPanelOutfitsInventory::onWearablesLoaded()
{
setWearablesLoading(false);
}
+
+LLSidepanelAppearance* LLPanelOutfitsInventory::getAppearanceSP()
+{
+ static LLSidepanelAppearance* panel_appearance =
+ dynamic_cast<LLSidepanelAppearance*>
+ (LLSideTray::getInstance()->getPanel("sidepanel_appearance"));
+ return panel_appearance;
+}
diff --git a/indra/newview/llpaneloutfitsinventory.h b/indra/newview/llpaneloutfitsinventory.h
index 6b4d1dbd84..a0fe91cd80 100644
--- a/indra/newview/llpaneloutfitsinventory.h
+++ b/indra/newview/llpaneloutfitsinventory.h
@@ -49,6 +49,7 @@ class LLTabContainer;
class LLPanelOutfitsInventory : public LLPanel
{
+ LOG_CLASS(LLPanelOutfitsInventory);
public:
LLPanelOutfitsInventory();
virtual ~LLPanelOutfitsInventory();
@@ -72,6 +73,7 @@ public:
void setParent(LLSidepanelAppearance *parent);
LLFolderView* getRootFolder();
+ LLSidepanelAppearance* getAppearanceSP();
static LLPanelOutfitsInventory* findInstance();
@@ -132,6 +134,8 @@ private:
// List Commands //
////////////////////////////////////////////////////////////////////////////////
///
+
+ bool mInitialized;
};
#endif //LL_LLPANELOUTFITSINVENTORY_H
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
diff --git a/indra/newview/llsidepanelappearance.h b/indra/newview/llsidepanelappearance.h
index a919b07ed6..f243bbd471 100644
--- a/indra/newview/llsidepanelappearance.h
+++ b/indra/newview/llsidepanelappearance.h
@@ -47,6 +47,7 @@ class LLPanelOutfitsInventory;
class LLSidepanelAppearance : public LLPanel
{
+ LOG_CLASS(LLSidepanelAppearance);
public:
LLSidepanelAppearance();
virtual ~LLSidepanelAppearance();
@@ -56,14 +57,15 @@ public:
void refreshCurrentOutfitName(const std::string& name = "");
- static void editWearable(LLWearable *wearable, void *data);
+ static void editWearable(LLWearable *wearable, LLView *data);
void fetchInventory();
void inventoryFetched();
void onNewOutfitButtonClicked();
void showOutfitsInventoryPanel();
- void showOutfitEditPanel(bool update);
+ void showOutfitEditPanel();
+ void showWearableEditPanel(LLWearable *wearable = NULL);
void setWearablesLoading(bool val);
private:
@@ -71,10 +73,8 @@ private:
void onOpenOutfitButtonClicked();
void onEditAppearanceButtonClicked();
- void onEditOutfitButtonClicked();
- void onEditWearBackClicked();
- //@deprecated use showXXX() methods instead
+ void togglMyOutfitsPanel(BOOL visible);
void toggleOutfitEditPanel(BOOL visible);
void toggleWearableEditPanel(BOOL visible, LLWearable* wearable = NULL);
@@ -100,6 +100,9 @@ private:
// Search string for filtering landmarks and teleport
// history locations
std::string mFilterSubString;
+
+ // Gets set to true when we're opened for the first time.
+ bool mOpened;
};
#endif //LL_LLSIDEPANELAPPEARANCE_H
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index c245650d51..a14fbdca82 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -3629,6 +3629,14 @@ class LLEditEnableCustomizeAvatar : public view_listener_t
}
};
+class LLEnableEditShape : public view_listener_t
+{
+ bool handleEvent(const LLSD& userdata)
+ {
+ return gAgentWearables.isWearableModifiable(LLWearableType::WT_SHAPE, 0);
+ }
+};
+
bool enable_sit_object()
{
LLViewerObject* object = LLSelectMgr::getInstance()->getSelection()->getPrimaryObject();
@@ -5600,6 +5608,11 @@ void handle_customize_avatar()
LLSideTray::getInstance()->showPanel("sidepanel_appearance", LLSD().with("type", "my_outfits"));
}
+void handle_edit_shape()
+{
+ LLSideTray::getInstance()->showPanel("sidepanel_appearance", LLSD().with("type", "edit_shape"));
+}
+
void handle_report_abuse()
{
// Prevent menu from appearing in screen shot.
@@ -7716,7 +7729,9 @@ void initialize_menus()
view_listener_t::addMenu(new LLEditEnableDuplicate(), "Edit.EnableDuplicate");
view_listener_t::addMenu(new LLEditEnableTakeOff(), "Edit.EnableTakeOff");
view_listener_t::addMenu(new LLEditEnableCustomizeAvatar(), "Edit.EnableCustomizeAvatar");
+ view_listener_t::addMenu(new LLEnableEditShape(), "Edit.EnableEditShape");
commit.add("CustomizeAvatar", boost::bind(&handle_customize_avatar));
+ commit.add("EditShape", boost::bind(&handle_edit_shape));
// View menu
view_listener_t::addMenu(new LLViewMouselook(), "View.Mouselook");
diff --git a/indra/newview/skins/default/xui/en/menu_avatar_self.xml b/indra/newview/skins/default/xui/en/menu_avatar_self.xml
index 0efe598243..b0cfb261cb 100644
--- a/indra/newview/skins/default/xui/en/menu_avatar_self.xml
+++ b/indra/newview/skins/default/xui/en/menu_avatar_self.xml
@@ -191,6 +191,15 @@
<menu_item_call.on_enable
function="Edit.EnableCustomizeAvatar" />
</menu_item_call>
+ <menu_item_call
+ label="Edit My Shape"
+ layout="topleft"
+ name="Edit My Shape">
+ <menu_item_call.on_click
+ function="EditShape" />
+ <menu_item_call.on_enable
+ function="Edit.EnableEditShape" />
+ </menu_item_call>
<menu_item_call
label="My Friends"
layout="topleft"
diff --git a/indra/newview/skins/default/xui/en/sidepanel_appearance.xml b/indra/newview/skins/default/xui/en/sidepanel_appearance.xml
index 6a3c148456..32fa6c3b5a 100644
--- a/indra/newview/skins/default/xui/en/sidepanel_appearance.xml
+++ b/indra/newview/skins/default/xui/en/sidepanel_appearance.xml
@@ -120,6 +120,7 @@ width="333">
height="493"
min_height="410"
width="320"
+ visible="false"
left="0"
tab_group="1"
top_pad="6"