From 6b983c8a7665a0f5899cb516786c36da70b86812 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Wed, 17 Jan 2018 11:00:44 +0100 Subject: [PATCH] Get rid of hardcoded downstream dependency in LLMultiFloater --- indra/llui/llfloater.cpp | 8 +++++++ indra/llui/llmultifloater.cpp | 23 ++++++++++++------- indra/llui/llmultifloater.h | 20 ++++++++++++++++ .../xui/en/floater_fs_im_container.xml | 1 + .../xui/en/floater_fs_im_container.xml | 1 + 5 files changed, 45 insertions(+), 8 deletions(-) diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 49bbeb010f..2615b18a82 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -3530,6 +3530,14 @@ bool LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, const std::str if (node->hasName("multi_floater")) { LLFloater::setFloaterHost((LLMultiFloater*) this); + + // MultiFloater without titlebar for hosted floater + BOOL show_titlebar; + if (node->getAttributeBOOL("hosted_floater_show_titlebar", show_titlebar)) + { + static_cast(this)->setHostedFloaterShowtitlebar(show_titlebar); + } + // } LLUICtrlFactory::createChildren(this, node, child_registry_t::instance(), output_node); diff --git a/indra/llui/llmultifloater.cpp b/indra/llui/llmultifloater.cpp index 3a4371bfd7..3e7488c947 100644 --- a/indra/llui/llmultifloater.cpp +++ b/indra/llui/llmultifloater.cpp @@ -37,16 +37,23 @@ // LLMultiFloater // -// Update torn off status and add title bar -static const std::string IM_CONTAINER = "floater_im_box"; +// MultiFloater without titlebar for hosted floater +//static +const LLMultiFloater::Params& LLMultiFloater::getDefaultParams() +{ + return LLUICtrlFactory::getDefaultParams(); +} -LLMultiFloater::LLMultiFloater(const LLSD& key, const LLFloater::Params& params) +//LLMultiFloater::LLMultiFloater(const LLSD& key, const LLFloater::Params& params) +LLMultiFloater::LLMultiFloater(const LLSD& key, const Params& params) +// : LLFloater(key), mTabContainer(NULL), mTabPos(LLTabContainer::TOP), mAutoResize(TRUE), mOrigMinWidth(params.min_width), - mOrigMinHeight(params.min_height) + mOrigMinHeight(params.min_height), + mHostedFloaterShowtitlebar(params.hosted_floater_show_titlebar) // MultiFloater without titlebar for hosted floater { } @@ -203,7 +210,7 @@ void LLMultiFloater::addFloater(LLFloater* floaterp, BOOL select_added_floater, floaterp->setBackgroundVisible(FALSE); // Update torn off status and add title bar; Do this AFTER we stored the original rect! - if (getName() == IM_CONTAINER) + if (!mHostedFloaterShowtitlebar) { floaterp->getDragHandle()->setTitleVisible(FALSE); LLRect rect = floaterp->getRect(); @@ -256,7 +263,7 @@ void LLMultiFloater::updateFloaterTitle(LLFloater* floaterp) // If the tab we're updating is the current tab, then // update the overall title too, since we're showing it // exclusively now. - if (getName() == IM_CONTAINER && floaterp == mTabContainer->getCurrentPanel()) + if (!mHostedFloaterShowtitlebar && floaterp == mTabContainer->getCurrentPanel()) { mDragHandle->setTitle(mTitle.getString() + " - " + floaterp->getTitle()); } @@ -310,7 +317,7 @@ void LLMultiFloater::removeFloater(LLFloater* floaterp) return; // Update torn off status and add title bar - if (getName() == IM_CONTAINER) + if (!mHostedFloaterShowtitlebar) { floaterp->getDragHandle()->setTitleVisible(TRUE); LLRect rect = floaterp->getRect(); @@ -477,7 +484,7 @@ void LLMultiFloater::onTabSelected() { tabOpen(floaterp, true); // Update torn off status and add title bar - if (getName() == IM_CONTAINER) + if (!mHostedFloaterShowtitlebar) { mDragHandle->setTitle(mTitle.getString() + " - " + floaterp->getTitle()); } diff --git a/indra/llui/llmultifloater.h b/indra/llui/llmultifloater.h index b9e2abed19..70da0ac053 100644 --- a/indra/llui/llmultifloater.h +++ b/indra/llui/llmultifloater.h @@ -38,6 +38,20 @@ class LLMultiFloater : public LLFloater { public: + // MultiFloater without titlebar for hosted floater + struct Params + : public LLInitParam::Block + { + Optional hosted_floater_show_titlebar; + + Params() : + hosted_floater_show_titlebar("hosted_floater_show_titlebar", true) + {} + }; + + static const Params& getDefaultParams(); + // + LLMultiFloater(const LLSD& key, const Params& params = getDefaultParams()); virtual ~LLMultiFloater() {}; @@ -82,6 +96,9 @@ public: // CTRL-W doesn't work with multifloaters void closeDockedFloater(); + // MultiFloater without titlebar for hosted floater + void setHostedFloaterShowtitlebar(bool show) { mHostedFloaterShowtitlebar = show; } + protected: struct LLFloaterData { @@ -101,6 +118,9 @@ protected: BOOL mAutoResize; S32 mOrigMinWidth, mOrigMinHeight; // logically const but initialized late + // MultiFloater without titlebar for hosted floater + bool mHostedFloaterShowtitlebar; + private: virtual void computeResizeLimits(S32& new_min_width, S32& new_min_height); }; diff --git a/indra/newview/skins/default/xui/en/floater_fs_im_container.xml b/indra/newview/skins/default/xui/en/floater_fs_im_container.xml index bb4f0dc1e8..a0ebae99f4 100644 --- a/indra/newview/skins/default/xui/en/floater_fs_im_container.xml +++ b/indra/newview/skins/default/xui/en/floater_fs_im_container.xml @@ -4,6 +4,7 @@ can_minimize="true" can_resize="true" height="390" + hosted_floater_show_titlebar="false" layout="topleft" name="floater_im_box" save_rect="true" diff --git a/indra/newview/skins/vintage/xui/en/floater_fs_im_container.xml b/indra/newview/skins/vintage/xui/en/floater_fs_im_container.xml index 115012da5a..9b7680bf44 100644 --- a/indra/newview/skins/vintage/xui/en/floater_fs_im_container.xml +++ b/indra/newview/skins/vintage/xui/en/floater_fs_im_container.xml @@ -4,6 +4,7 @@ can_minimize="true" can_resize="true" height="390" + hosted_floater_show_titlebar="false" layout="topleft" name="floater_im_box" save_rect="true"