Skip to content

Commit

Permalink
Implement UI scaling setting. (#661)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiisu-Master authored Apr 16, 2024
1 parent 2c13bb6 commit 42ba31d
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 10 deletions.
14 changes: 13 additions & 1 deletion src/GlobalSettings.gd
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const default_config = {
"use_ctrl_for_zoom": true,
"use_native_file_dialog": true,
"handle_size": 1.0,
"ui_scale": 1.0,
},
}

Expand Down Expand Up @@ -137,7 +138,10 @@ var wrap_mouse := false
var use_ctrl_for_zoom := true
var use_native_file_dialog := true
var handle_size := 1.0

var ui_scale := 1.0:
set(new_value):
ui_scale = new_value
update_ui_scale()

func toggle_bool_setting(section: String, setting: String) -> void:
set(setting, !get(setting))
Expand Down Expand Up @@ -185,6 +189,7 @@ func _enter_tree() -> void:
load_user_data()
DisplayServer.window_set_mode(save_data.window_mode)
get_window().wrap_controls = true # Prevents the main window from getting too small.
update_ui_scale()
ThemeGenerator.generate_theme()


Expand Down Expand Up @@ -235,3 +240,10 @@ func get_validity_color(error_condition: bool, warning_condition := false) -> Co
return GlobalSettings.basic_color_error if error_condition else\
GlobalSettings.basic_color_warning if warning_condition else\
GlobalSettings.basic_color_valid

func update_ui_scale() -> void:
await get_tree().process_frame
var window := get_window()
var new_min_size := window.get_contents_minimum_size() * ui_scale
window.min_size = new_min_size
window.content_scale_factor = ui_scale
18 changes: 13 additions & 5 deletions src/ui_parts/settings_menu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,25 @@ func setup_setting_labels() -> void:

var invert_zoom := %ContentContainer/Other/OtherSettings/Input/InvertZoom
invert_zoom.label.text = tr("Invert zoom direction")
invert_zoom.label.tooltip_text = tr("Swaps zoom in and zoom out with the mouse wheel.")
invert_zoom.tooltip_text = tr("Swaps zoom in and zoom out with the mouse wheel.")

wrap_mouse.label.text = tr("Wrap mouse")
wrap_mouse.label.tooltip_text = tr("Wraps the mouse cursor around when panning the viewport.")
wrap_mouse.tooltip_text = tr("Wraps the mouse cursor around when panning the viewport.")

var ctrl_for_zoom := %ContentContainer/Other/OtherSettings/Input/UseCtrlForZoom
ctrl_for_zoom.label.text = tr("Use CTRL for zooming")
ctrl_for_zoom.label.tooltip_text = tr("If turned on, scrolling will pan the view. To zoom, hold CTRL while scrolling.")
ctrl_for_zoom.tooltip_text = tr("If turned on, scrolling will pan the view. To zoom, hold CTRL while scrolling.")

use_native_file_dialog.label.text = tr("Use native file dialog")
use_native_file_dialog.label.tooltip_text = tr("If turned on, uses your operating system's native file dialog. If turned off, uses GodSVG's built-in file dialog.")
use_native_file_dialog.tooltip_text = tr("If turned on, uses your operating system's native file dialog. If turned off, uses GodSVG's built-in file dialog.")

var handles_size := %ContentContainer/Other/OtherSettings/Misc/HandleSize
handles_size.label.text = tr("Handles size")
handles_size.label.tooltip_text = tr("Increases the visual size and grabbing area of handles.")
handles_size.tooltip_text = tr("Increases the visual size and grabbing area of handles.")

var ui_scale := %ContentContainer/Other/OtherSettings/Misc/UIScale
ui_scale.label.text = tr("UI scale")
ui_scale.tooltip_text = tr("Changes the scale of the visual user interface.")

%GeneralVBox/NumberPrecision.label.text = tr("Number precision digits")
%GeneralVBox/AnglePrecision.label.text = tr("Angle precision digits")
Expand Down
14 changes: 10 additions & 4 deletions src/ui_parts/settings_menu.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -494,20 +494,17 @@ text = "Input"

[node name="InvertZoom" parent="VBoxContainer/HBoxContainer/MainPanel/ContentContainer/Other/OtherSettings/Input" instance=ExtResource("4_2qeh2")]
layout_mode = 2
tooltip_text = "Swaps zoom in and zoom out with the mouse wheel."
section_name = "other"
setting_name = "invert_zoom"

