Navigate Carousel Without Focus (#741)

* Navigate Carousel Without Focus

- Allow left/right inputs to change the setting value without having the arrow explicitly clicked

* Formatting
This commit is contained in:
SuperDude88
2026-05-09 16:23:59 -04:00
committed by GitHub
parent 23dc9bc39a
commit ad9c460ec9
2 changed files with 8 additions and 4 deletions
+6 -3
View File
@@ -195,8 +195,7 @@ Rml::String format_graphics_setting_value(GraphicsOption option, int value) {
GraphicsTuner::GraphicsTuner(GraphicsTunerProps props, bool prelaunch)
: Document(kDocumentSource), mOption(props.option), mValueMin(props.valueMin),
mValueMax(props.valueMax), mDefaultValue(props.defaultValue), mPrelaunch(prelaunch)
{
mValueMax(props.valueMax), mDefaultValue(props.defaultValue), mPrelaunch(prelaunch) {
if (mDocument == nullptr) {
return;
}
@@ -208,7 +207,7 @@ GraphicsTuner::GraphicsTuner(GraphicsTunerProps props, bool prelaunch)
description->SetInnerRML(escape(props.helpText));
}
if (auto* carouselParent = mDocument->GetElementById("carousel-container")) {
add_component<SteppedCarousel>(carouselParent,
mCarousel = &add_component<SteppedCarousel>(carouselParent,
SteppedCarousel::Props{
.min = mValueMin,
.max = mValueMax,
@@ -283,6 +282,10 @@ bool GraphicsTuner::handle_nav_command(Rml::Event& event, NavCommand cmd) {
return true;
}
if (mCarousel && mCarousel->handle_nav_command(cmd)) {
return true;
}
return mPrelaunch ? false : Document::handle_nav_command(event, cmd);
}
+2 -1
View File
@@ -28,9 +28,9 @@ public:
bool focus() override;
void update() override;
bool handle_nav_command(NavCommand cmd);
private:
bool handle_nav_command(NavCommand cmd);
void apply(int value);
Props mProps;
@@ -86,6 +86,7 @@ private:
int mValueMax = 0;
int mDefaultValue = 0;
std::vector<std::unique_ptr<Component> > mComponents;
SteppedCarousel* mCarousel;
Rml::Element* mRoot;
bool mPrelaunch;
};