Merge pull request #68627 from Sauermann/fix-tooltip-position
Fix position of Tooltips
This commit is contained in:
commit
13e20fed99
5 changed files with 32 additions and 11 deletions
|
@ -154,17 +154,7 @@ Transform2D CanvasItem::get_global_transform_with_canvas() const {
|
|||
|
||||
Transform2D CanvasItem::get_screen_transform() const {
|
||||
ERR_FAIL_COND_V(!is_inside_tree(), Transform2D());
|
||||
Transform2D xform = get_global_transform_with_canvas();
|
||||
|
||||
Window *w = Object::cast_to<Window>(get_viewport());
|
||||
if (w && !w->is_embedding_subwindows()) {
|
||||
Transform2D s;
|
||||
s.set_origin(w->get_position());
|
||||
|
||||
xform = s * xform;
|
||||
}
|
||||
|
||||
return xform;
|
||||
return get_viewport()->get_popup_base_transform() * get_global_transform_with_canvas();
|
||||
}
|
||||
|
||||
Transform2D CanvasItem::get_global_transform() const {
|
||||
|
|
|
@ -4186,6 +4186,21 @@ Transform2D SubViewport::get_screen_transform() const {
|
|||
return container_transform * Viewport::get_screen_transform();
|
||||
}
|
||||
|
||||
Transform2D SubViewport::get_popup_base_transform() const {
|
||||
if (is_embedding_subwindows()) {
|
||||
return Transform2D();
|
||||
}
|
||||
SubViewportContainer *c = Object::cast_to<SubViewportContainer>(get_parent());
|
||||
if (!c) {
|
||||
return Viewport::get_screen_transform();
|
||||
}
|
||||
Transform2D container_transform;
|
||||
if (c->is_stretch_enabled()) {
|
||||
container_transform.scale(Vector2(c->get_stretch_shrink(), c->get_stretch_shrink()));
|
||||
}
|
||||
return c->get_screen_transform() * container_transform * Viewport::get_screen_transform();
|
||||
}
|
||||
|
||||
void SubViewport::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
|
|
|
@ -649,6 +649,7 @@ public:
|
|||
bool get_canvas_cull_mask_bit(uint32_t p_layer) const;
|
||||
|
||||
virtual Transform2D get_screen_transform() const;
|
||||
virtual Transform2D get_popup_base_transform() const { return Transform2D(); }
|
||||
|
||||
#ifndef _3D_DISABLED
|
||||
bool use_xr = false;
|
||||
|
@ -775,6 +776,7 @@ public:
|
|||
ClearMode get_clear_mode() const;
|
||||
|
||||
virtual Transform2D get_screen_transform() const override;
|
||||
virtual Transform2D get_popup_base_transform() const override;
|
||||
|
||||
SubViewport();
|
||||
~SubViewport();
|
||||
|
|
|
@ -2104,6 +2104,19 @@ Transform2D Window::get_screen_transform() const {
|
|||
return embedder_transform * Viewport::get_screen_transform();
|
||||
}
|
||||
|
||||
Transform2D Window::get_popup_base_transform() const {
|
||||
if (is_embedding_subwindows()) {
|
||||
return Transform2D();
|
||||
}
|
||||
Transform2D window_transform;
|
||||
window_transform.set_origin(get_position());
|
||||
window_transform *= Viewport::get_screen_transform();
|
||||
if (_get_embedder()) {
|
||||
return _get_embedder()->get_popup_base_transform() * window_transform;
|
||||
}
|
||||
return window_transform;
|
||||
}
|
||||
|
||||
void Window::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_title", "title"), &Window::set_title);
|
||||
ClassDB::bind_method(D_METHOD("get_title"), &Window::get_title);
|
||||
|
|
|
@ -373,6 +373,7 @@ public:
|
|||
//
|
||||
|
||||
virtual Transform2D get_screen_transform() const override;
|
||||
virtual Transform2D get_popup_base_transform() const override;
|
||||
|
||||
Rect2i get_parent_rect() const;
|
||||
virtual DisplayServer::WindowID get_window_id() const override;
|
||||
|
|
Loading…
Reference in a new issue