From 142c2fc29c9645df1bff924d6a61c09f04713a7b Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Tue, 14 Jun 2011 16:35:15 -0700 Subject: EXP-896 FIX -- Inbox not opened by default when new items are received EXP-894 FIX -- When scrolling to the bottom of the inbox, the last item is c... EXP-856 FIX -- Inbox item count reflected as badge on inventory button * Inbox auto-expands when "fresh" items are reported * Logic for "fresh" item determination is still in progress but works for purchases while logged in * Badges now only displayed when the inventory side panel is collapsed or when inventory not visible Reviewed by Leyla --- indra/newview/llfolderviewitem.h | 10 +++- indra/newview/llpanelmarketplaceinbox.cpp | 65 +++++++++++++++++++--- indra/newview/llpanelmarketplaceinbox.h | 14 ++++- indra/newview/llsidepanelinventory.cpp | 15 +++-- .../skins/default/xui/en/sidepanel_inventory.xml | 61 ++++++++++---------- 5 files changed, 118 insertions(+), 47 deletions(-) diff --git a/indra/newview/llfolderviewitem.h b/indra/newview/llfolderviewitem.h index dbd7d5a370..789e104e8b 100644 --- a/indra/newview/llfolderviewitem.h +++ b/indra/newview/llfolderviewitem.h @@ -167,7 +167,7 @@ protected: void extendSelectionFromRoot(LLFolderViewItem* selection); // this is an internal method used for adding items to folders. A - // no-op at this leve, but reimplemented in derived classes. + // no-op at this level, but reimplemented in derived classes. virtual BOOL addItem(LLFolderViewItem*) { return FALSE; } virtual BOOL addFolder(LLFolderViewFolder*) { return FALSE; } @@ -366,6 +366,9 @@ public: UNKNOWN, TRASH, NOT_TRASH } ETrash; + typedef std::list items_t; + typedef std::list folders_t; + private: S32 mNumDescendantsSelected; @@ -374,8 +377,6 @@ public: // Accessed needed by LLFolderViewItem S32 numSelected(void) const { return mNumDescendantsSelected + (isSelected() ? 1 : 0); } protected: - typedef std::list items_t; - typedef std::list folders_t; items_t mItems; folders_t mFolders; LLInventorySort mSortFunction; @@ -537,6 +538,9 @@ public: time_t getCreationDate() const; bool isTrash() const; S32 getNumSelectedDescendants(void) const { return mNumDescendantsSelected; } + + folders_t::const_iterator getFoldersBegin() const { return mFolders.cbegin(); } + folders_t::const_iterator getFoldersEnd() const { return mFolders.cend(); } }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/indra/newview/llpanelmarketplaceinbox.cpp b/indra/newview/llpanelmarketplaceinbox.cpp index a6d6308dc2..0fe2560fbf 100644 --- a/indra/newview/llpanelmarketplaceinbox.cpp +++ b/indra/newview/llpanelmarketplaceinbox.cpp @@ -34,9 +34,14 @@ static LLRegisterPanelClassWrapper t_panel_marketplace_inbox("panel_marketplace_inbox"); +const LLPanelMarketplaceInbox::Params& LLPanelMarketplaceInbox::getDefaultParams() +{ + return LLUICtrlFactory::getDefaultParams(); +} + // protected -LLPanelMarketplaceInbox::LLPanelMarketplaceInbox() - : LLPanel() +LLPanelMarketplaceInbox::LLPanelMarketplaceInbox(const Params& p) + : LLPanel(p) , mInventoryPanel(NULL) { } @@ -69,7 +74,31 @@ BOOL LLPanelMarketplaceInbox::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL dr return TRUE; } -U32 LLPanelMarketplaceInbox::getItemCount() const +U32 LLPanelMarketplaceInbox::getFreshItemCount() const +{ + U32 fresh_item_count = 0; + + LLFolderView * root_folder = mInventoryPanel->getRootFolder(); + + const LLFolderViewFolder * inbox_folder = *(root_folder->getFoldersBegin()); + + LLFolderViewFolder::folders_t::const_iterator folders_it = inbox_folder->getFoldersBegin(); + LLFolderViewFolder::folders_t::const_iterator folders_end = inbox_folder->getFoldersEnd(); + + for (; folders_it != folders_end; ++folders_it) + { + const LLFolderViewFolder * folder = *folders_it; + + if (folder->getCreationDate() > 1500) + { + fresh_item_count++; + } + } + + return fresh_item_count; +} + +U32 LLPanelMarketplaceInbox::getTotalItemCount() const { LLInventoryModel* model = mInventoryPanel->getModel(); @@ -96,11 +125,16 @@ U32 LLPanelMarketplaceInbox::getItemCount() const std::string LLPanelMarketplaceInbox::getBadgeString() const { std::string item_count_str(""); - U32 item_count = getItemCount(); - if (item_count) + // If side panel collapsed or expanded and not inventory + if (LLSideTray::getInstance()->getCollapsed() || !LLSideTray::getInstance()->isPanelActive("sidepanel_inventory")) { - item_count_str = llformat("%d", item_count); + U32 item_count = getFreshItemCount(); + + if (item_count) + { + item_count_str = llformat("%d", item_count); + } } return item_count_str; @@ -108,17 +142,32 @@ std::string LLPanelMarketplaceInbox::getBadgeString() const void LLPanelMarketplaceInbox::draw() { - std::string item_count_str = getBadgeString(); + U32 item_count = getTotalItemCount(); + + LLView * fresh_new_count_view = getChildView("inbox_fresh_new_count"); - if (item_count_str.length() > 0) + if (item_count > 0) { + std::string item_count_str = llformat("%d", item_count); + LLStringUtil::format_map_t args; args["[NUM]"] = item_count_str; getChild("inbox_btn")->setLabel(getString("InboxLabelWithArg", args)); + + // set green text to fresh item count + U32 fresh_item_count = getFreshItemCount(); + fresh_new_count_view->setVisible((fresh_item_count > 0)); + + if (fresh_item_count > 0) + { + getChild("inbox_fresh_new_count")->setTextArg("[NUM]", llformat("%d", fresh_item_count)); + } } else { getChild("inbox_btn")->setLabel(getString("InboxLabelNoArg")); + + fresh_new_count_view->setVisible(FALSE); } LLPanel::draw(); diff --git a/indra/newview/llpanelmarketplaceinbox.h b/indra/newview/llpanelmarketplaceinbox.h index 61e8cf3c1f..21069a0ea1 100644 --- a/indra/newview/llpanelmarketplaceinbox.h +++ b/indra/newview/llpanelmarketplaceinbox.h @@ -36,9 +36,17 @@ class LLPanelMarketplaceInbox : public LLPanel, public LLSideTrayTabBadgeDriver { public: + struct Params : public LLInitParam::Block + { + Params() {} + }; + LOG_CLASS(LLPanelMarketplaceInbox); - LLPanelMarketplaceInbox(); + // RN: for some reason you can't just use LLUICtrlFactory::getDefaultParams as a default argument in VC8 + static const LLPanelMarketplaceInbox::Params& getDefaultParams(); + + LLPanelMarketplaceInbox(const Params& p = getDefaultParams()); ~LLPanelMarketplaceInbox(); /*virtual*/ BOOL postBuild(); @@ -47,7 +55,9 @@ public: /*virtual*/ void draw(); - U32 getItemCount() const; + U32 getFreshItemCount() const; + U32 getTotalItemCount() const; + std::string getBadgeString() const; private: diff --git a/indra/newview/llsidepanelinventory.cpp b/indra/newview/llsidepanelinventory.cpp index 6ac845385b..33d512d89e 100644 --- a/indra/newview/llsidepanelinventory.cpp +++ b/indra/newview/llsidepanelinventory.cpp @@ -43,6 +43,7 @@ #include "lllayoutstack.h" #include "lloutfitobserver.h" #include "llpanelmaininventory.h" +#include "llpanelmarketplaceinbox.h" #include "llselectmgr.h" #include "llsidepaneliteminfo.h" #include "llsidepaneltaskinfo.h" @@ -341,12 +342,6 @@ void LLSidepanelInventory::onToggleInboxBtn() { // 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 } } @@ -365,6 +360,14 @@ void LLSidepanelInventory::onOpen(const LLSD& key) { LLFirstUse::newInventory(false); + // Expand the inbox if we have fresh items + LLPanelMarketplaceInbox * inbox = getChild("marketplace_inbox"); + if (inbox && (inbox->getFreshItemCount() > 0)) + { + getChild(INBOX_BUTTON_NAME)->setToggleState(true); + onToggleInboxBtn(); + } + if(key.size() == 0) return; diff --git a/indra/newview/skins/default/xui/en/sidepanel_inventory.xml b/indra/newview/skins/default/xui/en/sidepanel_inventory.xml index 373a9011a1..9a91f90f79 100644 --- a/indra/newview/skins/default/xui/en/sidepanel_inventory.xml +++ b/indra/newview/skins/default/xui/en/sidepanel_inventory.xml @@ -54,8 +54,8 @@ follows="bottom|left|right" min_dim="35" name="inbox_layout_panel" - max_dim="125" - height="125"> + max_dim="200" + height="200"> - MARKETPLACE INBOX ([NUM]) - MARKETPLACE INBOX + Received Items ([NUM]) + Received Items