godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.19k stars 21.21k forks source link

Select property button in TileSet Paint Editor is not toggleable #97336

Open forkercat opened 1 month ago

forkercat commented 1 month ago

Tested versions

Reproducible in: 4.3.1.dev [ff9bc04223] and 4.3 stable release

System information

Godot v4.3.1.rc (ff9bc0422) - macOS 15.0.0 - Vulkan (Forward+) - integrated Apple M1 Max - Apple M1 Max (10 Threads)

Issue description

In TileSet editor, the "Select a property editor" button is not toggleable. Clicking the button second time won't close the popup. It is a minor issue since the popup can be closed when clicking empty space.

Also, selecting the same property type won't close the popup.

Steps to reproduce

  1. Add a TileMap or TileMapLayer node in a new scene
  2. Create a new TileSet
  3. Focus on the TileSet editor
  4. Create an atlas with icon.svg
  5. Click to switch to Paint mode
  6. Click the button "Select a property editor"
  7. Click the button second time

Expect it to close when the popup is visible. Currently, I can click empty space to close the popup.

https://github.com/user-attachments/assets/0c47eef3-f1b2-4725-a14a-c35a51d1a5db

Minimal reproduction project (MRP)

N/A

forkercat commented 1 month ago

Tried adding tile_data_editors_popup->hide() if Popup::popped_up == true, but it didn't work.

TileSetAtlasSourceEditor::TileSetAtlasSourceEditor() {
    ...
    tile_data_editor_dropdown_button->connect(SceneStringName(pressed), callable_mp(this, &TileSetAtlasSourceEditor::_tile_data_editor_dropdown_button_pressed));
    ...
}

void TileSetAtlasSourceEditor::_tile_data_editor_dropdown_button_pressed() {
    Size2 size = tile_data_editor_dropdown_button->get_size();
    tile_data_editors_popup->set_position(tile_data_editor_dropdown_button->get_screen_position() + Size2(0, size.height * get_global_transform().get_scale().y));
    tile_data_editors_popup->set_size(Size2(size.width, 0));
    tile_data_editors_popup->popup();
}

Looks like when the button is clicked Popup::_close_pressed is called to reset Popup::popped_up to false, so when this function is called popped_up is always false.