diff --git a/src/Autoload/Global.gd b/src/Autoload/Global.gd index 79b60235f..af1b03e1c 100644 --- a/src/Autoload/Global.gd +++ b/src/Autoload/Global.gd @@ -96,8 +96,6 @@ var onion_skinning := false var onion_skinning_past_rate := 1.0 var onion_skinning_future_rate := 1.0 var onion_skinning_blue_red := false -var past_above_canvas := true -var future_above_canvas := true # Palettes var palettes := {} diff --git a/src/UI/Canvas/Canvas.gd b/src/UI/Canvas/Canvas.gd index a8c9c612a..f97a7da5f 100644 --- a/src/UI/Canvas/Canvas.gd +++ b/src/UI/Canvas/Canvas.gd @@ -19,6 +19,10 @@ onready var previews = $Previews # Called when the node enters the scene tree for the first time. func _ready() -> void: + $OnionPast.type = $OnionPast.PAST + $OnionPast.blue_red_color = Color.blue + $OnionFuture.type = $OnionFuture.FUTURE + $OnionFuture.blue_red_color = Color.red var frame: Frame = new_empty_frame(true) Global.current_project.frames.append(frame) yield(get_tree(), "idle_frame") diff --git a/src/UI/Canvas/Canvas.tscn b/src/UI/Canvas/Canvas.tscn index 5f0e582e5..92d2162ec 100644 --- a/src/UI/Canvas/Canvas.tscn +++ b/src/UI/Canvas/Canvas.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=16 format=2] +[gd_scene load_steps=15 format=2] [ext_resource path="res://src/UI/Canvas/Canvas.gd" type="Script" id=1] [ext_resource path="res://src/UI/Canvas/Grid.gd" type="Script" id=2] @@ -10,8 +10,7 @@ [ext_resource path="res://src/UI/Canvas/Selection.gd" type="Script" id=8] [ext_resource path="res://src/Shaders/MarchingAntsOutline.shader" type="Shader" id=9] [ext_resource path="res://src/Shaders/AutoInvertColors.shader" type="Shader" id=10] -[ext_resource path="res://src/UI/Canvas/OnionFuture.gd" type="Script" id=11] -[ext_resource path="res://src/UI/Canvas/OnionPast.gd" type="Script" id=12] +[ext_resource path="res://src/UI/Canvas/OnionSkinning.gd" type="Script" id=12] [sub_resource type="CanvasItemMaterial" id=1] blend_mode = 4 @@ -71,4 +70,4 @@ script = ExtResource( 7 ) script = ExtResource( 12 ) [node name="OnionFuture" type="Node2D" parent="."] -script = ExtResource( 11 ) +script = ExtResource( 12 ) diff --git a/src/UI/Canvas/OnionFuture.gd b/src/UI/Canvas/OnionFuture.gd deleted file mode 100644 index 4b0b01abc..000000000 --- a/src/UI/Canvas/OnionFuture.gd +++ /dev/null @@ -1,22 +0,0 @@ -extends Node2D - - -func _draw() -> void: - if Global.onion_skinning: - if Global.onion_skinning_future_rate > 0: - var color : Color - if Global.onion_skinning_blue_red: - color = Color.red - else: - color = Color.white - for i in range(1, Global.onion_skinning_future_rate + 1): - if Global.current_project.current_frame < Global.current_project.frames.size() - i: - var layer_i := 0 - for layer in Global.current_project.frames[Global.current_project.current_frame + i].cels: - if Global.current_project.layers[layer_i].visible: - #ignore layer if it has "onion_ignore" in its name (case in-sensitive). - if not "ignore_onion" in Global.current_project.layers[layer_i].name.to_lower(): - color.a = 0.6 / i - draw_texture(layer.image_texture, Vector2.ZERO, color) - update() - layer_i += 1 diff --git a/src/UI/Canvas/OnionPast.gd b/src/UI/Canvas/OnionPast.gd deleted file mode 100644 index a9c7fa406..000000000 --- a/src/UI/Canvas/OnionPast.gd +++ /dev/null @@ -1,22 +0,0 @@ -extends Node2D - - -func _draw() -> void: - if Global.onion_skinning: - if Global.onion_skinning_past_rate > 0: - var color: Color - if Global.onion_skinning_blue_red: - color = Color.blue - else: - color = Color.white - for i in range(1, Global.onion_skinning_past_rate + 1): - if Global.current_project.current_frame >= i: - var layer_i := 0 - for layer in Global.current_project.frames[Global.current_project.current_frame - i].cels: - if Global.current_project.layers[layer_i].visible: - #ignore layer if it has "onion_ignore" in its name (case in-sensitive). - if not "ignore_onion" in Global.current_project.layers[layer_i].name.to_lower(): - color.a = 0.6 / i - draw_texture(layer.image_texture, Vector2.ZERO, color) - update() - layer_i += 1 diff --git a/src/UI/Canvas/OnionSkinning.gd b/src/UI/Canvas/OnionSkinning.gd new file mode 100644 index 000000000..c31cb1714 --- /dev/null +++ b/src/UI/Canvas/OnionSkinning.gd @@ -0,0 +1,38 @@ +extends Node2D + +enum { PAST, FUTURE } + +var type := PAST +var blue_red_color := Color.blue +var rate := Global.onion_skinning_past_rate + + +func _draw() -> void: + if !Global.onion_skinning: + return + + rate = Global.onion_skinning_past_rate if type == PAST else Global.onion_skinning_future_rate + if rate > 0: + var color: Color + if Global.onion_skinning_blue_red: + color = blue_red_color + else: + color = Color.white + for i in range(1, rate + 1): + var change = Global.current_project.current_frame + if type == PAST: + change -= i + else: + change += i + if change == clamp(change, 0, Global.current_project.frames.size() - 1): + var layer_i := 0 + for layer in Global.current_project.frames[change].cels: + if Global.current_project.layers[layer_i].visible: + # Ignore layer if it has "onion_ignore" in its name (case in-sensitive) + if not ( + "ignore_onion" + in Global.current_project.layers[layer_i].name.to_lower() + ): + color.a = 0.6 / i + draw_texture(layer.image_texture, Vector2.ZERO, color) + layer_i += 1 diff --git a/src/UI/Timeline/AnimationTimeline.gd b/src/UI/Timeline/AnimationTimeline.gd index 7fefcc44f..680e998ee 100644 --- a/src/UI/Timeline/AnimationTimeline.gd +++ b/src/UI/Timeline/AnimationTimeline.gd @@ -9,6 +9,8 @@ var is_mouse_hover := false var cel_size := 36 setget cel_size_changed var min_cel_size := 36 var max_cel_size := 144 +var past_above_canvas := true +var future_above_canvas := true var timeline_scroll: ScrollContainer var tag_scroll_container: ScrollContainer @@ -528,13 +530,13 @@ func _on_BlueRedMode_toggled(button_pressed: bool) -> void: func _on_PastPlacement_item_selected(index): - Global.past_above_canvas = (index == 0) - Global.canvas.get_node("OnionPast").set("show_behind_parent", !Global.past_above_canvas) + past_above_canvas = (index == 0) + Global.canvas.get_node("OnionPast").set("show_behind_parent", !past_above_canvas) func _on_FuturePlacement_item_selected(index): - Global.future_above_canvas = (index == 0) - Global.canvas.get_node("OnionFuture").set("show_behind_parent", !Global.future_above_canvas) + future_above_canvas = (index == 0) + Global.canvas.get_node("OnionFuture").set("show_behind_parent", !future_above_canvas) # Layer buttons diff --git a/src/UI/Timeline/AnimationTimeline.tscn b/src/UI/Timeline/AnimationTimeline.tscn index 533ae6509..41d504743 100644 --- a/src/UI/Timeline/AnimationTimeline.tscn +++ b/src/UI/Timeline/AnimationTimeline.tscn @@ -950,11 +950,11 @@ margin_bottom = 140.0 alignment = 2 [node name="Label" type="Label" parent="OnionSkinningSettings/OnionSkinningButtons/PastPlace"] -margin_left = 30.0 +margin_left = 34.0 margin_top = 3.0 margin_right = 171.0 margin_bottom = 17.0 -text = "Past Skin Placement : " +text = "Past Skin Placement: " align = 2 valign = 1 @@ -962,6 +962,7 @@ valign = 1 margin_left = 175.0 margin_right = 292.0 margin_bottom = 20.0 +mouse_default_cursor_shape = 2 text = "Above Canvas" items = [ "Above Canvas", null, false, 0, null, "Below Canvas", null, false, 1, null ] selected = 0 @@ -976,11 +977,11 @@ margin_bottom = 164.0 alignment = 2 [node name="Label" type="Label" parent="OnionSkinningSettings/OnionSkinningButtons/FuturePlace"] -margin_left = 16.0 +margin_left = 20.0 margin_top = 3.0 margin_right = 171.0 margin_bottom = 17.0 -text = "Future Skin Placement : " +text = "Future Skin Placement: " align = 2 valign = 1 @@ -988,6 +989,7 @@ valign = 1 margin_left = 175.0 margin_right = 292.0 margin_bottom = 20.0 +mouse_default_cursor_shape = 2 text = "Above Canvas" items = [ "Above Canvas", null, false, 0, null, "Below Canvas", null, false, 1, null ] selected = 0 @@ -998,7 +1000,7 @@ margin_right = 292.0 margin_bottom = 233.0 custom_colors/font_color = Color( 0.333333, 0.901961, 0.462745, 1 ) text = "Note: -If you want a layer to ignore Onion-skinning simply add \"ignore_onion\" in its name +If you want a layer to ignore onion skinning simply add \"ignore_onion\" in its name (it is case-insensitive)" align = 1 valign = 1