Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix move tool multi-cel previews #811

Merged
merged 9 commits into from
Jan 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions src/Tools/Move.gd
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,20 @@ func _input(event: InputEvent) -> void:
var grid_size := Vector2(Global.grid_width, Global.grid_height)
_offset = _offset.snapped(grid_size)
if Global.current_project.has_selection:
var prev_pos = selection_node.big_bounding_rectangle.position
selection_node.big_bounding_rectangle.position = prev_pos.snapped(grid_size)
# The First time transform_snap_grid is enabled then _snap_position() is not called
# and selection had wrong offset so i chose to do selection offsetting here
var grid_offset = Vector2(Global.grid_offset_x, Global.grid_offset_y)
grid_offset = Vector2(
fmod(grid_offset.x, grid_size.x), fmod(grid_offset.y, grid_size.y)
)
selection_node.big_bounding_rectangle.position += grid_offset
selection_node.marching_ants_outline.offset += (
selection_node.big_bounding_rectangle.position
- prev_pos
)
if selection_node.is_moving_content:
var prev_pos = selection_node.big_bounding_rectangle.position
selection_node.big_bounding_rectangle.position = prev_pos.snapped(grid_size)
# The First time transform_snap_grid is enabled then _snap_position() is not called
# and selection had wrong offset so i chose to do selection offsetting here
var grid_offset = Vector2(Global.grid_offset_x, Global.grid_offset_y)
grid_offset = Vector2(
fmod(grid_offset.x, grid_size.x), fmod(grid_offset.y, grid_size.y)
)
selection_node.big_bounding_rectangle.position += grid_offset
selection_node.marching_ants_outline.offset += (
selection_node.big_bounding_rectangle.position
- prev_pos
)
elif event.is_action_released("transform_snap_grid"):
_snap_to_grid = false

Expand Down
9 changes: 7 additions & 2 deletions src/UI/Canvas/Canvas.gd
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func _draw() -> void:
Global.small_preview_viewport.get_child(0).get_node("CanvasPreview").update()

var current_cels: Array = Global.current_project.frames[Global.current_project.current_frame].cels
var current_layer: int = Global.current_project.current_layer
var position_tmp := position
var scale_tmp := scale
if Global.mirror_view:
Expand All @@ -45,7 +44,13 @@ func _draw() -> void:
continue
var modulate_color := Color(1, 1, 1, current_cels[i].opacity)
if Global.current_project.layers[i].is_visible_in_hierarchy():
if i == current_layer:
var selected_layers = []
if move_preview_location != Vector2.ZERO:
for cel_pos in Global.current_project.selected_cels:
if cel_pos[0] == Global.current_project.current_frame:
Variable-ind marked this conversation as resolved.
Show resolved Hide resolved
Variable-ind marked this conversation as resolved.
Show resolved Hide resolved
if Global.current_project.layers[cel_pos[1]].can_layer_get_drawn():
selected_layers.append(cel_pos[1])
if i in selected_layers:
draw_texture(current_cels[i].image_texture, move_preview_location, modulate_color)
else:
draw_texture(current_cels[i].image_texture, Vector2.ZERO, modulate_color)
Expand Down