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

Remove Global.canvas from the canvas' children

This commit is contained in:
Emmanouil Papadeas 2024-10-11 14:08:43 +03:00
parent bd68f3d20b
commit fc695a038e
7 changed files with 28 additions and 21 deletions

View file

@ -57,8 +57,8 @@ func _ready() -> void:
zoom_slider.value_changed.connect(_zoom_slider_value_changed)
zoom_changed.connect(_zoom_changed)
rotation_changed.connect(_rotation_changed)
viewport_container = get_parent().get_parent()
transparent_checker = get_parent().get_node("TransparentChecker")
viewport_container = get_viewport().get_parent()
transparent_checker = get_viewport().get_node("TransparentChecker")
update_transparent_checker_offset()
@ -160,7 +160,7 @@ func fit_to_frame(size: Vector2) -> void:
size.x = maxf(absf(a.x - d.x), absf(b.x - c.x))
size.y = maxf(absf(a.y - d.y), absf(b.y - c.y))
viewport_container = get_parent().get_parent()
viewport_container = get_viewport().get_parent()
var h_ratio := viewport_container.size.x / size.x
var v_ratio := viewport_container.size.y / size.y
var ratio := minf(h_ratio, v_ratio)

View file

@ -30,6 +30,8 @@ var gizmo_rot_x := PackedVector2Array()
var gizmo_rot_y := PackedVector2Array()
var gizmo_rot_z := PackedVector2Array()
@onready var canvas := get_parent() as Canvas
func _ready() -> void:
set_process_input(false)
@ -188,13 +190,13 @@ func _draw() -> void:
# Draw bounding box outline
draw_multiline(points, selected_color, 0.5)
if object.applying_gizmos == Cel3DObject.Gizmos.X_ROT:
draw_line(gizmos_origin, Global.canvas.current_pixel, Color.RED)
draw_line(gizmos_origin, canvas.current_pixel, Color.RED)
continue
elif object.applying_gizmos == Cel3DObject.Gizmos.Y_ROT:
draw_line(gizmos_origin, Global.canvas.current_pixel, Color.GREEN)
draw_line(gizmos_origin, canvas.current_pixel, Color.GREEN)
continue
elif object.applying_gizmos == Cel3DObject.Gizmos.Z_ROT:
draw_line(gizmos_origin, Global.canvas.current_pixel, Color.BLUE)
draw_line(gizmos_origin, canvas.current_pixel, Color.BLUE)
continue
draw_set_transform(gizmos_origin, 0, draw_scale)
# Draw position arrows

View file

@ -8,6 +8,8 @@ var mode := Global.MeasurementMode.NONE
var apparent_width: float = WIDTH
var rect_bounds: Rect2i
@onready var canvas := get_parent() as Canvas
func _ready() -> void:
font = Themes.get_font()
@ -34,10 +36,10 @@ func _input(_event: InputEvent) -> void:
func _prepare_movement_rect() -> void:
var project := Global.current_project
if project.has_selection:
rect_bounds = Global.canvas.selection.preview_image.get_used_rect()
rect_bounds.position += Vector2i(Global.canvas.selection.big_bounding_rectangle.position)
rect_bounds = canvas.selection.preview_image.get_used_rect()
rect_bounds.position += Vector2i(canvas.selection.big_bounding_rectangle.position)
if !rect_bounds.has_area():
rect_bounds = Global.canvas.selection.big_bounding_rectangle
rect_bounds = canvas.selection.big_bounding_rectangle
return
if rect_bounds.has_area():
return
@ -65,7 +67,7 @@ func _prepare_movement_rect() -> void:
else:
rect_bounds = rect_bounds.merge(used_rect)
if not rect_bounds.has_area():
rect_bounds = Rect2(Vector2.ZERO, project.size)
rect_bounds = Rect2i(Vector2i.ZERO, project.size)
func _draw_move_measurement() -> void:
@ -74,7 +76,7 @@ func _draw_move_measurement() -> void:
dashed_color.a = 0.5
# Draw boundary
var boundary := Rect2i(rect_bounds)
boundary.position += Global.canvas.move_preview_location
boundary.position += canvas.move_preview_location
draw_rect(boundary, line_color, false, apparent_width)
# calculate lines
var top := Vector2(boundary.get_center().x, boundary.position.y)

View file

@ -7,6 +7,8 @@ var opacity := 0.6
var blue_red_color := Color.BLUE
var rate := Global.onion_skinning_past_rate
@onready var canvas := get_parent() as Canvas
func _draw() -> void:
var project := Global.current_project
@ -36,9 +38,7 @@ func _draw() -> void:
if not (layer.name.to_lower().ends_with("_io")):
color.a = opacity / i
if [change, layer_i] in project.selected_cels:
draw_texture(
cel.image_texture, Global.canvas.move_preview_location, color
)
draw_texture(cel.image_texture, canvas.move_preview_location, color)
else:
draw_texture(cel.image_texture, Vector2.ZERO, color)
layer_i += 1

View file

@ -43,7 +43,7 @@ var content_pivot := Vector2.ZERO
var mouse_pos_on_gizmo_drag := Vector2.ZERO
var resize_keep_ratio := false
@onready var canvas: Canvas = get_parent()
@onready var canvas := get_parent() as Canvas
@onready var marching_ants_outline: Sprite2D = $MarchingAntsOutline
@ -393,7 +393,7 @@ func resize_selection() -> void:
)
Global.current_project.selection_map_changed()
queue_redraw()
Global.canvas.queue_redraw()
canvas.queue_redraw()
func _gizmo_rotate() -> void:
@ -461,7 +461,7 @@ func move_borders_end() -> void:
else:
Global.current_project.selection_map_changed()
queue_redraw()
Global.canvas.queue_redraw()
canvas.queue_redraw()
func transform_content_start() -> void:
@ -478,7 +478,7 @@ func transform_content_start() -> void:
original_big_bounding_rectangle = big_bounding_rectangle
original_offset = Global.current_project.selection_offset
queue_redraw()
Global.canvas.queue_redraw()
canvas.queue_redraw()
func move_content(move: Vector2) -> void:
@ -522,7 +522,7 @@ func transform_content_confirm() -> void:
angle = 0.0
content_pivot = Vector2.ZERO
queue_redraw()
Global.canvas.queue_redraw()
canvas.queue_redraw()
func transform_content_cancel() -> void:
@ -555,7 +555,7 @@ func transform_content_cancel() -> void:
angle = 0.0
content_pivot = Vector2.ZERO
queue_redraw()
Global.canvas.queue_redraw()
canvas.queue_redraw()
func commit_undo(action: String, undo_data_tmp: Dictionary) -> void:

View file

@ -3,6 +3,8 @@ extends Node2D
var tiles: Tiles
var draw_center := false
@onready var canvas := get_parent() as Canvas
func _draw() -> void:
var positions := get_tile_positions()
@ -16,7 +18,7 @@ func _draw() -> void:
var modulate_color := Color(
tilemode_opacity, tilemode_opacity, tilemode_opacity, tilemode_opacity
) # premultiply alpha blending is applied
var current_frame_texture: Texture2D = Global.canvas.currently_visible_frame.get_texture()
var current_frame_texture := canvas.currently_visible_frame.get_texture()
for pos in positions:
draw_texture(current_frame_texture, pos, modulate_color)

View file

@ -205,6 +205,7 @@ hidden_tabs = {
"Reference Images": true,
"Second Canvas": true
}
windows = {}
save_on_change = false
[sub_resource type="ShaderMaterial" id="2"]