mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-12-01 10:45:31 +01:00
Merge branch 'pipe/s3' into area/app-1
This commit is contained in:
commit
88666f4aa4
6 files changed
+35
-11
No files matched your search
@@ -1857,10 +1857,8 @@ pub fn document_area_at(app: &mut PdfCraftApp, index: usize, rect: Rect, ui: &mu
|
||||
view.want_text(&app.session, &visible_pages, &rest_pages);
|
||||
|
||||
find_bar(view, info.pages.len(), rect, tool == QuickTool::EditText && can_modify, ui);
|
||||
// Whether the clipboard holds a picture, read only when this pass opens the page menu (a clipboard read is slow).
|
||||
// PLAN: a menu left open from an earlier pass keeps its row only if `page_menu` reads the clipboard itself.
|
||||
let can_paste_image = body_out.context.is_some() && app.can_paste_image();
|
||||
// The clipboard read takes the app; the document is read again after it.
|
||||
// The clipboard is read when Paste is invoked, so its menu stays enabled while the document is open.
|
||||
let can_paste_image = true;
|
||||
let doc = app.session.get(doc_id)?;
|
||||
let info = &doc.info;
|
||||
let view = &mut app.views[index];
|
||||
|
||||
@@ -117,7 +117,7 @@ impl CanvasTool for PageSelectTool<'_> {
|
||||
let capped = if self.cap_clicks && pointer.clicks > 2 { pointer.clicks(1) } else { *pointer };
|
||||
let action = self.text.press(&capped, cx);
|
||||
self.pick(&capped);
|
||||
action
|
||||
if action == ToolAction::Done && self.picks.pending.is_some() { ToolAction::Claimed } else { action }
|
||||
}
|
||||
|
||||
fn drag(&mut self, pointer: &ToolPointer, cx: &mut ToolContext<'_>) {
|
||||
|
||||
@@ -76,7 +76,7 @@ impl CanvasTool for EditTextTool<'_> {
|
||||
{
|
||||
return ToolAction::Done;
|
||||
}
|
||||
object_ui::begin_marquee(self.session, page, pointer.mods);
|
||||
object_ui::begin_marquee(self.session, pointer.mods);
|
||||
ToolAction::Claimed
|
||||
}
|
||||
|
||||
|
||||
@@ -692,7 +692,33 @@ pub(crate) fn page_parts(
|
||||
.filter(|(block, _)| Some(*block) != open)
|
||||
.filter_map(|(block, &bounds)| {
|
||||
let reach = if adding_text { bounds } else { reach_of(&boxes, block, upright) }.intersect(placed.rect);
|
||||
reach.is_positive().then(|| PagePart::new(Owner::Paragraph { block }, page, HitShape::Rect(reach), PageLayer::Text).cursor(cursor))
|
||||
if !reach.is_positive() {
|
||||
return None;
|
||||
}
|
||||
let shape = if adding_text || !upright {
|
||||
HitShape::Rect(reach)
|
||||
} else {
|
||||
let inner = (bounds.width() / 4.0).min(EDGE_REACH);
|
||||
let left = (bounds.left() + inner).clamp(reach.left(), reach.right());
|
||||
let right = (bounds.right() - inner).clamp(reach.left(), reach.right());
|
||||
let top = bounds.top().clamp(reach.top(), reach.bottom());
|
||||
let bottom = bounds.bottom().clamp(reach.top(), reach.bottom());
|
||||
HitShape::Polygon(vec![
|
||||
egui::pos2(reach.left(), reach.top()),
|
||||
egui::pos2(left, reach.top()),
|
||||
egui::pos2(left, top),
|
||||
egui::pos2(right, top),
|
||||
egui::pos2(right, reach.top()),
|
||||
egui::pos2(reach.right(), reach.top()),
|
||||
egui::pos2(reach.right(), reach.bottom()),
|
||||
egui::pos2(right, reach.bottom()),
|
||||
egui::pos2(right, bottom),
|
||||
egui::pos2(left, bottom),
|
||||
egui::pos2(left, reach.bottom()),
|
||||
egui::pos2(reach.left(), reach.bottom()),
|
||||
])
|
||||
};
|
||||
Some(PagePart::new(Owner::Paragraph { block }, page, shape, PageLayer::Text).cursor(cursor))
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
@@ -301,12 +301,11 @@ fn modified_target(session: &mut PageSession, doc: &Document, page: usize, xf: &
|
||||
}
|
||||
}
|
||||
|
||||
/// An area selection begins on `page`: the single selections of the families let go. The sweep itself is the
|
||||
/// An area selection begins: the single selections of the families let go. The sweep itself is the
|
||||
/// press's span, read from each pass's press phase.
|
||||
pub(crate) fn begin_marquee(session: &mut PageSession, page: usize, mods: Mods) {
|
||||
pub(crate) fn begin_marquee(session: &mut PageSession, mods: Mods) {
|
||||
leave_single(session);
|
||||
session.objects.marquee_mods = mods;
|
||||
session.pending_page = Some((page, None));
|
||||
}
|
||||
|
||||
/// The swept rectangle on screen while the press `phase` drags, whatever it started from.
|
||||
|
||||
@@ -1749,8 +1749,9 @@ fn paste_from_a_right_click_where_two_pages_touch_keeps_to_the_first_page() {
|
||||
right_click(&mut h, seam);
|
||||
assert_eq!(h.state().views[0].session.comments.context_at.map(|(page, _)| page), Some(0), "page 1 takes the right-click");
|
||||
assert!(h.state().views[0].session.image_selection.is_none(), "page 2's picture is not selected for its menu");
|
||||
h.event(picture());
|
||||
h.get_by_label("Paste").click();
|
||||
h.run_steps(1);
|
||||
h.event(picture());
|
||||
h.run_steps(3);
|
||||
let images = |page| {
|
||||
let s = h.state();
|
||||
|
||||
Reference in new issue
Block a user