mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-28 13:02:21 +01:00
* Unify onboarding entrances and follow the display clock * Keep onboarding waveforms alive through their effect-slot exits * Keep the waiting scanner intact on the first real press * Use Rune's phase channel for onboarding traces * Carry the download, keyboard, and practice stage through their exits * Hide the practice reply field with its second send * Onboarding: fly the dictated words into the practice field Live words fly out of the plate while the shortcut is held when the model streams; otherwise the pasted words fly after release. The field's text stays the truth, live partials are demanded only by the onboarding, and Reduce Motion fades words in. Drop canned timings from the headings and plain the Microphone caption. * Drop the unused AppSettings::refresh_runtime (as #545 does) * Turn on Labs › Mouse shortcuts in the macOS back-button shortcut test
223 lines
6.8 KiB
Rust
223 lines
6.8 KiB
Rust
//! Shared typography, motion transitions, and the `"Hex is ready"` finale.
|
|
|
|
use rune::{El, Spring, SpringPair, TextStyle, Transition, col, el, row, text};
|
|
use rune_kit::{Button, ButtonVariant};
|
|
|
|
use super::super::controls::{KeySize, Paint, PushSize, key_tray, keycap};
|
|
use super::fixture::Language;
|
|
use super::hex_meter::{hex_meter, hex_meter_glowing};
|
|
use super::pill::{FLY, PILL};
|
|
|
|
/// One display heading style across every onboarding step (`26 pt`, softened
|
|
/// weight in dark mode so light ink on dark doesn't bloom).
|
|
pub(crate) const TITLE: TextStyle = TextStyle::new(26.0, 580.0).lh(32.0).tracking(-0.35);
|
|
pub(crate) fn title_font(p: Paint) -> TextStyle {
|
|
TextStyle {
|
|
weight: if p.k.dark { 550.0 } else { 600.0 },
|
|
..TITLE
|
|
}
|
|
}
|
|
|
|
/// Subtitle line under every step's heading.
|
|
pub(crate) const LEAD: TextStyle = TextStyle::new(15.0, 410.0).lh(22.0);
|
|
|
|
/// Product UI spring: `0.30 s`, zero bounce.
|
|
pub(crate) const UI_SPRING: Spring = Spring::new(0.30, 0.0);
|
|
const EXIT_SPRING: Spring = Spring::new(0.25, 0.0);
|
|
|
|
/// The story's live motion controls. The real first run uses the same defaults.
|
|
#[derive(Clone, Copy)]
|
|
pub(crate) struct Motion {
|
|
pub enter: f32,
|
|
pub exit: f32,
|
|
pub travel: f32,
|
|
pub stagger: f32,
|
|
pub keyboard: f32,
|
|
}
|
|
|
|
impl Default for Motion {
|
|
fn default() -> Self {
|
|
Self {
|
|
enter: 0.34,
|
|
exit: 0.26,
|
|
travel: 8.0,
|
|
stagger: 0.05,
|
|
keyboard: 0.65,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Motion {
|
|
pub fn roll(self, distance: f32) -> Transition {
|
|
let fade = |y| Transition::offset(0.0, y).combined(Transition::opacity());
|
|
Transition::asymmetric(fade(distance), fade(-distance)).springs(SpringPair::new(
|
|
Spring::new(self.enter, 0.0),
|
|
Spring::new(self.exit, 0.0),
|
|
))
|
|
}
|
|
|
|
pub fn heading(self, child: El) -> El {
|
|
child.transition(self.roll(self.travel))
|
|
}
|
|
|
|
pub fn staggered(self, child: El, rank: f32, distance: f32) -> El {
|
|
child
|
|
.transition(self.roll(distance))
|
|
.enter_delay(rank * self.stagger)
|
|
}
|
|
|
|
/// One critically damped progress value for a clock-driven pose.
|
|
pub fn keyboard_progress(self, elapsed: f64) -> f32 {
|
|
Spring::new(self.keyboard, 0.0)
|
|
.sample(0.0, 0.0, 1.0, elapsed.max(0.0) as f32)
|
|
.0
|
|
}
|
|
}
|
|
|
|
/// Whole-state replacement in place, with a slightly shorter exit.
|
|
pub(crate) fn arrives() -> Transition {
|
|
Transition::scale(0.97)
|
|
.combined(Transition::opacity())
|
|
.springs(SpringPair::new(UI_SPRING, EXIT_SPRING))
|
|
}
|
|
|
|
/// Incoming words rise as outgoing words lift away, on one presence spring.
|
|
pub(crate) fn step_replace() -> Transition {
|
|
Motion::default().roll(Motion::default().travel)
|
|
}
|
|
|
|
/// A heading and the line under it, centred on the column spine.
|
|
pub(crate) fn heading(p: Paint, key: &str, title: &str, lead: &str) -> El {
|
|
col()
|
|
.key(key)
|
|
.gap(8.0)
|
|
.items_center()
|
|
.transition(step_replace())
|
|
.child(text(title).key("title").font(title_font(p)).color(p.text()))
|
|
.child(
|
|
text(lead)
|
|
.key("lead")
|
|
.font(LEAD)
|
|
.color(p.muted())
|
|
.align(rune::Align::Center)
|
|
.wrap()
|
|
.max_w(440.0),
|
|
)
|
|
}
|
|
|
|
/// Download English, or pick another language (used by the older option stories).
|
|
pub(crate) fn language_pick<S: 'static>(p: Paint, pick: fn(&mut S, Language)) -> El {
|
|
row()
|
|
.key("language-pick")
|
|
.gap(10.0)
|
|
.center_y()
|
|
.child(
|
|
Button::new("Download English")
|
|
.variant(ButtonVariant::Contrast)
|
|
.on_press(move |s: &mut S| pick(s, Language::English))
|
|
.build_push(p.k)
|
|
.key(PILL)
|
|
.matched(PILL)
|
|
.motion(FLY)
|
|
.default_button(),
|
|
)
|
|
.child(
|
|
Button::new("Other language")
|
|
.variant(ButtonVariant::Neutral)
|
|
.on_press(move |s: &mut S| pick(s, Language::Other))
|
|
.build_push(p.k)
|
|
.key("other"),
|
|
)
|
|
}
|
|
|
|
/// The shortcut's keys in a recessed tray, `down` while held.
|
|
pub(crate) fn keys(p: Paint, key: &str, caps: &[String], down: bool) -> El {
|
|
key_tray(
|
|
p,
|
|
key,
|
|
KeySize::Small,
|
|
caps.iter()
|
|
.enumerate()
|
|
.map(|(i, cap)| keycap(p, i, cap, KeySize::Small, down)),
|
|
)
|
|
}
|
|
|
|
/// Final `"Hex is ready"` landing: the thin single-hexagon mark arrives from
|
|
/// the top pill with a soft outline glow, followed by staggered copy and a
|
|
/// quiet macOS menu-bar preview showing where Hex lives.
|
|
pub(crate) fn ready(
|
|
p: Paint,
|
|
caps: &[String],
|
|
matched: Option<&str>,
|
|
now: f64,
|
|
reduced: bool,
|
|
motion: Motion,
|
|
) -> El {
|
|
let mark = hex_meter_glowing(p, "meter", 64.0, now, reduced);
|
|
let mark = match matched {
|
|
Some(id) => el().key(id).matched(id).motion(FLY).child(mark),
|
|
None => motion.staggered(mark.key("mark"), 0.0, 8.0),
|
|
};
|
|
col()
|
|
.key("ready")
|
|
.gap(24.0)
|
|
.items_center()
|
|
.child(mark)
|
|
.child(
|
|
motion.staggered(
|
|
col()
|
|
.key("ready-copy")
|
|
.gap(10.0)
|
|
.items_center()
|
|
.child(
|
|
text("Hex is ready")
|
|
.key("title")
|
|
.font(title_font(p))
|
|
.color(p.text()),
|
|
)
|
|
.child(hold_anywhere(p, caps)),
|
|
1.0,
|
|
8.0,
|
|
),
|
|
)
|
|
.child(motion.staggered(menubar_hint(p), 2.0, 8.0))
|
|
}
|
|
|
|
/// `"Hold [⌥] anywhere, then talk."`
|
|
pub(crate) fn hold_anywhere(p: Paint, caps: &[String]) -> El {
|
|
row()
|
|
.key("hold-anywhere")
|
|
.gap(8.0)
|
|
.center_y()
|
|
.child(text("Hold").key("hold").font(LEAD).color(p.muted()))
|
|
.child(keys(p, "keys", caps, false))
|
|
.child(
|
|
text("anywhere, then talk.")
|
|
.key("anywhere")
|
|
.font(LEAD)
|
|
.color(p.muted()),
|
|
)
|
|
}
|
|
|
|
/// Quiet capsule previewing the single-hexagon icon in the macOS menu bar.
|
|
fn menubar_hint(p: Paint) -> El {
|
|
let k = p.k;
|
|
let strip = row()
|
|
.key("menubar-pill")
|
|
.h(30.0)
|
|
.px(12.0)
|
|
.gap(10.0)
|
|
.center_y()
|
|
.radius(15.0)
|
|
.fill(k.c.surface_raised)
|
|
.border(p.hair, k.c.border_weak)
|
|
.child(hex_meter(p, "menubar-hex", 14.0, 1.0, 1.0))
|
|
.child(el().key("sep").size(p.hair, 12.0).fill(k.c.border_base))
|
|
.child(
|
|
text("Lives quietly in your menu bar")
|
|
.key("menubar-copy")
|
|
.font(k.ty.small)
|
|
.color(p.muted()),
|
|
);
|
|
k.elevate(strip, &k.elevation.raised)
|
|
}
|