1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-02-07 10:59: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. ## The perspective editor. It has the [param PerspectiveEditor.gd] script attached.
@onready var perspective_editor := control.find_child("Perspective Editor") @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. ## The top menu container. It has the [param TopMenuContainer.gd] script attached.
@onready var top_menu_container: Panel = control.find_child("TopMenuContainer") @onready var top_menu_container: Panel = control.find_child("TopMenuContainer")
## The label indicating cursor position. ## The label indicating cursor position.

View file

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

View file

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

View file

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

View file

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

View file

@ -242,9 +242,10 @@ custom_minimum_size = Vector2(0, 64)
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 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 layout_mode = 2
script = ExtResource("3_skjtb") script = ExtResource("3_skjtb")
references_panel = NodePath("../../..")
[node name="HSeparator" type="HSeparator" parent="ScrollContainer/Container/ReferenceEdit"] [node name="HSeparator" type="HSeparator" parent="ScrollContainer/Container/ReferenceEdit"]
layout_mode = 2 layout_mode = 2