aboutsummaryrefslogtreecommitdiff
path: root/src/ui/control.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2018-11-06 16:32:38 +0800
committercrupest <crupest@outlook.com>2018-11-06 16:32:38 +0800
commit1d551a7666ee61074fd36fed4f919c9583477fef (patch)
tree0b445619b034a22f7d30642b0ba84e4d82dfa4da /src/ui/control.cpp
parentbfdc5da41b9ab8b3f150a619c7893270dc8ccc7f (diff)
downloadcru-1d551a7666ee61074fd36fed4f919c9583477fef.tar.gz
cru-1d551a7666ee61074fd36fed4f919c9583477fef.tar.bz2
cru-1d551a7666ee61074fd36fed4f919c9583477fef.zip
Dev cursor for textbox.
Diffstat (limited to 'src/ui/control.cpp')
-rw-r--r--src/ui/control.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/ui/control.cpp b/src/ui/control.cpp
index 5215c107..6746e820 100644
--- a/src/ui/control.cpp
+++ b/src/ui/control.cpp
@@ -307,6 +307,18 @@ namespace cru {
return result;
}
+ Point Control::TransformPoint(const Point& point, const RectRange from, const RectRange to)
+ {
+ const auto rect_from = GetRect(from);
+ const auto rect_to = GetRect(to);
+ auto p = point;
+ p.x += rect_from.left;
+ p.y += rect_from.top;
+ p.x -= rect_to.left;
+ p.y -= rect_to.top;
+ return p;
+ }
+
void Control::InvalidateBorder()
{
InvalidateLayout();
@@ -324,10 +336,13 @@ namespace cru {
void Control::SetCursor(const Cursor::Ptr& cursor)
{
- cursor_ = cursor;
- const auto window = GetWindow();
- if (window && window->GetMouseHoverControl() == this)
- window->UpdateCursor();
+ if (cursor != cursor_)
+ {
+ cursor_ = cursor;
+ const auto window = GetWindow();
+ if (window && window->GetMouseHoverControl() == this)
+ window->UpdateCursor();
+ }
}
void Control::OnAddChild(Control* child)