compile fix 1 (chrome): name resolution after the app-1 combine (swarm/cfix1, report in swarm/cfix1/run); committed by the lead

This commit is contained in:
Dylan M. Taylor
2026-11-18 16:29:01 -05:00
parent 8c2b2e07a5
commit adfa37fef0
21 changed files with 149 additions and 111 deletions
+10 -10
View File
@@ -1,18 +1,18 @@
//! The view rail: the end slot's column of view controls (dock side, page display, rotation, fit, zoom, page
//! stepping, history and the page box) for the active document.
use craft::behavior::TypeRole;
use craft::ui::buttons::IconButton;
use craft::ui::contract::Bind;
use craft::ui::display::Text;
use craft::behavior::kurbo::Size;
use craft::behavior::{DockSide, IconId};
use craft::pages::PageDisplay;
use craft::ui::menu::{Menu, MenuItem, Trigger};
use craft::ui::primitives::{IconId, PopupKind};
use craft::theme::TypeRole;
use craft::ui::buttons::IconButton;
use craft::ui::contract::{Bind, PopupKind, Trigger};
use craft::ui::display::Text;
use craft::ui::menu::{Menu, MenuItem};
use craft::ui::text::{TextField, ZoomField, ZoomScale};
use egui::{Size2, Ui};
use egui::Ui;
use crate::PdfCraftApp;
use crate::hotbar::RailSide;
/// Shows the rail's view cluster; nothing without an active document or a current page to view.
pub(crate) fn show(app: &mut PdfCraftApp, ui: &mut Ui) {
@@ -20,12 +20,12 @@ pub(crate) fn show(app: &mut PdfCraftApp, ui: &mut Ui) {
let Some(doc) = app.session.get(id) else { return };
let page_count = doc.info.pages.len();
let labels: Vec<String> = doc.info.pages.iter().map(|p| p.label.clone()).collect();
let rail_on_right = app.rail_side == RailSide::End;
let rail_on_right = app.rail_side == DockSide::End;
let Some(view) = app.views.get_mut(index) else { return };
let current = view.current();
// Without a current page there is nothing to view or zoom.
let Some(page) = doc.info.pages.get(current) else { return };
let page_size = Size2 { width: page.width.max(1.0), height: page.height.max(1.0) };
let page_size = Size::new(f64::from(page.width.max(1.0)), f64::from(page.height.max(1.0)));
IconButton::command(IconId::new(if rail_on_right { "panel_left" } else { "panel_right" }), "view.dock_side").show(ui);
+18 -15
View File
@@ -6,6 +6,7 @@
//! one a key fired while it is disabled to [`PdfCraftApp::run_declined`].
pub(crate) mod catalog;
use craft::pages::PageDisplay;
use craft::theme::ModeChoice;
use craft::ui::runtime::commands::Fired;
use pdfcraft_engine::Edit;
@@ -420,36 +421,39 @@ impl PdfCraftApp {
}
}
"view.palette" => self.palette_open = !self.palette_open,
layout if crate::canvas::PageLayout::from_command(layout).is_some() => {
if let (Some(i), Some(layout)) = (active, crate::canvas::PageLayout::from_command(layout)) {
self.views[i].set_layout(layout);
"view.layout.single" | "view.layout.two_up" => {
if let Some(v) = active.and_then(|i| self.views.get_mut(i)) {
v.view.display = if id == "view.layout.single" { PageDisplay::Single } else { PageDisplay::TwoUp };
v.view.go_to(v.current());
}
}
// The Continuous scrolling checkbox (an independent toggle over the base layout).
"view.continuous" => {
if let Some(i) = active {
let v = &mut self.views[i];
v.set_continuous(!v.continuous());
if let Some(v) = active.and_then(|i| self.views.get_mut(i)) {
v.view.continuous = !v.view.continuous;
v.view.go_to(v.current());
}
}
"view.page_gaps" => {
if let Some(view) = active.and_then(|i| self.views.get(i)) {
self.set_active_page_gaps(!view.show_page_gaps);
self.set_active_page_gaps(!view.view.page_gaps);
}
}
"view.layout.cover" => {
if let Some(i) = active {
let v = &mut self.views[i];
v.set_cover(!v.cover);
if let Some(v) = active.and_then(|i| self.views.get_mut(i)) {
v.view.cover = !v.view.cover;
v.view.go_to(v.current());
}
}
"view.fit_width_scrolling" | "view.fit_one_page" => {
use crate::canvas::{Fit, PageLayout};
use crate::canvas::Fit;
// Fit one full page shows a single page on its own; fit width scrolls it.
let (continuous, fit) = if id == "view.fit_one_page" { (false, Fit::Page) } else { (true, Fit::Width) };
if let Some(i) = active {
self.views[i].set_display(PageLayout::Single, continuous);
self.views[i].set_fit(fit);
if let Some(v) = active.and_then(|i| self.views.get_mut(i)) {
v.view.display = PageDisplay::Single;
v.view.continuous = continuous;
v.view.fit = fit;
v.view.go_to(v.current());
}
}
"view.full_screen" => {
@@ -923,7 +927,6 @@ impl PdfCraftApp {
None => self.open_combine_tab(),
}
}
}
/// The tab after `current` of `count` (before it when `forward` is false), wrapping around. From
+7 -5
View File
@@ -4,13 +4,15 @@
use std::sync::OnceLock;
use craft::ui::runtime::commands::{AppCatalog, Binding, CommandDef, CommandDefError, CommandGate, CommandInput, CommandKind, CommandRef, CommandState, Scope};
use craft::ui::runtime::commands::{
AppCatalog, Binding, CommandDef, CommandDefError, CommandGate, CommandInput, CommandKind, CommandRef, CommandState, Scope,
};
use pdfcraft_engine::commands::{self as engine, CommandSpec};
use crate::menus::{self, CUT, DELETE, DOCUMENT, EXTRA, NO_RECENT, PANEL, PANELS, PASTE, SELECT_ALL};
use craft::pages::PageDisplay;
use crate::theme::ModeChoice;
use crate::{Mode, PdfCraftApp, QuickTool};
use craft::pages::PageDisplay;
use craft::theme::ModeChoice;
/// Commands only the catalog knows: id, English label and icon. Their handlers are the board's.
const CATALOG_ONLY: &[(&str, &str, &str)] = &[
@@ -44,8 +46,8 @@ fn kind_of(id: &str) -> CommandKind {
"view.layout.single" | "view.layout.two_up" => CommandKind::Radio { group: Some("layout".into()) },
"view.theme.system" | "view.theme.light" | "view.theme.dark" => CommandKind::Radio { group: Some("theme".into()) },
PANEL => CommandKind::Radio { group: Some("panel".into()) },
"view.continuous" | "view.page_gaps" | "view.layout.cover" | "view.full_screen" | "view.read_mode" | "view.side_panel" | "view.tools_pane"
| "view.split" => CommandKind::Toggle,
"view.continuous" | "view.page_gaps" | "view.layout.cover" | "view.full_screen" | "view.read_mode" | "view.side_panel"
| "view.tools_pane" | "view.split" => CommandKind::Toggle,
_ => CommandKind::Command,
}
}
+8 -10
View File
@@ -6,12 +6,10 @@ use craft::ui::choice::Swatch;
use craft::ui::contract::{Bind, Entry, Show};
use craft::ui::docking::PanelSpec;
use craft::ui::pickers::Select;
use craft::ui::rails::{
DrawerGroup, DrawerKind, LastUsed, RailTool, SlotId, ToolRail, ToolSlot, ToolbarDrawer, apply_toolbar_edit,
};
use craft::ui::rails::{DrawerGroup, DrawerKind, LastUsed, RailTool, SlotId, ToolRail, ToolSlot, ToolbarDrawer, apply_toolbar_edit};
use craft::ui::text::NumberField;
use pdfcraft_engine::{Edit, Rgb};
use pdfcraft_engine::commands::{COMMANDS, command};
use pdfcraft_engine::{Edit, Rgb};
use serde::{Deserialize, Serialize};
use crate::fill_sign::{FILL_TOOLS, FillTool};
@@ -175,7 +173,7 @@ fn from_srgba(color: Srgba) -> Rgb {
}
/// Opens the colour picker in the main window, the window the rail's footer lives in, and runs `then` with the answer.
fn open_picker(app: &mut PdfCraftApp, request: craft::ui::contract::ColorRequest, then: impl FnOnce(&mut PdfCraftApp, Srgba) + 'static) {
fn open_picker(app: &mut PdfCraftApp, request: craft::ui::runtime::requests::ColorRequest, then: impl FnOnce(&mut PdfCraftApp, Srgba) + 'static) {
// PLAN: assumed `PdfCraftApp::main_dialog_host(&self) -> DialogHost` and
// `open_colour_picker(&mut self, DialogHost, ColorRequest, impl FnOnce(&mut PdfCraftApp, Srgba) + 'static)` (pdf-comments-w10, q180).
let host = app.main_dialog_host();
@@ -209,10 +207,7 @@ pub(crate) fn show_rail(app: &mut PdfCraftApp, ui: &mut egui::Ui) {
return;
};
let groups = drawer_groups();
let drawer = ToolbarDrawer::new(output.response.rect, &groups, &toolbar, output.dropped)
.kind(DrawerKind::Searchable)
.opened_by(opener)
.show(ui);
let drawer = ToolbarDrawer::new(output.response.rect, &groups, &toolbar, output.dropped).kind(DrawerKind::Searchable).opened_by(opener).show(ui);
let defaults = slots_with(app, &[]);
let mut edited: Option<Vec<ToolSlot<String>>> = None;
for edit in &drawer.edits {
@@ -315,7 +310,10 @@ fn fill_text_border_controls(ui: &mut egui::Ui, app: &mut PdfCraftApp, picked: O
}
// The border's own colour (the text's unless picked).
if was.width > 0.0 {
let well = Swatch::new(tl!("Border colour").to_string(), to_srgba(was.color.unwrap_or(app.fill_text_color))).picker("hotbar.fill-border-colour").well().show(ui);
let well = Swatch::new(tl!("Border colour").to_string(), to_srgba(was.color.unwrap_or(app.fill_text_color)))
.picker("hotbar.fill-border-colour")
.well()
.show(ui);
if let Some(request) = well.pick_color {
let target = selected.map(|(page, index, _)| (page, index));
open_picker(app, request, move |app: &mut PdfCraftApp, picked_colour: Srgba| {
+1 -1
View File
@@ -240,7 +240,7 @@ pub struct PdfCraftApp {
/// Where the side panels are docked, their sizes and which are open.
pub dock: craft::behavior::dock::Workspace<side_panels::PanelId>,
/// The side the rail of panel buttons sits on.
pub rail_side: side_panels::RailSide,
pub rail_side: craft::behavior::DockSide,
pub session: Session,
/// The interface language signature status captions were last drawn in.
pub(crate) status_captions_lang: Option<i18n::Lang>,
+1 -2
View File
@@ -208,8 +208,7 @@ mod tests {
reveal_on_jobs(h.state_mut(), PathBuf::from("/pdfcraft-no-such-dir/missing.pdf"));
assert_eq!(jobs.waiting(), 1, "the reveal is a job on the host");
h.run_steps(2);
// PLAN: assumed `craft::ui::notices::Notices::posted(&Context) -> usize` (L-206).
let posted = |h: &Harness<'_, PdfCraftApp>| craft::ui::notices::Notices::posted(&h.ctx);
let posted = |h: &Harness<'_, PdfCraftApp>| crate::notices::posted(&h.ctx).len();
assert_eq!(posted(&h), 0, "nothing is shown until the job ends");
jobs.run_all();
h.run_steps(2);
+25 -10
View File
@@ -167,11 +167,13 @@ fn route(app: &mut PdfCraftApp, end: &NoticeEnd) {
#[cfg(test)]
mod tests {
use super::*;
use crate::workflows::optimize_ui::{OptimizeKind, OptimizeProgress, OptimizeRun};
use crate::workflows::scan_clean_ui::{ScanCleanProgress, ScanCleanRun};
use crate::JobCount;
use crate::workflows::optimize_ui::{OptimizeKind, OptimizeRun};
use crate::workflows::scan_clean_ui::ScanCleanRun;
use egui_kittest::Harness;
use egui_kittest::kittest::Queryable;
use pdfcraft_engine::DocId;
use pdfcraft_engine::optimizer::OptimizeStage;
use std::sync::{Arc, Mutex};
fn card_of(h: &Harness<'static, PdfCraftApp>, key: ProgressKey) -> toast::Card {
@@ -192,12 +194,20 @@ mod tests {
let optimize = ProgressNotice { label: "Optimizing… reading the pages".into(), fraction: 0.25, cancellable: true };
set_progress(h.state_mut(), ProgressKey::Optimize, optimize.clone());
set_progress(h.state_mut(), ProgressKey::ScanClean, ProgressNotice { label: "Cleaning image 1 of 4".into(), fraction: 0.1, cancellable: false });
set_progress(
h.state_mut(),
ProgressKey::ScanClean,
ProgressNotice { label: "Cleaning image 1 of 4".into(), fraction: 0.1, cancellable: false },
);
h.run_steps(2);
let first = card_of(&h, ProgressKey::Optimize).id;
// Repeated calls move the one card.
set_progress(h.state_mut(), ProgressKey::Optimize, ProgressNotice { label: "Optimizing… image 3 of 40".into(), fraction: 0.75, cancellable: true });
set_progress(
h.state_mut(),
ProgressKey::Optimize,
ProgressNotice { label: "Optimizing… image 3 of 40".into(), fraction: 0.75, cancellable: true },
);
h.run_steps(2);
let cards = posted(&h.ctx);
assert_eq!(cards.len(), 2, "one card per key: {cards:?}");
@@ -210,15 +220,20 @@ mod tests {
assert!(progress(h.state(), &h.ctx, ProgressKey::ScanClean).is_some());
// Both jobs are in flight; Cancel is on the Optimize card only.
let optimize_progress = Arc::new(Mutex::new(OptimizeProgress::default()));
let scan_progress = Arc::new(Mutex::new(ScanCleanProgress::default()));
h.state_mut().optimize_run =
Some(OptimizeRun { doc: DocId(1), kind: OptimizeKind::Reduce, destination: None, progress: optimize_progress.clone() });
let optimize_progress = Arc::new(JobCount::default());
let scan_progress = Arc::new(JobCount::default());
h.state_mut().optimize_run = Some(OptimizeRun {
doc: DocId(1),
kind: OptimizeKind::Reduce,
destination: None,
progress: optimize_progress.clone(),
stage: Arc::new(Mutex::new(OptimizeStage::Discarding)),
});
h.state_mut().scan_clean_run = Some(ScanCleanRun { doc: DocId(1), progress: scan_progress.clone() });
h.get_by_label("Cancel").click();
h.run_steps(3);
assert!(optimize_progress.lock().unwrap().cancel, "Cancel reaches the Optimize job");
assert!(!scan_progress.lock().unwrap().cancel, "the ScanClean job is left running");
assert!(optimize_progress.cancelled(), "Cancel reaches the Optimize job");
assert!(!scan_progress.cancelled(), "the ScanClean job is left running");
assert!(h.state().progress_cards.contains_key(&ProgressKey::ScanClean));
assert!(posted(&h.ctx).iter().any(|card| card.id == card_of(&h, ProgressKey::ScanClean).id));
+1 -2
View File
@@ -5,12 +5,11 @@ use egui::{Align, Align2, Color32, CornerRadius, Layout, Rect, Sense, Stroke, po
use pdfcraft_engine::catalog::{self, Availability, TOOL_GROUPS, ToolGroup, ToolItem};
use pdfcraft_render::{DocInfo, FieldKind, OutlineItem};
use crate::theme::{self, Tokens};
use crate::{LeftPanel, PdfCraftApp, RightPanel, icons};
pub(super) mod all_tools_ui;
mod attachments;
mod bookmarks;
pub(crate) mod bookmarks;
pub(super) mod comments_panel;
mod edit;
mod fields;
+3 -1
View File
@@ -70,7 +70,9 @@ fn tile(g: &'static ToolGroup, items: &[&'static str]) -> Tile<'static> {
return tile.dimmed();
}
match g.badge {
Some(b) => tile.badge(TileBadge::new(BadgeSlot::EndTop, BadgeKind::Text(tl!(b).to_owned().into()), craft::theme::variant::Tone::Accent, None)),
Some(b) => {
tile.badge(TileBadge::new(BadgeSlot::EndTop, BadgeKind::Text(tl!(b).to_owned().into()), craft::theme::variant::Tone::Accent, None))
}
None => tile,
}
}
+7 -6
View File
@@ -1,14 +1,15 @@
use super::{Nav, PanelResult, PanelRow, PdfCraftApp};
use super::right::PanelResult;
use super::{Nav, PdfCraftApp};
use craft::behavior::IconId;
use craft::behavior::{DisplayOrder, GesturePhase, ItemSource, Mixed, Selection};
use craft::keymap::CommandRef;
use craft::ui::buttons::IconButton;
use craft::ui::choice::Checkbox;
use craft::behavior::IconId;
use craft::ui::contract::{ActivateOn, Bind, CollectionEvent, Props, SelectMode, Show, ShowCollection, ShowContainer, request_rename};
use craft::ui::primitives::IconSpec;
use craft::ui::list::{HueTarget, List, ListRow, OpenSet};
use craft::ui::menu::{Menu, MenuItem};
use craft::ui::menu::{Menu, MenuItem, PanelRow};
use craft::ui::notices::Notice;
use craft::ui::primitives::IconSpec;
use craft::ui::style::DataColor;
use craft::ui::text::TextField;
use pdfcraft_render::OutlineItem;
@@ -198,7 +199,7 @@ pub(super) fn body(app: &mut PdfCraftApp, ui: &mut egui::Ui) -> PanelResult {
let current = view.current;
if outline.is_empty() {
Notice::new(craft::theme::Tone::Neutral, tl!("This document has no bookmarks.")).show(ui);
Notice::new(craft::theme::variant::Tone::Neutral, tl!("This document has no bookmarks.")).show(ui);
return result;
}
@@ -347,7 +348,7 @@ pub(super) fn body(app: &mut PdfCraftApp, ui: &mut egui::Ui) -> PanelResult {
if info.outline_more {
Notice::new(
craft::theme::Tone::Neutral,
craft::theme::variant::Tone::Neutral,
tl!("Some bookmarks are not shown here: the panel lists a limited number, nested a limited depth."),
)
.show(ui);
+1 -4
View File
@@ -8,9 +8,7 @@ use std::collections::HashMap;
use std::time::{SystemTime, UNIX_EPOCH};
use craft::behavior::IconId;
use craft::review::ui::comments::{
CommentEdit, CommentsHeader, CommentsPanel, comments_filter_menu, comments_more_menu,
};
use craft::review::ui::comments::{CommentEdit, CommentsHeader, CommentsPanel, comments_filter_menu, comments_more_menu};
use craft::review::{CommentAnchor, CommentThread, PageOrder, ReviewStatus, ReviewerStatus, ThreadId};
use craft::ui::buttons::IconButton;
use craft::ui::contract::{Entry, Props as _, SelectMode, Show as _};
@@ -121,7 +119,6 @@ impl ThreadMap {
}
}
fn review_status(state: &str) -> Option<ReviewStatus> {
Some(match state {
"None" => ReviewStatus::None,
+19 -9
View File
@@ -71,8 +71,13 @@ pub(super) fn edit_panel(app: &mut PdfCraftApp, ui: &mut egui::Ui, g: &'static T
});
Section::fixed(tl!("Add content").to_string()).show(ui, |ui, _| {
let content: Vec<_> =
g.sections.iter().filter(|s| s.title == "Add content").flat_map(|s| s.items.iter()).filter(|i| i.command != "edit.edit_text").collect();
let content: Vec<_> = g
.sections
.iter()
.filter(|s| s.title == "Add content")
.flat_map(|s| s.items.iter())
.filter(|i| i.command != "edit.edit_text")
.collect();
let shown = if app.edit_more { content.len() } else { EDIT_CONTENT_SHOWN.min(content.len()) };
for i in content.iter().take(shown) {
let resp = tool_row(ui, i.icon, tl!(i.label), i.availability, !i.actions.is_empty());
@@ -169,11 +174,8 @@ impl craft::behavior::ItemSource<usize> for Stamps {}
pub(super) fn stamp_palette(app: &mut PdfCraftApp, ui: &mut egui::Ui) {
use pdfcraft_engine::{StampGroup, StampKind};
Text::new(tl!("Choose a stamp, then click on the page to place it.").to_string()).shade(Shade::Faint).show(ui);
let titles = [
(StampGroup::Dynamic, tl!("Dynamic")),
(StampGroup::SignHere, tl!("Sign Here")),
(StampGroup::StandardBusiness, tl!("Standard Business")),
];
let titles =
[(StampGroup::Dynamic, tl!("Dynamic")), (StampGroup::SignHere, tl!("Sign Here")), (StampGroup::StandardBusiness, tl!("Standard Business"))];
// The kinds in group order, and the headers' keys after every tile's.
let mut kinds: Vec<(StampGroup, StampKind)> = Vec::new();
let mut groups = Vec::new();
@@ -210,7 +212,14 @@ pub(super) fn stamp_palette(app: &mut PdfCraftApp, ui: &mut egui::Ui) {
/// A stamp's chip: its colour as a tinted frame (Sign Here as a pentagon pointing left, with the label
/// in white), the label, and the Dynamic stamps' second line.
fn paint_chip(cx: &craft::ui::primitives::ContentPainterCx<'_>, chip: egui::Rect, group: pdfcraft_engine::StampGroup, label: &str, by: &str, col: egui::Color32) {
fn paint_chip(
cx: &craft::ui::primitives::ContentPainterCx<'_>,
chip: egui::Rect,
group: pdfcraft_engine::StampGroup,
label: &str,
by: &str,
col: egui::Color32,
) {
use craft::ui::primitives::{PaintShape, StrokeWidth};
use craft::ui::style::DataColor;
use egui::vec2;
@@ -221,7 +230,8 @@ fn paint_chip(cx: &craft::ui::primitives::ContentPainterCx<'_>, chip: egui::Rect
let chip = chip.shrink2(vec2(0.0, line));
if group == StampGroup::SignHere {
let tip = height * 0.45;
let pts = vec![chip.left_center(), chip.left_top() + vec2(tip, 0.0), chip.right_top(), chip.right_bottom(), chip.left_bottom() + vec2(tip, 0.0)];
let pts =
vec![chip.left_center(), chip.left_top() + vec2(tip, 0.0), chip.right_top(), chip.right_bottom(), chip.left_bottom() + vec2(tip, 0.0)];
cx.with_draw(|draw| draw.data_fill(&PaintShape::Polygon(pts), DataColor::new(col)));
centred_text(cx, chip.center() + vec2(tip / 2.0, 0.0), label, height * 0.28, egui::Color32::WHITE);
} else {
+2 -5
View File
@@ -151,9 +151,7 @@ pub(crate) fn show(app: &mut PdfCraftApp, ui: &mut egui::Ui) -> PanelResult {
}
}
let rows = Rows::new(&info.fields, doc.form.as_slice());
let is_selected = |row: &Row<'_>| {
row.select.as_ref().is_some_and(|key| selection.selected.as_ref() == Some(key) || selection.also.contains(key))
};
let is_selected = |row: &Row<'_>| row.select.as_ref().is_some_and(|key| selection.selected.as_ref() == Some(key) || selection.also.contains(key));
let shown = Selection::new(
rows.rows.iter().filter(|r| is_selected(r)).map(|r| r.key.clone()).collect(),
rows.rows.iter().find(|r| r.select.is_some() && r.select.as_ref() == selection.selected.as_ref()).map(|r| r.key.clone()),
@@ -169,8 +167,7 @@ pub(crate) fn show(app: &mut PdfCraftApp, ui: &mut egui::Ui) -> PanelResult {
let page = if let FieldRow::Page(p) = &row.key { *p } else { None };
return ListRow::new(heading(info, page)).section_heading();
};
let mut list_row =
ListRow::new(field.name.clone()).icon(IconSpec::svg(IconId::new(kind_icon(&field.kind)))).tooltip(field_tip(field));
let mut list_row = ListRow::new(field.name.clone()).icon(IconSpec::svg(IconId::new(kind_icon(&field.kind)))).tooltip(field_tip(field));
if let Some(value) = &field.value {
list_row = list_row.optional(value.clone());
}
+3 -6
View File
@@ -26,9 +26,9 @@ use craft::ui::sections::Section;
use pdfcraft_engine::text_script::Script;
use pdfcraft_engine::{AddedText, FontFamily, TextAlign};
use crate::PdfCraftApp;
use crate::content_ui::TextDraft;
use crate::edit_text_ui::{Extras, LineEditor, SelectionFormatting};
use crate::PdfCraftApp;
/// A font picked in the font row. The caller applies it, since keeping the paragraph's own font
/// also means restoring the family it started with.
@@ -342,11 +342,8 @@ pub(crate) fn values(target: &Target, fmt: Option<&SelectionFormatting>, sources
/// that is not open for typing; alignment while a paragraph selection is not tidy.
pub(crate) fn unsupported(target: &Target) -> Vec<(FormatControl, Label)> {
let planned = || Label::from(tl!("Planned").to_string());
let mut out = vec![
(FormatControl::BulletedList, planned()),
(FormatControl::NumberedList, planned()),
(FormatControl::ParagraphSpacing, planned()),
];
let mut out =
vec![(FormatControl::BulletedList, planned()), (FormatControl::NumberedList, planned()), (FormatControl::ParagraphSpacing, planned())];
let paragraphs = target.paragraphs();
if target.extras().is_none() {
out.extend([(FormatControl::Underline, planned()), (FormatControl::LineSpacing, planned()), (FormatControl::HorizontalScale, planned())]);
+4 -5
View File
@@ -1,9 +1,10 @@
use super::{Nav, PanelResult, PanelRow, PdfCraftApp};
use super::right::PanelResult;
use super::{Nav, PdfCraftApp};
use craft::behavior::GesturePhase;
use craft::keymap::CommandRef;
use craft::pages::ui::{PageThumbnails, ThumbnailEvent, moved_page};
use craft::ui::contract::{Props, Show, ShowContainer};
use craft::ui::menu::{Menu, MenuItem};
use craft::ui::menu::{Menu, MenuItem, PanelRow};
use craft::ui::style::DataColor;
/// The Pages panel's tools menu rows: insert a blank page or pages from a file, rotate, extract and delete. Each
@@ -28,9 +29,7 @@ pub(super) fn body(app: &mut PdfCraftApp, ui: &mut egui::Ui) -> PanelResult {
let count = doc.info.pages.len();
let Some(view) = app.views.get_mut(index) else { return result };
// PLAN: assumed `DocPageSource::new(&DocInfo, Thumbnails<usize>) -> impl PageSource` and `DocView::thumbnails()`
// returning a cloneable handle (pdf-canvas-w6, pdf-canvas-w8).
let source = crate::canvas::DocPageSource::new(&doc.info, view.thumbnails());
let source = crate::canvas::pictures::DocPages::new(&app.session, id);
let before = view.thumbnail_zoom();
let mut zoom = f64::from(before);
let current = view.current;
+1 -2
View File
@@ -90,8 +90,7 @@ pub fn panel_body(app: &mut PdfCraftApp, ui: &mut egui::Ui, _cx: &mut BodyCx<'_>
Some(crate::sign_ui::PanelAction::Validate) => app.run_command("sign.validate"),
Some(crate::sign_ui::PanelAction::GoTo(p)) => app.views[index].go_to_page(p),
Some(crate::sign_ui::PanelAction::Trust(c)) => app.trust_certificate(*c),
// PLAN: assumed `cert_viewer::open(app, chain)` at the crate root (pdf-forms-w15).
Some(crate::sign_ui::PanelAction::ViewCertificate(chain)) => crate::cert_viewer::open(app, chain),
Some(crate::sign_ui::PanelAction::ViewCertificate(chain)) => crate::sign_ui::cert_viewer::open(app, chain),
Some(crate::sign_ui::PanelAction::ViewSigned { len, revision }) => app.view_signed_version(len, revision),
Some(crate::sign_ui::PanelAction::Sign(field)) => {
let page = app.views[index].current();
+5 -1
View File
@@ -128,7 +128,11 @@ pub(crate) fn show(app: &mut PdfCraftApp, ui: &mut egui::Ui) -> PanelResult {
let after = flat(text.text_of(range.end.min(n)..range.end.saturating_add(CONTEXT).min(n)));
let name = format!("…{before} {hit} {after}…");
ListRow::new(Label::Empty)
.lines(vec![Span::new(format!("…{before} ")).muted(), Span::new(hit).highlight().strong(), Span::new(format!(" {after}…")).muted()])
.lines(vec![
Span::new(format!("…{before} ")).muted(),
Span::new(hit).highlight().strong(),
Span::new(format!(" {after}…")).muted(),
])
.accessible_name(name)
.tooltip(tl!("Go to this result").to_string())
}
+27 -8
View File
@@ -5,8 +5,8 @@
//! by earlier versions (`side_panels`, `docking`) are read once by [`migrate`].
use craft::automation::dock as dock_rpc;
use craft::behavior::{Axis, DockSide};
use craft::behavior::dock::{Action, Column, DockEdge, DockPlacement, Group, Layout, Location, Node, Permissions, SplitSize, Target, Workspace};
use craft::behavior::{Axis, DockSide};
use craft::keymap::CommandRef;
use craft::ui::contract::{Bind, BodyCx};
use craft::ui::docking::{DockConfig, DockPanels, GroupAt, HidePanels, PanelSpec};
@@ -113,7 +113,6 @@ impl PanelId {
Self::Tools | Self::Toolbar | Self::Document => return None,
})
}
}
impl From<RightPanel> for PanelId {
@@ -458,7 +457,9 @@ pub fn command(app: &mut PdfCraftApp, reset: bool, params: &Value) -> Result<Val
}
let rail = match params.get("rail_side") {
None | Some(Value::Null) => None,
Some(Value::String(side)) if side == "toggle" => Some(if rail_edge(app.rail_side) == DockEdge::Start { DockSide::End } else { DockSide::Start }),
Some(Value::String(side)) if side == "toggle" => {
Some(if rail_edge(app.rail_side) == DockEdge::Start { DockSide::End } else { DockSide::Start })
}
Some(value) => {
let edge = edge_param(value.as_str().unwrap_or_default(), "rail_side")?;
Some(if edge == DockEdge::Start { DockSide::Start } else { DockSide::End })
@@ -717,7 +718,11 @@ mod tests {
"docked default",
with_side(
workspace(
split(json!({"FixedFirst": 300.0}), tabs(&["tools"]), split(json!({"FixedSecond": 400.0}), tabs(&["canvas"]), tabs(&["inspector"]))),
split(
json!({"FixedFirst": 300.0}),
tabs(&["tools"]),
split(json!({"FixedSecond": 400.0}), tabs(&["canvas"]), tabs(&["inspector"])),
),
json!([]),
json!([]),
),
@@ -730,7 +735,11 @@ mod tests {
(
"tools on the right",
workspace(
split(json!({"FixedSecond": 330.0}), tabs(&["canvas"]), split(json!({"FixedSecond": 290.0}), tabs(&["inspector"]), tabs(&["tools"]))),
split(
json!({"FixedSecond": 330.0}),
tabs(&["canvas"]),
split(json!({"FixedSecond": 290.0}), tabs(&["inspector"]), tabs(&["tools"])),
),
json!([]),
json!([]),
),
@@ -751,7 +760,10 @@ mod tests {
),
(
"tools tabbed with the inspector",
with_side(workspace(split(json!({"FixedSecond": 350.0}), tabs(&["canvas"]), tabs(&["inspector", "tools"])), json!([]), json!([])), "Pages"),
with_side(
workspace(split(json!({"FixedSecond": 350.0}), tabs(&["canvas"]), tabs(&["inspector", "tools"])), json!([]), json!([])),
"Pages",
),
true,
DockEdge::Start,
true,
@@ -759,7 +771,11 @@ mod tests {
(
"hidden inspector and tools",
with_side(
workspace(tabs(&["canvas"]), json!([]), json!([["inspector", hidden_place("Right", 380.0)], ["tools", hidden_place("Right", 300.0)]])),
workspace(
tabs(&["canvas"]),
json!([]),
json!([["inspector", hidden_place("Right", 380.0)], ["tools", hidden_place("Right", 300.0)]]),
),
"Bookmarks",
),
false,
@@ -768,7 +784,10 @@ mod tests {
),
(
"version 1 value",
with_side(json!({"side_panels": {"version": 1, "tools_side": "right", "tools_open": true, "tools_width": 300.0, "side_width": 400.0}}), "Pages"),
with_side(
json!({"side_panels": {"version": 1, "tools_side": "right", "tools_open": true, "tools_width": 300.0, "side_width": 400.0}}),
"Pages",
),
true,
DockEdge::End,
true,
+1 -5
View File
@@ -241,11 +241,7 @@ fn tool_detail(app: &mut PdfCraftApp, ui: &mut egui::Ui, g: &'static ToolGroup)
if marks > 0 {
caption_row(
ui,
&if marks == 1 {
crate::i18n::fmt(tl!("1 mark"), &[])
} else {
crate::i18n::fmt(tl!("{n} marks"), &[("n", &marks.to_string())])
},
&if marks == 1 { crate::i18n::fmt(tl!("1 mark"), &[]) } else { crate::i18n::fmt(tl!("{n} marks"), &[("n", &marks.to_string())]) },
false,
);
}
+2 -2
View File
@@ -24,7 +24,7 @@ use crate::theme::{self, Tokens};
use crate::{QuickTool, icons};
mod bridge;
mod colours;
pub(crate) mod colours;
mod composer;
mod geometry;
mod menu;
@@ -34,7 +34,7 @@ mod state;
mod tool;
pub(crate) use bridge::{
PageMap, annotations, delete_selected, edit, edit_anchor, id_of, key_of, kind_of, markers, parts, pdf_date_seconds, screen_to_user_rect,
PageMap, annotations, delete_selected, edit, edit_anchor, id_of, key_of, kind_of, markers, parts, pdf_date_seconds, rgb8, screen_to_user_rect,
thread_id, thread_key, tips, tips_shown,
};
#[cfg(test)]
+3 -2
View File
@@ -173,7 +173,7 @@ pub(crate) fn kind_of(all: &[Annotation], a: &Annotation) -> AnnotationKind {
})
}
fn rgb8(c: [f32; 3]) -> [u8; 3] {
pub(crate) fn rgb8(c: [f32; 3]) -> [u8; 3] {
c.map(|v| (v.clamp(0.0, 1.0) * 255.0).round() as u8)
}
@@ -332,7 +332,8 @@ pub(crate) fn parts(
let markers = marker_boxes(info, &anns, icon_side);
let Some(id) = pick_at(&anns, at, tolerance, icon_side, &markers) else { return Vec::new() };
let Some(found) = anns.iter().find(|a| a.id == id) else { return Vec::new() };
let mut shapes: Vec<Rect> = if found.kind.is_markup() { found.points.chunks(4).filter_map(bounds).collect() } else { vec![found.extent(icon_side)] };
let mut shapes: Vec<Rect> =
if found.kind.is_markup() { found.points.chunks(4).filter_map(bounds).collect() } else { vec![found.extent(icon_side)] };
shapes.extend(markers.iter().filter(|(m, _)| *m == id).map(|(_, r)| *r));
let screen_shapes: Vec<egui::Rect> = shapes
.iter()