Compare commits
No commits in common. "d7d7fb66ea0b896cf9ae84b930fde7261f9350c8" and "1735ed09fdae31b4750f6dfea271e693c448eb39" have entirely different histories.
d7d7fb66ea
...
1735ed09fd
13 changed files with 40 additions and 156 deletions
|
|
@ -13,7 +13,6 @@ func _init() -> void:
|
|||
await _test_show_less()
|
||||
await _test_add_scrolls_and_focuses()
|
||||
await _test_wheel_zooms()
|
||||
await _test_zoomed_in_anchors()
|
||||
finish()
|
||||
|
||||
|
||||
|
|
@ -166,21 +165,3 @@ func _button(n: Node, prefix: String) -> Button:
|
|||
if found:
|
||||
return found
|
||||
return null
|
||||
|
||||
|
||||
## Zoomed in, a result's dot still sits on its row and shows (the row rect was
|
||||
## once read at 100% scale, hiding dots low in a scrolling list).
|
||||
func _test_zoomed_in_anchors() -> void:
|
||||
var card := main.card_for("road")
|
||||
card.set_user_size(380.0, 120.0)
|
||||
main.board.set_zoom(1.5)
|
||||
await _frames()
|
||||
var last: String = main.data.get_table("road").entries[-1].id
|
||||
var row := card.rows[last] as Control
|
||||
var a := card.anchor_for(last)
|
||||
var expected := card.position.y + (card.get_global_transform().affine_inverse() * row.get_global_position()).y + row.size.y / 2.0
|
||||
var in_list := main.board.world_rect_of(card.list_scroll).intersects(main.board.world_rect_of(row))
|
||||
_check(absf(a["pos"].y - expected) < 1.0 or not in_list, "zoomed in, a result's dot sits on its row: %.1f vs %.1f" % [a["pos"].y, expected])
|
||||
var scroll_rect := main.board.world_rect_of(card.list_scroll)
|
||||
_check(is_equal_approx(scroll_rect.size.y, 120.0), "world_rect_of gives the list's size in world units: %.1f" % scroll_rect.size.y)
|
||||
main.board.set_zoom(1.0)
|
||||
|
|
|
|||
|
|
@ -14,8 +14,6 @@ const FAR_ZOOM := 0.22
|
|||
## roll on a click; their names show as tooltips (CardShield).
|
||||
const COMPACT_ZOOM := 0.45
|
||||
const WORLD_SIZE := 40000.0
|
||||
## How far (screen pixels) from a thread's line a click or hover still picks it.
|
||||
const PIPE_HIT_RADIUS := 12.0
|
||||
|
||||
var main: Main
|
||||
var world: Control
|
||||
|
|
@ -205,11 +203,6 @@ func world_mouse() -> Vector2:
|
|||
return world.get_local_mouse_position()
|
||||
|
||||
|
||||
## The pipe under the mouse, within PIPE_HIT_RADIUS screen pixels of its line.
|
||||
func pipe_under_mouse() -> String:
|
||||
return pipes.pipe_at(world_mouse(), PIPE_HIT_RADIUS / zoom)
|
||||
|
||||
|
||||
func screen_to_world(p: Vector2) -> Vector2:
|
||||
return (p - world.position) / zoom
|
||||
|
||||
|
|
@ -236,22 +229,6 @@ 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:
|
||||
return (world.get_global_transform().affine_inverse() * control.get_global_transform()) * Rect2(Vector2.ZERO, control.size)
|
||||
|
||||
|
||||
## The part of the world the board shows right now.
|
||||
func view_rect() -> Rect2:
|
||||
return Rect2(screen_to_world(Vector2.ZERO), size / zoom)
|
||||
|
|
@ -323,7 +300,7 @@ func _gui_input(ev: InputEvent) -> void:
|
|||
if f is LineEdit or f is TextEdit:
|
||||
f.release_focus()
|
||||
if build_left:
|
||||
var key := pipe_under_mouse() if main.mode == Main.Mode.BUILD else ""
|
||||
var key := pipes.pipe_at(world_mouse(), 11.0) if main.mode == Main.Mode.BUILD else ""
|
||||
if key != "":
|
||||
# The pipe opens in the inspector (Main.open_pipe_options).
|
||||
main.open_pipe_options(key, mb.global_position)
|
||||
|
|
@ -366,7 +343,7 @@ func _gui_input(ev: InputEvent) -> void:
|
|||
MOUSE_BUTTON_RIGHT:
|
||||
if mb.pressed:
|
||||
# A thread under the mouse, else the empty spread.
|
||||
var key := pipe_under_mouse()
|
||||
var key := pipes.pipe_at(world_mouse(), 11.0)
|
||||
var list := Actions.thread(main, key) if key != "" else Actions.background(main, world_mouse())
|
||||
if not list.is_empty():
|
||||
Actions.popup_at(main, list, mb.global_position)
|
||||
|
|
@ -392,7 +369,7 @@ func _gui_input(ev: InputEvent) -> void:
|
|||
elif _panning:
|
||||
world.position += mm.relative
|
||||
elif main.mode == Main.Mode.BUILD:
|
||||
pipes.hover_key = pipe_under_mouse()
|
||||
pipes.hover_key = pipes.pipe_at(world_mouse(), 11.0)
|
||||
mouse_default_cursor_shape = CURSOR_POINTING_HAND if pipes.hover_key != "" else CURSOR_ARROW
|
||||
return
|
||||
var pan := ev as InputEventPanGesture
|
||||
|
|
|
|||
|
|
@ -30,7 +30,8 @@ var _flash_left := 0.0
|
|||
|
||||
func _init() -> void:
|
||||
mouse_filter = MOUSE_FILTER_IGNORE
|
||||
BoardView.cover_world(self)
|
||||
# Controls only draw inside their own rect, so cover the whole world.
|
||||
size = Vector2(BoardView.WORLD_SIZE, BoardView.WORLD_SIZE)
|
||||
_shadow = Style.box(Color(0, 0, 0, 0.22), 10)
|
||||
_ring = Style.box(Color(0, 0, 0, 0), 14)
|
||||
_ring.draw_center = false
|
||||
|
|
|
|||
|
|
@ -276,7 +276,9 @@ func inlet_point() -> Vector2:
|
|||
func anchor_for(tid: String, eid: String) -> Vector2:
|
||||
var row: Control = lit_rows.get(Roller.entry_key(tid, eid))
|
||||
if row != null and row.is_inside_tree():
|
||||
return Vector2(position.x + size.x, main.board.world_rect_of(row).get_center().y)
|
||||
var to_world := main.board.world.get_global_transform().affine_inverse()
|
||||
var r := row.get_global_rect()
|
||||
return Vector2(position.x + size.x, (to_world * (r.position + Vector2(0, r.size.y / 2.0))).y)
|
||||
return Vector2(position.x + size.x, position.y + INLET_Y)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ var frozen: Dictionary = {}
|
|||
|
||||
func _init() -> void:
|
||||
mouse_filter = MOUSE_FILTER_IGNORE
|
||||
BoardView.cover_world(self)
|
||||
# Controls only draw inside their own rect, so cover the whole world.
|
||||
size = Vector2(BoardView.WORLD_SIZE, BoardView.WORLD_SIZE)
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
|
|
|
|||
|
|
@ -107,10 +107,8 @@ func clear() -> void:
|
|||
func _mark_cards() -> void:
|
||||
if main == null:
|
||||
return
|
||||
var kind := str(selection.get("kind", ""))
|
||||
# A selected thread is the selection itself; its source card is not.
|
||||
var tid := str(selection.get("tid", "")) if kind != "pipe" else ""
|
||||
var eid := str(selection.get("eid", "")) if kind == "result" else ""
|
||||
var tid := str(selection.get("tid", ""))
|
||||
var eid := str(selection.get("eid", "")) if str(selection.get("kind", "")) == "result" else ""
|
||||
for c in main.cards.values():
|
||||
var card := c as TableCard
|
||||
if card and card.has_method("set_selected_entry"):
|
||||
|
|
|
|||
|
|
@ -198,8 +198,6 @@ func start_link(tid: String, eid: String) -> void:
|
|||
editing.start_link(tid, eid)
|
||||
func update_link() -> void:
|
||||
editing.update_link()
|
||||
func link_snap_point() -> Variant:
|
||||
return editing.link_snap_point()
|
||||
func finish_link() -> void:
|
||||
editing.finish_link()
|
||||
func is_selected(tid: String) -> bool:
|
||||
|
|
|
|||
|
|
@ -29,8 +29,6 @@ const ADD_KINDS := [
|
|||
]
|
||||
const MENU_FROM_TEMPLATE := 100
|
||||
const MENU_GROUP := 101
|
||||
## How close (screen pixels) a dragged thread must be to a card's input dot to drop on it.
|
||||
const LINK_DROP_RADIUS := 24.0
|
||||
const MENU_SAVE_SELECTION := 102
|
||||
|
||||
|
||||
|
|
@ -258,16 +256,6 @@ func update_link() -> void:
|
|||
_drop_card.set_drop_target(true)
|
||||
|
||||
|
||||
## The input dot a dragged thread would land on if dropped now, or null when
|
||||
## the mouse is not within LINK_DROP_RADIUS of one (the preview snaps to it).
|
||||
func link_snap_point() -> Variant:
|
||||
var card := _card_under_mouse()
|
||||
if card == null or card.table.kind == RollTable.KIND_VARIABLE:
|
||||
return null
|
||||
var mouse := m.board.world.get_local_mouse_position()
|
||||
return card.inlet_point() if card.inlet_point().distance_to(mouse) <= LINK_DROP_RADIUS / m.board.zoom else null
|
||||
|
||||
|
||||
func finish_link() -> void:
|
||||
var over := _card_under_mouse()
|
||||
if is_instance_valid(_drop_card):
|
||||
|
|
@ -298,12 +286,11 @@ func finish_link() -> void:
|
|||
func _card_under_mouse() -> TableCard:
|
||||
if _card_under_mouse_override:
|
||||
return _card_under_mouse_override
|
||||
var mouse := m.board.world.get_local_mouse_position()
|
||||
var reach := LINK_DROP_RADIUS / m.board.zoom
|
||||
var gp := m.get_global_mouse_position()
|
||||
var kids := m.board.cards.get_children()
|
||||
for i in range(kids.size() - 1, -1, -1):
|
||||
var card := kids[i] as TableCard
|
||||
if card and card.visible and (m.board.world_rect_of(card).has_point(mouse) or (card.table.kind != RollTable.KIND_VARIABLE and card.inlet_point().distance_to(mouse) <= reach)):
|
||||
if card and card.visible and card.get_global_rect().has_point(gp):
|
||||
return card
|
||||
return null
|
||||
|
||||
|
|
|
|||
|
|
@ -61,23 +61,15 @@ static func coarse(rid: RID, pts: PackedVector2Array, color: Color, width: float
|
|||
RenderingServer.canvas_item_add_polyline(rid, points, PackedColorArray([color]), width, false)
|
||||
|
||||
|
||||
## The glow selected cards have (TableCardSkin), around a selected thread.
|
||||
static func select_glow(rid: RID, pts: PackedVector2Array) -> void:
|
||||
line(rid, pts, Color(Style.SELECTED, 0.3), 26.0)
|
||||
line(rid, pts, Style.SELECTED, 15.0)
|
||||
|
||||
|
||||
## An unlit thread (as PipeLayer._draw_pipe draws it), in its own canvas item.
|
||||
## `own` is the thread's own colour ("" = the theme's THREAD).
|
||||
func add_pipe(pts: PackedVector2Array, hovered: bool, own: String = "", selected: bool = false) -> void:
|
||||
func add_pipe(pts: PackedVector2Array, hovered: bool, own: String = "") -> void:
|
||||
var rid := item()
|
||||
var color := Color.from_string(own, Style.THREAD) if own != "" else Style.THREAD
|
||||
var dark := color.darkened(0.6) if own != "" else Style.THREAD_DARK
|
||||
if far:
|
||||
coarse(rid, pts, color, 10.0)
|
||||
return
|
||||
if selected:
|
||||
select_glow(rid, pts)
|
||||
if ThreadStrip.active:
|
||||
ThreadStrip.active.add_to(rid, pts, color.lightened(0.35) if hovered else color, dark)
|
||||
ThreadStrip.active.add_pins(item(), pts)
|
||||
|
|
|
|||
|
|
@ -44,7 +44,8 @@ var _batch := PipeBatch.new(self)
|
|||
|
||||
func _init() -> void:
|
||||
mouse_filter = MOUSE_FILTER_IGNORE
|
||||
BoardView.cover_world(self)
|
||||
# Controls only draw inside their own rect, so cover the whole world.
|
||||
size = Vector2(BoardView.WORLD_SIZE, BoardView.WORLD_SIZE)
|
||||
_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])
|
||||
|
|
@ -142,10 +143,7 @@ func _draw() -> void:
|
|||
if not is_ref and not rerouted and e.is_conditional(to):
|
||||
diamonds.append([pts, lit, e.is_otherwise(to)])
|
||||
if lit:
|
||||
if is_ref:
|
||||
lit_refs.append(pts)
|
||||
else:
|
||||
lit_list.append([pts, key])
|
||||
(lit_refs if is_ref else lit_list).append(pts)
|
||||
if not is_ref and not rerouted:
|
||||
var lt := RulesView.pipe_label(e, to, main.data, plain)
|
||||
if lt != "":
|
||||
|
|
@ -161,7 +159,7 @@ func _draw() -> void:
|
|||
elif rerouted:
|
||||
_batch.add_bundle(pts)
|
||||
else:
|
||||
_batch.add_pipe(pts, build and (key == hover_key or key == select_key), str(e.pipe_color.get(to, "")), build and key == select_key)
|
||||
_batch.add_pipe(pts, build and (key == hover_key or key == select_key), str(e.pipe_color.get(to, "")))
|
||||
if not is_ref and not rerouted:
|
||||
var tag := RulesView.pipe_label(e, to, main.data, plain)
|
||||
if tag != "":
|
||||
|
|
@ -169,8 +167,8 @@ func _draw() -> void:
|
|||
# Lit pipes go on top so the path of the last roll reads clearly.
|
||||
for pts in lit_refs:
|
||||
_draw_ref(pts, true)
|
||||
for lit_pipe: Array in lit_list:
|
||||
_draw_pipe(lit_pipe[0], true, false, build and lit_pipe[1] == select_key)
|
||||
for pts in lit_list:
|
||||
_draw_pipe(pts, true, false)
|
||||
for d in diamonds:
|
||||
_draw_diamond(d[0], d[1], d[2])
|
||||
var placed: Array[Rect2] = []
|
||||
|
|
@ -251,13 +249,7 @@ func _draw_diamond(pts: PackedVector2Array, lit: bool, otherwise: bool) -> void:
|
|||
draw_colored_polygon(inner, fill)
|
||||
|
||||
|
||||
func _draw_pipe(pts: PackedVector2Array, lit: bool, hovered: bool, selected: bool = false) -> void:
|
||||
if selected: # the glow selected cards have (TableCardSkin)
|
||||
if ThreadStrip.active and not _batch.far:
|
||||
PipeBatch.select_glow(_batch.item(), pts)
|
||||
else:
|
||||
draw_polyline(pts, Color(Style.SELECTED, 0.3), 26.0, true)
|
||||
draw_polyline(pts, Style.SELECTED, 15.0, true)
|
||||
func _draw_pipe(pts: PackedVector2Array, lit: bool, hovered: bool) -> void:
|
||||
if ThreadStrip.active and not _batch.far:
|
||||
_strip_pipe(pts, lit, hovered)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -5,15 +5,10 @@ extends Control
|
|||
## mode, dragging from an outlet lays a new pipe.
|
||||
## Only the ports themselves take mouse input; everything else passes through.
|
||||
|
||||
## Screen pixels: the most a dot's grab area grows to, and the gap kept
|
||||
## between the grab areas of two close dots.
|
||||
const GRAB_RADIUS_MAX := MainEditing.LINK_DROP_RADIUS
|
||||
const GRAB_GAP := 2.0
|
||||
const GRAB_RADIUS := 10.0
|
||||
|
||||
var main: Main
|
||||
var _grab: Array = [] # [{pos, tid, eid, reach}] outlets that can start a pipe (reach: grab radius, world units)
|
||||
## Where the dot under the mouse sits (null for none).
|
||||
var _hot_pos: Variant = null
|
||||
var _grab: Array = [] # [{pos, tid, eid}] outlets that can start a pipe
|
||||
var _linking := false
|
||||
var _ghost_from := Vector2.ZERO
|
||||
var _ghost_to := Vector2.ZERO
|
||||
|
|
@ -22,7 +17,6 @@ var _drawn_rev := -1
|
|||
var _drawn_hover := -1
|
||||
var _drawn_mode := -1
|
||||
var _drawn_far := false
|
||||
var _drawn_zoom := 0.0
|
||||
## [stack index, rect] of each visible card, for hiding ports under other cards.
|
||||
var _stack: Array = []
|
||||
|
||||
|
|
@ -30,7 +24,8 @@ var _stack: Array = []
|
|||
func _init() -> void:
|
||||
mouse_filter = MOUSE_FILTER_STOP
|
||||
mouse_default_cursor_shape = CURSOR_CROSS
|
||||
BoardView.cover_world(self)
|
||||
# Controls only draw inside their own rect, so cover the whole world.
|
||||
size = Vector2(BoardView.WORLD_SIZE, BoardView.WORLD_SIZE)
|
||||
|
||||
|
||||
## Redraws only when the board's geometry changed (BoardView.geometry_rev),
|
||||
|
|
@ -40,9 +35,8 @@ func _process(_delta: float) -> void:
|
|||
return
|
||||
var hover := _hovered_grab()
|
||||
var far := main.board.cards.far
|
||||
if _linking or main.board.geometry_rev != _drawn_rev or hover != _drawn_hover or main.mode != _drawn_mode or far != _drawn_far or main.board.zoom != _drawn_zoom:
|
||||
if _linking or main.board.geometry_rev != _drawn_rev or hover != _drawn_hover or main.mode != _drawn_mode or far != _drawn_far:
|
||||
_drawn_far = far
|
||||
_drawn_zoom = main.board.zoom
|
||||
_drawn_rev = main.board.geometry_rev
|
||||
_drawn_hover = hover
|
||||
_drawn_mode = main.mode
|
||||
|
|
@ -55,7 +49,7 @@ func _hovered_grab() -> int:
|
|||
return -1
|
||||
var mouse := get_local_mouse_position()
|
||||
for i in _grab.size():
|
||||
if mouse.distance_to(_grab[i]["pos"]) <= _grab[i]["reach"]:
|
||||
if mouse.distance_to(_grab[i]["pos"]) <= GRAB_RADIUS:
|
||||
return i
|
||||
return -1
|
||||
|
||||
|
|
@ -66,15 +60,12 @@ func _has_point(p: Vector2) -> bool:
|
|||
if main == null or main.mode != Main.Mode.BUILD:
|
||||
return false
|
||||
for g in _grab:
|
||||
if p.distance_to(g["pos"]) <= g["reach"]:
|
||||
if p.distance_to(g["pos"]) <= GRAB_RADIUS:
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
func _draw() -> void:
|
||||
# The dot under the mouse (found with last frame's grab areas).
|
||||
var hover_index := _hovered_grab()
|
||||
_hot_pos = _grab[hover_index]["pos"] if hover_index >= 0 else null
|
||||
_grab.clear()
|
||||
# Zoomed far out (BoardView.FAR_ZOOM) the ports would be specks.
|
||||
if main.board.cards.far and not _linking:
|
||||
|
|
@ -89,10 +80,7 @@ func _draw() -> void:
|
|||
var below := card.get_index()
|
||||
# Variable cards are never rolled, so nothing pipes into them.
|
||||
if t.kind != RollTable.KIND_VARIABLE and not _covered(card.inlet_point(), below):
|
||||
if _linking and _ghost_to == card.inlet_point():
|
||||
_port(card.inlet_point(), Style.ACCENT, Style.ACCENT_DARK, 1.4) # the drop will land here
|
||||
else:
|
||||
_port(card.inlet_point(), Style.THREAD, Style.THREAD_DARK, 1.0)
|
||||
_port(card.inlet_point(), Style.THREAD, Style.THREAD_DARK, 1.0)
|
||||
for e in t.entries:
|
||||
if not card.rows.has(e.id):
|
||||
continue
|
||||
|
|
@ -111,7 +99,7 @@ func _draw() -> void:
|
|||
if on and main.is_entry_lit(t.id, e.id):
|
||||
fill = Style.ACCENT
|
||||
ring = Style.ACCENT_DARK
|
||||
if build and _hot_pos == pos and not _linking:
|
||||
if build and pos.distance_to(mouse) <= GRAB_RADIUS and not _linking:
|
||||
fill = Style.ACCENT
|
||||
s = 1.2
|
||||
_port(pos, fill, ring, s)
|
||||
|
|
@ -136,33 +124,10 @@ func _draw() -> void:
|
|||
_port(Vector2(p), Style.ACCENT, Style.ACCENT_DARK, 1.0)
|
||||
else:
|
||||
_port(Vector2(p), Style.THREAD, Style.THREAD_DARK, 1.0)
|
||||
_size_grab_areas()
|
||||
if _linking:
|
||||
_draw_ghost(PipeLayer.curve(_ghost_from, _ghost_to, _ghost_down))
|
||||
|
||||
|
||||
## Each dot's grab radius: up to GRAB_RADIUS_MAX on screen, less where another
|
||||
## dot is near, so neighbouring areas stay GRAB_GAP screen pixels apart.
|
||||
func _size_grab_areas() -> void:
|
||||
var zoom := main.board.zoom
|
||||
var cell := 2.0 * GRAB_RADIUS_MAX / zoom # only dots this close can matter
|
||||
var buckets := {}
|
||||
for g: Dictionary in _grab:
|
||||
var key := Vector2i((g["pos"] as Vector2) / cell)
|
||||
if not buckets.has(key):
|
||||
buckets[key] = []
|
||||
(buckets[key] as Array).append(g)
|
||||
for g: Dictionary in _grab:
|
||||
var key := Vector2i((g["pos"] as Vector2) / cell)
|
||||
var nearest := cell
|
||||
for dx in range(-1, 2):
|
||||
for dy in range(-1, 2):
|
||||
for other: Dictionary in buckets.get(key + Vector2i(dx, dy), []):
|
||||
if not is_same(other, g):
|
||||
nearest = minf(nearest, (g["pos"] as Vector2).distance_to(other["pos"]))
|
||||
g["reach"] = clampf(nearest / 2.0 - GRAB_GAP / 2.0 / zoom, 4.0 / zoom, GRAB_RADIUS_MAX / zoom)
|
||||
|
||||
|
||||
## The port on a card's bottom edge for card threads (CardThreads): in Build
|
||||
## always (drag from it to add one), in Play only when the card has some.
|
||||
func _outlet_port(t: RollTable, card: TableCard, build: bool, mouse: Vector2, below: int) -> void:
|
||||
|
|
@ -177,7 +142,7 @@ func _outlet_port(t: RollTable, card: TableCard, build: bool, mouse: Vector2, be
|
|||
if main.lit_pipes.has(Roller.pipe_key(t.id, RollTable.OUTLET_ID, to)):
|
||||
fill = Style.ACCENT
|
||||
ring = Style.ACCENT_DARK
|
||||
if build and _hot_pos == pos and not _linking:
|
||||
if build and pos.distance_to(mouse) <= GRAB_RADIUS and not _linking:
|
||||
fill = Style.ACCENT
|
||||
s = 1.2
|
||||
_port(pos, fill, ring, s)
|
||||
|
|
@ -225,7 +190,7 @@ func _gui_input(ev: InputEvent) -> void:
|
|||
if mb and mb.button_index == MOUSE_BUTTON_LEFT:
|
||||
if mb.pressed:
|
||||
for g in _grab:
|
||||
if mb.position.distance_to(g["pos"]) <= g["reach"]:
|
||||
if mb.position.distance_to(g["pos"]) <= GRAB_RADIUS:
|
||||
_linking = true
|
||||
_ghost_from = g["pos"]
|
||||
_ghost_down = g["eid"] == RollTable.OUTLET_ID
|
||||
|
|
@ -240,7 +205,6 @@ func _gui_input(ev: InputEvent) -> void:
|
|||
return
|
||||
var mm := ev as InputEventMouseMotion
|
||||
if mm and _linking:
|
||||
_ghost_to = mm.position
|
||||
main.update_link()
|
||||
var snap: Variant = main.link_snap_point()
|
||||
_ghost_to = snap if snap != null else mm.position
|
||||
accept_event()
|
||||
|
|
|
|||
|
|
@ -27,13 +27,14 @@ func anchor_for(eid: String) -> Dictionary:
|
|||
var row: Control = card.rows.get(eid, card.more_row)
|
||||
if row == null or not row.is_inside_tree():
|
||||
return {}
|
||||
var board := card.main.board
|
||||
var y := board.world_rect_of(row).get_center().y
|
||||
var to_world := card.main.board.world.get_global_transform().affine_inverse()
|
||||
var r := row.get_global_rect()
|
||||
var y := (to_world * (r.position + Vector2(0, r.size.y / 2.0))).y
|
||||
var shown := true
|
||||
if card.list_scroll != null and card.rows.has(eid):
|
||||
var scroll_rect := board.world_rect_of(card.list_scroll)
|
||||
var top := scroll_rect.position.y + 14.0
|
||||
var bottom := scroll_rect.end.y - 14.0
|
||||
var sr := card.list_scroll.get_global_rect()
|
||||
var top := (to_world * sr.position).y + 14.0
|
||||
var bottom := (to_world * sr.end).y - 14.0
|
||||
shown = y >= top - 4.0 and y <= bottom + 4.0
|
||||
y = clampf(y, top, bottom)
|
||||
return {"pos": Vector2(card.position.x + card.size.x, y), "visible": shown}
|
||||
|
|
|
|||
|
|
@ -15,10 +15,6 @@ func gui_input(ev: InputEvent) -> void:
|
|||
# ends, so scrolling past the last result doesn't start zooming.
|
||||
var mb := ev as InputEventMouseButton
|
||||
if mb and mb.button_index == MOUSE_BUTTON_LEFT:
|
||||
# In Build, a click on the card's own body (no control took it) selects the card.
|
||||
# (A click on a result row already selected that result; leave it.)
|
||||
if mb.pressed and card.main.mode == Main.Mode.BUILD and not _is_inspected():
|
||||
card.main.select_card(card.table.id)
|
||||
card.accept_event()
|
||||
elif mb and _wheel_in_list(mb):
|
||||
card.accept_event()
|
||||
|
|
@ -26,12 +22,6 @@ func gui_input(ev: InputEvent) -> void:
|
|||
card.accept_event()
|
||||
|
||||
|
||||
## True when the inspector already shows this card or one of its results.
|
||||
func _is_inspected() -> bool:
|
||||
var selection := card.main.inspector_selection()
|
||||
return str(selection.get("tid", "")) == card.table.id and str(selection.get("kind", "")) != "pipe"
|
||||
|
||||
|
||||
func _wheel_in_list(mb: InputEventMouseButton) -> bool:
|
||||
if mb.button_index != MOUSE_BUTTON_WHEEL_UP and mb.button_index != MOUSE_BUTTON_WHEEL_DOWN:
|
||||
return false
|
||||
|
|
|
|||
Loading…
Reference in a new issue