From a14704fbd9b9fb377b7009a9fbe641a9b8d0fdfb Mon Sep 17 00:00:00 2001 From: crupest Date: Fri, 25 Dec 2020 14:43:19 +0800 Subject: ... --- include/cru/ui/style/Styler.hpp | 48 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'include/cru/ui/style/Styler.hpp') diff --git a/include/cru/ui/style/Styler.hpp b/include/cru/ui/style/Styler.hpp index 10b169b1..865cbbaf 100644 --- a/include/cru/ui/style/Styler.hpp +++ b/include/cru/ui/style/Styler.hpp @@ -3,8 +3,11 @@ #include "ApplyBorderStyleInfo.hpp" #include "cru/common/Base.hpp" #include "cru/common/ClonablePtr.hpp" +#include "cru/platform/gui/Cursor.hpp" +#include "cru/ui/controls/Control.hpp" #include +#include namespace cru::ui::style { class Styler : public Object { @@ -14,6 +17,31 @@ class Styler : public Object { virtual Styler* Clone() const = 0; }; +class CompoundStyler : public Styler { + public: + template + static ClonablePtr Create(ClonablePtr... s) { + return ClonablePtr( + new CompoundStyler(std::vector>{std::move(s)...})); + } + + explicit CompoundStyler(std::vector> stylers) + : stylers_(std::move(stylers)) {} + + void Apply(controls::Control* control) const override { + for (const auto& styler : stylers_) { + styler->Apply(control); + } + } + + virtual CompoundStyler* Clone() const override { + return new CompoundStyler(stylers_); + } + + private: + std::vector> stylers_; +}; + class BorderStyler : public Styler { public: static ClonablePtr Create(ApplyBorderStyleInfo style) { @@ -29,4 +57,24 @@ class BorderStyler : public Styler { private: ApplyBorderStyleInfo style_; }; + +class CursorStyler : public Styler { + public: + static ClonablePtr Create( + std::shared_ptr cursor) { + return ClonablePtr(new CursorStyler(std::move(cursor))); + } + + static ClonablePtr Create(platform::gui::SystemCursorType type); + + explicit CursorStyler(std::shared_ptr cursor) + : cursor_(std::move(cursor)) {} + + void Apply(controls::Control* control) const override; + + CursorStyler* Clone() const override { return new CursorStyler(cursor_); } + + private: + std::shared_ptr cursor_; +}; } // namespace cru::ui::style -- cgit v1.2.3