mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-24 19:31:51 +01:00
Show the Organize close label and selected actions
This commit is contained in:
1 parent
15249ed990
commit
e327474d1d
2 files changed
+24
-1
No files matched your search
@@ -2,6 +2,7 @@ use super::{DocView, Edit, Pos2, ViewAction};
|
||||
use craft::behavior::{GesturePhase, IconId, MiddleButton, Selection};
|
||||
use craft::keymap::CommandRef;
|
||||
use craft::pages::ui::thumbnails::{ORGANIZE_ZOOM, PageThumbnails, ThumbnailArrangement, ThumbnailEvent};
|
||||
use craft::theme::Variant;
|
||||
use craft::ui::bars::{Bar, BarKind};
|
||||
use craft::ui::buttons::{Button, IconButton};
|
||||
use craft::ui::contract::overlay::Anchor;
|
||||
@@ -167,7 +168,7 @@ pub(super) fn organize_grid(view: &mut DocView, doc: &pdfcraft_engine::Document,
|
||||
// PLAN: assumed `Props::tooltip(impl Into<Tooltip>)` and `TooltipSpec -> Tooltip`.
|
||||
let hint = craft::ui::contract::TooltipSpec::new(tl!("Save these pages as one PDF")).disabled_text(tl!("No changes to save"));
|
||||
save |= Button::new(tl!("Save pages")).enabled(dirty).tooltip(hint).show(ui).clicked();
|
||||
close |= IconButton::new(IconId::new("x")).label(tl!("Close")).show(ui).clicked();
|
||||
close |= Button::new(tl!("Close")).variant(Variant::GHOST).icon(IconId::new("x")).show(ui).clicked();
|
||||
})
|
||||
.show(cx.ui, |ui, _| {
|
||||
Text::new(label.clone()).show(ui);
|
||||
|
||||
@@ -44,6 +44,28 @@ fn organize() -> Harness<'static, PdfCraftApp> {
|
||||
h
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn selected_pages_keep_actions_without_pointer_hover() {
|
||||
let mut h = organize();
|
||||
h.state_mut().views[0].select_pages(&[1, 2]);
|
||||
h.hover_at(Pos2::new(10.0, 10.0));
|
||||
h.run_steps(4);
|
||||
for page in [2, 3] {
|
||||
for action in ["Rotate page {label} counterclockwise", "Rotate page {label} clockwise", "Delete page {label}"] {
|
||||
let label = action.replace("{label}", &page.to_string());
|
||||
assert!(h.query_by_label(&label).is_some(), "selected page action is missing: {label}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn organize_header_paints_a_close_label() {
|
||||
let h = organize();
|
||||
assert!(h.output().shapes.iter().any(|shape| {
|
||||
matches!(&shape.shape, egui::Shape::Text(text) if text.galley.text() == "Close" && !text.galley.elided)
|
||||
}), "the Organize header must show the Close label");
|
||||
}
|
||||
|
||||
fn page_texts(app: &PdfCraftApp) -> Vec<String> {
|
||||
let doc = app.session.get(app.views[0].id).unwrap();
|
||||
let mut renderer = PageRenderer::new(doc.bytes.clone(), Default::default());
|
||||
|
||||
Reference in new issue
Block a user