Skip to content

Commit

Permalink
simplify the code and move it to the Export Dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Variable-ind committed Feb 5, 2025
1 parent 0d57155 commit 557cd7d
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 22 deletions.
1 change: 0 additions & 1 deletion project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ enabled=PackedStringArray("res://addons/aimg_io/plugin.cfg", "res://addons/docka

CanvasCameras=""
CanvasPreviews=""
FixInternalDialogs="Nodes in this group contain internal windows whose always_on_top needs correction"

[importer_defaults]

Expand Down
3 changes: 0 additions & 3 deletions src/Main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,6 @@ func _ready() -> void:
_handle_cmdline_arguments()
get_tree().root.files_dropped.connect(_on_files_dropped)

# Fix always_on_top of currently existing internal dialogs
Global.top_menu_container.Dialog.fix_internal_dialogs()

if OS.get_name() == "Android":
OS.request_permissions()
_handle_backup()
Expand Down
5 changes: 5 additions & 0 deletions src/UI/Dialogs/ExportDialog.gd
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ func _ready() -> void:
else:
file_exists_alert_popup.add_button("Cancel Export", false, "cancel")

# TODO: Remove the for loop when https://github.com/godotengine/godot/issues/92848 gets fixed.
for dialog_child in path_dialog_popup.get_children(true):
if dialog_child is Window:
dialog_child.always_on_top = path_dialog_popup.always_on_top


func show_tab() -> void:
get_tree().call_group("ExportImageOptions", "hide")
Expand Down
3 changes: 2 additions & 1 deletion src/UI/Dialogs/ExportDialog.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ size_flags_vertical = 3
[node name="TransparentChecker" parent="VBoxContainer/VSplitContainer/PreviewPanel" instance=ExtResource("2")]
unique_name_in_owner = true
layout_mode = 0
anchors_preset = 0
anchor_right = 1.0
anchor_bottom = 1.0

Expand Down Expand Up @@ -330,7 +331,7 @@ tooltip_text = "Only export content that is within the bounds of a selected area
mouse_default_cursor_shape = 2
text = "Clip image content to selection"

[node name="PathDialog" type="FileDialog" parent="." groups=["FileDialogs", "FixInternalDialogs"]]
[node name="PathDialog" type="FileDialog" parent="." groups=["FileDialogs"]]
mode = 2
title = "Open a Directory"
size = Vector2i(675, 500)
Expand Down
2 changes: 1 addition & 1 deletion src/UI/Dialogs/OpenSprite.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene format=3 uid="uid://b3aeqj2k58wdk"]

[node name="OpenSprite" type="FileDialog" groups=["FileDialogs", "FixInternalDialogs"]]
[node name="OpenSprite" type="FileDialog" groups=["FileDialogs"]]
title = "Open File(s)"
size = Vector2i(558, 400)
ok_button_text = "Open"
Expand Down
2 changes: 1 addition & 1 deletion src/UI/Dialogs/SaveSprite.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene format=3 uid="uid://d4euwo633u33b"]

[node name="SaveSprite" type="FileDialog" groups=["FileDialogs", "FixInternalDialogs"]]
[node name="SaveSprite" type="FileDialog" groups=["FileDialogs"]]
size = Vector2i(675, 400)
ok_button_text = "Save"
access = 2
Expand Down
15 changes: 0 additions & 15 deletions src/UI/TopMenuContainer/TopMenuContainer.gd
Original file line number Diff line number Diff line change
Expand Up @@ -99,21 +99,6 @@ class Dialog:
node = scene.instantiate()
if is_instance_valid(node):
Global.control.get_node("Dialogs").add_child(node)
fix_internal_dialogs()

static func fix_internal_dialogs() -> void:
# Procedurally set always_on_top roperty of sub items.
# (This could be an option button or window, etc...)
for item in Global.get_tree().get_nodes_in_group(&"FixInternalDialogs"):
# Sub dialogs are usually open one at a time so it should be safe to set them all
# to be always on top.
var parent_window: Window = item.get_window()
if item is Window:
parent_window = item
for dialog_child in item.get_children(true):
if dialog_child is Window:
dialog_child.always_on_top = parent_window.always_on_top
item.remove_from_group(&"FixInternalDialogs")


func _ready() -> void:
Expand Down

0 comments on commit 557cd7d

Please sign in to comment.