[node name="WrapMouse" parent="VBoxContainer/HBoxContainer/MainPanel/ContentContainer/Other/OtherSettings/Input" instance=ExtResource("4_2qeh2")]
unique_name_in_owner = true
layout_mode = 2
tooltip_text = "Wraps the mouse cursor around when panning the viewport."
section_name = "other"
setting_name = "wrap_mouse"

[node name="UseCtrlForZoom" parent="VBoxContainer/HBoxContainer/MainPanel/ContentContainer/Other/OtherSettings/Input" instance=ExtResource("4_2qeh2")]
layout_mode = 2
tooltip_text = "If turned on, scrolling will pan the view. To zoom, hold CTRL while scrolling."
section_name = "other"
setting_name = "use_ctrl_for_zoom"

Expand All @@ -524,7 +521,6 @@ text = "Miscellaneous"
[node name="UseNativeFileDialog" parent="VBoxContainer/HBoxContainer/MainPanel/ContentContainer/Other/OtherSettings/Misc" instance=ExtResource("4_2qeh2")]
unique_name_in_owner = true
layout_mode = 2
tooltip_text = "Swaps zoom in and zoom out with the mouse wheel."
section_name = "other"
setting_name = "use_native_file_dialog"

Expand All @@ -538,6 +534,16 @@ restricted = false
number_min = 0.5
number_max = 2.5

[node name="UIScale" parent="VBoxContainer/HBoxContainer/MainPanel/ContentContainer/Other/OtherSettings/Misc" instance=ExtResource("5_dx7vp")]
layout_mode = 2
section_name = "other"
setting_name = "ui_scale"
values = Array[String](["0.75", "1.0", "1.25", "1.5", "1.75", "2.0"])
type = 3
restricted = false
number_min = 0.5
number_max = 2.5

[node name="CloseButton" type="Button" parent="VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 4
Expand Down
5 changes: 5 additions & 0 deletions translations/GodSVG.pot
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ msgstr ""
msgid ""
"If turned on, scrolling will pan the view. To zoom, hold CTRL while "
"scrolling."

msgid "UI scale"
msgstr ""

msgid "Changes the scale of the visual user interface."
msgstr ""

msgid "Input"
Expand Down
7 changes: 7 additions & 0 deletions translations/bg.po
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ msgstr ""
"Когато е включено, влаченето ще премести гледката. За увеличение, натисни "
"CTRL докато влачиш"

#, fuzzy
msgid "UI scale"
msgstr "Мащаб"

msgid "Changes the scale of the visual user interface."
msgstr ""

msgid "Input"
msgstr "Входни сигнали"

Expand Down
7 changes: 7 additions & 0 deletions translations/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ msgstr ""
"Wenn diese Option aktiviert ist, wird durch Scrollen die Ansicht geschwenkt. "
"Halten Sie zum Zoomen beim Scrollen die Strg-Taste gedrückt."

#, fuzzy
msgid "UI scale"
msgstr "Skalieren"

msgid "Changes the scale of the visual user interface."
msgstr ""

msgid "Input"
msgstr "Eingabe"

Expand Down
6 changes: 6 additions & 0 deletions translations/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ msgid ""
"scrolling."
msgstr ""

msgid "UI scale"
msgstr ""

msgid "Changes the scale of the visual user interface."
msgstr ""

msgid "Input"
msgstr ""

Expand Down
7 changes: 7 additions & 0 deletions translations/ru.po
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ msgstr ""
"Если включено, прокрутка будет перемещать окно просмотра. Чтобы "
"масштабировать Зажмите CTRL когда прокручиваете."

#, fuzzy
msgid "UI scale"
msgstr "Масштаб"

msgid "Changes the scale of the visual user interface."
msgstr ""

msgid "Input"
msgstr "Устройства ввода"

Expand Down
7 changes: 7 additions & 0 deletions translations/uk.po
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ msgstr ""
"Якщо увімкнено, гортання буде рухати вікно перегляду. Щоб масштабувати, "
"затисніть CTRL доки гортаєте."

#, fuzzy
msgid "UI scale"
msgstr "Масштаб"

msgid "Changes the scale of the visual user interface."
msgstr ""

msgid "Input"
msgstr "Пристрої вводу"

Expand Down

0 comments on commit 42ba31d

Please sign in to comment.