Skip to content

Commit

Permalink
Add a set_display_scale() method to Main to avoid duplicate code
Browse files Browse the repository at this point in the history
  • Loading branch information
OverloadedOrama committed Nov 4, 2024
1 parent ec17e97 commit d289235
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
18 changes: 11 additions & 7 deletions src/Main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,10 @@ func _handle_layout_files() -> void:
func _setup_application_window_size() -> void:
if DisplayServer.get_name() == "headless":
return
var root := get_tree().root
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_display_scale()
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":
return
Expand All @@ -280,6 +274,16 @@ func _setup_application_window_size() -> void:
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:
if Global.native_cursors:
return
Expand Down
7 changes: 1 addition & 6 deletions src/Preferences/PreferencesDialog.gd
Original file line number Diff line number Diff line change
Expand Up @@ -413,12 +413,7 @@ func _on_List_item_selected(index: int) -> 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
root.min_size = Vector2(1024, 576)
root.content_scale_factor = Global.shrink
Global.control.set_custom_cursor()
Global.control.set_display_scale()
hide()
popup_centered(Vector2(600, 400))
Global.dialog_open(true)
Expand Down
1 change: 1 addition & 0 deletions src/UI/TopMenuContainer/TopMenuContainer.gd
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ func _ready() -> void:


func _input(event: InputEvent) -> void:
# Workaround for https://github.com/Orama-Interactive/Pixelorama/issues/1070
if event is InputEventMouseButton and event.pressed:
file_menu.activate_item_by_event(event)
edit_menu.activate_item_by_event(event)
Expand Down

0 comments on commit d289235

Please sign in to comment.