MobileLayout (Android, or --mobile to try it on a desktop): the List fills the screen with a Spread/List swap; the bar drops the title, hint, zoom, View, Help and Play/Build (the last three move into ☰); the tray hides its Earlier column and shortens Roll again; DPI scaling. TouchInput (every platform): a long press is a right-click, two fingers pan and pinch-zoom. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
51 lines
1.8 KiB
GDScript
51 lines
1.8 KiB
GDScript
class_name MobileLayout
|
|
extends RefCounted
|
|
## The phone layout (Android, or --mobile on a desktop to try it): the List
|
|
## fills the screen and a Spread/List button swaps it with the spread; the
|
|
## top bar drops its hint and zoom control; everything scales to the screen's
|
|
## density. Touch gestures come from TouchInput (added on every platform, so
|
|
## touch screens on laptops work too).
|
|
|
|
var m: Main
|
|
var showing_list := true
|
|
var swap: Button
|
|
|
|
|
|
func _init(p_main: Main) -> void:
|
|
m = p_main
|
|
|
|
|
|
static func wanted() -> bool:
|
|
return OS.has_feature("mobile") or OS.get_cmdline_user_args().has("--mobile")
|
|
|
|
|
|
func apply() -> void:
|
|
if OS.has_feature("mobile"):
|
|
m.get_window().content_scale_factor = clampf(DisplayServer.screen_get_dpi() / 160.0, 1.0, 3.0)
|
|
# Room is short: View, Help and Play/Build move into the ☰ menu
|
|
# (Actions.background adds them when the phone layout is on).
|
|
var bar := m.top_bar
|
|
for c: Control in [bar._hint, bar.zoom, bar.view_menu, bar.help_menu, bar.brand_title, bar._play_button.get_parent().get_parent()]:
|
|
if c:
|
|
c.visible = false
|
|
m.tray.side_panel.visible = false
|
|
m.tray.compact = true
|
|
m.list_view.close_button.visible = false
|
|
m.list_view.splitter.visible = false
|
|
m.list_view.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
|
m.board.minimap.visible = false
|
|
swap = Style.bar_button("Spread")
|
|
swap.tooltip_text = "Swap between the list and the spread"
|
|
swap.pressed.connect(func() -> void: show_list(not showing_list))
|
|
bar.actions_menu.get_parent().add_child(swap)
|
|
bar.actions_menu.get_parent().move_child(swap, bar.actions_menu.get_index())
|
|
show_list(true)
|
|
|
|
|
|
## The list or the spread fills the screen.
|
|
func show_list(on: bool) -> void:
|
|
showing_list = on
|
|
m.list_view.visible = on
|
|
m.list_view._rev = -1
|
|
m.board.visible = not on
|
|
swap.text = "Spread" if on else "List"
|