Skip to content

Commit

Permalink
improved rotate/flip brush UI (#1105)
Browse files Browse the repository at this point in the history
* Update BaseDraw.tscn

* Update BaseDraw.gd

* Implemented proposed changed, Also added a VFlowContainer for Rotate options
  • Loading branch information
Variable-ind authored Oct 14, 2024
1 parent fe5ced8 commit 4561c1f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 28 deletions.
10 changes: 5 additions & 5 deletions src/Tools/BaseDraw.gd
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ func set_config(config: Dictionary) -> void:
func update_config() -> void:
$Brush/BrushSize.value = _brush_size
$ColorInterpolation.value = _brush_interpolate
$RotationOptions/Flip/FlipX.button_pressed = _brush_flip_x
$RotationOptions/Flip/FlipY.button_pressed = _brush_flip_y
$RotationOptions/Rotate/Rotate90.button_pressed = _brush_rotate_90
$RotationOptions/Rotate/Rotate180.button_pressed = _brush_rotate_180
$RotationOptions/Rotate/Rotate270.button_pressed = _brush_rotate_270
%FlipX.button_pressed = _brush_flip_x
%FlipY.button_pressed = _brush_flip_y
%Rotate90.button_pressed = _brush_rotate_90
%Rotate180.button_pressed = _brush_rotate_180
%Rotate270.button_pressed = _brush_rotate_270
update_brush()


Expand Down
65 changes: 42 additions & 23 deletions src/Tools/BaseDraw.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
resource_name = "rotate"
allow_unpress = true

[sub_resource type="StyleBoxFlat" id="1"]
[sub_resource type="StyleBoxFlat" id="2"]
bg_color = Color(1, 1, 1, 1)
border_color = Color(1, 1, 1, 1)
corner_radius_top_left = 5
Expand All @@ -18,7 +18,7 @@ corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
anti_aliasing = false

[sub_resource type="StyleBoxFlat" id="2"]
[sub_resource type="StyleBoxFlat" id="1"]
bg_color = Color(1, 1, 1, 1)
border_color = Color(1, 1, 1, 1)
corner_radius_top_left = 5
Expand All @@ -38,44 +38,63 @@ script = ExtResource("3_76bek")
text = "Rotation options"
flat = true

[node name="Flip" type="HBoxContainer" parent="RotationOptions" index="1"]
[node name="GridContainer" type="GridContainer" parent="RotationOptions" index="1"]
visible = false
layout_mode = 2
columns = 2

[node name="FlipX" type="CheckBox" parent="RotationOptions/Flip" index="0"]
[node name="FlipLabel" type="Label" parent="RotationOptions/GridContainer" index="0"]
layout_mode = 2
text = "Flip:"

[node name="Flip" type="HBoxContainer" parent="RotationOptions/GridContainer" index="1"]
layout_mode = 2
size_flags_horizontal = 3

[node name="FlipX" type="CheckBox" parent="RotationOptions/GridContainer/Flip" index="0"]
unique_name_in_owner = true
layout_mode = 2
mouse_default_cursor_shape = 2
text = "Flip X"
text = "X"

[node name="FlipY" type="CheckBox" parent="RotationOptions/Flip" index="1"]
[node name="FlipY" type="CheckBox" parent="RotationOptions/GridContainer/Flip" index="1"]
unique_name_in_owner = true
layout_mode = 2
mouse_default_cursor_shape = 2
text = "Flip Y"
text = "Y"

[node name="Rotate" type="HBoxContainer" parent="RotationOptions" index="2"]
visible = false
[node name="RotateLabel" type="Label" parent="RotationOptions/GridContainer" index="2"]
layout_mode = 2
size_flags_vertical = 0
text = "Rotate:"

[node name="Rotate90" type="CheckBox" parent="RotationOptions/Rotate" index="0"]
[node name="Rotate" type="HFlowContainer" parent="RotationOptions/GridContainer" index="3"]
layout_mode = 2
size_flags_horizontal = 3

[node name="Rotate90" type="CheckBox" parent="RotationOptions/GridContainer/Rotate" index="0"]
unique_name_in_owner = true
layout_mode = 2
tooltip_text = "rotate the brush 90 degrees"
mouse_default_cursor_shape = 2
button_group = SubResource("ButtonGroup_7u3x0")
text = "R 90"
text = "90°"

[node name="Rotate180" type="CheckBox" parent="RotationOptions/Rotate" index="1"]
[node name="Rotate180" type="CheckBox" parent="RotationOptions/GridContainer/Rotate" index="1"]
unique_name_in_owner = true
layout_mode = 2
tooltip_text = "rotate the brush 180 degrees"
mouse_default_cursor_shape = 2
button_group = SubResource("ButtonGroup_7u3x0")
text = "R 180"
text = "180°"

[node name="Rotate270" type="CheckBox" parent="RotationOptions/Rotate" index="2"]
[node name="Rotate270" type="CheckBox" parent="RotationOptions/GridContainer/Rotate" index="2"]
unique_name_in_owner = true
layout_mode = 2
tooltip_text = "rotate the brush 270 degrees"
mouse_default_cursor_shape = 2
button_group = SubResource("ButtonGroup_7u3x0")
text = "R 270"
text = "270°"

[node name="Brush" type="HBoxContainer" parent="." index="3"]
layout_mode = 2
Expand All @@ -87,11 +106,11 @@ layout_mode = 2
size_flags_horizontal = 0
tooltip_text = "Select a brush"
mouse_default_cursor_shape = 2
theme_override_styles/normal = SubResource("1")
theme_override_styles/focus = SubResource("2")
theme_override_styles/disabled = SubResource("2")
theme_override_styles/hover = SubResource("1")
theme_override_styles/pressed = SubResource("1")
theme_override_styles/disabled = SubResource("2")
theme_override_styles/focus = SubResource("2")
theme_override_styles/normal = SubResource("1")

[node name="Texture" type="TextureRect" parent="Brush/Type" index="0"]
layout_mode = 0
Expand All @@ -117,11 +136,11 @@ layout_mode = 2
tooltip_text = "0: Color from the brush itself, 100: the currently selected color"
prefix = "Brush color from:"

[connection signal="toggled" from="RotationOptions/Flip/FlipX" to="." method="_on_flip_x_toggled"]
[connection signal="toggled" from="RotationOptions/Flip/FlipY" to="." method="_on_flip_y_toggled"]
[connection signal="toggled" from="RotationOptions/Rotate/Rotate90" to="." method="_on_rotate_90_toggled"]
[connection signal="toggled" from="RotationOptions/Rotate/Rotate180" to="." method="_on_rotate_180_toggled"]
[connection signal="toggled" from="RotationOptions/Rotate/Rotate270" to="." method="_on_rotate_270_toggled"]
[connection signal="toggled" from="RotationOptions/GridContainer/Flip/FlipX" to="." method="_on_flip_x_toggled"]
[connection signal="toggled" from="RotationOptions/GridContainer/Flip/FlipY" to="." method="_on_flip_y_toggled"]
[connection signal="toggled" from="RotationOptions/GridContainer/Rotate/Rotate90" to="." method="_on_rotate_90_toggled"]
[connection signal="toggled" from="RotationOptions/GridContainer/Rotate/Rotate180" to="." method="_on_rotate_180_toggled"]
[connection signal="toggled" from="RotationOptions/GridContainer/Rotate/Rotate270" to="." method="_on_rotate_270_toggled"]
[connection signal="pressed" from="Brush/Type" to="." method="_on_BrushType_pressed"]
[connection signal="value_changed" from="Brush/BrushSize" to="." method="_on_BrushSize_value_changed"]
[connection signal="value_changed" from="ColorInterpolation" to="." method="_on_InterpolateFactor_value_changed"]

0 comments on commit 4561c1f

Please sign in to comment.