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

Compare commits

...

5 commits

Author SHA1 Message Date
Emmanouil Papadeas ffd729486f Expose window transparency as an option in the preferences, keep it disabled by default
I had to disable it, because for some reason having it be enabled by default does not seem to be working. This may be a good idea anyway, as many people will not need this feature, and having this enabled affects performance.

This commit also allows for changing project setting related options in the preferences to also work when running Pixelorama inside Godot.
2024-02-02 00:19:53 +02:00
Emmanouil Papadeas ed072de84e Change the layouts array in TopMenuContainer to only contain DockableLayouts instead of being an array of arrays 2024-02-01 22:10:18 +02:00
Emmanouil Papadeas 606ce965f6 Remove unneeded layout code from TopMenuContainer 2024-02-01 21:41:32 +02:00
Emmanouil Papadeas 276a872f73 Rename "ui" variable to "main_ui" in Main.gd and TopMenuContainer.gd 2024-02-01 20:53:52 +02:00
Emmanouil Papadeas 2e8cf6a30a Minor code improvements in WindowOpacityDialog.gd 2024-02-01 20:51:26 +02:00
12 changed files with 77 additions and 49 deletions

View file

@ -1462,15 +1462,23 @@ msgstr ""
msgid "Set application FPS limit:" msgid "Set application FPS limit:"
msgstr "" msgstr ""
msgid "Pause application when it loses focus"
msgstr ""
msgid "Sets the limit of the application's frames per second. The lower the number, the lower the CPU usage, but the application gets slower, choppier and unresponsive. 0 means that there is no limit." msgid "Sets the limit of the application's frames per second. The lower the number, the lower the CPU usage, but the application gets slower, choppier and unresponsive. 0 means that there is no limit."
msgstr "" msgstr ""
msgid "Pause application when it loses focus"
msgstr ""
msgid "If this is toggled on, when the application's window loses focus, it gets paused. This helps lower CPU usage when idle. The application gets unpaused when the mouse enters the application's window." msgid "If this is toggled on, when the application's window loses focus, it gets paused. This helps lower CPU usage when idle. The application gets unpaused when the mouse enters the application's window."
msgstr "" msgstr ""
#. An option found in the preferences, under the Performance section.
msgid "Enable window transparency"
msgstr ""
#. Found in the preferences, tooltip of the "Enable window transparency" option.
msgid "If enabled, the application window can become transparent. This affects performance, so keep it off if you don't need it."
msgstr ""
#. Found in the Preferences, under Drivers. Specifies the renderer/video driver being used. #. Found in the Preferences, under Drivers. Specifies the renderer/video driver being used.
msgid "Renderer:" msgid "Renderer:"
msgstr "" msgstr ""

View file

@ -52,7 +52,6 @@ gdscript/warnings/narrowing_conversion=false
window/size/viewport_width=1280 window/size/viewport_width=1280
window/size/viewport_height=720 window/size/viewport_height=720
window/per_pixel_transparency/allowed=true
window/per_pixel_transparency/allowed.android=false window/per_pixel_transparency/allowed.android=false
window/per_pixel_transparency/allowed.web=false window/per_pixel_transparency/allowed.web=false

View file

@ -170,9 +170,9 @@ var use_native_file_dialogs := false:
## Found in Preferences. If [code]true[/code], subwindows are embedded in the main window. ## Found in Preferences. If [code]true[/code], subwindows are embedded in the main window.
var single_window_mode := true: var single_window_mode := true:
set(value): set(value):
single_window_mode = value if value == single_window_mode:
if OS.has_feature("editor"):
return return
single_window_mode = value
ProjectSettings.set_setting("display/window/subwindows/embed_subwindows", value) ProjectSettings.set_setting("display/window/subwindows/embed_subwindows", value)
ProjectSettings.save_custom(root_directory.path_join(OVERRIDE_FILE)) ProjectSettings.save_custom(root_directory.path_join(OVERRIDE_FILE))
## Found in Preferences. The modulation color (or simply color) of icons. ## Found in Preferences. The modulation color (or simply color) of icons.
@ -356,6 +356,16 @@ var fps_limit := 0:
set(value): set(value):
fps_limit = value fps_limit = value
Engine.max_fps = fps_limit Engine.max_fps = fps_limit
## Found in Preferences. Affects the per_pixel_transparency project setting.
## If [code]true[/code], it allows for the window to be transparent.
## This affects performance, so keep it [code]false[/code] if you don't need it.
var window_transparency := false:
set(value):
if value == window_transparency:
return
window_transparency = value
ProjectSettings.set_setting("display/window/per_pixel_transparency/allowed", value)
ProjectSettings.save_custom(root_directory.path_join(OVERRIDE_FILE))
## Found in Preferences. The time (in minutes) after which backup is created (if enabled). ## Found in Preferences. The time (in minutes) after which backup is created (if enabled).
var autosave_interval := 1.0: var autosave_interval := 1.0:
@ -374,9 +384,9 @@ var renderer := 0:
## Found in Preferences. The index of tablet driver used by Pixelorama. ## Found in Preferences. The index of tablet driver used by Pixelorama.
var tablet_driver := 0: var tablet_driver := 0:
set(value): set(value):
tablet_driver = value if value == tablet_driver:
if OS.has_feature("editor"):
return return
tablet_driver = value
var tablet_driver_name := DisplayServer.tablet_get_current_driver() var tablet_driver_name := DisplayServer.tablet_get_current_driver()
ProjectSettings.set_setting("display/window/tablet_driver", tablet_driver_name) ProjectSettings.set_setting("display/window/tablet_driver", tablet_driver_name)
ProjectSettings.save_custom(root_directory.path_join(OVERRIDE_FILE)) ProjectSettings.save_custom(root_directory.path_join(OVERRIDE_FILE))
@ -553,6 +563,9 @@ func _init() -> void:
if ProjectSettings.get_setting("display/window/tablet_driver") == "winink": if ProjectSettings.get_setting("display/window/tablet_driver") == "winink":
tablet_driver = 1 tablet_driver = 1
single_window_mode = ProjectSettings.get_setting("display/window/subwindows/embed_subwindows") single_window_mode = ProjectSettings.get_setting("display/window/subwindows/embed_subwindows")
window_transparency = ProjectSettings.get_setting(
"display/window/per_pixel_transparency/allowed"
)
func _ready() -> void: func _ready() -> void:

View file

@ -6,7 +6,7 @@ var is_quitting_on_save := false
var changed_projects_on_quit: Array[Project] var changed_projects_on_quit: Array[Project]
var cursor_image := preload("res://assets/graphics/cursor.png") var cursor_image := preload("res://assets/graphics/cursor.png")
@onready var ui := $MenuAndUI/UI/DockableContainer as DockableContainer @onready var main_ui := $MenuAndUI/UI/DockableContainer as DockableContainer
@onready var backup_confirmation: ConfirmationDialog = $Dialogs/BackupConfirmation @onready var backup_confirmation: ConfirmationDialog = $Dialogs/BackupConfirmation
@onready var save_sprite_html5: ConfirmationDialog = $Dialogs/SaveSpriteHTML5 @onready var save_sprite_html5: ConfirmationDialog = $Dialogs/SaveSpriteHTML5
@onready var quit_dialog: ConfirmationDialog = $Dialogs/QuitDialog @onready var quit_dialog: ConfirmationDialog = $Dialogs/QuitDialog

View file

