Settle names and module homes after third review (#103)
- Rename CardPosition/CardPositions/positions() to DrawnCard/DrawnCards/ drawn_cards(): "position" is a word CONTEXT.md avoids for Placement. - Move the Account and status queries from page/statistics/scope.rs to page/displayed.rs, since the whole page uses them. - Move the home's own statistics state (settle_home_scope, set_home_result, forget_home, home_is_current) to page/home/data.rs, leaving home.rs to queries and rendering. - Move the profiling flag shown() from display.rs to page/profiling.rs. - Narrow Page::new to pub(crate), and restore the domain phrase in the same_riot_id doc comment and the page.rs module doc. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit was merged in pull request #103.
This commit is contained in:
1 parent
242ecc4f28
commit
e7ff365069
16 files changed
+156
-141
No files matched your search
+16
-16
@@ -35,7 +35,7 @@ use geometry::{MAX_COLUMNS, Metrics};
|
||||
pub use geometry::{MAX_WIDTH, TAKEN_DROP, row_height};
|
||||
|
||||
mod layout;
|
||||
pub use layout::{CardHovered, CardPosition, CardPositions, PutDown};
|
||||
pub use layout::{CardHovered, DrawnCard, DrawnCards, PutDown};
|
||||
|
||||
/// What makes one card reachable with the keyboard: its handle, and the subscriptions that lift
|
||||
/// it while the keyboard is on it.
|
||||
@@ -54,7 +54,7 @@ pub struct CardGrid {
|
||||
/// The card under the pointer or the keyboard, which is lifted.
|
||||
hovered: Option<u32>,
|
||||
/// Where the visible cards were drawn last.
|
||||
positions: CardPositions,
|
||||
drawn_cards: DrawnCards,
|
||||
/// How far the list was scrolled when last drawn: a wheel that leaves it there (at either
|
||||
/// end) moves no card from under the pointer.
|
||||
drawn_scroll: Pixels,
|
||||
@@ -86,7 +86,7 @@ impl CardGrid {
|
||||
shown: Vec::new(),
|
||||
scroll: UniformListScrollHandle::new(),
|
||||
hovered: None,
|
||||
positions: CardPositions::default(),
|
||||
drawn_cards: DrawnCards::default(),
|
||||
drawn_scroll: Pixels::ZERO,
|
||||
focus: HashMap::new(),
|
||||
focus_stale: false,
|
||||
@@ -251,7 +251,7 @@ impl CardGrid {
|
||||
// Nor is any of its cards under the pointer: the ring's tick goes out.
|
||||
self.hover(None, cx);
|
||||
cx.emit(PutDown);
|
||||
self.positions.borrow_mut().clear();
|
||||
self.drawn_cards.borrow_mut().clear();
|
||||
let released = self
|
||||
.images
|
||||
.as_ref()
|
||||
@@ -305,11 +305,11 @@ impl CardGrid {
|
||||
}
|
||||
|
||||
/// Where its visible cards were drawn last.
|
||||
pub fn positions(&self) -> &CardPositions {
|
||||
&self.positions
|
||||
pub fn drawn_cards(&self) -> &DrawnCards {
|
||||
&self.drawn_cards
|
||||
}
|
||||
|
||||
/// All its cards, which `CardPosition::ix` indexes.
|
||||
/// All its cards, which `DrawnCard::ix` indexes.
|
||||
pub fn cards(&self) -> &Rc<[Card]> {
|
||||
&self.cards
|
||||
}
|
||||
@@ -327,8 +327,8 @@ impl CardGrid {
|
||||
|
||||
fn row(&mut self, ix: usize, metrics: Metrics, cx: &mut Context<Self>) -> AnyElement {
|
||||
let start = ix * metrics.columns;
|
||||
// The id and index of the card in each slot, for the row to say where it placed them.
|
||||
let mut placing = [None; MAX_COLUMNS];
|
||||
// The id and index of the card in each slot, for the row to record where it drew them.
|
||||
let mut in_slots = [None; MAX_COLUMNS];
|
||||
let mut slots = Vec::with_capacity(metrics.columns);
|
||||
for (column, slot) in (start..start + metrics.columns).enumerate() {
|
||||
// A stale index shows nothing rather than panicking.
|
||||
@@ -340,7 +340,7 @@ impl CardGrid {
|
||||
self.card_builds += 1;
|
||||
}
|
||||
let id = data.id;
|
||||
placing[column] = Some((id, c));
|
||||
in_slots[column] = Some((id, c));
|
||||
let focus = self.focus.get(&id).map(|focus| &focus.handle);
|
||||
// In the hand, a card an ally took rests a little lower than the others.
|
||||
let lowered = self.is_hand() && data.reasons.contains(&Reason::TakenByAlly);
|
||||
@@ -357,7 +357,7 @@ impl CardGrid {
|
||||
None => slots.push(div().flex_1().min_w_0().into_any_element()),
|
||||
}
|
||||
}
|
||||
let positions = self.positions.clone();
|
||||
let drawn_cards = self.drawn_cards.clone();
|
||||
div()
|
||||
.h_flex()
|
||||
.items_start()
|
||||
@@ -369,12 +369,12 @@ impl CardGrid {
|
||||
// Only a row painted is laid out here, not one `uniform_list` merely measures.
|
||||
.on_children_prepainted(move |bounds, window, _| {
|
||||
let visible = window.content_mask().bounds;
|
||||
let mut positions = positions.borrow_mut();
|
||||
for (slot, bounds) in placing.iter().zip(bounds) {
|
||||
let mut drawn_cards = drawn_cards.borrow_mut();
|
||||
for (slot, bounds) in in_slots.iter().zip(bounds) {
|
||||
if let Some((id, ix)) = *slot {
|
||||
positions.insert(
|
||||
drawn_cards.insert(
|
||||
id,
|
||||
CardPosition {
|
||||
DrawnCard {
|
||||
bounds,
|
||||
visible,
|
||||
ix,
|
||||
@@ -429,7 +429,7 @@ impl Render for CardGrid {
|
||||
}
|
||||
self.drawn_scroll = self.scrolled_to();
|
||||
// Only the rows drawn now place their cards.
|
||||
self.positions.borrow_mut().clear();
|
||||
self.drawn_cards.borrow_mut().clear();
|
||||
let images = (self.images)
|
||||
.get_or_insert_with(|| CardImages::new(cx))
|
||||
.clone();
|
||||
|
||||
@@ -20,11 +20,11 @@ pub struct PutDown;
|
||||
/// Where the grid last drew a card, in the window, the part of the window it showed of it, and
|
||||
/// its index in the grid's cards.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct CardPosition {
|
||||
pub struct DrawnCard {
|
||||
pub bounds: Bounds<Pixels>,
|
||||
pub visible: Bounds<Pixels>,
|
||||
pub ix: usize,
|
||||
}
|
||||
|
||||
/// The cards the grid drew last, by id: filled as its rows are laid out, read between its draws.
|
||||
pub type CardPositions = Rc<RefCell<HashMap<u32, CardPosition>>>;
|
||||
pub type DrawnCards = Rc<RefCell<HashMap<u32, DrawnCard>>>;
|
||||
+14
-14
@@ -9,7 +9,7 @@ use gpui_kit::component::ActiveTheme as _;
|
||||
use gpui_kit::*;
|
||||
|
||||
use crate::card::{CARD_RADIUS, Card, MarkFill, Pose, lifted, veil_color};
|
||||
use crate::card_grid::{CardPosition, CardPositions};
|
||||
use crate::card_grid::{DrawnCard, DrawnCards};
|
||||
use crate::card_images::CardImages;
|
||||
use crate::motion::{MATCH_SETTLE, ease_out};
|
||||
|
||||
@@ -217,7 +217,7 @@ pub(crate) enum Changes {
|
||||
/// stays cut where it is. The cards `changes` names show their change.
|
||||
pub(crate) fn layer(
|
||||
cards: Rc<[Card]>,
|
||||
positions: CardPositions,
|
||||
drawn_cards: DrawnCards,
|
||||
images: Option<Entity<CardImages>>,
|
||||
lifted_cards: Vec<Lifted>,
|
||||
changes: Changes,
|
||||
@@ -227,20 +227,20 @@ pub(crate) fn layer(
|
||||
deferred(
|
||||
canvas(
|
||||
move |_, window, cx| {
|
||||
let positions = positions.borrow();
|
||||
let drawn_cards = drawn_cards.borrow();
|
||||
let background = cx.theme().background;
|
||||
let mut layers = Vec::new();
|
||||
if veil > 0. {
|
||||
for (id, place) in positions.iter() {
|
||||
for (id, drawn) in drawn_cards.iter() {
|
||||
if !lifted_cards.iter().any(|lifted| lifted.id == *id) {
|
||||
layers.push(Layer::Quad(place.bounds, veil_color(veil), place.visible));
|
||||
layers.push(Layer::Quad(drawn.bounds, veil_color(veil), drawn.visible));
|
||||
}
|
||||
}
|
||||
}
|
||||
for &Lifted { id, progress } in &lifted_cards {
|
||||
let place = positions.get(&id);
|
||||
let card = place.and_then(|place| cards.get(place.ix));
|
||||
let (Some(place), Some(card)) = (place, card) else {
|
||||
let drawn = drawn_cards.get(&id);
|
||||
let card = drawn.and_then(|drawn| cards.get(drawn.ix));
|
||||
let (Some(drawn), Some(card)) = (drawn, card) else {
|
||||
continue;
|
||||
};
|
||||
let change = match &changes {
|
||||
@@ -262,14 +262,14 @@ pub(crate) fn layer(
|
||||
moves,
|
||||
};
|
||||
// Its place in the grid, where the card at rest is not to be seen.
|
||||
layers.push(Layer::Quad(place.bounds, background, place.visible));
|
||||
let mask = cut(place).map(|bounds| ContentMask { bounds });
|
||||
layers.push(Layer::Quad(drawn.bounds, background, drawn.visible));
|
||||
let mask = cut(drawn).map(|bounds| ContentMask { bounds });
|
||||
let lowered = match &changes {
|
||||
Changes::Taken(lowered) => lowered.iter().find(|lowered| lowered.id == id),
|
||||
Changes::Match(_) => None,
|
||||
};
|
||||
let above = lowered.map_or(0., |lowered| lowered.above);
|
||||
let size = place.bounds.size;
|
||||
let size = drawn.bounds.size;
|
||||
let before = lowered
|
||||
.filter(|lowered| lowered.opacity > 0.)
|
||||
.map(|lowered| {
|
||||
@@ -282,7 +282,7 @@ pub(crate) fn layer(
|
||||
let now = Some((card, self::lifted(card, pose, size, cx)));
|
||||
for (card, element) in [now, before].into_iter().flatten() {
|
||||
let origin =
|
||||
place.bounds.origin - point(px(0.), px(pose.rise(card) + above));
|
||||
drawn.bounds.origin - point(px(0.), px(pose.rise(card) + above));
|
||||
layers.push(prepaint_card(
|
||||
element,
|
||||
images.as_ref(),
|
||||
@@ -306,9 +306,9 @@ pub(crate) fn layer(
|
||||
/// Where a lifted card is cut: nowhere when its grid shows it whole, so it rises out of a
|
||||
/// scrolling list, else where the grid cuts it. A fraction of a pixel of layout or scrolling
|
||||
/// does not cut a card flush with the list's edge.
|
||||
pub(crate) fn cut(place: &CardPosition) -> Option<Bounds<Pixels>> {
|
||||
pub(crate) fn cut(drawn: &DrawnCard) -> Option<Bounds<Pixels>> {
|
||||
const SLACK: f32 = 1.;
|
||||
let (card, shown) = (place.bounds, place.visible);
|
||||
let (card, shown) = (drawn.bounds, drawn.visible);
|
||||
let whole = card.top().as_f32() >= shown.top().as_f32() - SLACK
|
||||
&& card.bottom().as_f32() <= shown.bottom().as_f32() + SLACK
|
||||
&& card.left().as_f32() >= shown.left().as_f32() - SLACK
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::time::{Duration, Instant};
|
||||
use gpui_kit::{Bounds, point, px, size};
|
||||
|
||||
use super::{Lifts, cut};
|
||||
use crate::card_grid::CardPosition;
|
||||
use crate::card_grid::DrawnCard;
|
||||
|
||||
const GRID: u32 = 1;
|
||||
|
||||
@@ -140,8 +140,8 @@ fn finishing_shows_the_end_state_at_once_and_nothing_moves_any_more() {
|
||||
assert_eq!(lifts.veil(GRID, start), 0.);
|
||||
}
|
||||
|
||||
fn card_position(top: f32, list_top: f32) -> CardPosition {
|
||||
CardPosition {
|
||||
fn drawn_card(top: f32, list_top: f32) -> DrawnCard {
|
||||
DrawnCard {
|
||||
bounds: Bounds::new(point(px(12.), px(top)), size(px(240.), px(350.))),
|
||||
visible: Bounds::new(point(px(12.), px(list_top)), size(px(1256.), px(480.))),
|
||||
ix: 0,
|
||||
@@ -152,14 +152,14 @@ fn card_position(top: f32, list_top: f32) -> CardPosition {
|
||||
fn a_card_the_list_shows_whole_rises_out_of_it() {
|
||||
// The first row, flush with the list's top edge, give or take a fraction of a pixel of
|
||||
// layout or scrolling.
|
||||
assert_eq!(cut(&card_position(583., 583.)), None);
|
||||
assert_eq!(cut(&card_position(582.7, 583.)), None);
|
||||
assert_eq!(cut(&card_position(583.3, 583.)), None);
|
||||
assert_eq!(cut(&drawn_card(583., 583.)), None);
|
||||
assert_eq!(cut(&drawn_card(582.7, 583.)), None);
|
||||
assert_eq!(cut(&drawn_card(583.3, 583.)), None);
|
||||
// A column of a fractional width: the bounds' intersection with the list differs from
|
||||
// the card by a rounding error, which cut the first row's lifted card (#88).
|
||||
let column = CardPosition {
|
||||
let column = DrawnCard {
|
||||
bounds: Bounds::new(point(px(533.3333), px(583.)), size(px(240.66666), px(357.))),
|
||||
..card_position(583., 583.)
|
||||
..drawn_card(583., 583.)
|
||||
};
|
||||
assert_ne!(column.visible.intersect(&column.bounds), column.bounds);
|
||||
assert_eq!(cut(&column), None);
|
||||
@@ -167,8 +167,8 @@ fn a_card_the_list_shows_whole_rises_out_of_it() {
|
||||
|
||||
#[test]
|
||||
fn a_card_the_list_shows_in_part_stays_cut_where_it_is() {
|
||||
let half_scrolled = card_position(400., 583.);
|
||||
let half_scrolled = drawn_card(400., 583.);
|
||||
assert_eq!(cut(&half_scrolled), Some(half_scrolled.visible));
|
||||
let below = card_position(900., 583.);
|
||||
let below = drawn_card(900., 583.);
|
||||
assert_eq!(cut(&below), Some(below.visible));
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
//! The page state and navigation for the home, champ select and statistics screens.
|
||||
//! The page and its two tabs: the shared state and the navigation. `display` renders the header
|
||||
//! row and the alerts; `home`, `champ_select` and `statistics` render the content under them.
|
||||
|
||||
use crate::banner_art::BannerArt;
|
||||
use crate::card::Card;
|
||||
@@ -13,7 +14,6 @@ use arena_tracker_core::{
|
||||
Account, ChampionSearch, ChampionSort, Format, Scope, SeasonScope, StateFilter, Statistics,
|
||||
Status, SyncProgress, Tracker,
|
||||
};
|
||||
pub use display::shown;
|
||||
use gpui_kit::base::Button as BaseButton;
|
||||
use gpui_kit::base::async_util::Sender;
|
||||
use gpui_kit::component::input::InputState;
|
||||
@@ -21,6 +21,7 @@ use gpui_kit::component::select::{SelectItem, SelectState};
|
||||
use gpui_kit::component::{ActiveTheme as _, StyledExt as _};
|
||||
use gpui_kit::prelude::FluentBuilder as _;
|
||||
use gpui_kit::*;
|
||||
use profiling::shown;
|
||||
use statistics::ChartsRow;
|
||||
use std::collections::HashMap;
|
||||
use std::rc::Rc;
|
||||
@@ -30,10 +31,12 @@ use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
|
||||
mod cards;
|
||||
mod champ_select;
|
||||
mod display;
|
||||
mod displayed;
|
||||
mod home;
|
||||
mod hover;
|
||||
mod lifecycle;
|
||||
mod playback;
|
||||
mod profiling;
|
||||
mod setup;
|
||||
mod statistics;
|
||||
mod worker_messages;
|
||||
|
||||
@@ -135,10 +135,10 @@ impl Page {
|
||||
// A card under the pointer or the keyboard is drawn: the grid knows where it is.
|
||||
let ix = grid
|
||||
.read(cx)
|
||||
.positions()
|
||||
.drawn_cards()
|
||||
.borrow()
|
||||
.get(&id)
|
||||
.map(|place| place.ix);
|
||||
.map(|drawn| drawn.ix);
|
||||
ix.is_some_and(|ix| !entry.landed(ix, now))
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ impl Page {
|
||||
let grid = self.anvil_grid.read(cx);
|
||||
Some(stage::hand_layer(
|
||||
grid.cards().clone(),
|
||||
grid.positions().clone(),
|
||||
grid.drawn_cards().clone(),
|
||||
grid.images().cloned(),
|
||||
motion,
|
||||
))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use super::{PAGE_PADDING, Page, Tab};
|
||||
use super::{PAGE_PADDING, Page, Tab, shown};
|
||||
use crate::stage;
|
||||
use crate::text::{CLIENT_ABSENT, official_differs, sync_line};
|
||||
#[cfg(test)]
|
||||
@@ -10,32 +10,6 @@ use gpui_kit::component::{ActiveTheme as _, Sizable as _, StyledExt as _};
|
||||
use gpui_kit::prelude::FluentBuilder as _;
|
||||
use gpui_kit::*;
|
||||
|
||||
/// Hides page parts for issue #27 measurements only with `--features profile`.
|
||||
#[inline]
|
||||
pub fn shown(part: &str) -> bool {
|
||||
#[cfg(feature = "profile")]
|
||||
{
|
||||
static HIDDEN: std::sync::OnceLock<Vec<String>> = std::sync::OnceLock::new();
|
||||
!HIDDEN
|
||||
.get_or_init(|| {
|
||||
std::env::var("ARENA_TRACKER_HIDE")
|
||||
.unwrap_or_default()
|
||||
.split(',')
|
||||
.map(str::trim)
|
||||
.filter(|part| !part.is_empty())
|
||||
.map(str::to_owned)
|
||||
.collect()
|
||||
})
|
||||
.iter()
|
||||
.any(|hidden| hidden == part)
|
||||
}
|
||||
#[cfg(not(feature = "profile"))]
|
||||
{
|
||||
let _ = part;
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
impl Page {
|
||||
/// One line each, the most important first; the stored data stays visible under all.
|
||||
fn status_alerts(&self) -> Vec<AnyElement> {
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
//! What the page displays: the Account, whether its data is stale, the official count, the
|
||||
//! error to show and the scope its statistics are computed for.
|
||||
|
||||
use crate::page::{Page, Tab};
|
||||
use arena_tracker_core::{Account, ProgressCheck, Scope, SeasonScope};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! The « Défi » tab, the home: the Challenge of one Season, and its champions.
|
||||
|
||||
use arena_tracker_core::{Scope, SeasonScope, StateFilter, Statistics};
|
||||
use arena_tracker_core::{SeasonScope, StateFilter, Statistics};
|
||||
use gpui_kit::component::input::Input;
|
||||
use gpui_kit::component::select::Select;
|
||||
use gpui_kit::component::tab::{Tab, TabBar};
|
||||
@@ -9,6 +9,7 @@ use gpui_kit::*;
|
||||
|
||||
mod banner;
|
||||
mod content;
|
||||
mod data;
|
||||
|
||||
pub(in crate::page) use content::{BannerContent, Line};
|
||||
|
||||
@@ -88,53 +89,6 @@ pub(in crate::page) fn count_badge(
|
||||
}
|
||||
|
||||
impl Page {
|
||||
/// The Season of the home's Challenge, and the scope to compute for it when the Statistics
|
||||
/// tab's does not already cover it. The Format never applies to the home.
|
||||
pub(in crate::page) fn settle_home_scope(&mut self) {
|
||||
let season = match &self.season {
|
||||
SeasonScope::Season(name) => Some(name),
|
||||
// A Challenge belongs to one Season: the current one stands in.
|
||||
SeasonScope::AllSeasons => self.current_season.as_ref(),
|
||||
};
|
||||
self.home_season = season.map(|name| name.clone().into());
|
||||
let home = season.map(|name| Scope {
|
||||
season: SeasonScope::Season(name.clone()),
|
||||
format: None,
|
||||
});
|
||||
self.home_scope = home.filter(|home| *home != self.statistics_scope());
|
||||
}
|
||||
|
||||
/// Keeps what was computed for the home's own scope, if it had one, and for which Account.
|
||||
pub(in crate::page) fn set_home_result(
|
||||
&mut self,
|
||||
home: Option<Box<Result<Statistics, String>>>,
|
||||
) {
|
||||
self.home_computed = home
|
||||
.as_ref()
|
||||
.and_then(|_| self.shown.clone().zip(self.home_scope.clone()));
|
||||
(self.home_stats, self.home_error) = match home.map(|result| *result) {
|
||||
Some(Ok(stats)) => (Some(stats), None),
|
||||
Some(Err(error)) => (None, Some(error)),
|
||||
None => (None, None),
|
||||
};
|
||||
}
|
||||
|
||||
pub(in crate::page) fn forget_home(&mut self) {
|
||||
self.home_stats = None;
|
||||
self.home_error = None;
|
||||
self.home_computed = None;
|
||||
}
|
||||
|
||||
/// Whether the home's own statistics were computed for the Account and scope it has now.
|
||||
pub(in crate::page) fn home_is_current(&self) -> bool {
|
||||
match (&self.shown, &self.home_scope, &self.home_computed) {
|
||||
(Some(puuid), Some(scope), Some((computed_puuid, computed_scope))) => {
|
||||
puuid == computed_puuid && scope == computed_scope
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether one Season is selected, rather than all of them: only a Season has a Challenge.
|
||||
pub(in crate::page) fn in_season(&self) -> bool {
|
||||
matches!(self.season, SeasonScope::Season(_))
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
//! The home's own statistics: the scope it computes them for, and what was computed.
|
||||
|
||||
use arena_tracker_core::{Scope, SeasonScope, Statistics};
|
||||
|
||||
use crate::page::Page;
|
||||
|
||||
impl Page {
|
||||
/// The Season of the home's Challenge, and the scope to compute for it when the Statistics
|
||||
/// tab's does not already cover it. The Format never applies to the home.
|
||||
pub(in crate::page) fn settle_home_scope(&mut self) {
|
||||
let season = match &self.season {
|
||||
SeasonScope::Season(name) => Some(name),
|
||||
// A Challenge belongs to one Season: the current one stands in.
|
||||
SeasonScope::AllSeasons => self.current_season.as_ref(),
|
||||
};
|
||||
self.home_season = season.map(|name| name.clone().into());
|
||||
let home = season.map(|name| Scope {
|
||||
season: SeasonScope::Season(name.clone()),
|
||||
format: None,
|
||||
});
|
||||
self.home_scope = home.filter(|home| *home != self.statistics_scope());
|
||||
}
|
||||
|
||||
/// Keeps what was computed for the home's own scope, if it had one, and for which Account.
|
||||
pub(in crate::page) fn set_home_result(
|
||||
&mut self,
|
||||
home: Option<Box<Result<Statistics, String>>>,
|
||||
) {
|
||||
self.home_computed = home
|
||||
.as_ref()
|
||||
.and_then(|_| self.shown.clone().zip(self.home_scope.clone()));
|
||||
(self.home_stats, self.home_error) = match home.map(|result| *result) {
|
||||
Some(Ok(stats)) => (Some(stats), None),
|
||||
Some(Err(error)) => (None, Some(error)),
|
||||
None => (None, None),
|
||||
};
|
||||
}
|
||||
|
||||
pub(in crate::page) fn forget_home(&mut self) {
|
||||
self.home_stats = None;
|
||||
self.home_error = None;
|
||||
self.home_computed = None;
|
||||
}
|
||||
|
||||
/// Whether the home's own statistics were computed for the Account and scope it has now.
|
||||
pub(in crate::page) fn home_is_current(&self) -> bool {
|
||||
match (&self.shown, &self.home_scope, &self.home_computed) {
|
||||
(Some(puuid), Some(scope), Some((computed_puuid, computed_scope))) => {
|
||||
puuid == computed_puuid && scope == computed_scope
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -123,7 +123,7 @@ impl Page {
|
||||
let grid = grid.read(cx);
|
||||
Some(crate::card_lift::layer(
|
||||
grid.cards().clone(),
|
||||
grid.positions().clone(),
|
||||
grid.drawn_cards().clone(),
|
||||
grid.images().cloned(),
|
||||
lifted,
|
||||
changing.map_or(Changes::Taken(lowered), Changes::Match),
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
//! Measurement aid for issue #27: page parts hidden with `--features profile`.
|
||||
|
||||
/// Hides page parts for issue #27 measurements only with `--features profile`.
|
||||
#[inline]
|
||||
pub(in crate::page) fn shown(part: &str) -> bool {
|
||||
#[cfg(feature = "profile")]
|
||||
{
|
||||
static HIDDEN: std::sync::OnceLock<Vec<String>> = std::sync::OnceLock::new();
|
||||
!HIDDEN
|
||||
.get_or_init(|| {
|
||||
std::env::var("ARENA_TRACKER_HIDE")
|
||||
.unwrap_or_default()
|
||||
.split(',')
|
||||
.map(str::trim)
|
||||
.filter(|part| !part.is_empty())
|
||||
.map(str::to_owned)
|
||||
.collect()
|
||||
})
|
||||
.iter()
|
||||
.any(|hidden| hidden == part)
|
||||
}
|
||||
#[cfg(not(feature = "profile"))]
|
||||
{
|
||||
let _ = part;
|
||||
true
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ use std::sync::Arc;
|
||||
use std::time::Instant;
|
||||
|
||||
impl Page {
|
||||
pub fn new(
|
||||
pub(crate) fn new(
|
||||
tracker: Arc<Tracker>,
|
||||
launch: Launch,
|
||||
rx: Receiver<Msg>,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
//! The « Statistiques » tab: the analysis of one Account, Season and Format.
|
||||
|
||||
mod data;
|
||||
mod scope;
|
||||
|
||||
use arena_tracker_core::{ChallengeSummary, Charts, ProgressCheck, StateFilter};
|
||||
use gpui_kit::component::chart::{AreaChart, BarChart};
|
||||
|
||||
@@ -4,7 +4,7 @@ use gpui_kit::*;
|
||||
use super::motion::Leaving;
|
||||
use super::{Entry, Leave, Taken};
|
||||
use crate::card::{self, Card, Pose};
|
||||
use crate::card_grid::CardPositions;
|
||||
use crate::card_grid::DrawnCards;
|
||||
use crate::card_images::CardImages;
|
||||
use crate::card_lift::{self, Layer};
|
||||
use std::time::Instant;
|
||||
@@ -54,7 +54,7 @@ impl<'a> Drawn<'a> {
|
||||
/// card out of sight is not built. Painted after the rest of the page, as the lifted cards are.
|
||||
pub(crate) fn hand_layer(
|
||||
cards: std::rc::Rc<[Card]>,
|
||||
positions: CardPositions,
|
||||
drawn_cards: DrawnCards,
|
||||
images: Option<Entity<CardImages>>,
|
||||
motion: HandMotion,
|
||||
) -> AnyElement {
|
||||
@@ -62,20 +62,20 @@ pub(crate) fn hand_layer(
|
||||
canvas(
|
||||
move |_, window, cx| {
|
||||
let background = cx.theme().background;
|
||||
let positions = positions.borrow();
|
||||
let drawn_cards = drawn_cards.borrow();
|
||||
let now = motion.now;
|
||||
let mut quads = Vec::new();
|
||||
let mut moving = Vec::new();
|
||||
// In the hand's order: the cards dealt later go over the earlier ones.
|
||||
for (ix, card) in cards.iter().enumerate() {
|
||||
let Some(place) = positions.get(&card.id) else {
|
||||
let Some(drawn) = drawn_cards.get(&card.id) else {
|
||||
continue;
|
||||
};
|
||||
// How far a card dealt comes from: the bottom of the window.
|
||||
let from = || {
|
||||
(place.visible.bottom() - place.bounds.top())
|
||||
(drawn.visible.bottom() - drawn.bounds.top())
|
||||
.as_f32()
|
||||
.max(place.bounds.size.height.as_f32())
|
||||
.max(drawn.bounds.size.height.as_f32())
|
||||
};
|
||||
// At most two: the card, and the card as it was fading over it.
|
||||
let mut draw: [Option<Drawn>; 2] = [None, None];
|
||||
@@ -83,8 +83,8 @@ pub(crate) fn hand_layer(
|
||||
// Where it was when the champ select ended. A card that was not in the
|
||||
// hand then is not seen: its place stays covered.
|
||||
let Some((ix, was)) = leave.card(card.id, ix) else {
|
||||
if place.bounds.intersects(&place.visible) {
|
||||
quads.push(Layer::Quad(place.bounds, background, place.visible));
|
||||
if drawn.bounds.intersects(&drawn.visible) {
|
||||
quads.push(Layer::Quad(drawn.bounds, background, drawn.visible));
|
||||
}
|
||||
continue;
|
||||
};
|
||||
@@ -125,10 +125,10 @@ pub(crate) fn hand_layer(
|
||||
if draw[0].is_none() {
|
||||
continue;
|
||||
}
|
||||
if place.bounds.intersects(&place.visible) {
|
||||
quads.push(Layer::Quad(place.bounds, background, place.visible));
|
||||
if drawn.bounds.intersects(&drawn.visible) {
|
||||
quads.push(Layer::Quad(drawn.bounds, background, drawn.visible));
|
||||
}
|
||||
let size = place.bounds.size;
|
||||
let size = drawn.bounds.size;
|
||||
for Drawn {
|
||||
card,
|
||||
pose,
|
||||
@@ -136,18 +136,18 @@ pub(crate) fn hand_layer(
|
||||
opacity,
|
||||
} in draw.into_iter().flatten()
|
||||
{
|
||||
let origin = place.bounds.origin + point(px(0.), px(down));
|
||||
let origin = drawn.bounds.origin + point(px(0.), px(down));
|
||||
// Out of sight, as a card still under the bottom of the window: GPUI
|
||||
// would cut it whole, so it is not built (rule #1).
|
||||
if opacity <= 0. || !Bounds::new(origin, size).intersects(&place.visible) {
|
||||
if opacity <= 0. || !Bounds::new(origin, size).intersects(&drawn.visible) {
|
||||
continue;
|
||||
}
|
||||
// A lifted card is cut as its own layer cuts it: not at all when the grid
|
||||
// shows it whole, so it is still over the list's edge.
|
||||
let (element, cut) = if pose.progress > 0. {
|
||||
(card::lifted(card, pose, size, cx), card_lift::cut(place))
|
||||
(card::lifted(card, pose, size, cx), card_lift::cut(drawn))
|
||||
} else {
|
||||
(card::moving(card, pose.veil, size, cx), Some(place.visible))
|
||||
(card::moving(card, pose.veil, size, cx), Some(drawn.visible))
|
||||
};
|
||||
let mask = cut.map(|bounds| ContentMask { bounds });
|
||||
moving.push(card_lift::prepaint_card(
|
||||
|
||||
@@ -68,7 +68,8 @@ pub fn riot_id(game_name: &str, tag_line: &str) -> String {
|
||||
format!("{game_name}#{tag_line}")
|
||||
}
|
||||
|
||||
/// Compare Riot IDs case-insensitively, including the tag line.
|
||||
/// Riot IDs differ in case only when they name the same Account: they compare
|
||||
/// case-insensitively, tag line included.
|
||||
///
|
||||
/// ```
|
||||
/// use arena_tracker_core::same_riot_id;
|
||||
|
||||
Reference in new issue
Block a user