- added : 'save_tearoff_state' for floaters to track the torn off state of LLMultiFloater hosted floaters across viewer sessions

--HG--
branch : Chat-NearbyChat
meow-7.2.2
Kitty Barnett 2011-09-30 18:11:13 +02:00
parent d48c4ccee1
commit 606a809f2f
4 changed files with 152 additions and 23 deletions

View File

@ -163,6 +163,9 @@ LLFloater::Params::Params()
save_dock_state("save_dock_state", false),
save_rect("save_rect", false),
save_visibility("save_visibility", false),
// [SL:KB] - Patch: UI-FloaterTearOffState | Checked: 2011-09-30 (Catznip-3.0.0a) | Added: Catznip-3.0.0a
save_tearoff_state("save_tearoff_state", false),
// [/SL:KB]
can_dock("can_dock", false),
open_centered("open_centered", false),
header_height("header_height", 0),
@ -547,6 +550,16 @@ void LLFloater::storeDockStateControl()
}
}
// [SL:KB] - Patch: UI-FloaterTearOffState | Checked: 2011-09-30 (Catznip-3.0.0a) | Added: Catznip-3.0.0a
void LLFloater::storeTearOffStateControl()
{
if ( (!sQuitting) && (mCanTearOff) && (mTearOffStateControl.size() > 1) )
{
getControlGroup()->setBOOL(mTearOffStateControl, isTornOff());
}
}
// [/SL:KB]
LLRect LLFloater::getSavedRect() const
{
LLRect rect;
@ -826,6 +839,9 @@ void LLFloater::applySavedVariables()
{
applyRectControl();
applyDockState();
// [SL:KB] - Patch: UI-FloaterTearOffState | Checked: 2011-09-30 (Catznip-3.0.0a) | Added: Catznip-3.0.0a
applyTearOffState();
// [/SL:KB]
}
void LLFloater::applyRectControl()
@ -861,6 +877,17 @@ void LLFloater::applyDockState()
}
// [SL:KB] - Patch: UI-FloaterTearOffState | Checked: 2011-09-30 (Catznip-3.0.0a) | Added: Catznip-3.0.0a
void LLFloater::applyTearOffState()
{
if ( (mCanTearOff) && (mTearOffStateControl.size() > 1) )
{
bool tearoffState = getControlGroup()->getBOOL(mTearOffStateControl);
setTornOff(tearoffState);
}
}
// [/SL:KB]
void LLFloater::applyTitle()
{
if (!mDragHandle)
@ -1508,47 +1535,99 @@ void LLFloater::onClickMinimize(LLFloater* self)
self->setMinimized( !self->isMinimized() );
}
void LLFloater::onClickTearOff(LLFloater* self)
// [SL:KB] - Patch: UI-FloaterTearOffState | Checked: 2011-09-30 (Catznip-3.0.0a) | Added: Catznip-3.0.0a
void LLFloater::setTornOff(bool torn_off)
{
if (!self)
if ( (!mCanTearOff) || (mTornOff == torn_off) )
return;
S32 floater_header_size = self->mHeaderHeight;
LLMultiFloater* host_floater = self->getHost();
if (host_floater) //Tear off
LLMultiFloater* host_floater = getHost();
if ( (torn_off) && (host_floater) ) // Tear off
{
LLRect new_rect;
host_floater->removeFloater(self);
host_floater->removeFloater(this);
// reparent to floater view
gFloaterView->addChild(self);
gFloaterView->addChild(this);
self->openFloater(self->getKey());
openFloater(getKey());
// only force position for floaters that don't have that data saved
if (self->mRectControl.size() <= 1)
if (mRectControl.size() <= 1)
{
new_rect.setLeftTopAndSize(host_floater->getRect().mLeft + 5, host_floater->getRect().mTop - floater_header_size - 5, self->getRect().getWidth(), self->getRect().getHeight());
self->setRect(new_rect);
new_rect.setLeftTopAndSize(host_floater->getRect().mLeft + 5, host_floater->getRect().mTop - mHeaderHeight - 5, getRect().getWidth(), getRect().getHeight());
setRect(new_rect);
}
gFloaterView->adjustToFitScreen(self, FALSE);
gFloaterView->adjustToFitScreen(this, FALSE);
// give focus to new window to keep continuity for the user
self->setFocus(TRUE);
self->setTornOff(true);
setFocus(TRUE);
mTornOff = true;;
}
else //Attach to parent.
else if (!torn_off) // Attach to parent.
{
LLMultiFloater* new_host = (LLMultiFloater*)self->mLastHostHandle.get();
LLMultiFloater* new_host = (LLMultiFloater*)mLastHostHandle.get();
if (new_host)
{
self->setMinimized(FALSE); // to reenable minimize button if it was minimized
new_host->showFloater(self);
setMinimized(FALSE); // to reenable minimize button if it was minimized
new_host->showFloater(this);
// make sure host is visible
new_host->openFloater(new_host->getKey());
}
self->setTornOff(false);
mTornOff = false;
}
self->updateTitleButtons();
updateTitleButtons();
storeTearOffStateControl();
}
void LLFloater::onClickTearOff(LLFloater* self)
{
if ( (self) && (self->mCanTearOff) )
{
self->setTornOff(!self->mTornOff);
}
}
// [/SL:KB]
//void LLFloater::onClickTearOff(LLFloater* self)
//{
// if (!self)
// return;
// S32 floater_header_size = self->mHeaderHeight;
// LLMultiFloater* host_floater = self->getHost();
// if (host_floater) //Tear off
// {
// LLRect new_rect;
// host_floater->removeFloater(self);
// // reparent to floater view
// gFloaterView->addChild(self);
//
// self->openFloater(self->getKey());
//
// // only force position for floaters that don't have that data saved
// if (self->mRectControl.size() <= 1)
// {
// new_rect.setLeftTopAndSize(host_floater->getRect().mLeft + 5, host_floater->getRect().mTop - floater_header_size - 5, self->getRect().getWidth(), self->getRect().getHeight());
// self->setRect(new_rect);
// }
// gFloaterView->adjustToFitScreen(self, FALSE);
// // give focus to new window to keep continuity for the user
// self->setFocus(TRUE);
// self->setTornOff(true);
// }
// else //Attach to parent.
// {
// LLMultiFloater* new_host = (LLMultiFloater*)self->mLastHostHandle.get();
// if (new_host)
// {
// self->setMinimized(FALSE); // to reenable minimize button if it was minimized
// new_host->showFloater(self);
// // make sure host is visible
// new_host->openFloater(new_host->getKey());
// }
// self->setTornOff(false);
// }
// self->updateTitleButtons();
//}
// static
void LLFloater::onClickDock(LLFloater* self)
{
@ -2775,7 +2854,12 @@ void LLFloater::setInstanceName(const std::string& name)
{
mDocStateControl = LLFloaterReg::declareDockStateControl(ctrl_name);
}
// [SL:KB] - Patch: UI-FloaterTearOffState | Checked: 2011-09-30 (Catznip-3.0.0a) | Added: Catznip-3.0.0a
if(!mTearOffStateControl.empty())
{
mTearOffStateControl = LLFloaterReg::declareTearOffStateControl(ctrl_name);
}
// [/SL:KB]
}
}
@ -2853,7 +2937,14 @@ void LLFloater::initFromParams(const LLFloater::Params& p)
{
mDocStateControl = "t"; // flag to build mDocStateControl name once mInstanceName is set
}
// [SL:KB] - Patch: UI-FloaterTearOffState | Checked: 2011-09-30 (Catznip-3.0.0a) | Added: Catznip-3.0.0a
if (p.save_tearoff_state)
{
mTearOffStateControl = "t"; // flag to build mTearOffStateControl name once mInstanceName is set
}
// [/SL:KB]
// open callback
if (p.open_callback.isProvided())
{

View File

@ -104,6 +104,9 @@ public:
save_rect,
save_visibility,
save_dock_state,
// [SL:KB] - Patch: UI-FloaterTearOffState | Checked: 2011-09-30 (Catznip-3.0.0a) | Added: Catznip-3.0.0a
save_tearoff_state,
// [/SL:KB]
can_dock,
open_centered;
Optional<S32> header_height,
@ -263,7 +266,11 @@ public:
bool isDocked() const { return mDocked; }
virtual void setDocked(bool docked, bool pop_on_undock = true);
virtual void setTornOff(bool torn_off) { mTornOff = torn_off; }
// [SL:KB] - Patch: UI-FloaterTearOffState | Checked: 2011-09-30 (Catznip-3.0.0a) | Added: Catznip-3.0.0a
bool isTornOff() const { return mTornOff; }
virtual void setTornOff(bool torn_off);
// [/SL:KB]
// virtual void setTornOff(bool torn_off) { mTornOff = torn_off; }
void stackWith(LLFloater& other);
@ -295,9 +302,15 @@ protected:
void applyRectControl();
void applyDockState();
// [SL:KB] - Patch: UI-FloaterTearOffState | Checked: 2011-09-30 (Catznip-3.0.0a) | Added: Catznip-3.0.0a
void applyTearOffState();
// [/SL:KB]
void storeRectControl();
void storeVisibilityControl();
void storeDockStateControl();
// [SL:KB] - Patch: UI-FloaterTearOffState | Checked: 2011-09-30 (Catznip-3.0.0a) | Added: Catznip-3.0.0a
void storeTearOffStateControl();
// [/SL:KB]
void setKey(const LLSD& key);
void setInstanceName(const std::string& name);
@ -362,6 +375,9 @@ protected:
std::string mRectControl;
std::string mVisibilityControl;
std::string mDocStateControl;
// [SL:KB] - Patch: UI-FloaterTearOffState | Checked: 2011-09-30 (Catznip-3.0.0a) | Added: Catznip-3.0.0a
std::string mTearOffStateControl;
// [/SL:KB]
LLSD mKey; // Key used for retrieving instances; set (for now) by LLFLoaterReg
LLDragHandle* mDragHandle;

View File

@ -391,6 +391,23 @@ std::string LLFloaterReg::getDockStateControlName(const std::string& name)
return res;
}
// [SL:KB] - Patch: UI-FloaterTearOffState | Checked: 2011-09-30 (Catznip-3.0.0a) | Added: Catznip-3.0.0a
//static
std::string LLFloaterReg::declareTearOffStateControl(const std::string& name)
{
std::string controlname = getTearOffStateControlName(name);
LLFloater::getControlGroup()->declareBOOL(controlname, TRUE, llformat("Window Tear Off state for %s", name.c_str()), TRUE);
return controlname;
}
//static
std::string LLFloaterReg::getTearOffStateControlName(const std::string& name)
{
std::string res = std::string("floater_tearoff_") + name;
LLStringUtil::replaceChar(res, ' ', '_');
return res;
}
// [/SL:KB]
//static
void LLFloaterReg::registerControlVariables()

View File

@ -131,6 +131,11 @@ public:
static std::string declareDockStateControl(const std::string& name);
static std::string getDockStateControlName(const std::string& name);
// [SL:KB] - Patch: UI-FloaterTearOffState | Checked: 2011-09-30 (Catznip-3.0.0a) | Added: Catznip-3.0.0a
static std::string declareTearOffStateControl(const std::string& name);
static std::string getTearOffStateControlName(const std::string& name);
// [/SL:KB]
static void registerControlVariables();
// Callback wrappers