Skip to content
Snippets Groups Projects
Commit af827615 authored by Jonathan Yap's avatar Jonathan Yap
Browse files

STORM-2082 Initial support for presets popup from status bar

parent f30e518f
No related branches found
No related tags found
No related merge requests found
Showing with 312 additions and 10 deletions
......@@ -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
......
/**
* @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<LLFloaterPreference*>
(LLFloaterReg::showInstance("preferences"));
if (prefsfloater)
{
// grab the 'move' panel from the preferences floater and
// bring it the front!
LLTabContainer* tabcontainer = prefsfloater->getChild<LLTabContainer>("pref core");
LLPanel* movepanel = prefsfloater->getChild<LLPanel>("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<LLFloaterPreference*>
(LLFloaterReg::showInstance("preferences"));
if (prefsfloater)
{
// grab the 'graphics' panel from the preferences floater and
// bring it the front!
LLTabContainer* tabcontainer = prefsfloater->getChild<LLTabContainer>("pref core");
LLPanel* graphicspanel = prefsfloater->getChild<LLPanel>("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);
}
}
/**
* @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
......@@ -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);
}
}
}
}
......
......@@ -44,6 +44,7 @@ class LLPresetsManager : public LLSingleton<LLPresetsManager>
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);
......
......@@ -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<LLIconCtrl>( "presets_icon" );
mIconPresets->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterPresets, this));
mBtnVolume = getChild<LLButton>( "volume_btn" );
mBtnVolume->setClickedCallback( onClickVolume, this );
mBtnVolume->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterVolume, this));
......@@ -228,6 +232,11 @@ BOOL LLStatusBar::postBuild()
mSGPacketLoss = LLUICtrlFactory::create<LLStatGraph>(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<LLIconCtrl>( "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<LLButton>( "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);
}
......
......@@ -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 @@ class LLStatusBar
void onClickBuyCurrency();
void onVolumeChanged(const LLSD& newvalue);
void onMouseEnterPresets();
void onMouseEnterVolume();
void onMouseEnterNearbyMedia();
void onClickScreen(S32 x, S32 y);
......@@ -103,6 +106,7 @@ class LLStatusBar
LLStatGraph *mSGPacketLoss;
LLView *mBtnStats;
LLIconCtrl *mIconPresets;
LLButton *mBtnVolume;
LLTextBox *mBoxBalance;
LLButton *mMediaToggle;
......@@ -115,6 +119,7 @@ class LLStatusBar
S32 mSquareMetersCommitted;
LLFrameTimer* mBalanceTimer;
LLFrameTimer* mHealthTimer;
LLPanelPresetsPulldown* mPanelPresetsPulldown;
LLPanelVolumePulldown* mPanelVolumePulldown;
LLPanelNearByMedia* mPanelNearByMedia;
};
......
......@@ -204,7 +204,7 @@ with the same filename but different name
<texture name="Facebook_Icon" file_name="icons/Facebook.png" preload="false" />
<texture name="FastPrefs_Icon" file_name="icons/FastPrefs_Icon.png" preload="true" />
<texture name="Presets_Icon" file_name="icons/Presets_Icon.png" preload="true" />
<texture name="Favorite_Star_Active" file_name="navbar/Favorite_Star_Active.png" preload="false" />
<texture name="Favorite_Star_Off" file_name="navbar/Favorite_Star_Off.png" preload="false" />
......
......@@ -37,14 +37,14 @@
<button
follows="top|left"
height="23"
label="Save As..."
label="Save..."
layout="topleft"
left_pad="5"
name="PrefSaveAsButton"
name="PrefSaveButton"
top_delta="0"
width="115">
<button.commit_callback
function="Pref.PrefSaveAs" />
function="Pref.PrefSave" />
</button>
<button
follows="top|left"
......
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<panel
background_opaque="true"
background_visible="true"
bg_opaque_image="Volume_Background"
bg_alpha_image="Volume_Background"
border_visible="false"
border="false"
chrome="true"
follows="bottom"
height="155"
layout="topleft"
name="presets_pulldown"
width="225">
<button
name="open_prefs_btn"
image_overlay="Icon_Gear_Foreground"
hover_glow_amount="0.15"
tool_tip = "Bring up graphics prefs"
top="5"
left="5"
height="20"
width="20">
<button.commit_callback
function="Presets.GoGraphicsPrefs" />
</button>
<text
type="string"
length="1"
follows="left|top"
height="12"
layout="topleft"
top_delta="4"
left_delta="25"
font.style="BOLD"
name="Graphic Presets"
width="120">
Graphic Presets
</text>
</panel>
......@@ -105,14 +105,13 @@
width="145">
24:00 AM PST
</text>
<button
<icon
follows="right|top"
height="16"
image_unselected="FastPrefs_Icon"
image_selected="FastPrefs_Icon"
image_name="Presets_Icon"
left_pad="5"
top="2"
name="fastprefs_btn"
name="presets_icon"
width="18" />
<button
follows="right|top"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment