From ec9da605c120b9df648eb163dc8647f955275f5f Mon Sep 17 00:00:00 2001 From: Loren Shih Date: Wed, 4 Nov 2009 16:25:13 -0500 Subject: EXT-2216 : Task properties sidepanel Subclassing sidepanel item/task info with llsidepanelinventorysubpanel. Some bug fixing and cleanup. --HG-- branch : avatar-pipeline --- indra/newview/CMakeLists.txt | 2 + indra/newview/llsidepanelinventory.cpp | 5 +- indra/newview/llsidepanelinventorysubpanel.cpp | 155 +++++++++++++++++++++++++ indra/newview/llsidepanelinventorysubpanel.h | 82 +++++++++++++ indra/newview/llsidepaneliteminfo.cpp | 104 ++--------------- indra/newview/llsidepaneliteminfo.h | 34 ++---- indra/newview/llsidepaneltaskinfo.cpp | 61 ++++++---- indra/newview/llsidepaneltaskinfo.h | 17 +-- 8 files changed, 305 insertions(+), 155 deletions(-) create mode 100644 indra/newview/llsidepanelinventorysubpanel.cpp create mode 100644 indra/newview/llsidepanelinventorysubpanel.h (limited to 'indra') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index c490c31393..b3de276e9c 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -370,6 +370,7 @@ set(viewer_SOURCE_FILES llsearchhistory.cpp llselectmgr.cpp llsidepanelinventory.cpp + llsidepanelinventorysubpanel.cpp llsidepaneliteminfo.cpp llsidepaneltaskinfo.cpp llsidetray.cpp @@ -856,6 +857,7 @@ set(viewer_HEADER_FILES llsearchhistory.h llselectmgr.h llsidepanelinventory.h + llsidepanelinventorysubpanel.h llsidepaneliteminfo.h llsidepaneltaskinfo.h llsidetray.h diff --git a/indra/newview/llsidepanelinventory.cpp b/indra/newview/llsidepanelinventory.cpp index 9b67bc701d..c4779cd29a 100644 --- a/indra/newview/llsidepanelinventory.cpp +++ b/indra/newview/llsidepanelinventory.cpp @@ -186,7 +186,7 @@ void LLSidepanelInventory::showItemInfoPanel() mInventoryPanel->setVisible(FALSE); mItemPanel->dirty(); - mItemPanel->setEditMode(FALSE); + mItemPanel->setIsEditing(FALSE); } void LLSidepanelInventory::showTaskInfoPanel() @@ -194,6 +194,9 @@ void LLSidepanelInventory::showTaskInfoPanel() mItemPanel->setVisible(FALSE); mTaskPanel->setVisible(TRUE); mInventoryPanel->setVisible(FALSE); + + mTaskPanel->dirty(); + mTaskPanel->setIsEditing(FALSE); } void LLSidepanelInventory::showInventoryPanel() diff --git a/indra/newview/llsidepanelinventorysubpanel.cpp b/indra/newview/llsidepanelinventorysubpanel.cpp new file mode 100644 index 0000000000..8522456777 --- /dev/null +++ b/indra/newview/llsidepanelinventorysubpanel.cpp @@ -0,0 +1,155 @@ +/** + * @file llsidepanelinventorysubpanel.cpp + * @brief A floater which shows an inventory item's properties. + * + * $LicenseInfo:firstyear=2002&license=viewergpl$ + * + * Copyright (c) 2002-2009, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" +#include "llsidepanelinventorysubpanel.h" + +#include "roles_constants.h" + +#include "llagent.h" +#include "llavataractions.h" +#include "llbutton.h" +#include "llfloaterreg.h" +#include "llgroupactions.h" +#include "llinventorymodel.h" +#include "lllineeditor.h" +#include "llradiogroup.h" +#include "llviewercontrol.h" +#include "llviewerinventory.h" +#include "llviewerobjectlist.h" + + +///---------------------------------------------------------------------------- +/// Class LLSidepanelInventorySubpanel +///---------------------------------------------------------------------------- + +// Default constructor +LLSidepanelInventorySubpanel::LLSidepanelInventorySubpanel() + : LLPanel(), + mIsDirty(TRUE), + mIsEditing(FALSE), + mEditBtn(NULL), + mCancelBtn(NULL), + mSaveBtn(NULL) +{ +} + +// Destroys the object +LLSidepanelInventorySubpanel::~LLSidepanelInventorySubpanel() +{ +} + +// virtual +BOOL LLSidepanelInventorySubpanel::postBuild() +{ + mEditBtn = getChild("edit_btn"); + mEditBtn->setClickedCallback(boost::bind(&LLSidepanelInventorySubpanel::onEditButtonClicked, this)); + + mSaveBtn = getChild("save_btn"); + mSaveBtn->setClickedCallback(boost::bind(&LLSidepanelInventorySubpanel::onSaveButtonClicked, this)); + + mCancelBtn = getChild("cancel_btn"); + mCancelBtn->setClickedCallback(boost::bind(&LLSidepanelInventorySubpanel::onCancelButtonClicked, this)); + return TRUE; +} + +void LLSidepanelInventorySubpanel::setVisible(BOOL visible) +{ + if (visible) + { + dirty(); + setIsEditing(FALSE); + } + LLPanel::setVisible(visible); +} + +void LLSidepanelInventorySubpanel::setIsEditing(BOOL edit) +{ + mIsEditing = edit; + mIsDirty = TRUE; +} + +BOOL LLSidepanelInventorySubpanel::getIsEditing() const +{ + return mIsEditing; +} + +void LLSidepanelInventorySubpanel::reset() +{ + mIsDirty = TRUE; +} + +void LLSidepanelInventorySubpanel::draw() +{ + if (mIsDirty) + { + mIsDirty = FALSE; + refresh(); + updateVerbs(); + } + + LLPanel::draw(); +} + +void LLSidepanelInventorySubpanel::dirty() +{ + mIsDirty = TRUE; +} + +void LLSidepanelInventorySubpanel::updateVerbs() +{ + mEditBtn->setVisible(!mIsEditing); + mSaveBtn->setVisible(mIsEditing); + mCancelBtn->setVisible(mIsEditing); +} + +void LLSidepanelInventorySubpanel::onEditButtonClicked() +{ + setIsEditing(TRUE); + refresh(); + updateVerbs(); +} + +void LLSidepanelInventorySubpanel::onSaveButtonClicked() +{ + save(); + setIsEditing(FALSE); + refresh(); + updateVerbs(); +} + +void LLSidepanelInventorySubpanel::onCancelButtonClicked() +{ + setIsEditing(FALSE); + refresh(); + updateVerbs(); +} diff --git a/indra/newview/llsidepanelinventorysubpanel.h b/indra/newview/llsidepanelinventorysubpanel.h new file mode 100644 index 0000000000..6503887cd1 --- /dev/null +++ b/indra/newview/llsidepanelinventorysubpanel.h @@ -0,0 +1,82 @@ +/** + * @file llsidepanelinventorysubpanel.h + * @brief A panel which shows an inventory item's properties. + * + * $LicenseInfo:firstyear=2002&license=viewergpl$ + * + * Copyright (c) 2002-2009, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#ifndef LL_LLSIDEPANELINVENTORYSUBPANEL_H +#define LL_LLSIDEPANELINVENTORYSUBPANEL_H + +#include "llpanel.h" + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Class LLSidepanelInventorySubpanel +// Base class for inventory sidepanel panels (e.g. item info, task info). +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +class LLButton; +class LLInventoryItem; + +class LLSidepanelInventorySubpanel : public LLPanel +{ +public: + LLSidepanelInventorySubpanel(); + virtual ~LLSidepanelInventorySubpanel(); + + /*virtual*/ void setVisible(BOOL visible); + virtual BOOL postBuild(); + virtual void draw(); + virtual void reset(); + + void dirty(); + void setIsEditing(BOOL edit); +protected: + virtual void refresh() = 0; + virtual void save() = 0; + virtual void updateVerbs(); + + BOOL getIsEditing() const; + + // + // UI Elements + // +protected: + void onEditButtonClicked(); + void onSaveButtonClicked(); + void onCancelButtonClicked(); + LLButton* mEditBtn; + LLButton* mSaveBtn; + LLButton* mCancelBtn; + +private: + BOOL mIsDirty; // item properties need to be updated + BOOL mIsEditing; // if we're in edit mode +}; + +#endif // LL_LLSIDEPANELINVENTORYSUBPANEL_H diff --git a/indra/newview/llsidepaneliteminfo.cpp b/indra/newview/llsidepaneliteminfo.cpp index c857afc652..d36ffc9a9c 100644 --- a/indra/newview/llsidepaneliteminfo.cpp +++ b/indra/newview/llsidepaneliteminfo.cpp @@ -89,10 +89,7 @@ static LLRegisterPanelClassWrapper t_item_info("sidepanel_i // Default constructor LLSidepanelItemInfo::LLSidepanelItemInfo() - : LLPanel(), - mItemID(LLUUID::null), - mDirty(TRUE), - mEditMode(FALSE) + : mItemID(LLUUID::null) { mPropertiesObserver = new LLItemPropertiesObserver(this); @@ -109,14 +106,7 @@ LLSidepanelItemInfo::~LLSidepanelItemInfo() // virtual BOOL LLSidepanelItemInfo::postBuild() { - mEditBtn = getChild("edit_btn"); - mEditBtn->setClickedCallback(boost::bind(&LLSidepanelItemInfo::onEditButtonClicked, this)); - - mSaveBtn = getChild("save_btn"); - mSaveBtn->setClickedCallback(boost::bind(&LLSidepanelItemInfo::onSaveButtonClicked, this)); - - mCancelBtn = getChild("cancel_btn"); - mCancelBtn->setClickedCallback(boost::bind(&LLSidepanelItemInfo::onCancelButtonClicked, this)); + LLSidepanelInventorySubpanel::postBuild(); // build the UI // item name & description @@ -131,42 +121,10 @@ BOOL LLSidepanelItemInfo::postBuild() // owner information getChild("BtnOwner")->setCommitCallback(boost::bind(&LLSidepanelItemInfo::onClickOwner,this)); - // acquired date - // owner permissions - // Permissions debug text - // group permissions - // getChild("CheckShareWithGroup")->setCommitCallback(boost::bind(&LLSidepanelItemInfo::onCommitPermissions, this)); - - // everyone permissions - // getChild("CheckEveryoneCopy")->setCommitCallback(boost::bind(&LLSidepanelItemInfo::onCommitPermissions, this)); - - // next owner permissions - // getChild("CheckNextOwnerModify")->setCommitCallback(boost::bind(&LLSidepanelItemInfo::onCommitPermissions, this)); - // getChild("CheckNextOwnerCopy")->setCommitCallback(boost::bind(&LLSidepanelItemInfo::onCommitPermissions, this)); - // getChild("CheckNextOwnerTransfer")->setCommitCallback(boost::bind(&LLSidepanelItemInfo::onCommitPermissions, this)); - - // Mark for sale or not, and sale info - // getChild("CheckPurchase")->setCommitCallback(boost::bind(&LLSidepanelItemInfo::onCommitSaleInfo, this)); - // getChild("RadioSaleType")->setCommitCallback(boost::bind(&LLSidepanelItemInfo::onCommitSaleType, this)); - - // "Price" label for edit - // getChild("Edit Cost")->setCommitCallback(boost::bind(&LLSidepanelItemInfo::onCommitSaleInfo, this)); - - // The UI has been built, now fill in all the values refresh(); - return TRUE; } -void LLSidepanelItemInfo::setVisible(BOOL visible) -{ - if (visible) - { - mDirty = TRUE; - } - LLPanel::setVisible(visible); -} - void LLSidepanelItemInfo::setObjectID(const LLUUID& object_id) { mObjectID = object_id; @@ -177,17 +135,12 @@ void LLSidepanelItemInfo::setItemID(const LLUUID& item_id) mItemID = item_id; } -void LLSidepanelItemInfo::setEditMode(BOOL edit) -{ - mEditMode = edit; - mDirty = TRUE; -} - void LLSidepanelItemInfo::reset() { + LLSidepanelInventorySubpanel::reset(); + mObjectID = LLUUID::null; mItemID = LLUUID::null; - mDirty = TRUE; } void LLSidepanelItemInfo::refresh() @@ -199,13 +152,8 @@ void LLSidepanelItemInfo::refresh() updateVerbs(); } - if (!mEditMode || !item) + if (!getIsEditing() || !item) { - //RN: it is possible that the container object is in the middle of an inventory refresh - // causing findItem() to fail, so just temporarily disable everything - - mDirty = TRUE; - const std::string no_item_names[]={ "LabelItemName", "LabelItemDesc", @@ -257,22 +205,6 @@ void LLSidepanelItemInfo::refresh() updateVerbs(); } -void LLSidepanelItemInfo::draw() -{ - if (mDirty) - { - mDirty = FALSE; - refresh(); - } - - LLPanel::draw(); -} - -void LLSidepanelItemInfo::dirty() -{ - mDirty = TRUE; -} - void LLSidepanelItemInfo::refreshFromItem(LLInventoryItem* item) { //////////////////////// @@ -916,11 +848,10 @@ LLInventoryItem* LLSidepanelItemInfo::findItem() const return item; } +// virtual void LLSidepanelItemInfo::updateVerbs() { - mEditBtn->setVisible(!mEditMode); - mSaveBtn->setVisible(mEditMode); - mCancelBtn->setVisible(mEditMode); + LLSidepanelInventorySubpanel::updateVerbs(); const LLViewerInventoryItem* item = (LLViewerInventoryItem*)findItem(); if (item) @@ -932,29 +863,12 @@ void LLSidepanelItemInfo::updateVerbs() } } -void LLSidepanelItemInfo::onEditButtonClicked() -{ - setEditMode(TRUE); - refresh(); - updateVerbs(); -} - -void LLSidepanelItemInfo::onSaveButtonClicked() +// virtual +void LLSidepanelItemInfo::save() { onCommitName(); onCommitDescription(); onCommitPermissions(); onCommitSaleInfo(); onCommitSaleType(); - - setEditMode(FALSE); - refresh(); - updateVerbs(); -} - -void LLSidepanelItemInfo::onCancelButtonClicked() -{ - setEditMode(FALSE); - refresh(); - updateVerbs(); } diff --git a/indra/newview/llsidepaneliteminfo.h b/indra/newview/llsidepaneliteminfo.h index 9f5ab402ea..b348b5cceb 100644 --- a/indra/newview/llsidepaneliteminfo.h +++ b/indra/newview/llsidepaneliteminfo.h @@ -33,10 +33,7 @@ #ifndef LL_LLSIDEPANELITEMINFO_H #define LL_LLSIDEPANELITEMINFO_H -#include -#include "llmultifloater.h" -#include "lliconctrl.h" -#include "llpermissions.h" +#include "llsidepanelinventorysubpanel.h" //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLSidepanelItemInfo @@ -47,38 +44,34 @@ class LLButton; class LLInventoryItem; class LLItemPropertiesObserver; class LLViewerObject; +class LLPermissions; -class LLSidepanelItemInfo : public LLPanel +class LLSidepanelItemInfo : public LLSidepanelInventorySubpanel { public: LLSidepanelItemInfo(); virtual ~LLSidepanelItemInfo(); /*virtual*/ BOOL postBuild(); - /*virtual*/ void setVisible(BOOL visible); - /*virtual*/ void draw(); + /*virtual*/ void reset(); void setObjectID(const LLUUID& object_id); void setItemID(const LLUUID& item_id); void setEditMode(BOOL edit); - void reset(); - void dirty(); - protected: + /*virtual*/ void refresh(); + /*virtual*/ void save(); + /*virtual*/ void updateVerbs(); + LLInventoryItem* findItem() const; LLViewerObject* findObject() const; - void refresh(); + void refreshFromItem(LLInventoryItem* item); - void refreshFromPermissions(const LLPermissions& perm); - void updateVerbs(); - BOOL isUpdatingObject() const; private: LLUUID mItemID; // inventory UUID for the inventory item. LLUUID mObjectID; // in-world task UUID, or null if in agent inventory. - BOOL mDirty; // item properties need to be updated - BOOL mEditMode; // if we're in edit mode LLItemPropertiesObserver* mPropertiesObserver; // for syncing changes to item // @@ -93,15 +86,6 @@ protected: void onCommitSaleInfo(); void onCommitSaleType(); void updateSaleInfo(); - -protected: - void onEditButtonClicked(); - void onSaveButtonClicked(); - void onCancelButtonClicked(); -private: - LLButton* mEditBtn; - LLButton* mSaveBtn; - LLButton* mCancelBtn; }; #endif // LL_LLSIDEPANELITEMINFO_H diff --git a/indra/newview/llsidepaneltaskinfo.cpp b/indra/newview/llsidepaneltaskinfo.cpp index 203fc35187..3608e2c097 100644 --- a/indra/newview/llsidepaneltaskinfo.cpp +++ b/indra/newview/llsidepaneltaskinfo.cpp @@ -73,14 +73,22 @@ static LLRegisterPanelClassWrapper t_task_info("sidepanel_task_info"); // Default constructor -LLSidepanelTaskInfo::LLSidepanelTaskInfo() : - LLPanel() +LLSidepanelTaskInfo::LLSidepanelTaskInfo() { setMouseOpaque(FALSE); } BOOL LLSidepanelTaskInfo::postBuild() { + LLSidepanelInventorySubpanel::postBuild(); + + mOpenBtn = getChild("open_btn"); + mOpenBtn->setClickedCallback(boost::bind(&LLSidepanelTaskInfo::onOpenButtonClicked, this)); + mBuildBtn = getChild("build_btn"); + mBuildBtn->setClickedCallback(boost::bind(&LLSidepanelTaskInfo::onBuildButtonClicked, this)); + mBuyBtn = getChild("buy_btn"); + mBuyBtn->setClickedCallback(boost::bind(&LLSidepanelTaskInfo::onBuyButtonClicked, this)); + childSetCommitCallback("Object Name",LLSidepanelTaskInfo::onCommitName,this); childSetPrevalidate("Object Name",LLLineEditor::prevalidatePrintableNotPipe); childSetCommitCallback("Object Description",LLSidepanelTaskInfo::onCommitDesc,this); @@ -114,26 +122,6 @@ BOOL LLSidepanelTaskInfo::postBuild() return TRUE; } -void LLSidepanelTaskInfo::setVisible(BOOL visible) -{ - if (visible) - { - mDirty = TRUE; - } - LLPanel::setVisible(visible); -} - -void LLSidepanelTaskInfo::draw() -{ - if (mDirty) - { - mDirty = FALSE; - refresh(); - } - - LLPanel::draw(); -} - LLSidepanelTaskInfo::~LLSidepanelTaskInfo() { // base class will take care of everything @@ -800,6 +788,8 @@ void LLSidepanelTaskInfo::refresh() } childSetEnabled("label click action",is_perm_modify && all_volume); childSetEnabled("clickaction",is_perm_modify && all_volume); + + updateVerbs(); } @@ -1064,3 +1054,30 @@ void LLSidepanelTaskInfo::onCommitIncludeInSearch(LLUICtrl* ctrl, void*) LLSelectMgr::getInstance()->selectionSetIncludeInSearch(box->get()); } +// virtual +void LLSidepanelTaskInfo::updateVerbs() +{ + LLSidepanelInventorySubpanel::updateVerbs(); + + mOpenBtn->setVisible(!getIsEditing()); + mBuildBtn->setVisible(!getIsEditing()); + mBuyBtn->setVisible(!getIsEditing()); +} + +void LLSidepanelTaskInfo::onOpenButtonClicked() +{ +} + +void LLSidepanelTaskInfo::onBuildButtonClicked() +{ +} + +void LLSidepanelTaskInfo::onBuyButtonClicked() +{ +} + +// virtual +void LLSidepanelTaskInfo::save() +{ +} + diff --git a/indra/newview/llsidepaneltaskinfo.h b/indra/newview/llsidepaneltaskinfo.h index 2b9b4b66b6..aea65c1170 100644 --- a/indra/newview/llsidepaneltaskinfo.h +++ b/indra/newview/llsidepaneltaskinfo.h @@ -33,7 +33,7 @@ #ifndef LL_LLSIDEPANELTASKINFO_H #define LL_LLSIDEPANELTASKINFO_H -#include "llpanel.h" +#include "llsidepanelinventorysubpanel.h" #include "lluuid.h" //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -44,18 +44,18 @@ class LLNameBox; -class LLSidepanelTaskInfo : public LLPanel +class LLSidepanelTaskInfo : public LLSidepanelInventorySubpanel { public: LLSidepanelTaskInfo(); virtual ~LLSidepanelTaskInfo(); /*virtual*/ BOOL postBuild(); - /*virtual*/ void draw(); - /*virtual*/ void setVisible(BOOL visible); protected: - void refresh(); // refresh all labels as needed + /*virtual*/ void refresh(); // refresh all labels as needed + /*virtual*/ void save(); + /*virtual*/ void updateVerbs(); // statics static void onClickClaim(void*); @@ -91,19 +91,12 @@ private: LLUUID mCreatorID; LLUUID mOwnerID; LLUUID mLastOwnerID; - BOOL mDirty; // item properties need to be updated protected: - void onEditButtonClicked(); - void onSaveButtonClicked(); - void onCancelButtonClicked(); void onOpenButtonClicked(); void onBuildButtonClicked(); void onBuyButtonClicked(); private: - LLButton* mEditBtn; - LLButton* mSaveBtn; - LLButton* mCancelBtn; LLButton* mOpenBtn; LLButton* mBuildBtn; LLButton* mBuyBtn; -- cgit v1.2.3