diff options
Diffstat (limited to 'indra/newview/llsidetray.h')
-rw-r--r-- | indra/newview/llsidetray.h | 126 |
1 files changed, 35 insertions, 91 deletions
diff --git a/indra/newview/llsidetray.h b/indra/newview/llsidetray.h index 6ea6bafac9..140a9c818a 100644 --- a/indra/newview/llsidetray.h +++ b/indra/newview/llsidetray.h @@ -36,58 +36,8 @@ #include "llpanel.h" #include "string" -class LLSideTray; 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; -}; +class LLSideTrayTab; // added inheritance from LLDestroyClass<LLSideTray> to enable Side Tray perform necessary actions // while disconnecting viewer in LLAppViewer::disconnectViewer(). @@ -112,21 +62,14 @@ 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 (); static bool instanceCreated (); protected: LLSideTray(Params& params); - typedef std::vector<LLView*> child_vector_t; + typedef std::vector<LLSideTrayTab*> child_vector_t; typedef child_vector_t::iterator child_vector_iter_t; typedef child_vector_t::const_iterator child_vector_const_iter_t; typedef child_vector_t::reverse_iterator child_vector_reverse_iter_t; @@ -146,29 +89,31 @@ 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 * Pass params as array, or they may be overwritten(example - params["name"]="nearby") */ - LLPanel* showPanel (const std::string& panel_name, const LLSD& params); + LLPanel* showPanel (const std::string& panel_name, const LLSD& params); + + /** + * Toggling Side Tray tab which contains "sub_panel" child of "panel_name" panel. + * If "sub_panel" is not visible Side Tray is opened to display it, + * otherwise Side Tray is collapsed. + * params are passed to "panel_name" panel onOpen(). + */ + void togglePanel (LLPanel* &sub_panel, const std::string& panel_name, const LLSD& params); + + /* + * get the panel (don't show it or do anything else with it) + */ + LLPanel* getPanel (const std::string& panel_name); + LLPanel* getActivePanel (); + bool isPanelActive (const std::string& panel_name); + /* + * get currently active tab + */ + const LLSideTrayTab* getActiveTab() const { return mActiveTab; } /* * collapse SideBar, hiding visible tab and moving tab buttons @@ -189,9 +134,13 @@ public: void setVisible(BOOL visible) { - LLPanel::setVisible(visible); + if (getParent()) getParent()->setVisible(visible); } + LLPanel* getButtonsPanel() { return mButtonsPanel; } + + bool getCollapsed() { return mCollapsed; } + public: virtual ~LLSideTray(){}; @@ -203,28 +152,24 @@ public: bool addChild (LLView* view, S32 tab_group); BOOL handleMouseDown (S32 x, S32 y, MASK mask); - BOOL handleScrollWheel(S32 x, S32 y, S32 mask); void reshape (S32 width, S32 height, BOOL called_from_parent = TRUE); - S32 getTrayWidth(); - void resetPanelRect (); + void processTriState (); + void updateSidetrayVisibility(); protected: LLSideTrayTab* getTab (const std::string& name); void createButtons (); - LLButton* createButton (const std::string& name,const std::string& image,LLUICtrl::commit_callback_t callback); + LLButton* createButton (const std::string& name,const std::string& image,const std::string& tooltip, + LLUICtrl::commit_callback_t callback); void arrange (); void reflectCollapseChange(); void toggleTabButton (LLSideTrayTab* tab); - void setPanelRect (); - - - private: // Implementation of LLDestroyClass<LLSideTray> static void destroyClass() @@ -234,18 +179,17 @@ private: LLSideTray::getInstance()->setEnabled(FALSE); } - private: - std::map<std::string,LLButton*> mTabButtons; + LLPanel* mButtonsPanel; + typedef std::map<std::string,LLButton*> button_map_t; + button_map_t mTabButtons; child_vector_t mTabs; LLSideTrayTab* mActiveTab; LLButton* mCollapseButton; bool mCollapsed; - S32 mMaxBarWidth; - static LLSideTray* sInstance; }; |