From bc563b6c829da268380daa2682840eb49315f813 Mon Sep 17 00:00:00 2001 From: aiongg Date: Sat, 14 Nov 2026 15:48:35 +0000 Subject: [PATCH] panels-w8: written from its sheet --- .../src/patterns/panels/history.rs | 306 ++++++++++++++++-- .../src/patterns/panels/history/stories.rs | 51 +++ crates/ui-patterns/src/patterns/panels/mod.rs | 2 +- .../ui-patterns/src/patterns/panels/words.rs | 9 + crates/ui-patterns/tests/it/panels/history.rs | 74 +++++ 5 files changed, 407 insertions(+), 35 deletions(-) create mode 100644 crates/ui-patterns/src/patterns/panels/history/stories.rs create mode 100644 crates/ui-patterns/tests/it/panels/history.rs diff --git a/crates/ui-patterns/src/patterns/panels/history.rs b/crates/ui-patterns/src/patterns/panels/history.rs index 812313030..283eeeca1 100644 --- a/crates/ui-patterns/src/patterns/panels/history.rs +++ b/crates/ui-patterns/src/patterns/panels/history.rs @@ -1,11 +1,34 @@ //! `HistoryPanel`: the undo history as a list of states and named snapshots, with a footer of snapshot buttons. -use crate::contract::{NoValue, Outcome, Pattern}; -use crate::primitives::textures::{ThumbSource, Thumbnails}; -use crate::runtime::env::Label; -use craft_behavior::IconId; +use super::words::PanelWords; +use crate::contract::{ + Bind, CollectionEvent, ColumnSpec, ListDrag, NoValue, Outcome, Pattern, Props as _, SelectMode, ShowCollection as _, ShowContainer as _, Sizing, + ToggleColumn, request_rename, +}; +use crate::layout_components::Stack; +use crate::list::{List, ListRow, RowInk, ThumbSize, ToggleCell, ToggleState}; +use crate::menu::{Menu, MenuItem}; +use crate::primitives::IconSpec; +use crate::primitives::textures::{Priority, ThumbPaint, ThumbRequest, ThumbSource, Thumbnails}; +use crate::runtime::env::{Env, Label}; +use crate::sections::{FooterAction, FooterBar}; +use craft_behavior::{ColumnKey, ColumnWidth, GesturePhase, IconId, Selection, SelectionChange, keyed}; use craft_keymap::Mods; use egui::{Response, Ui}; +use std::cell::RefCell; +use std::collections::HashSet; +use std::hash::{DefaultHasher, Hash, Hasher}; +use std::sync::Arc; + +#[cfg(feature = "testing")] +mod stories; + +/// The column of the source marks. +const SOURCE: ColumnKey = ColumnKey::new("historySource"); +/// The column of the names. +const NAME: ColumnKey = ColumnKey::new("historyName"); +/// The width in points a snapshot's picture is requested for. +const THUMB_POINTS: f32 = 32.0; /// What a history row stands for: a named snapshot or a state of the undo stack, by number. #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] @@ -31,30 +54,32 @@ pub struct HistoryRow { } impl HistoryRow { + fn new(key: HistoryKey, label: Label) -> Self { + HistoryRow { key, label, icon: None, redo: false } + } + /// A row for the snapshot `id` named `label`. pub fn snapshot(id: u64, label: impl Into