@ -101,6 +101,13 @@ var preferences: Array[Preference] = [
Preference.new( Preference.new(
"pause_when_unfocused", "Performance/PerformanceContainer/PauseAppFocus", "button_pressed" "pause_when_unfocused", "Performance/PerformanceContainer/PauseAppFocus", "button_pressed"
), ),
Preference.new(
"window_transparency",
"Performance/PerformanceContainer/WindowTransparency",
"button_pressed",
true,
false
),
# Preference.new( # Preference.new(
# "renderer", "Drivers/DriversContainer/Renderer", "selected", true, OS.VIDEO_DRIVER_GLES2 # "renderer", "Drivers/DriversContainer/Renderer", "selected", true, OS.VIDEO_DRIVER_GLES2
# ), # ),

View file

@ -1054,6 +1054,18 @@ mouse_default_cursor_shape = 2
button_pressed = true button_pressed = true
text = "On" text = "On"
[node name="WindowTransparencyLabel" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Performance/PerformanceContainer"]
layout_mode = 2
tooltip_text = "If enabled, the application window can become transparent. This affects performance, so keep it off if you don't need it."
mouse_filter = 0
text = "Enable window transparency"
[node name="WindowTransparency" type="CheckBox" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Performance/PerformanceContainer"]
layout_mode = 2
tooltip_text = "If enabled, the application window can become transparent. This affects performance, so keep it off if you don't need it."
mouse_default_cursor_shape = 2
text = "On"
[node name="Drivers" type="VBoxContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide"] [node name="Drivers" type="VBoxContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide"]
visible = false visible = false
layout_mode = 2 layout_mode = 2

View file

@ -257,7 +257,7 @@ func remove_reference_image(idx: int) -> void:
ri.queue_free() ri.queue_free()
Global.current_project.set_reference_image_index(-1) Global.current_project.set_reference_image_index(-1)
Global.current_project.change_project() Global.current_project.change_project()
Global.control.ui.find_child("Reference Images")._on_references_changed() Global.reference_panel._on_references_changed()
func _update_on_zoom() -> void: func _update_on_zoom() -> void:

View file

@ -64,7 +64,7 @@ func _on_DeleteLayout_pressed() -> void:
func _on_LayoutSettings_confirmed() -> void: func _on_LayoutSettings_confirmed() -> void:
var file_name := layout_name.text + ".tres" var file_name := layout_name.text + ".tres"
var path := "user://layouts/".path_join(file_name) var path := "user://layouts/".path_join(file_name)
var layout: DockableLayout = Global.control.ui.layout var layout: DockableLayout = Global.control.main_ui.layout
var err := ResourceSaver.save(layout, path) var err := ResourceSaver.save(layout, path)
if err != OK: if err != OK:
print(err) print(err)
@ -108,7 +108,7 @@ func _on_DeleteConfirmation_confirmed() -> void:
func refresh_preview(): func refresh_preview():
for tab in mimic_ui.get_tabs(): for tab in mimic_ui.get_tabs():
mimic_ui.remove_child(tab) mimic_ui.remove_child(tab)
for item in Global.top_menu_container.ui.get_tabs(): for item in Global.top_menu_container.main_ui.get_tabs():
var box := TextEdit.new() var box := TextEdit.new()
box.name = item.name box.name = item.name
box.text = item.name box.text = item.name

View file

@ -1,13 +1,13 @@
extends AcceptDialog extends AcceptDialog
@onready var slider: ValueSlider = $VBoxContainer/ValueSlider @onready var slider := $VBoxContainer/ValueSlider as ValueSlider
@onready var fullscreen_warning: Label = $VBoxContainer/FullscreenWarning @onready var fullscreen_warning := $VBoxContainer/FullscreenWarning as Label
@onready var main_canvas = Global.control.find_child("Main Canvas") @onready var main_canvas := Global.control.find_child("Main Canvas") as Control
func _ready() -> void: func _ready() -> void:
await get_tree().process_frame await get_tree().process_frame
Global.control.ui.sort_children.connect(_recalculate_opacity) Global.control.main_ui.sort_children.connect(_recalculate_opacity)
func _on_WindowOpacityDialog_about_to_show() -> void: func _on_WindowOpacityDialog_about_to_show() -> void:
@ -33,13 +33,12 @@ func set_window_opacity(value: float) -> void:
slider.value = value slider.value = value
value = value / 100.0 value = value / 100.0
for container in Global.control.ui._panel_container.get_children(): # Find the TabContainer that has the Main Canvas panel
for container: Control in Global.control.main_ui._panel_container.get_children():
if container is TabContainer: if container is TabContainer:
var point = container.get_rect().position + (container.get_rect().size / 2.0) var center := container.get_rect().get_center()
if main_canvas.get_rect().has_point(point): if main_canvas.get_rect().has_point(center):
container.self_modulate.a = value container.self_modulate.a = value
else:
container.self_modulate.a = 1.0
Global.transparent_checker.update_transparency(value) Global.transparent_checker.update_transparency(value)

View file

@ -10,16 +10,16 @@ const PIXELORAMA_ICON := preload("res://assets/graphics/icons/icon_16x16.png")
const HEART_ICON := preload("res://assets/graphics/misc/heart.svg") const HEART_ICON := preload("res://assets/graphics/misc/heart.svg")
var recent_projects := [] var recent_projects := []
var layouts := [ var layouts: Array[DockableLayout] = [
["Default", preload("res://assets/layouts/default.tres")], preload("res://assets/layouts/Default.tres"),
["Tallscreen", preload("res://assets/layouts/tallscreen.tres")], preload("res://assets/layouts/Tallscreen.tres"),
] ]
var default_layout_size := layouts.size() var default_layout_size := layouts.size()
var selected_layout := 0 var selected_layout := 0
var zen_mode := false var zen_mode := false
@onready var ui := Global.control.find_child("DockableContainer") as DockableContainer @onready var main_ui := Global.control.find_child("DockableContainer") as DockableContainer
@onready var ui_elements := ui.get_children() @onready var ui_elements := main_ui.get_children()
@onready var file_menu: PopupMenu = $MenuBar/File @onready var file_menu: PopupMenu = $MenuBar/File
@onready var edit_menu: PopupMenu = $MenuBar/Edit @onready var edit_menu: PopupMenu = $MenuBar/Edit
@onready var select_menu: PopupMenu = $MenuBar/Select @onready var select_menu: PopupMenu = $MenuBar/Select
@ -28,7 +28,7 @@ var zen_mode := false
@onready var window_menu: PopupMenu = $MenuBar/Window @onready var window_menu: PopupMenu = $MenuBar/Window
@onready var help_menu: PopupMenu = $MenuBar/Help @onready var help_menu: PopupMenu = $MenuBar/Help
@onready var greyscale_vision: ColorRect = ui.find_child("GreyscaleVision") @onready var greyscale_vision: ColorRect = main_ui.find_child("GreyscaleVision")
@onready var new_image_dialog: ConfirmationDialog = Global.control.find_child("CreateNewImage") @onready var new_image_dialog: ConfirmationDialog = Global.control.find_child("CreateNewImage")
@onready var window_opacity_dialog: AcceptDialog = Global.control.find_child("WindowOpacityDialog") @onready var window_opacity_dialog: AcceptDialog = Global.control.find_child("WindowOpacityDialog")
@onready var tile_mode_submenu := PopupMenu.new() @onready var tile_mode_submenu := PopupMenu.new()
@ -239,7 +239,7 @@ func _setup_panels_submenu(item: String) -> void:
panels_submenu.hide_on_checkable_item_selection = false panels_submenu.hide_on_checkable_item_selection = false
for element in ui_elements: for element in ui_elements:
panels_submenu.add_check_item(element.name) panels_submenu.add_check_item(element.name)
var is_hidden: bool = ui.is_control_hidden(element) var is_hidden: bool = main_ui.is_control_hidden(element)
panels_submenu.set_item_checked(ui_elements.find(element), !is_hidden) panels_submenu.set_item_checked(ui_elements.find(element), !is_hidden)
panels_submenu.id_pressed.connect(_panels_submenu_id_pressed) panels_submenu.id_pressed.connect(_panels_submenu_id_pressed)
@ -255,8 +255,9 @@ func _setup_layouts_submenu(item: String) -> void:
var file_name = dir.get_next() var file_name = dir.get_next()
while file_name != "": while file_name != "":
if !dir.current_is_dir(): if !dir.current_is_dir():
var file_name_no_tres: String = file_name.get_basename() var layout := ResourceLoader.load(path.path_join(file_name))
layouts.append([file_name_no_tres, ResourceLoader.load(path.path_join(file_name))]) if layout is DockableLayout:
layouts.append(layout)
file_name = dir.get_next() file_name = dir.get_next()
dir.list_dir_end() dir.list_dir_end()
@ -276,7 +277,8 @@ func populate_layouts_submenu() -> void:
layouts_submenu.clear() # Does not do anything if it's called for the first time layouts_submenu.clear() # Does not do anything if it's called for the first time
layouts_submenu.add_item("Manage Layouts", 0) layouts_submenu.add_item("Manage Layouts", 0)
for layout in layouts: for layout in layouts:
layouts_submenu.add_radio_check_item(layout[0]) var layout_name := layout.resource_path.get_basename().get_file()
layouts_submenu.add_radio_check_item(layout_name)
func _setup_image_menu() -> void: func _setup_image_menu() -> void:
@ -516,8 +518,8 @@ func window_menu_id_pressed(id: int) -> void:
Global.WindowMenu.WINDOW_OPACITY: Global.WindowMenu.WINDOW_OPACITY:
_popup_dialog(window_opacity_dialog) _popup_dialog(window_opacity_dialog)
Global.WindowMenu.MOVABLE_PANELS: Global.WindowMenu.MOVABLE_PANELS:
ui.tabs_visible = !ui.tabs_visible main_ui.tabs_visible = !main_ui.tabs_visible
window_menu.set_item_checked(id, ui.tabs_visible) window_menu.set_item_checked(id, main_ui.tabs_visible)
Global.WindowMenu.ZEN_MODE: Global.WindowMenu.ZEN_MODE:
_toggle_zen_mode() _toggle_zen_mode()
Global.WindowMenu.FULLSCREEN_MODE: Global.WindowMenu.FULLSCREEN_MODE:
@ -555,15 +557,9 @@ func _snap_to_submenu_id_pressed(id: int) -> void:
func _panels_submenu_id_pressed(id: int) -> void: func _panels_submenu_id_pressed(id: int) -> void:
if zen_mode: if zen_mode:
return return
var element_visible := panels_submenu.is_item_checked(id) var element_visible := panels_submenu.is_item_checked(id)
ui.set_control_hidden(ui_elements[id], element_visible) main_ui.set_control_hidden(ui_elements[id], element_visible)
panels_submenu.set_item_checked(id, !element_visible) panels_submenu.set_item_checked(id, !element_visible)
if ui.tabs_visible == false:
ui.tabs_visible = true
await get_tree().process_frame
await get_tree().process_frame
ui.tabs_visible = false
func _layouts_submenu_id_pressed(id: int) -> void: func _layouts_submenu_id_pressed(id: int) -> void:
@ -577,13 +573,13 @@ func set_layout(id: int) -> void:
if id >= layouts.size(): if id >= layouts.size():
id = 0 id = 0
selected_layout = id selected_layout = id
ui.layout = layouts[id][1].clone() # Clone is needed to avoid modifying premade layouts main_ui.layout = layouts[id].clone() # Clone is needed to avoid modifying premade layouts
for i in layouts.size(): for i in layouts.size():
var offset := i + 1 var offset := i + 1
layouts_submenu.set_item_checked(offset, offset == (id + 1)) layouts_submenu.set_item_checked(offset, offset == (id + 1))
for i in ui_elements.size(): for i in ui_elements.size():
var is_hidden := ui.is_control_hidden(ui_elements[i]) var is_hidden := main_ui.is_control_hidden(ui_elements[i])
panels_submenu.set_item_checked(i, !is_hidden) panels_submenu.set_item_checked(i, !is_hidden)
if zen_mode: # Turn zen mode off if zen_mode: # Turn zen mode off
@ -591,12 +587,6 @@ func set_layout(id: int) -> void:
zen_mode = false zen_mode = false
window_menu.set_item_checked(Global.WindowMenu.ZEN_MODE, false) window_menu.set_item_checked(Global.WindowMenu.ZEN_MODE, false)
# Hacky but without 2 idle frames it doesn't work properly. Should be replaced eventually
await get_tree().process_frame
await get_tree().process_frame
# Call set_tabs_visible to keep tabs visible if there are 2 or more in the same panel
ui.tabs_visible = ui.tabs_visible
func _toggle_greyscale_view() -> void: func _toggle_greyscale_view() -> void:
Global.greyscale_view = !Global.greyscale_view Global.greyscale_view = !Global.greyscale_view
@ -665,7 +655,7 @@ func _toggle_zen_mode() -> void:
continue continue
if !panels_submenu.is_item_checked(i): if !panels_submenu.is_item_checked(i):
continue continue
ui.set_control_hidden(ui_elements[i], !zen_mode) main_ui.set_control_hidden(ui_elements[i], !zen_mode)
Global.control.find_child("TabsContainer").visible = zen_mode Global.control.find_child("TabsContainer").visible = zen_mode
zen_mode = !zen_mode zen_mode = !zen_mode
window_menu.set_item_checked(Global.WindowMenu.ZEN_MODE, zen_mode) window_menu.set_item_checked(Global.WindowMenu.ZEN_MODE, zen_mode)