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

Add a set_display_scale() method to Main to avoid duplicate code

This commit is contained in:
Emmanouil Papadeas 2024-11-04 18:47:29 +02:00
parent ec17e970e0
commit d2892358e3
3 changed files with 13 additions and 13 deletions

View file

@ -250,16 +250,10 @@ func _handle_layout_files() -> void:
func _setup_application_window_size() -> void: func _setup_application_window_size() -> void:
if DisplayServer.get_name() == "headless": if DisplayServer.get_name() == "headless":
return return
var root := get_tree().root set_display_scale()
root.content_scale_aspect = Window.CONTENT_SCALE_ASPECT_IGNORE
root.content_scale_mode = Window.CONTENT_SCALE_MODE_DISABLED
# 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: if Global.font_size != theme.default_font_size:
theme.default_font_size = Global.font_size theme.default_font_size = Global.font_size
theme.set_font_size("font_size", "HeaderSmall", Global.font_size + 2) theme.set_font_size("font_size", "HeaderSmall", Global.font_size + 2)
set_custom_cursor()
if OS.get_name() == "Web": if OS.get_name() == "Web":
return return
@ -280,6 +274,16 @@ func _setup_application_window_size() -> void:
get_window().size = Global.config_cache.get_value("window", "size") get_window().size = Global.config_cache.get_value("window", "size")
func set_display_scale() -> void:
var root := get_window()
root.content_scale_aspect = Window.CONTENT_SCALE_ASPECT_IGNORE
root.content_scale_mode = Window.CONTENT_SCALE_MODE_DISABLED
# 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
set_custom_cursor()
func set_custom_cursor() -> void: func set_custom_cursor() -> void:
if Global.native_cursors: if Global.native_cursors:
return return

View file

@ -413,12 +413,7 @@ func _on_List_item_selected(index: int) -> void:
func _on_shrink_apply_button_pressed() -> void: func _on_shrink_apply_button_pressed() -> void:
var root := get_tree().root Global.control.set_display_scale()
root.content_scale_aspect = Window.CONTENT_SCALE_ASPECT_IGNORE
root.content_scale_mode = Window.CONTENT_SCALE_MODE_DISABLED
root.min_size = Vector2(1024, 576)
root.content_scale_factor = Global.shrink
Global.control.set_custom_cursor()
hide() hide()
popup_centered(Vector2(600, 400)) popup_centered(Vector2(600, 400))
Global.dialog_open(true) Global.dialog_open(true)

View file

@ -99,6 +99,7 @@ func _ready() -> void:
func _input(event: InputEvent) -> void: func _input(event: InputEvent) -> void:
# Workaround for https://github.com/Orama-Interactive/Pixelorama/issues/1070
if event is InputEventMouseButton and event.pressed: if event is InputEventMouseButton and event.pressed:
file_menu.activate_item_by_event(event) file_menu.activate_item_by_event(event)
edit_menu.activate_item_by_event(event) edit_menu.activate_item_by_event(event)