From f8fd15690c556b0bb0499e0a407b496e53c06242 Mon Sep 17 00:00:00 2001 From: kobewi Date: Fri, 3 Jan 2025 22:54:26 +0100 Subject: [PATCH] Don't show "Drawing rect" when not actually drawing --- editor/plugins/tiles/tile_map_layer_editor.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/editor/plugins/tiles/tile_map_layer_editor.cpp b/editor/plugins/tiles/tile_map_layer_editor.cpp index af93af3e9391..23607783cbf9 100644 --- a/editor/plugins/tiles/tile_map_layer_editor.cpp +++ b/editor/plugins/tiles/tile_map_layer_editor.cpp @@ -800,6 +800,7 @@ void TileMapLayerEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p Transform2D xform = CanvasItemEditor::get_singleton()->get_canvas_transform() * edited_layer->get_global_transform_with_canvas(); Vector2 mpos = edited_layer->get_local_mouse_position(); Vector2i tile_shape_size = tile_set->get_tile_size(); + bool drawing_rect = false; // Draw the selection. if ((tiles_bottom_panel->is_visible_in_tree() || patterns_bottom_panel->is_visible_in_tree()) && tool_buttons_group->get_pressed_button() == select_tool_button) { @@ -893,6 +894,7 @@ void TileMapLayerEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p } else if (drag_type == DRAG_TYPE_RECT) { // Preview for a rect pattern. preview = _draw_rect(tile_set->local_to_map(drag_start_mouse_pos), tile_set->local_to_map(mpos), drag_erasing); + drawing_rect = !preview.is_empty(); expand_grid = true; } else if (tool_buttons_group->get_pressed_button() == bucket_tool_button && drag_type == DRAG_TYPE_NONE) { // Preview for a fill pattern. @@ -1003,7 +1005,7 @@ void TileMapLayerEditorTilesPlugin::forward_canvas_draw_over_viewport(Control *p Point2 msgpos = Point2(20 * EDSCALE, p_overlay->get_size().y - 20 * EDSCALE); String text = tile_set->local_to_map(edited_layer->get_local_mouse_position()); - if (drag_type == DRAG_TYPE_RECT) { + if (drawing_rect) { Vector2i size = tile_set->local_to_map(edited_layer->get_local_mouse_position()) - tile_set->local_to_map(drag_start_mouse_pos); text += vformat(" %s (%dx%d)", TTR("Drawing Rect:"), ABS(size.x) + 1, ABS(size.y) + 1); }