From 3d65e48c92269f38f5841a416033e072566631fd Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Thu, 21 Nov 2024 12:48:52 +0200 Subject: [PATCH] Add backend for diagonal mirror buttons The buttons are not yet visible --- assets/graphics/misc/x_minus_y_mirror_off.png | Bin 0 -> 218 bytes .../misc/x_minus_y_mirror_off.png.import | 34 ++++++ assets/graphics/misc/x_minus_y_mirror_on.png | Bin 0 -> 187 bytes .../misc/x_minus_y_mirror_on.png.import | 34 ++++++ assets/graphics/misc/xy_mirror_off.png | Bin 0 -> 183 bytes assets/graphics/misc/xy_mirror_off.png.import | 34 ++++++ assets/graphics/misc/xy_mirror_on.png | Bin 0 -> 185 bytes assets/graphics/misc/xy_mirror_on.png.import | 34 ++++++ src/Autoload/Global.gd | 2 +- src/Autoload/Tools.gd | 16 +-- src/Classes/Drawers.gd | 4 +- src/UI/Canvas/Rulers/Guide.gd | 2 +- src/UI/GlobalToolOptions/GlobalToolOptions.gd | 54 +++++++-- .../GlobalToolOptions/GlobalToolOptions.tscn | 108 +++++++++++++++++- src/UI/TopMenuContainer/TopMenuContainer.gd | 2 +- 15 files changed, 300 insertions(+), 24 deletions(-) create mode 100644 assets/graphics/misc/x_minus_y_mirror_off.png create mode 100644 assets/graphics/misc/x_minus_y_mirror_off.png.import create mode 100644 assets/graphics/misc/x_minus_y_mirror_on.png create mode 100644 assets/graphics/misc/x_minus_y_mirror_on.png.import create mode 100644 assets/graphics/misc/xy_mirror_off.png create mode 100644 assets/graphics/misc/xy_mirror_off.png.import create mode 100644 assets/graphics/misc/xy_mirror_on.png create mode 100644 assets/graphics/misc/xy_mirror_on.png.import diff --git a/assets/graphics/misc/x_minus_y_mirror_off.png b/assets/graphics/misc/x_minus_y_mirror_off.png new file mode 100644 index 0000000000000000000000000000000000000000..3d76d8f8705af81aa6a19d7236a3b948ff1f12a3 GIT binary patch literal 218 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VV{wqX6T`Z5GB1IgDV{ElAr`$$ zCp!uqP~cz|UjF~Tk?lpR4lk4KS$Fk3GSk=?R5%&_)yz`Yvxqpk_6S4qf|-%CbG6cH zL*Is&H#075zxwZN0>g!4*Z(`u{L8hCWmVd|#2lNC0jyzWYYurilyWUo{ciB|edN6& zw%fe*TsDTEc~svgT+&^g7Ws4S{g8x6k4b;U^AhH*Z{KbpUj3+Pmc}P0&L<7rr=)b* Qf$n4QboFyt=akR{0BHVD_y7O^ literal 0 HcmV?d00001 diff --git a/assets/graphics/misc/x_minus_y_mirror_off.png.import b/assets/graphics/misc/x_minus_y_mirror_off.png.import new file mode 100644 index 000000000..231b1e836 --- /dev/null +++ b/assets/graphics/misc/x_minus_y_mirror_off.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://1kj5gcswa3t2" +path="res://.godot/imported/x_minus_y_mirror_off.png-da237e3b5b7ad1dfef1c935385f53dc5.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/graphics/misc/x_minus_y_mirror_off.png" +dest_files=["res://.godot/imported/x_minus_y_mirror_off.png-da237e3b5b7ad1dfef1c935385f53dc5.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/graphics/misc/x_minus_y_mirror_on.png b/assets/graphics/misc/x_minus_y_mirror_on.png new file mode 100644 index 0000000000000000000000000000000000000000..7532906e618b6ad6cc4f5d2f70b63b8d4894d0f5 GIT binary patch literal 187 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VV{wqX6T`Z5GB1IgQcoAh5R2ZU zQ@!~PC~&x>d%Ukt-L+|9SkliWwbmvFE01V|hB7v&FeY4)^!OB^nBEB$)dV*R&%imvtFphHvZRvUS4+n@MQ jvMNS@zpl}l_~V>WyguxAdNTZh4q)(f^>bP0l+XkKgTzCH literal 0 HcmV?d00001 diff --git a/assets/graphics/misc/x_minus_y_mirror_on.png.import b/assets/graphics/misc/x_minus_y_mirror_on.png.import new file mode 100644 index 000000000..aa0b81718 --- /dev/null +++ b/assets/graphics/misc/x_minus_y_mirror_on.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dn14bkxwdqsfk" +path="res://.godot/imported/x_minus_y_mirror_on.png-0e9186904d8241facc4a0c1190f32c53.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/graphics/misc/x_minus_y_mirror_on.png" +dest_files=["res://.godot/imported/x_minus_y_mirror_on.png-0e9186904d8241facc4a0c1190f32c53.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/graphics/misc/xy_mirror_off.png b/assets/graphics/misc/xy_mirror_off.png new file mode 100644 index 0000000000000000000000000000000000000000..c86917a91eee24ac3108944eb062d19e16bddf16 GIT binary patch literal 183 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VV{wqX6T`Z5GB1IgLQfaR5R2Zm zS5NaEFyLSg5H9^c^{%&l)+Dutj|~3L7$g`bs7x|6{w={()*jBVAT;5??GUDFAEtB( z&t(TBr{(Q9bm##ecca`H-YP?JiG$k`M53D{--w?{3Jy5P7I3sJ?UiPA+0IRo+Oon2 eE+)USwqSe~o53|_(yI!f3QqJ?{3tU}Y7*sk}y_#jnxUXF| void: elif type == Types.VERTICAL: visible = Global.show_y_symmetry_axis and Global.show_guides elif type == Types.XY: - visible = Global.show_x_y_symmetry_axis and Global.show_guides + visible = Global.show_xy_symmetry_axis and Global.show_guides elif type == Types.X_MINUS_Y: visible = Global.show_x_minus_y_symmetry_axis and Global.show_guides else: diff --git a/src/UI/GlobalToolOptions/GlobalToolOptions.gd b/src/UI/GlobalToolOptions/GlobalToolOptions.gd index 8a1a1415b..275cecad6 100644 --- a/src/UI/GlobalToolOptions/GlobalToolOptions.gd +++ b/src/UI/GlobalToolOptions/GlobalToolOptions.gd @@ -3,6 +3,8 @@ extends PanelContainer @onready var grid_container: GridContainer = find_child("GridContainer") @onready var horizontal_mirror: BaseButton = grid_container.get_node("Horizontal") @onready var vertical_mirror: BaseButton = grid_container.get_node("Vertical") +@onready var diagonal_xy_mirror: BaseButton = grid_container.get_node("DiagonalXY") +@onready var diagonal_x_minus_y_mirror: BaseButton = grid_container.get_node("DiagonalXMinusY") @onready var pixel_perfect: BaseButton = grid_container.get_node("PixelPerfect") @onready var alpha_lock: BaseButton = grid_container.get_node("AlphaLock") @onready var dynamics: Button = $"%Dynamics" @@ -39,25 +41,25 @@ func _on_resized() -> void: grid_container.columns = column_n -func _on_Horizontal_toggled(button_pressed: bool) -> void: - Tools.horizontal_mirror = button_pressed - Global.config_cache.set_value("tools", "horizontal_mirror", button_pressed) - Global.show_y_symmetry_axis = button_pressed +func _on_Horizontal_toggled(toggled_on: bool) -> void: + Tools.horizontal_mirror = toggled_on + Global.config_cache.set_value("tools", "horizontal_mirror", toggled_on) + Global.show_y_symmetry_axis = toggled_on Global.current_project.y_symmetry_axis.visible = ( Global.show_y_symmetry_axis and Global.show_guides ) var texture_button: TextureRect = horizontal_mirror.get_node("TextureRect") var file_name := "horizontal_mirror_on.png" - if !button_pressed: + if not toggled_on: file_name = "horizontal_mirror_off.png" Global.change_button_texturerect(texture_button, file_name) -func _on_Vertical_toggled(button_pressed: bool) -> void: - Tools.vertical_mirror = button_pressed - Global.config_cache.set_value("tools", "vertical_mirror", button_pressed) - Global.show_x_symmetry_axis = button_pressed +func _on_Vertical_toggled(toggled_on: bool) -> void: + Tools.vertical_mirror = toggled_on + Global.config_cache.set_value("tools", "vertical_mirror", toggled_on) + Global.show_x_symmetry_axis = toggled_on # If the button is not pressed but another button is, keep the symmetry guide visible Global.current_project.x_symmetry_axis.visible = ( Global.show_x_symmetry_axis and Global.show_guides @@ -65,11 +67,43 @@ func _on_Vertical_toggled(button_pressed: bool) -> void: var texture_button: TextureRect = vertical_mirror.get_node("TextureRect") var file_name := "vertical_mirror_on.png" - if !button_pressed: + if not toggled_on: file_name = "vertical_mirror_off.png" Global.change_button_texturerect(texture_button, file_name) +func _on_diagonal_xy_toggled(toggled_on: bool) -> void: + Tools.diagonal_xy_mirror = toggled_on + Global.config_cache.set_value("tools", "diagonal_xy_mirror", toggled_on) + Global.show_xy_symmetry_axis = toggled_on + # If the button is not pressed but another button is, keep the symmetry guide visible + Global.current_project.diagonal_xy_symmetry_axis.visible = ( + Global.show_xy_symmetry_axis and Global.show_guides + ) + + var texture_button: TextureRect = diagonal_xy_mirror.get_node("TextureRect") + var file_name := "xy_mirror_on.png" + if not toggled_on: + file_name = "xy_mirror_off.png" + Global.change_button_texturerect(texture_button, file_name) + + +func _on_diagonal_x_minus_y_toggled(toggled_on: bool) -> void: + Tools.diagonal_x_minus_y_mirror = toggled_on + Global.config_cache.set_value("tools", "diagonal_x_minus_y_mirror", toggled_on) + Global.show_x_minus_y_symmetry_axis = toggled_on + # If the button is not pressed but another button is, keep the symmetry guide visible + Global.current_project.diagonal_x_minus_y_symmetry_axis.visible = ( + Global.show_x_minus_y_symmetry_axis and Global.show_guides + ) + + var texture_button: TextureRect = diagonal_x_minus_y_mirror.get_node("TextureRect") + var file_name := "x_minus_y_mirror_on.png" + if not toggled_on: + file_name = "x_minus_y_mirror_off.png" + Global.change_button_texturerect(texture_button, file_name) + + func _on_PixelPerfect_toggled(button_pressed: bool) -> void: Tools.pixel_perfect = button_pressed Global.config_cache.set_value("tools", "pixel_perfect", button_pressed) diff --git a/src/UI/GlobalToolOptions/GlobalToolOptions.tscn b/src/UI/GlobalToolOptions/GlobalToolOptions.tscn index 012f227e5..71890881e 100644 --- a/src/UI/GlobalToolOptions/GlobalToolOptions.tscn +++ b/src/UI/GlobalToolOptions/GlobalToolOptions.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=25 format=3 uid="uid://wo0hqxkst808"] +[gd_scene load_steps=27 format=3 uid="uid://wo0hqxkst808"] [ext_resource type="Texture2D" uid="uid://cjrokejjsp5dm" path="res://assets/graphics/misc/horizontal_mirror_off.png" id="1"] [ext_resource type="Texture2D" uid="uid://hiduvaa73fr6" path="res://assets/graphics/misc/vertical_mirror_off.png" id="2"] @@ -6,8 +6,10 @@ [ext_resource type="Texture2D" uid="uid://ct8wn8m6x4m54" path="res://assets/graphics/misc/value_arrow.svg" id="3_faalk"] [ext_resource type="Texture2D" uid="uid://22h12g8p3jtd" path="res://assets/graphics/misc/pixel_perfect_off.png" id="4"] [ext_resource type="Script" path="res://src/UI/Nodes/ValueSlider.gd" id="5"] +[ext_resource type="Texture2D" uid="uid://dlxhm0ronna25" path="res://assets/graphics/misc/xy_mirror_off.png" id="5_hcmgx"] [ext_resource type="Texture2D" uid="uid://j8eywwy082a4" path="res://assets/graphics/misc/alpha_lock_off.png" id="5_jv20x"] [ext_resource type="Texture2D" uid="uid://dg3dumyfj1682" path="res://assets/graphics/misc/dynamics.png" id="6"] +[ext_resource type="Texture2D" uid="uid://1kj5gcswa3t2" path="res://assets/graphics/misc/x_minus_y_mirror_off.png" id="6_sw8fy"] [ext_resource type="Texture2D" uid="uid://di8au2u87jgv5" path="res://assets/graphics/misc/uncheck.png" id="7"] [ext_resource type="Script" path="res://src/UI/GlobalToolOptions/DynamicsPanel.gd" id="7_iqcw1"] [ext_resource type="PackedScene" uid="uid://bmsc0s03pwji4" path="res://src/UI/Nodes/MaxMinEdit.tscn" id="8"] @@ -179,6 +181,108 @@ grow_vertical = 2 texture = ExtResource("3_faalk") stretch_mode = 3 +[node name="DiagonalXY" type="Button" parent="ScrollContainer/CenterContainer/GridContainer" groups=["UIButtons"]] +visible = false +custom_minimum_size = Vector2(46, 32) +layout_mode = 2 +tooltip_text = "Enable vertical mirrored drawing" +mouse_default_cursor_shape = 2 +toggle_mode = true +shortcut = SubResource("Shortcut_ai7qc") + +[node name="TextureRect" type="TextureRect" parent="ScrollContainer/CenterContainer/GridContainer/DiagonalXY"] +layout_mode = 1 +anchors_preset = 4 +anchor_top = 0.5 +anchor_bottom = 0.5 +offset_left = 5.0 +offset_top = -10.0 +offset_right = 25.0 +offset_bottom = 10.0 +grow_vertical = 2 +texture = ExtResource("5_hcmgx") + +[node name="MirrorOptions" type="MenuButton" parent="ScrollContainer/CenterContainer/GridContainer/DiagonalXY"] +visible = false +custom_minimum_size = Vector2(20, 0) +layout_mode = 1 +anchors_preset = 6 +anchor_left = 1.0 +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 0.5 +offset_left = -20.0 +offset_top = -10.0 +offset_bottom = 10.0 +grow_horizontal = 0 +grow_vertical = 2 +mouse_default_cursor_shape = 2 +item_count = 2 +popup/item_0/text = "Move to canvas center" +popup/item_1/text = "Move to view center" +popup/item_1/id = 1 + +[node name="TextureRect" type="TextureRect" parent="ScrollContainer/CenterContainer/GridContainer/DiagonalXY/MirrorOptions"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("3_faalk") +stretch_mode = 3 + +[node name="DiagonalXMinusY" type="Button" parent="ScrollContainer/CenterContainer/GridContainer" groups=["UIButtons"]] +visible = false +custom_minimum_size = Vector2(46, 32) +layout_mode = 2 +tooltip_text = "Enable vertical mirrored drawing" +mouse_default_cursor_shape = 2 +toggle_mode = true +shortcut = SubResource("Shortcut_ai7qc") + +[node name="TextureRect" type="TextureRect" parent="ScrollContainer/CenterContainer/GridContainer/DiagonalXMinusY"] +layout_mode = 1 +anchors_preset = 4 +anchor_top = 0.5 +anchor_bottom = 0.5 +offset_left = 5.0 +offset_top = -10.0 +offset_right = 25.0 +offset_bottom = 10.0 +grow_vertical = 2 +texture = ExtResource("6_sw8fy") + +[node name="MirrorOptions" type="MenuButton" parent="ScrollContainer/CenterContainer/GridContainer/DiagonalXMinusY"] +visible = false +custom_minimum_size = Vector2(20, 0) +layout_mode = 1 +anchors_preset = 6 +anchor_left = 1.0 +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 0.5 +offset_left = -20.0 +offset_top = -10.0 +offset_bottom = 10.0 +grow_horizontal = 0 +grow_vertical = 2 +mouse_default_cursor_shape = 2 +item_count = 2 +popup/item_0/text = "Move to canvas center" +popup/item_1/text = "Move to view center" +popup/item_1/id = 1 + +[node name="TextureRect" type="TextureRect" parent="ScrollContainer/CenterContainer/GridContainer/DiagonalXMinusY/MirrorOptions"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("3_faalk") +stretch_mode = 3 + [node name="PixelPerfect" type="Button" parent="ScrollContainer/CenterContainer/GridContainer" groups=["UIButtons"]] custom_minimum_size = Vector2(32, 32) layout_mode = 2 @@ -546,6 +650,8 @@ offset_bottom = 23.0 [connection signal="resized" from="." to="." method="_on_resized"] [connection signal="toggled" from="ScrollContainer/CenterContainer/GridContainer/Horizontal" to="." method="_on_Horizontal_toggled"] [connection signal="toggled" from="ScrollContainer/CenterContainer/GridContainer/Vertical" to="." method="_on_Vertical_toggled"] +[connection signal="toggled" from="ScrollContainer/CenterContainer/GridContainer/DiagonalXY" to="." method="_on_diagonal_xy_toggled"] +[connection signal="toggled" from="ScrollContainer/CenterContainer/GridContainer/DiagonalXMinusY" to="." method="_on_diagonal_x_minus_y_toggled"] [connection signal="toggled" from="ScrollContainer/CenterContainer/GridContainer/PixelPerfect" to="." method="_on_PixelPerfect_toggled"] [connection signal="toggled" from="ScrollContainer/CenterContainer/GridContainer/AlphaLock" to="." method="_on_alpha_lock_toggled"] [connection signal="pressed" from="ScrollContainer/CenterContainer/GridContainer/Dynamics" to="." method="_on_Dynamics_pressed"] diff --git a/src/UI/TopMenuContainer/TopMenuContainer.gd b/src/UI/TopMenuContainer/TopMenuContainer.gd index 3858450e7..4814ed57c 100644 --- a/src/UI/TopMenuContainer/TopMenuContainer.gd +++ b/src/UI/TopMenuContainer/TopMenuContainer.gd @@ -838,7 +838,7 @@ func _toggle_show_guides() -> void: elif guide.type == Guide.Types.VERTICAL: guide.visible = Global.show_y_symmetry_axis and Global.show_guides elif guide.type == Guide.Types.XY: - guide.visible = Global.show_x_y_symmetry_axis and Global.show_guides + guide.visible = Global.show_xy_symmetry_axis and Global.show_guides elif guide.type == Guide.Types.X_MINUS_Y: guide.visible = Global.show_x_minus_y_symmetry_axis and Global.show_guides