1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-02-22 05:23:14 +00:00

Replace the fill area OptionButton with a Checkbox in the bucket tool options

This commit is contained in:
Emmanouil Papadeas 2022-09-18 16:36:03 +03:00
parent 698c7c4a08
commit 94789a57c8
3 changed files with 39 additions and 52 deletions

View file

@ -1322,13 +1322,13 @@ msgstr ""
msgid "0: Color from the brush itself, 100: the currently selected color" msgid "0: Color from the brush itself, 100: the currently selected color"
msgstr "" msgstr ""
msgid "Fill area:" #. Found in the bucket tool options, to let users toggle if it should fill colors continuously or not.
msgid "Fill continuously"
msgstr "" msgstr ""
msgid "Same color area" #. Hint tooltip of the "Fill continuously" checkbox, found in the bucket tool options.
msgstr "" msgid "If enabled, it fills the continuous area with the selected color.\n"
"If disabled, it replaces all pixels of the same color with the selected color."
msgid "Same color pixels"
msgstr "" msgstr ""
msgid "Fill with:" msgid "Fill with:"

View file

@ -5,7 +5,7 @@ const COLOR_REPLACE_SHADER := preload("res://src/Shaders/ColorReplace.shader")
var _prev_mode := 0 var _prev_mode := 0
var _pattern: Patterns.Pattern var _pattern: Patterns.Pattern
var _similarity := 100 var _similarity := 100
var _fill_area := 0 var _fill_area := true
var _fill_with := 0 var _fill_with := 0
var _offset_x := 0 var _offset_x := 0
var _offset_y := 0 var _offset_y := 0
@ -14,28 +14,22 @@ var _allegro_flood_segments: Array
# results array per image while flooding # results array per image while flooding
var _allegro_image_segments: Array var _allegro_image_segments: Array
onready var fill_check_box: CheckBox = $FillCheckBox
func _ready() -> void: func _ready() -> void:
update_pattern() update_pattern()
func _input(event: InputEvent) -> void: func _input(event: InputEvent) -> void:
var options: OptionButton = $FillAreaOptions if event.is_action_pressed("change_tool_mode") or event.is_action_released("change_tool_mode"):
fill_check_box.pressed = not fill_check_box.pressed
if event.is_action_pressed("change_tool_mode"): _fill_area = fill_check_box.pressed
_prev_mode = options.selected $Similarity.visible = not _fill_area
if event.is_action("change_tool_mode"):
options.selected = _prev_mode ^ 1
_fill_area = options.selected
$Similarity.visible = (_fill_area == 1)
if event.is_action_released("change_tool_mode"):
options.selected = _prev_mode
_fill_area = options.selected
$Similarity.visible = (_fill_area == 1)
func _on_FillAreaOptions_item_selected(index: int) -> void: func _on_FillCheckBox_toggled(button_pressed: bool) -> void:
_fill_area = index _fill_area = button_pressed
update_config() update_config()
save_config() save_config()
@ -111,9 +105,9 @@ func set_config(config: Dictionary) -> void:
func update_config() -> void: func update_config() -> void:
$FillAreaOptions.selected = _fill_area $FillCheckBox.pressed = _fill_area
$FillWithOptions.selected = _fill_with $FillWithOptions.selected = _fill_with
$Similarity.visible = (_fill_area == 1) $Similarity.visible = not _fill_area
$Similarity/Value.value = _similarity $Similarity/Value.value = _similarity
$Similarity/Slider.value = _similarity $Similarity/Slider.value = _similarity
$FillPattern.visible = _fill_with == 1 $FillPattern.visible = _fill_with == 1
@ -154,7 +148,7 @@ func draw_start(position: Vector2) -> void:
): ):
return return
var undo_data = _get_undo_data() var undo_data = _get_undo_data()
if _fill_area == 0: if _fill_area:
fill_in_area(position) fill_in_area(position)
else: else:
fill_in_color(position) fill_in_color(position)

View file

