Get rid of hardcoded downstream dependency in LLMultiFloater

Ansariel 2018-01-17 11:00:44 +01:00
parent 38171944dc
commit 6b983c8a76
5 changed files with 45 additions and 8 deletions

View File

@ -3530,6 +3530,14 @@ bool LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, const std::str
if (node->hasName("multi_floater"))
{
LLFloater::setFloaterHost((LLMultiFloater*) this);
// <FS:Ansariel> MultiFloater without titlebar for hosted floater
BOOL show_titlebar;
if (node->getAttributeBOOL("hosted_floater_show_titlebar", show_titlebar))
{
static_cast<LLMultiFloater*>(this)->setHostedFloaterShowtitlebar(show_titlebar);
}
// </FS:Ansariel>
}
LLUICtrlFactory::createChildren(this, node, child_registry_t::instance(), output_node);

View File

@ -37,16 +37,23 @@
// LLMultiFloater
//
// <FS> Update torn off status and add title bar
static const std::string IM_CONTAINER = "floater_im_box";
// <FS:Ansariel> MultiFloater without titlebar for hosted floater
//static
const LLMultiFloater::Params& LLMultiFloater::getDefaultParams()
{
return LLUICtrlFactory::getDefaultParams<LLMultiFloater>();
}
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)
// </FS:Ansariel>
: 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) // <FS:Ansariel> MultiFloater without titlebar for hosted floater
{
}
@ -203,7 +210,7 @@ void LLMultiFloater::addFloater(LLFloater* floaterp, BOOL select_added_floater,
floaterp->setBackgroundVisible(FALSE);
// <FS> 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)
// <FS:TS> 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;
// <FS> 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);
// <FS> Update torn off status and add title bar
if (getName() == IM_CONTAINER)
if (!mHostedFloaterShowtitlebar)
{
mDragHandle->setTitle(mTitle.getString() + " - " + floaterp->getTitle());
}

View File

@ -38,6 +38,20 @@
class LLMultiFloater : public LLFloater
{
public:
// <FS:Ansariel> MultiFloater without titlebar for hosted floater
struct Params
: public LLInitParam::Block<Params, LLFloater::Params>
{
Optional<bool> hosted_floater_show_titlebar;
Params() :
hosted_floater_show_titlebar("hosted_floater_show_titlebar", true)
{}
};
static const Params& getDefaultParams();
// </FS:Ansariel>
LLMultiFloater(const LLSD& key, const Params& params = getDefaultParams());
virtual ~LLMultiFloater() {};
@ -82,6 +96,9 @@ public:
// <FS:Ansariel> CTRL-W doesn't work with multifloaters
void closeDockedFloater();
// <FS:Ansariel> 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
// <FS:Ansariel> MultiFloater without titlebar for hosted floater
bool mHostedFloaterShowtitlebar;
private:
virtual void computeResizeLimits(S32& new_min_width, S32& new_min_height);
};

View File

@ -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"

View File

@ -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"