variables: put the panel in the collapsed icon column
Opening the panel from the Window menu worked, but collapsing the dock did not show it: `ICON_PANELS` only registers a panel (so `window.panel` finds it) while `ICON_PANEL_GROUPS` is what the collapsed column actually draws, and `variables` was in the first list only. Sixteen panels are registered without a group; for the ones meant to live in the column, the entry in `ICON_PANELS` alone is not enough. `variables` gets a row of its own at the bottom of the column, where the reference app keeps it. Both lists now say which is which, so the next panel does not repeat this, and a test asserts a registered panel reaches the column (it fails without the group entry) and that every grouped id names a registered panel with an icon. `floating.rs`'s icon test counted the column's icons, which only means "one left" while the column is tall enough to show them all — past that, one scrolling into view replaces the one that left. It runs on a window tall enough for every icon now, and checks the count is the number of registered groups' icons rather than a number that happens to pass. Dragging a panel into the icon column still doesn't work, and is not something this PR changes: tearing a panel off makes it float, for every panel. Docking it back into the column would be a dock feature of its own. cargo xtask ci: all 7 steps pass on Rust 1.99.
This commit is contained in:
parent
5a638b0a80
commit
06dbe5b1e8
|
|
@ -496,12 +496,13 @@ mod tests {
|
|||
|
||||
const SCREEN: Vec2 = vec2(1400.0, 900.0);
|
||||
|
||||
/// Frames of the whole window, 1400 × 900, with pointer input one event a frame (as the
|
||||
/// control channel's `ui.drag` sends it).
|
||||
/// Frames of the whole window, with pointer input one event a frame (as the control
|
||||
/// channel's `ui.drag` sends it).
|
||||
struct Harness {
|
||||
app: VectorcraftApp,
|
||||
ctx: egui::Context,
|
||||
time: f64,
|
||||
screen: Vec2,
|
||||
}
|
||||
|
||||
fn button(pos: Pos2, pressed: bool) -> Event {
|
||||
|
|
@ -510,16 +511,23 @@ mod tests {
|
|||
|
||||
impl Harness {
|
||||
fn new() -> Self {
|
||||
Self::on(SCREEN)
|
||||
}
|
||||
|
||||
/// The same window at another size. The icon column scrolls when it is too short for
|
||||
/// every icon, which hides the ones past the bottom — a test that counts them needs
|
||||
/// a window tall enough to show them all.
|
||||
fn on(screen: Vec2) -> Self {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.run("file.new", json!({"width": 300, "height": 300})).unwrap();
|
||||
let mut h = Self { app, ctx: egui::Context::default(), time: 0.0 };
|
||||
let mut h = Self { app, ctx: egui::Context::default(), time: 0.0, screen };
|
||||
h.settle();
|
||||
h
|
||||
}
|
||||
|
||||
fn frame(&mut self, events: Vec<Event>) {
|
||||
self.time += 0.05;
|
||||
let screen = Rect::from_min_size(Pos2::ZERO, SCREEN);
|
||||
let screen = Rect::from_min_size(Pos2::ZERO, self.screen);
|
||||
let raw = egui::RawInput { time: Some(self.time), screen_rect: Some(screen), events, ..Default::default() };
|
||||
let app = &mut self.app;
|
||||
self.ctx
|
||||
|
|
@ -651,10 +659,13 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn icons_dragged_out_float_stack_onto_another_group_and_tear_out_of_it() {
|
||||
let mut h = Harness::new();
|
||||
// Tall enough that the icon column shows every icon, so counting them says what it
|
||||
// means: one leaves the column, rather than one more scrolling into view.
|
||||
let mut h = Harness::on(vec2(1400.0, 1600.0));
|
||||
// Color, Color Guide, Swatches… top to bottom.
|
||||
let icons = h.icons();
|
||||
let count = icons.len();
|
||||
assert_eq!(count, crate::state::ICON_PANEL_GROUPS.iter().map(|g| g.len()).sum::<usize>(), "every group's icons are drawn");
|
||||
h.drag(icons[2].center(), pos2(500.0, 250.0));
|
||||
assert_eq!(h.groups(), [["swatches"]]);
|
||||
assert_eq!(h.icons().len(), count - 1, "its icon left the column");
|
||||
|
|
|
|||
|
|
@ -293,6 +293,22 @@ mod tests {
|
|||
assert!(crate::icons::exists(row.2), "{} is not a bundled icon", row.2);
|
||||
}
|
||||
|
||||
/// The collapsed column draws `ICON_PANEL_GROUPS`, not `ICON_PANELS`: a panel registered
|
||||
/// but in no group opens from the Window menu and then has nowhere to collapse to. Both
|
||||
/// lists need an entry, and this is the one that was missing.
|
||||
#[test]
|
||||
fn the_panel_reaches_the_collapsed_icon_column() {
|
||||
let in_column = crate::state::ICON_PANEL_GROUPS.iter().any(|g| g.contains(&ID));
|
||||
assert!(in_column, "{ID} is in ICON_PANELS but in no ICON_PANEL_GROUPS row, so the collapsed column never draws it");
|
||||
// Every id in a group names a panel that is registered with a label and an icon.
|
||||
for group in crate::state::ICON_PANEL_GROUPS {
|
||||
for id in *group {
|
||||
let row = crate::state::ICON_PANELS.iter().find(|p| p.0 == *id).unwrap_or_else(|| panic!("{id} is in a group but not registered"));
|
||||
assert!(!row.1.is_empty() && crate::icons::exists(row.2), "{id}: {} / {}", row.1, row.2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Every Variables command is in the Window menu, so the feature is reachable without an
|
||||
/// agent: the palette runs these with empty params, which the dialogs turn into a form.
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -142,6 +142,10 @@ pub const ICON_PANELS: &[(&str, &str, &str)] = &[
|
|||
];
|
||||
|
||||
/// Groups of icon panels separated by dividers in the collapsed column.
|
||||
///
|
||||
/// This, not [`ICON_PANELS`], is what the collapsed column draws: a panel listed there but in
|
||||
/// no group can be opened from the Window menu and `window.panel`, but never appears as an
|
||||
/// icon. A panel that belongs in the column needs a row here as well as its entry above.
|
||||
pub const ICON_PANEL_GROUPS: &[&[&str]] = &[
|
||||
&["color", "colorGuide"],
|
||||
&["swatches", "brushes", "symbols", "patternOptions"],
|
||||
|
|
@ -151,6 +155,7 @@ pub const ICON_PANEL_GROUPS: &[&[&str]] = &[
|
|||
&["transform", "align", "pathfinder"],
|
||||
&["character", "paragraph", "glyphs"],
|
||||
&["history", "actions", "info", "navigator"],
|
||||
&["variables"],
|
||||
];
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
|
|
|
|||
Loading…
Reference in New Issue