aboutsummaryrefslogtreecommitdiff
path: root/include/cru/ui/controls
diff options
context:
space:
mode:
Diffstat (limited to 'include/cru/ui/controls')
-rw-r--r--include/cru/ui/controls/Base.hpp22
-rw-r--r--include/cru/ui/controls/Button.hpp5
-rw-r--r--include/cru/ui/controls/Control.hpp5
-rw-r--r--include/cru/ui/controls/TextBox.hpp14
4 files changed, 9 insertions, 37 deletions
diff --git a/include/cru/ui/controls/Base.hpp b/include/cru/ui/controls/Base.hpp
index 82c31d1e..7c85cdb2 100644
--- a/include/cru/ui/controls/Base.hpp
+++ b/include/cru/ui/controls/Base.hpp
@@ -1,24 +1,4 @@
#pragma once
#include "../Base.hpp"
-namespace cru::ui::controls {
-using ButtonStateStyle = ui::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 {
- ui::BorderStyle normal;
- ui::BorderStyle hover;
- ui::BorderStyle focus;
- ui::BorderStyle focus_hover;
-};
-} // namespace cru::ui::controls
+namespace cru::ui::controls {} // namespace cru::ui::controls
diff --git a/include/cru/ui/controls/Button.hpp b/include/cru/ui/controls/Button.hpp
index 7299c146..1c9b1216 100644
--- a/include/cru/ui/controls/Button.hpp
+++ b/include/cru/ui/controls/Button.hpp
@@ -41,14 +41,9 @@ class Button : public ContentControl,
void ApplyBorderStyle(const style::ApplyBorderStyleInfo& style) override;
- const ButtonStyle& GetStyle() const { return style_; }
- void SetStyle(ButtonStyle style);
-
private:
std::unique_ptr<render::BorderRenderObject> render_object_{};
- ButtonStyle style_;
-
helper::ClickDetector click_detector_;
};
} // namespace cru::ui::controls
diff --git a/include/cru/ui/controls/Control.hpp b/include/cru/ui/controls/Control.hpp
index 96aad2bd..0d34bc63 100644
--- a/include/cru/ui/controls/Control.hpp
+++ b/include/cru/ui/controls/Control.hpp
@@ -66,6 +66,9 @@ class Control : public Object {
// null to unset
void SetCursor(std::shared_ptr<platform::gui::ICursor> cursor);
+ public:
+ style::StyleRuleSet* GetStyleRuleSet();
+
//*************** region: events ***************
public:
// Raised when mouse enter the control. Even when the control itself captures
@@ -147,5 +150,7 @@ class Control : public Object {
bool is_mouse_over_ = false;
std::shared_ptr<platform::gui::ICursor> cursor_ = nullptr;
+
+ std::unique_ptr<style::StyleRuleSet> style_rule_set_;
};
} // namespace cru::ui::controls
diff --git a/include/cru/ui/controls/TextBox.hpp b/include/cru/ui/controls/TextBox.hpp
index 91d38c61..75e7cb65 100644
--- a/include/cru/ui/controls/TextBox.hpp
+++ b/include/cru/ui/controls/TextBox.hpp
@@ -1,5 +1,6 @@
#pragma once
#include "NoChildControl.hpp"
+#include "IBorderControl.hpp"
#include <memory>
@@ -7,7 +8,7 @@ namespace cru::ui::controls {
template <typename TControl>
class TextControlService;
-class TextBox : public NoChildControl {
+class TextBox : public NoChildControl, public IBorderControl {
public:
static constexpr std::u16string_view control_type = u"TextBox";
@@ -29,22 +30,13 @@ class TextBox : public NoChildControl {
gsl::not_null<render::TextRenderObject*> GetTextRenderObject();
render::ScrollRenderObject* GetScrollRenderObject();
- const TextBoxBorderStyle& GetBorderStyle();
- void SetBorderStyle(TextBoxBorderStyle border_style);
-
- protected:
- void OnMouseHoverChange(bool newHover) override;
-
- private:
- void UpdateBorderStyle();
+ void ApplyBorderStyle(const style::ApplyBorderStyleInfo& style) override;
private:
std::unique_ptr<render::BorderRenderObject> border_render_object_;
std::unique_ptr<render::ScrollRenderObject> scroll_render_object_;
std::unique_ptr<render::TextRenderObject> text_render_object_;
- TextBoxBorderStyle border_style_;
-
std::unique_ptr<TextControlService<TextBox>> service_;
};
} // namespace cru::ui::controls