From 5cc4857bdcb5470c0d50f06b0810a6e8a308fdf1 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Wed, 25 Nov 2026 18:03:27 +0700 Subject: [PATCH] Home: Learn after the presets, as one row of skill cards The presets stand right under New and Open again, as in 0.24.1, and Learn follows them before Community. Learn is a Column page section whose heading row ends in the Quick skill guide link (learn.skills), over a raised card per skill: its title over its tutorials as plain links (learn.show), a page link gap apart. The four cards stand in one row in a full-width column and two by two in a narrower one. The section is about half as tall as before (161 points at 1600x1000, was 333). --- crates/ui-egui/src/canvas/home.rs | 87 ++++++++++++++++-------------- crates/ui-egui/src/panels/learn.rs | 8 ++- crates/ui-egui/src/tests/home.rs | 6 ++- docs/mcp.md | 6 +-- docs/target-app-parity.md | 2 +- 5 files changed, 59 insertions(+), 50 deletions(-) diff --git a/crates/ui-egui/src/canvas/home.rs b/crates/ui-egui/src/canvas/home.rs index 556574d1ba..d95cdc02e1 100644 --- a/crates/ui-egui/src/canvas/home.rs +++ b/crates/ui-egui/src/canvas/home.rs @@ -1,11 +1,13 @@ -use craft::behavior::IconId; -use craft::ui::buttons::{Button, ControlPlace, LinkLook}; -use craft::ui::contract::{Bind, Gap, Props as _, Show as _, ShowContainer as _}; -use craft::ui::display::{Shade, Text}; -use craft::ui::layout_components::{Row, Stack}; -use craft::ui::runtime::env::{Overrides, with_env}; -use craft::ui::shell::{RecentFile, StartAction, StartLayout, StartLink, StartScreen, Template}; -use craft::ui::style::TypeRole; +use craft::behavior::{ColumnWidth, IconId}; +use craft::ui::buttons::{Link, LinkLook}; +use craft::ui::contract::{Bind, Gap, Pad, Props as _, Show as _, ShowContainer as _, clicked}; +use craft::ui::display::Text; +use craft::ui::layout::CellAlign; +use craft::ui::layout_components::{Grid, Stack}; +use craft::ui::runtime::env::{Env, Overrides, with_env}; +use craft::ui::sections::Section; +use craft::ui::shell::{RecentFile, StartAction, StartLayout, StartLink, StartPlace, StartScreen, Template}; +use craft::ui::style::{SurfaceKind, TypeRole}; use super::{Ui, VectorcraftApp, json}; @@ -15,6 +17,10 @@ const TEMPLATES: [&str; 6] = ["Letter", "A4", "Web 1920×1080", "Phone 390×844" /// The icons of the three `community::link_urls` links, in their order. const LINK_ICONS: [&str; 3] = ["globe", "external-link", "git-branch"]; +/// The Learn cards across a full-width column, and across a narrower one. +const FOUR: &[ColumnWidth] = &[ColumnWidth::fill(1.0); 4]; +const TWO: &[ColumnWidth] = &[ColumnWidth::fill(1.0); 2]; + /// The Home screen (`app.home`; with no document open, unless its preference is off). pub(super) fn home(app: &mut VectorcraftApp, ui: &mut Ui, rect: egui::Rect) { let recent: Vec = crate::io::recent_files(app) @@ -37,16 +43,14 @@ pub(super) fn home(app: &mut VectorcraftApp, ui: &mut Ui, rect: egui::Rect) { for ((label, url), icon) in crate::community::link_urls(app).into_iter().zip(LINK_ICONS) { links.push(StartLink::url(tl!(label), Some(IconId::new(icon)), url)); } - // The column shows no view switch or sort; the bindings hold copies so the Learn section can borrow the app. - let (mut view, mut sort) = (app.ui.home_view, app.ui.home_sort); let mut pressed = None; - let mut learn = |ui: &mut Ui| learn(app, ui, &mut pressed); let mut child = ui.new_child(egui::UiBuilder::new().max_rect(rect).layout(egui::Layout::top_down(egui::Align::Min))); // Production's community links read in the accent alone, with no underline. let plain_links = |overrides: &mut Overrides| { overrides.values.set(LinkLook::Plain); }; - let start = StartScreen::new(Bind::bound(&mut view), Bind::bound(&mut sort), &recent) + // Learn follows the presets, which stand right under New and Open as in production 0.24.1. + let start = StartScreen::new(Bind::bound(&mut app.ui.home_view), Bind::bound(&mut app.ui.home_sort), &recent) .layout(StartLayout::Column) .title(tl!("Welcome to VectorCraft")) .subtitle(tl!("Vector illustration — fast, open, scriptable.")) @@ -57,15 +61,13 @@ pub(super) fn home(app: &mut VectorcraftApp, ui: &mut Ui, rect: egui::Rect) { .templates_title(tl!("Quickly start a new file")) .links(&links) .links_title(tl!("Community")) - .app_section(tl!("Learn"), &mut learn); + .section(StartPlace::AfterSections, |ui, _| learn(ui, &mut pressed)); let out = with_env(&mut child, plain_links, |ui| start.show(ui)); - app.ui.home_view = view; - app.ui.home_sort = sort; for action in out.actions { run_action(app, action); } - if let Some(id) = pressed - && let Err(e) = app.run("learn.show", json!({ "tutorial": id })) + if let Some((command, args)) = pressed + && let Err(e) = app.run(command, args) { app.status(e); } @@ -92,31 +94,36 @@ fn run_action(app: &mut VectorcraftApp, action: StartAction) { } } -/// The Home screen's Learn section: the Quick skill guide card, which shows the Learn panel's list -/// of skills, and the Learn panel's tutorials under their skills (each title dim over its tutorials), each a button -/// that shows the panel at its steps (`learn.show`), as tall as New and Open and a page heading's gap apart, as -/// production spaced them. The start screen may run this twice in a pass, so it only draws and records the tutorial -/// pressed in `pressed`. -fn learn(app: &mut VectorcraftApp, ui: &mut Ui, pressed: &mut Option<&'static str>) { - use crate::panels::learn::{catalog, guide_card}; - let _ = Stack::new().gap(Gap::PageHeading).fill_width().show(ui, |ui, _| { - guide_card(app, ui); // PLAN: assumed `guide_card(app, ui)` as document-panels-w18 leaves it, on `Button::detail`. - for skill in catalog::SKILLS { - let _ = Stack::new().gap(Gap::Stack).fill_width().show(ui, |ui, _| { - let _ = Text::new(skill.title).role(TypeRole::Label).shade(Shade::Muted).show(ui); - let place = |overrides: &mut Overrides| { - overrides.values.set(ControlPlace::PageAction); - }; - let _ = with_env(ui, place, |ui| { - Row::new().show(ui, |ui, _| { - for tutorial in skill.tutorials { - if Button::new(tutorial.title).id_salt(tutorial.id).show(ui).clicked() { - *pressed = Some(tutorial.id); +/// The Home screen's Learn section, after the new-file presets: a Column page section whose heading row ends in the +/// Quick skill guide link, which shows the Learn panel's list of skills (`learn.skills`), over a card per skill: its +/// title over its tutorials as links, each showing the panel at its steps (`learn.show`). The four cards stand in one +/// row in a column at its full `size.page.column` width, and two by two in a narrower one. The start screen may run +/// this twice in a pass, so it only draws and records the command chosen in `pressed`. +fn learn(ui: &mut Ui, pressed: &mut Option<(&'static str, serde_json::Value)>) { + use crate::panels::learn::catalog::SKILLS; + let (mut guide, mut tutorial) = (false, None); + let across = if ui.available_width() + 0.5 >= Env::of(ui).tokens.size.page.column { FOUR } else { TWO }; + let section = Section::fixed(tl!("Learn")).quiet_header().header_gap(Gap::PageHeading); + let _ = section.controls(|ui, _| guide |= clicked(&Link::new(tl!("Quick skill guide")).show(ui))).show(ui, |ui, _| { + let _ = Grid::new(across).gap(Gap::Section).cells(CellAlign::Top).fill_width().show(ui, |ui, _| { + for skill in SKILLS { + let card = Stack::new().surface(SurfaceKind::Raised).pad(Pad::Regular).gap(Gap::Stack).fill_width(); + let _ = card.show(ui, |ui, _| { + let _ = Text::new(skill.title).role(TypeRole::BodyStrong).show(ui); + let _ = Stack::new().gap(Gap::PageLink).show(ui, |ui, _| { + for t in skill.tutorials { + if clicked(&Link::new(t.title).id_salt(t.id).show(ui)) { + tutorial = Some(t.id); } } - }) + }); }); - }); - } + } + }); }); + if guide { + *pressed = Some(("learn.skills", json!({}))); + } else if let Some(id) = tutorial { + *pressed = Some(("learn.show", json!({ "tutorial": id }))); + } } diff --git a/crates/ui-egui/src/panels/learn.rs b/crates/ui-egui/src/panels/learn.rs index 7b67ecc804..d765fe48c3 100644 --- a/crates/ui-egui/src/panels/learn.rs +++ b/crates/ui-egui/src/panels/learn.rs @@ -13,8 +13,7 @@ //! one tutorial, `learn.back` goes up one level, `learn.locateTool` shows where a tool is, //! `learn.openSample`, `learn.markStep`, `learn.finish` and `learn.next` run the practice controls, //! `learn.resetProgress` clears the progress, and `window.learn` shows or hides the panel. The Home -//! screen's Learn section shows the same card ([`guide_card`]) and the tutorials, which open the -//! panel. +//! screen's Learn section links to the list of skills and to each tutorial, which open the panel. pub mod catalog; pub mod locate; @@ -109,9 +108,8 @@ fn for_you(app: &mut VectorcraftApp, ui: &mut Ui) { } /// The Quick skill guide card, as one button: a click, or Enter or Space while it has the keyboard -/// focus, shows the panel's list of skills (`learn.skills`). The For you tab and the Home screen's -/// Learn section show it. -pub(crate) fn guide_card(app: &mut VectorcraftApp, ui: &mut Ui) { +/// focus, shows the panel's list of skills (`learn.skills`). The For you tab shows it. +fn guide_card(app: &mut VectorcraftApp, ui: &mut Ui) { // PLAN: assumed `Button::detail(impl Into