feat(engine): replace docked touch bar with floating glass tab bar
Touch layout only (desktop bar unchanged): a floating glass pill (Undo / Draw / Hint / Pause) plus a detached circular Menu button, margin above the bottom edge on top of the safe-area inset. Draw is the persistently expanded accent pill (icon + label); other buttons are icon-only and slide their label out while pressed, snapping under reduce-motion. Buttons keep the existing marker components so click handlers, tooltips, focus ring, and chrome toggle work unchanged. Icons: None degrades to text-fallback labels (MinimalPlugins tests / SVG regression), keeping the bar fully usable. Toast stack clearance now derives from TAB_BAR_CLEARANCE_PX; the legacy touch bar spawn path and primary-button metrics are removed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -360,6 +360,7 @@ pub(super) fn handle_avatar_button(
|
||||
pub(super) fn spawn_action_buttons(
|
||||
font_res: Option<Res<FontResource>>,
|
||||
windows: Query<&Window>,
|
||||
images: Option<ResMut<Assets<Image>>>,
|
||||
mut commands: Commands,
|
||||
) {
|
||||
let action_font_size =
|
||||
@@ -370,9 +371,18 @@ pub(super) fn spawn_action_buttons(
|
||||
..default()
|
||||
};
|
||||
|
||||
// Bottom bar: full-width, centered, sits above the gesture-navigation zone.
|
||||
// Touch layout: the floating glass tab bar (pill + circular Menu).
|
||||
// `Assets<Image>` is absent under `MinimalPlugins`; `rasterize_into`
|
||||
// returning `None` switches the bar to its text-fallback form.
|
||||
if USE_TOUCH_UI_LAYOUT {
|
||||
let icons = images.and_then(|mut imgs| TabIcons::rasterize_into(&mut imgs));
|
||||
spawn_glass_tab_bar(&mut commands, &font, icons.as_ref());
|
||||
return;
|
||||
}
|
||||
|
||||
// Desktop bottom bar: full-width, centered, docked to the bottom edge.
|
||||
// `SafeAreaAnchoredBottom` applies the correct logical-pixel inset once
|
||||
// Android reports it (frames 1-3); initial value is 0.0.
|
||||
// the platform reports it; initial value is 0.0.
|
||||
commands
|
||||
.spawn((
|
||||
Node {
|
||||
@@ -400,73 +410,10 @@ pub(super) fn spawn_action_buttons(
|
||||
HudActionBar,
|
||||
))
|
||||
.with_children(|row| {
|
||||
if USE_TOUCH_UI_LAYOUT {
|
||||
spawn_touch_action_bar(row, &font);
|
||||
} else {
|
||||
spawn_desktop_action_bar(row, &font);
|
||||
}
|
||||
spawn_desktop_action_bar(row, &font);
|
||||
});
|
||||
}
|
||||
|
||||
/// Phase F touch action bar — five buttons, three of them big.
|
||||
///
|
||||
/// The core gameplay trio (**Undo · Draw · Hint**) gets enlarged
|
||||
/// thumb-reach targets; Menu and Pause stay compact at the edges. The
|
||||
/// utility actions the desktop bar carries are reachable elsewhere on
|
||||
/// touch and are deliberately absent here: Help lives in Menu → System,
|
||||
/// mode switching lives on the Home screen (Phase B), and New Game is
|
||||
/// Home's hero button. Draw duplicates the stock-pile tap so the most
|
||||
/// frequent action of all no longer requires reaching the top half of a
|
||||
/// tall folded screen.
|
||||
pub(super) fn spawn_touch_action_bar(row: &mut ChildSpawnerCommands, font: &TextFont) {
|
||||
// The trailing `order` argument feeds `Focusable { group: Hud, order }`
|
||||
// so Tab (external keyboard) cycles the bar in visual reading order.
|
||||
spawn_action_button(
|
||||
row,
|
||||
MenuButton,
|
||||
"Menu",
|
||||
None,
|
||||
"Open Home, Stats, Achievements, Profile, Settings, or Leaderboard.",
|
||||
font,
|
||||
0,
|
||||
TEXT_SECONDARY,
|
||||
);
|
||||
spawn_primary_action_button(
|
||||
row,
|
||||
UndoButton,
|
||||
"Undo",
|
||||
"Take back your last move. Hold to keep undoing. Costs points and blocks No Undo.",
|
||||
font,
|
||||
1,
|
||||
);
|
||||
spawn_primary_action_button(
|
||||
row,
|
||||
DrawButton,
|
||||
"Draw",
|
||||
"Draw from the stock — same as tapping the deck.",
|
||||
font,
|
||||
2,
|
||||
);
|
||||
spawn_primary_action_button(
|
||||
row,
|
||||
HintButton,
|
||||
TOUCH_HINT_LABEL,
|
||||
"Highlight a suggested move. Cycles through alternatives on repeat taps.",
|
||||
font,
|
||||
3,
|
||||
);
|
||||
spawn_action_button(
|
||||
row,
|
||||
PauseButton,
|
||||
"Pause",
|
||||
None,
|
||||
"Pause the game and freeze the timer.",
|
||||
font,
|
||||
4,
|
||||
TEXT_SECONDARY,
|
||||
);
|
||||
}
|
||||
|
||||
/// Desktop action bar — unchanged by Phase F (decision 5: the touch bar
|
||||
/// is touch-only). All seven actions, uniform sizing.
|
||||
pub(super) fn spawn_desktop_action_bar(row: &mut ChildSpawnerCommands, font: &TextFont) {
|
||||
@@ -585,44 +532,9 @@ pub(super) fn spawn_action_button<M: Component>(
|
||||
);
|
||||
}
|
||||
|
||||
/// Enlarged variant for the touch bar's core gameplay trio (Phase F):
|
||||
/// bigger padding / minimum target and a scaled-up label so Undo, Draw,
|
||||
/// and Hint read (and hit) as the primary actions. Hotkey chips are
|
||||
/// irrelevant on touch, so the variant takes none.
|
||||
pub(super) fn spawn_primary_action_button<M: Component>(
|
||||
row: &mut ChildSpawnerCommands,
|
||||
marker: M,
|
||||
label: &str,
|
||||
tooltip: &'static str,
|
||||
font: &TextFont,
|
||||
order: i32,
|
||||
) {
|
||||
let (pad, min_w, min_h) = primary_action_button_metrics();
|
||||
let primary_font = TextFont {
|
||||
font: font.font.clone(),
|
||||
// 1.35× the bar's responsive size, capped so landscape tablets
|
||||
// don't blow the row height out.
|
||||
font_size: (font.font_size * 1.35).min(24.0),
|
||||
..default()
|
||||
};
|
||||
spawn_action_button_sized(
|
||||
row,
|
||||
marker,
|
||||
label,
|
||||
None,
|
||||
tooltip,
|
||||
&primary_font,
|
||||
order,
|
||||
TEXT_PRIMARY,
|
||||
pad,
|
||||
min_w,
|
||||
min_h,
|
||||
);
|
||||
}
|
||||
|
||||
/// Shared body of [`spawn_action_button`] / [`spawn_primary_action_button`]
|
||||
/// — one place owns the component set so `paint_action_buttons`, tooltips,
|
||||
/// and the focus ring treat every bar button identically.
|
||||
/// Shared body of [`spawn_action_button`] — one place owns the component
|
||||
/// set so `paint_action_buttons`, tooltips, and the focus ring treat every
|
||||
/// bar button identically.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn spawn_action_button_sized<M: Component>(
|
||||
row: &mut ChildSpawnerCommands,
|
||||
|
||||
Reference in New Issue
Block a user