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

Improved "Fit to Frame" button

Also set the default mode for the right zoom tool to zoom out.
This commit is contained in:
OverloadedOrama 2020-04-16 18:34:57 +03:00
parent 42dbd31c7a
commit 4068330e26
4 changed files with 43 additions and 50 deletions

File diff suppressed because one or more lines are too long

View file

@ -507,8 +507,8 @@ func _input(event : InputEvent) -> void:
func camera_zoom() -> void:
# Set camera zoom based on the sprite size
var bigger = max(size.x, size.y)
var zoom_max := Vector2(bigger, bigger) * 0.01
var bigger_canvas_axis = max(size.x, size.y)
var zoom_max := Vector2(bigger_canvas_axis, bigger_canvas_axis) * 0.01
if zoom_max > Vector2.ONE:
Global.camera.zoom_max = zoom_max
Global.camera2.zoom_max = zoom_max
@ -518,9 +518,10 @@ func camera_zoom() -> void:
Global.camera2.zoom_max = Vector2.ONE
Global.camera_preview.zoom_max = Vector2.ONE
Global.camera.zoom = Vector2(bigger, bigger) * 0.002
Global.camera2.zoom = Vector2(bigger, bigger) * 0.002
Global.camera_preview.zoom = Vector2(bigger, bigger) * 0.007
var smaller_viewport_axis = min(Global.main_viewport.rect_size.x, Global.main_viewport.rect_size.y)
Global.camera.zoom = Vector2(bigger_canvas_axis, bigger_canvas_axis) / smaller_viewport_axis
Global.camera2.zoom = Vector2(bigger_canvas_axis, bigger_canvas_axis) * 0.002
Global.camera_preview.zoom = Vector2(bigger_canvas_axis, bigger_canvas_axis) * 0.007
Global.zoom_level_label.text = str(round(100 / Global.camera.zoom.x)) + " %"
# Set camera offset to the center of canvas

View file

@ -115,7 +115,7 @@ var right_color_picker_for := 1
# 0 for zoom in, 1 for zoom out
var left_zoom_mode := 0
var right_zoom_mode := 0
var right_zoom_mode := 1
# warning-ignore:unused_class_variable
var left_horizontal_mirror := false

View file

@ -659,8 +659,9 @@ func _on_RightZoomModeOptions_item_selected(ID : int) -> void:
func _on_FitToFrameButton_pressed() -> void:
var bigger = max(Global.canvas.size.x, Global.canvas.size.y)
Global.camera.zoom = (Vector2(bigger, bigger) * 0.004) / (Global.main_viewport.rect_size.x * 0.002)
var bigger_canvas_axis = max(Global.canvas.size.x, Global.canvas.size.y)
var smaller_viewport_axis = min(Global.main_viewport.rect_size.x, Global.main_viewport.rect_size.y)
Global.camera.zoom = Vector2(bigger_canvas_axis, bigger_canvas_axis) / smaller_viewport_axis
Global.camera.offset = Global.canvas.size / 2
Global.zoom_level_label.text = str(round(100 / Global.camera.zoom.x)) + " %"