UI: Bold modified settings values

This commit is contained in:
Luke Street
2026-05-03 16:01:33 -06:00
parent da9b99f650
commit 5717aeef85
11 changed files with 102 additions and 11 deletions
+31 -1
View File
@@ -2,6 +2,7 @@
#include "ui.hpp"
#include <fmt/format.h>
#include <utility>
namespace dusk::ui {
@@ -23,9 +24,29 @@ SelectButton::SelectButton(Rml::Element* parent, Props props)
on_nav_command([this](Rml::Event&, NavCommand cmd) { return handle_nav_command(cmd); });
}
bool SelectButton::modified() const {
return mProps.modified;
}
void SelectButton::set_modified(bool value) {
if (mProps.modified != value) {
mValueElem->SetClass("modified", value);
if (value) {
mValueElem->SetInnerRML(fmt::format("• {}", escape(mProps.value)));
} else {
mValueElem->SetInnerRML(escape(mProps.value));
}
mProps.modified = value;
}
}
void SelectButton::set_value_label(const Rml::String& value) {
if (mProps.value != value) {
mValueElem->SetInnerRML(escape(value));
if (mProps.modified) {
mValueElem->SetInnerRML(fmt::format("• {}", escape(value)));
} else {
mValueElem->SetInnerRML(escape(value));
}
mProps.value = value;
}
}
@@ -35,6 +56,7 @@ void SelectButton::update_props(Props props) {
mKeyElem->SetInnerRML(escape(props.key));
}
set_value_label(props.value);
set_modified(props.modified);
mProps = std::move(props);
}
@@ -49,9 +71,17 @@ bool SelectButton::handle_nav_command(NavCommand cmd) {
void BaseControlledSelectButton::update() {
set_disabled(disabled());
set_value_label(format_value());
set_modified(modified());
SelectButton::update();
}
bool ControlledSelectButton::modified() const {
if (mIsModified) {
return mIsModified();
}
return BaseControlledSelectButton::modified();
}
bool ControlledSelectButton::disabled() const {
if (mIsDisabled) {
return mIsDisabled();