diff options
author | crupest <crupest@outlook.com> | 2020-12-03 22:44:57 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-12-03 22:44:57 +0800 |
commit | b29fb11be2f043a3438a50d8942b4ad7d2af0034 (patch) | |
tree | 5847f7b880b43f2596bc10b46fc52c6f028a7a58 /src/ui/controls/Button.cpp | |
parent | 93a8bf8b967817031cd2798cdaedfa73f867dead (diff) | |
download | cru-b29fb11be2f043a3438a50d8942b4ad7d2af0034.tar.gz cru-b29fb11be2f043a3438a50d8942b4ad7d2af0034.tar.bz2 cru-b29fb11be2f043a3438a50d8942b4ad7d2af0034.zip |
...
Diffstat (limited to 'src/ui/controls/Button.cpp')
-rw-r--r-- | src/ui/controls/Button.cpp | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/src/ui/controls/Button.cpp b/src/ui/controls/Button.cpp index 6f19e6b9..7858eadb 100644 --- a/src/ui/controls/Button.cpp +++ b/src/ui/controls/Button.cpp @@ -13,50 +13,37 @@ namespace cru::ui::controls { using cru::platform::gui::SystemCursorType; namespace { -void Set(render::BorderRenderObject* o, const ButtonStateStyle& s) { - o->SetBorderBrush(s.border_brush); - o->SetBorderThickness(s.border_thickness); - o->SetBorderRadius(s.border_radius); - o->SetForegroundBrush(s.foreground_brush); - o->SetBackgroundBrush(s.background_brush); -} - std::shared_ptr<platform::gui::ICursor> GetSystemCursor(SystemCursorType type) { return GetUiApplication()->GetCursorManager()->GetSystemCursor(type); } } // namespace Button::Button() : click_detector_(this) { - style_ = UiManager::GetInstance()->GetThemeResources()->button_style; - render_object_ = std::make_unique<render::BorderRenderObject>(); render_object_->SetAttachedControl(this); SetContainerRenderObject(render_object_.get()); - - Set(render_object_.get(), style_.normal); render_object_->SetBorderEnabled(true); click_detector_.StateChangeEvent()->AddHandler( [this](const helper::ClickState& state) { switch (state) { case helper::ClickState::None: - Set(render_object_.get(), style_.normal); SetCursor(GetSystemCursor(SystemCursorType::Arrow)); break; case helper::ClickState::Hover: - Set(render_object_.get(), style_.hover); SetCursor(GetSystemCursor(SystemCursorType::Hand)); break; case helper::ClickState::Press: - Set(render_object_.get(), style_.press); SetCursor(GetSystemCursor(SystemCursorType::Hand)); break; case helper::ClickState::PressInactive: - Set(render_object_.get(), style_.press_cancel); SetCursor(GetSystemCursor(SystemCursorType::Arrow)); break; } }); + + GetStyleRuleSet()->Set( + UiManager::GetInstance()->GetThemeResources()->button_style); } Button::~Button() = default; |