PdfCraft: An open-source PDF reader and editor written by scratch in pure Rust
Merge PR #3070: M7: the paragraph editor draws on its page only (#3061)
aiongg30ac04ace3d1
diff --cc crates/ui-egui/src/edit_text_ui.rsindex 031d9b3fb,e19caf686..490bbf583--- a/crates/ui-egui/src/edit_text_ui.rs+++ b/crates/ui-egui/src/edit_text_ui.rs@@@ -1497,13 -1313,11 +1498,17 @@@ pub(crate) fn overlay(ctx: &egui::Conte.line_editor.as_ref().is_some_and(|ed| view.text_background.ready(ed.page, ed.block) && !ed.source.as_ref().is_some_and(|(b, _)| b.invisible));- let draft_rect = view.text_background.draft_rect.map(|r| xf.user_rect(info, page, r.map(|v| v as f32)));+ // The measured extent of this paragraph's draft: a click straight from another paragraph+ // opens this one after the frame's measuring, which was the other one's.+ let draft_rect = view+ .line_editor+ .as_ref()+ .and_then(|ed| view.text_background.draft_rect_for(ed.page, ed.block))+ .map(|r| xf.user_rect(info, page, r.map(|v| v as f32)));+ // The editor draws on its page only, as the page itself does: a paragraph running past the+ // page's edge (a converter relying on the page clip) must not cover the next page or the+ // tool bars (#3061).+ let page_clip = xf.rect.intersect(view.viewport_rect());let ed = view.line_editor.as_mut()?;if hold {ed.focus = true;@@@ -1527,16 -1341,11 +1532,17 @@@ed.source.as_ref().and_then(|(block, lines)| block.lines.iter().filter_map(|i| lines.get(*i)).map(|l| l.size as f32).reduce(f32::min));let font = editor_font(&ed.look, smallest.map_or(ed.size, |s| (s * scale * 0.5).clamp(1.0, 300.0).min(ed.size)));let text_color = color32(ed.look.color);+ let block = ed.block;let mut done = None;- egui::Area::new(egui::Id::new("edit-text-line")).order(egui::Order::Foreground).fixed_pos(Pos2::new(ed.rect.left(), ed.rect.top())).show(- ctx,- |ui| {+ let mut reveal = false;+ let mut look = None;+ // No fade-in: while it faded, the page's own copy of the text showed through the cover.+ egui::Area::new(egui::Id::new("edit-text-line"))+ .order(egui::Order::Foreground)+ .fade_in(false)+ .fixed_pos(Pos2::new(ed.rect.left(), ed.rect.top()))+ .show(ctx, |ui| {+ ui.set_clip_rect(ui.clip_rect().intersect(page_clip));// The editor opens at the source size. Once text changes, show the real draft// extent: single rows grow toward the page edge, paragraphs rewrap at their// source width, and the visible frame grows/shrinks vertically with their rows.