Skip to content

Commit f331b77

Browse files
authored
Merge pull request #930 from aidandavey/AssetDock-fixes
Fix search and pinned button
2 parents e5f17d7 + 1b590d7 commit f331b77

File tree

1 file changed

+34
-28
lines changed

1 file changed

+34
-28
lines changed

project/addons/terrain_3d/src/asset_dock.gd

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ var window: Window
4747
var _godot_last_state: Window.Mode = Window.MODE_FULLSCREEN
4848

4949

50+
func _notification(what: int) -> void:
51+
if what == NOTIFICATION_ENTER_TREE:
52+
await get_tree().process_frame
53+
update_layout()
54+
55+
5056
func initialize(p_plugin: EditorPlugin) -> void:
5157
if p_plugin:
5258
plugin = p_plugin
@@ -103,35 +109,30 @@ func initialize(p_plugin: EditorPlugin) -> void:
103109
meshes_btn.add_theme_font_size_override("font_size", 16 * EditorInterface.get_editor_scale())
104110
textures_btn.add_theme_font_size_override("font_size", 16 * EditorInterface.get_editor_scale())
105111

106-
_initialized = true
107-
update_dock()
108-
update_layout()
109-
110-
111-
func _ready() -> void:
112-
if not _initialized:
113-
return
114-
115-
# Setup styles
116-
set("theme_override_styles/panel", get_theme_stylebox("panel", "Panel"))
117-
# Avoid saving icon resources in tscn when editing w/ a tool script
118-
if EditorInterface.get_edited_scene_root() != self:
119-
pinned_btn.icon = get_theme_icon("Pin", "EditorIcons")
120-
pinned_btn.text = ""
121-
search_button.icon = get_theme_icon("Search", "EditorIcons")
122-
123112
search_box.text_changed.connect(_on_search_text_changed)
124113
search_button.pressed.connect(_on_search_button_pressed)
125114

126115
confirm_dialog = ConfirmationDialog.new()
127116
add_child(confirm_dialog, true)
128117
confirm_dialog.hide()
129118
confirm_dialog.confirmed.connect(func(): _confirmed = true; \
130-
emit_signal("confirmation_closed"); \
131-
emit_signal("confirmation_confirmed") )
119+
confirmation_closed.emit(); \
120+
confirmation_confirmed.emit() )
132121
confirm_dialog.canceled.connect(func(): _confirmed = false; \
133-
emit_signal("confirmation_closed"); \
134-
emit_signal("confirmation_canceled") )
122+
confirmation_closed.emit(); \
123+
confirmation_canceled.emit() )
124+
125+
# Setup styles
126+
set("theme_override_styles/panel", get_theme_stylebox("panel", "Panel"))
127+
# Avoid saving icon resources in tscn when editing w/ a tool script
128+
if EditorInterface.get_edited_scene_root() != self:
129+
pinned_btn.icon = get_theme_icon("Pin", "EditorIcons")
130+
pinned_btn.text = ""
131+
search_button.icon = get_theme_icon("Search", "EditorIcons")
132+
133+
_initialized = true
134+
update_dock()
135+
update_layout()
135136

136137

137138
func _gui_input(p_event: InputEvent) -> void:
@@ -201,17 +202,21 @@ func update_dock() -> void:
201202

202203

203204
func update_layout() -> void:
204-
if plugin.debug > 1:
205-
print("Terrain3DAssetDock: update_layout")
206205
if not _initialized:
207206
return
207+
if plugin.debug > 1:
208+
print("Terrain3DAssetDock: update_layout")
209+
208210

209211
# Detect if we have a new window from Make floating, grab it so we can free it properly
210-
if not window and get_parent() and get_parent().get_parent() is Window:
211-
window = get_parent().get_parent()
212-
make_dock_float()
212+
if not window and get_parent() and get_parent().get_parent().get_parent() is Window:
213+
window = get_parent().get_parent().get_parent()
213214
return # Will call this function again upon display
214-
215+
elif window and get_parent() and not get_parent().get_parent().get_parent() is Window:
216+
window = null
217+
return # Will call this function again upon display
218+
219+
215220
# Vertical layout: buttons on top
216221
if size.x < 500 or ( not window and _dock_slot < EditorDock.DockSlot.DOCK_SLOT_BOTTOM ):
217222
box.vertical = true
@@ -228,9 +233,10 @@ func update_layout() -> void:
228233
search_box.reparent(buttons)
229234
buttons.move_child(search_box, 0)
230235
size_slider.reparent(buttons)
231-
buttons.move_child(size_slider, 4)
236+
buttons.move_child(size_slider, 3)
232237
pinned_btn.reparent(box)
233238

239+
pinned_btn.visible = is_instance_valid(window)
234240
save_editor_settings()
235241

236242

0 commit comments

Comments
 (0)