diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/application.cpp | 17 | ||||
-rw-r--r-- | src/ui/control.cpp | 10 | ||||
-rw-r--r-- | src/ui/control.h | 19 |
3 files changed, 37 insertions, 9 deletions
diff --git a/src/application.cpp b/src/application.cpp index 7658a340..2adab7c6 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -89,6 +89,17 @@ namespace cru { namespace { + CaretInfo GetSystemCaretInfo() + { + CaretInfo caret_info; + caret_info.caret_blink_duration = std::chrono::milliseconds(::GetCaretBlinkTime()); + DWORD caret_width; + if (!::SystemParametersInfoW(SPI_GETCARETWIDTH, 0 , &caret_width, 0)) + throw Win32Error(::GetLastError(), "Failed to get system caret width."); + caret_info.half_caret_width = caret_width / 2.0f; + return caret_info; + } + void LoadSystemCursor(HINSTANCE h_instance) { ui::cursors[ui::cursor_arrow_key] = std::make_shared<ui::Cursor>(::LoadCursorW(h_instance, MAKEINTRESOURCEW(IDC_ARROW)), false); @@ -118,11 +129,7 @@ namespace cru { debug_layout_resource_.padding_brush = graph::CreateSolidBrush(D2D1::ColorF(D2D1::ColorF::SkyBlue, 0.25f)); #endif - caret_info_.caret_blink_duration = std::chrono::milliseconds(::GetCaretBlinkTime()); - DWORD caret_width; - if (!::SystemParametersInfoW(SPI_GETCARETWIDTH, 0 , &caret_width, 0)) - throw Win32Error(::GetLastError(), "Failed to get system caret width."); - caret_info_.half_caret_width = caret_width / 2.0f; + caret_info_ = GetSystemCaretInfo(); LoadSystemCursor(h_instance); } diff --git a/src/ui/control.cpp b/src/ui/control.cpp index 3aa8c7e2..838747bc 100644 --- a/src/ui/control.cpp +++ b/src/ui/control.cpp @@ -350,6 +350,16 @@ namespace cru { } } + void Control::SetCursor(const Cursor::Ptr& cursor) + { + + } + + Cursor::Ptr Control::GetCursorInherit() + { + + } + void Control::OnAddChild(Control* child) { if (auto window = GetWindow()) diff --git a/src/ui/control.h b/src/ui/control.h index 666d7f69..e88228d0 100644 --- a/src/ui/control.h +++ b/src/ui/control.h @@ -12,6 +12,7 @@ #include "layout_base.h" #include "events/ui_event.h" #include "border_property.h" +#include "cursor.h" namespace cru { @@ -231,6 +232,18 @@ namespace cru additional_properties_[key] = std::make_any<T>(std::move(value)); } + + //*************** region: cursor *************** + Cursor::Ptr GetCursor() const + { + return cursor_; + } + + void SetCursor(const Cursor::Ptr& cursor); + + Cursor::Ptr GetCursorInherit(); + + //*************** region: events *************** //Raised when mouse enter the control. events::MouseEvent mouse_enter_event; @@ -346,10 +359,6 @@ namespace cru virtual Size OnMeasureContent(const Size& available_size); virtual void OnLayoutContent(const Rect& rect); - - //*************** region: cursor *************** - //TODO! - private: // Only for layout manager to use. // Check if the old position is updated to current position. @@ -408,6 +417,8 @@ namespace cru Microsoft::WRL::ComPtr<ID2D1Geometry> margin_geometry_; Microsoft::WRL::ComPtr<ID2D1Geometry> padding_geometry_; #endif + + Cursor::Ptr cursor_{}; }; // Find the lowest common ancestor. |