1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-30 23:19:49 +00:00

Remove Global.reference_panel

Slowly trying to remove nodes from Global
This commit is contained in:
Emmanouil Papadeas 2024-03-23 02:52:27 +02:00
parent 54142eb048
commit 572fabbe66
6 changed files with 17 additions and 20 deletions

View file

@ -576,10 +576,6 @@ var cel_button_scene: PackedScene = load("res://src/UI/Timeline/CelButton.tscn")
## The perspective editor. It has the [param PerspectiveEditor.gd] script attached.
@onready var perspective_editor := control.find_child("Perspective Editor")
## The reference panel. It has the [param ReferencesPanel.gd] script attached.
@onready var reference_panel: ReferencesPanel = control.find_child("Reference Images")
## The top menu container. It has the [param TopMenuContainer.gd] script attached.
@onready var top_menu_container: Panel = control.find_child("TopMenuContainer")
## The label indicating cursor position.

View file

@ -260,7 +260,6 @@ func remove_reference_image(idx: int) -> void:
ri.queue_free()
Global.current_project.set_reference_image_index(-1)
Global.current_project.change_project()
Global.reference_panel._on_references_changed()
func _update_on_zoom() -> void:

View file

@ -1,7 +1,7 @@
extends VBoxContainer
@export var references_panel: ReferencesPanel
var undo_data: Dictionary
var _prev_index: int = -1
var _ignore_spinbox_changes: bool = false
@ -139,6 +139,7 @@ func _on_Remove_pressed():
# If shift is pressed we just remove it without a dialog
if Input.is_action_pressed("shift"):
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()
@ -238,6 +239,7 @@ func _on_confirm_remove_dialog_confirmed() -> void:
var index: int = Global.current_project.reference_index
if index > -1:
references_container.remove_reference_image(index)
references_panel._on_references_changed()
Global.dialog_open(false)

View file

@ -1,5 +1,7 @@
extends Button
var references_panel: ReferencesPanel
func _get_drag_data(_at_position: Vector2) -> Variant:
var index := get_index() - 1
@ -16,10 +18,10 @@ func _get_drag_data(_at_position: Vector2) -> Variant:
func _can_drop_data(_at_position: Vector2, data: Variant) -> bool:
if typeof(data) != TYPE_ARRAY:
Global.reference_panel.drag_highlight.visible = false
references_panel.drag_highlight.visible = false
return false
if data[0] != "ReferenceImage":
Global.reference_panel.drag_highlight.visible = false
references_panel.drag_highlight.visible = false
return false
var index := get_index() - 1
@ -27,7 +29,7 @@ func _can_drop_data(_at_position: Vector2, data: Variant) -> bool:
# If the index < 0 then that means this button is the "reset button"
# Or we are trying to drop on the same button
if index < 0 or index == from_index:
Global.reference_panel.drag_highlight.visible = false
references_panel.drag_highlight.visible = false
return false
var side: int = -1
@ -40,9 +42,9 @@ func _can_drop_data(_at_position: Vector2, data: Variant) -> bool:
if side == 1:
region.position.x = (size.x + global_position.x) - 3
Global.reference_panel.drag_highlight.visible = true
Global.reference_panel.drag_highlight.position = region.position
Global.reference_panel.drag_highlight.size = region.size
references_panel.drag_highlight.visible = true
references_panel.drag_highlight.position = region.position
references_panel.drag_highlight.size = region.size
return true
@ -59,9 +61,4 @@ func _drop_data(_at_position: Vector2, data: Variant) -> void:
if from_index < to_index:
to_index -= 1
Global.reference_panel.reorder_reference_image(from_index, to_index - 1, false)
#Global.current_project.reorder_reference_image(from_index, to_index - 1)
#Global.reference_panel._on_references_changed()
#Global.reference_panel.drag_highlight.visible = false
references_panel.reorder_reference_image(from_index, to_index - 1, false)

View file

@ -2,7 +2,7 @@ class_name ReferencesPanel
extends PanelContainer
## Panel for reference image management
const REFERENCE_IMAGE_BUTTON = preload("res://src/UI/ReferenceImages/ReferenceImageButton.tscn")
const REFERENCE_IMAGE_BUTTON := preload("res://src/UI/ReferenceImages/ReferenceImageButton.tscn")
var list_btn_group := ButtonGroup.new()
var transform_button_group: ButtonGroup
@ -155,6 +155,7 @@ func _on_references_changed() -> void:
# The default button
var default := REFERENCE_IMAGE_BUTTON.instantiate()
default.references_panel = self
default.button_group = list_btn_group
default.text = "none"
default.get_child(0).visible = false # Hide it's transparent checker
@ -175,6 +176,7 @@ func _on_references_changed() -> void:
# And update.
for ref in Global.current_project.reference_images:
var l: Button = REFERENCE_IMAGE_BUTTON.instantiate()
l.references_panel = self
l.button_group = list_btn_group
if ref.texture:
l.icon = ref.texture

View file

@ -242,9 +242,10 @@ custom_minimum_size = Vector2(0, 64)
layout_mode = 2
size_flags_horizontal = 3
[node name="ReferenceEdit" type="VBoxContainer" parent="ScrollContainer/Container"]
[node name="ReferenceEdit" type="VBoxContainer" parent="ScrollContainer/Container" node_paths=PackedStringArray("references_panel")]
layout_mode = 2
script = ExtResource("3_skjtb")
references_panel = NodePath("../../..")
[node name="HSeparator" type="HSeparator" parent="ScrollContainer/Container/ReferenceEdit"]
layout_mode = 2