From 4518d1011a0a030aaedc15f86497b8da1b1c6002 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Mon, 23 Feb 2015 17:57:13 +0100 Subject: [PATCH] QuickPrefs is a TransientDockableFloater - let's make it actually behave like one and dock to the toolbar button, unless a legacy skin (Vintage or Latency) is used --- indra/newview/fscommon.cpp | 6 +++ indra/newview/fscommon.h | 2 + indra/newview/lltoolbarview.cpp | 31 +++++++++-- indra/newview/quickprefs.cpp | 51 +++++++++++++++++-- indra/newview/quickprefs.h | 2 + .../default/xui/en/floater_quickprefs.xml | 4 +- 6 files changed, 88 insertions(+), 8 deletions(-) diff --git a/indra/newview/fscommon.cpp b/indra/newview/fscommon.cpp index df2326b1e8..d26edf060b 100644 --- a/indra/newview/fscommon.cpp +++ b/indra/newview/fscommon.cpp @@ -413,3 +413,9 @@ bool FSCommon::isDefaultTexture(const LLUUID& asset_id) } return false; } + +bool FSCommon::isLegacySkin() +{ + std::string current_skin = gSavedSettings.getString("SkinCurrent"); + return (current_skin == "vintage" || current_skin == "latency"); +} diff --git a/indra/newview/fscommon.h b/indra/newview/fscommon.h index c9e9780643..c2efbb795f 100644 --- a/indra/newview/fscommon.h +++ b/indra/newview/fscommon.h @@ -80,6 +80,8 @@ namespace FSCommon std::string getAvatarNameByDisplaySettings(const LLAvatarName& av_name); bool isDefaultTexture(const LLUUID& asset_id); + + bool isLegacySkin(); }; #endif // FS_COMMON_H diff --git a/indra/newview/lltoolbarview.cpp b/indra/newview/lltoolbarview.cpp index 9224ba6b96..fed00e1569 100755 --- a/indra/newview/lltoolbarview.cpp +++ b/indra/newview/lltoolbarview.cpp @@ -47,6 +47,9 @@ #include +#include "fscommon.h" +#include "quickprefs.h" + LLToolBarView* gToolBarView = NULL; static LLDefaultChildRegistry::Register r("toolbar_view"); @@ -130,9 +133,7 @@ BOOL LLToolBarView::postBuild() mBottomChatStack = findChild("bottom_chat_stack"); // Added to determine if toolbar gets hidden when empty - std::string current_skin = gSavedSettings.getString("SkinCurrent"); - mHideBottomOnEmpty = (current_skin == "vintage" || current_skin == "latency"); - // + mHideBottomOnEmpty = FSCommon::isLegacySkin(); return TRUE; } @@ -544,6 +545,17 @@ void LLToolBarView::onToolBarButtonAdded(LLView* button) // to prevent hiding the transient IM floater upon pressing "Voice controls". LLTransientFloaterMgr::getInstance()->addControlView(button); } + // Dockable QuickPrefs floater + else if (button->getName() == "quickprefs" && !FSCommon::isLegacySkin()) + { + LLTransientFloaterMgr::getInstance()->addControlView(button); + FloaterQuickPrefs* quickprefs_floater = LLFloaterReg::getTypedInstance("quickprefs"); + if (quickprefs_floater && quickprefs_floater->isShown()) + { + quickprefs_floater->dockToToolbarButton(); + } + } + // } void LLToolBarView::onToolBarButtonRemoved(LLView* button) @@ -581,6 +593,19 @@ void LLToolBarView::onToolBarButtonRemoved(LLView* button) { LLTransientFloaterMgr::getInstance()->removeControlView(button); } + // Dockable QuickPrefs floater + else if (button->getName() == "quickprefs" && !FSCommon::isLegacySkin()) + { + LLTransientFloaterMgr::getInstance()->removeControlView(button); + FloaterQuickPrefs* quickprefs_floater = LLFloaterReg::getTypedInstance("quickprefs"); + if (quickprefs_floater && quickprefs_floater->isShown()) + { + quickprefs_floater->setCanDock(false); + LLDockControl* dock_control = quickprefs_floater->getDockControl(); + dock_control->setDock(NULL); + } + } + // } void LLToolBarView::draw() diff --git a/indra/newview/quickprefs.cpp b/indra/newview/quickprefs.cpp index 6eeb6c258f..7a4e910c45 100644 --- a/indra/newview/quickprefs.cpp +++ b/indra/newview/quickprefs.cpp @@ -32,6 +32,7 @@ #include "quickprefs.h" +#include "fscommon.h" #include "llappviewer.h" #include "llcheckboxctrl.h" #include "llcolorswatch.h" @@ -97,6 +98,11 @@ FloaterQuickPrefs::FloaterQuickPrefs(const LLSD& key) { // For Phototools mCommitCallbackRegistrar.add("Quickprefs.ShaderChanged", boost::bind(&handleSetShaderChanged, LLSD())); + + if (!getIsPhototools() && !FSCommon::isLegacySkin()) + { + LLTransientFloaterMgr::getInstance()->addControlView(this); + } } FloaterQuickPrefs::~FloaterQuickPrefs() @@ -105,6 +111,11 @@ FloaterQuickPrefs::~FloaterQuickPrefs() { mRlvBehaviorCallbackConnection.disconnect(); } + + if (!getIsPhototools() && !FSCommon::isLegacySkin()) + { + LLTransientFloaterMgr::getInstance()->removeControlView(this); + } } void FloaterQuickPrefs::onOpen(const LLSD& key) @@ -140,6 +151,8 @@ void FloaterQuickPrefs::onOpen(const LLSD& key) } } // + + dockToToolbarButton(); } @@ -375,7 +388,7 @@ BOOL FloaterQuickPrefs::postBuild() // bail out here if this is a reused Phototools floater if (getIsPhototools()) { - return LLDockableFloater::postBuild(); + return LLTransientDockableFloater::postBuild(); } // find the layout_stack to insert the controls into @@ -432,7 +445,7 @@ BOOL FloaterQuickPrefs::postBuild() mControlNameCombo->sortByName(); // - return LLDockableFloater::postBuild(); + return LLTransientDockableFloater::postBuild(); } void FloaterQuickPrefs::loadSavedSettingsFromFile(const std::string& settings_path) @@ -653,7 +666,7 @@ void FloaterQuickPrefs::draw() mWLSunPos->setCurSliderValue(val); - LLFloater::draw(); + LLTransientDockableFloater::draw(); } void FloaterQuickPrefs::onSunMoved() @@ -1874,3 +1887,35 @@ void FloaterQuickPrefs::onClickRestoreDefaults() LLNotificationsUtil::add("ConfirmRestoreQuickPrefsDefaults", LLSD(), LLSD(), boost::bind(&FloaterQuickPrefs::callbackRestoreDefaults, this, _1, _2)); } // + +void FloaterQuickPrefs::dockToToolbarButton() +{ + LLCommandId command_id("quickprefs"); + S32 toolbar_loc = gToolBarView->hasCommand(command_id); + + if (toolbar_loc != LLToolBarEnums::TOOLBAR_NONE && !FSCommon::isLegacySkin()) + { + LLDockControl::DocAt doc_at = LLDockControl::TOP; + switch (toolbar_loc) + { + case LLToolBarEnums::TOOLBAR_LEFT: + doc_at = LLDockControl::RIGHT; + break; + + case LLToolBarEnums::TOOLBAR_RIGHT: + doc_at = LLDockControl::LEFT; + break; + } + setCanDock(true); + LLView* anchor_panel = gToolBarView->findChildView("quickprefs"); + setUseTongue(anchor_panel); + // Garbage collected by std::auto_ptr + setDockControl(new LLDockControl(anchor_panel, this, getDockTongue(doc_at), doc_at)); + } + else + { + setUseTongue(false); + setDockControl(NULL); + setCanDock(false); + } +} diff --git a/indra/newview/quickprefs.h b/indra/newview/quickprefs.h index 937a57710d..186e219c86 100644 --- a/indra/newview/quickprefs.h +++ b/indra/newview/quickprefs.h @@ -110,6 +110,8 @@ public: void refreshSettings(); bool getIsPhototools() const { return getName() == PHOTOTOOLS_FLOATER; }; + void dockToToolbarButton(); + private: LLMultiSliderCtrl* mWLSunPos; diff --git a/indra/newview/skins/default/xui/en/floater_quickprefs.xml b/indra/newview/skins/default/xui/en/floater_quickprefs.xml index 14d1ea69af..1d698c4753 100644 --- a/indra/newview/skins/default/xui/en/floater_quickprefs.xml +++ b/indra/newview/skins/default/xui/en/floater_quickprefs.xml @@ -3,7 +3,7 @@ positioning="centered" legacy_header_height="18" can_resize="false" - can_dock="false" + can_dock="true" can_close="true" height="160" width="260" @@ -13,7 +13,7 @@ save_rect="true" save_visibility="true" single_instance="true" - save_dock_state="false" + save_dock_state="true" title="Quick Preferences">