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

Fix previews (#811)

* Fix move tool preview (without selection)

* typo

* Dont snap if transformation hasn't started

* Added a can_layer_get_drawn() check

* Formatting

* remove useless line

* Formatting (Again cause i am DUMB)

* Formatting (Again cause i am DUMB)

* Better Code
This commit is contained in:
Variable 2023-01-14 21:09:46 +05:00 committed by GitHub
parent 7dc0af21e7
commit facabc1143
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 15 deletions

View file

@ -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

View file

@ -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:
@ -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:
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)