From 5e8a1c825bdf373ba90db2fd72087ecf13b41e14 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Fri, 27 Nov 2026 14:51:29 +0000 Subject: [PATCH] shell-w7: net change of 3 commits - shell-w7: written from its sheet - shell-w7: written by an agent - shell-w7: review fixes (review-1) --- crates/ui-egui/src/backstage.rs | 395 ++++------- crates/ui-egui/src/backstage/files.rs | 529 +++++++------- crates/ui-egui/src/backstage/tests.rs | 955 +++++++++----------------- 3 files changed, 691 insertions(+), 1188 deletions(-) diff --git a/crates/ui-egui/src/backstage.rs b/crates/ui-egui/src/backstage.rs index 4fd295892..a6b60636a 100644 --- a/crates/ui-egui/src/backstage.rs +++ b/crates/ui-egui/src/backstage.rs @@ -1,22 +1,20 @@ -//! The File tab (Backstage, #76): a full-window view that replaces the ribbon, slides and status -//! bar until Esc or the back arrow returns to the presentation. With nothing open it is the start -//! screen: PowerPoint's start screen and File › Home are the same page. +//! The File tab replaces the editor until the user returns to the presentation. +//! With no document it is the start screen, showing the same Home page. //! //! A side menu on the left picks a page (Home, New, Open, Info, Save As, Print, Export, About); //! Save, Close and Options act at once. Every action runs an existing command through //! [`SlideApp::run`] or one of the app's file helpers ([`SlideApp::export_as`], //! [`SlideApp::print_pdf`], [`SlideApp::save_as_dialog`]); the state here is UI-only and never //! saved. Recent presentations are listed by path: nothing on disk is read until one is picked. -//! -//! Laid out after PowerPoint for Windows (observed black-box): a 160-point side menu darker than -//! the page, 40-point entries with an outline icon, the current page in the accent colour. -use egui::{Align2, Color32, CornerRadius, Key, Rect, RichText, Sense, Stroke, StrokeKind, Ui, pos2, vec2}; +use craft::menu::ribbon::{BackstageEntry, BackstageEvent, BackstageView}; +use craft::ui::contract::{BodyCx, Show as _}; +use craft::ui::display::Text; +use egui::Ui; use serde_json::{Value, json}; use crate::SlideApp; -use crate::icons::{self, Icon}; -use crate::theme::{self, Tokens}; +use crate::icons::Icon; mod files; mod info; @@ -24,33 +22,34 @@ mod print; pub use files::split_path; use files::{home, new_page, open_page}; +pub use info::SAVE_TYPES; use info::{PROPERTIES, about, commit_props, info, save_as}; -pub use info::{SAVE_TYPES, format_bytes}; use print::{export, print}; pub use print::{print_page_size, print_params, print_slides}; -/// Width of the side menu. -pub const NAV_W: f32 = 160.0; -/// Height of a side-menu entry (the back arrow's row is a little taller). -const ITEM_H: f32 = 40.0; -const BACK_H: f32 = 46.0; -/// The widest a page's content grows. -const CONTENT_W: f32 = 1180.0; - /// A page of the File tab. #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub enum Page { + /// Start page and recent presentations. Home, + /// Blank presentations, themes and templates. New, + /// File browsing and recent presentations. Open, + /// Presentation metadata and properties. Info, + /// A destination and format for saving. SaveAs, + /// Print settings and page previews. Print, + /// Copies in other formats. Export, + /// Product information and appearance settings. About, } impl Page { + /// Every File page accepted by the automation command. pub const ALL: [Page; 8] = [Page::Home, Page::New, Page::Open, Page::Info, Page::SaveAs, Page::Print, Page::Export, Page::About]; /// The id `app.backstage {page}` takes. @@ -67,9 +66,10 @@ impl Page { } } + /// Resolve a File page id, including its compatibility alias. pub fn parse(id: &str) -> Option { let id = id.trim(); - // Keep existing control-channel callers working after the visible page rename. + // The compatibility alias keeps saved automation requests valid. if id.eq_ignore_ascii_case("account") { return Some(Page::About); } @@ -112,9 +112,13 @@ impl Page { /// A side-menu entry: a page, or an action that runs at once. #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub enum Nav { + /// Shows a File page. Page(Page), + /// Saves the active presentation. Save, + /// Requests closing the active presentation. Close, + /// Opens preferences above the File view. Options, } @@ -127,6 +131,7 @@ impl Nav { Nav::Options => "Options", } } + fn icon(self) -> Icon { match self { Nav::Page(p) => p.icon(), @@ -137,29 +142,36 @@ impl Nav { } } -/// The side menu, top group then bottom group, in keyboard order. PowerPoint's Share (cloud) is -/// left out; with nothing open only Home, New and Open stay at the top. -pub fn entries(has_doc: bool) -> (Vec