diff options
author | Loren Shih <seraph@lindenlab.com> | 2009-12-03 14:06:08 -0500 |
---|---|---|
committer | Loren Shih <seraph@lindenlab.com> | 2009-12-03 14:06:08 -0500 |
commit | e23d51700733e98f966c540602038686cba98d4e (patch) | |
tree | 3304bdf4248679d23598a36f0d66bce7a5f93ae7 /indra | |
parent | bd4ad607ba9015c97a013d734b1fa597924c0e07 (diff) |
EXT-2410 : Accepting an offered notecard should open the inventorySP
Added logic to choose the side panel if it's open, or open the side panel if no other inventory panels are open.
--HG--
branch : avatar-pipeline
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llinventorypanel.cpp | 50 | ||||
-rw-r--r-- | indra/newview/llsidepanelinventory.cpp | 5 | ||||
-rw-r--r-- | indra/newview/llsidepanelinventory.h | 1 | ||||
-rw-r--r-- | indra/newview/llsidetray.cpp | 26 | ||||
-rw-r--r-- | indra/newview/llsidetray.h | 3 |
5 files changed, 65 insertions, 20 deletions
diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 938114ade0..c13ae7726b 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -856,14 +856,31 @@ void LLInventoryPanel::dumpSelectionInformation(void* user_data) iv->mFolders->dumpSelectionInformation(); } +BOOL is_inventorysp_active() +{ + if (!LLSideTray::getInstance()->isPanelActive("sidepanel_inventory")) return FALSE; + LLSidepanelInventory *inventorySP = dynamic_cast<LLSidepanelInventory *>(LLSideTray::getInstance()->getPanel("sidepanel_inventory")); + if (!inventorySP) return FALSE; + return inventorySP->isMainInventoryPanelActive(); +} + // static LLInventoryPanel* LLInventoryPanel::getActiveInventoryPanel(BOOL auto_open) { - LLInventoryPanel* res = NULL; - - // Iterate through the inventory floaters and return whichever is on top. + // A. If the inventory side panel is open, use that preferably. + if (is_inventorysp_active()) + { + LLSidepanelInventory *inventorySP = dynamic_cast<LLSidepanelInventory *>(LLSideTray::getInstance()->getPanel("sidepanel_inventory")); + if (inventorySP) + { + return inventorySP->getActivePanel(); + } + } + + // B. Iterate through the inventory floaters and return whichever is on top. LLFloaterReg::const_instance_list_t& inst_list = LLFloaterReg::getFloaterList("inventory"); S32 z_min = S32_MAX; + LLInventoryPanel* res = NULL; for (LLFloaterReg::const_instance_list_t::const_iterator iter = inst_list.begin(); iter != inst_list.end(); ++iter) { LLFloaterInventory* iv = dynamic_cast<LLFloaterInventory*>(*iter); @@ -877,22 +894,19 @@ LLInventoryPanel* LLInventoryPanel::getActiveInventoryPanel(BOOL auto_open) } } } - - // Otherwise, open the inventorySP and use that. - if (!res && auto_open) + if (res) return res; + + // C. If no panels are open and we don't want to force open a panel, then just abort out. + if (!auto_open) return NULL; + + // D. Open the inventory side panel and use that. + LLSD key; + LLSidepanelInventory *sidepanel_inventory = + dynamic_cast<LLSidepanelInventory *>(LLSideTray::getInstance()->showPanel("sidepanel_inventory", key)); + if (sidepanel_inventory) { - LLSD key; - LLSidepanelInventory *sidepanel_inventory = - dynamic_cast<LLSidepanelInventory *>(LLSideTray::getInstance()->showPanel("sidepanel_inventory", key)); - if (sidepanel_inventory) - { - res = sidepanel_inventory->getActivePanel(); - if (res) - { - return res; - } - } + return sidepanel_inventory->getActivePanel(); } - return res; + return NULL; } diff --git a/indra/newview/llsidepanelinventory.cpp b/indra/newview/llsidepanelinventory.cpp index 5f27a21bb5..ca7a3b663a 100644 --- a/indra/newview/llsidepanelinventory.cpp +++ b/indra/newview/llsidepanelinventory.cpp @@ -286,3 +286,8 @@ LLInventoryPanel *LLSidepanelInventory::getActivePanel() } return NULL; } + +BOOL LLSidepanelInventory::isMainInventoryPanelActive() const +{ + return mInventoryPanel->getVisible(); +} diff --git a/indra/newview/llsidepanelinventory.h b/indra/newview/llsidepanelinventory.h index c2ce3badb8..231cdac9e1 100644 --- a/indra/newview/llsidepanelinventory.h +++ b/indra/newview/llsidepanelinventory.h @@ -51,6 +51,7 @@ public: /*virtual*/ void onOpen(const LLSD& key); LLInventoryPanel* getActivePanel(); // Returns an active inventory panel, if any. + BOOL isMainInventoryPanelActive() const; protected: // Tracks highlighted (selected) item in inventory panel. diff --git a/indra/newview/llsidetray.cpp b/indra/newview/llsidetray.cpp index ee62d689b5..43a3d10634 100644 --- a/indra/newview/llsidetray.cpp +++ b/indra/newview/llsidetray.cpp @@ -159,6 +159,7 @@ public: void onOpen (const LLSD& key); + LLPanel *getPanel(); private: std::string mTabTitle; std::string mImage; @@ -230,11 +231,17 @@ void LLSideTrayTab::reshape (S32 width, S32 height, BOOL called_from_parent ) void LLSideTrayTab::onOpen (const LLSD& key) { - LLPanel* panel = dynamic_cast<LLPanel*>(mMainPanel); + LLPanel *panel = getPanel(); if(panel) panel->onOpen(key); } +LLPanel* LLSideTrayTab::getPanel() +{ + LLPanel* panel = dynamic_cast<LLPanel*>(mMainPanel); + return panel; +} + LLSideTrayTab* LLSideTrayTab::createInstance () { LLSideTrayTab::Params tab_params; @@ -684,6 +691,23 @@ LLPanel* LLSideTray::getPanel (const std::string& panel_name) return NULL; } +LLPanel* LLSideTray::getActivePanel() +{ + if (mActiveTab) + { + return mActiveTab->getPanel(); + } + return NULL; +} + +bool LLSideTray::isPanelActive(const std::string& panel_name) +{ + LLPanel *panel = getActivePanel(); + if (!panel) return false; + return (panel->getName() == panel_name); +} + + // *TODO: Eliminate magic constants. static const S32 fake_offset = 132; static const S32 fake_top_offset = 18; diff --git a/indra/newview/llsidetray.h b/indra/newview/llsidetray.h index 7321574681..cf2f6992d5 100644 --- a/indra/newview/llsidetray.h +++ b/indra/newview/llsidetray.h @@ -100,7 +100,8 @@ public: * 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); /* * collapse SideBar, hiding visible tab and moving tab buttons * to the right corner of the screen |