mirror of
https://github.com/storytold/deckcraft.git
synced 2026-12-01 18:23:52 -06:00
File view: titles at 18 px, full-width page, recent remove through app.forgetRecent, glyph Back
DeckCraft's sizes set the Title role (pane and File page titles) to 18 px and the File page column to production's 1180 px. The search fields show their placeholder, every recent row shows its remove button and removing runs the new app.forgetRecent command, the side menu's Back is the glyph alone, and the Export and Info icons use their registered ids so they draw. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
5fae147c51
commit
4fab4dedf2
@@ -65,6 +65,7 @@ pub static UI_COMMANDS: &[UiCommand] = &[
|
||||
UiCommand { id: "app.palette", label: "Command Palette", params: "{}" },
|
||||
UiCommand { id: "app.preferences", label: "Preferences…", params: "{}" },
|
||||
UiCommand { id: "app.openDialog", label: "Open…", params: "{purpose?}" },
|
||||
UiCommand { id: "app.forgetRecent", label: "Remove from Recent", params: "{path} → {recent: [paths]}" },
|
||||
UiCommand { id: "app.insertPictureDialog", label: "Picture from File…", params: "{}" },
|
||||
UiCommand { id: "app.smartArtPictureDialog", label: "Insert Picture in Diagram…", params: "{id?, index}" },
|
||||
UiCommand { id: "app.changePictureDialog", label: "Change Picture…", params: "{}" },
|
||||
|
||||
@@ -285,6 +285,14 @@ impl SlideApp {
|
||||
}
|
||||
"app.preferences" => self.open_dialog("preferences", p.clone()),
|
||||
"app.openDialog" => self.pick_and_open(),
|
||||
"app.forgetRecent" => {
|
||||
let path = p.get("path").and_then(Value::as_str).ok_or("missing `path`")?;
|
||||
if !self.ui.recent.iter().any(|recent| recent == path) {
|
||||
return Err(format!("`{path}` is not in the Recent list"));
|
||||
}
|
||||
self.forget_recent(path);
|
||||
return Ok(json!({"recent": self.ui.recent}));
|
||||
}
|
||||
"app.insertPictureDialog" => self.pick_and_insert("picture", "insert.picture"),
|
||||
"app.smartArtPictureDialog" => {
|
||||
if !self.host.files().can_pick() {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
//! [`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.
|
||||
|
||||
use craft::menu::ribbon::{BackstageEntry, BackstageEvent, BackstageView};
|
||||
use craft::menu::ribbon::{BackLook, BackstageEntry, BackstageEvent, BackstageView};
|
||||
use craft::ui::contract::{BodyCx, Show as _};
|
||||
use craft::ui::display::Text;
|
||||
use egui::Ui;
|
||||
@@ -315,7 +315,13 @@ pub(crate) fn page(app: &mut SlideApp, ui: &mut Ui, cx: &mut BodyCx<'_>) {
|
||||
let bottom = view_entries(bottom);
|
||||
// Measuring does not consume the request: the real pass takes it once.
|
||||
let focus_shown = !craft::ui::runtime::measure::active(ui.ctx()) && std::mem::take(&mut bs.focus_shown);
|
||||
let mut view = BackstageView::new(Nav::Page(bs.page)).back(has_doc).group(&first).group(&document).bottom(&bottom).focus_shown(focus_shown);
|
||||
let mut view = BackstageView::new(Nav::Page(bs.page))
|
||||
.back(has_doc)
|
||||
.back_look(BackLook::Glyph)
|
||||
.group(&first)
|
||||
.group(&document)
|
||||
.bottom(&bottom)
|
||||
.focus_shown(focus_shown);
|
||||
if bs.page != Page::Home {
|
||||
view = view.heading(bs.page.label());
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ use craft::ui::layout_components::{Row, Stack};
|
||||
use craft::ui::list::{List, ListRow, ThumbAspect, ThumbSize};
|
||||
|
||||
use craft::ui::sections::Section;
|
||||
use craft::ui::shell::{RecentFile, RecentList, StartAction};
|
||||
use craft::ui::shell::{RecentFile, RecentList, RecentRemove, StartAction};
|
||||
use craft::ui::style::TypeRole;
|
||||
use craft::ui::text::TextField;
|
||||
use craft::ui::tile_grid::{CardText, Tile, TileGrid};
|
||||
@@ -161,7 +161,9 @@ fn recent_actions(app: &mut SlideApp, actions: Vec<StartAction>) {
|
||||
for action in actions {
|
||||
match action {
|
||||
StartAction::OpenRecent(path) => app.open_path_in_background(&path.to_string_lossy()),
|
||||
StartAction::RemoveRecent(path) => app.forget_recent(&path.to_string_lossy()),
|
||||
StartAction::RemoveRecent(path) => {
|
||||
let _ = app.run("app.forgetRecent", json!({"path": path.to_string_lossy()}));
|
||||
}
|
||||
StartAction::ClearRecent => app.ui.recent.clear(),
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
StartAction::RevealRecent(path) if craft::platform::open::CAN_REVEAL => {
|
||||
@@ -197,10 +199,11 @@ pub(super) fn home(app: &mut SlideApp, ui: &mut Ui, _cx: &mut BodyCx<'_>, bs: &m
|
||||
let files = recent_files(app, &bs.query);
|
||||
let empty = recent_empty(&bs.query);
|
||||
let shown = RecentList::new(&files)
|
||||
.remove(RecentRemove::Always)
|
||||
.max_recent(8)
|
||||
.empty(empty)
|
||||
.controls(|ui, _| {
|
||||
let _ = TextField::search("Search for a file", Bind::bound(&mut bs.query)).show(ui);
|
||||
let _ = TextField::search("Search for a file", Bind::bound(&mut bs.query)).placeholder("Search for a file").show(ui);
|
||||
})
|
||||
.show(ui);
|
||||
recent_actions(app, shown.actions);
|
||||
@@ -214,7 +217,7 @@ pub(super) fn home(app: &mut SlideApp, ui: &mut Ui, _cx: &mut BodyCx<'_>, bs: &m
|
||||
pub(super) fn new_page(app: &mut SlideApp, ui: &mut Ui, _cx: &mut BodyCx<'_>, bs: &mut Backstage) {
|
||||
show_tiles(app, ui, "Blank presentation", &[NewTile::blank()], true);
|
||||
let _ = Divider::horizontal().show(ui);
|
||||
let _ = TextField::search("Search for themes and templates", Bind::bound(&mut bs.query)).show(ui);
|
||||
let _ = TextField::search("Search for themes and templates", Bind::bound(&mut bs.query)).placeholder("Search for themes and templates").show(ui);
|
||||
let themes = theme_tiles(&bs.query, usize::MAX, false);
|
||||
let templates = template_tiles(&bs.query, usize::MAX);
|
||||
show_tiles(app, ui, "Themes", &themes, false);
|
||||
@@ -264,9 +267,9 @@ pub(super) fn open_page(app: &mut SlideApp, ui: &mut Ui, _cx: &mut BodyCx<'_>, b
|
||||
});
|
||||
let _ = Divider::vertical().show(ui);
|
||||
Stack::new().fill_width().show(ui, |ui, _| {
|
||||
let _ = TextField::search("Search for a file", Bind::bound(&mut bs.query)).show(ui);
|
||||
let _ = TextField::search("Search for a file", Bind::bound(&mut bs.query)).placeholder("Search for a file").show(ui);
|
||||
let files = recent_files(app, &bs.query);
|
||||
let shown = RecentList::new(&files).heading("Presentations").empty(recent_empty(&bs.query)).show(ui);
|
||||
let shown = RecentList::new(&files).remove(RecentRemove::Always).heading("Presentations").empty(recent_empty(&bs.query)).show(ui);
|
||||
recent_actions(app, shown.actions);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::{Backstage, Icon, Outcome, Page, SlideApp, Ui, Value, json};
|
||||
use crate::app::files::SaveOutcome;
|
||||
use craft::behavior::{ColumnWidth, IconId};
|
||||
use craft::behavior::ColumnWidth;
|
||||
use craft::ui::buttons::{Arrangement, Button, Link};
|
||||
use craft::ui::contract::{Bind, BodyCx, Entry, FieldLayout, LabelScheme, Props as _, Show as _, ShowContainer as _, Sizing, WrapWidth};
|
||||
use craft::ui::display::{Picture, Shade, Text};
|
||||
@@ -42,7 +42,7 @@ pub(super) const PROPERTIES: [(&str, &str, &str); 7] = [
|
||||
pub(super) fn task_row(ui: &mut Ui, icon: Icon, label: &'static str, title: &'static str, detail: &'static str, enabled: bool) -> bool {
|
||||
Row::new()
|
||||
.show(ui, |ui, _| {
|
||||
let pressed = Button::new(label).icon(IconId::new(icon.name())).arrangement(Arrangement::Stacked).enabled(enabled).show(ui).clicked();
|
||||
let pressed = Button::new(label).icon(icon.id()).arrangement(Arrangement::Stacked).enabled(enabled).show(ui).clicked();
|
||||
Stack::new().wrap_width(WrapWidth::Column).show(ui, |ui, _| {
|
||||
Text::new(title).role(TypeRole::Heading).show(ui);
|
||||
Text::new(detail).shade(Shade::Muted).show(ui);
|
||||
|
||||
@@ -288,7 +288,7 @@ fn choose(
|
||||
row = row.lines(detail);
|
||||
}
|
||||
if let Some(icon) = icon {
|
||||
row = row.icon(craft::behavior::IconId::new(icon.name()).into());
|
||||
row = row.icon(icon.id().into());
|
||||
}
|
||||
row
|
||||
});
|
||||
@@ -331,12 +331,7 @@ pub(super) fn export(app: &mut SlideApp, ui: &mut Ui, _cx: &mut BodyCx<'_>, bs:
|
||||
Text::new("• Opens on any device with a PDF viewer").show(ui);
|
||||
Text::new("• The presentation keeps its own file").show(ui);
|
||||
Checkbox::new(Bind::bound(&mut bs.pdf_hidden)).label("Include hidden slides").show(ui);
|
||||
if Button::new("Create PDF")
|
||||
.icon(craft::behavior::IconId::new(Icon::File.name()))
|
||||
.arrangement(Arrangement::Stacked)
|
||||
.show(ui)
|
||||
.clicked()
|
||||
{
|
||||
if Button::new("Create PDF").icon(Icon::File.id()).arrangement(Arrangement::Stacked).show(ui).clicked() {
|
||||
app.export_as("pdf", json!({"includeHidden": bs.pdf_hidden}));
|
||||
}
|
||||
}
|
||||
@@ -357,12 +352,7 @@ pub(super) fn export(app: &mut SlideApp, ui: &mut Ui, _cx: &mut BodyCx<'_>, bs:
|
||||
Field::new("Slides per page").show(ui, |ui, _| {
|
||||
Select::new("Slides per page", Bind::bound(&mut bs.handouts_per_page), &entries).show(ui);
|
||||
});
|
||||
if Button::new("Create Handouts")
|
||||
.icon(craft::behavior::IconId::new(Icon::Notes.name()))
|
||||
.arrangement(Arrangement::Stacked)
|
||||
.show(ui)
|
||||
.clicked()
|
||||
{
|
||||
if Button::new("Create Handouts").icon(Icon::Notes.id()).arrangement(Arrangement::Stacked).show(ui).clicked() {
|
||||
app.export_as("pdf", json!({"layout": "handouts", "perPage": bs.handouts_per_page}));
|
||||
}
|
||||
}
|
||||
@@ -379,7 +369,7 @@ pub(super) fn export(app: &mut SlideApp, ui: &mut Ui, _cx: &mut BodyCx<'_>, bs:
|
||||
.show(ui);
|
||||
}
|
||||
if Button::new("Save As")
|
||||
.icon(craft::behavior::IconId::new(Icon::SaveAs.name()))
|
||||
.icon(Icon::SaveAs.id())
|
||||
.arrangement(Arrangement::Stacked)
|
||||
.enabled(types.iter().any(|entry| entry.0 == bs.file_type))
|
||||
.show(ui)
|
||||
|
||||
@@ -139,12 +139,13 @@ fn open_lists_recent_files_and_opens_one() {
|
||||
h.state_mut().ui.recent = vec![path.clone(), dir.join("Other.pptx").to_string_lossy().to_string()];
|
||||
h.state_mut().run("app.backstage", json!({"page": "open"})).unwrap();
|
||||
h.run_steps(3);
|
||||
assert!(h.query_by_label_contains("Other.pptx").is_some());
|
||||
// The row and its remove button both name the file.
|
||||
assert!(h.query_all_by_label_contains("Other.pptx").next().is_some());
|
||||
h.get_by_role_and_label(Role::TextInput, "Search for a file").click();
|
||||
h.run_steps(2);
|
||||
h.get_by_role_and_label(Role::TextInput, "Search for a file").type_text("quarter");
|
||||
h.run_steps(2);
|
||||
assert!(h.query_by_label_contains("Other.pptx").is_none(), "the search filters by file name");
|
||||
assert!(h.query_all_by_label_contains("Other.pptx").next().is_none(), "the search filters by file name");
|
||||
page_choice(&h, "Quarterly review.pptx").click();
|
||||
wait_for_open(&mut h);
|
||||
assert_eq!(h.state().session.documents().len(), 2);
|
||||
@@ -154,6 +155,24 @@ fn open_lists_recent_files_and_opens_one() {
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
/// A recent row's remove button and the automation command drop only that file, and the command refuses a path that
|
||||
/// is not in the list instead of reporting success.
|
||||
#[test]
|
||||
fn a_recent_row_removes_its_file_through_the_command() {
|
||||
let mut h = new_app();
|
||||
let (kept, removed) = ("/decks/kept.pptx".to_string(), "/decks/removed.pptx".to_string());
|
||||
h.state_mut().ui.recent = vec![kept.clone(), removed.clone()];
|
||||
h.state_mut().run("app.backstage", json!({"page": "open"})).unwrap();
|
||||
h.run_steps(3);
|
||||
h.get_by_role_and_label(Role::Button, "Remove removed.pptx from Recent").click();
|
||||
h.run_steps(3);
|
||||
assert_eq!(h.state().ui.recent, vec![kept.clone()], "the clicked row's file left the list");
|
||||
assert!(h.query_all_by_label_contains("removed.pptx").next().is_none(), "its row is gone");
|
||||
assert!(h.state_mut().run("app.forgetRecent", json!({"path": removed})).is_err(), "a path not in the list is an error");
|
||||
let reply = h.state_mut().run("app.forgetRecent", json!({"path": kept})).unwrap();
|
||||
assert_eq!(reply["recent"], json!([]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn save_as_and_export_run_the_file_commands() {
|
||||
let files = Arc::new(ScriptedFiles::new().saving_suggested());
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
{
|
||||
"all": {
|
||||
"radius.surface": 8,
|
||||
"size.page.column": 1180,
|
||||
"typography.body.size": 13,
|
||||
"typography.body_strong.size": 13,
|
||||
"typography.caption.size": 11,
|
||||
"typography.heading.line_height": 24,
|
||||
"typography.heading.size": 18,
|
||||
"typography.label.size": 13
|
||||
"typography.label.size": 13,
|
||||
"typography.title.line_height": 24,
|
||||
"typography.title.size": 18
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ pub fn to_color32(c: deckcraft_color::Rgba) -> Color32 {
|
||||
Color32::from_rgba_unmultiplied(c.r, c.g, c.b, c.a)
|
||||
}
|
||||
|
||||
/// DeckCraft's overrides of the suite's size sets (`sizes.json`): its interface type scale and surface rounding. One
|
||||
/// DeckCraft's overrides of the suite's size sets (`sizes.json`): its interface type scale, surface rounding and File page column. One
|
||||
/// shared value, so every root that carries it keeps one identity for the token cache.
|
||||
pub fn app_sizes() -> std::sync::Arc<craft::theme::AppSizes> {
|
||||
static SIZES: std::sync::LazyLock<std::sync::Arc<craft::theme::AppSizes>> =
|
||||
|
||||
Reference in New Issue
Block a user