mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-06-22 23:09:52 -04:00
UI: Bold modified settings values
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user