From 74b8ca575ff7f0cfcfd443e03885542bc5b10c46 Mon Sep 17 00:00:00 2001 From: Maxim Nikolenko Date: Thu, 25 May 2023 13:02:52 +0300 Subject: SL-19770 allow changing current preset from My Camera Presets list --- indra/newview/llfloatercamerapresets.cpp | 18 +++++++++++++++++- indra/newview/llfloatercamerapresets.h | 3 +++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/indra/newview/llfloatercamerapresets.cpp b/indra/newview/llfloatercamerapresets.cpp index 300c945a85..a1cbffd094 100644 --- a/indra/newview/llfloatercamerapresets.cpp +++ b/indra/newview/llfloatercamerapresets.cpp @@ -24,6 +24,7 @@ */ #include "llviewerprecompiledheaders.h" +#include "llfloatercamera.h" #include "llfloatercamerapresets.h" #include "llfloaterreg.h" #include "llnotificationsutil.h" @@ -40,7 +41,8 @@ LLFloaterCameraPresets::~LLFloaterCameraPresets() BOOL LLFloaterCameraPresets::postBuild() { mPresetList = getChild("preset_list"); - + mPresetList->setCommitCallback(boost::bind(&LLFloaterCameraPresets::onSelectionChange, this)); + mPresetList->setCommitOnSelectionChange(true); LLPresetsManager::getInstance()->setPresetListChangeCameraCallback(boost::bind(&LLFloaterCameraPresets::populateList, this)); return TRUE; @@ -58,6 +60,7 @@ void LLFloaterCameraPresets::populateList() std::list preset_names; presetsMgr->loadPresetNamesFromDir(PRESETS_CAMERA, preset_names, DEFAULT_BOTTOM); + std::string active_preset = gSavedSettings.getString("PresetCameraActive"); for (std::list::const_iterator it = preset_names.begin(); it != preset_names.end(); ++it) { @@ -66,6 +69,19 @@ void LLFloaterCameraPresets::populateList() LLCameraPresetFlatItem* item = new LLCameraPresetFlatItem(name, is_default); item->postBuild(); mPresetList->addItem(item); + if(name == active_preset) + { + mPresetList->selectItem(item); + } + } +} + +void LLFloaterCameraPresets::onSelectionChange() +{ + LLCameraPresetFlatItem* selected_preset = dynamic_cast(mPresetList->getSelectedItem()); + if(selected_preset) + { + LLFloaterCamera::switchToPreset(selected_preset->getPresetName()); } } diff --git a/indra/newview/llfloatercamerapresets.h b/indra/newview/llfloatercamerapresets.h index 66430fa399..4430a4209e 100644 --- a/indra/newview/llfloatercamerapresets.h +++ b/indra/newview/llfloatercamerapresets.h @@ -38,6 +38,7 @@ class LLFloaterCameraPresets : public LLFloater virtual void onOpen(const LLSD& key); void populateList(); + void onSelectionChange(); private: LLFloaterCameraPresets(const LLSD& key); @@ -58,6 +59,8 @@ public: virtual void onMouseEnter(S32 x, S32 y, MASK mask); virtual void onMouseLeave(S32 x, S32 y, MASK mask); + std::string getPresetName() { return mPresetName; } + private: void onDeleteBtnClick(); void onResetBtnClick(); -- cgit v1.2.3