TableTower/ui/card_move_handle.gd

28 lines
886 B
GDScript3
Raw Normal View History

class_name CardMoveHandle
extends Control
## The dotted handle at the left of a card's header in Build: shows where to
## grab the card to move it. It only draws; the header under it does the
## dragging. (The resize corner is CardGrip.)
const DOT := 1.8
const STEP := 6.0
func _init() -> void:
custom_minimum_size = Vector2(14, 30)
size_flags_vertical = Control.SIZE_SHRINK_CENTER
mouse_filter = Control.MOUSE_FILTER_PASS
mouse_default_cursor_shape = Control.CURSOR_MOVE
tooltip_text = "Drag to move the card"
mouse_entered.connect(queue_redraw)
mouse_exited.connect(queue_redraw)
func _draw() -> void:
var hot := get_global_rect().has_point(get_global_mouse_position())
var color := Style.INK if hot else Style.MUTED
for col in 2:
for row in 4:
var at := Vector2(size.x / 2.0 + (col - 0.5) * STEP, size.y / 2.0 + (row - 1.5) * STEP)
draw_circle(at, DOT, color)