summaryrefslogtreecommitdiff
path: root/indra/llui/lldockablefloater.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui/lldockablefloater.cpp')
-rw-r--r--indra/llui/lldockablefloater.cpp58
1 files changed, 54 insertions, 4 deletions
diff --git a/indra/llui/lldockablefloater.cpp b/indra/llui/lldockablefloater.cpp
index c512ef25be..228d0e701f 100644
--- a/indra/llui/lldockablefloater.cpp
+++ b/indra/llui/lldockablefloater.cpp
@@ -33,24 +33,36 @@
#include "linden_common.h"
#include "lldockablefloater.h"
+#include "llfloaterreg.h"
//static
LLHandle<LLFloater> LLDockableFloater::sInstanceHandle;
+//static
+void LLDockableFloater::init(LLDockableFloater* thiz)
+{
+ thiz->setDocked(thiz->mDockControl.get() != NULL
+ && thiz->mDockControl.get()->isDockVisible());
+ thiz->resetInstance();
+
+ // all dockable floaters should have close, dock and minimize buttons
+ thiz->setCanClose(TRUE);
+ thiz->setCanDock(true);
+ thiz->setCanMinimize(TRUE);
+}
+
LLDockableFloater::LLDockableFloater(LLDockControl* dockControl,
const LLSD& key, const Params& params) :
LLFloater(key, params), mDockControl(dockControl), mUniqueDocking(true)
{
- setDocked(mDockControl.get() != NULL && mDockControl.get()->isDockVisible());
- resetInstance();
+ init(this);
}
LLDockableFloater::LLDockableFloater(LLDockControl* dockControl, bool uniqueDocking,
const LLSD& key, const Params& params) :
LLFloater(key, params), mDockControl(dockControl), mUniqueDocking(uniqueDocking)
{
- setDocked(mDockControl.get() != NULL && mDockControl.get()->isDockVisible());
- resetInstance();
+ init(this);
}
LLDockableFloater::~LLDockableFloater()
@@ -64,6 +76,33 @@ BOOL LLDockableFloater::postBuild()
return LLView::postBuild();
}
+//static
+void LLDockableFloater::toggleInstance(const LLSD& sdname)
+{
+ LLSD key;
+ std::string name = sdname.asString();
+
+ LLDockableFloater* instance =
+ dynamic_cast<LLDockableFloater*> (LLFloaterReg::findInstance(name));
+ // if floater closed or docked
+ if (instance == NULL || instance != NULL && instance->isDocked())
+ {
+ LLFloaterReg::toggleInstance(name, key);
+ // restore button toggle state
+ if (instance != NULL)
+ {
+ instance->storeVisibilityControl();
+ }
+ }
+ // if floater undocked
+ else if (instance != NULL)
+ {
+ instance->setMinimized(FALSE);
+ instance->setVisible(TRUE);
+ instance->setFocus(TRUE);
+ }
+}
+
void LLDockableFloater::resetInstance()
{
if (mUniqueDocking && sInstanceHandle.get() != this)
@@ -91,6 +130,17 @@ void LLDockableFloater::setVisible(BOOL visible)
LLFloater::setVisible(visible);
}
+void LLDockableFloater::setMinimized(BOOL minimize)
+{
+ if(minimize && isDocked())
+ {
+ setVisible(FALSE);
+ }
+ setCanDock(!minimize);
+
+ LLFloater::setMinimized(minimize);
+}
+
void LLDockableFloater::onDockHidden()
{
setCanDock(FALSE);