blob: cad860d7b6a8339133cdbb11d749621c525bc251 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#include "cru/ui/events/MouseEventArgs.h"
#include "cru/ui/controls/Control.h"
#include "cru/ui/host/WindowHost.h"
#include "cru/ui/render/RenderObject.h"
namespace cru::ui::events {
Point MouseEventArgs::GetPoint(render::RenderObject* render_object) const {
return GetPoint() - render_object->GetTotalOffset();
}
Point MouseEventArgs::GetPointToContent(
render::RenderObject* render_object) const {
return render_object->FromRootToContent(GetPoint());
}
Point MouseEventArgs::GetPointOfScreen() const {
auto sender = GetSender();
if (auto control = dynamic_cast<controls::Control*>(sender)) {
if (auto host = control->GetWindowHost())
return GetPoint() + control->GetWindowHost()
->GetNativeWindow()
->GetClientRect()
.GetLeftTop();
}
return GetPoint();
}
} // namespace cru::ui::events
|