1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 17:19:50 +00:00

Add an Apply button to the font size slider in the Preferences, fix display scale not being applied on startup

This commit is contained in:
Emmanouil Papadeas 2024-03-30 01:25:01 +02:00
parent 0caf3de2d1
commit 11a1428eef
4 changed files with 27 additions and 16 deletions

View file

@ -188,13 +188,7 @@ var integer_zoom := false:
## Found in Preferences. The scale of the interface.
var shrink := 1.0
## Found in Preferences. The font size used by the interface.
var font_size := 16:
set(value):
if font_size == value:
return
font_size = value
control.theme.default_font_size = value
control.theme.set_font_size("font_size", "HeaderSmall", value + 2)
var font_size := 16
## Found in Preferences. If [code]true[/code], the interface dims on popups.
var dim_on_popup := true
## Found in Preferences. If [code]true[/code], the native file dialogs of the

View file

@ -32,7 +32,6 @@ func _init() -> void:
func _ready() -> void:
get_tree().set_auto_accept_quit(false)
_setup_application_window_size()
Global.main_window.title = tr("untitled") + " - Pixelorama " + Global.current_version
@ -66,6 +65,8 @@ or CLI exporting. Loading pxo files in Pixelorama does not need this option to b
if OS.get_name() == "Android":
OS.request_permissions()
_handle_backup()
await get_tree().process_frame
_setup_application_window_size()
_show_splash_screen()
Global.pixelorama_opened.emit()
@ -120,6 +121,9 @@ func _setup_application_window_size() -> void:
# Set a minimum window size to prevent UI elements from collapsing on each other.
root.min_size = Vector2(1024, 576)
root.content_scale_factor = Global.shrink
if Global.font_size != theme.default_font_size:
theme.default_font_size = Global.font_size
theme.set_font_size("font_size", "HeaderSmall", Global.font_size + 2)
set_custom_cursor()
if OS.get_name() == "Web":
@ -164,7 +168,6 @@ func _show_splash_screen() -> void:
if Global.config_cache.get_value("preferences", "startup"):
# Wait for the window to adjust itself, so the popup is correctly centered
await get_tree().process_frame
await get_tree().process_frame
splash_dialog.popup_centered() # Splash screen
modulate = Color(0.5, 0.5, 0.5)

View file

@ -9,7 +9,7 @@ var preferences: Array[Preference] = [
),
Preference.new("ffmpeg_path", "Startup/StartupContainer/FFMPEGPath", "text", ""),
Preference.new("shrink", "%ShrinkSlider", "value", 1.0),
Preference.new("font_size", "Interface/InterfaceOptions/FontSizeSlider", "value", 16),
Preference.new("font_size", "%FontSizeSlider", "value", 16),
Preference.new(
"dim_on_popup", "Interface/InterfaceOptions/DimCheckBox", "button_pressed", true
),
@ -196,7 +196,6 @@ var selected_item := 0
@onready var language: VBoxContainer = %Language
@onready var autosave_container: Container = right_side.get_node("Backup/AutosaveContainer")
@onready var autosave_interval: SpinBox = autosave_container.get_node("AutosaveInterval")
@onready var shrink_slider: ValueSlider = $"%ShrinkSlider"
@onready var themes: BoxContainer = right_side.get_node("Interface/Themes")
@onready var shortcuts: Control = right_side.get_node("Shortcuts/ShortcutEdit")
@onready var tablet_driver_label: Label = $"%TabletDriverLabel"
@ -233,7 +232,6 @@ func _ready() -> void:
# Replace OK since preference changes are being applied immediately, not after OK confirmation
get_ok_button().text = "Close"
get_ok_button().size_flags_horizontal = Control.SIZE_EXPAND_FILL
shrink_slider.value = Global.shrink # In case shrink is not equal to 1
shortcuts.profile_option_button.item_selected.connect(func(_i): Tools.update_hint_tooltips())
if shortcuts.profile_option_button.selected != 0:
@ -282,7 +280,7 @@ func _ready() -> void:
restore_default_button.default_value = pref.default_value
restore_default_button.require_restart = pref.require_restart
restore_default_button.node = node
if pref.node_path == "%ShrinkSlider":
if pref.node_path in ["%ShrinkSlider", "%FontSizeSlider"]:
# Add the default button to the shrink slider's grandparent
var node_position := node.get_parent().get_index()
node.get_parent().get_parent().add_child(restore_default_button)
@ -379,7 +377,7 @@ func _on_List_item_selected(index: int) -> void:
child.visible = child.name == content_list[index]
func _on_ShrinkApplyButton_pressed() -> void:
func _on_shrink_apply_button_pressed() -> void:
var root := get_tree().root
root.content_scale_aspect = Window.CONTENT_SCALE_ASPECT_IGNORE
root.content_scale_mode = Window.CONTENT_SCALE_MODE_DISABLED
@ -393,6 +391,11 @@ func _on_ShrinkApplyButton_pressed() -> void:
Global.camera.fit_to_frame(Global.current_project.size)
func _on_font_size_apply_button_pressed() -> void:
Global.control.theme.default_font_size = Global.font_size
Global.control.theme.set_font_size("font_size", "HeaderSmall", Global.font_size + 2)
func _on_language_pressed(index: int) -> void:
var locale := OS.get_locale()
if index > 1:

View file

@ -181,8 +181,13 @@ layout_mode = 2
size_flags_horizontal = 3
text = "Font size:"
[node name="FontSizeSlider" type="TextureProgressBar" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Interface/InterfaceOptions"]
[node name="FontSizeContainer" type="HBoxContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Interface/InterfaceOptions"]
layout_mode = 2
[node name="FontSizeSlider" type="TextureProgressBar" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Interface/InterfaceOptions/FontSizeContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
focus_mode = 2
mouse_default_cursor_shape = 2
theme_type_variation = &"ValueSlider"
@ -197,6 +202,11 @@ stretch_margin_right = 3
stretch_margin_bottom = 3
script = ExtResource("8")
[node name="FontSizeApplyButton" type="Button" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Interface/InterfaceOptions/FontSizeContainer"]
layout_mode = 2
mouse_default_cursor_shape = 2
text = "Apply"
[node name="DimLabel" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Interface/InterfaceOptions"]
layout_mode = 2
size_flags_horizontal = 3
@ -1377,7 +1387,8 @@ vertical_alignment = 1
[connection signal="visibility_changed" from="." to="." method="_on_PreferencesDialog_visibility_changed"]
[connection signal="item_selected" from="HSplitContainer/List" to="." method="_on_List_item_selected"]
[connection signal="pressed" from="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Language/System Language" to="." method="_on_language_pressed" binds= [1]]
[connection signal="pressed" from="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Interface/InterfaceOptions/ShrinkContainer/ShrinkApplyButton" to="." method="_on_ShrinkApplyButton_pressed"]
[connection signal="pressed" from="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Interface/InterfaceOptions/ShrinkContainer/ShrinkApplyButton" to="." method="_on_shrink_apply_button_pressed"]
[connection signal="pressed" from="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Interface/InterfaceOptions/FontSizeContainer/FontSizeApplyButton" to="." method="_on_font_size_apply_button_pressed"]
[connection signal="pressed" from="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Extensions/ExtensionsHeader/Explore" to="Store" method="_on_explore_pressed"]
[connection signal="empty_clicked" from="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Extensions/InstalledExtensions" to="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Extensions" method="_on_InstalledExtensions_empty_clicked"]
[connection signal="item_selected" from="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Extensions/InstalledExtensions" to="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Extensions" method="_on_InstalledExtensions_item_selected"]