mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-07-11 05:04:40 -04:00
Dim Carousel Arrows
- Dim carousel arrows if there are no further options in that direction (closes #708) This sets the color property constantly, not sure if that is a concern for perf (would imagine not since it already sets the rml to mValueElem every frame also?)
This commit is contained in:
@@ -91,18 +91,23 @@ Rml::Element* create_stepped_carousel_arrow(
|
||||
return parent->AppendChild(std::move(button));
|
||||
}
|
||||
|
||||
void update_carousel_arrow_color(Rml::Element* arrow, bool dim) {
|
||||
const Rml::Colourb& color = Rml::Colourb(255, 255, 255, dim ? 128 : 255);
|
||||
arrow->SetProperty(Rml::PropertyId::Color, Rml::Property(color, Rml::Unit::COLOUR));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
SteppedCarousel::SteppedCarousel(Rml::Element* parent, Props props)
|
||||
: Component(create_stepped_carousel_root(parent)), mProps(std::move(props)) {
|
||||
Rml::Element* prevElem = create_stepped_carousel_arrow(mRoot, "prev", "");
|
||||
mPrevElem = create_stepped_carousel_arrow(mRoot, "prev", "");
|
||||
mValueElem = append(mRoot, "div");
|
||||
mValueElem->SetClass("stepped-carousel-value", true);
|
||||
Rml::Element* nextElem = create_stepped_carousel_arrow(mRoot, "next", "");
|
||||
mNextElem = create_stepped_carousel_arrow(mRoot, "next", "");
|
||||
|
||||
listen(prevElem, Rml::EventId::Click,
|
||||
listen(mPrevElem, Rml::EventId::Click,
|
||||
[this](Rml::Event&) { handle_nav_command(NavCommand::Left); });
|
||||
listen(nextElem, Rml::EventId::Click,
|
||||
listen(mNextElem, Rml::EventId::Click,
|
||||
[this](Rml::Event&) { handle_nav_command(NavCommand::Right); });
|
||||
listen(mRoot, Rml::EventId::Keydown, [this](Rml::Event& event) {
|
||||
const auto cmd = map_nav_event(event);
|
||||
@@ -126,6 +131,9 @@ void SteppedCarousel::update() {
|
||||
} else {
|
||||
mValueElem->SetInnerRML(std::to_string(value));
|
||||
}
|
||||
|
||||
update_carousel_arrow_color(mPrevElem, value == mProps.min);
|
||||
update_carousel_arrow_color(mNextElem, value == mProps.max);
|
||||
}
|
||||
|
||||
bool SteppedCarousel::handle_nav_command(NavCommand cmd) {
|
||||
@@ -280,4 +288,4 @@ void GraphicsTuner::reset_default() {
|
||||
set_value(mOption, mDefaultValue);
|
||||
}
|
||||
|
||||
} // namespace dusk::ui
|
||||
} // namespace dusk::ui
|
||||
|
||||
@@ -34,6 +34,8 @@ private:
|
||||
void apply(int value);
|
||||
|
||||
Props mProps;
|
||||
Rml::Element* mPrevElem = nullptr;
|
||||
Rml::Element* mNextElem = nullptr;
|
||||
Rml::Element* mValueElem = nullptr;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user