diff options
author | crupest <crupest@outlook.com> | 2019-12-13 01:02:47 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-12-13 01:02:47 +0800 |
commit | 9110574bb51e9e2959842a7641f598d34c3cd847 (patch) | |
tree | 96ee1f5b3c40095e4e923fc763de0663ee6a01aa /src/ui/controls/button.cpp | |
parent | f2aa96fba0b72eeeadf5160ea5df2c8143ec8aa0 (diff) | |
download | cru-9110574bb51e9e2959842a7641f598d34c3cd847.tar.gz cru-9110574bb51e9e2959842a7641f598d34c3cd847.tar.bz2 cru-9110574bb51e9e2959842a7641f598d34c3cd847.zip |
...
Diffstat (limited to 'src/ui/controls/button.cpp')
-rw-r--r-- | src/ui/controls/button.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/ui/controls/button.cpp b/src/ui/controls/button.cpp index 2822f6db..b7f972be 100644 --- a/src/ui/controls/button.cpp +++ b/src/ui/controls/button.cpp @@ -1,18 +1,16 @@ #include "cru/ui/controls/button.hpp" #include <memory> +#include "../helper.hpp" #include "cru/platform/graph/brush.hpp" -#include "cru/platform/graph/graph_factory.hpp" #include "cru/platform/native/cursor.hpp" -#include "cru/platform/native/native_window.hpp" #include "cru/platform/native/ui_application.hpp" #include "cru/ui/render/border_render_object.hpp" #include "cru/ui/ui_manager.hpp" #include "cru/ui/window.hpp" namespace cru::ui::controls { -using platform::native::GetSystemCursor; -using platform::native::SystemCursor; +using cru::platform::native::SystemCursorType; namespace { void Set(render::BorderRenderObject* o, const ButtonStateStyle& s) { @@ -22,12 +20,17 @@ void Set(render::BorderRenderObject* o, const ButtonStateStyle& s) { o->SetForegroundBrush(s.foreground_brush); o->SetBackgroundBrush(s.background_brush); } + +std::shared_ptr<platform::native::ICursor> GetSystemCursor( + SystemCursorType type) { + return GetUiApplication()->GetCursorManager()->GetSystemCursor(type); +} } // namespace Button::Button() : click_detector_(this) { style_ = UiManager::GetInstance()->GetThemeResources()->button_style; - render_object_.reset(new render::BorderRenderObject); + render_object_ = std::make_unique<render::BorderRenderObject>(); render_object_->SetAttachedControl(this); Set(render_object_.get(), style_.normal); render_object_->SetBorderEnabled(true); @@ -75,21 +78,20 @@ void Button::OnStateChange(ButtonState oldState, ButtonState newState) { switch (newState) { case ButtonState::Normal: Set(render_object_.get(), style_.normal); - SetCursor(GetSystemCursor(SystemCursor::Arrow)); + SetCursor(GetSystemCursor(SystemCursorType::Arrow)); break; case ButtonState::Hover: Set(render_object_.get(), style_.hover); - SetCursor(GetSystemCursor(SystemCursor::Hand)); + SetCursor(GetSystemCursor(SystemCursorType::Hand)); break; case ButtonState::Press: Set(render_object_.get(), style_.press); - SetCursor(GetSystemCursor(SystemCursor::Hand)); + SetCursor(GetSystemCursor(SystemCursorType::Hand)); break; case ButtonState::PressCancel: Set(render_object_.get(), style_.press_cancel); - SetCursor(GetSystemCursor(SystemCursor::Arrow)); + SetCursor(GetSystemCursor(SystemCursorType::Arrow)); break; } - GetWindow()->GetNativeWindow()->Repaint(); } } // namespace cru::ui::controls |