From 34316644305f2c212d99c01474d585e1a241cef4 Mon Sep 17 00:00:00 2001 From: James Cook Date: Thu, 22 Oct 2009 15:40:59 -0700 Subject: Moved internal LLSideTrayTab class to .cpp file, de-inline param block constructor, not reviewed --- indra/newview/llsidetray.cpp | 67 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'indra/newview/llsidetray.cpp') diff --git a/indra/newview/llsidetray.cpp b/indra/newview/llsidetray.cpp index 329d7d26ee..47bf69d56c 100644 --- a/indra/newview/llsidetray.cpp +++ b/indra/newview/llsidetray.cpp @@ -111,6 +111,61 @@ bool LLSideTray::instanceCreated () return sInstance!=0; } +////////////////////////////////////////////////////////////////////////////// +// LLSideTrayTab +// Represents a single tab in the side tray, only used by LLSideTray +////////////////////////////////////////////////////////////////////////////// + +class LLSideTrayTab: public LLPanel +{ + friend class LLUICtrlFactory; + friend class LLSideTray; +public: + + struct Params + : public LLInitParam::Block + { + // image name + Optional image_path; + Optional tab_title; + Optional 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; +}; + LLSideTrayTab::LLSideTrayTab(const Params& params):mMainPanel(0) { mImagePath = params.image_path; @@ -221,6 +276,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) -- cgit v1.2.3 From 350138e2bb086314bcdf74052d2b14c2f9f84c83 Mon Sep 17 00:00:00 2001 From: James Cook Date: Thu, 22 Oct 2009 17:30:45 -0700 Subject: EXT-287 Side tray open/close arrows are now an image, not the text "<<" and ">>" Removed some dead code from LLSideTray Next step is to merge all the tab art with overlay art and use button selected images to show a "pressed" state for all buttons. Reviewed with Angela. --- indra/newview/llsidetray.cpp | 96 +++++++++++++++++++------------------------- 1 file changed, 42 insertions(+), 54 deletions(-) (limited to 'indra/newview/llsidetray.cpp') diff --git a/indra/newview/llsidetray.cpp b/indra/newview/llsidetray.cpp index 47bf69d56c..22c3779050 100644 --- a/indra/newview/llsidetray.cpp +++ b/indra/newview/llsidetray.cpp @@ -126,13 +126,15 @@ public: : public LLInitParam::Block { // image name - Optional image_path; + Optional image; + Optional image_selected; Optional tab_title; Optional description; Params() - : image_path("image"), - tab_title("tab_title","no title"), - description("description","no description") + : image("image"), + image_selected("image_selected"), + tab_title("tab_title","no title"), + description("description","no description") {}; }; protected: @@ -160,18 +162,21 @@ public: private: std::string mTabTitle; - std::string mImagePath; + std::string mImage; + std::string mImageSelected; std::string mDescription; LLView* mMainPanel; }; -LLSideTrayTab::LLSideTrayTab(const Params& params):mMainPanel(0) +LLSideTrayTab::LLSideTrayTab(const Params& p) +: LLPanel(), + mTabTitle(p.tab_title), + mImage(p.image), + mImageSelected(p.image_selected), + mDescription(p.description), + mMainPanel(NULL) { - mImagePath = params.image_path; - mTabTitle = params.tab_title; - mDescription = params.description; - // Necessary for focus movement among child controls setFocusRoot(TRUE); } @@ -322,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 (params); - addChild(tab,1); - return true; -} - LLSideTrayTab* LLSideTray::getTab(const std::string& name) { @@ -358,7 +334,6 @@ LLSideTrayTab* LLSideTray::getTab(const std::string& name) } - void LLSideTray::toggleTabButton (LLSideTrayTab* tab) { if(tab == NULL) @@ -460,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(*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) @@ -581,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() -- cgit v1.2.3