Add Ui::MapFrom for optimized mapFromGlobal(mapToGlobal(..)).
This commit is contained in:
parent
d7c2185f5c
commit
12b8b3804c
2 changed files with 26 additions and 0 deletions
|
|
@ -222,4 +222,20 @@ int WheelDirection(not_null<QWheelEvent*> e) {
|
|||
return (delta / absDelta);
|
||||
}
|
||||
|
||||
QPoint MapFrom(
|
||||
not_null<QWidget*> to,
|
||||
not_null<QWidget*> from,
|
||||
QPoint point) {
|
||||
return (to->window() != from->window())
|
||||
? to->mapFromGlobal(from->mapToGlobal(point))
|
||||
: to->mapFrom(to->window(), from->mapTo(from->window(), point));
|
||||
}
|
||||
|
||||
[[nodiscard]] QRect MapFrom(
|
||||
not_null<QWidget*> to,
|
||||
not_null<QWidget*> from,
|
||||
QRect rect) {
|
||||
return { MapFrom(to, from, rect.topLeft()), rect.size() };
|
||||
}
|
||||
|
||||
} // namespace Ui
|
||||
|
|
|
|||
|
|
@ -196,4 +196,14 @@ QPointer<const Widget> MakeWeak(not_null<const Widget*> object) {
|
|||
|
||||
int WheelDirection(not_null<QWheelEvent*> e);
|
||||
|
||||
[[nodiscard]] QPoint MapFrom(
|
||||
not_null<QWidget*> to,
|
||||
not_null<QWidget*> from,
|
||||
QPoint point);
|
||||
|
||||
[[nodiscard]] QRect MapFrom(
|
||||
not_null<QWidget*> to,
|
||||
not_null<QWidget*> from,
|
||||
QRect rect);
|
||||
|
||||
} // namespace Ui
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue