2021-11-18 17:23:37 +01:00
tool
2021-11-21 11:46:04 +01:00
extends PanelContainer
2021-11-18 17:23:37 +01:00
class_name SummerDayCanvas
var scene : SummerDayScene
2021-11-20 11:38:50 +01:00
var canvas_state : = SummerDayCanvasState . new ( )
2021-11-21 11:46:04 +01:00
var tool_pool : = SummerDayCanvasToolPool . new ( )
var tool_context : SummerDayToolContext # Provided by plugin root.
2021-11-18 17:23:37 +01:00
func _ready ( ) :
2021-11-21 11:46:04 +01:00
tool_context . canvas_state = canvas_state
2021-11-20 11:38:50 +01:00
canvas_state . connect ( " view_transform_changed " ,
2021-11-21 11:46:04 +01:00
$ Render / BackgroundLayer / EmptyCanvasLayer , " _on_view_transform_changed " )
2021-11-18 17:23:37 +01:00
2021-11-25 18:26:56 +01:00
func _gui_input ( event ) :
tool_pool . run_most_prior ( event , tool_context )
2021-11-21 11:46:04 +01:00
func _input ( event ) :
2021-11-25 18:26:56 +01:00
if event is InputEventScreenTouch and ! event . is_pressed ( ) :
2021-11-21 11:46:04 +01:00
tool_pool . run_most_prior ( event , tool_context )
2021-11-18 17:23:37 +01:00
func _on_SummerDay_scene_changed ( new_scene ) :
scene = new_scene
2021-11-20 11:38:50 +01:00
canvas_state . update_fill_transform ( scene )
2021-11-19 21:05:44 +01:00
scene . connect ( " aspect_ratio_changed " ,
self , " _on_scene_aspect_ratio_changed " )
2021-11-21 11:46:04 +01:00
$ Render / Label . text = str ( scene ) + " \n " + str ( scene . aspect_ratio )
$ Render / BackgroundLayer / EmptyCanvasLayer . update_size ( scene )
canvas_state . update_fill_transform ( scene )
2021-11-18 17:23:37 +01:00
func _on_Canvas_resized ( ) :
2021-11-20 11:38:50 +01:00
canvas_state . rect_size = rect_size
canvas_state . update_fill_transform ( scene )
2021-11-19 21:05:44 +01:00
func _on_scene_aspect_ratio_changed ( new_aspect_ratio ) :
2021-11-21 11:46:04 +01:00
$ Render / BackgroundLayer / EmptyCanvasLayer . update_size ( scene )
2021-11-20 11:38:50 +01:00
canvas_state . update_fill_transform ( scene )