Layers keep drawing outside their rect: ports and lit threads vanished for cards at negative or far coordinates

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
tachyonwolf 2026-11-21 08:53:15 -06:00
parent 5c69acbba0
commit 0a72c2b12c
5 changed files with 14 additions and 8 deletions

View file

@ -229,6 +229,16 @@ func fit() -> void:
world.position = Vector2(maxf(8.0, (size.x - bounds.size.x * zoom) / 2.0), 8.0) - bounds.position * zoom
## Makes a layer cover the whole world. A Control's canvas item is clipped to
## its rect, and the world reaches past it (cards can sit at negative
## coordinates), so the clip is switched off: nothing a layer draws is lost.
static func cover_world(layer: Control) -> void:
layer.size = Vector2(WORLD_SIZE, WORLD_SIZE)
# Control sets its clip rect on entering the tree and on every resize, so
# switch it off again whenever the layer draws.
layer.draw.connect(func() -> void: RenderingServer.canvas_item_set_custom_rect(layer.get_canvas_item(), false))
## A control's rect in world coordinates. (Control.get_global_rect ignores the
## world's zoom for the size, so it is wrong whenever the board is not at 100%.)
func world_rect_of(control: Control) -> Rect2:

View file

@ -30,8 +30,7 @@ var _flash_left := 0.0
func _init() -> void:
mouse_filter = MOUSE_FILTER_IGNORE
# Controls only draw inside their own rect, so cover the whole world.
size = Vector2(BoardView.WORLD_SIZE, BoardView.WORLD_SIZE)
BoardView.cover_world(self)
_shadow = Style.box(Color(0, 0, 0, 0.22), 10)
_ring = Style.box(Color(0, 0, 0, 0), 14)
_ring.draw_center = false

View file

@ -11,8 +11,7 @@ var frozen: Dictionary = {}
func _init() -> void:
mouse_filter = MOUSE_FILTER_IGNORE
# Controls only draw inside their own rect, so cover the whole world.
size = Vector2(BoardView.WORLD_SIZE, BoardView.WORLD_SIZE)
BoardView.cover_world(self)
func _process(_delta: float) -> void:

View file

@ -44,8 +44,7 @@ var _batch := PipeBatch.new(self)
func _init() -> void:
mouse_filter = MOUSE_FILTER_IGNORE
# Controls only draw inside their own rect, so cover the whole world.
size = Vector2(BoardView.WORLD_SIZE, BoardView.WORLD_SIZE)
BoardView.cover_world(self)
_label_box = Style.box(Style.CARD, 7, [6, 1, 6, 2])
Style.bordered(_label_box, 1, Style.THREAD_DARK)
_lit_label_box = Style.box(Style.LIT, 7, [6, 1, 6, 2])

View file

@ -24,8 +24,7 @@ var _stack: Array = []
func _init() -> void:
mouse_filter = MOUSE_FILTER_STOP
mouse_default_cursor_shape = CURSOR_CROSS
# Controls only draw inside their own rect, so cover the whole world.
size = Vector2(BoardView.WORLD_SIZE, BoardView.WORLD_SIZE)
BoardView.cover_world(self)
## Redraws only when the board's geometry changed (BoardView.geometry_rev),