diff options
Diffstat (limited to 'include/cru/ui/controls')
-rw-r--r-- | include/cru/ui/controls/button.hpp | 51 | ||||
-rw-r--r-- | include/cru/ui/controls/flex_layout.hpp | 2 |
2 files changed, 19 insertions, 34 deletions
diff --git a/include/cru/ui/controls/button.hpp b/include/cru/ui/controls/button.hpp index b5cca7dc..0fad0035 100644 --- a/include/cru/ui/controls/button.hpp +++ b/include/cru/ui/controls/button.hpp @@ -13,15 +13,25 @@ class BorderRenderObject; } namespace cru::ui::controls { -struct ButtonBorderStyle { +using render::CornerRadius; + +struct ButtonStateStyle { + std::shared_ptr<platform::graph::Brush> border_brush; + Thickness border_thickness; + CornerRadius corner_radius; + std::shared_ptr<platform::graph::Brush> foreground_brush; + std::shared_ptr<platform::graph::Brush> background_brush; +}; + +struct ButtonStyle { // corresponds to ButtonState::Normal - render::BorderStyle normal; + ButtonStateStyle normal; // corresponds to ButtonState::Hover - render::BorderStyle hover; + ButtonStateStyle hover; // corresponds to ButtonState::Press - render::BorderStyle press; + ButtonStateStyle press; // corresponds to ButtonState::PressCancel - render::BorderStyle press_cancel; + ButtonStateStyle press_cancel; }; enum class ButtonState { @@ -32,7 +42,7 @@ enum class ButtonState { // mouse is pressed in it Press, // mouse is pressed outside button - PressCancel, + PressCancel, }; class Button : public ContentControl { @@ -58,31 +68,8 @@ class Button : public ContentControl { render::RenderObject* GetRenderObject() const override; public: - render::BorderStyle GetNormalBorderStyle() const { - return border_style_.normal; - } - void SetNormalBorderStyle(render::BorderStyle newStyle) { - border_style_.normal = std::move(newStyle); - } - - render::BorderStyle GetHoverBorderStyle() const { - return border_style_.hover; - } - void SetHoverBorderStyle(render::BorderStyle newStyle) { - border_style_.hover = std::move(newStyle); - } - - render::BorderStyle GetPressBorderStyle() const { - return border_style_.press; - } - void SetPressBorderStyle(render::BorderStyle newStyle) { - border_style_.press = std::move(newStyle); - } - - ButtonBorderStyle GetBorderStyle() const { return border_style_; } - void SetBorderStyle(ButtonBorderStyle newStyle) { - border_style_ = std::move(newStyle); - } + const ButtonStyle& GetStyle() const { return style_; } + void SetStyle(ButtonStyle style); ButtonState GetState() const { return state_; } @@ -115,7 +102,7 @@ class Button : public ContentControl { MouseButton trigger_button_ = MouseButton::Left; - ButtonBorderStyle border_style_; + ButtonStyle style_; ClickDetector click_detector_; }; diff --git a/include/cru/ui/controls/flex_layout.hpp b/include/cru/ui/controls/flex_layout.hpp index 128a79b0..d8d92d08 100644 --- a/include/cru/ui/controls/flex_layout.hpp +++ b/include/cru/ui/controls/flex_layout.hpp @@ -42,7 +42,6 @@ class FlexLayout : public LayoutControl { void SetContentMainAlign(FlexMainAlignment value) { if (value == GetContentMainAlign()) return; render_object_->SetContentMainAlign(value); - if (const auto window = GetWindow()) window->InvalidateLayout(); } FlexDirection GetFlexDirection() const { @@ -52,7 +51,6 @@ class FlexLayout : public LayoutControl { void SetFlexDirection(FlexDirection direction) { if (direction == GetFlexDirection()) return; render_object_->SetFlexDirection(direction); - if (const auto window = GetWindow()) window->InvalidateLayout(); } FlexChildLayoutData GetChildLayoutData(Control* control); |