From 3eeb14ee0abb5720e010d94eba52db09fa32237e Mon Sep 17 00:00:00 2001 From: Leslie Linden Date: Fri, 10 Jun 2011 16:20:30 -0700 Subject: EXP-856 FIX -- Inbox item count reflected as badge on inventory button * Modified badges to be parented to their owners if their owners have no parents * Modified side tray tab panels to create badges on side tab buttons when the xml specifies a badge. * Modified inbox to drive the badge value of the sidebar_inventory button. * Updated inbox and outbox sizes so scroll bars function as expected * Updated inventory_panel.xml to allow scroll tag to specify scroll bar properties, instead of just having them hardcoded. Reviewed by Richard --- indra/newview/llinventorypanel.cpp | 11 +- indra/newview/llinventorypanel.h | 6 +- indra/newview/llpanelmarketplaceinbox.cpp | 40 ++++- indra/newview/llpanelmarketplaceinbox.h | 9 +- indra/newview/llsidetray.cpp | 180 +++++++++++++-------- indra/newview/llsidetray.h | 13 +- .../skins/default/xui/en/panel_side_tray.xml | 1 + .../skins/default/xui/en/sidepanel_inventory.xml | 125 +++++++------- .../default/xui/en/widgets/inventory_panel.xml | 9 +- 9 files changed, 248 insertions(+), 146 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 1dcb91ad4d..5b47e939a4 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -42,7 +42,6 @@ #include "llinventorymodelbackgroundfetch.h" #include "llsidepanelinventory.h" #include "llsidetray.h" -#include "llscrollcontainer.h" #include "llviewerattachmenu.h" #include "llviewerfoldertype.h" #include "llvoavatarself.h" @@ -184,13 +183,9 @@ void LLInventoryPanel::initFromParams(const LLInventoryPanel::Params& params) { LLRect scroller_view_rect = getRect(); scroller_view_rect.translate(-scroller_view_rect.mLeft, -scroller_view_rect.mBottom); - LLScrollContainer::Params p; - p.name("Inventory Scroller"); - p.rect(scroller_view_rect); - p.follows.flags(FOLLOWS_ALL); - p.reserve_scroll_corner(true); - p.tab_stop(true); - mScroller = LLUICtrlFactory::create(p); + LLScrollContainer::Params scroller_params(params.scroll()); + scroller_params.rect(scroller_view_rect); + mScroller = LLUICtrlFactory::create(scroller_params); addChild(mScroller); mScroller->addChild(mFolderRoot); mFolderRoot->setScrollContainer(mScroller); diff --git a/indra/newview/llinventorypanel.h b/indra/newview/llinventorypanel.h index 9da9f7d8ba..484360b8ca 100644 --- a/indra/newview/llinventorypanel.h +++ b/indra/newview/llinventorypanel.h @@ -35,6 +35,7 @@ #include "llinventoryfilter.h" #include "llfolderview.h" #include "llinventorymodel.h" +#include "llscrollcontainer.h" #include "lluictrlfactory.h" #include @@ -46,7 +47,6 @@ class LLInventoryFVBridgeBuilder; class LLMenuBarGL; class LLCheckBoxCtrl; class LLSpinCtrl; -class LLScrollContainer; class LLTextBox; class LLIconCtrl; class LLSaveFolderState; @@ -83,6 +83,7 @@ public: Optional filter; Optional start_folder; Optional use_label_suffix; + Optional scroll; Params() : sort_order_setting("sort_order_setting"), @@ -91,7 +92,8 @@ public: show_item_link_overlays("show_item_link_overlays", false), filter("filter"), start_folder("start_folder"), - use_label_suffix("use_label_suffix", true) + use_label_suffix("use_label_suffix", true), + scroll("scroll") {} }; diff --git a/indra/newview/llpanelmarketplaceinbox.cpp b/indra/newview/llpanelmarketplaceinbox.cpp index 6cebc5dd5a..a6d6308dc2 100644 --- a/indra/newview/llpanelmarketplaceinbox.cpp +++ b/indra/newview/llpanelmarketplaceinbox.cpp @@ -28,6 +28,7 @@ #include "llpanelmarketplaceinbox.h" +#include "llappviewer.h" #include "llbutton.h" #include "llinventorypanel.h" @@ -35,7 +36,8 @@ static LLRegisterPanelClassWrapper t_panel_marketplace_ // protected LLPanelMarketplaceInbox::LLPanelMarketplaceInbox() -: LLPanel() + : LLPanel() + , mInventoryPanel(NULL) { } @@ -50,16 +52,24 @@ BOOL LLPanelMarketplaceInbox::postBuild() mInventoryPanel->setSortOrder(LLInventoryFilter::SO_DATE); + LLAppViewer::instance()->setOnLoginCompletedCallback(boost::bind(&LLPanelMarketplaceInbox::handleLoginComplete, 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); +} + 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; } -void LLPanelMarketplaceInbox::draw() +U32 LLPanelMarketplaceInbox::getItemCount() const { LLInventoryModel* model = mInventoryPanel->getModel(); @@ -68,8 +78,8 @@ void LLPanelMarketplaceInbox::draw() model->getDirectDescendentsOf(model->findCategoryUUIDForType(LLFolderType::FT_INBOX, false, false), cats, items); - S32 item_count = 0; - + U32 item_count = 0; + if (cats) { item_count += cats->size(); @@ -80,10 +90,30 @@ void LLPanelMarketplaceInbox::draw() item_count += items->size(); } + return item_count; +} + +std::string LLPanelMarketplaceInbox::getBadgeString() const +{ + std::string item_count_str(""); + U32 item_count = getItemCount(); + if (item_count) + { + item_count_str = llformat("%d", item_count); + } + + return item_count_str; +} + +void LLPanelMarketplaceInbox::draw() +{ + std::string item_count_str = getBadgeString(); + + if (item_count_str.length() > 0) { LLStringUtil::format_map_t args; - args["[NUM]"] = llformat ("%d", item_count); + args["[NUM]"] = item_count_str; getChild("inbox_btn")->setLabel(getString("InboxLabelWithArg", args)); } else diff --git a/indra/newview/llpanelmarketplaceinbox.h b/indra/newview/llpanelmarketplaceinbox.h index 504659b1ef..61e8cf3c1f 100644 --- a/indra/newview/llpanelmarketplaceinbox.h +++ b/indra/newview/llpanelmarketplaceinbox.h @@ -28,10 +28,11 @@ #define LL_LLPANELMARKETPLACEINBOX_H #include "llpanel.h" +#include "llsidetray.h" class LLInventoryPanel; -class LLPanelMarketplaceInbox : public LLPanel +class LLPanelMarketplaceInbox : public LLPanel, public LLSideTrayTabBadgeDriver { public: @@ -46,6 +47,12 @@ public: /*virtual*/ void draw(); + U32 getItemCount() const; + std::string getBadgeString() const; + +private: + void handleLoginComplete(); + private: LLInventoryPanel* mInventoryPanel; }; diff --git a/indra/newview/llsidetray.cpp b/indra/newview/llsidetray.cpp index fe3f2568bc..651897a217 100644 --- a/indra/newview/llsidetray.cpp +++ b/indra/newview/llsidetray.cpp @@ -30,7 +30,7 @@ #include "llagentcamera.h" #include "llappviewer.h" -#include "llbadgeowner.h" +#include "llbadge.h" #include "llbottomtray.h" #include "llfloaterreg.h" #include "llfirstuse.h" @@ -41,6 +41,7 @@ #include "llfocusmgr.h" #include "llrootview.h" #include "llnavigationbar.h" +#include "llpanelmarketplaceinbox.h" #include "llaccordionctrltab.h" @@ -99,7 +100,7 @@ bool LLSideTray::instanceCreated () // Represents a single tab in the side tray, only used by LLSideTray ////////////////////////////////////////////////////////////////////////////// -class LLSideTrayTab: public LLPanel, public LLBadgeOwner +class LLSideTrayTab: public LLPanel { LOG_CLASS(LLSideTrayTab); friend class LLUICtrlFactory; @@ -144,7 +145,6 @@ public: static LLSideTrayTab* createInstance (); const std::string& getDescription () const { return mDescription;} - const std::string& getTabTitle() const { return mTabTitle;} void onOpen (const LLSD& key); @@ -154,7 +154,10 @@ public: BOOL handleScrollWheel(S32 x, S32 y, S32 clicks); - LLPanel *getPanel(); + LLPanel* getPanel(); + + LLButton* createButton(bool allowTearOff, LLUICtrl::commit_callback_t callback); + private: std::string mTabTitle; std::string mImage; @@ -162,21 +165,21 @@ private: std::string mDescription; LLView* mMainPanel; + + bool mHasBadge; + LLBadge::Params mBadgeParams; }; LLSideTrayTab::LLSideTrayTab(const Params& p) : LLPanel(), - LLBadgeOwner(LLView::getHandle()), mTabTitle(p.tab_title), mImage(p.image), mImageSelected(p.image_selected), mDescription(p.description), - mMainPanel(NULL) + mMainPanel(NULL), + mBadgeParams(p.badge) { - if (p.badge.isProvided()) - { - LLBadgeOwner::initBadgeParams(p.badge()); - } + mHasBadge = p.badge.isProvided(); } LLSideTrayTab::~LLSideTrayTab() @@ -191,8 +194,6 @@ bool LLSideTrayTab::addChild(LLView* view, S32 tab_group) //return res; } - - //virtual BOOL LLSideTrayTab::postBuild() { @@ -205,8 +206,6 @@ BOOL LLSideTrayTab::postBuild() getChild("undock")->setCommitCallback(boost::bind(&LLSideTrayTab::setDocked, this, false)); getChild("dock")->setCommitCallback(boost::bind(&LLSideTrayTab::setDocked, this, true)); - addBadgeToParentPanel(); - return LLPanel::postBuild(); } @@ -534,18 +533,36 @@ public: return FALSE; } + void setBadgeDriver(LLSideTrayTabBadgeDriver* driver) + { + mBadgeDriver = driver; + } + protected: LLSideTrayButton(const LLButton::Params& p) - : LLButton(p) - , mDragLastScreenX(0) - , mDragLastScreenY(0) + : LLButton(p) + , mDragLastScreenX(0) + , mDragLastScreenY(0) + , mBadgeDriver(NULL) {} friend class LLUICtrlFactory; + void draw() + { + if (mBadgeDriver) + { + setBadgeLabel(mBadgeDriver->getBadgeString()); + } + + LLButton::draw(); + } + private: S32 mDragLastScreenX; S32 mDragLastScreenY; + + LLSideTrayTabBadgeDriver* mBadgeDriver; }; ////////////////////////////////////////////////////////////////////////////// @@ -626,11 +643,31 @@ BOOL LLSideTray::postBuild() return true; } +void LLSideTray::setTabButtonBadgeDriver(std::string tabName, LLSideTrayTabBadgeDriver* driver) +{ + mTabButtonBadgeDrivers[tabName] = driver; +} + void LLSideTray::handleLoginComplete() { //reset tab to "home" tab if it was changesd during login process selectTabByName("sidebar_home"); + for (badge_map_t::iterator it = mTabButtonBadgeDrivers.begin(); it != mTabButtonBadgeDrivers.end(); ++it) + { + LLButton* button = mTabButtons[it->first]; + LLSideTrayButton* side_button = dynamic_cast(button); + + if (side_button) + { + side_button->setBadgeDriver(it->second); + } + else + { + llwarns << "Unable to find button " << it->first << " to set the badge driver. " << llendl; + } + } + detachTabs(); } @@ -777,51 +814,6 @@ bool LLSideTray::selectTabByName(const std::string& name, bool keep_prev_visible return true; } -LLButton* LLSideTray::createButton (const std::string& name,const std::string& image,const std::string& tooltip, - LLUICtrl::commit_callback_t callback) -{ - static LLSideTray::Params sidetray_params(LLUICtrlFactory::getDefaultParams()); - - LLButton::Params bparams; - - LLRect rect; - rect.setOriginAndSize(0, 0, sidetray_params.default_button_width, sidetray_params.default_button_height); - - bparams.name(name); - bparams.follows.flags (FOLLOWS_LEFT | FOLLOWS_TOP); - bparams.rect (rect); - bparams.tab_stop(false); - bparams.image_unselected(sidetray_params.tab_btn_image_normal); - bparams.image_selected(sidetray_params.tab_btn_image_selected); - bparams.image_disabled(sidetray_params.tab_btn_image_normal); - bparams.image_disabled_selected(sidetray_params.tab_btn_image_selected); - - LLButton* button; - if (name == "sidebar_openclose") - { - // "Open/Close" button shouldn't allow "tear off" - // hence it is created as LLButton instance. - button = LLUICtrlFactory::create(bparams); - } - else - { - button = LLUICtrlFactory::create(bparams); - } - - button->setClickedCallback(callback); - - button->setToolTip(tooltip); - - if(image.length()) - { - button->setImageOverlay(image); - } - - mButtonsPanel->addChildInBack(button); - - return button; -} - bool LLSideTray::addChild(LLView* view, S32 tab_group) { LLSideTrayTab* tab_panel = dynamic_cast(view); @@ -949,7 +941,56 @@ bool LLSideTray::addTab(LLSideTrayTab* tab) return true; } -void LLSideTray::createButtons () +LLButton* LLSideTrayTab::createButton(bool allowTearOff, LLUICtrl::commit_callback_t callback) +{ + static LLSideTray::Params sidetray_params(LLUICtrlFactory::getDefaultParams()); + + LLRect rect; + rect.setOriginAndSize(0, 0, sidetray_params.default_button_width, sidetray_params.default_button_height); + + LLButton::Params bparams; + + // Append "_button" to the side tray tab name + std::string button_name = getName() + "_button"; + bparams.name(button_name); + bparams.follows.flags (FOLLOWS_LEFT | FOLLOWS_TOP); + bparams.rect (rect); + bparams.tab_stop(false); + bparams.image_unselected(sidetray_params.tab_btn_image_normal); + bparams.image_selected(sidetray_params.tab_btn_image_selected); + bparams.image_disabled(sidetray_params.tab_btn_image_normal); + bparams.image_disabled_selected(sidetray_params.tab_btn_image_selected); + + if (mHasBadge) + { + bparams.badge = mBadgeParams; + } + + LLButton* button; + if (allowTearOff) + { + button = LLUICtrlFactory::create(bparams); + } + else + { + // "Open/Close" button shouldn't allow "tear off" + // hence it is created as LLButton instance. + button = LLUICtrlFactory::create(bparams); + } + + button->setClickedCallback(callback); + + button->setToolTip(mTabTitle); + + if(mImage.length()) + { + button->setImageOverlay(mImage); + } + + return button; +} + +void LLSideTray::createButtons() { //create buttons for tabs child_vector_const_iter_t child_it = mTabs.begin(); @@ -962,17 +1003,22 @@ void LLSideTray::createButtons () // The "OpenClose" button will open/close the whole panel if (name == "sidebar_openclose") { - mCollapseButton = createButton(name,sidebar_tab->mImage,sidebar_tab->getTabTitle(), - boost::bind(&LLSideTray::onToggleCollapse, this)); + mCollapseButton = sidebar_tab->createButton(false, boost::bind(&LLSideTray::onToggleCollapse, this)); + + mButtonsPanel->addChildInBack(mCollapseButton); + LLHints::registerHintTarget("side_panel_btn", mCollapseButton->getHandle()); } else { - LLButton* button = createButton(name,sidebar_tab->mImage,sidebar_tab->getTabTitle(), - boost::bind(&LLSideTray::onTabButtonClick, this, name)); + LLButton* button = sidebar_tab->createButton(true, boost::bind(&LLSideTray::onTabButtonClick, this, name)); + + mButtonsPanel->addChildInBack(button); + mTabButtons[name] = button; } } + LLHints::registerHintTarget("inventory_btn", mTabButtons["sidebar_inventory"]->getHandle()); } diff --git a/indra/newview/llsidetray.h b/indra/newview/llsidetray.h index 24882411f4..17158329dc 100644 --- a/indra/newview/llsidetray.h +++ b/indra/newview/llsidetray.h @@ -33,6 +33,13 @@ class LLAccordionCtrl; class LLSideTrayTab; +// Define an interface for side tab button badge values +class LLSideTrayTabBadgeDriver +{ +public: + virtual std::string getBadgeString() const = 0; +}; + // Deal with LLSideTrayTab being opaque. Generic do-nothing cast... template T tab_cast(LLSideTrayTab* tab) { return tab; } @@ -166,6 +173,8 @@ public: bool getCollapsed() { return mCollapsed; } + void setTabButtonBadgeDriver(std::string tabName, LLSideTrayTabBadgeDriver* driver); + public: virtual ~LLSideTray(){}; @@ -204,8 +213,6 @@ protected: void createButtons (); - LLButton* createButton (const std::string& name,const std::string& image,const std::string& tooltip, - LLUICtrl::commit_callback_t callback); void arrange (); void detachTabs (); void reflectCollapseChange(); @@ -234,6 +241,8 @@ private: LLPanel* mButtonsPanel; typedef std::map button_map_t; button_map_t mTabButtons; + typedef std::map badge_map_t; + badge_map_t mTabButtonBadgeDrivers; child_vector_t mTabs; child_vector_t mDetachedTabs; tab_order_vector_t mOriginalTabOrder; diff --git a/indra/newview/skins/default/xui/en/panel_side_tray.xml b/indra/newview/skins/default/xui/en/panel_side_tray.xml index 6ef93406ec..0f330a7b98 100644 --- a/indra/newview/skins/default/xui/en/panel_side_tray.xml +++ b/indra/newview/skins/default/xui/en/panel_side_tray.xml @@ -142,6 +142,7 @@ mouse_opaque="false" background_visible="true" > + + height="125"> MARKETPLACE INBOX ([NUM]) MARKETPLACE INBOX