Calculate window input event transform only on window change
This commit is contained in:
parent
e69b7083d4
commit
2bf2217b1a
|
@ -1108,14 +1108,11 @@ Viewport::PositionalShadowAtlasQuadrantSubdiv Viewport::get_positional_shadow_at
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform2D Viewport::_get_input_pre_xform() const {
|
Transform2D Viewport::_get_input_pre_xform() const {
|
||||||
Transform2D pre_xf;
|
const Window *this_window = Object::cast_to<Window>(this);
|
||||||
|
if (this_window) {
|
||||||
if (to_screen_rect.size.x != 0 && to_screen_rect.size.y != 0) {
|
return this_window->window_transform.affine_inverse();
|
||||||
pre_xf.columns[2] = -to_screen_rect.position;
|
|
||||||
pre_xf.scale(Vector2(size) / to_screen_rect.size);
|
|
||||||
}
|
}
|
||||||
|
return Transform2D();
|
||||||
return pre_xf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<InputEvent> Viewport::_make_input_local(const Ref<InputEvent> &ev) {
|
Ref<InputEvent> Viewport::_make_input_local(const Ref<InputEvent> &ev) {
|
||||||
|
|
|
@ -668,6 +668,7 @@ void Window::_update_viewport_size() {
|
||||||
Rect2i attach_to_screen_rect(Point2i(), size);
|
Rect2i attach_to_screen_rect(Point2i(), size);
|
||||||
Transform2D stretch_transform;
|
Transform2D stretch_transform;
|
||||||
float font_oversampling = 1.0;
|
float font_oversampling = 1.0;
|
||||||
|
window_transform = Transform2D();
|
||||||
|
|
||||||
if (content_scale_mode == CONTENT_SCALE_MODE_DISABLED || content_scale_size.x == 0 || content_scale_size.y == 0) {
|
if (content_scale_mode == CONTENT_SCALE_MODE_DISABLED || content_scale_size.x == 0 || content_scale_size.y == 0) {
|
||||||
font_oversampling = content_scale_factor;
|
font_oversampling = content_scale_factor;
|
||||||
|
@ -754,11 +755,18 @@ void Window::_update_viewport_size() {
|
||||||
Size2 scale = Vector2(screen_size) / Vector2(final_size_override);
|
Size2 scale = Vector2(screen_size) / Vector2(final_size_override);
|
||||||
stretch_transform.scale(scale);
|
stretch_transform.scale(scale);
|
||||||
|
|
||||||
|
window_transform.translate_local(margin);
|
||||||
} break;
|
} break;
|
||||||
case CONTENT_SCALE_MODE_VIEWPORT: {
|
case CONTENT_SCALE_MODE_VIEWPORT: {
|
||||||
final_size = (viewport_size / content_scale_factor).floor();
|
final_size = (viewport_size / content_scale_factor).floor();
|
||||||
attach_to_screen_rect = Rect2(margin, screen_size);
|
attach_to_screen_rect = Rect2(margin, screen_size);
|
||||||
|
|
||||||
|
window_transform.translate_local(margin);
|
||||||
|
if (final_size.x != 0 && final_size.y != 0) {
|
||||||
|
Transform2D scale_transform;
|
||||||
|
scale_transform.scale(Vector2(attach_to_screen_rect.size) / Vector2(final_size));
|
||||||
|
window_transform *= scale_transform;
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,6 +152,8 @@ private:
|
||||||
|
|
||||||
Viewport *embedder = nullptr;
|
Viewport *embedder = nullptr;
|
||||||
|
|
||||||
|
Transform2D window_transform;
|
||||||
|
|
||||||
friend class Viewport; //friend back, can call the methods below
|
friend class Viewport; //friend back, can call the methods below
|
||||||
|
|
||||||
void _window_input(const Ref<InputEvent> &p_ev);
|
void _window_input(const Ref<InputEvent> &p_ev);
|
||||||
|
|
Loading…
Reference in New Issue