From af827615acc6cce0457ba00810136c41283f6158 Mon Sep 17 00:00:00 2001 From: Jonathan Yap Date: Fri, 28 Nov 2014 10:00:41 -0500 Subject: STORM-2082 Initial support for presets popup from status bar --- indra/newview/CMakeLists.txt | 2 + indra/newview/llpanelpresetspulldown.cpp | 155 +++++++++++++++++++++ indra/newview/llpanelpresetspulldown.h | 57 ++++++++ indra/newview/llpresetsmanager.cpp | 15 +- indra/newview/llpresetsmanager.h | 1 + indra/newview/llstatusbar.cpp | 32 +++++ indra/newview/llstatusbar.h | 5 + .../default/textures/icons/FastPrefs_Icon.png | Bin 268 -> 0 bytes .../skins/default/textures/icons/Presets_Icon.png | Bin 0 -> 268 bytes indra/newview/skins/default/textures/textures.xml | 2 +- .../default/xui/en/panel_preferences_graphics1.xml | 6 +- .../default/xui/en/panel_presets_pulldown.xml | 40 ++++++ .../skins/default/xui/en/panel_status_bar.xml | 7 +- 13 files changed, 312 insertions(+), 10 deletions(-) create mode 100644 indra/newview/llpanelpresetspulldown.cpp create mode 100644 indra/newview/llpanelpresetspulldown.h delete mode 100644 indra/newview/skins/default/textures/icons/FastPrefs_Icon.png create mode 100644 indra/newview/skins/default/textures/icons/Presets_Icon.png create mode 100644 indra/newview/skins/default/xui/en/panel_presets_pulldown.xml diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index e95cbf391d..e29506bdf5 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -451,6 +451,7 @@ set(viewer_SOURCE_FILES llpanelplaceprofile.cpp llpanelplaces.cpp llpanelplacestab.cpp + llpanelpresetspulldown.cpp llpanelprimmediacontrols.cpp llpanelprofile.cpp llpanelsnapshot.cpp @@ -1051,6 +1052,7 @@ set(viewer_HEADER_FILES llpanelplaceprofile.h llpanelplaces.h llpanelplacestab.h + llpanelpresetspulldown.h llpanelprimmediacontrols.h llpanelprofile.h llpanelsnapshot.h diff --git a/indra/newview/llpanelpresetspulldown.cpp b/indra/newview/llpanelpresetspulldown.cpp new file mode 100644 index 0000000000..d93afd674c --- /dev/null +++ b/indra/newview/llpanelpresetspulldown.cpp @@ -0,0 +1,155 @@ +/** + * @file llpanelpresetspulldown.cpp + * @author Tofu Linden + * @brief A panel showing a quick way to pick presets + * + * $LicenseInfo:firstyear=2008&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llpanelpresetspulldown.h" + +// Viewer libs +#include "llviewercontrol.h" +#include "llstatusbar.h" + +// Linden libs +#include "llbutton.h" +#include "lltabcontainer.h" +#include "llfloaterreg.h" +#include "llfloaterpreference.h" +#include "llsliderctrl.h" + +/* static */ const F32 LLPanelPresetsPulldown::sAutoCloseFadeStartTimeSec = 4.0f; +/* static */ const F32 LLPanelPresetsPulldown::sAutoCloseTotalTimeSec = 5.0f; + +///---------------------------------------------------------------------------- +/// Class LLPanelPresetsPulldown +///---------------------------------------------------------------------------- + +// Default constructor +LLPanelPresetsPulldown::LLPanelPresetsPulldown() +{ + mHoverTimer.stop(); + + mCommitCallbackRegistrar.add("Presets.GoMoveViewPrefs", boost::bind(&LLPanelPresetsPulldown::onMoveViewButtonClick, this, _2)); + mCommitCallbackRegistrar.add("Presets.GoGraphicsPrefs", boost::bind(&LLPanelPresetsPulldown::onGraphicsButtonClick, this, _2)); + buildFromFile( "panel_presets_pulldown.xml"); +} + +BOOL LLPanelPresetsPulldown::postBuild() +{ + return LLPanel::postBuild(); +} + +/*virtual*/ +void LLPanelPresetsPulldown::onMouseEnter(S32 x, S32 y, MASK mask) +{ + mHoverTimer.stop(); + LLPanel::onMouseEnter(x,y,mask); +} + +/*virtual*/ +void LLPanelPresetsPulldown::onTopLost() +{ + setVisible(FALSE); +} + +/*virtual*/ +void LLPanelPresetsPulldown::onMouseLeave(S32 x, S32 y, MASK mask) +{ + mHoverTimer.start(); + LLPanel::onMouseLeave(x,y,mask); +} + +/*virtual*/ +void LLPanelPresetsPulldown::onVisibilityChange ( BOOL new_visibility ) +{ + if (new_visibility) + { + mHoverTimer.start(); // timer will be stopped when mouse hovers over panel + } + else + { + mHoverTimer.stop(); + + } +} + +void LLPanelPresetsPulldown::onMoveViewButtonClick(const LLSD& user_data) +{ + // close the minicontrol, we're bringing up the big one + setVisible(FALSE); + + // bring up the prefs floater + LLFloaterPreference* prefsfloater = dynamic_cast + (LLFloaterReg::showInstance("preferences")); + if (prefsfloater) + { + // grab the 'move' panel from the preferences floater and + // bring it the front! + LLTabContainer* tabcontainer = prefsfloater->getChild("pref core"); + LLPanel* movepanel = prefsfloater->getChild("move"); + if (tabcontainer && movepanel) + { + tabcontainer->selectTabPanel(movepanel); + } + } +} + +void LLPanelPresetsPulldown::onGraphicsButtonClick(const LLSD& user_data) +{ + // close the minicontrol, we're bringing up the big one + setVisible(FALSE); + + // bring up the prefs floater + LLFloaterPreference* prefsfloater = dynamic_cast + (LLFloaterReg::showInstance("preferences")); + if (prefsfloater) + { + // grab the 'graphics' panel from the preferences floater and + // bring it the front! + LLTabContainer* tabcontainer = prefsfloater->getChild("pref core"); + LLPanel* graphicspanel = prefsfloater->getChild("display"); + if (tabcontainer && graphicspanel) + { + tabcontainer->selectTabPanel(graphicspanel); + } + } +} + +//virtual +void LLPanelPresetsPulldown::draw() +{ + F32 alpha = mHoverTimer.getStarted() + ? clamp_rescale(mHoverTimer.getElapsedTimeF32(), sAutoCloseFadeStartTimeSec, sAutoCloseTotalTimeSec, 1.f, 0.f) + : 1.0f; + LLViewDrawContext context(alpha); + + LLPanel::draw(); + + if (alpha == 0.f) + { + setVisible(FALSE); + } +} diff --git a/indra/newview/llpanelpresetspulldown.h b/indra/newview/llpanelpresetspulldown.h new file mode 100644 index 0000000000..400dd73a4c --- /dev/null +++ b/indra/newview/llpanelpresetspulldown.h @@ -0,0 +1,57 @@ +/** + * @file llpanelpresetspulldown.h + * @author Tofu Linden + * @brief A panel showing a quick way to pick presets + * + * $LicenseInfo:firstyear=2008&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLPANELPRESETSPULLDOWN_H +#define LL_LLPANELPRESETSPULLDOWN_H + +#include "linden_common.h" + +#include "llpanel.h" + +class LLFrameTimer; + +class LLPanelPresetsPulldown : public LLPanel +{ + public: + LLPanelPresetsPulldown(); + /*virtual*/ void draw(); + /*virtual*/ void onMouseEnter(S32 x, S32 y, MASK mask); + /*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask); + /*virtual*/ void onTopLost(); + /*virtual*/ void onVisibilityChange ( BOOL new_visibility ); + /*virtual*/ BOOL postBuild(); + + private: + void onGraphicsButtonClick(const LLSD& user_data); + void onMoveViewButtonClick(const LLSD& user_data); + + LLFrameTimer mHoverTimer; + static const F32 sAutoCloseFadeStartTimeSec; + static const F32 sAutoCloseTotalTimeSec; +}; + +#endif // LL_LLPANELPRESETSPULLDOWN_H diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp index 8fd9024fef..642d9819fe 100644 --- a/indra/newview/llpresetsmanager.cpp +++ b/indra/newview/llpresetsmanager.cpp @@ -62,6 +62,11 @@ std::string LLPresetsManager::getUserDir(const std::string& subdirectory) return full_path; } +std::string LLPresetsManager::getCameraPresetsDir() +{ + return getUserDir(PRESETS_CAMERA_DIR); +} + std::string LLPresetsManager::getGraphicPresetsDir() { return getUserDir(PRESETS_GRAPHIC_DIR); @@ -70,7 +75,6 @@ std::string LLPresetsManager::getGraphicPresetsDir() void LLPresetsManager::getPresetNames(preset_name_list_t& presets) const { presets = mPresetNames; - } void LLPresetsManager::loadPresetNamesFromDir(const std::string& dir) @@ -90,7 +94,14 @@ void LLPresetsManager::loadPresetNamesFromDir(const std::string& dir) { std::string path = gDirUtilp->add(dir, file); std::string name(gDirUtilp->getBaseFileName(LLURI::unescape(path), /*strip_exten = */ true)); - mPresetNames.push_back(name); + if ("Default" != name) + { + mPresetNames.push_back(name); + } + else + { + mPresetNames.insert(mPresetNames.begin(), name); + } } } } diff --git a/indra/newview/llpresetsmanager.h b/indra/newview/llpresetsmanager.h index 5bf85b835a..9b0de887ce 100644 --- a/indra/newview/llpresetsmanager.h +++ b/indra/newview/llpresetsmanager.h @@ -44,6 +44,7 @@ public: void loadPresetNamesFromDir(const std::string& dir); void savePreset(const std::string & name); void loadPreset(const std::string & name); + static std::string getCameraPresetsDir(); static std::string getGraphicPresetsDir(); bool removeParamSet(const std::string& name, bool delete_from_disk); diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp index eedb829b48..3c8dcaf4d4 100755 --- a/indra/newview/llstatusbar.cpp +++ b/indra/newview/llstatusbar.cpp @@ -38,6 +38,7 @@ #include "llfloaterbuycurrency.h" #include "llbuycurrencyhtml.h" #include "llpanelnearbymedia.h" +#include "llpanelpresetspulldown.h" #include "llpanelvolumepulldown.h" #include "llfloaterregioninfo.h" #include "llfloaterscriptdebug.h" @@ -175,6 +176,9 @@ BOOL LLStatusBar::postBuild() mBtnStats = getChildView("stat_btn"); + mIconPresets = getChild( "presets_icon" ); + mIconPresets->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterPresets, this)); + mBtnVolume = getChild( "volume_btn" ); mBtnVolume->setClickedCallback( onClickVolume, this ); mBtnVolume->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterVolume, this)); @@ -228,6 +232,11 @@ BOOL LLStatusBar::postBuild() mSGPacketLoss = LLUICtrlFactory::create(pgp); addChild(mSGPacketLoss); + mPanelPresetsPulldown = new LLPanelPresetsPulldown(); + addChild(mPanelPresetsPulldown); + mPanelPresetsPulldown->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT); + mPanelPresetsPulldown->setVisible(FALSE); + mPanelVolumePulldown = new LLPanelVolumePulldown(); addChild(mPanelVolumePulldown); mPanelVolumePulldown->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT); @@ -465,6 +474,27 @@ void LLStatusBar::onClickBuyCurrency() LLFirstUse::receiveLindens(false); } +void LLStatusBar::onMouseEnterPresets() +{ + LLIconCtrl* icon = getChild( "presets_icon" ); + LLRect btn_rect = icon->getRect(); + LLRect pulldown_rect = mPanelPresetsPulldown->getRect(); + pulldown_rect.setLeftTopAndSize(btn_rect.mLeft - + (pulldown_rect.getWidth() - btn_rect.getWidth()), + btn_rect.mBottom, + pulldown_rect.getWidth(), + pulldown_rect.getHeight()); + + mPanelPresetsPulldown->setShape(pulldown_rect); + + // show the master presets pull-down + LLUI::clearPopups(); + LLUI::addPopup(mPanelPresetsPulldown); + mPanelNearByMedia->setVisible(FALSE); + mPanelVolumePulldown->setVisible(FALSE); + mPanelPresetsPulldown->setVisible(TRUE); +} + void LLStatusBar::onMouseEnterVolume() { LLButton* volbtn = getChild( "volume_btn" ); @@ -482,6 +512,7 @@ void LLStatusBar::onMouseEnterVolume() // show the master volume pull-down LLUI::clearPopups(); LLUI::addPopup(mPanelVolumePulldown); + mPanelPresetsPulldown->setVisible(FALSE); mPanelNearByMedia->setVisible(FALSE); mPanelVolumePulldown->setVisible(TRUE); } @@ -505,6 +536,7 @@ void LLStatusBar::onMouseEnterNearbyMedia() LLUI::clearPopups(); LLUI::addPopup(mPanelNearByMedia); + mPanelPresetsPulldown->setVisible(FALSE); mPanelVolumePulldown->setVisible(FALSE); mPanelNearByMedia->setVisible(TRUE); } diff --git a/indra/newview/llstatusbar.h b/indra/newview/llstatusbar.h index 9d28e6c2bc..277f039f20 100755 --- a/indra/newview/llstatusbar.h +++ b/indra/newview/llstatusbar.h @@ -41,8 +41,10 @@ class LLUICtrl; class LLUUID; class LLFrameTimer; class LLStatGraph; +class LLPanelPresetsPulldown; class LLPanelVolumePulldown; class LLPanelNearByMedia; +class LLIconCtrl; class LLStatusBar : public LLPanel @@ -89,6 +91,7 @@ private: void onClickBuyCurrency(); void onVolumeChanged(const LLSD& newvalue); + void onMouseEnterPresets(); void onMouseEnterVolume(); void onMouseEnterNearbyMedia(); void onClickScreen(S32 x, S32 y); @@ -103,6 +106,7 @@ private: LLStatGraph *mSGPacketLoss; LLView *mBtnStats; + LLIconCtrl *mIconPresets; LLButton *mBtnVolume; LLTextBox *mBoxBalance; LLButton *mMediaToggle; @@ -115,6 +119,7 @@ private: S32 mSquareMetersCommitted; LLFrameTimer* mBalanceTimer; LLFrameTimer* mHealthTimer; + LLPanelPresetsPulldown* mPanelPresetsPulldown; LLPanelVolumePulldown* mPanelVolumePulldown; LLPanelNearByMedia* mPanelNearByMedia; }; diff --git a/indra/newview/skins/default/textures/icons/FastPrefs_Icon.png b/indra/newview/skins/default/textures/icons/FastPrefs_Icon.png deleted file mode 100644 index 380d3812d8..0000000000 Binary files a/indra/newview/skins/default/textures/icons/FastPrefs_Icon.png and /dev/null differ diff --git a/indra/newview/skins/default/textures/icons/Presets_Icon.png b/indra/newview/skins/default/textures/icons/Presets_Icon.png new file mode 100644 index 0000000000..380d3812d8 Binary files /dev/null and b/indra/newview/skins/default/textures/icons/Presets_Icon.png differ diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml index 2dbf9d1bab..feddb04a56 100755 --- a/indra/newview/skins/default/textures/textures.xml +++ b/indra/newview/skins/default/textures/textures.xml @@ -204,7 +204,7 @@ with the same filename but different name - + diff --git a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml index 2cbba946d4..d8095c0476 100755 --- a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml +++ b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml @@ -37,14 +37,14 @@ + + Graphic Presets + + diff --git a/indra/newview/skins/default/xui/en/panel_status_bar.xml b/indra/newview/skins/default/xui/en/panel_status_bar.xml index a1f7503269..bb38c384a8 100755 --- a/indra/newview/skins/default/xui/en/panel_status_bar.xml +++ b/indra/newview/skins/default/xui/en/panel_status_bar.xml @@ -105,14 +105,13 @@ width="145"> 24:00 AM PST -