User-facing text only; code names, JSON keys and the project's internal name (and so the user:// folder) are unchanged. The Collection card kind keeps its name until a new one is chosen. The window title says Table Tarot; the top bar shows the theme's logo (the fortune teller, drawn from a copy of the art without its background square); the app icon is the mascot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
60 lines
1.8 KiB
GDScript
60 lines
1.8 KiB
GDScript
class_name ZoomControl
|
||
extends HBoxContainer
|
||
## The top bar's zoom: − and + around a "90% ▾" menu that offers Fit board,
|
||
## Zoom to 100% and the minimap. The percentage follows the board's zoom,
|
||
## however it changed (buttons, wheel, Fit or a pan-and-zoom animation).
|
||
|
||
const ID_FIT := 0
|
||
const ID_ACTUAL := 1
|
||
const ID_MINIMAP := 2
|
||
const STEP := 1.15
|
||
|
||
var m: Main
|
||
var menu: MenuButton
|
||
var _shown := -1.0
|
||
|
||
|
||
func setup(p_main: Main) -> void:
|
||
m = p_main
|
||
add_theme_constant_override("separation", 4)
|
||
var zout := _step_button("−", "Zoom out", 1.0 / STEP)
|
||
add_child(zout)
|
||
menu = ModalCard.bar_menu_button("100% ▾")
|
||
menu.tooltip_text = "Zoom: fit the spread, 100% or the minimap"
|
||
menu.custom_minimum_size.x = 86
|
||
var pm := menu.get_popup()
|
||
pm.add_item("Fit spread", ID_FIT)
|
||
pm.set_item_tooltip(pm.get_item_index(ID_FIT), "Show every table")
|
||
pm.add_item("Zoom to 100%", ID_ACTUAL)
|
||
pm.add_separator()
|
||
pm.add_check_item("Minimap (M)", ID_MINIMAP)
|
||
pm.about_to_popup.connect(func() -> void:
|
||
pm.set_item_checked(pm.get_item_index(ID_MINIMAP), m.board.minimap.visible))
|
||
pm.id_pressed.connect(activate)
|
||
add_child(menu)
|
||
add_child(_step_button("+", "Zoom in", STEP))
|
||
|
||
|
||
func _step_button(text: String, tip: String, factor: float) -> Button:
|
||
var b := Style.bar_button(text)
|
||
b.tooltip_text = tip
|
||
b.custom_minimum_size = Vector2(34, 0)
|
||
b.pressed.connect(func() -> void: m.board.set_zoom(m.board.zoom * factor))
|
||
return b
|
||
|
||
|
||
func activate(id: int) -> void:
|
||
match id:
|
||
ID_FIT:
|
||
m.board.fit()
|
||
ID_ACTUAL:
|
||
m.board.set_zoom(1.0)
|
||
ID_MINIMAP:
|
||
m.nav.set_minimap_visible(not m.board.minimap.visible, true)
|
||
|
||
|
||
func _process(_delta: float) -> void:
|
||
if m == null or m.board == null or is_equal_approx(m.board.zoom, _shown):
|
||
return
|
||
_shown = m.board.zoom
|
||
menu.text = "%d%% ▾" % roundi(_shown * 100.0)
|