spaceship/ui/menus/MenuLayout.gd

27 lines
819 B
GDScript3
Raw Normal View History

extends RefCounted
const HEADER_GAP: float = 16.0
const BOTTOM_MARGIN: float = 28.0
static func grid_band(header_bottom: float, panel_height: float) -> Vector2:
var half: float = panel_height * 0.5
if half <= 0.0:
half = 640.0
return Vector2(header_bottom + HEADER_GAP - half, half - BOTTOM_MARGIN)
static func grid_row_top(row: int, rows: int, row_height: float, band: Vector2,
natural_pitch: float) -> float:
var pitch: float = natural_pitch
if rows > 1:
pitch = minf(pitch, (band.y - band.x - row_height) / float(rows - 1))
return band.x + maxf(pitch, row_height) * float(row)
static func place_entry(node: Control, cx: float, top: float, half: float,
height: float) -> void:
node.offset_left = cx - half
node.offset_right = cx + half
node.offset_top = top
node.offset_bottom = top + height