Dragged threads snap to an input dot within 24 screen px and highlight it
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
f87aa00795
commit
54eb5d1af2
3 changed files with 19 additions and 3 deletions
|
|
@ -198,6 +198,8 @@ 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:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ 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 := 10.0
|
||||
const LINK_DROP_RADIUS := 24.0
|
||||
const MENU_SAVE_SELECTION := 102
|
||||
|
||||
|
||||
|
|
@ -258,6 +258,16 @@ 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):
|
||||
|
|
|
|||
|
|
@ -79,7 +79,10 @@ 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):
|
||||
_port(card.inlet_point(), Style.THREAD, Style.THREAD_DARK, 1.0)
|
||||
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)
|
||||
for e in t.entries:
|
||||
if not card.rows.has(e.id):
|
||||
continue
|
||||
|
|
@ -204,6 +207,7 @@ 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()
|
||||
|
|
|
|||
Loading…
Reference in a new issue