Contract stubs: craft-ui-canvas, craft-ui-shell

This commit is contained in:
Dylan M. Taylor committed 2026-11-17 22:51:25 -05:00
1 parent 2d343ecbdf
commit ecb210cc2f
14 files changed
+289 -31

No files matched your search

+29 -1
View File
@@ -171,9 +171,33 @@ pub struct CropOverlay<'a> {
/// Nothing is painted and a press anywhere on the canvas draws a new frame.
#[prop(flag)]
hidden: bool,
/// What a press outside the frame does: turns it, applies the crop, or draws a new frame.
#[prop]
#[allow(dead_code)] // P3(pdf-edit-w4): ED-F8
outside: CropOutside,
/// The quad the frame is bounded to, drawn as an outline in the guide colour.
#[prop]
#[allow(dead_code)] // P3(pdf-edit-w4): ED-F8
area: Option<[Point; 4]>,
/// The smallest side a drawn frame keeps.
#[prop(quantity = "document units")]
min_side: f64,
report: Report,
}
/// What a press outside a crop frame does.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
#[non_exhaustive]
pub enum CropOutside {
/// The press turns the frame.
#[default]
Turn,
/// The press applies the crop.
Apply,
/// The press draws a new frame.
NewFrame,
}
impl<'a> CropOverlay<'a> {
/// An overlay named `label` over `crop`. A mixed value shows the whole document.
pub fn new(label: impl Into<Label>, crop: Bind<'a, CropBox>) -> Self {
@@ -192,6 +216,9 @@ impl<'a> CropOverlay<'a> {
auto_center: false,
fills_uncovered: false,
hidden: false,
outside: CropOutside::default(),
area: None,
min_side: 0.0,
report: Report::default(),
}
.label(label)
@@ -360,7 +387,8 @@ impl CropOverlay<'_> {
}
return;
}
if drag.last.is_finite() && drag.last.size_ok() {
if drag.last.is_finite() && drag.last.size_ok(self.min_side) {
// P3(pdf-edit-w4): ED-F9
if let Some(view) = gesture::centred(&drag, self.auto_center, &space.view, &drag.last) {
self.report.view = Some(view);
}
+1 -1
View File
@@ -278,7 +278,7 @@ impl Container for FullWindowDialog<'_> {
if self.props.outer_edit {
outer::keep(ui.ctx(), cx);
}
frame::header(ui, cx, frame::close_action(self.closable));
frame::header(ui, cx, frame::close_action(self.closable), None); // P3(pdf-comments-w6): CM-C27
}
fn end(&mut self, ui: &mut Ui, cx: &mut BodyCx<'_>) {
+7 -4
View File
@@ -26,7 +26,7 @@ mod tool_groups;
mod tool_host;
pub use crate::canvas_data::{Guide, GuideColor, GuideDrag, GuideKey, GuideLine, NavigatorOptions, NavigatorSettings, ProxyColor};
pub use crop::{CropOverlay, CropOverlayOutput, CropShield, CropStyle, ShieldColor, paint_outside};
pub use crop::{CropOutside, CropOverlay, CropOverlayOutput, CropShield, CropStyle, ShieldColor, paint_outside};
pub use frame_step::{FRAME_STEP_MAX, frame_step};
pub(crate) use march::{MARCH_SECONDS, MARCH_TICK, march_shift};
pub use readout::{ShowReadouts, hud, readout};
@@ -45,7 +45,7 @@ pub use raster_source::{PixelRect, RasterSource};
mod pasteboard;
mod split;
pub use pasteboard::{PageBorder, PageFrame, Pasteboard, PasteboardColor, PasteboardOutput, PasteboardStyle};
pub use split::{SplitAt, SplitLayout, SplitPane, SplitStyle, SplitViews, SplitViewsOutput};
pub use split::{SplitAt, SplitLayout, SplitPane, SplitStyle, SplitViews, SplitViewsOutput, TabDrop, TabDropTarget};
pub use words::SplitWords;
mod app_paint;
@@ -72,7 +72,8 @@ mod zoom_motion;
pub use momentary::{Momentary, MomentaryCommands, MomentaryTool};
pub use navigate::{
Autoscroll, FlickPan, NavigateBar, NavigateBarOutput, NavigationOptions, PageKey, TouchpadGlide, WheelAction, WheelInput, WheelNavigation, pan,
Autoscroll, FlickPan, NavigateBar, NavigateBarOutput, NavigationOptions, PageKey, TouchpadGlide, WheelAction, WheelInput, WheelNavigation,
WheelScheme, pan,
};
pub use rotate::{RotateView, RotateViewOutput, RotateViewStyle, ViewTurn};
pub use tools::{HandTool, LayerBounds, RotateViewTool, ViewCommands, ViewRequest, ViewTarget, ZoomTool};
@@ -583,6 +584,8 @@ pub struct CanvasOutput {
/// target; the canvas shows the way there itself. [`ToolHost::run`] carries it in [`ToolHostResponse::view`]
/// when no tool set a view, so an app with a tool host copies that one view.
pub view: Option<CanvasView>,
/// True while a latched or held middle scroll runs this pass.
pub auto_scrolling: bool,
}
impl CanvasOutput {
@@ -723,7 +726,7 @@ impl Component for Canvas<'_> {
fn finish(self, cx: Cx<'_, Self>) -> CanvasOutput {
let pass = self.tool_pass(&cx);
CanvasOutput { response: cx.response.clone(), press: pass.press, space: pass.space, view: pass.view }
CanvasOutput { response: cx.response.clone(), press: pass.press, space: pass.space, view: pass.view, auto_scrolling: false } // P3(pdf-canvas-w1): CV-C6
}
}
+1 -1
View File
@@ -15,7 +15,7 @@ mod wheel;
pub use bar::{NavigateBar, NavigateBarOutput};
pub use keys::PageKey;
pub use options::NavigationOptions;
pub use options::{NavigationOptions, WheelScheme};
pub use wheel::{WheelAction, WheelInput, WheelNavigation};
use super::frame_step;
@@ -1,8 +1,10 @@
//! `NavigationOptions`: the user's navigation choices (Photoshop's Preferences, General, Tools and Enhanced Controls
//! rows), which the app owns and hands to the navigation pieces and the view tools.
use super::PageKey;
/// The navigation choices, with Photoshop's defaults.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[derive(Clone, Copy, Debug, PartialEq)]
#[non_exhaustive]
pub struct NavigationOptions {
/// General, Zoom with Scroll Wheel: the wheel zooms and Alt + wheel scrolls. Off.
@@ -28,6 +30,38 @@ pub struct NavigationOptions {
pub trackpad_rotate: bool,
/// Enhanced Controls, Enable Gestures: a touch screen's two-finger pinch and twist. On.
pub touch_gestures: bool,
/// What a plain and a modified wheel do. `Scroll`.
pub wheel: WheelScheme,
/// How many points a wheel line moves the view. 16.
pub wheel_line: f32,
/// How many points a key move of the view steps. [`PageKey::SMALL_STEP`].
pub key_line: f32,
/// A wheel pan eases to its target through the wheel service instead of jumping. Off.
pub eased_wheel: bool,
/// A touchpad's scroll glides on after the fingers lift. Off.
pub touchpad_glide: bool,
/// What the middle button does over the canvas background. `Pan`.
pub middle_button: craft_behavior::MiddleButton,
/// The middle-button scroll runs the other way. Off.
pub invert_middle: bool,
}
/// What a plain and a modified wheel do over a canvas.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
#[non_exhaustive]
pub enum WheelScheme {
/// The wheel scrolls; Alt and the zoom modifiers zoom.
#[default]
Scroll,
/// The wheel zooms; Alt scrolls.
Zoom,
/// Cmd or Ctrl zooms about the pointer by [`ACROBAT_NOTCH`](Self::ACROBAT_NOTCH) per line; Shift scrolls sideways.
Acrobat,
}
impl WheelScheme {
/// The zoom factor of one wheel line under [`Acrobat`](Self::Acrobat).
pub const ACROBAT_NOTCH: f64 = 1.221_402_758;
}
impl Default for NavigationOptions {
@@ -44,6 +78,13 @@ impl Default for NavigationOptions {
pinch_zooms: true,
trackpad_rotate: false,
touch_gestures: true,
wheel: WheelScheme::default(),
wheel_line: 16.0,
key_line: PageKey::SMALL_STEP,
eased_wheel: false,
touchpad_glide: false,
middle_button: craft_behavior::MiddleButton::default(),
invert_middle: false,
}
}
}
+15
View File
@@ -40,6 +40,8 @@ pub struct CanvasSpace {
/// The canvas's picture slot for this pass, which [`paint_picture`](Self::paint_picture) appends to; `None` in a
/// measuring pass.
picture: Option<PaintSlot>,
#[allow(dead_code)] // P3(pdf-canvas-w1): CV-C5
wheel: Option<craft_behavior::Wheel>,
}
impl CanvasSpace {
@@ -60,9 +62,22 @@ impl CanvasSpace {
pasteboard: PasteboardColor::Default,
precise: false,
picture: None,
wheel: None,
}
}
/// The wheel share the canvas read this pass, for a body that pages by wheel to read once.
pub fn wheel(&self) -> Option<craft_behavior::Wheel> {
todo!("CV-C5")
}
/// This space with the wheel share the canvas read this pass.
#[must_use]
pub fn with_wheel(self, wheel: Option<craft_behavior::Wheel>) -> Self {
let _ = wheel;
todo!("CV-C5")
}
/// This space for a pass in which the app's tool moves the view with the pointer
/// ([`Canvas::view_follows_pointer`](super::Canvas::view_follows_pointer)): [`set_view`](Self::set_view) then shows
/// a view as it is, not [`pixel_aligned`].
+46 -12
View File
@@ -243,15 +243,37 @@ pub struct SplitStyle {
/// What split views report: the dividers' edits and the pane the user chose.
#[derive(Debug)]
#[non_exhaustive]
pub struct SplitViewsOutput {
pub struct SplitViewsOutput<D = ()> {
/// The divider edits and the area's response.
pub edit: EditResponse<SplitAt>,
/// The pane pressed, or activated by key or assistive technology, this pass that was not the active one: the app
/// makes it active.
pub activated: Option<usize>,
/// The documents dropped on the views this pass, and where.
pub tab_drop: Option<TabDrop<D>>,
}
impl Outcome for SplitViewsOutput {
/// Where a dragged document strip tab lands on split views.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum TabDropTarget {
/// A whole pane of a split body.
Pane(usize),
/// The reading-end half of an unsplit body.
SplitEnd,
}
/// The documents of a dragged tab group and the target they were dropped on.
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub struct TabDrop<D> {
/// The dragged documents.
pub documents: Vec<D>,
/// Where they were dropped.
pub target: TabDropTarget,
}
impl<D> Outcome for SplitViewsOutput<D> {
type Value = SplitAt;
fn response(&self) -> &Response {
@@ -269,8 +291,8 @@ impl Outcome for SplitViewsOutput {
/// Tab stop over its view: a press, Enter or Space on it reports it in [`SplitViewsOutput::activated`] and its view
/// gets no press.
#[derive(crate::contract::Component, crate::contract::Props)]
#[component(container)]
pub struct SplitViews<'a> {
#[component(container, probe(SplitViews<'static, ()>))]
pub struct SplitViews<'a, D: Clone + Send + Sync + 'static = ()> {
#[common]
common: Common,
#[container]
@@ -285,6 +307,8 @@ pub struct SplitViews<'a> {
#[prop]
count: usize,
activated: Option<usize>,
#[allow(dead_code)] // P3(pdf-chrome-w7): CH-C21
accepts: Option<Box<dyn Fn(&[D], TabDropTarget) -> bool + 'a>>,
}
impl<'a> SplitViews<'a> {
@@ -292,7 +316,15 @@ impl<'a> SplitViews<'a> {
/// active until [`active`](Self::active) says otherwise.
pub fn new(label: impl Into<Label>, layout: SplitLayout, at: Bind<'a, SplitAt>) -> Self {
let props = ContainerProps::new().arena(true).sizing(Sizing::Fill).pad(Pad::None);
SplitViews { common: Common::new(), props, layout, at, active: 0, count: 0, activated: None }.label(label)
SplitViews { common: Common::new(), props, layout, at, active: 0, count: 0, activated: None, accepts: None }.label(label)
}
/// Takes a dragged document strip tab over the views: an unsplit body offers its reading-end half, a split body
/// each whole pane, each only when `accepts` returns true.
#[must_use]
pub fn takes_tabs<D: Clone + Send + Sync + 'static>(self, accepts: impl Fn(&[D], TabDropTarget) -> bool + 'a) -> SplitViews<'a, D> {
let _ = accepts;
todo!("CH-C21")
}
/// Copies the main view's centre and zoom into the linked panes, each keeping its own rect and rotation.
@@ -302,7 +334,9 @@ impl<'a> SplitViews<'a> {
pane.view.zoom = main.zoom;
}
}
}
impl<D: Clone + Send + Sync + 'static> SplitViews<'_, D> {
fn active_pane(&self) -> usize {
self.active.min(pane_count(self.layout, self.count).saturating_sub(1))
}
@@ -315,7 +349,7 @@ impl<'a> SplitViews<'a> {
/// Dragging a divider moves its boundary (one gesture from the drag's start to its release), the arrow keys move the
/// focused divider by a step, Shift or Page by a jump, and assistive technology sets it to a value.
fn resize(cx: &mut Cx<'_, SplitViews<'_>>, at: &SplitAt, laid: &Laid, dividers: &[Divider]) {
fn resize<D: Clone + Send + Sync + 'static>(cx: &mut Cx<'_, SplitViews<'_, D>>, at: &SplitAt, laid: &Laid, dividers: &[Divider]) {
let rect = cx.rect;
for (index, divider) in dividers.iter().enumerate() {
match divider::pointer(cx, DIVIDER, index as u64, divider) {
@@ -337,13 +371,13 @@ fn resize(cx: &mut Cx<'_, SplitViews<'_>>, at: &SplitAt, laid: &Laid, dividers:
}
}
impl Component for SplitViews<'_> {
impl<D: Clone + Send + Sync + 'static> Component for SplitViews<'_, D> {
const ROLE: Role = Role::GROUP;
const KEYS: KeyUse = KeyUse::SPLITTER;
type Style = SplitStyle;
type Output = SplitViewsOutput;
type Output = SplitViewsOutput<D>;
fn style(cx: &StyleCx<'_>, _: SplitViewsStyleKey) -> SplitStyle {
fn style(cx: &StyleCx<'_>, _: SplitViewsStyleKey<D>) -> SplitStyle {
SplitStyle {
metrics: Metrics::new(),
sizes: DockSizes::style(cx),
@@ -436,9 +470,9 @@ impl Component for SplitViews<'_> {
}
}
fn finish(self, cx: Cx<'_, Self>) -> SplitViewsOutput {
SplitViewsOutput { edit: cx.edit_response(), activated: self.activated }
fn finish(self, cx: Cx<'_, Self>) -> SplitViewsOutput<D> {
SplitViewsOutput { edit: cx.edit_response(), activated: self.activated, tab_drop: None } // P3(pdf-chrome-w7): CH-C21
}
}
impl Container for SplitViews<'_> {}
impl<D: Clone + Send + Sync + 'static> Container for SplitViews<'_, D> {}
+1 -1
View File
@@ -27,7 +27,7 @@ pub use line_preview::{LineGuideStyle, StraightLinePreview};
pub use marquee::{Marquee, MarqueeLook, MarqueeShape, MarqueeStyle, Run};
pub use outline::{HoverMask, HoverOutline, HoverShape, OutlineStyle, SelectionOutline, SelectionOutlineLook, path_runs};
pub use pixel_grid::{GridSegment, PixelGrid, PixelGridStyle};
pub use task_bar::{TaskBar, TaskBarCx, TaskBarOutput, TaskBarPlace};
pub use task_bar::{TaskBar, TaskBarCx, TaskBarKind, TaskBarOutput, TaskBarPlace};
// End of canvas-controls-b.
// Brush overlays.
@@ -55,6 +55,8 @@ pub enum SelectionOutlineLook {
Solid,
/// A medium line in dashes: a CAD app's selection effect.
Dashed,
/// A thin line with no halo, in the overlay grid colour: every editable object in an edit mode.
Faint,
}
/// The style of the hover and selection outlines.
@@ -72,6 +74,9 @@ pub struct OutlineStyle {
/// The length of a dash and of the gap after it.
dash: f32,
gap: f32,
/// The line colour of a faint outline.
#[allow(dead_code)] // P3(pdf-edit-w5): ED-F10
faint: StyleColor,
}
fn outline_style(cx: &StyleCx<'_>) -> OutlineStyle {
@@ -83,6 +88,7 @@ fn outline_style(cx: &StyleCx<'_>) -> OutlineStyle {
thin: stroke.thin,
dash: stroke.dash,
gap: stroke.dash_gap,
faint: cx.color(cx.tokens.color.overlay.grid),
}
}
@@ -284,6 +290,13 @@ impl<'a> SelectionOutline<'a> {
SelectionOutline { common: Common::new(), paths, look: SelectionOutlineLook::Solid, color: None }.label(label)
}
/// A thin outline of `paths` (document units) with no halo, for every editable object in an edit mode, named
/// `label`.
pub fn faint(label: impl Into<Label>, paths: &'a [BezPath]) -> Self {
let _ = (label, paths);
todo!("ED-F10")
}
/// A dashed outline of `paths` (document units), named `label`.
pub fn dashed(label: impl Into<Label>, paths: &'a [BezPath]) -> Self {
SelectionOutline { common: Common::new(), paths, look: SelectionOutlineLook::Dashed, color: None }.label(label)
@@ -316,6 +329,7 @@ impl Component for SelectionOutline<'_> {
for (mut points, closed) in path_runs(&space.view, path) {
match self.look {
SelectionOutlineLook::Solid => stroke_run(&painter, points, closed, self.color, style.thin),
SelectionOutlineLook::Faint => todo!("ED-F10"),
SelectionOutlineLook::Dashed => {
if closed {
points.extend(points.first().copied());
@@ -70,6 +70,19 @@ pub struct TaskBar<'a> {
label: Label,
anchor: &'a [Point],
place: Bind<'a, TaskBarPlace>,
#[allow(dead_code)] // P3(pdf-canvas-w3): CV-C15
kind: TaskBarKind,
}
/// Whether a task bar follows its anchor and moves, or stays where it hangs.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
#[non_exhaustive]
pub enum TaskBarKind {
/// The bar follows its anchor and the user moves it.
#[default]
Movable,
/// The bar hangs where it is placed: no grip, no move band and no More menu.
Fixed,
}
/// What the task bar reports.
@@ -148,12 +161,29 @@ impl MoreMenu {
impl<'a> TaskBar<'a> {
/// A bar named `label` hung below the screen bounds of `anchor` (document points) until `place` moves it.
pub fn new(label: impl Into<Label>, anchor: &'a [Point], place: Bind<'a, TaskBarPlace>) -> Self {
TaskBar { label: label.into(), anchor, place }
TaskBar { label: label.into(), anchor, place, kind: TaskBarKind::Movable }
}
/// A fixed bar named `label` hung below the screen bounds of `anchor`, above them when there is no room below.
pub fn fixed(label: impl Into<Label>, anchor: &'a [Point]) -> Self {
let _ = (label, anchor);
todo!("CV-C15")
}
/// A fixed bar at the canvas view's top edge, aligned `edge` in reading direction and inset by the regular pad.
pub fn at_edge(label: impl Into<Label>, edge: Align) -> Self {
let _ = (label, edge);
todo!("CV-C15")
}
/// Whether the bar is movable or fixed.
pub fn kind(&self) -> TaskBarKind {
todo!("CV-C15")
}
/// Shows the bar inside `area`; `body` fills its members.
pub fn show<R>(self, ui: &mut Ui, area: Rect, mut body: impl FnMut(&mut Ui, &mut TaskBarCx<'_>) -> R) -> Inner<TaskBarOutput, R> {
let TaskBar { label, anchor, mut place } = self;
let TaskBar { label, anchor, mut place, .. } = self; // P3(pdf-canvas-w3): CV-C15
let env = Env::of(ui);
let words = env.words::<CanvasControlWords>();
// The anchor maps through this pass's view, so the bar follows a scroll or zoom in the same pass.
+4 -1
View File
@@ -37,7 +37,10 @@ mod start;
mod viewport_window;
pub use recent::{RecentFile, RecentSort, RecentView, Template, ThumbKey, sort_recent};
pub use start::{StartAction, StartLink, StartLinkTarget, StartOutput, StartPinnedCommands, StartRecentCommands, StartScreen};
pub use start::{
FolderListing, PINNED_FILES_SHOWN, PinnedFile, PinnedFolder, StartAction, StartLink, StartLinkTarget, StartOutput, StartPinnedCommands,
StartPlace, StartRecentCommands, StartScreen,
};
pub use viewport_window::{ViewportWindow, ViewportWindowOutput};
// Caption buttons: the four families' button, its slot layout and the icon-theme glyphs.
+10 -1
View File
@@ -27,12 +27,21 @@ pub struct RecentFile {
pub opened: Option<i64>,
/// Created, in seconds since the Unix epoch, for sorting by Created.
pub created: Option<i64>,
/// A second line under the name.
pub note: Option<String>,
}
impl RecentFile {
/// A recent file at `path` shown as `name`, with no dates.
pub fn new(path: impl Into<PathBuf>, name: impl Into<String>) -> Self {
RecentFile { path: path.into(), name: name.into(), opened: None, created: None }
RecentFile { path: path.into(), name: name.into(), opened: None, created: None, note: None }
}
/// This file with a second line, `note`, under its name.
#[must_use]
pub fn note(self, note: impl Into<String>) -> Self {
let _ = note;
todo!("CH-C17")
}
}
+81 -5
View File
@@ -24,7 +24,7 @@ use crate::runtime::commands::{CommandSet as _, Commands as _};
use crate::runtime::env::{AgeStyle, Env, Label};
use crate::sections::Section;
use crate::style::{Corners, SurfaceKind, SurroundLook};
use crate::tile_grid::{CaptionPlace, Tile, TileGrid, TilePartEvent};
use crate::tile_grid::{CaptionPlace, GridZoom, Tile, TileGrid, TilePartEvent};
use craft_behavior::{IconId, Proposal, SelectionChange, keyed};
use craft_theme::Variant;
use craft_theme::variant::Tone;
@@ -104,6 +104,70 @@ pub enum StartAction {
UnpinFolder(PathBuf),
/// A template card was chosen; the string is [`Template::id`].
UseTemplate(String),
/// A file listed under a pinned folder was opened: the app opens that path.
OpenPinnedFile(PathBuf),
/// A pinned folder was folded: the app keeps it folded.
FoldPinned(PathBuf),
/// A pinned folder's More row was chosen: the app lists all of its files.
ExpandPinned(PathBuf),
}
/// Where a host section sits on the start screen.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum StartPlace {
/// Before the Recent section.
BeforeRecent,
/// After the last built-in section.
AfterSections,
}
/// The most files a pinned folder lists before its More row.
pub const PINNED_FILES_SHOWN: usize = 8;
/// A pinned folder as the start screen lists it, with the files the app found in it.
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub struct PinnedFolder {
/// The folder's path; also the identity of the entry.
pub path: PathBuf,
/// The name shown.
pub name: String,
/// The folder's files, once the app has listed them.
pub listing: Option<FolderListing>,
/// The folder shows no files.
pub folded: bool,
/// The folder lists all of its files, not the first [`PINNED_FILES_SHOWN`].
pub expanded: bool,
}
/// What the app knows of a pinned folder's files.
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum FolderListing {
/// The app is still listing the folder.
Pending,
/// The folder cannot be listed.
Unavailable,
/// The folder's files, and how many it holds in all.
Listed {
/// The files to show.
files: Vec<PinnedFile>,
/// The number of files in the folder.
total: usize,
},
}
/// A file listed under a pinned folder.
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub struct PinnedFile {
/// The file's full path.
pub path: PathBuf,
/// The name shown.
pub name: String,
/// A second line under the name.
pub note: Option<String>,
}
/// What a start screen pass reports.
@@ -154,7 +218,7 @@ pub struct StartScreen<'a> {
/// The pinned folders in the app's order. The section shows once this is given; an app that cannot pin leaves it
/// out.
#[prop]
pinned: Option<&'a [PathBuf]>,
pinned: Option<&'a [PinnedFolder]>,
/// The template cards; the section is left out when there are none.
#[prop]
templates: &'a [Template],
@@ -172,6 +236,9 @@ pub struct StartScreen<'a> {
/// With no recent files, the Recent body is a drop card with this hint that opens a file on a click.
#[prop(into)]
drop_hint: Option<Label>,
/// The New… button shows (true by default).
#[prop]
offers_new: bool,
}
/// A link on the start screen's rail.
@@ -222,9 +289,17 @@ impl<'a> StartScreen<'a> {
thumbnails: None,
links: &[],
drop_hint: None,
offers_new: true,
}
}
/// Shows `body` as a host section at `place` on the start screen.
#[must_use]
pub fn section(self, place: StartPlace, body: impl FnMut(&mut Ui, &mut BodyCx<'_>) + 'a) -> Self {
let _ = (place, body);
todo!("CH-C17")
}
/// Cards, rows and templates ask `thumbnails.state(..)` for what they show; `source` gives each key's revision.
pub fn thumbnails(mut self, thumbnails: &'a Thumbnails<ThumbKey>, source: &'a dyn ThumbSource<ThumbKey>) -> Self {
self.thumbnails = Some((thumbnails, source));
@@ -290,7 +365,7 @@ impl<'p> Page<'p> {
.detail_line()
.card()
.aspect(f32::from(PICTURE_WIDE) / f32::from(PICTURE_HIGH))
.zoom(CARD_ZOOM)
.zoom(GridZoom::Fixed(f64::from(CARD_ZOOM))) // P3(pdf-chrome-w5): WF-W12
.fill_row()
.sizing(Sizing::FillWidth)
.natural_height(true)
@@ -341,7 +416,7 @@ fn read_events<K: Clone, E>(events: Vec<CollectionEvent<K, E>>, lead: &mut Optio
impl StartScreen<'_> {
/// Shows the page across the available room and reports what the user did.
pub fn show(self, ui: &mut Ui) -> StartOutput {
let StartScreen { view, sort, recent, pinned, templates, max_recent, now, thumbnails, links, drop_hint } = self;
let StartScreen { view, sort, recent, pinned, templates, max_recent, now, thumbnails, links, drop_hint, offers_new: _ } = self; // P3(pdf-chrome-w5): CH-C17
let env = Env::of(ui);
let collator = env.collator();
let words = env.words::<ShellWords>();
@@ -374,7 +449,8 @@ impl StartScreen<'_> {
}
recent_section(&page, ui, &view, &sort, current_view, &files);
if let Some(pinned) = pinned {
pinned_section(&page, ui, pinned);
let paths: Vec<PathBuf> = pinned.iter().map(|folder| folder.path.clone()).collect(); // P3(pdf-chrome-w5): CH-C18
pinned_section(&page, ui, &paths);
}
if !templates.is_empty() {
templates_section(&page, ui, templates);
+6 -1
View File
@@ -97,8 +97,13 @@ fn screen(
) -> StoryOutput {
let mut choice = data.value("choice", choice).clone();
let thumbnails = Thumbnails::<ThumbKey>::in_context(ui.ctx(), "start-stories", ThumbnailOptions::new());
// P3(pdf-chrome-w5): CH-C18
let folders: Vec<super::PinnedFolder> = pinned
.iter()
.map(|path| super::PinnedFolder { path: path.clone(), name: String::new(), listing: None, folded: false, expanded: false })
.collect();
let mut start = StartScreen::new(Bind::bound(&mut choice.view), Bind::bound(&mut choice.sort), files)
.pinned(pinned)
.pinned(&folders)
.templates(templates)
.now(NOW)
.links(extras.links);