mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-26 03:49:11 +00:00
pipe object_selection-1: fixes for object_selection (6 tests)
This commit is contained in:
@@ -13,7 +13,7 @@ use craft::host::queue::{JobQueue, QueueOptions};
|
||||
use craft::pages::ui::{PageBody, PageView, PageViewOutput, PageViewState, PlacedPage, TextMark, TextMarks, TextSelectState, TextSelection};
|
||||
use craft::review::ui::annotate::AnnotateWords;
|
||||
use craft::ui::canvas::{ContextRequest, Momentary, NavigationOptions, PageBorder, ToolHost};
|
||||
use craft::ui::contract::Show as _;
|
||||
use craft::ui::contract::{Props as _, Show as _};
|
||||
use craft::ui::display::Text;
|
||||
use craft::ui::list::OpenSet;
|
||||
use craft::ui::primitives::TextureStatistics;
|
||||
@@ -564,6 +564,7 @@ impl DocView {
|
||||
pub(crate) fn cancel_pointer_gestures(&mut self, ctx: &egui::Context) {
|
||||
self.session.comments.tool.cancel_drawing();
|
||||
self.cancel_page_drags(ctx);
|
||||
craft::ui::primitives::cancel_press_of(ctx, page_parts::control_id(self.view_key()));
|
||||
}
|
||||
|
||||
/// A view of a newly opened document, shown as `defaults` say, with fields highlighted when `highlight_fields`
|
||||
@@ -1260,7 +1261,7 @@ fn page_before(ui: &mut egui::Ui, body: &PageBody<'_>, callbacks: &mut PageCallb
|
||||
session.forms.focus = None;
|
||||
}
|
||||
let focus = crate::forms_ui::focus_owner(&session.forms, cx.form);
|
||||
let parts_out = PageParts::new(&parts).focus(focus).show_at(ui, body.rect);
|
||||
let parts_out = PageParts::new(&parts).id(page_parts::control_id(cx.view_key)).focus(focus).show_at(ui, body.rect);
|
||||
if session.forms.refocus
|
||||
&& let Some(at) = focus.and_then(|owner| page_parts::focus_stop(&parts, owner))
|
||||
{
|
||||
|
||||
@@ -53,6 +53,10 @@ const PREPARE_FIELD: PartKey = PartKey::new("prepare_field");
|
||||
const PARAGRAPH: PartKey = PartKey::new("paragraph");
|
||||
const PICTURE: PartKey = PartKey::new("picture");
|
||||
const OBJECTS: PartKey = PartKey::new("objects");
|
||||
/// The page-part control's identity also lets the view cancel its captured press on leaving.
|
||||
pub(crate) fn control_id(view_key: u64) -> egui::Id {
|
||||
egui::Id::new(("page-parts", view_key))
|
||||
}
|
||||
const FRAME: PartKey = PartKey::new("frame");
|
||||
const ADDED: PartKey = PartKey::new("added");
|
||||
const SIGN_TAB: PartKey = PartKey::new("sign_tab");
|
||||
|
||||
@@ -80,6 +80,16 @@ impl PdfCraftApp {
|
||||
// In Organize the clipboard rows and keys are the picked pages' (the catalog enables them as
|
||||
// `page.copy`, `page.cut` and `page.paste`); the registry's text Copy itself stays off there.
|
||||
let organize = self.active.and_then(|i| self.views.get(i)).is_some_and(|v| v.organize);
|
||||
if !organize
|
||||
&& !self.is_preparing()
|
||||
&& id == crate::menus::PASTE
|
||||
&& fired.pasted.is_none()
|
||||
&& fired.source == craft::ui::runtime::commands::FireSource::Menu
|
||||
{
|
||||
craft::ui::runtime::overlay::close_popups(ctx);
|
||||
ctx.send_viewport_cmd(egui::ViewportCommand::RequestPaste);
|
||||
return;
|
||||
}
|
||||
let page_command = match id {
|
||||
"edit.copy" => Some("page.copy"),
|
||||
crate::menus::CUT => Some("page.cut"),
|
||||
|
||||
@@ -63,9 +63,13 @@ fn harness_document(clipping: bool, background: bool) -> Harness<'static, PdfCra
|
||||
|
||||
/// The harness with the clipboard its app copies to: each copy's flavours are recorded in the list.
|
||||
fn harness_copying(clipping: bool, background: bool) -> (Harness<'static, PdfCraftApp>, Copies) {
|
||||
harness_copying_step(clipping, background, 0.25)
|
||||
}
|
||||
|
||||
fn harness_copying_step(clipping: bool, background: bool, step: f32) -> (Harness<'static, PdfCraftApp>, Copies) {
|
||||
let copies = Copies::default();
|
||||
let sink = copies.clone();
|
||||
let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_eframe(move |cc| {
|
||||
let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).with_step_dt(step).build_eframe(move |cc| {
|
||||
crate::support::install_runtime(&cc.egui_ctx);
|
||||
{
|
||||
let mut app = clipboard_app(&cc.egui_ctx, &sink);
|
||||
@@ -461,7 +465,7 @@ fn a_press_just_outside_a_picture_starts_an_area_selection() {
|
||||
/// added text opens for typing.
|
||||
#[test]
|
||||
fn a_double_click_on_a_grouped_object_reaches_it() {
|
||||
let mut h = harness();
|
||||
let mut h = harness_copying_step(false, false, 0.05).0;
|
||||
marquee(&mut h);
|
||||
// The added note is x 130..230, y 130..144 from the page's top.
|
||||
let note = at(&h, 180.0, 137.0);
|
||||
@@ -474,7 +478,7 @@ fn a_double_click_on_a_grouped_object_reaches_it() {
|
||||
/// button came up just off it.
|
||||
#[test]
|
||||
fn a_double_click_on_a_grouped_paragraph_released_just_off_it_opens_it() {
|
||||
let mut h = harness();
|
||||
let mut h = harness_copying_step(false, false, 0.05).0;
|
||||
marquee(&mut h);
|
||||
let (inside, outside) = {
|
||||
let app = h.state();
|
||||
@@ -483,7 +487,8 @@ fn a_double_click_on_a_grouped_paragraph_released_just_off_it_opens_it() {
|
||||
let doc = app.session.get(view.id).unwrap();
|
||||
let block = doc.text_blocks(0).into_iter().find(|b| b.text.contains("Group headline")).expect("the headline");
|
||||
let frame = xf.user_rect(&doc.info, 0, block.rect.map(|v| v as f32));
|
||||
(egui::pos2(frame.center().x, frame.top() + 1.0), egui::pos2(frame.center().x, frame.top() - 4.0))
|
||||
// Stay within click slop while releasing outside the paragraph.
|
||||
(egui::pos2(frame.center().x, frame.top() + 1.0), egui::pos2(frame.center().x, frame.top() - 1.0))
|
||||
};
|
||||
let button = |pos, pressed| egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed, modifiers: Modifiers::NONE };
|
||||
h.hover_at(inside);
|
||||
@@ -514,7 +519,7 @@ fn a_press_counts_the_modifiers_of_its_own_event() {
|
||||
/// A double-click on a paragraph selected with others opens it for typing (the user's ruling).
|
||||
#[test]
|
||||
fn a_double_click_on_a_grouped_paragraph_opens_it() {
|
||||
let mut h = harness();
|
||||
let mut h = harness_copying_step(false, false, 0.05).0;
|
||||
marquee(&mut h);
|
||||
// "Group headline" is at x 40, its baseline y 430 of 500.
|
||||
let headline = at(&h, 80.0, 65.0);
|
||||
@@ -660,6 +665,7 @@ fn a_picture_for_a_native_edit_paste_with_a_context_menu_open_lands_on_the_page(
|
||||
let before = can_undo(&h, 0);
|
||||
crate::support::fire_menu(&mut h, "edit.paste");
|
||||
assert!(crate::support::asked_for_the_clipboard(&h), "Edit ▸ Paste asked the platform for the clipboard");
|
||||
h.run_steps(2);
|
||||
assert!(h.query_by_role(egui::accesskit::Role::Menu).is_none(), "Edit ▸ Paste closed the context menu");
|
||||
h.event(egui::Event::PasteImage(std::sync::Arc::new(egui::ColorImage::filled([30, 20], egui::Color32::GRAY))));
|
||||
h.run_steps(3);
|
||||
|
||||
Reference in New Issue
Block a user