diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/control.cpp | 2 | ||||
-rw-r--r-- | src/ui/controls/button.cpp | 32 | ||||
-rw-r--r-- | src/ui/ui_manager.cpp | 2 | ||||
-rw-r--r-- | src/ui/window.cpp | 2 |
4 files changed, 25 insertions, 13 deletions
diff --git a/src/ui/control.cpp b/src/ui/control.cpp index 50628883..8e8819de 100644 --- a/src/ui/control.cpp +++ b/src/ui/control.cpp @@ -3,7 +3,7 @@ #include "cru/platform/native/basic_types.hpp" #include "cru/platform/native/cursor.hpp" #include "cru/platform/native/native_window.hpp" -#include "cru/platform/native/ui_applicaition.hpp" +#include "cru/platform/native/ui_application.hpp" #include "cru/ui/base.hpp" #include "cru/ui/event/ui_event.hpp" #include "cru/ui/window.hpp" diff --git a/src/ui/controls/button.cpp b/src/ui/controls/button.cpp index 38ce75a8..5e32e064 100644 --- a/src/ui/controls/button.cpp +++ b/src/ui/controls/button.cpp @@ -5,14 +5,14 @@ #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_applicaition.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 platform::native::UiApplication; Button::Button() : click_detector_(this) { // const auto predefined_resource = @@ -25,12 +25,17 @@ Button::Button() : click_detector_(this) { factory->CreateSolidColorBrush(Color::FromHex(0x47d1ff))); border_style_.press.brush = std::shared_ptr<platform::graph::Brush>( factory->CreateSolidColorBrush(Color::FromHex(0x91e4ff))); + border_style_.press_cancel.brush = std::shared_ptr<platform::graph::Brush>( + factory->CreateSolidColorBrush(Color::FromHex(0x91e4ff))); border_style_.normal.thickness = border_style_.hover.thickness = - border_style_.press.thickness = Thickness{3}; + border_style_.press.thickness = border_style_.press_cancel.thickness = + Thickness{3}; border_style_.normal.corner_radius = border_style_.hover.corner_radius = - border_style_.press.corner_radius = render::CornerRadius{Point{10, 5}}; + border_style_.press.corner_radius = + border_style_.press_cancel.corner_radius = + render::CornerRadius{Point{10, 5}}; render_object_.reset( new render::BorderRenderObject(border_style_.normal.brush)); @@ -44,14 +49,14 @@ Button::Button() : click_detector_(this) { } else { SetState(ButtonState::Hover); } - SetCursor(UiApplication::GetInstance()->GetCursorManager()->GetSystemCursor( - SystemCursor::Hand)); }); MouseLeaveEvent()->Direct()->AddHandler([this](event::MouseEventArgs& args) { - SetState(ButtonState::Normal); - SetCursor(UiApplication::GetInstance()->GetCursorManager()->GetSystemCursor( - SystemCursor::Arrow)); + if (click_detector_.GetPressingButton() & trigger_button_) { + SetState(ButtonState::Normal); + } else { + SetState(ButtonState::PressCancel); + } }); click_detector_.ClickBeginEvent()->AddHandler([this](MouseButton button) { @@ -62,7 +67,7 @@ Button::Button() : click_detector_(this) { click_detector_.ClickEndEvent()->AddHandler([this](MouseButton button) { if (button & trigger_button_) { - SetState(ButtonState::Normal); + SetState(ButtonState::Hover); } }); } @@ -81,12 +86,19 @@ void Button::OnStateChange(ButtonState oldState, ButtonState newState) { switch (newState) { case ButtonState::Normal: render_object_->SetStyle(border_style_.normal); + SetCursor(GetSystemCursor(SystemCursor::Arrow)); break; case ButtonState::Hover: render_object_->SetStyle(border_style_.hover); + SetCursor(GetSystemCursor(SystemCursor::Hand)); break; case ButtonState::Press: render_object_->SetStyle(border_style_.press); + SetCursor(GetSystemCursor(SystemCursor::Hand)); + break; + case ButtonState::PressCancel: + render_object_->SetStyle(border_style_.press_cancel); + SetCursor(GetSystemCursor(SystemCursor::Arrow)); break; } GetWindow()->GetNativeWindow()->Repaint(); diff --git a/src/ui/ui_manager.cpp b/src/ui/ui_manager.cpp index 376b1b45..fa3304fb 100644 --- a/src/ui/ui_manager.cpp +++ b/src/ui/ui_manager.cpp @@ -3,7 +3,7 @@ #include "cru/platform/graph/brush.hpp" #include "cru/platform/graph/font.hpp" #include "cru/platform/graph/graph_factory.hpp" -#include "cru/platform/native/ui_applicaition.hpp" +#include "cru/platform/native/ui_application.hpp" namespace cru::ui { using namespace cru::platform::graph; diff --git a/src/ui/window.cpp b/src/ui/window.cpp index af95c3c6..41f440f0 100644 --- a/src/ui/window.cpp +++ b/src/ui/window.cpp @@ -2,7 +2,7 @@ #include "cru/platform/graph/painter.hpp" #include "cru/platform/native/native_window.hpp" -#include "cru/platform/native/ui_applicaition.hpp" +#include "cru/platform/native/ui_application.hpp" #include "cru/ui/render/window_render_object.hpp" #include "routed_event_dispatch.hpp" |