SL-18388 Searchable debug settings UI

master
Mnikolenko Productengine 2022-10-24 21:46:14 +03:00
parent 58d6265662
commit 8de9beeb6f
6 changed files with 343 additions and 109 deletions

View File

@ -1313,14 +1313,14 @@ LLScrollListItem* LLScrollListCtrl::getItemByLabel(const std::string& label, BOO
}
BOOL LLScrollListCtrl::selectItemByPrefix(const std::string& target, BOOL case_sensitive)
BOOL LLScrollListCtrl::selectItemByPrefix(const std::string& target, BOOL case_sensitive, S32 column)
{
return selectItemByPrefix(utf8str_to_wstring(target), case_sensitive);
return selectItemByPrefix(utf8str_to_wstring(target), case_sensitive, column);
}
// Selects first enabled item that has a name where the name's first part matched the target string.
// Returns false if item not found.
BOOL LLScrollListCtrl::selectItemByPrefix(const LLWString& target, BOOL case_sensitive)
BOOL LLScrollListCtrl::selectItemByPrefix(const LLWString& target, BOOL case_sensitive, S32 column)
{
BOOL found = FALSE;
@ -1335,7 +1335,7 @@ BOOL LLScrollListCtrl::selectItemByPrefix(const LLWString& target, BOOL case_sen
{
LLScrollListItem* item = *iter;
// Only select enabled items with matching names
LLScrollListCell* cellp = item->getColumn(getSearchColumn());
LLScrollListCell* cellp = item->getColumn(column == -1 ? getSearchColumn() : column);
BOOL select = cellp ? item->getEnabled() && ('\0' == cellp->getValue().asString()[0]) : FALSE;
if (select)
{
@ -1358,7 +1358,7 @@ BOOL LLScrollListCtrl::selectItemByPrefix(const LLWString& target, BOOL case_sen
LLScrollListItem* item = *iter;
// Only select enabled items with matching names
LLScrollListCell* cellp = item->getColumn(getSearchColumn());
LLScrollListCell* cellp = item->getColumn(column == -1 ? getSearchColumn() : column);
if (!cellp)
{
continue;

View File

@ -261,8 +261,8 @@ public:
virtual LLScrollListItem* addSimpleElement(const std::string& value, EAddPosition pos = ADD_BOTTOM, const LLSD& id = LLSD());
BOOL selectItemByLabel( const std::string& item, BOOL case_sensitive = TRUE, S32 column = 0 ); // FALSE if item not found
BOOL selectItemByPrefix(const std::string& target, BOOL case_sensitive = TRUE);
BOOL selectItemByPrefix(const LLWString& target, BOOL case_sensitive = TRUE);
BOOL selectItemByPrefix(const std::string& target, BOOL case_sensitive = TRUE, S32 column = -1);
BOOL selectItemByPrefix(const LLWString& target, BOOL case_sensitive = TRUE, S32 column = -1);
LLScrollListItem* getItemByLabel( const std::string& item, BOOL case_sensitive = TRUE, S32 column = 0 );
const std::string getSelectedItemLabel(S32 column = 0) const;
LLSD getSelectedValue();

View File

@ -16876,5 +16876,16 @@
<key>Value</key>
<string></string>
</map>
<key>DebugSettingsHideDefault</key>
<map>
<key>Comment</key>
<string>Show non-default settings only in Debug Settings list</string>
<key>Persist</key>
<integer>0</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>0</integer>
</map>
</map>
</llsd>

View File

@ -2,9 +2,9 @@
* @file llfloatersettingsdebug.cpp
* @brief floater for debugging internal viewer settings
*
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
* $LicenseInfo:firstyear=2022&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
* Copyright (C) 2022, 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
@ -27,8 +27,8 @@
#include "llviewerprecompiledheaders.h"
#include "llfloatersettingsdebug.h"
#include "llfloater.h"
#include "llfiltereditor.h"
#include "lluictrlfactory.h"
//#include "llfirstuse.h"
#include "llcombobox.h"
#include "llspinctrl.h"
#include "llcolorswatch.h"
@ -37,12 +37,11 @@
LLFloaterSettingsDebug::LLFloaterSettingsDebug(const LLSD& key)
: LLFloater(key)
: LLFloater(key),
mSettingList(NULL)
{
mCommitCallbackRegistrar.add("SettingSelect", boost::bind(&LLFloaterSettingsDebug::onSettingSelect, this,_1));
mCommitCallbackRegistrar.add("CommitSettings", boost::bind(&LLFloaterSettingsDebug::onCommitSettings, this));
mCommitCallbackRegistrar.add("ClickDefault", boost::bind(&LLFloaterSettingsDebug::onClickDefault, this));
}
LLFloaterSettingsDebug::~LLFloaterSettingsDebug()
@ -50,59 +49,43 @@ LLFloaterSettingsDebug::~LLFloaterSettingsDebug()
BOOL LLFloaterSettingsDebug::postBuild()
{
LLComboBox* settings_combo = getChild<LLComboBox>("settings_combo");
enableResizeCtrls(true, false, true);
struct f : public LLControlGroup::ApplyFunctor
{
LLComboBox* combo;
f(LLComboBox* c) : combo(c) {}
virtual void apply(const std::string& name, LLControlVariable* control)
{
if (!control->isHiddenFromSettingsEditor())
{
combo->add(name, (void*)control);
}
}
} func(settings_combo);
mComment = getChild<LLTextEditor>("comment_text");
std::string key = getKey().asString();
if (key == "all" || key == "base")
{
gSavedSettings.applyToAll(&func);
}
if (key == "all" || key == "account")
{
gSavedPerAccountSettings.applyToAll(&func);
}
getChild<LLFilterEditor>("filter_input")->setCommitCallback(boost::bind(&LLFloaterSettingsDebug::setSearchFilter, this, _2));
mSettingList = getChild<LLScrollListCtrl>("setting_list");
mSettingList->setCommitOnSelectionChange(TRUE);
mSettingList->setCommitCallback(boost::bind(&LLFloaterSettingsDebug::onSettingSelect, this));
updateList();
gSavedSettings.getControl("DebugSettingsHideDefault")->getCommitSignal()->connect(boost::bind(&LLFloaterSettingsDebug::updateList, this, false));
settings_combo->sortByName();
settings_combo->updateSelection();
mComment = getChild<LLTextEditor>("comment_text");
return TRUE;
}
void LLFloaterSettingsDebug::draw()
{
LLComboBox* settings_combo = getChild<LLComboBox>("settings_combo");
LLControlVariable* controlp = (LLControlVariable*)settings_combo->getCurrentUserdata();
updateControl(controlp);
LLScrollListItem* first_selected = mSettingList->getFirstSelected();
if (first_selected)
{
LLControlVariable* controlp = (LLControlVariable*)first_selected->getUserdata();
updateControl(controlp);
}
LLFloater::draw();
}
//static
void LLFloaterSettingsDebug::onSettingSelect(LLUICtrl* ctrl)
{
LLComboBox* combo_box = (LLComboBox*)ctrl;
LLControlVariable* controlp = (LLControlVariable*)combo_box->getCurrentUserdata();
updateControl(controlp);
}
void LLFloaterSettingsDebug::onCommitSettings()
{
LLComboBox* settings_combo = getChild<LLComboBox>("settings_combo");
LLControlVariable* controlp = (LLControlVariable*)settings_combo->getCurrentUserdata();
LLScrollListItem* first_selected = mSettingList->getFirstSelected();
if (!first_selected)
{
return;
}
LLControlVariable* controlp = (LLControlVariable*)first_selected->getUserdata();
if (!controlp)
{
@ -176,19 +159,23 @@ void LLFloaterSettingsDebug::onCommitSettings()
default:
break;
}
updateDefaultColumn(controlp);
}
// static
void LLFloaterSettingsDebug::onClickDefault()
{
LLComboBox* settings_combo = getChild<LLComboBox>("settings_combo");
LLControlVariable* controlp = (LLControlVariable*)settings_combo->getCurrentUserdata();
if (controlp)
{
controlp->resetToDefault(true);
updateControl(controlp);
}
LLScrollListItem* first_selected = mSettingList->getFirstSelected();
if (first_selected)
{
LLControlVariable* controlp = (LLControlVariable*)first_selected->getUserdata();
if (controlp)
{
controlp->resetToDefault(true);
updateDefaultColumn(controlp);
updateControl(controlp);
}
}
}
// we've switched controls, or doing per-frame update, so update spinners, etc.
@ -207,21 +194,19 @@ void LLFloaterSettingsDebug::updateControl(LLControlVariable* controlp)
return;
}
spinner1->setVisible(FALSE);
spinner2->setVisible(FALSE);
spinner3->setVisible(FALSE);
spinner4->setVisible(FALSE);
color_swatch->setVisible(FALSE);
getChildView("val_text")->setVisible( FALSE);
mComment->setText(LLStringUtil::null);
hideUIControls();
if (controlp)
if (controlp && !isSettingHidden(controlp))
{
eControlType type = controlp->type();
//hide combo box only for non booleans, otherwise this will result in the combo box closing every frame
getChildView("boolean_combo")->setVisible( type == TYPE_BOOLEAN);
getChildView("default_btn")->setVisible(true);
getChildView("setting_name_txt")->setVisible(true);
getChild<LLTextBox>("setting_name_txt")->setText(controlp->getName());
getChild<LLTextBox>("setting_name_txt")->setToolTip(controlp->getName());
mComment->setVisible(true);
mComment->setText(controlp->getComment());
spinner1->setMaxValue(F32_MAX);
@ -479,3 +464,166 @@ void LLFloaterSettingsDebug::updateControl(LLControlVariable* controlp)
}
}
void LLFloaterSettingsDebug::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();
struct f : public LLControlGroup::ApplyFunctor
{
LLScrollListCtrl* setting_list;
LLFloaterSettingsDebug* floater;
std::string selected_setting;
bool skip_selection;
f(LLScrollListCtrl* list, LLFloaterSettingsDebug* floater, std::string setting, bool skip_selection)
: setting_list(list), floater(floater), selected_setting(setting), skip_selection(skip_selection) {}
virtual void apply(const std::string& name, LLControlVariable* control)
{
if (!control->isHiddenFromSettingsEditor() && floater->matchesSearchFilter(name) && !floater->isSettingHidden(control))
{
LLSD row;
row["columns"][0]["column"] = "changed_setting";
row["columns"][0]["value"] = control->isDefault() ? "" : "*";
row["columns"][1]["column"] = "setting";
row["columns"][1]["value"] = name;
LLScrollListItem* item = setting_list->addElement(row, ADD_BOTTOM, (void*)control);
if (!floater->mSearchFilter.empty() && (selected_setting == name) && !skip_selection)
{
std::string lower_name(name);
LLStringUtil::toLower(lower_name);
if (LLStringUtil::startsWith(lower_name, floater->mSearchFilter))
{
item->setSelected(true);
}
}
}
}
} func(mSettingList, this, last_selected, skip_selection);
std::string key = getKey().asString();
if (key == "all" || key == "base")
{
gSavedSettings.applyToAll(&func);
}
if (key == "all" || key == "account")
{
gSavedPerAccountSettings.applyToAll(&func);
}
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_setting";
row["columns"][0]["value"] = "";
row["columns"][1]["column"] = "setting";
row["columns"][1]["value"] = "No matching settings.";
mSettingList->addElement(row);
hideUIControls();
}
}
void LLFloaterSettingsDebug::onSettingSelect()
{
LLScrollListItem* first_selected = mSettingList->getFirstSelected();
if (first_selected)
{
LLControlVariable* controlp = (LLControlVariable*)first_selected->getUserdata();
if (controlp)
{
updateControl(controlp);
}
}
}
void LLFloaterSettingsDebug::setSearchFilter(const std::string& filter)
{
if(mSearchFilter == filter)
return;
mSearchFilter = filter;
LLStringUtil::toLower(mSearchFilter);
updateList();
}
bool LLFloaterSettingsDebug::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 LLFloaterSettingsDebug::isSettingHidden(LLControlVariable* control)
{
static LLCachedControl<bool> hide_default(gSavedSettings, "DebugSettingsHideDefault", false);
return hide_default && control->isDefault();
}
void LLFloaterSettingsDebug::updateDefaultColumn(LLControlVariable* control)
{
if (isSettingHidden(control))
{
hideUIControls();
updateList(true);
return;
}
LLScrollListItem* item = mSettingList->getFirstSelected();
if (item)
{
LLScrollListCell* cell = item->getColumn(0);
if (cell)
{
std::string is_default = control->isDefault() ? "" : "*";
cell->setValue(is_default);
}
}
}
void LLFloaterSettingsDebug::hideUIControls()
{
getChildView("val_spinner_1")->setVisible(false);
getChildView("val_spinner_2")->setVisible(false);
getChildView("val_spinner_3")->setVisible(false);
getChildView("val_spinner_4")->setVisible(false);
getChildView("val_color_swatch")->setVisible(false);
getChildView("val_text")->setVisible(false);
getChildView("default_btn")->setVisible(false);
getChildView("boolean_combo")->setVisible(false);
getChildView("setting_name_txt")->setVisible(false);
mComment->setVisible(false);
}

View File

@ -2,9 +2,9 @@
* @file llfloatersettingsdebug.h
* @brief floater for debugging internal viewer settings
*
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
* $LicenseInfo:firstyear=2022&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
* Copyright (C) 2022, 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
@ -30,6 +30,8 @@
#include "llcontrol.h"
#include "llfloater.h"
class LLScrollListCtrl;
class LLFloaterSettingsDebug
: public LLFloater
{
@ -42,18 +44,31 @@ public:
void updateControl(LLControlVariable* control);
void onSettingSelect(LLUICtrl* ctrl);
void onCommitSettings();
void onClickDefault();
bool matchesSearchFilter(std::string setting_name);
bool isSettingHidden(LLControlVariable* control);
private:
// key - selects which settings to show, one of:
// "all", "base", "account", "skin"
LLFloaterSettingsDebug(const LLSD& key);
virtual ~LLFloaterSettingsDebug();
void updateList(bool skip_selection = false);
void onSettingSelect();
void setSearchFilter(const std::string& filter);
void updateDefaultColumn(LLControlVariable* control);
void hideUIControls();
LLScrollListCtrl* mSettingList;
protected:
class LLTextEditor* mComment;
std::string mSearchFilter;
};
#endif //LLFLOATERDEBUGSETTINGS_H

View File

@ -2,41 +2,79 @@
<floater
legacy_header_height="18"
can_minimize="false"
height="215"
height="360"
min_height="367"
layout="topleft"
name="settings_debug"
help_topic="settings_debug"
title="DEBUG SETTINGS"
width="350">
<combo_box
allow_text_entry="true"
follows="top|left"
height="22"
layout="topleft"
left="15"
max_chars="255"
name="settings_combo"
top="30"
width="320">
<combo_box.commit_callback
function="SettingSelect" />
</combo_box>
<text_editor
enabled="false"
height="60"
layout="topleft"
left_delta="0"
name="comment_text"
top_pad="10"
width="320"
word_wrap="true" />
reuse_instance="true"
can_resize="true"
min_width="550"
width="570">
<filter_editor
follows="left|top|right"
height="23"
layout="topleft"
left="10"
right="-10"
label="Enter search text"
max_length_chars="300"
name="filter_input"
text_pad_left="10"
top="30" />
<scroll_list
column_padding="0"
draw_heading="true"
draw_stripes="false"
heading_height="23"
height="266"
layout="topleft"
search_column="1"
left="10"
follows="left|top|bottom"
name="setting_list"
top_pad="2"
width="300">
<scroll_list.columns
name="changed_setting"
relative_width="0.05" />
<scroll_list.columns
label="Setting"
name="setting" />
</scroll_list>
<text
type="string"
length="1"
follows="left|top"
height="16"
layout="topleft"
name="setting_name_txt"
font="SansSerifSmallBold"
top_delta="8"
left_pad="10"
visible="false"
use_ellipses="true"
text_color="White"
width="240">
Debug setting name
</text>
<text_editor
enabled="false"
height="75"
layout="topleft"
visible="false"
name="comment_text"
follows="left|top"
width="240"
top_delta="20"
word_wrap="true" />
<radio_group
follows="top|left"
height="30"
layout="topleft"
left_delta="0"
name="boolean_combo"
top_pad="10"
top_pad="15"
visible="false"
tab_stop="true"
width="100">
@ -55,21 +93,25 @@
</radio_group>
<line_editor
height="20"
follows="top|left"
layout="topleft"
left_delta="0"
name="val_text"
top_delta="0"
visible="false"
width="300" >
width="220" >
<line_editor.commit_callback
function="CommitSettings" />
</line_editor>
<color_swatch
bottom="185"
top_delta="0"
left_delta="0"
follows="top|left"
can_apply_immediately="true"
height="55"
name="val_color_swatch"
label="Color"
visible="false"
layout="topleft"
width="37" >
<color_swatch.commit_callback
@ -79,10 +121,11 @@
height="20"
label="x"
layout="topleft"
follows="top|left"
left_delta="0"
max_val="1e+007"
name="val_spinner_1"
top_delta="10"
top_delta="5"
visible="false"
width="120" >
<spinner.commit_callback
@ -92,10 +135,11 @@
height="20"
label="x"
layout="topleft"
left_pad="15"
follows="top|left"
left_delta="0"
max_val="1e+007"
name="val_spinner_2"
top_delta="0"
top_pad="10"
visible="false"
width="120">
<spinner.commit_callback
@ -105,10 +149,11 @@
height="20"
label="x"
layout="topleft"
left="15"
follows="top|left"
left_delta="0"
max_val="1e+007"
name="val_spinner_3"
top="160"
top_pad="10"
visible="false"
width="120">
<spinner.commit_callback
@ -118,10 +163,11 @@
height="20"
label="x"
layout="topleft"
left_pad="15"
follows="top|left"
left_delta="0"
max_val="1e+007"
name="val_spinner_4"
top_delta="0"
top_pad="10"
visible="false"
width="120" >
<spinner.commit_callback
@ -130,12 +176,26 @@
<button
height="22"
label="Reset to default"
follows="left|top"
layout="topleft"
left="15"
left_delta="0"
name="default_btn"
top="186"
visible="false"
top_pad="10"
width="150" >
<button.commit_callback
function="ClickDefault" />
</button>
<check_box
control_name="DebugSettingsHideDefault"
height="16"
initial_value="true"
label="Show changed settings only"
layout="topleft"
top_pad="10"
left="10"
follows="left|bottom"
name="hide_default"
width="330">
</check_box>
</floater>