tool extends PanelContainer class_name SummerDayCanvas var scene: SummerDayScene var canvas_state := SummerDayCanvasState.new() var tool_pool := SummerDayCanvasToolPool.new() var tool_context: SummerDayToolContext # Provided by plugin root. func _ready(): tool_context.canvas_state = canvas_state canvas_state.connect("view_transform_changed", $Render/BackgroundLayer/EmptyCanvasLayer, "_on_view_transform_changed") func _input(event): var allow_pass = false var pos = event.get("position") if pos == null: allow_pass = true else: if get_rect().has_point(get_local_mouse_position()): allow_pass = true if allow_pass: tool_pool.run_most_prior(event, tool_context) func _on_SummerDay_scene_changed(new_scene): scene = new_scene canvas_state.update_fill_transform(scene) scene.connect("aspect_ratio_changed", self, "_on_scene_aspect_ratio_changed") $Render/Label.text = str(scene) + "\n" + str(scene.aspect_ratio) $Render/BackgroundLayer/EmptyCanvasLayer.update_size(scene) canvas_state.update_fill_transform(scene) func _on_Canvas_resized(): canvas_state.rect_size = rect_size canvas_state.update_fill_transform(scene) func _on_scene_aspect_ratio_changed(new_aspect_ratio): $Render/BackgroundLayer/EmptyCanvasLayer.update_size(scene) canvas_state.update_fill_transform(scene)