From 3e1ed3f2d7ea5728856f709392c486f0063dc4db Mon Sep 17 00:00:00 2001 From: Tozh Date: Sun, 20 Mar 2011 15:18:39 -0400 Subject: [PATCH] Toggle sidebar people panel and floater FIRE-493 --- indra/newview/llbottomtray.cpp | 54 ++++++--- indra/newview/llbottomtray.h | 5 +- indra/newview/llsidetray.cpp | 110 +++++++++++++++--- indra/newview/llsidetray.h | 8 +- indra/newview/llsidetraytab.h | 3 + indra/newview/llviewermenu.cpp | 1 + .../skins/default/xui/en/panel_bottomtray.xml | 3 + 7 files changed, 149 insertions(+), 35 deletions(-) diff --git a/indra/newview/llbottomtray.cpp b/indra/newview/llbottomtray.cpp index 7c7fc977eb..201d9d22ae 100644 --- a/indra/newview/llbottomtray.cpp +++ b/indra/newview/llbottomtray.cpp @@ -57,7 +57,9 @@ #include "rlvhandler.h" #include "rlvui.h" // [/RLVa:KB] - +//-TT Toggle sidebar panels and floaters +#include "llsidetraytab.h" +//-TT // Distance from mouse down on which drag'n'drop should be started. #define DRAG_START_DISTANCE 3 @@ -866,7 +868,7 @@ bool LLBottomTray::onContextMenuItemEnabled(const LLSD& userdata) // used to manage the bottom bar icons specific to sidebar panels. // AO: A bit hacky and might be better in another place. -void LLBottomTray::showSidebarPanel(const std::string& panel_name) +void LLBottomTray::showSidebarPanel(const LLSD& panel_name) { LLSD param; LLSideTray* sb = LLSideTray::getInstance(); @@ -876,35 +878,35 @@ void LLBottomTray::showSidebarPanel(const std::string& panel_name) // map buttons to specific values that are useful for detection & comparisons - if (panel_name == "panel_people") + if (master_panel_name == "panel_people") { param["people_panel_tab_name"] = "nearby_panel"; tab_name = "sidebar_people"; btn = getChild("sidebar_people_btn"); master_panel_name = "panel_container_people"; } - else if (panel_name == "panel_me") + else if (master_panel_name == "panel_me") { tab_name = "sidebar_me"; btn = getChild("sidebar_me_btn"); master_panel_name = "panel_container_me"; } - else if (panel_name == "panel_home") + else if (master_panel_name == "panel_home") { tab_name = "sidebar_home"; btn = getChild("sidebar_home_btn"); } - else if (panel_name == "panel_places") + else if (master_panel_name == "panel_places") { tab_name = "sidebar_places"; btn = getChild("sidebar_places_btn"); } - else if (panel_name == "sidepanel_appearance") + else if (master_panel_name == "sidepanel_appearance") { tab_name = "sidebar_appearance"; btn = getChild("sidebar_appearance_btn"); } - else if (panel_name == "sidepanel_inventory") + else if (master_panel_name == "sidepanel_inventory") { tab_name = "sidebar_inventory"; btn = getChild("sidebar_inv_btn"); @@ -914,18 +916,17 @@ void LLBottomTray::showSidebarPanel(const std::string& panel_name) LLFloater* floater_tab = LLFloaterReg::getInstance("side_bar_tab", tab_name); if (LLFloater::isShown(floater_tab)) { - if (floater_tab->isMinimized()) +//-TT Toggle sidebar panels and floaters - added state toggle and combined the cases + bool isMinimized = floater_tab->isMinimized(); + if (btn) { - if (btn) - btn->setForcePressedState(true); - floater_tab->setMinimized(false); - } - else - { - if (btn) - btn->setForcePressedState(false); - floater_tab->setMinimized(true); + //btn->setToggleState(isMinimized); + btn->setForcePressedState(isMinimized); + //const LLSD& sdName(tab_name); + //// Set the clicked callback to toggle the floater + //btn->setClickedCallback(boost::bind(&LLFloaterReg::toggleFloaterInstance, sdName)); } + floater_tab->setMinimized(!isMinimized); } // toggle collapsing sidebar if active & docked else @@ -933,12 +934,29 @@ void LLBottomTray::showSidebarPanel(const std::string& panel_name) if (sb->isPanelActive(master_panel_name)) { sb->collapseSideBar(); + //btn->setToggleState(false); } else { sb->showPanel(panel_name, param); + //btn->setToggleState(true); + } +//-TT Toggle sidebar panels with buttons + if (btn) + { + // Set the clicked callback to toggle the sidebar + //btn->setClickedCallback(boost::bind(&LLSideTrayTab::toggleSidebarTabInstance, sdName)); } } + + //const LLSD& sdName(panel_name); + //std::string vis_control_name = LLSideTrayTab::declareVisibilityControl(sdname.asString()); + // Set the button control value (toggle state) to the floater visibility control (Sets the value as well) + //btn->setControlVariable(LLSideTray::getInstance()->getPanel(sdName)); + // Set the clicked callback to toggle the floater + //btn->setClickedCallback(boost::bind(&LLSideTrayTab::toggleSidebarTabInstance, sdName)); + //btn->toggleState(); +//-TT } void LLBottomTray::onContextMenuItemClicked(const LLSD& userdata) diff --git a/indra/newview/llbottomtray.h b/indra/newview/llbottomtray.h index 6f1c28ed7a..78873be77d 100644 --- a/indra/newview/llbottomtray.h +++ b/indra/newview/llbottomtray.h @@ -445,7 +445,10 @@ protected: void updateContextMenu(S32 x, S32 y, MASK mask); void onContextMenuItemClicked(const LLSD& userdata); - void showSidebarPanel(const std::string& panel_name); + //void showSidebarPanel(std::string &panel_name); +//-TT Toggle sidebar panels with buttons + void showSidebarPanel(const LLSD& panel_name); +//-TT bool onContextMenuItemEnabled(const LLSD& userdata); // Either default or saved after user's manual resize width of nearby chat. diff --git a/indra/newview/llsidetray.cpp b/indra/newview/llsidetray.cpp index 2e02019321..77be26dbfb 100644 --- a/indra/newview/llsidetray.cpp +++ b/indra/newview/llsidetray.cpp @@ -190,17 +190,18 @@ LLSideTray* LLSideTrayTab::getSideTray() //-TT - Patch : MinimizeSidetabs void LLSideTrayTab::minimizeTab() { - LLSideTray* side_tray = LLSideTray::getInstance(); - if (side_tray->isTabAttached(getName())) - { - side_tray->collapseSideBar(); - } - else - { - llinfos << "Trying to minimize floater " << getName() << llendl; - LLFloater* floater_tab = (LLFloater*)getParent(); - floater_tab->setMinimized(true); - } + LLSideTrayTab::toggleSidebarTabInstance(getName()); + ////LLSideTray* side_tray = LLSideTray::getInstance(); + ////if (side_tray->isTabAttached(getName())) + ////{ + //// side_tray->collapseSideBar(); + ////} + ////else + ////{ + //// llinfos << "Trying to minimize floater " << getName() << llendl; + //// LLFloater* floater_tab = (LLFloater*)getParent(); + //// floater_tab->setMinimized(true); + ////} } @@ -242,6 +243,28 @@ void LLSideTrayTab::toggleTabDocked() // so that it doesn't receive redundant visibility change notifications. LLFloaterReg::toggleInstance("side_bar_tab", tab_name); } +//-TT Toggle sidebar panels with buttons +void LLSideTrayTab::toggleSidebarTabInstance(std::string sdname) +{ + LLSideTray* side_tray = LLSideTray::getInstance(); + if (side_tray->isTabAttached(sdname)) + { + side_tray->collapseSideBar(); + } + else + { + llinfos << "Trying to minimize floater " << sdname << llendl; + //LLFloater* floater_tab = (LLFloater*)getParent(); + LLFloater* floater_tab = LLFloaterReg::getInstance("side_bar_tab", sdname); + floater_tab->setMinimized(true); + } + + //if (floater_tab) + // return !(floater_tab->isMinimized()); + //else + // return side_tray->isTabAttached(sdname); +} +//-TT void LLSideTrayTab::dock(LLFloater* floater_tab) { @@ -1242,10 +1265,28 @@ void LLSideTray::togglePanel(LLPanel* &sub_panel, const std::string& panel_name, // If a panel is visible and attached to Side Tray (has LLSideTray among its ancestors) // it should be toggled off by collapsing Side Tray. - if (sub_panel->isInVisibleChain() && sub_panel->hasAncestor(this)) - { - LLSideTray::getInstance()->collapseSideBar(); - } + //if (sub_panel->isInVisibleChain() && sub_panel->hasAncestor(this)) + //{ + // LLSideTray::getInstance()->collapseSideBar(); + //} + +//-TT Toggle sidebar panels with buttons + if (sub_panel->isInVisibleChain()) + if (sub_panel->hasAncestor(this)) + { + LLSideTray::getInstance()->collapseSideBar(); + } + else + { + LLSideTrayTab *tab = getTabByPanel(panel_name); + if(tab) + { + LLFloater* floater_tab = LLFloaterReg::getInstance("side_bar_tab", tab->getName()); + floater_tab->setMinimized(!(floater_tab->isMinimized())); + //tab->minimizeTab(); + } + } +//-TT else { LLSideTray::getInstance()->showPanel(panel_name, params); @@ -1284,6 +1325,44 @@ LLPanel *findChildPanel(LLPanel *panel, const std::string& name, bool recurse) return NULL; } +//-TT Toggle sidebar panels and floaters +LLSideTrayTab* LLSideTray::getTabByPanel(const std::string& panel_name) +{ + // Look up the panel in the list of detached tabs. + for ( child_vector_const_iter_t child_it = mDetachedTabs.begin(); child_it != mDetachedTabs.end(); ++child_it) + { + LLPanel *panel = findChildPanel(*child_it,panel_name,true); + if(panel) + { + return *child_it; + } + } + + // Look up the panel in the list of attached tabs. + for ( child_vector_const_iter_t child_it = mTabs.begin(); child_it != mTabs.end(); ++child_it) + { + LLPanel *panel = findChildPanel(*child_it,panel_name,true); + if(panel) + { + return *child_it; + } + } + return NULL; +} +//-TT +//-TT Toggle sidebar panels and floaters +bool LLSideTray::isFloaterPanelVisible(const std::string& panel_name) +{ + LLSideTrayTab *tab = LLSideTray::getInstance()->getTabByPanel(panel_name); + if(tab) + { + LLFloater* floater_tab = LLFloaterReg::getInstance("side_bar_tab", tab->getName()); + return !(floater_tab->isMinimized()); + } + return false; +} +//-TT + LLPanel* LLSideTray::getPanel(const std::string& panel_name) { // Look up the panel in the list of detached tabs. @@ -1324,6 +1403,7 @@ bool LLSideTray::isPanelActive(const std::string& panel_name) return (panel->getName() == panel_name); } + void LLSideTray::updateSidetrayVisibility() { // set visibility of parent container based on collapsed state diff --git a/indra/newview/llsidetray.h b/indra/newview/llsidetray.h index c98f744312..bee7b40fcc 100644 --- a/indra/newview/llsidetray.h +++ b/indra/newview/llsidetray.h @@ -197,6 +197,10 @@ public: void toggleTabDocked(const std::string& strTabName); // [/RLVa:KB] +//-TT Toggle sidebar panels with buttons +static bool isFloaterPanelVisible(const std::string& panel_name); +//-TT + protected: bool addChild (LLView* view, S32 tab_group); bool removeTab (LLSideTrayTab* tab); // Used to detach tabs temporarily @@ -224,7 +228,9 @@ protected: bool onTabDestroy (const LLSideTrayTab* tab); // [/RLVa:KB] void onToggleCollapse(); - +//-TT Toggle sidebar panels with buttons + LLSideTrayTab* getTabByPanel(const std::string& panel_name); +//-TT private: // Implementation of LLDestroyClass static void destroyClass() diff --git a/indra/newview/llsidetraytab.h b/indra/newview/llsidetraytab.h index 9122a787a5..c29f865a4a 100644 --- a/indra/newview/llsidetraytab.h +++ b/indra/newview/llsidetraytab.h @@ -69,6 +69,9 @@ public: /*virtual*/ BOOL postBuild (); /*virtual*/ bool addChild (LLView* view, S32 tab_group); +//-TT Toggle sidebar panels with buttons + static void toggleSidebarTabInstance(std::string sdname); +//-TT void reshape (S32 width, S32 height, BOOL called_from_parent = TRUE); diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index e6eda9037d..7fd29e3de5 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -5923,6 +5923,7 @@ class LLSidetrayPanelVisible : public view_listener_t std::string panel_name = userdata.asString(); // Toggle the panel if (LLSideTray::getInstance()->isPanelActive(panel_name)) + //|| LLSideTray::getInstance()->isFloaterPanelVisible(panel_name)) { return true; } diff --git a/indra/newview/skins/default/xui/en/panel_bottomtray.xml b/indra/newview/skins/default/xui/en/panel_bottomtray.xml index d306bc93c0..f4e8643939 100644 --- a/indra/newview/skins/default/xui/en/panel_bottomtray.xml +++ b/indra/newview/skins/default/xui/en/panel_bottomtray.xml @@ -213,6 +213,9 @@ enabled="true" use_ellipses="true" width="36"> +