From c75225bcb9781b090f1abcc93c4163230b8ad73e Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Thu, 20 May 2010 16:51:35 +0300 Subject: EXT-7104 WIP Enable Build button and set necessary callbacks. Because it is not enough to call showInstance for Build Floater it was implemented in a such way: * set save_visibility==true in floater tools to update button toggle state properly and subscribe Build button to listen visibility changes * added callback to observe parcel changing to set build button enabled/disabled. KNOWN ISSUE: if build permissions are changed button will not change state until restart/teleport Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/413/ --HG-- branch : product-engine --- indra/newview/llbottomtray.cpp | 35 +++++++++++++++++----- .../newview/skins/default/xui/en/floater_tools.xml | 1 + .../skins/default/xui/en/panel_bottomtray.xml | 5 ++-- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/indra/newview/llbottomtray.cpp b/indra/newview/llbottomtray.cpp index 0595bedd31..caf43f5ddc 100644 --- a/indra/newview/llbottomtray.cpp +++ b/indra/newview/llbottomtray.cpp @@ -35,20 +35,32 @@ #define LLBOTTOMTRAY_CPP #include "llbottomtray.h" -#include "llagentcamera.h" -#include "llchiclet.h" +// library includes #include "llfloaterreg.h" #include "llflyoutbutton.h" -#include "llimfloater.h" // for LLIMFloater #include "lllayoutstack.h" -#include "llnearbychatbar.h" +#include "llnotifications.h" #include "llnotificationsutil.h" +#include "lltexteditor.h" + +// newview includes +#include "llagentcamera.h" +#include "llchiclet.h" +#include "llfloatercamera.h" +#include "llimfloater.h" // for LLIMFloater +#include "llnearbychatbar.h" #include "llspeakbutton.h" #include "llsplitbutton.h" #include "llsyswellwindow.h" -#include "llfloatercamera.h" -#include "lltexteditor.h" -#include "llnotifications.h" +#include "lltoolmgr.h" +#include "llviewerparcelmgr.h" + +static void update_build_button_enable_state() +{ + bool can_edit = LLToolMgr::getInstance()->canEdit(); + + LLBottomTray::getInstance()->childSetEnabled("build_btn", can_edit); +} // Build time optimization, generate extern template once in .cpp file template class LLBottomTray* LLSingleton::getInstance(); @@ -508,6 +520,8 @@ BOOL LLBottomTray::postBuild() showWellButton(RS_IM_WELL, !LLIMWellWindow::getInstance()->isWindowEmpty()); showWellButton(RS_NOTIFICATION_WELL, !LLNotificationWellWindow::getInstance()->isWindowEmpty()); + LLViewerParcelMgr::getInstance()->addAgentParcelChangedCallback(boost::bind(&update_build_button_enable_state)); + return TRUE; } @@ -1246,6 +1260,13 @@ void LLBottomTray::setButtonsControlsAndListeners() gSavedSettings.getControl("ShowSearchButton")->getSignal()->connect(boost::bind(&LLBottomTray::toggleShowButton, RS_BUTTON_SEARCH, _2)); gSavedSettings.getControl("ShowWorldMapButton")->getSignal()->connect(boost::bind(&LLBottomTray::toggleShowButton, RS_BUTTON_WORLD_MAP, _2)); gSavedSettings.getControl("ShowMiniMapButton")->getSignal()->connect(boost::bind(&LLBottomTray::toggleShowButton, RS_BUTTON_MINI_MAP, _2)); + + + LLButton* build_btn = getChild("build_btn"); + // set control name for Build button. It is not enough to link it with Button.SetFloaterToggle in xml + std::string vis_control_name = LLFloaterReg::declareVisibilityControl("build"); + // Set the button control value (toggle state) to the floater visibility control (Sets the value as well) + build_btn->setControlVariable(LLUI::sSettingGroups["floater"]->getControl(vis_control_name)); } bool LLBottomTray::toggleShowButton(LLBottomTray::EResizeState button_type, const LLSD& new_visibility) diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml index 0c7ef3619d..c3c63cec37 100644 --- a/indra/newview/skins/default/xui/en/floater_tools.xml +++ b/indra/newview/skins/default/xui/en/floater_tools.xml @@ -11,6 +11,7 @@ save_rect="true" short_title="BUILD TOOLS" single_instance="true" + save_visibility="true" sound_flags="0" width="295"> -- cgit v1.2.3