mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-19 01:29:49 +00:00
Add ValueSliders to Bucket and SelectionTool tool options
Replace Bucket's pattern offsets and SelectionTool's position and size SpinBoxes with ValueSliders.
This commit is contained in:
parent
ed76cc05e9
commit
0c954e65d8
|
@ -44,7 +44,7 @@ func _on_FillAreaOptions_item_selected(index: int) -> void:
|
|||
|
||||
|
||||
func _select_fill_area_optionbutton() -> void:
|
||||
$"%FillAreaOptions".selected = _fill_area
|
||||
$FillAreaOptions.selected = _fill_area
|
||||
$SimilaritySlider.visible = (_fill_area == FillArea.COLORS)
|
||||
|
||||
|
||||
|
@ -112,11 +112,11 @@ func set_config(config: Dictionary) -> void:
|
|||
|
||||
func update_config() -> void:
|
||||
_select_fill_area_optionbutton()
|
||||
$"%FillWithOptions".selected = _fill_with
|
||||
$FillWithOptions.selected = _fill_with
|
||||
$SimilaritySlider.value = _similarity
|
||||
$FillPattern.visible = _fill_with == FillWith.PATTERN
|
||||
$FillPattern/XOffset/OffsetX.value = _offset_x
|
||||
$FillPattern/YOffset/OffsetY.value = _offset_y
|
||||
$FillPattern/OffsetX.value = _offset_x
|
||||
$FillPattern/OffsetY.value = _offset_y
|
||||
|
||||
|
||||
func update_pattern() -> void:
|
||||
|
@ -130,8 +130,8 @@ func update_pattern() -> void:
|
|||
tex.create_from_image(_pattern.image, 0)
|
||||
$FillPattern/Type/Texture.texture = tex
|
||||
var size := _pattern.image.get_size()
|
||||
$FillPattern/XOffset/OffsetX.max_value = size.x - 1
|
||||
$FillPattern/YOffset/OffsetY.max_value = size.y - 1
|
||||
$FillPattern/OffsetX.max_value = size.x - 1
|
||||
$FillPattern/OffsetY.max_value = size.y - 1
|
||||
|
||||
|
||||
func draw_start(position: Vector2) -> void:
|
||||
|
|
|
@ -33,20 +33,15 @@ margin_right = 131.0
|
|||
[node name="Label" parent="." index="1"]
|
||||
margin_right = 131.0
|
||||
|
||||
[node name="FillAreaContainer" type="HBoxContainer" parent="." index="2"]
|
||||
[node name="FillArea" type="Label" parent="." index="2"]
|
||||
margin_top = 26.0
|
||||
margin_right = 131.0
|
||||
margin_bottom = 40.0
|
||||
|
||||
[node name="FillArea" type="Label" parent="FillAreaContainer" index="0"]
|
||||
margin_right = 131.0
|
||||
margin_bottom = 14.0
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Fill area:"
|
||||
|
||||
[node name="FillAreaOptions" type="OptionButton" parent="." index="3"]
|
||||
unique_name_in_owner = true
|
||||
margin_top = 44.0
|
||||
margin_right = 131.0
|
||||
margin_bottom = 64.0
|
||||
|
@ -64,19 +59,14 @@ margin_bottom = 92.0
|
|||
value = 100.0
|
||||
prefix = "Similarity:"
|
||||
|
||||
[node name="FillWithContainer" type="HBoxContainer" parent="." index="5"]
|
||||
[node name="FillWith" type="Label" parent="." index="5"]
|
||||
margin_top = 68.0
|
||||
margin_right = 131.0
|
||||
margin_bottom = 82.0
|
||||
|
||||
[node name="FillWith" type="Label" parent="FillWithContainer" index="0"]
|
||||
margin_right = 131.0
|
||||
margin_bottom = 14.0
|
||||
size_flags_horizontal = 3
|
||||
text = "Fill with:"
|
||||
|
||||
[node name="FillWithOptions" type="OptionButton" parent="." index="6"]
|
||||
unique_name_in_owner = true
|
||||
margin_top = 86.0
|
||||
margin_right = 131.0
|
||||
margin_bottom = 106.0
|
||||
|
@ -90,7 +80,7 @@ selected = 0
|
|||
visible = false
|
||||
margin_top = 110.0
|
||||
margin_right = 131.0
|
||||
margin_bottom = 216.0
|
||||
margin_bottom = 198.0
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Type" type="Button" parent="FillPattern" index="0"]
|
||||
|
@ -112,51 +102,21 @@ margin_bottom = 32.0
|
|||
expand = true
|
||||
stretch_mode = 6
|
||||
|
||||
[node name="Offset" type="Label" parent="FillPattern" index="1"]
|
||||
[node name="OffsetX" parent="FillPattern" index="1" instance=ExtResource( 1 )]
|
||||
margin_top = 36.0
|
||||
margin_right = 131.0
|
||||
margin_bottom = 50.0
|
||||
text = "Offset"
|
||||
margin_bottom = 60.0
|
||||
prefix = "Offset X:"
|
||||
|
||||
[node name="XOffset" type="HBoxContainer" parent="FillPattern" index="2"]
|
||||
margin_top = 54.0
|
||||
[node name="OffsetY" parent="FillPattern" index="2" instance=ExtResource( 1 )]
|
||||
margin_top = 64.0
|
||||
margin_right = 131.0
|
||||
margin_bottom = 78.0
|
||||
|
||||
[node name="Label" type="Label" parent="FillPattern/XOffset" index="0"]
|
||||
margin_top = 5.0
|
||||
margin_right = 8.0
|
||||
margin_bottom = 19.0
|
||||
text = "X"
|
||||
|
||||
[node name="OffsetX" type="SpinBox" parent="FillPattern/XOffset" index="1"]
|
||||
margin_left = 12.0
|
||||
margin_right = 131.0
|
||||
margin_bottom = 24.0
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="YOffset" type="HBoxContainer" parent="FillPattern" index="3"]
|
||||
margin_top = 82.0
|
||||
margin_right = 131.0
|
||||
margin_bottom = 106.0
|
||||
|
||||
[node name="Label" type="Label" parent="FillPattern/YOffset" index="0"]
|
||||
margin_top = 5.0
|
||||
margin_right = 7.0
|
||||
margin_bottom = 19.0
|
||||
text = "Y"
|
||||
|
||||
[node name="OffsetY" type="SpinBox" parent="FillPattern/YOffset" index="1"]
|
||||
margin_left = 11.0
|
||||
margin_right = 131.0
|
||||
margin_bottom = 24.0
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_horizontal = 3
|
||||
margin_bottom = 88.0
|
||||
prefix = "Offset Y:"
|
||||
|
||||
[connection signal="item_selected" from="FillAreaOptions" to="." method="_on_FillAreaOptions_item_selected"]
|
||||
[connection signal="value_changed" from="SimilaritySlider" to="." method="_on_SimilaritySlider_value_changed"]
|
||||
[connection signal="item_selected" from="FillWithOptions" to="." method="_on_FillWithOptions_item_selected"]
|
||||
[connection signal="pressed" from="FillPattern/Type" to="." method="_on_PatternType_pressed"]
|
||||
[connection signal="value_changed" from="FillPattern/XOffset/OffsetX" to="." method="_on_PatternOffsetX_value_changed"]
|
||||
[connection signal="value_changed" from="FillPattern/YOffset/OffsetY" to="." method="_on_PatternOffsetY_value_changed"]
|
||||
[connection signal="value_changed" from="FillPattern/OffsetX" to="." method="_on_PatternOffsetX_value_changed"]
|
||||
[connection signal="value_changed" from="FillPattern/OffsetY" to="." method="_on_PatternOffsetY_value_changed"]
|
||||
|
|
|
@ -19,10 +19,10 @@ var _intersect := false # Shift + Ctrl + Mouse Click
|
|||
var _content_transformation_check := false
|
||||
|
||||
onready var selection_node: Node2D = Global.canvas.selection
|
||||
onready var xspinbox: SpinBox = find_node("XSpinBox")
|
||||
onready var yspinbox: SpinBox = find_node("YSpinBox")
|
||||
onready var wspinbox: SpinBox = find_node("WSpinBox")
|
||||
onready var hspinbox: SpinBox = find_node("HSpinBox")
|
||||
onready var xspinbox: ValueSlider = $XSpinBox
|
||||
onready var yspinbox: ValueSlider = $YSpinBox
|
||||
onready var wspinbox: ValueSlider = $WSpinBox
|
||||
onready var hspinbox: ValueSlider = $HSpinBox
|
||||
onready var timer: Timer = $Timer
|
||||
|
||||
|
||||
|
@ -182,29 +182,23 @@ func _set_cursor_text(rect: Rect2) -> void:
|
|||
cursor_text += " (%s, %s)" % [rect.size.x, rect.size.y]
|
||||
|
||||
|
||||
func _on_XSpinBox_value_changed(value: float) -> void:
|
||||
var project: Project = Global.current_project
|
||||
if !project.has_selection or selection_node.big_bounding_rectangle.position.x == value:
|
||||
func _on_position_value_changed(value: float, horizontal: bool) -> void:
|
||||
if horizontal:
|
||||
if selection_node.big_bounding_rectangle.position.x == value:
|
||||
return
|
||||
else:
|
||||
if selection_node.big_bounding_rectangle.position.y == value:
|
||||
return
|
||||
var project: Project = Global.current_project
|
||||
if !project.has_selection:
|
||||
return
|
||||
|
||||
if timer.is_stopped():
|
||||
undo_data = selection_node.get_undo_data(false)
|
||||
timer.start()
|
||||
if horizontal:
|
||||
selection_node.big_bounding_rectangle.position.x = value
|
||||
|
||||
var selection_map_copy := SelectionMap.new()
|
||||
selection_map_copy.copy_from(project.selection_map)
|
||||
selection_map_copy.move_bitmap_values(project)
|
||||
project.selection_map = selection_map_copy
|
||||
project.selection_map_changed()
|
||||
|
||||
|
||||
func _on_YSpinBox_value_changed(value: float) -> void:
|
||||
var project: Project = Global.current_project
|
||||
if !project.has_selection or selection_node.big_bounding_rectangle.position.y == value:
|
||||
return
|
||||
if timer.is_stopped():
|
||||
undo_data = selection_node.get_undo_data(false)
|
||||
timer.start()
|
||||
else:
|
||||
selection_node.big_bounding_rectangle.position.y = value
|
||||
|
||||
var selection_map_copy := SelectionMap.new()
|
||||
|
@ -214,32 +208,28 @@ func _on_YSpinBox_value_changed(value: float) -> void:
|
|||
project.selection_map_changed()
|
||||
|
||||
|
||||
func _on_WSpinBox_value_changed(value: float) -> void:
|
||||
var project: Project = Global.current_project
|
||||
func _on_size_value_changed(value: float, horizontal: bool) -> void:
|
||||
if horizontal:
|
||||
if (
|
||||
!project.has_selection
|
||||
or selection_node.big_bounding_rectangle.size.x == value
|
||||
selection_node.big_bounding_rectangle.size.x == value
|
||||
or selection_node.big_bounding_rectangle.size.x <= 0
|
||||
):
|
||||
return
|
||||
if timer.is_stopped():
|
||||
undo_data = selection_node.get_undo_data(false)
|
||||
timer.start()
|
||||
selection_node.big_bounding_rectangle.size.x = value
|
||||
resize_selection()
|
||||
|
||||
|
||||
func _on_HSpinBox_value_changed(value: float) -> void:
|
||||
var project: Project = Global.current_project
|
||||
else:
|
||||
if (
|
||||
!project.has_selection
|
||||
or selection_node.big_bounding_rectangle.size.y == value
|
||||
selection_node.big_bounding_rectangle.size.y == value
|
||||
or selection_node.big_bounding_rectangle.size.y <= 0
|
||||
):
|
||||
return
|
||||
if !Global.current_project.has_selection:
|
||||
return
|
||||
|
||||
if timer.is_stopped():
|
||||
undo_data = selection_node.get_undo_data(false)
|
||||
timer.start()
|
||||
if horizontal:
|
||||
selection_node.big_bounding_rectangle.size.x = value
|
||||
else:
|
||||
selection_node.big_bounding_rectangle.size.y = value
|
||||
resize_selection()
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
[gd_scene load_steps=3 format=2]
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://src/Tools/BaseTool.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://src/Tools/SelectionTools/SelectionTool.gd" type="Script" id=2]
|
||||
[ext_resource path="res://src/UI/Nodes/ValueSlider.tscn" type="PackedScene" id=3]
|
||||
|
||||
[node name="ToolOptions" instance=ExtResource( 1 )]
|
||||
script = ExtResource( 2 )
|
||||
|
@ -12,49 +13,23 @@ margin_right = 116.0
|
|||
margin_bottom = 40.0
|
||||
text = "Position:"
|
||||
|
||||
[node name="XContainer" type="HBoxContainer" parent="." index="3"]
|
||||
[node name="XSpinBox" parent="." index="3" instance=ExtResource( 3 )]
|
||||
margin_top = 44.0
|
||||
margin_right = 116.0
|
||||
margin_bottom = 68.0
|
||||
|
||||
[node name="Label" type="Label" parent="XContainer" index="0"]
|
||||
margin_top = 5.0
|
||||
margin_right = 17.0
|
||||
margin_bottom = 19.0
|
||||
rect_min_size = Vector2( 17, 0 )
|
||||
text = "X:"
|
||||
|
||||
[node name="XSpinBox" type="SpinBox" parent="XContainer" index="1"]
|
||||
margin_left = 21.0
|
||||
margin_right = 116.0
|
||||
margin_bottom = 24.0
|
||||
hint_tooltip = "X coordinate of the top left corner"
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_horizontal = 3
|
||||
allow_greater = true
|
||||
allow_lesser = true
|
||||
prefix = "X:"
|
||||
|
||||
[node name="YContainer" type="HBoxContainer" parent="." index="4"]
|
||||
[node name="YSpinBox" parent="." index="4" instance=ExtResource( 3 )]
|
||||
margin_top = 72.0
|
||||
margin_right = 116.0
|
||||
margin_bottom = 96.0
|
||||
|
||||
[node name="Label" type="Label" parent="YContainer" index="0"]
|
||||
margin_top = 5.0
|
||||
margin_right = 17.0
|
||||
margin_bottom = 19.0
|
||||
rect_min_size = Vector2( 17, 0 )
|
||||
text = "Y:"
|
||||
|
||||
[node name="YSpinBox" type="SpinBox" parent="YContainer" index="1"]
|
||||
margin_left = 21.0
|
||||
margin_right = 116.0
|
||||
margin_bottom = 24.0
|
||||
hint_tooltip = "Y coordinate of the top left corner"
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_horizontal = 3
|
||||
allow_greater = true
|
||||
allow_lesser = true
|
||||
prefix = "Y:"
|
||||
|
||||
[node name="SizeLabel" type="Label" parent="." index="5"]
|
||||
margin_top = 100.0
|
||||
|
@ -62,58 +37,32 @@ margin_right = 116.0
|
|||
margin_bottom = 114.0
|
||||
text = "Size:"
|
||||
|
||||
[node name="WidthContainer" type="HBoxContainer" parent="." index="6"]
|
||||
[node name="WSpinBox" parent="." index="6" instance=ExtResource( 3 )]
|
||||
margin_top = 118.0
|
||||
margin_right = 116.0
|
||||
margin_bottom = 142.0
|
||||
|
||||
[node name="Label" type="Label" parent="WidthContainer" index="0"]
|
||||
margin_top = 5.0
|
||||
margin_right = 17.0
|
||||
margin_bottom = 19.0
|
||||
rect_min_size = Vector2( 17, 0 )
|
||||
text = "W:"
|
||||
|
||||
[node name="WSpinBox" type="SpinBox" parent="WidthContainer" index="1"]
|
||||
margin_left = 21.0
|
||||
margin_right = 116.0
|
||||
margin_bottom = 24.0
|
||||
hint_tooltip = "Width of selection"
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_horizontal = 3
|
||||
min_value = 1.0
|
||||
value = 1.0
|
||||
allow_greater = true
|
||||
prefix = "W:"
|
||||
|
||||
[node name="HeightContainer" type="HBoxContainer" parent="." index="7"]
|
||||
[node name="HSpinBox" parent="." index="7" instance=ExtResource( 3 )]
|
||||
margin_top = 146.0
|
||||
margin_right = 116.0
|
||||
margin_bottom = 170.0
|
||||
|
||||
[node name="Label" type="Label" parent="HeightContainer" index="0"]
|
||||
margin_top = 5.0
|
||||
margin_right = 17.0
|
||||
margin_bottom = 19.0
|
||||
rect_min_size = Vector2( 17, 0 )
|
||||
text = "H:"
|
||||
|
||||
[node name="HSpinBox" type="SpinBox" parent="HeightContainer" index="1"]
|
||||
margin_left = 21.0
|
||||
margin_right = 116.0
|
||||
margin_bottom = 24.0
|
||||
hint_tooltip = "Height of selection"
|
||||
mouse_default_cursor_shape = 2
|
||||
size_flags_horizontal = 3
|
||||
min_value = 1.0
|
||||
value = 1.0
|
||||
allow_greater = true
|
||||
prefix = "H:"
|
||||
|
||||
[node name="Timer" type="Timer" parent="." index="8"]
|
||||
wait_time = 0.2
|
||||
one_shot = true
|
||||
|
||||
[connection signal="value_changed" from="XContainer/XSpinBox" to="." method="_on_XSpinBox_value_changed"]
|
||||
[connection signal="value_changed" from="YContainer/YSpinBox" to="." method="_on_YSpinBox_value_changed"]
|
||||
[connection signal="value_changed" from="WidthContainer/WSpinBox" to="." method="_on_WSpinBox_value_changed"]
|
||||
[connection signal="value_changed" from="HeightContainer/HSpinBox" to="." method="_on_HSpinBox_value_changed"]
|
||||
[connection signal="value_changed" from="XSpinBox" to="." method="_on_position_value_changed" binds= [ true ]]
|
||||
[connection signal="value_changed" from="YSpinBox" to="." method="_on_position_value_changed" binds= [ false ]]
|
||||
[connection signal="value_changed" from="WSpinBox" to="." method="_on_size_value_changed" binds= [ true ]]
|
||||
[connection signal="value_changed" from="HSpinBox" to="." method="_on_size_value_changed" binds= [ false ]]
|
||||
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
|
||||
|
|
|
@ -584,7 +584,7 @@ func commit_undo(action: String, undo_data_tmp: Dictionary) -> void:
|
|||
if !undo_data_tmp:
|
||||
print("No undo data found!")
|
||||
return
|
||||
var redo_data = get_undo_data(undo_data_tmp["undo_image"])
|
||||
var redo_data := get_undo_data(undo_data_tmp["undo_image"])
|
||||
var project: Project = Global.current_project
|
||||
|
||||
project.undos += 1
|
||||
|
|
Loading…
Reference in a new issue