From 874794ea584588457dfde7ef17c447e2a0eb46bb Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Sun, 4 Aug 2024 21:00:10 -0400 Subject: Add LLUIColorTable debug-settings-like floater for easing skin design --- indra/newview/CMakeLists.txt | 2 + indra/newview/app_settings/settings.xml | 11 + indra/newview/llfloatersettingscolor.cpp | 334 +++++++++++++++++++++ indra/newview/llfloatersettingscolor.h | 81 +++++ indra/newview/llmanip.cpp | 6 +- indra/newview/llselectmgr.cpp | 25 +- indra/newview/llselectmgr.h | 13 +- indra/newview/llviewerfloaterreg.cpp | 2 + .../default/xui/en/floater_settings_color.xml | 117 ++++++++ indra/newview/skins/default/xui/en/menu_login.xml | 7 + indra/newview/skins/default/xui/en/menu_viewer.xml | 7 + 11 files changed, 583 insertions(+), 22 deletions(-) create mode 100644 indra/newview/llfloatersettingscolor.cpp create mode 100644 indra/newview/llfloatersettingscolor.h create mode 100644 indra/newview/skins/default/xui/en/floater_settings_color.xml (limited to 'indra/newview') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 4c5deb4974..8df9c41219 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -286,6 +286,7 @@ set(viewer_SOURCE_FILES llfloaterscriptlimits.cpp llfloatersearch.cpp llfloatersellland.cpp + llfloatersettingscolor.cpp llfloatersettingsdebug.cpp llfloatersidepanelcontainer.cpp llfloatersnapshot.cpp @@ -954,6 +955,7 @@ set(viewer_HEADER_FILES llfloaterscriptlimits.h llfloatersearch.h llfloatersellland.h + llfloatersettingscolor.h llfloatersettingsdebug.h llfloatersidepanelcontainer.h llfloatersnapshot.h diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 9e5d3f09bd..eb053ebaa0 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -15773,6 +15773,17 @@ Value 0 + ColorSettingsHideDefault + + Comment + Show non-default settings only in Color Settings list + Persist + 0 + Type + Boolean + Value + 0 + DebugSettingsHideDefault Comment diff --git a/indra/newview/llfloatersettingscolor.cpp b/indra/newview/llfloatersettingscolor.cpp new file mode 100644 index 0000000000..d9c382a1dc --- /dev/null +++ b/indra/newview/llfloatersettingscolor.cpp @@ -0,0 +1,334 @@ +/** +* @file llfloatersettingscolor.cpp +* @brief Implementation of LLFloaterSettingsColor +* @author Rye Cogtail +* +* $LicenseInfo:firstyear=2024&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2024, 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 "llfloatersettingscolor.h" + +#include "llfloater.h" +#include "llfiltereditor.h" +#include "lluictrlfactory.h" +#include "llcombobox.h" +#include "llspinctrl.h" +#include "llcolorswatch.h" +#include "llviewercontrol.h" +#include "lltexteditor.h" + + +LLFloaterSettingsColor::LLFloaterSettingsColor(const LLSD& key) +: LLFloater(key), + mSettingList(NULL) +{ + mCommitCallbackRegistrar.add("CommitSettings", boost::bind(&LLFloaterSettingsColor::onCommitSettings, this)); + mCommitCallbackRegistrar.add("ClickDefault", boost::bind(&LLFloaterSettingsColor::onClickDefault, this)); +} + +LLFloaterSettingsColor::~LLFloaterSettingsColor() +{} + +bool LLFloaterSettingsColor::postBuild() +{ + enableResizeCtrls(true, false, true); + + mAlphaSpinner = getChild("alpha_spinner"); + mColorSwatch = getChild("color_swatch"); + + mDefaultButton = getChild("default_btn"); + mSettingNameText = getChild("color_name_txt"); + + getChild("filter_input")->setCommitCallback(boost::bind(&LLFloaterSettingsColor::setSearchFilter, this, _2)); + + mSettingList = getChild("setting_list"); + mSettingList->setCommitOnSelectionChange(true); + mSettingList->setCommitCallback(boost::bind(&LLFloaterSettingsColor::onSettingSelect, this)); + + updateList(); + + gSavedSettings.getControl("ColorSettingsHideDefault")->getCommitSignal()->connect(boost::bind(&LLFloaterSettingsColor::updateList, this, false)); + + return LLFloater::postBuild(); +} + +void LLFloaterSettingsColor::draw() +{ + LLScrollListItem* first_selected = mSettingList->getFirstSelected(); + if (first_selected) + { + if(auto cell = first_selected->getColumn(1)) + { + updateControl(cell->getValue().asString()); + } + } + + LLFloater::draw(); +} + +void LLFloaterSettingsColor::onCommitSettings() +{ + LLScrollListItem* first_selected = mSettingList->getFirstSelected(); + if (!first_selected) + { + return; + } + auto cell = first_selected->getColumn(1); + + if (!cell) + { + return; + } + + auto color_name = cell->getValue().asString(); + if (color_name.empty()) + { + return; + } + + LLColor4 col4; + LLColor3 col3; + col3.setValue(mColorSwatch->getValue()); + col4 = LLColor4(col3, (F32)mAlphaSpinner->getValue().asReal()); + LLUIColorTable::instance().setColor(color_name, col4); + + updateDefaultColumn(color_name); +} + +// static +void LLFloaterSettingsColor::onClickDefault() +{ + LLScrollListItem* first_selected = mSettingList->getFirstSelected(); + if (first_selected) + { + auto cell = first_selected->getColumn(1); + if (cell) + { + auto name = cell->getValue().asString(); + LLUIColorTable::instance().resetToDefault(name); + updateDefaultColumn(name); + updateControl(name); + } + } +} + +// we've switched controls, or doing per-frame update, so update spinners, etc. +void LLFloaterSettingsColor::updateControl(const std::string& color_name) +{ + hideUIControls(); + + if (!isSettingHidden(color_name)) + { + mDefaultButton->setVisible(true); + mSettingNameText->setVisible(true); + mSettingNameText->setText(color_name); + mSettingNameText->setToolTip(color_name); + + LLColor4 clr = LLUIColorTable::instance().getColor(color_name); + mColorSwatch->setVisible(true); + // only set if changed so color picker doesn't update + if (clr != LLColor4(mColorSwatch->getValue())) + { + mColorSwatch->setOriginal(clr); + } + mAlphaSpinner->setVisible(true); + mAlphaSpinner->setLabel(std::string("Alpha")); + if (!mAlphaSpinner->hasFocus()) + { + mAlphaSpinner->setPrecision(3); + mAlphaSpinner->setMinValue(0.0); + mAlphaSpinner->setMaxValue(1.f); + mAlphaSpinner->setValue(clr.mV[VALPHA]); + } + } + +} + +void LLFloaterSettingsColor::updateList(bool skip_selection) +{ + std::string last_selected; + LLScrollListItem* item = mSettingList->getFirstSelected(); + if (item) + { + LLScrollListCell* cell = item->getColumn(1); + if (cell) + { + last_selected = cell->getValue().asString(); + } + } + + mSettingList->deleteAllItems(); + + const auto& base_colors = LLUIColorTable::instance().getLoadedColors(); + for (const auto& pair : base_colors) + { + const auto& name = pair.first; + if (matchesSearchFilter(name) && !isSettingHidden(name)) + { + LLSD row; + + row["columns"][0]["column"] = "changed_color"; + row["columns"][0]["value"] = LLUIColorTable::instance().isDefault(name) ? "" : "*"; + + row["columns"][1]["column"] = "color"; + row["columns"][1]["value"] = name; + + LLScrollListItem* item = mSettingList->addElement(row, ADD_BOTTOM, nullptr); + if (!mSearchFilter.empty() && (last_selected == name) && !skip_selection) + { + std::string lower_name(name); + LLStringUtil::toLower(lower_name); + if (LLStringUtil::startsWith(lower_name, mSearchFilter)) + { + item->setSelected(true); + } + } + } + } + + for (const auto& pair : LLUIColorTable::instance().getUserColors()) + { + const auto& name = pair.first; + if (base_colors.find(name) == base_colors.end() && matchesSearchFilter(name) && !isSettingHidden(name)) + { + LLSD row; + + row["columns"][0]["column"] = "changed_color"; + row["columns"][0]["value"] = LLUIColorTable::instance().isDefault(name) ? "" : "*"; + + row["columns"][1]["column"] = "color"; + row["columns"][1]["value"] = name; + + LLScrollListItem* item = mSettingList->addElement(row, ADD_BOTTOM, nullptr); + if (!mSearchFilter.empty() && (last_selected == name) && !skip_selection) + { + std::string lower_name(name); + LLStringUtil::toLower(lower_name); + if (LLStringUtil::startsWith(lower_name, mSearchFilter)) + { + item->setSelected(true); + } + } + } + } + + mSettingList->updateSort(); + + if (!mSettingList->isEmpty()) + { + if (mSettingList->hasSelectedItem()) + { + mSettingList->scrollToShowSelected(); + } + else if (!mSettingList->hasSelectedItem() && !mSearchFilter.empty() && !skip_selection) + { + if (!mSettingList->selectItemByPrefix(mSearchFilter, false, 1)) + { + mSettingList->selectFirstItem(); + } + mSettingList->scrollToShowSelected(); + } + } + else + { + LLSD row; + + row["columns"][0]["column"] = "changed_color"; + row["columns"][0]["value"] = ""; + row["columns"][1]["column"] = "color"; + row["columns"][1]["value"] = "No matching colors."; + + mSettingList->addElement(row); + hideUIControls(); + } +} + +void LLFloaterSettingsColor::onSettingSelect() +{ + LLScrollListItem* first_selected = mSettingList->getFirstSelected(); + if (first_selected) + { + auto cell = first_selected->getColumn(1); + if (cell) + { + updateControl(cell->getValue().asString()); + } + } +} + +void LLFloaterSettingsColor::setSearchFilter(const std::string& filter) +{ + if(mSearchFilter == filter) + return; + mSearchFilter = filter; + LLStringUtil::toLower(mSearchFilter); + updateList(); +} + +bool LLFloaterSettingsColor::matchesSearchFilter(std::string setting_name) +{ + // If the search filter is empty, everything passes. + if (mSearchFilter.empty()) return true; + + LLStringUtil::toLower(setting_name); + std::string::size_type match_name = setting_name.find(mSearchFilter); + + return (std::string::npos != match_name); +} + +bool LLFloaterSettingsColor::isSettingHidden(const std::string& color_name) +{ + static LLCachedControl hide_default(gSavedSettings, "ColorSettingsHideDefault", false); + return hide_default && LLUIColorTable::instance().isDefault(color_name); +} + +void LLFloaterSettingsColor::updateDefaultColumn(const std::string& color_name) +{ + if (isSettingHidden(color_name)) + { + hideUIControls(); + updateList(true); + return; + } + + LLScrollListItem* item = mSettingList->getFirstSelected(); + if (item) + { + LLScrollListCell* cell = item->getColumn(0); + if (cell) + { + std::string is_default = LLUIColorTable::instance().isDefault(color_name) ? "" : "*"; + cell->setValue(is_default); + } + } +} + +void LLFloaterSettingsColor::hideUIControls() +{ + mColorSwatch->setVisible(false); + mAlphaSpinner->setVisible(false); + mDefaultButton->setVisible(false); + mSettingNameText->setVisible(false); +} + diff --git a/indra/newview/llfloatersettingscolor.h b/indra/newview/llfloatersettingscolor.h new file mode 100644 index 0000000000..42eb85cd60 --- /dev/null +++ b/indra/newview/llfloatersettingscolor.h @@ -0,0 +1,81 @@ +/** +* @file llfloatersettingscolor.h +* @brief Header file for LLFloaterSettingsColor +* @author Rye Cogtail +* +* $LicenseInfo:firstyear=2024&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2024, 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 LLFLOATERCOLORSETTINGS_H +#define LLFLOATERCOLORSETTINGS_H + +#include "llcontrol.h" +#include "llfloater.h" + +class LLColorSwatchCtrl; +class LLScrollListCtrl; +class LLSpinCtrl; +class LLTextBox; + +class LLFloaterSettingsColor final +: public LLFloater +{ + friend class LLFloaterReg; + +public: + + bool postBuild() override; + void draw() override; + + void updateControl(const std::string& color_name); + + void onCommitSettings(); + void onClickDefault(); + + bool matchesSearchFilter(std::string setting_name); + bool isSettingHidden(const std::string& color_name); + +private: + LLFloaterSettingsColor(const LLSD& key); + virtual ~LLFloaterSettingsColor(); + + void updateList(bool skip_selection = false); + void onSettingSelect(); + void setSearchFilter(const std::string& filter); + + void updateDefaultColumn(const std::string& color_name); + void hideUIControls(); + + LLScrollListCtrl* mSettingList; + +protected: + LLUICtrl* mDefaultButton = nullptr; + LLTextBox* mSettingNameText = nullptr; + + LLSpinCtrl* mAlphaSpinner = nullptr; + LLColorSwatchCtrl* mColorSwatch = nullptr; + + std::string mSearchFilter; +}; + +#endif //LLFLOATERCOLORSETTINGS_H + diff --git a/indra/newview/llmanip.cpp b/indra/newview/llmanip.cpp index 0c82db1011..0d617753c8 100644 --- a/indra/newview/llmanip.cpp +++ b/indra/newview/llmanip.cpp @@ -594,9 +594,9 @@ void LLManip::renderTickValue(const LLVector3& pos, F32 value, const std::string LLColor4 LLManip::setupSnapGuideRenderPass(S32 pass) { - static LLColor4 grid_color_fg = LLUIColorTable::instance().getColor("GridlineColor"); - static LLColor4 grid_color_bg = LLUIColorTable::instance().getColor("GridlineBGColor"); - static LLColor4 grid_color_shadow = LLUIColorTable::instance().getColor("GridlineShadowColor"); + static LLUIColor grid_color_fg = LLUIColorTable::instance().getColor("GridlineColor"); + static LLUIColor grid_color_bg = LLUIColorTable::instance().getColor("GridlineBGColor"); + static LLUIColor grid_color_shadow = LLUIColorTable::instance().getColor("GridlineShadowColor"); LLColor4 line_color; F32 line_alpha = gSavedSettings.getF32("GridOpacity"); diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index fcd1c84ba4..342048252f 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -128,12 +128,12 @@ F32 LLSelectMgr::sHighlightAlpha = 0.f; F32 LLSelectMgr::sHighlightAlphaTest = 0.f; F32 LLSelectMgr::sHighlightUAnim = 0.f; F32 LLSelectMgr::sHighlightVAnim = 0.f; -LLColor4 LLSelectMgr::sSilhouetteParentColor; -LLColor4 LLSelectMgr::sSilhouetteChildColor; -LLColor4 LLSelectMgr::sHighlightInspectColor; -LLColor4 LLSelectMgr::sHighlightParentColor; -LLColor4 LLSelectMgr::sHighlightChildColor; -LLColor4 LLSelectMgr::sContextSilhouetteColor; +LLUIColor LLSelectMgr::sSilhouetteParentColor; +LLUIColor LLSelectMgr::sSilhouetteChildColor; +LLUIColor LLSelectMgr::sHighlightInspectColor; +LLUIColor LLSelectMgr::sHighlightParentColor; +LLUIColor LLSelectMgr::sHighlightChildColor; +LLUIColor LLSelectMgr::sContextSilhouetteColor; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // struct LLDeRezInfo @@ -6437,8 +6437,10 @@ void LLSelectMgr::renderSilhouettes(bool for_hud) bool wireframe_selection = (gFloaterTools && gFloaterTools->getVisible()) || LLSelectMgr::sRenderHiddenSelections; F32 fogCfx = (F32)llclamp((LLSelectMgr::getInstance()->getSelectionCenterGlobal() - gAgentCamera.getCameraPositionGlobal()).magVec() / (LLSelectMgr::getInstance()->getBBoxOfSelection().getExtentLocal().magVec() * 4), 0.0, 1.0); - static LLColor4 sParentColor = LLColor4(sSilhouetteParentColor[VRED], sSilhouetteParentColor[VGREEN], sSilhouetteParentColor[VBLUE], LLSelectMgr::sHighlightAlpha); - static LLColor4 sChildColor = LLColor4(sSilhouetteChildColor[VRED], sSilhouetteChildColor[VGREEN], sSilhouetteChildColor[VBLUE], LLSelectMgr::sHighlightAlpha); + LLColor4 sParentColor = sSilhouetteParentColor; + sParentColor.mV[VALPHA] = LLSelectMgr::sHighlightAlpha; + LLColor4 sChildColor = sSilhouetteChildColor; + sChildColor.mV[VALPHA] = LLSelectMgr::sHighlightAlpha; auto renderMeshSelection_f = [fogCfx, wireframe_selection](LLSelectNode* node, LLViewerObject* objectp, LLColor4 hlColor) { @@ -8006,12 +8008,9 @@ S32 LLObjectSelection::getSelectedObjectRenderCost() cost += object->getRenderCost(textures); computed_objects.insert(object->getID()); - const_child_list_t children = object->getChildren(); - for (const_child_list_t::const_iterator child_iter = children.begin(); - child_iter != children.end(); - ++child_iter) + const const_child_list_t& children = object->getChildren(); + for (LLViewerObject* child_obj : children) { - LLViewerObject* child_obj = *child_iter; LLVOVolume *child = dynamic_cast( child_obj ); if (child) { diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h index 355e28595b..2764b0179c 100644 --- a/indra/newview/llselectmgr.h +++ b/indra/newview/llselectmgr.h @@ -44,6 +44,7 @@ #include "llcontrol.h" #include "llviewerobject.h" // LLObjectSelection::getSelectedTEValue template #include "llmaterial.h" +#include "lluicolor.h" #include #include @@ -450,12 +451,12 @@ public: static F32 sHighlightAlphaTest; static F32 sHighlightUAnim; static F32 sHighlightVAnim; - static LLColor4 sSilhouetteParentColor; - static LLColor4 sSilhouetteChildColor; - static LLColor4 sHighlightParentColor; - static LLColor4 sHighlightChildColor; - static LLColor4 sHighlightInspectColor; - static LLColor4 sContextSilhouetteColor; + static LLUIColor sSilhouetteParentColor; + static LLUIColor sSilhouetteChildColor; + static LLUIColor sHighlightParentColor; + static LLUIColor sHighlightChildColor; + static LLUIColor sHighlightInspectColor; + static LLUIColor sContextSilhouetteColor; LLCachedControl mHideSelectedObjects; LLCachedControl mRenderHighlightSelections; diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index c97a512a57..9bdd246129 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -134,6 +134,7 @@ #include "llfloaterscriptlimits.h" #include "llfloatersearch.h" #include "llfloatersellland.h" +#include "llfloatersettingscolor.h" #include "llfloatersettingsdebug.h" #include "llfloatersidepanelcontainer.h" #include "llfloatersnapshot.h" @@ -486,6 +487,7 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("script_limits", "floater_script_limits.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("my_scripts", "floater_my_scripts.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("sell_land", "floater_sell_land.xml", &LLFloaterSellLand::buildFloater); + LLFloaterReg::add("settings_color", "floater_settings_color.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("settings_debug", "floater_settings_debug.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("sound_devices", "floater_sound_devices.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("stats", "floater_stats.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); diff --git a/indra/newview/skins/default/xui/en/floater_settings_color.xml b/indra/newview/skins/default/xui/en/floater_settings_color.xml new file mode 100644 index 0000000000..0722677f1d --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_settings_color.xml @@ -0,0 +1,117 @@ + + + + + + + + + Color name + + + + + + + + + + + \ No newline at end of file diff --git a/indra/newview/skins/default/xui/en/menu_login.xml b/indra/newview/skins/default/xui/en/menu_login.xml index a71cbde21b..1d1b81e31a 100644 --- a/indra/newview/skins/default/xui/en/menu_login.xml +++ b/indra/newview/skins/default/xui/en/menu_login.xml @@ -149,6 +149,13 @@ function="Advanced.ShowDebugSettings" parameter="all" /> + + + + + + -- cgit v1.2.3