diff options
Diffstat (limited to 'include/cru/ui/controls')
-rw-r--r-- | include/cru/ui/controls/base.hpp | 24 | ||||
-rw-r--r-- | include/cru/ui/controls/button.hpp | 20 | ||||
-rw-r--r-- | include/cru/ui/controls/text_block.hpp | 2 | ||||
-rw-r--r-- | include/cru/ui/controls/text_box.hpp | 15 |
4 files changed, 41 insertions, 20 deletions
diff --git a/include/cru/ui/controls/base.hpp b/include/cru/ui/controls/base.hpp new file mode 100644 index 00000000..ebe9cdda --- /dev/null +++ b/include/cru/ui/controls/base.hpp @@ -0,0 +1,24 @@ +#pragma once +#include "../base.hpp" + +namespace cru::ui::controls { +using ButtonStateStyle = BorderStyle; + +struct ButtonStyle { + // corresponds to ClickState::None + ButtonStateStyle normal; + // corresponds to ClickState::Hover + ButtonStateStyle hover; + // corresponds to ClickState::Press + ButtonStateStyle press; + // corresponds to ClickState::PressInactive + ButtonStateStyle press_cancel; +}; + +struct TextBoxBorderStyle { + BorderStyle normal; + BorderStyle hover; + BorderStyle focus; + BorderStyle focus_hover; +}; +} // namespace cru::ui::controls diff --git a/include/cru/ui/controls/button.hpp b/include/cru/ui/controls/button.hpp index a95b75ce..fb636a33 100644 --- a/include/cru/ui/controls/button.hpp +++ b/include/cru/ui/controls/button.hpp @@ -1,28 +1,10 @@ #pragma once #include "../content_control.hpp" +#include "base.hpp" #include "../click_detector.hpp" namespace cru::ui::controls { -struct ButtonStateStyle { - std::shared_ptr<platform::graph::IBrush> border_brush; - Thickness border_thickness; - CornerRadius border_radius; - std::shared_ptr<platform::graph::IBrush> foreground_brush; - std::shared_ptr<platform::graph::IBrush> background_brush; -}; - -struct ButtonStyle { - // corresponds to ClickState::None - ButtonStateStyle normal; - // corresponds to ClickState::Hover - ButtonStateStyle hover; - // corresponds to ClickState::Press - ButtonStateStyle press; - // corresponds to ClickState::PressInactive - ButtonStateStyle press_cancel; -}; - class Button : public ContentControl { public: static constexpr std::string_view control_type = "Button"; diff --git a/include/cru/ui/controls/text_block.hpp b/include/cru/ui/controls/text_block.hpp index 701f946f..ec61a08c 100644 --- a/include/cru/ui/controls/text_block.hpp +++ b/include/cru/ui/controls/text_block.hpp @@ -30,7 +30,7 @@ class TextBlock : public NoChildControl { render::TextRenderObject* GetTextRenderObject(); render::CanvasRenderObject* GetCaretRenderObject(); - platform::graph::IBrush* GetCaretBrush(); + std::shared_ptr<platform::graph::IBrush> GetCaretBrush(); private: std::unique_ptr<render::StackLayoutRenderObject> root_render_object_; diff --git a/include/cru/ui/controls/text_box.hpp b/include/cru/ui/controls/text_box.hpp index 58179a57..4a4ed6e7 100644 --- a/include/cru/ui/controls/text_box.hpp +++ b/include/cru/ui/controls/text_box.hpp @@ -1,7 +1,11 @@ #pragma once #include "../no_child_control.hpp" +#include "base.hpp" namespace cru::ui::controls { +template <typename TControl> +class TextControlService; + class TextBox : public NoChildControl { public: static constexpr std::string_view control_type = "TextBox"; @@ -17,11 +21,22 @@ class TextBox : public NoChildControl { std::string_view GetControlType() const final { return control_type; } + render::TextRenderObject* GetTextRenderObject(); + render::CanvasRenderObject* GetCaretRenderObject(); + std::shared_ptr<platform::graph::IBrush> GetCaretBrush(); + + const TextBoxBorderStyle& GetBorderStyle(); + void SetBorderStyle(TextBoxBorderStyle border_style); + private: std::unique_ptr<render::BorderRenderObject> border_render_object_; std::unique_ptr<render::StackLayoutRenderObject> stack_layout_render_object_; std::unique_ptr<render::TextRenderObject> text_render_object_; std::unique_ptr<render::CanvasRenderObject> caret_render_object_; + std::shared_ptr<platform::graph::IBrush> caret_brush_; + TextBoxBorderStyle border_style_; + + std::unique_ptr<TextControlService<TextBox>> service_; }; } // namespace cru::ui::controls |