diff options
| author | Leslie Linden <none@none> | 2011-06-06 17:00:59 -0700 |
|---|---|---|
| committer | Leslie Linden <none@none> | 2011-06-06 17:00:59 -0700 |
| commit | 98bcd9e2efe4cc0dc5e51da09c6f18424b9d9144 (patch) | |
| tree | bc60274730d7515c1088f7d4a99cb6308297474b /indra/newview/llsidepanelinventory.cpp | |
| parent | 0c0f7558782edccda375609777967184b8440441 (diff) | |
EXP-859 FIX -- Save setting for last time inbox expanded
EXP-841 PROGRESS -- Create outbox sync button with basic enable/disable logic and animation
EXP-866 PROGRESS -- Create inbox observer to dynamically update inbox item count and badge value
EXP-872 PROGRESS -- Hide inbox and outbox unless applicable
Inbox expansion time is now saved as setting variable "LastInventoryInboxExpand".
New outbox sync button art.
Observers for items and categories are now implemented in the LLSidepanelInventory but the exact
method of use is still to be determined.
Functions are in place to show and hide the inbox and outbox panels but the logic around the
decision is TBD.
The resize bar for the inbox/outbox is now disabled when both inbox and outbox are collapsed.
Reviewed by Leyla.
Diffstat (limited to 'indra/newview/llsidepanelinventory.cpp')
| -rw-r--r-- | indra/newview/llsidepanelinventory.cpp | 235 |
1 files changed, 205 insertions, 30 deletions
diff --git a/indra/newview/llsidepanelinventory.cpp b/indra/newview/llsidepanelinventory.cpp index 301322d24b..ae2ac4b5e5 100644 --- a/indra/newview/llsidepanelinventory.cpp +++ b/indra/newview/llsidepanelinventory.cpp @@ -31,32 +31,116 @@ #include "llappearancemgr.h" #include "llavataractions.h" #include "llbutton.h" +#include "lldate.h" #include "llfirstuse.h" +#include "llfoldertype.h" #include "llinventorybridge.h" #include "llinventoryfunctions.h" +#include "llinventorymodel.h" +#include "llinventorymodelbackgroundfetch.h" +#include "llinventoryobserver.h" #include "llinventorypanel.h" +#include "lllayoutstack.h" #include "lloutfitobserver.h" #include "llpanelmaininventory.h" +#include "llselectmgr.h" #include "llsidepaneliteminfo.h" #include "llsidepaneltaskinfo.h" #include "lltabcontainer.h" -#include "llselectmgr.h" #include "llweb.h" -#include "lllayoutstack.h" static LLRegisterPanelClassWrapper<LLSidepanelInventory> t_inventory("sidepanel_inventory"); -LLSidepanelInventory::LLSidepanelInventory() - : LLPanel(), - mItemPanel(NULL), - mPanelMainInventory(NULL) +// +// Constants +// + +static const char * const INBOX_EXPAND_TIME_SETTING = "LastInventoryInboxExpand"; + +static const char * const INBOX_BUTTON_NAME = "inbox_btn"; +static const char * const OUTBOX_BUTTON_NAME = "outbox_btn"; + +static const char * const INBOX_LAYOUT_PANEL_NAME = "inbox_layout_panel"; +static const char * const OUTBOX_LAYOUT_PANEL_NAME = "outbox_layout_panel"; +static const char * const MAIN_INVENTORY_LAYOUT_PANEL = "main_inventory_layout_panel"; + +static const char * const INVENTORY_LAYOUT_STACK_NAME = "inventory_layout_stack"; + +// +// Helpers +// + +class LLInboxOutboxInventoryAddedObserver : public LLInventoryAddedObserver { +public: + LLInboxOutboxInventoryAddedObserver(LLSidepanelInventory * sidepanelInventory) + : LLInventoryAddedObserver() + , mSidepanelInventory(sidepanelInventory) + {} + +protected: + virtual void done() + { + uuid_vec_t::const_iterator it = mAdded.begin(); + uuid_vec_t::const_iterator it_end = mAdded.end(); + + for(; it != it_end; ++it) + { + LLInventoryObject* item = gInventory.getObject(*it); + + // NOTE: This doesn't actually work because folder creation does not trigger this observer + if (item && item->getType() == LLAssetType::AT_CATEGORY) + { + // Check for FolderType FT_INBOX or FT_OUTBOX and report back to mSidepanelInventory + LLInventoryCategory * item_cat = static_cast<LLInventoryCategory *>(item); + LLFolderType::EType folderType = item_cat->getPreferredType(); + + if (folderType == LLFolderType::FT_INBOX) + { + mSidepanelInventory->enableInbox(true); + } + else if (folderType == LLFolderType::FT_OUTBOX) + { + mSidepanelInventory->enableOutbox(true); + } + } + } + + mAdded.clear(); + } +private: + LLSidepanelInventory * mSidepanelInventory; +}; + +// +// Implementation +// + +LLSidepanelInventory::LLSidepanelInventory() + : LLPanel() + , mItemPanel(NULL) + , mPanelMainInventory(NULL) + , mInventoryFetched(false) + , mCategoriesObserver(NULL) + , mInboxOutboxAddedObserver(NULL) +{ //buildFromFile( "panel_inventory.xml"); // Called from LLRegisterPanelClass::defaultPanelClassBuilder() } LLSidepanelInventory::~LLSidepanelInventory() { + if (mInboxOutboxAddedObserver && gInventory.containsObserver(mInboxOutboxAddedObserver)) + { + gInventory.removeObserver(mInboxOutboxAddedObserver); + } + delete mInboxOutboxAddedObserver; + + if (mCategoriesObserver && gInventory.containsObserver(mCategoriesObserver)) + { + gInventory.removeObserver(mCategoriesObserver); + } + delete mCategoriesObserver; } BOOL LLSidepanelInventory::postBuild() @@ -122,32 +206,110 @@ BOOL LLSidepanelInventory::postBuild() // Marketplace inbox/outbox setup { - LLButton * inboxButton = getChild<LLButton>("inbox_btn"); - LLButton * outboxButton = getChild<LLButton>("outbox_btn"); + LLButton * inbox_button = getChild<LLButton>(INBOX_BUTTON_NAME); + LLButton * outbox_button = getChild<LLButton>(OUTBOX_BUTTON_NAME); + + LLLayoutStack* stack = getChild<LLLayoutStack>(INVENTORY_LAYOUT_STACK_NAME); + + LLLayoutPanel * inbox_panel = getChild<LLLayoutPanel>(INBOX_LAYOUT_PANEL_NAME); + LLLayoutPanel * outbox_panel = getChild<LLLayoutPanel>(OUTBOX_LAYOUT_PANEL_NAME); + + stack->collapsePanel(inbox_panel, true); + stack->collapsePanel(outbox_panel, true); - inboxButton->setCommitCallback(boost::bind(&LLSidepanelInventory::onToggleInboxBtn, this)); - outboxButton->setCommitCallback(boost::bind(&LLSidepanelInventory::onToggleOutboxBtn, this)); + inbox_button->setToggleState(false); + outbox_button->setToggleState(false); - LLLayoutStack* stack = getChild<LLLayoutStack>("inventory_layout_stack"); + inbox_button->setCommitCallback(boost::bind(&LLSidepanelInventory::onToggleInboxBtn, this)); + outbox_button->setCommitCallback(boost::bind(&LLSidepanelInventory::onToggleOutboxBtn, this)); + + // TODO: Hide inbox/outbox panels until we determine the status of the feature + //inbox_panel->setVisible(false); + //outbox_panel->setVisible(false); - stack->collapsePanel(getChild<LLLayoutPanel>("inbox_layout_panel"), true); - stack->collapsePanel(getChild<LLLayoutPanel>("outbox_layout_panel"), true); + // Track added items + mInboxOutboxAddedObserver = new LLInboxOutboxInventoryAddedObserver(this); + gInventory.addObserver(mInboxOutboxAddedObserver); - inboxButton->setToggleState(false); - outboxButton->setToggleState(false); + // Track inbox and outbox folder changes + const bool do_not_create_folder = false; + const bool do_not_find_in_library = false; + + const LLUUID inbox_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_INBOX, do_not_create_folder, do_not_find_in_library); + const LLUUID outbox_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_OUTBOX, do_not_create_folder, do_not_find_in_library); + + mCategoriesObserver = new LLInventoryCategoriesObserver(); + gInventory.addObserver(mCategoriesObserver); + + mCategoriesObserver->addCategory(inbox_id, boost::bind(&LLSidepanelInventory::onInboxChanged, this, inbox_id)); + mCategoriesObserver->addCategory(outbox_id, boost::bind(&LLSidepanelInventory::onOutboxChanged, this, outbox_id)); } return TRUE; } +void LLSidepanelInventory::draw() +{ + if (!mInventoryFetched && LLInventoryModelBackgroundFetch::instance().isEverythingFetched()) + { + mInventoryFetched = true; + + updateInboxOutboxPanels(); + } + + LLPanel::draw(); +} + +void LLSidepanelInventory::updateInboxOutboxPanels() +{ + // Iterate through gInventory looking for inbox and outbox + const bool do_not_create_folder = false; + const bool do_not_find_in_library = false; + + const LLUUID inbox_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_INBOX, do_not_create_folder, do_not_find_in_library); + const LLUUID outbox_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_OUTBOX, do_not_create_folder, do_not_find_in_library); + + enableInbox(inbox_id.notNull()); + enableOutbox(outbox_id.notNull()); +} + +void LLSidepanelInventory::enableInbox(bool enabled) +{ + getChild<LLLayoutPanel>(INBOX_LAYOUT_PANEL_NAME)->setVisible(enabled); +} + +void LLSidepanelInventory::enableOutbox(bool enabled) +{ + getChild<LLLayoutPanel>(OUTBOX_LAYOUT_PANEL_NAME)->setVisible(enabled); +} -void manageInboxOutboxPanels(LLLayoutStack * stack, +void LLSidepanelInventory::onInboxChanged(const LLUUID& inbox_id) +{ + // Perhaps use this to track inbox changes? +} + +void LLSidepanelInventory::onOutboxChanged(const LLUUID& outbox_id) +{ + // Perhaps use this to track outbox changes? +} + +bool manageInboxOutboxPanels(LLLayoutStack * stack, LLButton * pressedButton, LLLayoutPanel * pressedPanel, LLButton * otherButton, LLLayoutPanel * otherPanel) { bool expand = pressedButton->getToggleState(); bool otherExpanded = otherButton->getToggleState(); + // + // NOTE: Ideally we could have two panel sizes stored for a collapsed and expanded minimum size. + // For now, leave this code disabled because it creates some bad artifacts when expanding + // and collapsing the inbox/outbox. + // + //S32 smallMinSize = (expand ? pressedPanel->getMinDim() : otherPanel->getMinDim()); + //S32 pressedMinSize = (expand ? 2 * smallMinSize : smallMinSize); + //otherPanel->setMinDim(smallMinSize); + //pressedPanel->setMinDim(pressedMinSize); + if (expand && otherExpanded) { // Reshape pressedPanel to the otherPanel's height so we preserve the marketplace panel size @@ -159,33 +321,46 @@ void manageInboxOutboxPanels(LLLayoutStack * stack, stack->collapsePanel(pressedPanel, !expand); - // Enable user_resize on main inventory panel when at least one marketplace box is expanded - stack->setPanelUserResize("main_inventory_layout_panel", expand); + // Enable user_resize on main inventory panel only when a marketplace box is expanded + stack->setPanelUserResize(MAIN_INVENTORY_LAYOUT_PANEL, expand); + + return expand; } void LLSidepanelInventory::onToggleInboxBtn() { - LLLayoutStack* stack = getChild<LLLayoutStack>("inventory_layout_stack"); - LLButton* pressedButton = getChild<LLButton>("inbox_btn"); - LLLayoutPanel* pressedPanel = getChild<LLLayoutPanel>("inbox_layout_panel"); - LLButton* otherButton = getChild<LLButton>("outbox_btn"); - LLLayoutPanel* otherPanel = getChild<LLLayoutPanel>("outbox_layout_panel"); + LLLayoutStack* stack = getChild<LLLayoutStack>(INVENTORY_LAYOUT_STACK_NAME); + LLButton* pressedButton = getChild<LLButton>(INBOX_BUTTON_NAME); + LLLayoutPanel* pressedPanel = getChild<LLLayoutPanel>(INBOX_LAYOUT_PANEL_NAME); + LLButton* otherButton = getChild<LLButton>(OUTBOX_BUTTON_NAME); + LLLayoutPanel* otherPanel = getChild<LLLayoutPanel>(OUTBOX_LAYOUT_PANEL_NAME); - manageInboxOutboxPanels(stack, pressedButton, pressedPanel, otherButton, otherPanel); + bool inboxExpanded = manageInboxOutboxPanels(stack, pressedButton, pressedPanel, otherButton, otherPanel); + + if (inboxExpanded) + { + // Save current time as a setting for future new-ness tests + gSavedSettings.setString(INBOX_EXPAND_TIME_SETTING, LLDate::now().asString()); + + // TODO: Hide inbox badge + } + else + { + // TODO: Show inbox badge + } } void LLSidepanelInventory::onToggleOutboxBtn() { - LLLayoutStack* stack = getChild<LLLayoutStack>("inventory_layout_stack"); - LLButton* pressedButton = getChild<LLButton>("outbox_btn"); - LLLayoutPanel* pressedPanel = getChild<LLLayoutPanel>("outbox_layout_panel"); - LLButton* otherButton = getChild<LLButton>("inbox_btn"); - LLLayoutPanel* otherPanel = getChild<LLLayoutPanel>("inbox_layout_panel"); + LLLayoutStack* stack = getChild<LLLayoutStack>(INVENTORY_LAYOUT_STACK_NAME); + LLButton* pressedButton = getChild<LLButton>(OUTBOX_BUTTON_NAME); + LLLayoutPanel* pressedPanel = getChild<LLLayoutPanel>(OUTBOX_LAYOUT_PANEL_NAME); + LLButton* otherButton = getChild<LLButton>(INBOX_BUTTON_NAME); + LLLayoutPanel* otherPanel = getChild<LLLayoutPanel>(INBOX_LAYOUT_PANEL_NAME); manageInboxOutboxPanels(stack, pressedButton, pressedPanel, otherButton, otherPanel); } - void LLSidepanelInventory::onOpen(const LLSD& key) { LLFirstUse::newInventory(false); |
