Fit slide width on double-click from unzoomed view
This commit is contained in:
parent
8b193dfec6
commit
3066e82e51
|
|
@ -2245,7 +2245,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "pdf-presenter"
|
||||
version = "0.1.57"
|
||||
version = "0.1.58"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"chrono",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ default-members = ["crates/pdf-presenter"]
|
|||
resolver = "3"
|
||||
|
||||
[workspace.package]
|
||||
version = "0.1.57"
|
||||
version = "0.1.58"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
repository = "https://proxy.dandaedre.com/gitea/idle-org/pdf-presenter"
|
||||
|
|
|
|||
|
|
@ -51,8 +51,8 @@ pub fn tr<'a>(ctx: &egui::Context, text: &'a str) -> &'a str {
|
|||
"Disable zoom" => "Désactiver le zoom",
|
||||
"Keep zoom enabled" => "Garder le zoom activé",
|
||||
"Zoom performance" => "Performances du zoom",
|
||||
"Scroll to zoom · drag to pan · double-click to reset" => {
|
||||
"Molette pour zoomer · glisser pour déplacer · double-clic pour réinitialiser"
|
||||
"Scroll to zoom · drag to pan · double-click to fit width / reset" => {
|
||||
"Molette pour zoomer · glisser pour déplacer · double-clic pour ajuster à la largeur / réinitialiser"
|
||||
}
|
||||
"Use the current slide preview or a presentation screen. Changing slides resets zoom." => {
|
||||
"Utilisez l’aperçu actuel ou un écran de présentation. Changer de diapositive réinitialise le zoom."
|
||||
|
|
|
|||
|
|
@ -171,6 +171,12 @@ pub fn zoom_gestures_in(
|
|||
}
|
||||
if response.double_clicked() {
|
||||
next = Default::default();
|
||||
if view.normalized().scale == 1. {
|
||||
let fitted = fitted_slide(rect, dimensions);
|
||||
if fitted.width() > 0. {
|
||||
next.scale = (rect.width() / fitted.width()).clamp(1., 8.);
|
||||
}
|
||||
}
|
||||
}
|
||||
if response.hovered() || response.dragged() {
|
||||
ui.ctx().set_cursor_icon(if response.dragged() {
|
||||
|
|
@ -845,7 +851,7 @@ pub fn presenter(ui: &mut Ui, s: &mut Studio, native: &mut UiState) {
|
|||
);
|
||||
response.on_hover_text(tr(
|
||||
&locale,
|
||||
"Scroll to zoom · drag to pan · double-click to reset",
|
||||
"Scroll to zoom · drag to pan · double-click to fit width / reset",
|
||||
));
|
||||
if view != s.zoom.view {
|
||||
s.set_zoom(view);
|
||||
|
|
@ -2108,7 +2114,7 @@ fn menu(ui: &mut Ui, s: &mut Studio) {
|
|||
s.set_zoom(s.zoom.view.zoom_at(scale, [0.5; 2]));
|
||||
}
|
||||
if ui.button(tr(&locale, "Reset zoom")).clicked() { s.set_zoom(Default::default()); }
|
||||
ui.small(tr(&locale, "Scroll to zoom · drag to pan · double-click to reset"));
|
||||
ui.small(tr(&locale, "Scroll to zoom · drag to pan · double-click to fit width / reset"));
|
||||
ui.small(tr(&locale, "Use the current slide preview or a presentation screen. Changing slides resets zoom."));
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -601,3 +601,57 @@ fn portrait_screen_adapting_gestures_pan_visible_area_and_reset() {
|
|||
}
|
||||
assert_eq!(zoom, View::default());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn double_click_fits_width_then_resets_without_stretching() {
|
||||
use pdf_presenter::presenter_ui::{zoom_geometry, zoom_gestures_in};
|
||||
for (dimensions, expected) in [([210, 297], 2.8285716), ([400, 100], 1.), ([10, 1000], 8.)] {
|
||||
let ctx = Context::default();
|
||||
let target = Rect::from_min_size(Pos2::new(40., 40.), Vec2::new(400., 200.));
|
||||
let center = target.center();
|
||||
let mut view = View::default();
|
||||
let mut time = 0.;
|
||||
let mut render = |events| {
|
||||
time += 0.04;
|
||||
let _ = ctx.run_ui(
|
||||
RawInput {
|
||||
screen_rect: Some(Rect::from_min_size(Pos2::ZERO, Vec2::new(500., 300.))),
|
||||
events,
|
||||
time: Some(time),
|
||||
..Default::default()
|
||||
},
|
||||
|ui| {
|
||||
view = zoom_gestures_in(ui, target, dimensions, view, false).0;
|
||||
},
|
||||
);
|
||||
view
|
||||
};
|
||||
render(vec![egui::Event::PointerMoved(center)]);
|
||||
for expected_scale in [expected, 1.] {
|
||||
for _ in 0..20 {
|
||||
render(vec![]);
|
||||
}
|
||||
let mut actual = View::default();
|
||||
for _ in 0..2 {
|
||||
for pressed in [true, false] {
|
||||
actual = render(vec![egui::Event::PointerButton {
|
||||
pos: center,
|
||||
button: egui::PointerButton::Primary,
|
||||
pressed,
|
||||
modifiers: Default::default(),
|
||||
}]);
|
||||
}
|
||||
}
|
||||
assert!((actual.scale - expected_scale).abs() < 0.0001);
|
||||
assert_eq!(actual.center, [0.5; 2]);
|
||||
if actual.scale > 1. && actual.scale < 8. {
|
||||
let (draw, uv) = zoom_geometry(target, dimensions, actual, false);
|
||||
assert!((draw.width() - target.width()).abs() < 0.001);
|
||||
assert!(
|
||||
(uv.width() - 1.).abs() < 0.001,
|
||||
"fit width must show the entire page width"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,14 @@
|
|||
|
||||
## Unreleased
|
||||
|
||||
### 0.1.58
|
||||
|
||||
- Double-click an unzoomed current preview or presentation output to fit the page
|
||||
width to that viewport (within the existing 8× limit). Double-click while zoomed
|
||||
still resets to the whole page. Reuse the buffered texture and shared zoom state;
|
||||
update English/French gesture hints and the guide. Linux checks pass, including
|
||||
pointer-gesture regression tests and 86.22% whole-application coverage.
|
||||
|
||||
### 0.1.57
|
||||
|
||||
- Fix tiny clock/timer text in the header, above slides and below notes: use the
|
||||
|
|
|
|||
|
|
@ -334,7 +334,10 @@ the visible area, not the cached image resolution.
|
|||
- On the **current slide preview** or any **presentation screen**, scroll up/down
|
||||
to zoom in/out (1×–8×). The point under the mouse stays anchored when possible.
|
||||
- Hold the left mouse button and drag to move the enlarged image. Movement stops
|
||||
at the page edges. Double-click to reset to the complete fitted slide.
|
||||
at the page edges. When viewing the whole page, **double-click to fit its width**
|
||||
to the screen or current-preview area you clicked (up to 8×). Double-click again
|
||||
while zoomed to reset to the complete fitted page. Pages already filling the
|
||||
width stay unchanged. The optional fixed page area still applies if enabled.
|
||||
- **Menu → Page zoom** also has a zoom slider and **Reset zoom** button. If the
|
||||
current preview is hidden, show it in Layout to pan from the presenter.
|
||||
- All mirrored presenter/current previews and presentation outputs share zoom and
|
||||
|
|
|
|||
Loading…
Reference in New Issue