diff --git a/src/ui/elements/ui_button.cpp b/src/ui/elements/ui_button.cpp index 6da95d6..e467354 100644 --- a/src/ui/elements/ui_button.cpp +++ b/src/ui/elements/ui_button.cpp @@ -4,8 +4,8 @@ namespace recompui { - static const std::string hover_state = "hover"; - static const std::string disabled_state = "disabled"; + static const std::string_view hover_state = "hover"; + static const std::string_view disabled_state = "disabled"; Button::Button(const std::string &text, ButtonStyle style, Element *parent) : Element(parent, Events(EventType::Click, EventType::Hover, EventType::Enable), "button") { this->style = style; diff --git a/src/ui/elements/ui_element.cpp b/src/ui/elements/ui_element.cpp index 477ddba..173bad2 100644 --- a/src/ui/elements/ui_element.cpp +++ b/src/ui/elements/ui_element.cpp @@ -52,11 +52,13 @@ void Element::add_child(Element *child) { void Element::set_property(Rml::PropertyId property_id, const Rml::Property &property, Animation animation) { assert(base != nullptr); - if (animation.type == AnimationType::None) { + if (animation.type == AnimationType::None || animation.type == AnimationType::Set) { base->SetProperty(property_id, property); - // Only non-animated properties should be stored as part of the style. - Style::set_property(property_id, property, animation); + if (animation.type == AnimationType::None) { + // Only non-animated properties should be stored as part of the style. + Style::set_property(property_id, property, animation); + } } else { const Rml::String property_name = Rml::StyleSheetSpecification::GetPropertyName(property_id); @@ -184,6 +186,10 @@ void Element::set_enabled(bool enabled) { propagate_disabled(disabled_from_parent); } +bool Element::is_enabled() const { + return enabled && !disabled_from_parent; +} + void Element::set_text(const std::string &text) { base->SetInnerRML(text); } diff --git a/src/ui/elements/ui_element.h b/src/ui/elements/ui_element.h index 7d774ac..0b975cc 100644 --- a/src/ui/elements/ui_element.h +++ b/src/ui/elements/ui_element.h @@ -9,10 +9,18 @@ namespace recompui { class Element : public Style, public Rml::EventListener { friend class Element; private: + Rml::Element *base = nullptr; + uint32_t events_enabled = 0; std::vector