EXT-2216 : Task properties sidepanel

Subclassing sidepanel item/task info with llsidepanelinventorysubpanel.
Some bug fixing and cleanup.

--HG--
branch : avatar-pipeline
meow-7.2.2
Loren Shih 2009-11-04 16:25:13 -05:00
parent 7383cfe14b
commit ec9da605c1
8 changed files with 305 additions and 155 deletions

View File

@ -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

View File

@ -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()

View File

@ -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<LLButton>("edit_btn");
mEditBtn->setClickedCallback(boost::bind(&LLSidepanelInventorySubpanel::onEditButtonClicked, this));
mSaveBtn = getChild<LLButton>("save_btn");
mSaveBtn->setClickedCallback(boost::bind(&LLSidepanelInventorySubpanel::onSaveButtonClicked, this));
mCancelBtn = getChild<LLButton>("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();
}

View File

@ -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

View File

@ -89,10 +89,7 @@ static LLRegisterPanelClassWrapper<LLSidepanelItemInfo> 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<LLButton>("edit_btn");
mEditBtn->setClickedCallback(boost::bind(&LLSidepanelItemInfo::onEditButtonClicked, this));
mSaveBtn = getChild<LLButton>("save_btn");
mSaveBtn->setClickedCallback(boost::bind(&LLSidepanelItemInfo::onSaveButtonClicked, this));
mCancelBtn = getChild<LLButton>("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<LLUICtrl>("BtnOwner")->setCommitCallback(boost::bind(&LLSidepanelItemInfo::onClickOwner,this));
// acquired date
// owner permissions
// Permissions debug text
// group permissions
// getChild<LLUICtrl>("CheckShareWithGroup")->setCommitCallback(boost::bind(&LLSidepanelItemInfo::onCommitPermissions, this));
// everyone permissions
// getChild<LLUICtrl>("CheckEveryoneCopy")->setCommitCallback(boost::bind(&LLSidepanelItemInfo::onCommitPermissions, this));
// next owner permissions
// getChild<LLUICtrl>("CheckNextOwnerModify")->setCommitCallback(boost::bind(&LLSidepanelItemInfo::onCommitPermissions, this));
// getChild<LLUICtrl>("CheckNextOwnerCopy")->setCommitCallback(boost::bind(&LLSidepanelItemInfo::onCommitPermissions, this));
// getChild<LLUICtrl>("CheckNextOwnerTransfer")->setCommitCallback(boost::bind(&LLSidepanelItemInfo::onCommitPermissions, this));
// Mark for sale or not, and sale info
// getChild<LLUICtrl>("CheckPurchase")->setCommitCallback(boost::bind(&LLSidepanelItemInfo::onCommitSaleInfo, this));
// getChild<LLUICtrl>("RadioSaleType")->setCommitCallback(boost::bind(&LLSidepanelItemInfo::onCommitSaleType, this));
// "Price" label for edit
// getChild<LLUICtrl>("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();
}

View File

@ -33,10 +33,7 @@
#ifndef LL_LLSIDEPANELITEMINFO_H
#define LL_LLSIDEPANELITEMINFO_H
#include <map>
#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

View File

@ -73,14 +73,22 @@
static LLRegisterPanelClassWrapper<LLSidepanelTaskInfo> t_task_info("sidepanel_task_info");
// Default constructor
LLSidepanelTaskInfo::LLSidepanelTaskInfo() :
LLPanel()
LLSidepanelTaskInfo::LLSidepanelTaskInfo()
{
setMouseOpaque(FALSE);
}
BOOL LLSidepanelTaskInfo::postBuild()
{
LLSidepanelInventorySubpanel::postBuild();
mOpenBtn = getChild<LLButton>("open_btn");
mOpenBtn->setClickedCallback(boost::bind(&LLSidepanelTaskInfo::onOpenButtonClicked, this));
mBuildBtn = getChild<LLButton>("build_btn");
mBuildBtn->setClickedCallback(boost::bind(&LLSidepanelTaskInfo::onBuildButtonClicked, this));
mBuyBtn = getChild<LLButton>("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()
{
}

View File

@ -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;