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

Minor code cleanups

This commit is contained in:
Manolis Papadeas 2021-11-06 17:23:54 +02:00
parent 87261e93c6
commit 056cb76a46
2 changed files with 12 additions and 17 deletions

View file

@ -25,7 +25,7 @@ func _ready() -> void:
Global.zoom_level_spinbox.get_child(0).connect("focus_exited", self, "zoom_focus_exited") Global.zoom_level_spinbox.get_child(0).connect("focus_exited", self, "zoom_focus_exited")
func zoom_label_clicked(event :InputEvent): func zoom_label_clicked(event :InputEvent) -> void:
if event is InputEventMouseButton and event.button_index == BUTTON_LEFT: if event is InputEventMouseButton and event.button_index == BUTTON_LEFT:
if event.doubleclick: if event.doubleclick:
Global.zoom_level_label.visible = false Global.zoom_level_label.visible = false
@ -35,12 +35,12 @@ func zoom_label_clicked(event :InputEvent):
Global.zoom_level_spinbox.get_child(0).grab_focus() #since the actual lineedit is the first child of spinbox Global.zoom_level_spinbox.get_child(0).grab_focus() #since the actual lineedit is the first child of spinbox
func zoom_value_changed(value): func zoom_value_changed(value) -> void:
if name == "Camera2D": if name == "Camera2D":
zoom_camera_percent(value) zoom_camera_percent(value)
func zoom_focus_exited(): func zoom_focus_exited() -> void:
if Global.zoom_level_spinbox.value != round(100 / zoom.x): #If user pressed enter while editing if Global.zoom_level_spinbox.value != round(100 / zoom.x): #If user pressed enter while editing
if name == "Camera2D": if name == "Camera2D":
zoom_camera_percent(Global.zoom_level_spinbox.value) zoom_camera_percent(Global.zoom_level_spinbox.value)
@ -207,7 +207,8 @@ func zoom_camera(dir : int) -> void:
offset = offset + (-0.5 * viewport_size + mouse_pos) * (prev_zoom - zoom) offset = offset + (-0.5 * viewport_size + mouse_pos) * (prev_zoom - zoom)
zoom_changed() zoom_changed()
func zoom_camera_percent(value :float):
func zoom_camera_percent(value : float) -> void:
var percent :float = (100.0 / value) var percent :float = (100.0 / value)
var new_zoom = Vector2(percent, percent) var new_zoom = Vector2(percent, percent)
if Global.smooth_zoom: if Global.smooth_zoom:
@ -217,6 +218,7 @@ func zoom_camera_percent(value :float):
zoom = new_zoom zoom = new_zoom
zoom_changed() zoom_changed()
func zoom_changed() -> void: func zoom_changed() -> void:
update_transparent_checker_offset() update_transparent_checker_offset()
if name == "Camera2D": if name == "Camera2D":

View file

@ -8,12 +8,12 @@ enum ImageMenuId {SCALE_IMAGE, CENTRALIZE_IMAGE, CROP_IMAGE, RESIZE_CANVAS, FLIP
enum SelectMenuId {SELECT_ALL, CLEAR_SELECTION, INVERT} enum SelectMenuId {SELECT_ALL, CLEAR_SELECTION, INVERT}
enum HelpMenuId {VIEW_SPLASH_SCREEN, ONLINE_DOCS, ISSUE_TRACKER, OPEN_LOGS_FOLDER, CHANGELOG, ABOUT_PIXELORAMA} enum HelpMenuId {VIEW_SPLASH_SCREEN, ONLINE_DOCS, ISSUE_TRACKER, OPEN_LOGS_FOLDER, CHANGELOG, ABOUT_PIXELORAMA}
var file_menu_button : MenuButton onready var file_menu_button : MenuButton = find_node("FileMenu")
var edit_menu_button : MenuButton onready var edit_menu_button : MenuButton = find_node("EditMenu")
var view_menu_button : MenuButton onready var view_menu_button : MenuButton = find_node("ViewMenu")
var image_menu_button : MenuButton onready var image_menu_button : MenuButton = find_node("ImageMenu")
var select_menu_button : MenuButton onready var select_menu_button : MenuButton = find_node("SelectMenu")
var help_menu_button : MenuButton onready var help_menu_button : MenuButton = find_node("HelpMenu")
var file_menu : PopupMenu var file_menu : PopupMenu
var view_menu : PopupMenu var view_menu : PopupMenu
@ -21,13 +21,6 @@ var zen_mode := false
func _ready() -> void: func _ready() -> void:
file_menu_button = find_node("FileMenu")
edit_menu_button = find_node("EditMenu")
view_menu_button = find_node("ViewMenu")
image_menu_button = find_node("ImageMenu")
select_menu_button = find_node("SelectMenu")
help_menu_button = find_node("HelpMenu")
setup_file_menu() setup_file_menu()
setup_edit_menu() setup_edit_menu()
setup_view_menu() setup_view_menu()