Dual pane navigation & more player editor

This commit is contained in:
Luke Street
2026-05-01 12:06:00 -06:00
parent 2b505f1be4
commit 8f7b9cdfdd
13 changed files with 437 additions and 115 deletions
+7 -36
View File
@@ -15,20 +15,21 @@ Rml::Element* createRoot(Rml::Element* parent) {
} // namespace
SelectButton::SelectButton(Rml::Element* parent, Props props) : Component(createRoot(parent)) {
SelectButton::SelectButton(Rml::Element* parent, Props props)
: FluentComponent(createRoot(parent)) {
mKeyElem = append(mRoot, "key");
mValueElem = append(mRoot, "value");
update_props(std::move(props));
listen(mRoot, Rml::EventId::Click, [this](Rml::Event& event) {
if (mProps.disabled) {
listen(Rml::EventId::Click, [this](Rml::Event& event) {
if (disabled()) {
return;
}
if (handle_nav_command(NavCommand::Confirm)) {
event.StopPropagation();
}
});
listen(mRoot, Rml::EventId::Keydown, [this](Rml::Event& event) {
if (mProps.disabled) {
listen(Rml::EventId::Keydown, [this](Rml::Event& event) {
if (disabled()) {
return;
}
const auto cmd = map_nav_event(event);
@@ -38,34 +39,6 @@ SelectButton::SelectButton(Rml::Element* parent, Props props) : Component(create
});
}
bool SelectButton::focus() {
if (mProps.disabled) {
return false;
}
return Component::focus();
}
void SelectButton::set_selected(bool selected) {
if (mProps.selected != selected) {
mRoot->SetPseudoClass("selected", selected);
mProps.selected = selected;
}
}
void SelectButton::set_disabled(bool disabled) {
if (mProps.disabled != disabled) {
if (disabled) {
mRoot->SetAttribute("disabled", "");
mRoot->SetPseudoClass("disabled", true);
mRoot->Blur();
} else {
mRoot->RemoveAttribute("disabled");
mRoot->SetPseudoClass("disabled", false);
}
mProps.disabled = disabled;
}
}
void SelectButton::set_value_label(const Rml::String& value) {
if (mProps.value != value) {
mValueElem->SetInnerRML(escape(value));
@@ -78,14 +51,12 @@ void SelectButton::update_props(Props props) {
mKeyElem->SetInnerRML(escape(props.key));
}
set_value_label(props.value);
set_selected(props.selected);
set_disabled(props.disabled);
mProps = std::move(props);
}
bool SelectButton::handle_nav_command(NavCommand cmd) {
if (cmd == NavCommand::Confirm) {
set_selected(!get_selected());
set_selected(!selected());
return true;
}
return false;