From 917e2d18973bd17929d589ee58b3f47a09c7157b Mon Sep 17 00:00:00 2001 From: Leyla Farazha Date: Tue, 21 Jun 2011 14:16:27 -0700 Subject: EXP-895 Selecting items in Marketplace Inbox does not change focus in inventory panel away from items selected in inventory panel --- indra/newview/llfolderview.cpp | 8 +- indra/newview/llpanelmaininventory.cpp | 6 +- indra/newview/llpanelmarketplaceinbox.cpp | 426 +++++++++++++++--------------- indra/newview/llpanelmarketplaceinbox.h | 2 + indra/newview/llsidepanelinventory.h | 3 +- 5 files changed, 227 insertions(+), 218 deletions(-) diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp index 3884b94b60..ba6fa18aab 100644 --- a/indra/newview/llfolderview.cpp +++ b/indra/newview/llfolderview.cpp @@ -806,13 +806,7 @@ void LLFolderView::sanitizeSelection() } else { - // nothing selected to start with, so pick "My Inventory" as best guess - new_selection = getItemByID(gInventory.getRootFolderID()); - // ... except if it's hidden from the UI. - if (new_selection && new_selection->getHidden()) - { - new_selection = NULL; - } + new_selection = NULL; } if (new_selection) diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp index 9f797eb147..728642e4c7 100644 --- a/indra/newview/llpanelmaininventory.cpp +++ b/indra/newview/llpanelmaininventory.cpp @@ -577,14 +577,16 @@ void LLPanelMainInventory::updateItemcountText() void LLPanelMainInventory::onFocusReceived() { - LLInventoryPanel * inbox_panel = findChild("inventory_inbox"); + LLSidepanelInventory * sidepanel_inventory = LLSideTray::getInstance()->getPanel("sidepanel_inventory"); + + LLInventoryPanel * inbox_panel = sidepanel_inventory->findChild("inventory_inbox"); if (inbox_panel) { inbox_panel->clearSelection(); } - LLInventoryPanel * outbox_panel = findChild("inventory_outbox"); + LLInventoryPanel * outbox_panel = sidepanel_inventory->findChild("inventory_outbox"); if (outbox_panel) { diff --git a/indra/newview/llpanelmarketplaceinbox.cpp b/indra/newview/llpanelmarketplaceinbox.cpp index eff27aa541..1962724891 100644 --- a/indra/newview/llpanelmarketplaceinbox.cpp +++ b/indra/newview/llpanelmarketplaceinbox.cpp @@ -1,208 +1,218 @@ -/** - * @file llpanelmarketplaceinbox.cpp - * @brief Panel for marketplace inbox - * -* $LicenseInfo:firstyear=2011&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" - -#include "llpanelmarketplaceinbox.h" - -#include "llappviewer.h" -#include "llbutton.h" -#include "llinventorypanel.h" -#include "llsidepanelinventory.h" - - -#define SUPPORTING_FRESH_ITEM_COUNT 0 - - -static LLRegisterPanelClassWrapper t_panel_marketplace_inbox("panel_marketplace_inbox"); - -const LLPanelMarketplaceInbox::Params& LLPanelMarketplaceInbox::getDefaultParams() -{ - return LLUICtrlFactory::getDefaultParams(); -} - -// protected -LLPanelMarketplaceInbox::LLPanelMarketplaceInbox(const Params& p) - : LLPanel(p) - , mInventoryPanel(NULL) -{ -} - -LLPanelMarketplaceInbox::~LLPanelMarketplaceInbox() -{ -} - -// virtual -BOOL LLPanelMarketplaceInbox::postBuild() -{ - mInventoryPanel = getChild("inventory_inbox"); - - mInventoryPanel->setSortOrder(LLInventoryFilter::SO_DATE); - - LLAppViewer::instance()->setOnLoginCompletedCallback(boost::bind(&LLPanelMarketplaceInbox::handleLoginComplete, this)); - - LLFocusableElement::setFocusReceivedCallback(boost::bind(&LLPanelMarketplaceInbox::onFocusReceived, this)); - - return TRUE; -} - -void LLPanelMarketplaceInbox::handleLoginComplete() -{ - // Set us up as the class to drive the badge value for the sidebar_inventory button - LLSideTray::getInstance()->setTabButtonBadgeDriver("sidebar_inventory", this); -} - -void LLPanelMarketplaceInbox::onFocusReceived() -{ - LLSidepanelInventory * sidepanel_inventory = LLSideTray::getInstance()->getPanel("sidepanel_inventory"); - - if (sidepanel_inventory) - { - LLInventoryPanel * inv_panel = sidepanel_inventory->getActivePanel(); - - if (inv_panel) - { - inv_panel->clearSelection(); - } - - LLInventoryPanel * outbox_panel = sidepanel_inventory->findChild("inventory_outbox"); - - if (outbox_panel) - { - outbox_panel->clearSelection(); - } - } -} - -BOOL LLPanelMarketplaceInbox::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, std::string& tooltip_msg) -{ - *accept = ACCEPT_NO; - return TRUE; -} - -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(); - - LLInventoryModel::cat_array_t* cats; - LLInventoryModel::item_array_t* items; - - model->getDirectDescendentsOf(model->findCategoryUUIDForType(LLFolderType::FT_INBOX, false, false), cats, items); - - U32 item_count = 0; - - if (cats) - { - item_count += cats->size(); - } - - if (items) - { - item_count += items->size(); - } - - return item_count; -} - -std::string LLPanelMarketplaceInbox::getBadgeString() const -{ - std::string item_count_str(""); - - // If the inbox is visible, and the side panel is collapsed or expanded and not the inventory panel - if (getParent()->getVisible() && - (LLSideTray::getInstance()->getCollapsed() || !LLSideTray::getInstance()->isPanelActive("sidepanel_inventory"))) - { - U32 item_count = getFreshItemCount(); - - if (item_count) - { - item_count_str = llformat("%d", item_count); - } - } - - return item_count_str; -} - -void LLPanelMarketplaceInbox::draw() -{ - U32 item_count = getTotalItemCount(); - - LLView * fresh_new_count_view = getChildView("inbox_fresh_new_count"); - - 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)); - -#if SUPPORTING_FRESH_ITEM_COUNT - // 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 - fresh_new_count_view->setVisible(FALSE); -#endif - } - else - { - getChild("inbox_btn")->setLabel(getString("InboxLabelNoArg")); - - fresh_new_count_view->setVisible(FALSE); - } - - LLPanel::draw(); -} +/** + * @file llpanelmarketplaceinbox.cpp + * @brief Panel for marketplace inbox + * +* $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llpanelmarketplaceinbox.h" + +#include "llappviewer.h" +#include "llbutton.h" +#include "llinventorypanel.h" +#include "llsidepanelinventory.h" + + +#define SUPPORTING_FRESH_ITEM_COUNT 0 + + +static LLRegisterPanelClassWrapper t_panel_marketplace_inbox("panel_marketplace_inbox"); + +const LLPanelMarketplaceInbox::Params& LLPanelMarketplaceInbox::getDefaultParams() +{ + return LLUICtrlFactory::getDefaultParams(); +} + +// protected +LLPanelMarketplaceInbox::LLPanelMarketplaceInbox(const Params& p) + : LLPanel(p) + , mInventoryPanel(NULL) +{ +} + +LLPanelMarketplaceInbox::~LLPanelMarketplaceInbox() +{ +} + +// virtual +BOOL LLPanelMarketplaceInbox::postBuild() +{ + mInventoryPanel = getChild("inventory_inbox"); + + mInventoryPanel->setSortOrder(LLInventoryFilter::SO_DATE); + + LLAppViewer::instance()->setOnLoginCompletedCallback(boost::bind(&LLPanelMarketplaceInbox::handleLoginComplete, this)); + + LLFocusableElement::setFocusReceivedCallback(boost::bind(&LLPanelMarketplaceInbox::onFocusReceived, this)); + + mInventoryPanel->setSelectCallback(boost::bind(&LLPanelMarketplaceInbox::onSelectionChange, this)); + + return TRUE; +} + +void LLPanelMarketplaceInbox::onSelectionChange() +{ + LLSidepanelInventory* sidepanel_inventory = dynamic_cast(LLSideTray::getInstance()->getPanel("sidepanel_inventory")); + + sidepanel_inventory->updateVerbs(); +} + + +void LLPanelMarketplaceInbox::handleLoginComplete() +{ + // Set us up as the class to drive the badge value for the sidebar_inventory button + LLSideTray::getInstance()->setTabButtonBadgeDriver("sidebar_inventory", this); +} + +void LLPanelMarketplaceInbox::onFocusReceived() +{ + LLSidepanelInventory * sidepanel_inventory = LLSideTray::getInstance()->getPanel("sidepanel_inventory"); + + if (sidepanel_inventory) + { + LLInventoryPanel * inv_panel = sidepanel_inventory->getActivePanel(); + + if (inv_panel) + { + inv_panel->clearSelection(); + } + + LLInventoryPanel * outbox_panel = sidepanel_inventory->findChild("inventory_outbox"); + + if (outbox_panel) + { + outbox_panel->clearSelection(); + } + } +} + +BOOL LLPanelMarketplaceInbox::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, std::string& tooltip_msg) +{ + *accept = ACCEPT_NO; + return TRUE; +} + +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(); + + LLInventoryModel::cat_array_t* cats; + LLInventoryModel::item_array_t* items; + + model->getDirectDescendentsOf(model->findCategoryUUIDForType(LLFolderType::FT_INBOX, false, false), cats, items); + + U32 item_count = 0; + + if (cats) + { + item_count += cats->size(); + } + + if (items) + { + item_count += items->size(); + } + + return item_count; +} + +std::string LLPanelMarketplaceInbox::getBadgeString() const +{ + std::string item_count_str(""); + + // If the inbox is visible, and the side panel is collapsed or expanded and not the inventory panel + if (getParent()->getVisible() && + (LLSideTray::getInstance()->getCollapsed() || !LLSideTray::getInstance()->isPanelActive("sidepanel_inventory"))) + { + U32 item_count = getFreshItemCount(); + + if (item_count) + { + item_count_str = llformat("%d", item_count); + } + } + + return item_count_str; +} + +void LLPanelMarketplaceInbox::draw() +{ + U32 item_count = getTotalItemCount(); + + LLView * fresh_new_count_view = getChildView("inbox_fresh_new_count"); + + 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)); + +#if SUPPORTING_FRESH_ITEM_COUNT + // 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 + fresh_new_count_view->setVisible(FALSE); +#endif + } + 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 d5b216b56d..b176d57d3f 100644 --- a/indra/newview/llpanelmarketplaceinbox.h +++ b/indra/newview/llpanelmarketplaceinbox.h @@ -63,6 +63,8 @@ public: private: void handleLoginComplete(); + void onSelectionChange(); + void onFocusReceived(); private: diff --git a/indra/newview/llsidepanelinventory.h b/indra/newview/llsidepanelinventory.h index b68abd65cc..df29cbceba 100644 --- a/indra/newview/llsidepanelinventory.h +++ b/indra/newview/llsidepanelinventory.h @@ -70,6 +70,8 @@ public: bool isInboxEnabled() const { return mInboxEnabled; } bool isOutboxEnabled() const { return mOutboxEnabled; } + void updateVerbs(); + protected: // Tracks highlighted (selected) item in inventory panel. LLInventoryItem *getSelectedItem(); @@ -77,7 +79,6 @@ protected: void onSelectionChange(const std::deque &items, BOOL user_action); // "wear", "teleport", etc. void performActionOnSelection(const std::string &action); - void updateVerbs(); bool canWearSelected(); // check whether selected items can be worn -- cgit v1.2.3