mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-26 03:49:11 +00:00
Adapt comment and signature hooks to framework
This commit is contained in:
@@ -160,7 +160,7 @@ fn reviewer_statuses(states: &ReviewStates<'_>, a: &Annotation) -> Vec<ReviewerS
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn message(a: &Annotation) -> craft::review::CommentMessage {
|
||||
fn message(doc: &pdfcraft_engine::Document, a: &Annotation) -> craft::review::CommentMessage {
|
||||
craft::review::CommentMessage {
|
||||
author: a.author.clone().unwrap_or_default(),
|
||||
created: a.modified.as_deref().and_then(pdf_date_seconds).unwrap_or(0),
|
||||
@@ -168,6 +168,7 @@ fn message(a: &Annotation) -> craft::review::CommentMessage {
|
||||
text: a.contents.clone().unwrap_or_default(),
|
||||
reactions: Vec::new(),
|
||||
read: true,
|
||||
deletable: doc.annotation_deletable(a.page, a.index),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,10 +199,10 @@ fn threads(doc: &pdfcraft_engine::Document, prefs: &CommentPrefs) -> (Vec<Commen
|
||||
let key = (a.page, a.index);
|
||||
let id = thread_id(key.0, key.1);
|
||||
let replies = replies.get(&key).map(Vec::as_slice).unwrap_or(&[]);
|
||||
let mut messages = vec![message(a)];
|
||||
let mut messages = vec![message(doc, a)];
|
||||
let mut members = vec![key];
|
||||
for r in replies {
|
||||
messages.push(message(r));
|
||||
messages.push(message(doc, r));
|
||||
members.push((r.page, r.index));
|
||||
}
|
||||
list.push(CommentThread {
|
||||
|
||||
@@ -389,8 +389,22 @@ impl ScanTabState {
|
||||
/// The Scan tab of the signature pad: choose or drop a photo, frame the signature, adjust the ink. Cleaning runs on
|
||||
/// the host's jobs, so a pass never waits for a scan. `draft.image` is set only by a full scan of the current frame
|
||||
/// and sensitivity, and cleared on any change, so the pad's Apply waits for the result.
|
||||
pub(crate) fn tab(host: Arc<Host>, wake: Wake) -> impl FnMut(&mut egui::Ui, &mut SignatureDraft, Option<OsFile>) + Send + 'static {
|
||||
pub(crate) fn tab(host: Arc<Host>, wake: Wake) -> impl FnMut(&mut egui::Ui, &mut SignatureDraft, craft::review::ui::ScanEvent) + Send + 'static {
|
||||
let queue = JobQueue::new(host.jobs_shared().clone(), wake, QueueOptions::default());
|
||||
let mut state = ScanTabState { host, scan: None, preview: None, shown: None, pick: None, queue, request: 0, view: unfitted(), error: None };
|
||||
move |ui, draft, dropped| state.show(ui, draft, dropped)
|
||||
move |ui, draft, event| match event {
|
||||
craft::review::ui::ScanEvent::Show(dropped) => state.show(ui, draft, dropped),
|
||||
craft::review::ui::ScanEvent::Clear => {
|
||||
if let Some(id) = state.pick.take() {
|
||||
state.host.files().forget(id);
|
||||
}
|
||||
state.queue.reprioritize(|_, _| None);
|
||||
state.request = state.request.wrapping_add(1);
|
||||
state.scan = None;
|
||||
state.preview = None;
|
||||
state.shown = None;
|
||||
state.view = unfitted();
|
||||
state.error = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user