diff options
author | maxim_productengine <mnikolenko@productengine.com> | 2019-11-08 17:57:17 +0200 |
---|---|---|
committer | maxim_productengine <mnikolenko@productengine.com> | 2019-11-08 17:57:17 +0200 |
commit | 1fa0b3fe954ead1a136d3c38b63db05b5f2f657e (patch) | |
tree | 777098d0f648110cb41cc5067ef4019300970537 /indra/newview | |
parent | dd8128114c8cfe812e1dd8f2cfd449a4050d9aea (diff) |
SL-12186 WIP Add new 'My camera presets' floater
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/CMakeLists.txt | 2 | ||||
-rw-r--r-- | indra/newview/llfloatercamera.cpp | 3 | ||||
-rw-r--r-- | indra/newview/llfloatercamerapresets.cpp | 122 | ||||
-rw-r--r-- | indra/newview/llfloatercamerapresets.h | 69 | ||||
-rw-r--r-- | indra/newview/llpresetsmanager.cpp | 27 | ||||
-rw-r--r-- | indra/newview/llpresetsmanager.h | 4 | ||||
-rw-r--r-- | indra/newview/llviewerfloaterreg.cpp | 2 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_camera.xml | 22 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_camera_presets.xml | 23 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/panel_camera_preset_item.xml | 56 |
10 files changed, 317 insertions, 13 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 17095d8fcd..534af4d8f6 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -229,6 +229,7 @@ set(viewer_SOURCE_FILES llfloaterbuycurrencyhtml.cpp llfloaterbuyland.cpp llfloatercamera.cpp + llfloatercamerapresets.cpp llfloaterchatvoicevolume.cpp llfloatercolorpicker.cpp llfloaterconversationlog.cpp @@ -855,6 +856,7 @@ set(viewer_HEADER_FILES llfloaterbuycurrency.h llfloaterbuycurrencyhtml.h llfloaterbuyland.h + llfloatercamerapresets.h llfloatercamera.h llfloaterchatvoicevolume.h llfloatercolorpicker.h diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp index 8502b5685d..2f85e7db34 100644 --- a/indra/newview/llfloatercamera.cpp +++ b/indra/newview/llfloatercamera.cpp @@ -351,6 +351,7 @@ LLFloaterCamera::LLFloaterCamera(const LLSD& val) LLHints::registerHintTarget("view_popup", getHandle()); mCommitCallbackRegistrar.add("CameraPresets.ChangeView", boost::bind(&LLFloaterCamera::onClickCameraItem, _2)); mCommitCallbackRegistrar.add("CameraPresets.Save", boost::bind(&LLFloaterCamera::onSavePreset, this)); + mCommitCallbackRegistrar.add("CameraPresets.ShowPresetsList", boost::bind(&LLFloaterReg::showInstance, "camera_presets", LLSD(), FALSE)); } // virtual @@ -599,7 +600,7 @@ void LLFloaterCamera::onSavePreset() LLSD key; key["subdirectory"] = PRESETS_CAMERA; 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; LLFloaterReg::showInstance("save_pref_preset", key); } diff --git a/indra/newview/llfloatercamerapresets.cpp b/indra/newview/llfloatercamerapresets.cpp new file mode 100644 index 0000000000..6a9df5d067 --- /dev/null +++ b/indra/newview/llfloatercamerapresets.cpp @@ -0,0 +1,122 @@ +/** +* @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); +} diff --git a/indra/newview/llfloatercamerapresets.h b/indra/newview/llfloatercamerapresets.h new file mode 100644 index 0000000000..8c293c57de --- /dev/null +++ b/indra/newview/llfloatercamerapresets.h @@ -0,0 +1,69 @@ +/** +* @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 diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp index ea4850bdb0..ab4f60d486 100644 --- a/indra/newview/llpresetsmanager.cpp +++ b/indra/newview/llpresetsmanager.cpp @@ -89,6 +89,7 @@ void LLPresetsManager::startWatching(const std::string& subdirectory) { std::vector<std::string> name_list; getControlNames(name_list); + getOffsetControlNames(name_list); 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 if (default_option == DEFAULT_VIEWS_HIDE) { - if (isDefaultPreset(name)) + if (isDefaultCameraPreset(name)) { continue; } @@ -239,6 +240,21 @@ void LLPresetsManager::getControlNames(std::vector<std::string>& names) 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) { if (LLTrans::getString(PRESETS_DEFAULT) == name) @@ -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.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) { @@ -489,11 +505,16 @@ bool LLPresetsManager::deletePreset(const std::string& subdirectory, std::string 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); } +void LLPresetsManager::resetCameraPreset(std::string preset_name) +{ + +} + boost::signals2::connection LLPresetsManager::setPresetListChangeCameraCallback(const preset_list_signal_t::slot_type& cb) { return mPresetListChangeCameraSignal.connect(cb); diff --git a/indra/newview/llpresetsmanager.h b/indra/newview/llpresetsmanager.h index e865fe2512..9964cc0fcf 100644 --- a/indra/newview/llpresetsmanager.h +++ b/indra/newview/llpresetsmanager.h @@ -71,7 +71,8 @@ public: bool isCameraDirty(); 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. boost::signals2::connection setPresetListChangeCameraCallback(const preset_list_signal_t::slot_type& cb); @@ -88,6 +89,7 @@ public: LOG_CLASS(LLPresetsManager); void getControlNames(std::vector<std::string>& names); + void getOffsetControlNames(std::vector<std::string>& names); static void settingChanged(); boost::signals2::connection mCameraChangedSignal; diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index 193ee17912..bc5e04a4c3 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -53,6 +53,7 @@ #include "llfloaterbuyland.h" #include "llfloaterbvhpreview.h" #include "llfloatercamera.h" +#include "llfloatercamerapresets.h" #include "llfloaterchatvoicevolume.h" #include "llfloaterconversationlog.h" #include "llfloaterconversationpreview.h" @@ -215,6 +216,7 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("bumps", "floater_bumps.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBump>); 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("nearby_chat", "floater_im_session.xml", (LLFloaterBuildFunc)&LLFloaterIMNearbyChat::buildFloater); LLFloaterReg::add("compile_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterCompileQueue>); diff --git a/indra/newview/skins/default/xui/en/floater_camera.xml b/indra/newview/skins/default/xui/en/floater_camera.xml index 933d50acae..9408e68c2d 100644 --- a/indra/newview/skins/default/xui/en/floater_camera.xml +++ b/indra/newview/skins/default/xui/en/floater_camera.xml @@ -222,16 +222,22 @@ name="Use preset" value="default" /> </combo_box> - <icon - height="28" - width="28" - image_name="Command_Preferences_Icon" + <button + height="16" + width="16" layout="topleft" mouse_opaque="true" - name="icon_gear" + name="gear_btn" tool_tip="My Camera Presets" - top_delta="0" - left_pad="5" /> + top_delta="3" + 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 follows="top|left" height="25" @@ -239,7 +245,7 @@ layout="topleft" left="0" name="save_preset_btn" - top_pad="8" + top_pad="18" width="150"> <button.commit_callback function="CameraPresets.Save"/> diff --git a/indra/newview/skins/default/xui/en/floater_camera_presets.xml b/indra/newview/skins/default/xui/en/floater_camera_presets.xml new file mode 100644 index 0000000000..0d9a6bb16a --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_camera_presets.xml @@ -0,0 +1,23 @@ +<?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>
diff --git a/indra/newview/skins/default/xui/en/panel_camera_preset_item.xml b/indra/newview/skins/default/xui/en/panel_camera_preset_item.xml new file mode 100644 index 0000000000..187f5889eb --- /dev/null +++ b/indra/newview/skins/default/xui/en/panel_camera_preset_item.xml @@ -0,0 +1,56 @@ +<?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> |