diff options
author | kobewi <kobewi4e@gmail.com> | 2022-05-26 03:59:16 +0200 |
---|---|---|
committer | kobewi <kobewi4e@gmail.com> | 2022-05-26 20:54:45 +0200 |
commit | e748fc1a11a1fdc2e94872060f5c6f77700bf00b (patch) | |
tree | b48801451eb0c18c021ce6451e239494588ff1e0 /editor/plugins/texture_region_editor_plugin.cpp | |
parent | 2e8862887c07708ea0d4cb015902c3001ea6f495 (diff) |
Improve TextureRegionEditor
Diffstat (limited to 'editor/plugins/texture_region_editor_plugin.cpp')
-rw-r--r-- | editor/plugins/texture_region_editor_plugin.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index 79e09404a0..3f4f9a4f4d 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -83,6 +83,7 @@ void TextureRegionEditor::_region_draw() { mtx.scale_basis(Vector2(draw_zoom, draw_zoom)); RS::get_singleton()->canvas_item_add_set_transform(edit_draw->get_canvas_item(), mtx); + edit_draw->draw_rect(Rect2(Point2(), base_tex->get_size()), Color(0.5, 0.5, 0.5, 0.5), false); edit_draw->draw_texture(base_tex, Point2()); RS::get_singleton()->canvas_item_add_set_transform(edit_draw->get_canvas_item(), Transform2D()); @@ -234,6 +235,14 @@ void TextureRegionEditor::_region_draw() { updating_scroll = false; + if (request_center && hscroll->get_min() < 0) { + hscroll->set_value((hscroll->get_min() + hscroll->get_max() - hscroll->get_page()) / 2); + vscroll->set_value((vscroll->get_min() + vscroll->get_max() - vscroll->get_page()) / 2); + // This ensures that the view is updated correctly. + callable_bind(callable_mp(this, &TextureRegionEditor::_pan_callback), Vector2(1, 0)).call_deferred(nullptr, 0); + request_center = false; + } + if (node_ninepatch || obj_styleBox.is_valid()) { float margins[4] = { 0 }; if (node_ninepatch) { @@ -922,7 +931,8 @@ void TextureRegionEditor::edit(Object *p_obj) { atlas_tex = Ref<AtlasTexture>(nullptr); } edit_draw->update(); - popup_centered_ratio(); + popup_centered_ratio(0.5); + request_center = true; } void TextureRegionEditor::_texture_changed() { |