mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-26 03:49:11 +00:00
Open paragraphs from inside their width grips
This commit is contained in:
@@ -1404,7 +1404,7 @@ fn page_body(ui: &mut egui::Ui, body: &PageBody<'_>, callbacks: &mut PageCallbac
|
||||
crate::edit_text_ui::picture_controls(ui, body, session, cx.doc, cx.info, geo),
|
||||
crate::object_ui::object_controls(ui, body, session, cx.info, parts_out.press.as_slice(), geo),
|
||||
crate::content_ui::content_controls(ui, body, session, cx.doc, added_hovered, cx.view_key),
|
||||
crate::edit_text_ui::paragraph_controls(ui, body, session, cx.doc, &parts_out, geo),
|
||||
crate::edit_text_ui::paragraph_controls(ui, body, session, cx.doc, &parts_out, geo, cx.tool == QuickTool::AddText),
|
||||
];
|
||||
// One edit per pass, the first control's that made one, as each control's own `or` keeps its first.
|
||||
if let Some(edit) = edits.into_iter().flatten().next() {
|
||||
|
||||
@@ -899,6 +899,7 @@ pub(crate) fn paragraph_controls(
|
||||
doc: &pdfcraft_engine::Document,
|
||||
parts: &PagePartsOutput,
|
||||
geo: PageGeometry<'_>,
|
||||
adding_text: bool,
|
||||
) -> Option<Edit> {
|
||||
let press = parts.press.as_ref().filter(|p| matches!(p.owner, Owner::Paragraph { .. }));
|
||||
let hovered = match parts.hovered {
|
||||
@@ -922,7 +923,11 @@ pub(crate) fn paragraph_controls(
|
||||
.or(hovered)
|
||||
.filter(|(p, _)| *p == page)
|
||||
.and_then(|(_, block)| blocks.get(block).zip(boxes.get(block).copied()).map(|(l, b)| (block, l, b)));
|
||||
edit = edit.or_else(|| width_frame(ui, body, session, doc, page, framed, geo));
|
||||
let mut clicked = None;
|
||||
edit = edit.or_else(|| width_frame(ui, body, session, doc, page, framed, geo, &mut clicked));
|
||||
if adding_text && let Some(block) = clicked {
|
||||
edit = edit.or_else(|| open_by_click(session, doc, page, block, geo));
|
||||
}
|
||||
}
|
||||
edit.or_else(|| editor_session(ui, body, session, doc, geo))
|
||||
}
|
||||
@@ -1014,6 +1019,7 @@ fn width_frame(
|
||||
page: usize,
|
||||
framed: Option<(usize, &pdfcraft_engine::TextBlock, Rect)>,
|
||||
geo: PageGeometry<'_>,
|
||||
clicked: &mut Option<usize>,
|
||||
) -> Option<Edit> {
|
||||
let info = &doc.info;
|
||||
let xf = session.page_xform(page, geo)?;
|
||||
@@ -1037,6 +1043,9 @@ fn width_frame(
|
||||
.id(width_frame_id(ui, page, block))
|
||||
.rules(rules)
|
||||
.show_at(ui, body.rect);
|
||||
if output.clicked.is_some_and(|(_, point)| b.contains(body.view.to_screen(point))) {
|
||||
*clicked = Some(block);
|
||||
}
|
||||
let after = output.edit.events.iter().find_map(|event| match event {
|
||||
EditEvent::Commit { after, .. } | EditEvent::Set { after, .. } => Some(*after),
|
||||
_ => None,
|
||||
|
||||
Reference in New Issue
Block a user