Skip to content

Commit

Permalink
Darken blocks out of dragged scope
Browse files Browse the repository at this point in the history
Darken the block trees that cannot be snapped to by the currently dragged block.
  • Loading branch information
wnbaum committed Jun 25, 2024
1 parent 9bec376 commit be7c709
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions addons/block_code/drag_manager/drag_manager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ func drag_block(block: Block, copied_from: Block = null):
drag_offset = get_local_mouse_position() - block.position
dragging = block

if block.scope != "":
_block_canvas.set_scope(block.scope)


func copy_block(block: Block) -> Block:
return block.duplicate(DUPLICATE_USE_INSTANTIATION) # use instantiation
Expand Down Expand Up @@ -163,6 +166,8 @@ func drag_ended():
else:
dragging.queue_free()

_block_canvas.release_scope()

dragging = null
block_dropped.emit()

Expand Down
17 changes: 17 additions & 0 deletions addons/block_code/ui/block_canvas/block_canvas.gd
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,20 @@ func find_snaps(node: Node) -> Array:
snaps.append_array(find_snaps(c))

return snaps


func set_scope(scope: String):
for block in _window.get_children():
if block is EntryBlock:
var entry_block = block as EntryBlock

if scope != entry_block.get_entry_statement():
entry_block.modulate = Color(0.5, 0.5, 0.5, 1)


func release_scope():
for block in _window.get_children():
if block is EntryBlock:
var entry_block = block as EntryBlock

entry_block.modulate = Color.WHITE

0 comments on commit be7c709

Please sign in to comment.