diff options
author | Thaddeus Crews <repiteo@outlook.com> | 2024-11-27 10:47:12 -0600 |
---|---|---|
committer | Thaddeus Crews <repiteo@outlook.com> | 2024-11-27 10:47:12 -0600 |
commit | 9c300a6c057c809ce093d92fc570010dba84fc05 (patch) | |
tree | c673fdde641db7cb07e7e2354675ae701eea6a0c /scene/main | |
parent | c5cd7c66ee417f6854fb5e36812e870849c46c3e (diff) | |
parent | 0cf99cf95d098392d7d1943aac37b12bd831a1d9 (diff) | |
download | redot-engine-9c300a6c057c809ce093d92fc570010dba84fc05.tar.gz |
Merge pull request #80965 from Calinou/viewport-add-get-stretch-scale-factor
Add a Viewport method to get automatically computed 2D stretch transform
Diffstat (limited to 'scene/main')
-rw-r--r-- | scene/main/viewport.cpp | 5 | ||||
-rw-r--r-- | scene/main/viewport.h | 1 |
2 files changed, 6 insertions, 0 deletions
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index a0f39462a0..dd3ae1ad3c 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1254,6 +1254,10 @@ Ref<World2D> Viewport::get_world_2d() const { return world_2d; } +Transform2D Viewport::get_stretch_transform() const { + return stretch_transform; +} + Transform2D Viewport::get_final_transform() const { ERR_READ_THREAD_GUARD_V(Transform2D()); return stretch_transform * global_canvas_transform; @@ -4636,6 +4640,7 @@ void Viewport::_bind_methods() { ClassDB::bind_method(D_METHOD("set_global_canvas_transform", "xform"), &Viewport::set_global_canvas_transform); ClassDB::bind_method(D_METHOD("get_global_canvas_transform"), &Viewport::get_global_canvas_transform); + ClassDB::bind_method(D_METHOD("get_stretch_transform"), &Viewport::get_stretch_transform); ClassDB::bind_method(D_METHOD("get_final_transform"), &Viewport::get_final_transform); ClassDB::bind_method(D_METHOD("get_screen_transform"), &Viewport::get_screen_transform); diff --git a/scene/main/viewport.h b/scene/main/viewport.h index 92691ccbec..3a5ad2d83c 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -515,6 +515,7 @@ public: void set_global_canvas_transform(const Transform2D &p_transform); Transform2D get_global_canvas_transform() const; + Transform2D get_stretch_transform() const; virtual Transform2D get_final_transform() const; void gui_set_root_order_dirty(); |