@ -27,28 +27,21 @@ margin_bottom = 105.0
script = ExtResource( 3 ) script = ExtResource( 3 )
[node name="Label" parent="." index="0"] [node name="Label" parent="." index="0"]
margin_right = 131.0 margin_right = 133.0
[node name="FillArea" type="Label" parent="." index="1"] [node name="FillCheckBox" type="CheckBox" parent="." index="1"]
margin_left = 38.0
margin_top = 18.0 margin_top = 18.0
margin_right = 92.0 margin_right = 133.0
margin_bottom = 32.0 margin_bottom = 42.0
hint_tooltip = "If enabled, it fills the continuous area with the selected color.
If disabled, it replaces all pixels of the same color with the selected color."
mouse_default_cursor_shape = 2 mouse_default_cursor_shape = 2
size_flags_horizontal = 4 size_flags_horizontal = 4
text = "Fill area:" pressed = true
text = "Fill continuously"
align = 1
[node name="FillAreaOptions" type="OptionButton" parent="." index="2"] [node name="Similarity" type="VBoxContainer" parent="." index="2"]
margin_top = 36.0
margin_right = 131.0
margin_bottom = 56.0
mouse_default_cursor_shape = 2
size_flags_horizontal = 4
text = "Same color area"
items = [ "Same color area", null, false, 0, null, "Same color pixels", null, false, 1, null ]
selected = 0
[node name="Similarity" type="VBoxContainer" parent="." index="3"]
visible = false visible = false
margin_top = 60.0 margin_top = 60.0
margin_right = 131.0 margin_right = 131.0
@ -96,26 +89,26 @@ __meta__ = {
"_editor_description_": "" "_editor_description_": ""
} }
[node name="FillWith" type="Label" parent="." index="4"] [node name="FillWith" type="Label" parent="." index="3"]
margin_left = 38.0 margin_left = 39.0
margin_top = 60.0 margin_top = 46.0
margin_right = 92.0 margin_right = 93.0
margin_bottom = 74.0 margin_bottom = 60.0
size_flags_horizontal = 4 size_flags_horizontal = 4
text = "Fill with:" text = "Fill with:"
[node name="FillWithOptions" type="OptionButton" parent="." index="5"] [node name="FillWithOptions" type="OptionButton" parent="." index="4"]
margin_left = 5.0 margin_left = 6.0
margin_top = 78.0 margin_top = 64.0
margin_right = 126.0 margin_right = 127.0
margin_bottom = 98.0 margin_bottom = 84.0
mouse_default_cursor_shape = 2 mouse_default_cursor_shape = 2
size_flags_horizontal = 4 size_flags_horizontal = 4
text = "Selected Color" text = "Selected Color"
items = [ "Selected Color", null, false, 0, null, "Pattern", null, false, 1, null ] items = [ "Selected Color", null, false, 0, null, "Pattern", null, false, 1, null ]
selected = 0 selected = 0
[node name="FillPattern" type="VBoxContainer" parent="." index="6"] [node name="FillPattern" type="VBoxContainer" parent="." index="5"]
visible = false visible = false
margin_left = 22.0 margin_left = 22.0
margin_top = 102.0 margin_top = 102.0
@ -187,7 +180,7 @@ margin_right = 85.0
margin_bottom = 24.0 margin_bottom = 24.0
mouse_default_cursor_shape = 2 mouse_default_cursor_shape = 2
[connection signal="item_selected" from="FillAreaOptions" to="." method="_on_FillAreaOptions_item_selected"] [connection signal="toggled" from="FillCheckBox" to="." method="_on_FillCheckBox_toggled"]
[connection signal="value_changed" from="Similarity/Value" to="." method="_on_Value_value_changed"] [connection signal="value_changed" from="Similarity/Value" to="." method="_on_Value_value_changed"]
[connection signal="value_changed" from="Similarity/Slider" to="." method="_on_Slider_value_changed"] [connection signal="value_changed" from="Similarity/Slider" to="." method="_on_Slider_value_changed"]
[connection signal="item_selected" from="FillWithOptions" to="." method="_on_FillWithOptions_item_selected"] [connection signal="item_selected" from="FillWithOptions" to="." method="_on_FillWithOptions_item_selected"]