diff --git a/CHANGELOG.md b/CHANGELOG.md index 7356e399f..5f34d1933 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ Darshan Phaldesai (luiq54), Igor Santarek (jegor377), rob-a-bolton, Kinwailo - You can now preview how the frames of the spritesheet you are importing will look. - You can now import image files as layers. Their size will be cropped to the project's size. - You can import image files as brushes, patterns and palettes. +- Buttons have been added in Preferences to restore each setting to its default state. - Added "Copy", "Paste" and "Delete" options in the Edit menu. ([#281](https://github.com/Orama-Interactive/Pixelorama/pull/281)) - Selection region and size are now being shown when making a selection on the top, next to the position label. ([#281](https://github.com/Orama-Interactive/Pixelorama/pull/281)) - Added color overwrite option for the Pencil tool. ([#282](https://github.com/Orama-Interactive/Pixelorama/pull/282)) @@ -39,6 +40,7 @@ Darshan Phaldesai (luiq54), Igor Santarek (jegor377), rob-a-bolton, Kinwailo - Pixelorama now remembers the selected colors, tools and their options when it's closed and re-opened. ([#281](https://github.com/Orama-Interactive/Pixelorama/pull/281)) - Drawing brushes with mirror also mirrors the images of the brushes themselves. ([#281](https://github.com/Orama-Interactive/Pixelorama/pull/281)) - When making a new palette or importing one and its name already exists, Pixelorama will add a number to its name. For example, "Palette_Name" would become "Palette_Name (2)", "Palette_Name (3)", etc. +- Re-organized preferences dialog. - The "create new image" dialog now remembers the last created canvas size. The default image settings are being used only when Pixelorama first launches. ([#178](https://github.com/Orama-Interactive/Pixelorama/issues/178)) - Language and theme checkboxes are now radio buttons. - The Blue theme has more similar margins and seperations with the rest of the themes. diff --git a/Translations/Translations.pot b/Translations/Translations.pot index 08cd1617a..3abe16df6 100644 --- a/Translations/Translations.pot +++ b/Translations/Translations.pot @@ -359,6 +359,9 @@ msgstr "" msgid "On" msgstr "" +msgid "Restore default value" +msgstr "" + msgid "Smooth Zoom" msgstr "" diff --git a/assets/graphics/dark_themes/misc/icon_reload.png b/assets/graphics/dark_themes/misc/icon_reload.png new file mode 100644 index 000000000..bec5f3f4f Binary files /dev/null and b/assets/graphics/dark_themes/misc/icon_reload.png differ diff --git a/assets/graphics/dark_themes/misc/icon_reload.png.import b/assets/graphics/dark_themes/misc/icon_reload.png.import new file mode 100644 index 000000000..3b8414286 --- /dev/null +++ b/assets/graphics/dark_themes/misc/icon_reload.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/icon_reload.png-8fcd39d06a036f444930d60868611210.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/graphics/dark_themes/misc/icon_reload.png" +dest_files=[ "res://.import/icon_reload.png-8fcd39d06a036f444930d60868611210.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/src/Autoload/Global.gd b/src/Autoload/Global.gd index bf6f4af08..f81a02500 100644 --- a/src/Autoload/Global.gd +++ b/src/Autoload/Global.gd @@ -59,7 +59,7 @@ var checker_size := 10 var checker_color_1 := Color(0.47, 0.47, 0.47, 1) var checker_color_2 := Color(0.34, 0.35, 0.34, 1) -var autosave_interval := 5.0 +var autosave_interval := 1.0 var enable_autosave := true # Tools & options diff --git a/src/Preferences/PreferencesDialog.gd b/src/Preferences/PreferencesDialog.gd index 57a1772d0..0ab70d109 100644 --- a/src/Preferences/PreferencesDialog.gd +++ b/src/Preferences/PreferencesDialog.gd @@ -1,28 +1,28 @@ extends AcceptDialog -# Preferences table: [Prop name in Global, relative node path, value type] +# Preferences table: [Prop name in Global, relative node path, value type, default value] var preferences = [ - ["open_last_project", "Startup/StartupContainer/OpenLastProject", "pressed"], - ["smooth_zoom", "Canvas/SmoothZoom", "pressed"], - ["pressure_sensitivity_mode", "Startup/PressureSentivity/PressureSensitivityOptionButton", "selected"], - ["show_left_tool_icon", "Indicators/IndicatorsContainer/LeftToolIconCheckbox", "pressed"], - ["show_right_tool_icon", "Indicators/IndicatorsContainer/RightToolIconCheckbox", "pressed"], - ["left_square_indicator_visible", "Indicators/IndicatorsContainer/LeftIndicatorCheckbox", "pressed"], - ["right_square_indicator_visible", "Indicators/IndicatorsContainer/RightIndicatorCheckbox", "pressed"], - ["autosave_interval", "Backup/AutosaveContainer/AutosaveInterval", "value"], - ["enable_autosave", "Backup/AutosaveContainer/EnableAutosave", "pressed"], + ["open_last_project", "Startup/StartupContainer/OpenLastProject", "pressed", Global.open_last_project], + ["smooth_zoom", "Canvas/ZoomOptions/SmoothZoom", "pressed", Global.smooth_zoom], + ["pressure_sensitivity_mode", "Startup/PressureSentivity/PressureSensitivityOptionButton", "selected", Global.pressure_sensitivity_mode], + ["show_left_tool_icon", "Indicators/IndicatorsContainer/LeftToolIconCheckbox", "pressed", Global.show_left_tool_icon], + ["show_right_tool_icon", "Indicators/IndicatorsContainer/RightToolIconCheckbox", "pressed", Global.show_right_tool_icon], + ["left_square_indicator_visible", "Indicators/IndicatorsContainer/LeftIndicatorCheckbox", "pressed", Global.left_square_indicator_visible], + ["right_square_indicator_visible", "Indicators/IndicatorsContainer/RightIndicatorCheckbox", "pressed", Global.right_square_indicator_visible], + ["autosave_interval", "Backup/AutosaveContainer/AutosaveInterval", "value", Global.autosave_interval], + ["enable_autosave", "Backup/AutosaveContainer/EnableAutosave", "pressed", Global.enable_autosave], - ["default_image_width", "Image/ImageOptions/ImageDefaultWidth", "value"], - ["default_image_height", "Image/ImageOptions/ImageDefaultHeight", "value"], - ["default_fill_color", "Image/ImageOptions/DefaultFillColor", "color"], + ["default_image_width", "Image/ImageOptions/ImageDefaultWidth", "value", Global.default_image_width], + ["default_image_height", "Image/ImageOptions/ImageDefaultHeight", "value", Global.default_image_height], + ["default_fill_color", "Image/ImageOptions/DefaultFillColor", "color", Global.default_fill_color], - ["grid_width", "Canvas/GridOptions/GridWidthValue", "value"], - ["grid_height", "Canvas/GridOptions/GridHeightValue", "value"], - ["grid_color", "Canvas/GridOptions/GridColor", "color"], - ["guide_color", "Canvas/GuideOptions/GuideColor", "color"], - ["checker_size", "Canvas/CheckerOptions/CheckerSizeValue", "value"], - ["checker_color_1", "Canvas/CheckerOptions/CheckerColor1", "color"], - ["checker_color_2", "Canvas/CheckerOptions/CheckerColor2", "color"], + ["grid_width", "Canvas/GridOptions/GridWidthValue", "value", Global.grid_width], + ["grid_height", "Canvas/GridOptions/GridHeightValue", "value", Global.grid_height], + ["grid_color", "Canvas/GridOptions/GridColor", "color", Global.grid_color], + ["guide_color", "Canvas/GuideOptions/GuideColor", "color", Global.guide_color], + ["checker_size", "Canvas/CheckerOptions/CheckerSizeValue", "value", Global.checker_size], + ["checker_color_1", "Canvas/CheckerOptions/CheckerColor1", "color", Global.checker_color_1], + ["checker_color_2", "Canvas/CheckerOptions/CheckerColor2", "color", Global.checker_color_2], ] var selected_item := 0 @@ -30,6 +30,7 @@ var selected_item := 0 onready var list : ItemList = $HSplitContainer/List onready var right_side : VBoxContainer = $HSplitContainer/ScrollContainer/VBoxContainer onready var autosave_interval : SpinBox = $HSplitContainer/ScrollContainer/VBoxContainer/Backup/AutosaveContainer/AutosaveInterval +onready var restore_default_button_scene = preload("res://src/Preferences/RestoreDefaultButton.tscn") func _ready() -> void: @@ -43,46 +44,64 @@ func _ready() -> void: for pref in preferences: var node = right_side.get_node(pref[1]) + var node_position = node.get_index() + + var restore_default_button : BaseButton = restore_default_button_scene.instance() + restore_default_button.setting_name = pref[0] + restore_default_button.value_type = pref[2] + restore_default_button.default_value = pref[3] + restore_default_button.node = node + node.get_parent().add_child(restore_default_button) + node.get_parent().move_child(restore_default_button, node_position) match pref[2]: "pressed": - node.connect("toggled", self, "_on_Preference_toggled", [pref[0]]) + node.connect("toggled", self, "_on_Preference_toggled", [pref[0], pref[3], restore_default_button]) "value": - node.connect("value_changed", self, "_on_Preference_value_changed", [pref[0]]) + node.connect("value_changed", self, "_on_Preference_value_changed", [pref[0], pref[3], restore_default_button]) "color": node.get_picker().presets_visible = false - node.connect("color_changed", self, "_on_Preference_color_changed", [pref[0]]) + node.connect("color_changed", self, "_on_Preference_color_changed", [pref[0], pref[3], restore_default_button]) "selected": - node.connect("item_selected", self, "_on_Preference_item_selected", [pref[0]]) + node.connect("item_selected", self, "_on_Preference_item_selected", [pref[0], pref[3], restore_default_button]) if Global.config_cache.has_section_key("preferences", pref[0]): var value = Global.config_cache.get_value("preferences", pref[0]) Global.set(pref[0], value) node.set(pref[2], value) + # This is needed because color_changed doesn't fire if the color changes in code + if pref[2] == "color": + preference_update(pref[0]) + disable_restore_default_button(restore_default_button, Global.get(pref[0]).is_equal_approx(pref[3])) -func _on_Preference_toggled(button_pressed : bool, prop : String) -> void: + +func _on_Preference_toggled(button_pressed : bool, prop : String, default_value, restore_default_button : BaseButton) -> void: Global.set(prop, button_pressed) Global.config_cache.set_value("preferences", prop, button_pressed) preference_update(prop) + disable_restore_default_button(restore_default_button, Global.get(prop) == default_value) -func _on_Preference_value_changed(value : float, prop : String) -> void: +func _on_Preference_value_changed(value : float, prop : String, default_value, restore_default_button : BaseButton) -> void: Global.set(prop, value) Global.config_cache.set_value("preferences", prop, value) preference_update(prop) + disable_restore_default_button(restore_default_button, Global.get(prop) == default_value) -func _on_Preference_color_changed(color : Color, prop : String) -> void: +func _on_Preference_color_changed(color : Color, prop : String, default_value, restore_default_button : BaseButton) -> void: Global.set(prop, color) Global.config_cache.set_value("preferences", prop, color) preference_update(prop) + disable_restore_default_button(restore_default_button, Global.get(prop).is_equal_approx(default_value)) -func _on_Preference_item_selected(id : int, prop : String) -> void: +func _on_Preference_item_selected(id : int, prop : String, default_value, restore_default_button : BaseButton) -> void: Global.set(prop, id) Global.config_cache.set_value("preferences", prop, id) preference_update(prop) + disable_restore_default_button(restore_default_button, Global.get(prop) == default_value) func preference_update(prop : String) -> void: @@ -108,6 +127,16 @@ func preference_update(prop : String) -> void: Global.config_cache.save("user://cache.ini") +func disable_restore_default_button(button : BaseButton, disable : bool) -> void: + button.disabled = disable + if disable: + button.mouse_default_cursor_shape = Control.CURSOR_ARROW + button.hint_tooltip = "" + else: + button.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND + button.hint_tooltip = "Restore default value" + + func _on_PreferencesDialog_about_to_show(changed_language := false) -> void: if OS.get_name() != "HTML5": list.add_item(" " + tr("Startup")) diff --git a/src/Preferences/PreferencesDialog.tscn b/src/Preferences/PreferencesDialog.tscn index 04189c6f2..bf1cf19e9 100644 --- a/src/Preferences/PreferencesDialog.tscn +++ b/src/Preferences/PreferencesDialog.tscn @@ -285,23 +285,34 @@ text = "Light" [node name="Canvas" type="VBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer"] visible = false -margin_top = 184.0 +margin_top = 28.0 margin_right = 498.0 -margin_bottom = 484.0 +margin_bottom = 280.0 [node name="ZoomLabel" type="Label" parent="HSplitContainer/ScrollContainer/VBoxContainer/Canvas"] margin_right = 498.0 margin_bottom = 14.0 text = "Zoom" -[node name="SmoothZoom" type="CheckBox" parent="HSplitContainer/ScrollContainer/VBoxContainer/Canvas"] +[node name="ZoomOptions" type="HBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer/Canvas"] margin_top = 18.0 margin_right = 498.0 margin_bottom = 42.0 + +[node name="Label" type="Label" parent="HSplitContainer/ScrollContainer/VBoxContainer/Canvas/ZoomOptions"] +margin_top = 5.0 +margin_right = 90.0 +margin_bottom = 19.0 +text = "Smooth Zoom" + +[node name="SmoothZoom" type="CheckBox" parent="HSplitContainer/ScrollContainer/VBoxContainer/Canvas/ZoomOptions"] +margin_left = 94.0 +margin_right = 141.0 +margin_bottom = 24.0 hint_tooltip = "Adds a smoother transition when zooming in or out" mouse_default_cursor_shape = 2 pressed = true -text = "Smooth Zoom" +text = "On" [node name="HSeparator" type="HSeparator" parent="HSplitContainer/ScrollContainer/VBoxContainer/Canvas"] margin_top = 46.0 @@ -320,7 +331,7 @@ margin_right = 498.0 margin_bottom = 92.0 custom_constants/vseparation = 4 custom_constants/hseparation = 4 -columns = 2 +columns = 3 [node name="GuideColorLabel" type="Label" parent="HSplitContainer/ScrollContainer/VBoxContainer/Canvas/GuideOptions"] margin_top = 3.0 @@ -354,10 +365,10 @@ text = "Grid" [node name="GridOptions" type="GridContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer/Canvas"] margin_top = 122.0 margin_right = 498.0 -margin_bottom = 198.0 +margin_bottom = 174.0 custom_constants/vseparation = 4 custom_constants/hseparation = 4 -columns = 2 +columns = 3 [node name="WidthLabel" type="Label" parent="HSplitContainer/ScrollContainer/VBoxContainer/Canvas/GridOptions"] margin_top = 5.0 @@ -382,17 +393,17 @@ align = 2 suffix = "px" [node name="Height" type="Label" parent="HSplitContainer/ScrollContainer/VBoxContainer/Canvas/GridOptions"] -margin_top = 33.0 -margin_right = 110.0 -margin_bottom = 47.0 +margin_left = 192.0 +margin_top = 5.0 +margin_right = 267.0 +margin_bottom = 19.0 hint_tooltip = "Sets how far apart are horizontal lines of the grid" mouse_filter = 0 text = "Grid height:" [node name="GridHeightValue" type="SpinBox" parent="HSplitContainer/ScrollContainer/VBoxContainer/Canvas/GridOptions"] -margin_left = 114.0 margin_top = 28.0 -margin_right = 188.0 +margin_right = 110.0 margin_bottom = 52.0 hint_tooltip = "Sets how far apart are horizontal lines of the grid" mouse_default_cursor_shape = 2 @@ -404,40 +415,41 @@ align = 2 suffix = "px" [node name="GridColorLabel" type="Label" parent="HSplitContainer/ScrollContainer/VBoxContainer/Canvas/GridOptions"] -margin_top = 59.0 -margin_right = 110.0 -margin_bottom = 73.0 +margin_left = 114.0 +margin_top = 33.0 +margin_right = 188.0 +margin_bottom = 47.0 hint_tooltip = "A color of the grid" mouse_filter = 0 text = "Grid color:" [node name="GridColor" type="ColorPickerButton" parent="HSplitContainer/ScrollContainer/VBoxContainer/Canvas/GridOptions"] -margin_left = 114.0 -margin_top = 56.0 -margin_right = 188.0 -margin_bottom = 76.0 +margin_left = 192.0 +margin_top = 28.0 +margin_right = 267.0 +margin_bottom = 52.0 rect_min_size = Vector2( 64, 20 ) hint_tooltip = "A color of the grid" mouse_default_cursor_shape = 2 [node name="HSeparator3" type="HSeparator" parent="HSplitContainer/ScrollContainer/VBoxContainer/Canvas"] -margin_top = 202.0 +margin_top = 178.0 margin_right = 498.0 -margin_bottom = 206.0 +margin_bottom = 182.0 [node name="TransparencyLabel" type="Label" parent="HSplitContainer/ScrollContainer/VBoxContainer/Canvas"] -margin_top = 210.0 +margin_top = 186.0 margin_right = 498.0 -margin_bottom = 224.0 +margin_bottom = 200.0 text = "Transparency" [node name="CheckerOptions" type="GridContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer/Canvas"] -margin_top = 228.0 +margin_top = 204.0 margin_right = 498.0 -margin_bottom = 300.0 +margin_bottom = 252.0 custom_constants/vseparation = 4 custom_constants/hseparation = 4 -columns = 2 +columns = 3 [node name="SizeLabel" type="Label" parent="HSplitContainer/ScrollContainer/VBoxContainer/Canvas/CheckerOptions"] margin_top = 5.0 @@ -450,7 +462,7 @@ text = "Checker size:" [node name="CheckerSizeValue" type="SpinBox" parent="HSplitContainer/ScrollContainer/VBoxContainer/Canvas/CheckerOptions"] margin_left = 114.0 -margin_right = 188.0 +margin_right = 217.0 margin_bottom = 24.0 hint_tooltip = "Size of the transparent checker background" mouse_default_cursor_shape = 2 @@ -462,17 +474,17 @@ align = 2 suffix = "px" [node name="CheckerColor1Label" type="Label" parent="HSplitContainer/ScrollContainer/VBoxContainer/Canvas/CheckerOptions"] -margin_top = 31.0 -margin_right = 110.0 -margin_bottom = 45.0 +margin_left = 221.0 +margin_top = 5.0 +margin_right = 324.0 +margin_bottom = 19.0 hint_tooltip = "First color of the transparent checker background" mouse_filter = 0 text = "Checker color 1:" [node name="CheckerColor1" type="ColorPickerButton" parent="HSplitContainer/ScrollContainer/VBoxContainer/Canvas/CheckerOptions"] -margin_left = 114.0 margin_top = 28.0 -margin_right = 188.0 +margin_right = 110.0 margin_bottom = 48.0 rect_min_size = Vector2( 64, 20 ) hint_tooltip = "First color of the transparent checker background" @@ -480,18 +492,19 @@ mouse_default_cursor_shape = 2 color = Color( 0.470588, 0.470588, 0.470588, 1 ) [node name="CheckerColor2Label" type="Label" parent="HSplitContainer/ScrollContainer/VBoxContainer/Canvas/CheckerOptions"] -margin_top = 55.0 -margin_right = 110.0 -margin_bottom = 69.0 +margin_left = 114.0 +margin_top = 31.0 +margin_right = 217.0 +margin_bottom = 45.0 hint_tooltip = "Second color of the transparent checker background" mouse_filter = 0 text = "Checker color 2:" [node name="CheckerColor2" type="ColorPickerButton" parent="HSplitContainer/ScrollContainer/VBoxContainer/Canvas/CheckerOptions"] -margin_left = 114.0 -margin_top = 52.0 -margin_right = 188.0 -margin_bottom = 72.0 +margin_left = 221.0 +margin_top = 28.0 +margin_right = 324.0 +margin_bottom = 48.0 rect_min_size = Vector2( 64, 20 ) hint_tooltip = "Second color of the transparent checker background" mouse_default_cursor_shape = 2 @@ -508,7 +521,7 @@ margin_right = 506.0 margin_bottom = 76.0 custom_constants/vseparation = 4 custom_constants/hseparation = 4 -columns = 2 +columns = 3 [node name="DefaultWidthLabel" type="Label" parent="HSplitContainer/ScrollContainer/VBoxContainer/Image/ImageOptions"] margin_top = 5.0 @@ -829,7 +842,7 @@ margin_bottom = 254.0 margin_top = 18.0 margin_right = 498.0 margin_bottom = 70.0 -columns = 2 +columns = 3 [node name="Label" type="Label" parent="HSplitContainer/ScrollContainer/VBoxContainer/Backup/AutosaveContainer"] margin_top = 5.0 @@ -885,7 +898,7 @@ margin_right = 498.0 margin_bottom = 126.0 custom_constants/vseparation = 4 custom_constants/hseparation = 4 -columns = 2 +columns = 3 [node name="Label" type="Label" parent="HSplitContainer/ScrollContainer/VBoxContainer/Indicators/IndicatorsContainer"] margin_top = 5.0 diff --git a/src/Preferences/RestoreDefaultButton.gd b/src/Preferences/RestoreDefaultButton.gd new file mode 100644 index 000000000..f9d9e727d --- /dev/null +++ b/src/Preferences/RestoreDefaultButton.gd @@ -0,0 +1,15 @@ +extends TextureButton + + +var setting_name : String +var value_type : String +var default_value +var node : Node + + +func _on_RestoreDefaultButton_pressed() -> void: + Global.set(setting_name, default_value) + Global.config_cache.set_value("preferences", setting_name, default_value) + Global.preferences_dialog.preference_update(setting_name) + Global.preferences_dialog.disable_restore_default_button(self, true) + node.set(value_type, default_value) diff --git a/src/Preferences/RestoreDefaultButton.tscn b/src/Preferences/RestoreDefaultButton.tscn new file mode 100644 index 000000000..a9cbedad2 --- /dev/null +++ b/src/Preferences/RestoreDefaultButton.tscn @@ -0,0 +1,18 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://assets/graphics/dark_themes/misc/icon_reload.png" type="Texture" id=1] +[ext_resource path="res://src/Preferences/RestoreDefaultButton.gd" type="Script" id=2] + +[sub_resource type="ImageTexture" id=1] + +[node name="RestoreDefaultButton" type="TextureButton"] +margin_right = 16.0 +margin_bottom = 16.0 +disabled = true +texture_normal = ExtResource( 1 ) +texture_disabled = SubResource( 1 ) +script = ExtResource( 2 ) +__meta__ = { +"_edit_use_anchors_": false +} +[connection signal="pressed" from="." to="." method="_on_RestoreDefaultButton_pressed"]