Lighten the ring and the splash and follow the pointer and the scope (#84)
CI / core (pull_request) Successful in 1m36s
CI / core (pull_request) Successful in 1m36s
From the review of PR #94: - The ring tessellates its fixed shapes once per set of ticks and size; a hover tessellates only the lit tick. - The banner decodes its splash itself, one at a time, on GPUI's low-priority queue at below-normal thread priority: a splash asked for while another decodes waits, so two at most are ever held. - Opening « Paramètres » gives back the splash and the grids' portraits. - The grid has one hover transition: a card that leaves the grid puts its tick out, and a wheel that moves no card keeps it. - The home column scrolls in a low window, so the grid stays reachable. - Entering or leaving a champ select clears the banner until the new scope's statistics arrive. - Tests: drawing the ring alone draws no grid and builds no card. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WYQB8paBcLk67XoAUYARBK
This commit is contained in:
1 parent
d256dd61d2
commit
4fb8b37509
10 files changed
+495
-136
No files matched your search
+47
-10
@@ -104,6 +104,9 @@ pub struct CardGrid {
|
||||
scroll: UniformListScrollHandle,
|
||||
/// The card under the pointer, which shows its sheet.
|
||||
hovered: Option<u32>,
|
||||
/// 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,
|
||||
/// One per card id, kept across `set_cards` and dropped with the card.
|
||||
focus: HashMap<u32, CardFocus>,
|
||||
/// The cards changed since the focus handles were last matched to them.
|
||||
@@ -131,6 +134,7 @@ impl CardGrid {
|
||||
shown: Vec::new(),
|
||||
scroll: UniformListScrollHandle::new(),
|
||||
hovered: None,
|
||||
drawn_scroll: Pixels::ZERO,
|
||||
focus: HashMap::new(),
|
||||
focus_stale: false,
|
||||
fit_content: false,
|
||||
@@ -163,6 +167,7 @@ impl CardGrid {
|
||||
if *self.cards != *cards {
|
||||
self.cards = cards;
|
||||
self.focus_stale = true;
|
||||
self.forget_hover_if_gone(cx);
|
||||
cx.notify();
|
||||
}
|
||||
}
|
||||
@@ -193,10 +198,29 @@ impl CardGrid {
|
||||
(false, Some(current)) if current == id => None,
|
||||
(false, current) => current,
|
||||
};
|
||||
if next != self.hovered {
|
||||
self.hovered = next;
|
||||
cx.emit(CardHovered(next));
|
||||
cx.notify();
|
||||
self.hover(next, cx);
|
||||
}
|
||||
|
||||
/// The one change of the card under the pointer: it draws the grid again and is told
|
||||
/// (the ring lights that card's tick). True when it changed.
|
||||
fn hover(&mut self, next: Option<u32>, cx: &mut Context<Self>) -> bool {
|
||||
if next == self.hovered {
|
||||
return false;
|
||||
}
|
||||
self.hovered = next;
|
||||
cx.emit(CardHovered(next));
|
||||
cx.notify();
|
||||
true
|
||||
}
|
||||
|
||||
/// The card under the pointer is no longer shown (filtered out, or gone with new cards):
|
||||
/// none is hovered until the pointer moves again.
|
||||
fn forget_hover_if_gone(&mut self, cx: &mut Context<Self>) {
|
||||
let shown = |id| {
|
||||
(self.shown.iter()).any(|&ix| self.cards.get(ix).is_some_and(|card| card.id == id))
|
||||
};
|
||||
if self.hovered.is_some_and(|id| !shown(id)) {
|
||||
self.hover(None, cx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,13 +255,22 @@ impl CardGrid {
|
||||
window.focus(&handle, cx);
|
||||
}
|
||||
|
||||
/// How far down the list is scrolled, as its next layout will put it: a wheel past either end
|
||||
/// is held there.
|
||||
fn scrolled_to(&self) -> Pixels {
|
||||
let handle = &self.scroll.0.borrow().base_handle;
|
||||
handle
|
||||
.offset()
|
||||
.y
|
||||
.max(-handle.max_offset().y)
|
||||
.min(Pixels::ZERO)
|
||||
}
|
||||
|
||||
/// The grid is not shown any more: its portraits are given back, in memory and in the
|
||||
/// window's atlas, and load again when it is drawn.
|
||||
pub fn release_images(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||
// Nor is any of its cards under the pointer: the ring's tick goes out.
|
||||
if self.hovered.take().is_some() {
|
||||
cx.emit(CardHovered(None));
|
||||
}
|
||||
self.hover(None, cx);
|
||||
let released = self
|
||||
.images
|
||||
.as_ref()
|
||||
@@ -251,6 +284,7 @@ impl CardGrid {
|
||||
pub fn set_shown(&mut self, shown: Vec<usize>, cx: &mut Context<Self>) {
|
||||
if self.shown != shown {
|
||||
self.shown = shown;
|
||||
self.forget_hover_if_gone(cx);
|
||||
cx.notify();
|
||||
}
|
||||
}
|
||||
@@ -344,9 +378,11 @@ impl CardGrid {
|
||||
// A wheel scroll moves cards under a still pointer without a hover event: the
|
||||
// sheet of the card that was under it would stay. The next mouse move hovers again.
|
||||
.on_scroll(cx.listener(|grid, _: &ScrollEvent, _, cx| {
|
||||
if grid.hovered.take().is_some() {
|
||||
cx.emit(CardHovered(None));
|
||||
cx.notify();
|
||||
// The list has scrolled first. A grid that fits its content is moved by its
|
||||
// parent's scrolling instead, which it cannot see.
|
||||
let moved = grid.fit_content || grid.scrolled_to() != grid.drawn_scroll;
|
||||
if moved {
|
||||
grid.hover(None, cx);
|
||||
}
|
||||
}))
|
||||
.on_action(cx.listener(|grid, _: &NextCard, window, cx| grid.move_focus(1, window, cx)))
|
||||
@@ -365,6 +401,7 @@ impl Render for CardGrid {
|
||||
if self.focus_stale {
|
||||
self.sync_focus(window, cx);
|
||||
}
|
||||
self.drawn_scroll = self.scrolled_to();
|
||||
let images = (self.images)
|
||||
.get_or_insert_with(|| CardImages::new(cx))
|
||||
.clone();
|
||||
|
||||
Reference in new issue
Block a user