diff --git a/crates/app/src/card.rs b/crates/app/src/card.rs index 7e11533..f48d206 100644 --- a/crates/app/src/card.rs +++ b/crates/app/src/card.rs @@ -10,7 +10,7 @@ use gpui_kit::prelude::FluentBuilder as _; use gpui_kit::*; use crate::text::{ordinal, thousands}; -use crate::theme::{LOGO_GOLD, ON_GOLD, surface}; +use crate::theme::{LOGO_GOLD, ON_GOLD, gold_glow, surface}; /// Width over height: the ratio the stored portraits are cropped to. pub const ASPECT: f32 = arena_tracker_core::CARD_ASPECT as f32; @@ -114,14 +114,54 @@ pub struct Card { pub sheet: Vec<(&'static str, SharedString)>, } -/// What the grid knows of a card that the card does not: whether to show its sheet, and the -/// focus handle that makes it reachable with the keyboard. -#[derive(Clone, Copy, Default)] -pub struct CardState<'a> { - pub sheet: bool, - pub focus: Option<&'a FocusHandle>, +/// How far a card is lifted over its grid (#88), drawn over it while the pointer or the keyboard +/// is on it: it rises, its illustration zooms in, its caption fades and its sheet slides up from +/// the bottom. +#[derive(Clone, Copy, Debug, PartialEq)] +pub struct Pose { + /// 0 at rest, 1 lifted all the way. + pub progress: f32, + /// The hand's veil on this card: 0 to 1. + pub veil: f32, + /// Off with the Windows « Show animations » setting: the sheet shows, the card stays put. + pub moves: bool, } +/// How high a card rises: less for a greyed one, which cannot be picked. +const RISE: f32 = 10.; +const GREYED_RISE: f32 = 4.; +/// How much the illustration zooms in, inside the card. +const ZOOM: f32 = 0.07; +/// How far the sheet slides up, and the caption down. +const SHEET_SLIDE: f32 = 14.; +const CAPTION_SLIDE: f32 = 6.; +const CAPTION_BOTTOM: f32 = 12.; +/// The hand's veil on the other cards, as the mockup's `rgba(9, 11, 24, .42)`. +const VEIL: u32 = 0x090b18; +const VEIL_OPACITY: f32 = 0.42; + +impl Pose { + /// How many pixels the card is above its place. + pub fn rise(&self, card: &Card) -> f32 { + if !self.moves { + return 0.; + } + self.progress * if card.greyed() { GREYED_RISE } else { RISE } + } + + fn zoom(&self) -> f32 { + if self.moves { self.progress * ZOOM } else { 0. } + } +} + +/// The hand's veil on a card at rest in it, `veil` from 0 to 1. +pub fn veil_color(veil: f32) -> Hsla { + Hsla::from(rgb(VEIL)).opacity(VEIL_OPACITY * veil) +} + +/// The radius of a card, for what is drawn over one. +pub const CARD_RADIUS: f32 = RADIUS; + impl Card { /// A row without a Challenge (no Season) has no Marks. pub fn from_row(row: &ChampionRow) -> Card { @@ -205,36 +245,80 @@ fn sheet_lines(row: &ChampionRow) -> Vec<(&'static str, SharedString)> { lines } -/// One card, as wide as its parent gives it, `ASPECT` wide over tall. Hovering only changes the -/// border colour; the sheet covers it when `state` says so, and a focus handle makes it a tab -/// stop with an accent border while the keyboard is on it. The caller adds its own listeners. -pub fn card(card: &Card, state: CardState<'_>, cx: &App) -> Stateful