mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-06-25 15:54:44 -04:00
Rename layers, layers & frames are now toggle-able buttons
This commit is contained in:
parent
79ceced483
commit
c535ec801a
8 changed files with 85 additions and 47 deletions
|
@ -1,31 +1,38 @@
|
|||
extends PanelContainer
|
||||
extends Button
|
||||
class_name LayerContainer
|
||||
|
||||
var i
|
||||
# warning-ignore:unused_class_variable
|
||||
var currently_selected := false
|
||||
var visibility_toggled := false
|
||||
|
||||
func _ready() -> void:
|
||||
var stylebox := StyleBoxFlat.new()
|
||||
stylebox.bg_color = Color("3d3b45")
|
||||
add_stylebox_override("panel", stylebox)
|
||||
changed_selection()
|
||||
|
||||
# warning-ignore:unused_argument
|
||||
func _process(delta) -> void:
|
||||
var mouse_pos := get_local_mouse_position() + rect_position
|
||||
if Rect2(rect_position, rect_position + rect_size).has_point(mouse_pos) && !visibility_toggled:
|
||||
if Input.is_action_just_pressed("left_mouse"):
|
||||
Global.canvas.current_layer_index = i
|
||||
changed_selection()
|
||||
func _on_LayerContainer_pressed() -> void:
|
||||
var initially_pressed := pressed
|
||||
var label_initially_visible : bool = $HBoxContainer/Label.visible
|
||||
Global.canvas.current_layer_index = i
|
||||
changed_selection()
|
||||
if !initially_pressed:
|
||||
if label_initially_visible:
|
||||
$HBoxContainer/Label.visible = false
|
||||
$HBoxContainer/LineEdit.visible = true
|
||||
$HBoxContainer/LineEdit.editable = true
|
||||
else:
|
||||
$HBoxContainer/Label.visible = true
|
||||
$HBoxContainer/LineEdit.visible = false
|
||||
$HBoxContainer/LineEdit.editable = false
|
||||
|
||||
func changed_selection() -> void:
|
||||
var parent = get_parent()
|
||||
for child in parent.get_children():
|
||||
if child is PanelContainer:
|
||||
if child is Button:
|
||||
child.get_node("HBoxContainer/Label").visible = true
|
||||
child.get_node("HBoxContainer/LineEdit").visible = false
|
||||
child.get_node("HBoxContainer/LineEdit").editable = false
|
||||
if Global.canvas.current_layer_index == child.i:
|
||||
child.currently_selected = true
|
||||
child.get_stylebox("panel").bg_color = Color("282532")
|
||||
child.pressed = true
|
||||
|
||||
if Global.canvas.current_layer_index < Global.canvas.layers.size() - 1:
|
||||
Global.move_up_layer_button.disabled = false
|
||||
|
@ -46,7 +53,7 @@ func changed_selection() -> void:
|
|||
Global.merge_down_layer_button.mouse_default_cursor_shape = Control.CURSOR_FORBIDDEN
|
||||
else:
|
||||
child.currently_selected = false
|
||||
child.get_stylebox("panel").bg_color = Color("3d3b45")
|
||||
child.pressed = false
|
||||
|
||||
func _on_VisibilityButton_pressed() -> void:
|
||||
if Global.canvas.layers[i][3]:
|
||||
|
@ -56,9 +63,6 @@ func _on_VisibilityButton_pressed() -> void:
|
|||
Global.canvas.layers[i][3] = true
|
||||
get_child(0).get_child(0).text = "V"
|
||||
|
||||
|
||||
func _on_VisibilityButton_button_down() -> void:
|
||||
visibility_toggled = true
|
||||
|
||||
func _on_VisibilityButton_button_up() -> void:
|
||||
visibility_toggled = false
|
||||
func _on_LineEdit_text_changed(new_text : String) -> void:
|
||||
Global.canvas.layers[i][2] = new_text
|
||||
$HBoxContainer/Label.text = new_text
|
Loading…
Add table
Add a link
Reference in a new issue