From aab64557b6a412c41fdaafb58362ccd6680d2c7f Mon Sep 17 00:00:00 2001 From: ziree Date: Fri, 6 May 2011 18:21:25 +0200 Subject: [PATCH] Created branch for docking window state work. Currently not suitable for everyday use because of very very ugly code, debugging output and a few code flaws, so I put it in a branch to keep workign on it. --HG-- branch : Docking_Window_States_Branch --- indra/llui/llfloater.cpp | 36 +++++++++++++++---- indra/llui/llfloaterreg.cpp | 3 ++ indra/newview/llfloaterchatterbox.cpp | 2 +- indra/newview/llimfloater.cpp | 10 +++++- indra/newview/llimfloatercontainer.cpp | 19 ++++++++-- indra/newview/llnearbychat.cpp | 30 +++++++++++----- indra/newview/llnearbychat.h | 2 +- .../default/xui/en/floater_im_container.xml | 1 + .../default/xui/en/floater_nearby_chat-cb.xml | 5 ++- .../default/xui/en/floater_nearby_chat.xml | 5 ++- 10 files changed, 91 insertions(+), 22 deletions(-) diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 249d1a8bbc..c8102cfb79 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -245,7 +245,7 @@ LLFloater::LLFloater(const LLSD& key, const LLFloater::Params& p) mAutoFocus(TRUE), // automatically take focus when opened mCanDock(false), mDocked(false), - mTornOff(false), + mTornOff(true), mHasBeenDraggedWhileMinimized(FALSE), mPreviousMinimizedBottom(0), mPreviousMinimizedLeft(0), @@ -529,9 +529,11 @@ LLFloater::~LLFloater() void LLFloater::storeRectControl() { - if( mRectControl.size() > 1 ) + llwarns << getName() << " LLFloater::storeRectControl() " << mTornOff << " " << getHost() << llendl; + if( mTornOff && mRectControl.size() > 1 ) { getControlGroup()->setRect( mRectControl, getRect() ); + llwarns << getName() << " stored " << getRect() << llendl; } } @@ -561,6 +563,7 @@ void LLFloater::storeMinimizeStateControl() LLRect LLFloater::getSavedRect() const { + llwarns << getName() << " LLFloater::getSavedRect()" << llendl; LLRect rect; if (mRectControl.size() > 1) @@ -568,6 +571,8 @@ LLRect LLFloater::getSavedRect() const rect = getControlGroup()->getRect(mRectControl); } + llwarns << getName() << " rect " << rect << llendl; + return rect; } @@ -851,7 +856,7 @@ void LLFloater::applyRectControl() } // override center if we have saved rect control - if (mRectControl.size() > 1) + if (mTornOff && mRectControl.size() > 1) { const LLRect& rect = getControlGroup()->getRect(mRectControl); if (rect.getWidth() > 0 && rect.getHeight() > 0) @@ -1575,26 +1580,44 @@ void LLFloater::onClickTearOff(LLFloater* self) LLMultiFloater* host_floater = self->getHost(); if (host_floater) //Tear off { + llwarns << self->getName() << " tear off" << llendl; 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) +// if (self->getRect().isEmpty()) { - 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=self->getExpandedRect(); + if(new_rect.isEmpty()) + { + llwarns << "no rect saved yet, so reshape the floater" << llendl; + new_rect.setLeftTopAndSize(host_floater->getRect().mLeft + 5, host_floater->getRect().mTop - floater_header_size - 5, self->getRect().getWidth(), self->getRect().getHeight()); + } + self->setShape(new_rect); + self->storeRectControl(); + } + else + { + self->setShape(self->getSavedRect(),FALSE); + llwarns <getName() << " restored rect: " << self->getSavedRect() << llendl; } 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. { + self->storeRectControl(); + self->setExpandedRect(self->getRect()); + llwarns << self->getName() << " stored rect " << self->getRect() << llendl; + self->setTornOff(false); LLMultiFloater* new_host = (LLMultiFloater*)self->mLastHostHandle.get(); if (new_host) { @@ -1603,7 +1626,6 @@ void LLFloater::onClickTearOff(LLFloater* self) // make sure host is visible new_host->openFloater(new_host->getKey()); } - self->setTornOff(false); } self->updateTitleButtons(); } diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp index 2de10eb75e..c4b836a5c3 100644 --- a/indra/llui/llfloaterreg.cpp +++ b/indra/llui/llfloaterreg.cpp @@ -431,13 +431,16 @@ void LLFloaterReg::registerControlVariables() for (build_map_t::iterator iter = sBuildMap.begin(); iter != sBuildMap.end(); ++iter) { const std::string& name = iter->first; + llwarns << name << llendl; if (LLFloater::getControlGroup()->controlExists(getRectControlName(name))) { declareRectControl(name); + llwarns << "rect " << name << llendl; } if (LLFloater::getControlGroup()->controlExists(getVisibilityControlName(name))) { declareVisibilityControl(name); + llwarns << "vis " << name << llendl; } } diff --git a/indra/newview/llfloaterchatterbox.cpp b/indra/newview/llfloaterchatterbox.cpp index dc33e45dd4..5710ee058f 100644 --- a/indra/newview/llfloaterchatterbox.cpp +++ b/indra/newview/llfloaterchatterbox.cpp @@ -109,7 +109,7 @@ LLFloaterChatterBox::~LLFloaterChatterBox() BOOL LLFloaterChatterBox::postBuild() { setVisibleCallback(boost::bind(&LLFloaterChatterBox::onVisibilityChange, this, _2)); - + llwarns << __LINE__ << llendl; if (gSavedSettings.getBOOL("ContactsTornOff")) { LLFloaterMyFriends* floater_contacts = LLFloaterMyFriends::getInstance(); diff --git a/indra/newview/llimfloater.cpp b/indra/newview/llimfloater.cpp index d279c5f705..d8ac310a93 100644 --- a/indra/newview/llimfloater.cpp +++ b/indra/newview/llimfloater.cpp @@ -828,6 +828,14 @@ LLIMFloater* LLIMFloater::show(const LLUUID& session_id) { LLIMFloaterContainer* floater_container = LLIMFloaterContainer::getInstance(); + if (gSavedSettings.getBOOL("ContactsTornOff")) + { + floater->setHost(floater_container); + gFloaterView->addChild(floater); + floater->setTornOff(TRUE); + } + else + // do not add existed floaters to avoid adding torn off instances if (!exist) { @@ -867,8 +875,8 @@ LLIMFloater* LLIMFloater::show(const LLUUID& session_id) } // window is positioned, now we can show it. + floater->setVisible(TRUE); } - floater->setVisible(TRUE); return floater; } diff --git a/indra/newview/llimfloatercontainer.cpp b/indra/newview/llimfloatercontainer.cpp index 8af9dcdb04..adb34f63ef 100644 --- a/indra/newview/llimfloatercontainer.cpp +++ b/indra/newview/llimfloatercontainer.cpp @@ -71,26 +71,37 @@ void LLIMFloaterContainer::onOpen(const LLSD& key) LLMultiFloater::onOpen(key); + llwarns << __LINE__ << llendl; // If we're using multitabs, and we open up for the first time // Add localchat by default if it's not already on the screen somewhere else. -AO // But only if it hasnt been already so we can reopen it to the same tab -KC LLFloater* floater = LLNearbyChat::getInstance(); + llwarns << __LINE__ << llendl; if (! LLFloater::isVisible(floater) && (floater->getHost() != this)) { + llwarns << __LINE__ << llendl; if (gSavedSettings.getBOOL("ChatHistoryTornOff")) { + llwarns << __LINE__ << llendl; +// const LLRect rect=floater->getRect(); + floater->setHost(this); // add then remove to set up relationship for re-attach - LLMultiFloater::showFloater(floater); - removeFloater(floater); +// LLMultiFloater::showFloater(floater); +// removeFloater(floater); // reparent to floater view gFloaterView->addChild(floater); + floater->setTornOff(TRUE); +// floater->setShape(rect); } else { + llwarns << __LINE__ << llendl; + floater->setTornOff(FALSE); LLMultiFloater::showFloater(floater); } } + llwarns << __LINE__ << llendl; /* @@ -118,6 +129,7 @@ void LLIMFloaterContainer::removeFloater(LLFloater* floaterp) { // only chat floater now locked mTabContainer->lockTabs(mTabContainer->getNumLockedTabs() - 1); + gSavedSettings.setBOOL("ContactsTornOff", TRUE); } LLMultiFloater::removeFloater(floaterp); } @@ -143,9 +155,11 @@ void LLIMFloaterContainer::addFloater(LLFloater* floaterp, if (floaterp->getName() == "imcontacts") { LLMultiFloater::addFloater(floaterp, select_added_floater, LLTabContainer::START); + gSavedSettings.setBOOL("ContactsTornOff", FALSE); } else { + llwarns << floaterp->getName() << " adding with rect " << floaterp->getRect() << llendl; // add chat history as second tab if contact window is present, first tab otherwise if (getChildView("imcontacts")) { @@ -158,6 +172,7 @@ void LLIMFloaterContainer::addFloater(LLFloater* floaterp, { LLMultiFloater::addFloater(floaterp, select_added_floater, LLTabContainer::START); } + llwarns << floaterp->getName() << " added. rect now " << floaterp->getRect() << llendl; gSavedSettings.setBOOL("ChatHistoryTornOff", FALSE); } // make sure first two tabs are now locked diff --git a/indra/newview/llnearbychat.cpp b/indra/newview/llnearbychat.cpp index 245da20ecf..ce6cbb3b4f 100644 --- a/indra/newview/llnearbychat.cpp +++ b/indra/newview/llnearbychat.cpp @@ -164,28 +164,40 @@ BOOL LLNearbyChat::postBuild() LLButton* slide_right = getChild("slide_right_btn"); slide_right->setVisible(false); - + llwarns << __LINE__ << llendl; if (getDockControl() == NULL) { + llwarns << __LINE__ << llendl; LLIMFloaterContainer* floater_container = LLIMFloaterContainer::getInstance(); if (floater_container) { + llwarns << __LINE__ << llendl; if (gSavedSettings.getBOOL("ChatHistoryTornOff")) { + llwarns << __LINE__ << llendl; + +// BOOL visible=LLFloater::isVisible(floater_container); // add then remove to set up relationship for re-attach - floater_container->addFloater(this, FALSE); - floater_container->removeFloater(this); - // reparent to floater view +// floater_container->addFloater(this, FALSE); +// floater_container->removeFloater(this); + // reparent to floater view + + setHost(floater_container); gFloaterView->addChild(this); +// setTornOff(TRUE); } else { + llwarns << __LINE__ << llendl; + setTornOff(FALSE); floater_container->addFloater(this, FALSE); } + llwarns << __LINE__ << llendl; + floater_container->setVisible(FALSE); } } - PhoenixUseNearbyChatConsole = gSavedSettings.getBOOL("PhoenixUseNearbyChatConsole"); +PhoenixUseNearbyChatConsole = gSavedSettings.getBOOL("PhoenixUseNearbyChatConsole"); gSavedSettings.getControl("PhoenixUseNearbyChatConsole")->getSignal()->connect(boost::bind(&LLNearbyChat::updatePhoenixUseNearbyChatConsole, this, _2)); return LLDockableFloater::postBuild(); @@ -210,6 +222,8 @@ BOOL LLNearbyChat::postBuild() return true; } + +/* void LLNearbyChat::applySavedVariables() { if (mRectControl.size() > 1) @@ -222,7 +236,6 @@ void LLNearbyChat::applySavedVariables() } } - if(!LLFloater::getControlGroup()->controlExists(mDocStateControl)) { setDocked(true); @@ -236,6 +249,7 @@ void LLNearbyChat::applySavedVariables() } } } +*/ @@ -340,7 +354,7 @@ void LLNearbyChat::openFloater(const LLSD& key) if(isChatMultiTab()) { LLIMFloaterContainer* floater_container = LLIMFloaterContainer::getInstance(); - if (floater_container) + if (floater_container && !gSavedSettings.getBOOL("ChatHistoryTornOff")) { floater_container->showFloater(this, LLTabContainer::START); } @@ -373,7 +387,7 @@ void LLNearbyChat::onOpen(const LLSD& key ) if(isChatMultiTab() && ! isVisible(this)) { LLIMFloaterContainer* floater_container = LLIMFloaterContainer::getInstance(); - if (floater_container) + if (floater_container && !gSavedSettings.getBOOL("ChatHistoryTornOff")) { floater_container->showFloater(this, LLTabContainer::START); } diff --git a/indra/newview/llnearbychat.h b/indra/newview/llnearbychat.h index 1d8e521931..aa81ffb43f 100644 --- a/indra/newview/llnearbychat.h +++ b/indra/newview/llnearbychat.h @@ -81,7 +81,7 @@ public: void updatePhoenixUseNearbyChatConsole(const LLSD &data); private: - virtual void applySavedVariables(); + // virtual void applySavedVariables(); void getAllowedRect (LLRect& rect); diff --git a/indra/newview/skins/default/xui/en/floater_im_container.xml b/indra/newview/skins/default/xui/en/floater_im_container.xml index 2ff322ef95..f6af415f71 100644 --- a/indra/newview/skins/default/xui/en/floater_im_container.xml +++ b/indra/newview/skins/default/xui/en/floater_im_container.xml @@ -8,6 +8,7 @@ name="floater_im_box" save_rect="true" save_visibility="true" + save_dock_state="true" single_instance="true" title="CONVERSATIONS" width="396"> diff --git a/indra/newview/skins/default/xui/en/floater_nearby_chat-cb.xml b/indra/newview/skins/default/xui/en/floater_nearby_chat-cb.xml index faf30ce99e..1ecc900a70 100644 --- a/indra/newview/skins/default/xui/en/floater_nearby_chat-cb.xml +++ b/indra/newview/skins/default/xui/en/floater_nearby_chat-cb.xml @@ -8,12 +8,15 @@ layout="topleft" left="0" name="nearby_chat" - title="NEARBY CHAT" + title="NEARBY CHAT CB" top="0" can_dock="false" can_close="true" can_minimize="false" single_instance="true" + save_rect="true" + save_visibility="true" + save_dock_state="true" visible="false" width="394" can_resize="true" diff --git a/indra/newview/skins/default/xui/en/floater_nearby_chat.xml b/indra/newview/skins/default/xui/en/floater_nearby_chat.xml index 61fbf6302f..e98eb80cdc 100644 --- a/indra/newview/skins/default/xui/en/floater_nearby_chat.xml +++ b/indra/newview/skins/default/xui/en/floater_nearby_chat.xml @@ -8,12 +8,15 @@ layout="topleft" left="0" name="nearby_chat" - title="NEARBY CHAT" + title="NEARBY CHAT N" top="0" can_dock="false" can_close="true" can_minimize="false" single_instance="true" + save_rect="true" + save_visibility="true" + save_dock_state="true" visible="false" width="394" can_resize="true"