diff options
-rw-r--r-- | indra/newview/llsidetray.cpp | 151 | ||||
-rw-r--r-- | indra/newview/llsidetray.h | 78 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/panel_side_tray.xml | 1 |
3 files changed, 106 insertions, 124 deletions
diff --git a/indra/newview/llsidetray.cpp b/indra/newview/llsidetray.cpp index 329d7d26ee..22c3779050 100644 --- a/indra/newview/llsidetray.cpp +++ b/indra/newview/llsidetray.cpp @@ -111,12 +111,72 @@ bool LLSideTray::instanceCreated () return sInstance!=0; } -LLSideTrayTab::LLSideTrayTab(const Params& params):mMainPanel(0) +////////////////////////////////////////////////////////////////////////////// +// LLSideTrayTab +// Represents a single tab in the side tray, only used by LLSideTray +////////////////////////////////////////////////////////////////////////////// + +class LLSideTrayTab: public LLPanel { - mImagePath = params.image_path; - mTabTitle = params.tab_title; - mDescription = params.description; + friend class LLUICtrlFactory; + friend class LLSideTray; +public: + + struct Params + : public LLInitParam::Block<Params, LLPanel::Params> + { + // image name + Optional<std::string> image; + Optional<std::string> image_selected; + Optional<std::string> tab_title; + Optional<std::string> description; + Params() + : image("image"), + image_selected("image_selected"), + tab_title("tab_title","no title"), + description("description","no description") + {}; + }; +protected: + LLSideTrayTab(const Params& params); + + +public: + virtual ~LLSideTrayTab(); + + /*virtual*/ BOOL postBuild (); + /*virtual*/ bool addChild (LLView* view, S32 tab_group); + + + void arrange (S32 width, S32 height); + void reshape (S32 width, S32 height, BOOL called_from_parent = TRUE); + + static LLSideTrayTab* createInstance (); + + const std::string& getDescription () const { return mDescription;} + const std::string& getTabTitle() const { return mTabTitle;} + + void draw(); + + void onOpen (const LLSD& key); + +private: + std::string mTabTitle; + std::string mImage; + std::string mImageSelected; + std::string mDescription; + + LLView* mMainPanel; +}; +LLSideTrayTab::LLSideTrayTab(const Params& p) +: LLPanel(), + mTabTitle(p.tab_title), + mImage(p.image), + mImageSelected(p.image_selected), + mDescription(p.description), + mMainPanel(NULL) +{ // Necessary for focus movement among child controls setFocusRoot(TRUE); } @@ -221,6 +281,18 @@ LLSideTrayTab* LLSideTrayTab::createInstance () return tab; } +////////////////////////////////////////////////////////////////////////////// +// LLSideTray +////////////////////////////////////////////////////////////////////////////// + +LLSideTray::Params::Params() +: collapsed("collapsed",false), + tab_btn_image_normal("tab_btn_image","sidebar_tab_left.tga"), + tab_btn_image_selected("tab_btn_image_selected","button_enabled_selected_32x128.tga"), + default_button_width("tab_btn_width",32), + default_button_height("tab_btn_height",32), + default_button_margin("tab_btn_margin",0) +{} //virtual LLSideTray::LLSideTray(Params& params) @@ -255,35 +327,6 @@ BOOL LLSideTray::postBuild() setMouseOpaque(false); return true; } - -/** - * add new panel to tab with tab_name name - * @param tab_name - name of sidebar tab to add new panel - * @param panel - pointer to panel - */ -bool LLSideTray::addPanel ( const std::string& tab_name - ,LLPanel* panel ) -{ - return false; -} -/** - * Add new tab to side bar - * @param tab_name - name of the new tab - * @param image - image for new sidebar button - * @param title - title for new tab - */ -bool LLSideTray::addTab ( const std::string& tab_name - ,const std::string& image - ,const std::string& title) -{ - LLSideTrayTab::Params params; - params.image_path = image; - params.tab_title = title; - LLSideTrayTab* tab = LLUICtrlFactory::create<LLSideTrayTab> (params); - addChild(tab,1); - return true; -} - LLSideTrayTab* LLSideTray::getTab(const std::string& name) { @@ -291,7 +334,6 @@ LLSideTrayTab* LLSideTray::getTab(const std::string& name) } - void LLSideTray::toggleTabButton (LLSideTrayTab* tab) { if(tab == NULL) @@ -393,25 +435,30 @@ bool LLSideTray::addChild(LLView* view, S32 tab_group) void LLSideTray::createButtons () { - //create show/hide button - mCollapseButton = createButton(EXPANDED_NAME,"",boost::bind(&LLSideTray::onToggleCollapse, this)); - //create buttons for tabs child_vector_const_iter_t child_it = mTabs.begin(); - ++child_it; - for ( ; child_it != mTabs.end(); ++child_it) { LLSideTrayTab* sidebar_tab = dynamic_cast<LLSideTrayTab*>(*child_it); if(sidebar_tab == NULL) continue; - string name = sidebar_tab->getName(); + std::string name = sidebar_tab->getName(); - LLButton* button = createButton("",sidebar_tab->mImagePath,boost::bind(&LLSideTray::onTabButtonClick, this, sidebar_tab->getName())); - mTabButtons[sidebar_tab->getName()] = button; + // The "home" button will open/close the whole panel, this will need to + // change if the home screen becomes its own tab. + if (name == "sidebar_home") + { + mCollapseButton = createButton("",sidebar_tab->mImage, + boost::bind(&LLSideTray::onToggleCollapse, this)); + } + else + { + LLButton* button = createButton("",sidebar_tab->mImage, + boost::bind(&LLSideTray::onTabButtonClick, this, name)); + mTabButtons[name] = button; + } } - } void LLSideTray::onTabButtonClick(string name) @@ -514,25 +561,33 @@ void LLSideTray::arrange () } } -void LLSideTray::collapseSideBar () +void LLSideTray::collapseSideBar() { mCollapsed = true; - mCollapseButton->setLabel(COLLAPSED_NAME); + LLSideTrayTab* home_tab = getTab("sidebar_home"); + if (home_tab) + { + mCollapseButton->setImageOverlay( home_tab->mImage ); + } mActiveTab->setVisible(FALSE); reflectCollapseChange(); setFocus( FALSE ); } -void LLSideTray::expandSideBar () + +void LLSideTray::expandSideBar() { mCollapsed = false; - mCollapseButton->setLabel(EXPANDED_NAME); + LLSideTrayTab* home_tab = getTab("sidebar_home"); + if (home_tab) + { + mCollapseButton->setImageOverlay( home_tab->mImageSelected ); + } LLSD key;//empty mActiveTab->onOpen(key); mActiveTab->setVisible(TRUE); reflectCollapseChange(); - } void LLSideTray::highlightFocused() diff --git a/indra/newview/llsidetray.h b/indra/newview/llsidetray.h index 6ea6bafac9..845eb86bc1 100644 --- a/indra/newview/llsidetray.h +++ b/indra/newview/llsidetray.h @@ -36,59 +36,9 @@ #include "llpanel.h" #include "string" -class LLSideTray; +class LLSideTrayTab; class LLAccordionCtrl; -class LLSideTrayTab: public LLPanel -{ - friend class LLUICtrlFactory; - friend class LLSideTray; -public: - - struct Params - : public LLInitParam::Block<Params, LLPanel::Params> - { - // image name - Optional<std::string> image_path; - Optional<std::string> tab_title; - Optional<std::string> description; - Params() - : image_path("image"), - tab_title("tab_title","no title"), - description("description","no description") - {}; - }; -protected: - LLSideTrayTab(const Params& params); - - -public: - virtual ~LLSideTrayTab(); - - /*virtual*/ BOOL postBuild (); - /*virtual*/ bool addChild (LLView* view, S32 tab_group); - - - void arrange (S32 width, S32 height); - void reshape (S32 width, S32 height, BOOL called_from_parent = TRUE); - - static LLSideTrayTab* createInstance (); - - const std::string& getDescription () const { return mDescription;} - const std::string& getTabTitle() const { return mTabTitle;} - - void draw(); - - void onOpen (const LLSD& key); - -private: - std::string mTabTitle; - std::string mImagePath; - std::string mDescription; - - LLView* mMainPanel; -}; - // added inheritance from LLDestroyClass<LLSideTray> to enable Side Tray perform necessary actions // while disconnecting viewer in LLAppViewer::disconnectViewer(). // LLDestroyClassList::instance().fireCallbacks() calls destroyClass method. See EXT-245. @@ -112,14 +62,7 @@ public: Optional<S32> default_button_height; Optional<S32> default_button_margin; - Params() - : collapsed("collapsed",false), - tab_btn_image_normal("tab_btn_image","sidebar_tab_left.tga"), - tab_btn_image_selected("tab_btn_image_selected","button_enabled_selected_32x128.tga"), - default_button_width("tab_btn_width",32), - default_button_height("tab_btn_height",32), - default_button_margin("tab_btn_margin",0) - {}; + Params(); }; static LLSideTray* getInstance (); @@ -146,23 +89,6 @@ public: */ bool selectTabByIndex(size_t index); - /** - * add new panel to tab with tab_name name - * @param tab_name - name of sidebar tab to add new panel - * @param panel - pointer to panel - */ - bool addPanel ( const std::string& tab_name - ,LLPanel* panel ); - /** - * Add new tab to side bar - * @param tab_name - name of the new tab - * @param image - image for new sidebar button - * @param title - title for new tab - */ - bool addTab ( const std::string& tab_name - ,const std::string& image - ,const std::string& title); - /** * Activate tab with "panel_name" panel * if no such tab - return NULL, otherwise a pointer to the panel 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 395b574425..6abcbc40d2 100644 --- a/indra/newview/skins/default/xui/en/panel_side_tray.xml +++ b/indra/newview/skins/default/xui/en/panel_side_tray.xml @@ -18,6 +18,7 @@ tab_title="Home" description="Home." image="TabIcon_Open_Off" + image_selected="TabIcon_Close_Off" mouse_opaque="false" background_visible="true" > |