diff options
author | crupest <crupest@outlook.com> | 2020-12-25 14:43:19 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-12-25 14:43:19 +0800 |
commit | a14704fbd9b9fb377b7009a9fbe641a9b8d0fdfb (patch) | |
tree | 7ee33e1d51f15841ee908ec16b937985f7d9be96 /include/cru/ui | |
parent | d23cdd9c6f2fbec1329c704bde7e183b5ef07e2e (diff) | |
download | cru-a14704fbd9b9fb377b7009a9fbe641a9b8d0fdfb.tar.gz cru-a14704fbd9b9fb377b7009a9fbe641a9b8d0fdfb.tar.bz2 cru-a14704fbd9b9fb377b7009a9fbe641a9b8d0fdfb.zip |
...
Diffstat (limited to 'include/cru/ui')
-rw-r--r-- | include/cru/ui/style/Styler.hpp | 48 |
1 files changed, 48 insertions, 0 deletions
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 <memory> +#include <vector> 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 <typename... S> + static ClonablePtr<CompoundStyler> Create(ClonablePtr<S>... s) { + return ClonablePtr<CompoundStyler>( + new CompoundStyler(std::vector<ClonablePtr<Styler>>{std::move(s)...})); + } + + explicit CompoundStyler(std::vector<ClonablePtr<Styler>> 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<ClonablePtr<Styler>> stylers_; +}; + class BorderStyler : public Styler { public: static ClonablePtr<BorderStyler> Create(ApplyBorderStyleInfo style) { @@ -29,4 +57,24 @@ class BorderStyler : public Styler { private: ApplyBorderStyleInfo style_; }; + +class CursorStyler : public Styler { + public: + static ClonablePtr<CursorStyler> Create( + std::shared_ptr<platform::gui::ICursor> cursor) { + return ClonablePtr<CursorStyler>(new CursorStyler(std::move(cursor))); + } + + static ClonablePtr<CursorStyler> Create(platform::gui::SystemCursorType type); + + explicit CursorStyler(std::shared_ptr<platform::gui::ICursor> cursor) + : cursor_(std::move(cursor)) {} + + void Apply(controls::Control* control) const override; + + CursorStyler* Clone() const override { return new CursorStyler(cursor_); } + + private: + std::shared_ptr<platform::gui::ICursor> cursor_; +}; } // namespace cru::ui::style |