Skip to content
Snippets Groups Projects
Commit 1fa0b3fe authored by maxim_productengine's avatar maxim_productengine
Browse files

SL-12186 WIP Add new 'My camera presets' floater

parent dd812811
Branches
Tags
No related merge requests found
...@@ -229,6 +229,7 @@ set(viewer_SOURCE_FILES ...@@ -229,6 +229,7 @@ set(viewer_SOURCE_FILES
llfloaterbuycurrencyhtml.cpp llfloaterbuycurrencyhtml.cpp
llfloaterbuyland.cpp llfloaterbuyland.cpp
llfloatercamera.cpp llfloatercamera.cpp
llfloatercamerapresets.cpp
llfloaterchatvoicevolume.cpp llfloaterchatvoicevolume.cpp
llfloatercolorpicker.cpp llfloatercolorpicker.cpp
llfloaterconversationlog.cpp llfloaterconversationlog.cpp
...@@ -855,6 +856,7 @@ set(viewer_HEADER_FILES ...@@ -855,6 +856,7 @@ set(viewer_HEADER_FILES
llfloaterbuycurrency.h llfloaterbuycurrency.h
llfloaterbuycurrencyhtml.h llfloaterbuycurrencyhtml.h
llfloaterbuyland.h llfloaterbuyland.h
llfloatercamerapresets.h
llfloatercamera.h llfloatercamera.h
llfloaterchatvoicevolume.h llfloaterchatvoicevolume.h
llfloatercolorpicker.h llfloatercolorpicker.h
......
...@@ -351,6 +351,7 @@ LLFloaterCamera::LLFloaterCamera(const LLSD& val) ...@@ -351,6 +351,7 @@ LLFloaterCamera::LLFloaterCamera(const LLSD& val)
LLHints::registerHintTarget("view_popup", getHandle()); LLHints::registerHintTarget("view_popup", getHandle());
mCommitCallbackRegistrar.add("CameraPresets.ChangeView", boost::bind(&LLFloaterCamera::onClickCameraItem, _2)); mCommitCallbackRegistrar.add("CameraPresets.ChangeView", boost::bind(&LLFloaterCamera::onClickCameraItem, _2));
mCommitCallbackRegistrar.add("CameraPresets.Save", boost::bind(&LLFloaterCamera::onSavePreset, this)); mCommitCallbackRegistrar.add("CameraPresets.Save", boost::bind(&LLFloaterCamera::onSavePreset, this));
mCommitCallbackRegistrar.add("CameraPresets.ShowPresetsList", boost::bind(&LLFloaterReg::showInstance, "camera_presets", LLSD(), FALSE));
} }
// virtual // virtual
...@@ -599,7 +600,7 @@ void LLFloaterCamera::onSavePreset() ...@@ -599,7 +600,7 @@ void LLFloaterCamera::onSavePreset()
LLSD key; LLSD key;
key["subdirectory"] = PRESETS_CAMERA; key["subdirectory"] = PRESETS_CAMERA;
std::string current_preset = gSavedSettings.getString("PresetCameraActive"); std::string current_preset = gSavedSettings.getString("PresetCameraActive");
bool is_custom_preset = current_preset != "" && !LLPresetsManager::getInstance()->isDefaultPreset(current_preset); bool is_custom_preset = current_preset != "" && !LLPresetsManager::getInstance()->isDefaultCameraPreset(current_preset);
key["index"] = is_custom_preset ? 1 : 0; key["index"] = is_custom_preset ? 1 : 0;
LLFloaterReg::showInstance("save_pref_preset", key); LLFloaterReg::showInstance("save_pref_preset", key);
} }
......
/**
* @file llfloatercamerapresets.cpp
*
* $LicenseInfo:firstyear=2019&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2019, 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 "llfloatercamerapresets.h"
#include "llfloaterreg.h"
#include "llnotificationsutil.h"
#include "llpresetsmanager.h"
#include "llviewercontrol.h"
LLFloaterCameraPresets::LLFloaterCameraPresets(const LLSD& key)
: LLFloater(key)
{}
LLFloaterCameraPresets::~LLFloaterCameraPresets()
{}
BOOL LLFloaterCameraPresets::postBuild()
{
mPresetList = getChild<LLFlatListView>("preset_list");
LLPresetsManager::getInstance()->setPresetListChangeCameraCallback(boost::bind(&LLFloaterCameraPresets::populateList, this));
return TRUE;
}
void LLFloaterCameraPresets::onOpen(const LLSD& key)
{
populateList();
}
void LLFloaterCameraPresets::populateList()
{
mPresetList->clear();
LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
std::string presets_dir = presetsMgr->getPresetsDir(PRESETS_CAMERA);
std::list<std::string> preset_names;
presetsMgr->loadPresetNamesFromDir(presets_dir, preset_names, DEFAULT_TOP);
for (std::list<std::string>::const_iterator it = preset_names.begin(); it != preset_names.end(); ++it)
{
const std::string& name = *it;
bool is_default = presetsMgr->isDefaultCameraPreset(name);
LLCameraPresetFlatItem* item = new LLCameraPresetFlatItem(name, is_default);
item->postBuild();
mPresetList->addItem(item);
}
}
LLCameraPresetFlatItem::LLCameraPresetFlatItem(const std::string &preset_name, bool is_default)
: LLPanel(),
mPresetName(preset_name),
mIsDefaultPrest(is_default)
{
mCommitCallbackRegistrar.add("CameraPresets.Delete", boost::bind(&LLCameraPresetFlatItem::onDeleteBtnClick, this));
mCommitCallbackRegistrar.add("CameraPresets.Reset", boost::bind(&LLCameraPresetFlatItem::onResetBtnClick, this));
buildFromFile("panel_camera_preset_item.xml");
}
LLCameraPresetFlatItem::~LLCameraPresetFlatItem()
{
}
BOOL LLCameraPresetFlatItem::postBuild()
{
mDeleteBtn = getChild<LLButton>("delete_btn");
mDeleteBtn->setVisible(!mIsDefaultPrest);
mResetBtn = getChild<LLButton>("reset_btn");
mResetBtn->setVisible(mIsDefaultPrest);
LLStyle::Params style;
LLTextBox* name_text = getChild<LLTextBox>("preset_name");
LLFontDescriptor new_desc(name_text->getFont()->getFontDesc());
new_desc.setStyle(mIsDefaultPrest ? LLFontGL::ITALIC : LLFontGL::NORMAL);
LLFontGL* new_font = LLFontGL::getFont(new_desc);
style.font = new_font;
name_text->setText(mPresetName, style);
return true;
}
void LLCameraPresetFlatItem::onDeleteBtnClick()
{
if (!LLPresetsManager::getInstance()->deletePreset(PRESETS_CAMERA, mPresetName))
{
LLSD args;
args["NAME"] = mPresetName;
LLNotificationsUtil::add("PresetNotDeleted", args);
}
else if (gSavedSettings.getString("PresetCameraActive") == mPresetName)
{
gSavedSettings.setString("PresetCameraActive", "");
}
}
void LLCameraPresetFlatItem::onResetBtnClick()
{
LLPresetsManager::getInstance()->resetCameraPreset(mPresetName);
}
/**
* @file llfloatercamerapresets.h
*
* $LicenseInfo:firstyear=2019&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2019, 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 LLFLOATERCAMERAPRESETS_H
#define LLFLOATERCAMERAPRESETS_H
#include "llfloater.h"
#include "llflatlistview.h"
class LLFloaterReg;
class LLFloaterCameraPresets : public LLFloater
{
friend class LLFloaterReg;
virtual BOOL postBuild();
virtual void onOpen(const LLSD& key);
void populateList();
private:
LLFloaterCameraPresets(const LLSD& key);
~LLFloaterCameraPresets();
LLFlatListView* mPresetList;
};
class LLCameraPresetFlatItem : public LLPanel
{
public:
LLCameraPresetFlatItem(const std::string &preset_name, bool is_default);
virtual ~LLCameraPresetFlatItem();
virtual BOOL postBuild();
private:
void onDeleteBtnClick();
void onResetBtnClick();
LLButton* mDeleteBtn;
LLButton* mResetBtn;
std::string mPresetName;
bool mIsDefaultPrest;
};
#endif
...@@ -89,6 +89,7 @@ void LLPresetsManager::startWatching(const std::string& subdirectory) ...@@ -89,6 +89,7 @@ void LLPresetsManager::startWatching(const std::string& subdirectory)
{ {
std::vector<std::string> name_list; std::vector<std::string> name_list;
getControlNames(name_list); getControlNames(name_list);
getOffsetControlNames(name_list);
for (std::vector<std::string>::iterator it = name_list.begin(); it != name_list.end(); ++it) for (std::vector<std::string>::iterator it = name_list.begin(); it != name_list.end(); ++it)
{ {
...@@ -164,7 +165,7 @@ void LLPresetsManager::loadPresetNamesFromDir(const std::string& dir, preset_nam ...@@ -164,7 +165,7 @@ void LLPresetsManager::loadPresetNamesFromDir(const std::string& dir, preset_nam
if (default_option == DEFAULT_VIEWS_HIDE) if (default_option == DEFAULT_VIEWS_HIDE)
{ {
if (isDefaultPreset(name)) if (isDefaultCameraPreset(name))
{ {
continue; continue;
} }
...@@ -239,6 +240,21 @@ void LLPresetsManager::getControlNames(std::vector<std::string>& names) ...@@ -239,6 +240,21 @@ void LLPresetsManager::getControlNames(std::vector<std::string>& names)
names = camera_controls; names = camera_controls;
} }
void LLPresetsManager::getOffsetControlNames(std::vector<std::string>& names)
{
const std::vector<std::string> offset_controls = boost::assign::list_of
("CameraOffsetRearView")
("CameraOffsetFrontView")
("CameraOffsetGroupView")
("CameraOffsetCustomPreset")
("FocusOffsetRearView")
("FocusOffsetFrontView")
("FocusOffsetGroupView")
("FocusOffsetCustomPreset")
;
names.insert(std::end(names), std::begin(offset_controls), std::end(offset_controls));
}
bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string name, bool createDefault) bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string name, bool createDefault)
{ {
if (LLTrans::getString(PRESETS_DEFAULT) == name) if (LLTrans::getString(PRESETS_DEFAULT) == name)
...@@ -300,7 +316,7 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n ...@@ -300,7 +316,7 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n
{ {
name_list.push_back(gAgentCamera.getCameraOffsetCtrlName()); name_list.push_back(gAgentCamera.getCameraOffsetCtrlName());
name_list.push_back(gAgentCamera.getFocusOffsetCtrlName()); name_list.push_back(gAgentCamera.getFocusOffsetCtrlName());
custom_camera_offsets = !isDefaultPreset(name); custom_camera_offsets = !isDefaultCameraPreset(name);
} }
for (std::vector<std::string>::iterator it = name_list.begin(); it != name_list.end(); ++it) for (std::vector<std::string>::iterator it = name_list.begin(); it != name_list.end(); ++it)
{ {
...@@ -489,11 +505,16 @@ bool LLPresetsManager::deletePreset(const std::string& subdirectory, std::string ...@@ -489,11 +505,16 @@ bool LLPresetsManager::deletePreset(const std::string& subdirectory, std::string
return sts; return sts;
} }
bool LLPresetsManager::isDefaultPreset(std::string preset_name) bool LLPresetsManager::isDefaultCameraPreset(std::string preset_name)
{ {
return (preset_name == PRESETS_REAR || preset_name == PRESETS_SIDE || preset_name == PRESETS_FRONT); return (preset_name == PRESETS_REAR || preset_name == PRESETS_SIDE || preset_name == PRESETS_FRONT);
} }
void LLPresetsManager::resetCameraPreset(std::string preset_name)
{
}
boost::signals2::connection LLPresetsManager::setPresetListChangeCameraCallback(const preset_list_signal_t::slot_type& cb) boost::signals2::connection LLPresetsManager::setPresetListChangeCameraCallback(const preset_list_signal_t::slot_type& cb)
{ {
return mPresetListChangeCameraSignal.connect(cb); return mPresetListChangeCameraSignal.connect(cb);
......
...@@ -71,7 +71,8 @@ class LLPresetsManager : public LLSingleton<LLPresetsManager> ...@@ -71,7 +71,8 @@ class LLPresetsManager : public LLSingleton<LLPresetsManager>
bool isCameraDirty(); bool isCameraDirty();
static void setCameraDirty(bool dirty); static void setCameraDirty(bool dirty);
bool isDefaultPreset(std::string preset_name); bool isDefaultCameraPreset(std::string preset_name);
void resetCameraPreset(std::string preset_name);
// Emitted when a preset gets loaded, deleted, or saved. // Emitted when a preset gets loaded, deleted, or saved.
boost::signals2::connection setPresetListChangeCameraCallback(const preset_list_signal_t::slot_type& cb); boost::signals2::connection setPresetListChangeCameraCallback(const preset_list_signal_t::slot_type& cb);
...@@ -88,6 +89,7 @@ class LLPresetsManager : public LLSingleton<LLPresetsManager> ...@@ -88,6 +89,7 @@ class LLPresetsManager : public LLSingleton<LLPresetsManager>
LOG_CLASS(LLPresetsManager); LOG_CLASS(LLPresetsManager);
void getControlNames(std::vector<std::string>& names); void getControlNames(std::vector<std::string>& names);
void getOffsetControlNames(std::vector<std::string>& names);
static void settingChanged(); static void settingChanged();
boost::signals2::connection mCameraChangedSignal; boost::signals2::connection mCameraChangedSignal;
......
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
#include "llfloaterbuyland.h" #include "llfloaterbuyland.h"
#include "llfloaterbvhpreview.h" #include "llfloaterbvhpreview.h"
#include "llfloatercamera.h" #include "llfloatercamera.h"
#include "llfloatercamerapresets.h"
#include "llfloaterchatvoicevolume.h" #include "llfloaterchatvoicevolume.h"
#include "llfloaterconversationlog.h" #include "llfloaterconversationlog.h"
#include "llfloaterconversationpreview.h" #include "llfloaterconversationpreview.h"
...@@ -215,6 +216,7 @@ void LLViewerFloaterReg::registerFloaters() ...@@ -215,6 +216,7 @@ void LLViewerFloaterReg::registerFloaters()
LLFloaterReg::add("bumps", "floater_bumps.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBump>); LLFloaterReg::add("bumps", "floater_bumps.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBump>);
LLFloaterReg::add("camera", "floater_camera.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterCamera>); LLFloaterReg::add("camera", "floater_camera.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterCamera>);
LLFloaterReg::add("camera_presets", "floater_camera_presets.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterCameraPresets>);
LLFloaterReg::add("chat_voice", "floater_voice_chat_volume.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterChatVoiceVolume>); LLFloaterReg::add("chat_voice", "floater_voice_chat_volume.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterChatVoiceVolume>);
LLFloaterReg::add("nearby_chat", "floater_im_session.xml", (LLFloaterBuildFunc)&LLFloaterIMNearbyChat::buildFloater); LLFloaterReg::add("nearby_chat", "floater_im_session.xml", (LLFloaterBuildFunc)&LLFloaterIMNearbyChat::buildFloater);
LLFloaterReg::add("compile_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterCompileQueue>); LLFloaterReg::add("compile_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterCompileQueue>);
......
...@@ -222,16 +222,22 @@ ...@@ -222,16 +222,22 @@
name="Use preset" name="Use preset"
value="default" /> value="default" />
</combo_box> </combo_box>
<icon <button
height="28" height="16"
width="28" width="16"
image_name="Command_Preferences_Icon"
layout="topleft" layout="topleft"
mouse_opaque="true" mouse_opaque="true"
name="icon_gear" name="gear_btn"
tool_tip="My Camera Presets" tool_tip="My Camera Presets"
top_delta="0" top_delta="3"
left_pad="5" /> left_pad="10"
image_selected="Icon_Gear"
image_pressed="Icon_Gear"
image_unselected="Icon_Gear"
is_toggle="true">
<button.commit_callback
function="CameraPresets.ShowPresetsList"/>
</button>
<button <button
follows="top|left" follows="top|left"
height="25" height="25"
...@@ -239,7 +245,7 @@ ...@@ -239,7 +245,7 @@
layout="topleft" layout="topleft"
left="0" left="0"
name="save_preset_btn" name="save_preset_btn"
top_pad="8" top_pad="18"
width="150"> width="150">
<button.commit_callback <button.commit_callback
function="CameraPresets.Save"/> function="CameraPresets.Save"/>
......
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<floater
legacy_header_height="18"
can_resize="true"
height="200"
min_height="150"
title="MY CAMERA PRESETS"
layout="topleft"
name="floater_camera_presets"
single_instance="true"
min_width="185"
width="250">
<flat_list_view
allow_select="true"
follows="all"
height="165"
layout="topleft"
left="3"
multi_select="false"
name="preset_list"
top="20"
width="245" />
</floater>
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<panel
follows="top|right|left"
height="20"
layout="topleft"
left="0"
name="camera_preset_item"
top="0"
width="280">
<text
follows="left"
height="20"
layout="topleft"
left="10"
parse_urls="false"
use_ellipses="true"
name="preset_name"
text_color="White"
top="2"
value="Default"
width="159" />
<button
follows="right"
image_selected="TrashItem_Off"
image_pressed="TrashItem_Off"
image_unselected="TrashItem_Off"
is_toggle="true"
layout="topleft"
left_pad="5"
right="-10"
name="delete_btn"
tool_tip="Delete preset"
top="3"
height="18"
width="18" >
<button.commit_callback
function="CameraPresets.Delete"/>
</button>
<button
follows="right"
image_selected="Refresh_Off"
image_pressed="Refresh_Off"
image_unselected="Refresh_Off"
is_toggle="true"
layout="topleft"
left_pad="5"
right="-10"
name="reset_btn"
tool_tip="Reset preset to default"
top="2"
height="20"
width="20" >
<button.commit_callback
function="CameraPresets.Reset"/>
</button>
</panel>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment