Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created dummyBtn which holds the ButtonGrp #329

Merged
merged 2 commits into from
Sep 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Palette/EditPalettePopup.gd
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ onready var color_name_edit = $VBoxContainer/PaletteOptions/EditPaletteColorName
onready var palette_name_edit = $VBoxContainer/PaletteOptions/EditPaletteNameLineEdit
onready var left_color_button = $VBoxContainer/HBoxContainer/VBoxContainer/CenterContainer/HBoxContainer/LeftColor/NinePatchRect
onready var right_color_button = $VBoxContainer/HBoxContainer/VBoxContainer/CenterContainer/HBoxContainer/RightColor/NinePatchRect
onready var dummyBtn = $DummyBtn


func _ready() -> void:
Expand Down Expand Up @@ -46,6 +47,7 @@ func _display_palette() -> void:
new_button.index = index
new_button.connect("on_drop_data", self, "on_move_swatch")
new_button.connect("pressed", self, "on_swatch_select", [new_button])
new_button.group = dummyBtn.group

palette_grid.add_child(new_button)
index += 1
Expand All @@ -56,7 +58,7 @@ func _display_palette() -> void:

func _clear_swatches() -> void:
for child in palette_grid.get_children():
if child is BaseButton:
if child is BaseButton and child.text != "Dummy":
child.disconnect("on_drop_data", self, "on_move_swatch")
child.queue_free()

Expand Down Expand Up @@ -90,6 +92,7 @@ func _on_AddSwatchButton_pressed() -> void:
new_button.index = index
new_button.connect("on_drop_data", self, "on_move_swatch")
new_button.connect("pressed", self, "on_swatch_select", [new_button])
new_button.group = dummyBtn.group

palette_grid.add_child(new_button)
on_swatch_select(new_button)
Expand Down
13 changes: 12 additions & 1 deletion src/Palette/EditPalettePopup.tscn
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
[gd_scene load_steps=5 format=2]
[gd_scene load_steps=6 format=2]

[ext_resource path="res://src/Palette/EditPalettePopup.gd" type="Script" id=1]
[ext_resource path="res://assets/graphics/dark_themes/timeline/new_frame.png" type="Texture" id=2]
[ext_resource path="res://assets/graphics/dark_themes/timeline/remove_frame.png" type="Texture" id=3]
[ext_resource path="res://assets/graphics/palette/palette_button_fill.png" type="Texture" id=6]

[sub_resource type="ButtonGroup" id=1]

[node name="EditPalettePopup" type="WindowDialog"]
margin_right = 600.0
margin_bottom = 550.0
Expand Down Expand Up @@ -228,6 +230,15 @@ margin_left = 423.0
margin_right = 580.0
margin_bottom = 20.0
size_flags_horizontal = 3

[node name="DummyBtn" type="Button" parent="."]
visible = false
margin_left = 322.0
margin_top = 10.0
margin_right = 385.0
margin_bottom = 30.0
group = SubResource( 1 )
text = "Dummy"
[connection signal="popup_hide" from="." to="." method="_on_EditPalettePopup_popup_hide"]
[connection signal="color_changed" from="VBoxContainer/HBoxContainer/EditPaletteColorPicker" to="." method="_on_EditPaletteColorPicker_color_changed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer/VBoxContainer/CenterContainer/HBoxContainer/LeftColor" to="." method="_on_LeftColor_pressed"]
Expand Down
4 changes: 1 addition & 3 deletions src/Palette/PaletteButton.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
[ext_resource path="res://assets/themes/palette_styleboxes/palette_stylebox_normal.tres" type="StyleBox" id=5]
[ext_resource path="res://assets/graphics/palette/palette_button_fill.png" type="Texture" id=6]




[sub_resource type="ImageTexture" id=1]

[node name="PaletteButton" type="Button"]
Expand All @@ -22,6 +19,7 @@ custom_styles/hover = ExtResource( 2 )
custom_styles/pressed = ExtResource( 1 )
custom_styles/focus = ExtResource( 4 )
custom_styles/normal = ExtResource( 5 )
toggle_mode = true
action_mode = 0
button_mask = 3
icon = SubResource( 1 )
Expand Down
3 changes: 2 additions & 1 deletion src/Palette/PaletteContainer.gd
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func _ready() -> void:

func _clear_swatches() -> void:
for child in get_children():
if child is BaseButton:
if child is BaseButton and child.text != "Dummy":
child.disconnect("pressed", self, "on_color_select")
child.queue_free()

Expand Down Expand Up @@ -218,6 +218,7 @@ func _display_palette(palette : Palette) -> void:
new_button.get_child(0).modulate = color
new_button.hint_tooltip = "#" + color_data.data.to_upper() + " " + color_data.name
new_button.connect("pressed", self, "on_color_select", [index])
new_button.group = $DummyBtn.group

add_child(new_button)
index += 1
Expand Down
13 changes: 12 additions & 1 deletion src/Palette/PalettePanelContainer.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=8 format=2]
[gd_scene load_steps=9 format=2]

[ext_resource path="res://src/Palette/PaletteContainer.gd" type="Script" id=1]
[ext_resource path="res://assets/graphics/dark_themes/palette/edit_palette.png" type="Texture" id=2]
Expand All @@ -8,6 +8,8 @@
[ext_resource path="res://src/Palette/NewPaletteDialog.tscn" type="PackedScene" id=6]
[ext_resource path="res://src/Palette/EditPalettePopup.tscn" type="PackedScene" id=7]

[sub_resource type="ButtonGroup" id=1]

[node name="PalettePanelContainer" type="PanelContainer"]
margin_left = 15.0
margin_top = 261.0
Expand Down Expand Up @@ -160,6 +162,13 @@ size_flags_horizontal = 3
columns = 10
script = ExtResource( 1 )

[node name="DummyBtn" type="Button" parent="PaletteVBoxContainer/ScrollPalette/CenterPalette/PaletteContainer"]
visible = false
margin_right = 12.0
margin_bottom = 20.0
group = SubResource( 1 )
text = "Dummy"

[node name="NewPaletteDialog" parent="." instance=ExtResource( 6 )]
margin_left = 7.0
margin_top = 7.0
Expand All @@ -175,6 +184,8 @@ margin_left = 7.0
margin_top = 7.0
margin_right = 507.0
margin_bottom = 307.0
current_dir = "/home/luiq/data/libDev/git/Pixelorama"
current_path = "/home/luiq/data/libDev/git/Pixelorama/"

[node name="EditPalettePopup" parent="." instance=ExtResource( 7 )]
margin_left = 7.0
Expand Down