From a3d7725a44b40d55f2cec38f6a542f787fc61d6c Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Sat, 3 Aug 2024 22:36:05 +0300 Subject: [PATCH] Fix popups appearing in wrong places when single window mode is disabled --- src/Classes/ImageEffect.gd | 2 +- src/Palette/PalettePanel.gd | 4 ++-- src/Tools/BaseDraw.gd | 2 +- src/Tools/DesignTools/Bucket.gd | 2 +- src/Tools/SelectionTools/PaintSelect.gd | 2 +- src/UI/Canvas/ReferenceImages.gd | 8 ++++---- src/UI/GlobalToolOptions/GlobalToolOptions.gd | 2 +- src/UI/Nodes/GradientEdit.gd | 3 +-- src/UI/Recorder/Recorder.gd | 2 +- src/UI/ReferenceImages/ReferenceEdit.gd | 4 ++-- src/UI/Timeline/AnimationTimeline.gd | 2 +- src/UI/Timeline/CelButton.gd | 2 +- src/UI/Timeline/FrameButton.gd | 2 +- src/UI/Timeline/LayerButton.gd | 2 +- 14 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/Classes/ImageEffect.gd b/src/Classes/ImageEffect.gd index 7dd43e6dd..1567d416f 100644 --- a/src/Classes/ImageEffect.gd +++ b/src/Classes/ImageEffect.gd @@ -148,7 +148,7 @@ func set_nodes() -> void: live_checkbox.button_pressed = live_preview -func display_animate_dialog(): +func display_animate_dialog() -> void: var animate_dialog: Popup = animate_panel.get_parent() var pos := Vector2(position.x + size.x, position.y) var animate_dialog_rect := Rect2(pos, Vector2(animate_dialog.size.x, size.y)) diff --git a/src/Palette/PalettePanel.gd b/src/Palette/PalettePanel.gd index 1e335fcf4..50ee1a9e5 100644 --- a/src/Palette/PalettePanel.gd +++ b/src/Palette/PalettePanel.gd @@ -213,8 +213,8 @@ func _on_PaletteGrid_swatch_double_clicked(_mb: int, index: int, click_position: # Open color picker popup with its right bottom corner next to swatch var popup := hidden_color_picker.get_popup() - popup.position = click_position - Vector2(popup.size) - popup.popup() + var popup_position := click_position - Vector2(popup.size) + popup.popup_on_parent(Rect2i(popup_position, Vector2i.ONE)) func _on_PaletteGrid_swatch_dropped(source_index: int, target_index: int) -> void: diff --git a/src/Tools/BaseDraw.gd b/src/Tools/BaseDraw.gd index 8074b58bd..295ca9dfa 100644 --- a/src/Tools/BaseDraw.gd +++ b/src/Tools/BaseDraw.gd @@ -58,7 +58,7 @@ func _on_BrushType_pressed() -> void: for child in categories.get_children(): if child is GridContainer: child.columns = columns - Global.brushes_popup.popup(Rect2(pop_position, Vector2(size_x, size_y))) + Global.brushes_popup.popup_on_parent(Rect2(pop_position, Vector2(size_x, size_y))) Tools.flip_rotated.emit( _brush_flip_x, _brush_flip_y, _brush_rotate_90, _brush_rotate_180, _brush_rotate_270 ) diff --git a/src/Tools/DesignTools/Bucket.gd b/src/Tools/DesignTools/Bucket.gd index 721558c98..c4ccaf01e 100644 --- a/src/Tools/DesignTools/Bucket.gd +++ b/src/Tools/DesignTools/Bucket.gd @@ -79,7 +79,7 @@ func _on_PatternType_pressed() -> void: var popup: Popup = Global.patterns_popup if !popup.pattern_selected.is_connected(_on_Pattern_selected): popup.pattern_selected.connect(_on_Pattern_selected.bind(), CONNECT_ONE_SHOT) - popup.popup(Rect2i($FillPattern/Type.global_position, Vector2i(226, 72))) + popup.popup_on_parent(Rect2i($FillPattern/Type.global_position, Vector2i(226, 72))) func _on_Pattern_selected(pattern: Patterns.Pattern) -> void: diff --git a/src/Tools/SelectionTools/PaintSelect.gd b/src/Tools/SelectionTools/PaintSelect.gd index 8b42043b7..1a36972f7 100644 --- a/src/Tools/SelectionTools/PaintSelect.gd +++ b/src/Tools/SelectionTools/PaintSelect.gd @@ -272,7 +272,7 @@ func _on_BrushType_pressed() -> void: for child in categories.get_children(): if child is GridContainer: child.columns = columns - Global.brushes_popup.popup(Rect2(pop_position, Vector2(size_x, size_y))) + Global.brushes_popup.popup_on_parent(Rect2(pop_position, Vector2(size_x, size_y))) func _on_Brush_selected(brush: Brushes.Brush) -> void: diff --git a/src/UI/Canvas/ReferenceImages.gd b/src/UI/Canvas/ReferenceImages.gd index be3ed0189..845298338 100644 --- a/src/UI/Canvas/ReferenceImages.gd +++ b/src/UI/Canvas/ReferenceImages.gd @@ -49,8 +49,8 @@ func _input(event: InputEvent) -> void: if event.is_action_pressed("reference_quick_menu"): var list: Array[ReferenceImage] = Global.current_project.reference_images populate_reference_menu(list, true) - reference_menu.position = Global.control.get_global_mouse_position() - reference_menu.popup() + var popup_position := Global.control.get_global_mouse_position() + reference_menu.popup_on_parent(Rect2i(popup_position, Vector2i.ONE)) var ri: ReferenceImage = Global.current_project.get_current_reference_image() @@ -104,8 +104,8 @@ func _input(event: InputEvent) -> void: # 2. There are more than 1 Reference Images elif overlapping.size() > 1: populate_reference_menu(overlapping, true) - reference_menu.position = Global.control.get_global_mouse_position() - reference_menu.popup() + var popup_position := Global.control.get_global_mouse_position() + reference_menu.popup_on_parent(Rect2i(popup_position, Vector2i.ONE)) # 3. There are no Reference Images else: Global.current_project.set_reference_image_index(-1) diff --git a/src/UI/GlobalToolOptions/GlobalToolOptions.gd b/src/UI/GlobalToolOptions/GlobalToolOptions.gd index 6cab570a4..5f179a39f 100644 --- a/src/UI/GlobalToolOptions/GlobalToolOptions.gd +++ b/src/UI/GlobalToolOptions/GlobalToolOptions.gd @@ -79,4 +79,4 @@ func _on_alpha_lock_toggled(toggled_on: bool) -> void: func _on_Dynamics_pressed() -> void: var pos := dynamics.global_position + Vector2(0, 32) - dynamics_panel.popup(Rect2(pos, dynamics_panel.size)) + dynamics_panel.popup_on_parent(Rect2(pos, dynamics_panel.size)) diff --git a/src/UI/Nodes/GradientEdit.gd b/src/UI/Nodes/GradientEdit.gd index 545d6bd5c..2635b0a94 100644 --- a/src/UI/Nodes/GradientEdit.gd +++ b/src/UI/Nodes/GradientEdit.gd @@ -151,8 +151,7 @@ func select_color(cursor: GradientCursor, pos: Vector2) -> void: pos.x = global_position.x + size.x else: pos.x = global_position.x - $Popup.size.x - $Popup.position = pos - $Popup.popup() + $Popup.popup_on_parent(Rect2i(pos, Vector2.ONE)) func get_sorted_cursors() -> Array: diff --git a/src/UI/Recorder/Recorder.gd b/src/UI/Recorder/Recorder.gd index 893ada1a5..f2b611b9e 100644 --- a/src/UI/Recorder/Recorder.gd +++ b/src/UI/Recorder/Recorder.gd @@ -163,7 +163,7 @@ func _on_Start_toggled(button_pressed: bool) -> void: func _on_Settings_pressed() -> void: - options_dialog.popup(Rect2(position, options_dialog.size)) + options_dialog.popup_on_parent(Rect2(position, options_dialog.size)) func _on_SkipAmount_value_changed(value: float) -> void: diff --git a/src/UI/ReferenceImages/ReferenceEdit.gd b/src/UI/ReferenceImages/ReferenceEdit.gd index e52f684fe..bff73584e 100644 --- a/src/UI/ReferenceImages/ReferenceEdit.gd +++ b/src/UI/ReferenceImages/ReferenceEdit.gd @@ -141,8 +141,8 @@ func _on_Remove_pressed() -> void: references_container.remove_reference_image(index) references_panel._on_references_changed() else: - confirm_remove_dialog.position = Global.control.get_global_mouse_position() - confirm_remove_dialog.popup() + var popup_position := Global.control.get_global_mouse_position() + confirm_remove_dialog.popup_on_parent(Rect2i(popup_position, Vector2i.ONE)) Global.dialog_open(true) diff --git a/src/UI/Timeline/AnimationTimeline.gd b/src/UI/Timeline/AnimationTimeline.gd index fc943ed97..73e123c01 100644 --- a/src/UI/Timeline/AnimationTimeline.gd +++ b/src/UI/Timeline/AnimationTimeline.gd @@ -563,7 +563,7 @@ func _on_OnionSkinning_pressed() -> void: func _on_timeline_settings_button_pressed() -> void: var pos := Vector2i(onion_skinning_button.global_position) - timeline_settings.size - timeline_settings.popup(Rect2i(pos.x - 16, pos.y + 32, 136, 126)) + timeline_settings.popup_on_parent(Rect2i(pos.x - 16, pos.y + 32, 136, 126)) func _on_LoopAnim_pressed() -> void: diff --git a/src/UI/Timeline/CelButton.gd b/src/UI/Timeline/CelButton.gd index da16539b6..d6fd47d9d 100644 --- a/src/UI/Timeline/CelButton.gd +++ b/src/UI/Timeline/CelButton.gd @@ -111,7 +111,7 @@ func _on_CelButton_pressed() -> void: elif Input.is_action_just_released("right_mouse"): if cel is PixelCel: - popup_menu.popup(Rect2(get_global_mouse_position(), Vector2.ONE)) + popup_menu.popup_on_parent(Rect2(get_global_mouse_position(), Vector2.ONE)) button_pressed = !button_pressed elif Input.is_action_just_released("middle_mouse"): button_pressed = !button_pressed diff --git a/src/UI/Timeline/FrameButton.gd b/src/UI/Timeline/FrameButton.gd index 31159d3c7..82f63866c 100644 --- a/src/UI/Timeline/FrameButton.gd +++ b/src/UI/Timeline/FrameButton.gd @@ -69,7 +69,7 @@ func _button_pressed() -> void: popup_menu.set_item_disabled(MOVE_LEFT, false) if frame < Global.current_project.frames.size() - 1: popup_menu.set_item_disabled(MOVE_RIGHT, false) - popup_menu.popup(Rect2(get_global_mouse_position(), Vector2.ONE)) + popup_menu.popup_on_parent(Rect2(get_global_mouse_position(), Vector2.ONE)) button_pressed = !button_pressed elif Input.is_action_just_released("middle_mouse"): button_pressed = !button_pressed diff --git a/src/UI/Timeline/LayerButton.gd b/src/UI/Timeline/LayerButton.gd index aab686f48..aca3df875 100644 --- a/src/UI/Timeline/LayerButton.gd +++ b/src/UI/Timeline/LayerButton.gd @@ -147,7 +147,7 @@ func _on_main_button_gui_input(event: InputEvent) -> void: elif event.button_index == MOUSE_BUTTON_RIGHT and event.pressed: var layer := Global.current_project.layers[layer_index] if not layer is GroupLayer: - popup_menu.popup(Rect2(get_global_mouse_position(), Vector2.ONE)) + popup_menu.popup_on_parent(Rect2(get_global_mouse_position(), Vector2.ONE)) func _on_layer_name_line_edit_focus_exited() -> void: