1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-15 13:51:40 +00:00

Merge pull request #104192 from arkology/tile_editors_ui_ux

Improve/fix `TileMap` and `TileSet` editors UI
This commit is contained in:
Rémi Verschelde
2025-03-19 12:27:18 +01:00
5 changed files with 30 additions and 18 deletions

View File

@@ -2371,6 +2371,7 @@ TileMapLayerEditorTilesPlugin::TileMapLayerEditorTilesPlugin() {
missing_source_label = memnew(Label); missing_source_label = memnew(Label);
missing_source_label->set_text(TTR("This TileMap's TileSet has no Tile Source configured. Go to the TileSet bottom panel to add one.")); missing_source_label->set_text(TTR("This TileMap's TileSet has no Tile Source configured. Go to the TileSet bottom panel to add one."));
missing_source_label->set_autowrap_mode(TextServer::AUTOWRAP_WORD_SMART);
missing_source_label->set_h_size_flags(Control::SIZE_EXPAND_FILL); missing_source_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
missing_source_label->set_v_size_flags(Control::SIZE_EXPAND_FILL); missing_source_label->set_v_size_flags(Control::SIZE_EXPAND_FILL);
missing_source_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); missing_source_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
@@ -2489,8 +2490,9 @@ TileMapLayerEditorTilesPlugin::TileMapLayerEditorTilesPlugin() {
patterns_help_label = memnew(Label); patterns_help_label = memnew(Label);
patterns_help_label->set_text(TTR("Drag and drop or paste a TileMap selection here to store a pattern.")); patterns_help_label->set_text(TTR("Drag and drop or paste a TileMap selection here to store a pattern."));
patterns_help_label->set_autowrap_mode(TextServer::AUTOWRAP_WORD_SMART);
patterns_help_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); patterns_help_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
patterns_help_label->set_anchors_and_offsets_preset(Control::PRESET_CENTER); patterns_help_label->set_anchors_and_offsets_preset(Control::PRESET_HCENTER_WIDE);
patterns_item_list->add_child(patterns_help_label); patterns_item_list->add_child(patterns_help_label);
// Update. // Update.
@@ -4107,6 +4109,7 @@ void TileMapLayerEditor::_tab_changed(int p_tab_id) {
// Graphical update. // Graphical update.
tabs_data[tabs_bar->get_current_tab()].panel->queue_redraw(); tabs_data[tabs_bar->get_current_tab()].panel->queue_redraw();
CanvasItemEditor::get_singleton()->update_viewport(); CanvasItemEditor::get_singleton()->update_viewport();
_update_bottom_panel();
} }
void TileMapLayerEditor::_layers_select_next_or_previous(bool p_next) { void TileMapLayerEditor::_layers_select_next_or_previous(bool p_next) {
@@ -4515,6 +4518,8 @@ TileMapLayerEditor::TileMapLayerEditor() {
// A label for editing errors. // A label for editing errors.
cant_edit_label = memnew(Label); cant_edit_label = memnew(Label);
cant_edit_label->set_autowrap_mode(TextServer::AUTOWRAP_WORD_SMART);
cant_edit_label->set_anchors_and_offsets_preset(Control::PRESET_HCENTER_WIDE);
cant_edit_label->set_h_size_flags(SIZE_EXPAND_FILL); cant_edit_label->set_h_size_flags(SIZE_EXPAND_FILL);
cant_edit_label->set_v_size_flags(SIZE_EXPAND_FILL); cant_edit_label->set_v_size_flags(SIZE_EXPAND_FILL);
cant_edit_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); cant_edit_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);

View File

@@ -968,7 +968,15 @@ void TileSetAtlasSourceEditor::_update_atlas_view() {
if (tile_set.is_null()) { if (tile_set.is_null()) {
return; return;
} else { } else {
tile_create_help->set_visible(tools_button_group->get_pressed_button() == tool_setup_atlas_source_button); if (tools_button_group->get_pressed_button() == tool_setup_atlas_source_button) {
help_label->set_visible(true);
help_label->set_text(TTR("Hold Ctrl to create multiple tiles.") + "\n" + TTR("Hold Shift to create big tiles."));
} else if (tools_button_group->get_pressed_button() == tool_select_button) {
help_label->set_visible(true);
help_label->set_text(TTRC("Hold Shift to select multiple regions."));
} else {
help_label->set_visible(false);
}
} }
if (tools_button_group->get_pressed_button() != tool_paint_button) { if (tools_button_group->get_pressed_button() != tool_paint_button) {
@@ -2685,18 +2693,12 @@ TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() {
tile_atlas_view->connect("transform_changed", callable_mp(this, &TileSetAtlasSourceEditor::_tile_atlas_view_transform_changed).unbind(2)); tile_atlas_view->connect("transform_changed", callable_mp(this, &TileSetAtlasSourceEditor::_tile_atlas_view_transform_changed).unbind(2));
right_panel->add_child(tile_atlas_view); right_panel->add_child(tile_atlas_view);
tile_create_help = memnew(VBoxContainer); help_label = memnew(Label);
tile_atlas_view->add_child(tile_create_help); help_label->set_mouse_filter(MOUSE_FILTER_IGNORE);
tile_create_help->set_mouse_filter(MOUSE_FILTER_IGNORE); help_label->set_anchors_and_offsets_preset(PRESET_FULL_RECT);
help_label->set_vertical_alignment(VERTICAL_ALIGNMENT_BOTTOM);
Label *help_label = memnew(Label(TTR("Hold Ctrl to create multiple tiles."))); help_label->set_autowrap_mode(TextServer::AUTOWRAP_WORD_SMART);
tile_create_help->add_child(help_label); tile_atlas_view->add_child(help_label);
help_label = memnew(Label(TTR("Hold Shift to create big tiles.")));
tile_create_help->add_child(help_label);
tile_create_help->set_anchors_and_offsets_preset(Control::PRESET_BOTTOM_LEFT, Control::PRESET_MODE_MINSIZE, 8);
tile_create_help->set_grow_direction_preset(Control::PRESET_BOTTOM_LEFT);
base_tile_popup_menu = memnew(PopupMenu); base_tile_popup_menu = memnew(PopupMenu);
base_tile_popup_menu->add_shortcut(ED_GET_SHORTCUT("tiles_editor/delete"), TILE_DELETE); base_tile_popup_menu->add_shortcut(ED_GET_SHORTCUT("tiles_editor/delete"), TILE_DELETE);

View File

@@ -159,7 +159,7 @@ private:
// -- Atlas view -- // -- Atlas view --
TileAtlasView *tile_atlas_view = nullptr; TileAtlasView *tile_atlas_view = nullptr;
VBoxContainer *tile_create_help = nullptr; Label *help_label = nullptr;
// Dragging // Dragging
enum DragType { enum DragType {

View File

@@ -914,6 +914,8 @@ TileSetEditor::TileSetEditor() {
// No source selected. // No source selected.
no_source_selected_label = memnew(Label); no_source_selected_label = memnew(Label);
no_source_selected_label->set_text(TTR("No TileSet source selected. Select or create a TileSet source.\nYou can create a new source by using the Add button on the left or by dropping a tileset texture onto the source list.")); no_source_selected_label->set_text(TTR("No TileSet source selected. Select or create a TileSet source.\nYou can create a new source by using the Add button on the left or by dropping a tileset texture onto the source list."));
no_source_selected_label->set_autowrap_mode(TextServer::AUTOWRAP_WORD_SMART);
no_source_selected_label->set_text_overrun_behavior(TextServer::OVERRUN_TRIM_ELLIPSIS);
no_source_selected_label->set_h_size_flags(SIZE_EXPAND_FILL); no_source_selected_label->set_h_size_flags(SIZE_EXPAND_FILL);
no_source_selected_label->set_v_size_flags(SIZE_EXPAND_FILL); no_source_selected_label->set_v_size_flags(SIZE_EXPAND_FILL);
no_source_selected_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); no_source_selected_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
@@ -953,8 +955,9 @@ TileSetEditor::TileSetEditor() {
patterns_help_label = memnew(Label); patterns_help_label = memnew(Label);
patterns_help_label->set_text(TTR("Add new patterns in the TileMap editing mode.")); patterns_help_label->set_text(TTR("Add new patterns in the TileMap editing mode."));
patterns_help_label->set_autowrap_mode(TextServer::AUTOWRAP_WORD_SMART);
patterns_help_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); patterns_help_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);
patterns_help_label->set_anchors_and_offsets_preset(Control::PRESET_CENTER); patterns_help_label->set_anchors_and_offsets_preset(Control::PRESET_HCENTER_WIDE);
patterns_item_list->add_child(patterns_help_label); patterns_item_list->add_child(patterns_help_label);
// Expanded editor // Expanded editor
@@ -978,6 +981,8 @@ void TileSourceInspectorPlugin::_show_id_edit_dialog(Object *p_for_source) {
Label *label = memnew(Label(TTR("Warning: Modifying a source ID will result in all TileMaps using that source to reference an invalid source instead. This may result in unexpected data loss. Change this ID carefully."))); Label *label = memnew(Label(TTR("Warning: Modifying a source ID will result in all TileMaps using that source to reference an invalid source instead. This may result in unexpected data loss. Change this ID carefully.")));
label->set_autowrap_mode(TextServer::AUTOWRAP_WORD); label->set_autowrap_mode(TextServer::AUTOWRAP_WORD);
// Workaround too tall popup window due to text autowrapping. See GH-83546.
label->set_custom_minimum_size(Vector2i(400, 0));
vbox->add_child(label); vbox->add_child(label);
id_input = memnew(SpinBox); id_input = memnew(SpinBox);

View File

@@ -44,8 +44,8 @@ class SplitContainer;
class EditorFileDialog; class EditorFileDialog;
class EditorInspectorPlugin; class EditorInspectorPlugin;
class TileSetEditor : public Control { class TileSetEditor : public MarginContainer {
GDCLASS(TileSetEditor, Control); GDCLASS(TileSetEditor, MarginContainer);
static TileSetEditor *singleton; static TileSetEditor *singleton;