Fix All slides loading status and navigation

This commit is contained in:
Dandaedre 2026-11-20 08:56:14 +01:00
parent 29e8671c40
commit c7d527ac43
9 changed files with 119 additions and 34 deletions

2
Cargo.lock generated
View File

@ -2245,7 +2245,7 @@ dependencies = [
[[package]]
name = "pdf-presenter"
version = "0.1.63"
version = "0.1.64"
dependencies = [
"bytemuck",
"chrono",

View File

@ -4,7 +4,7 @@ default-members = ["crates/pdf-presenter"]
resolver = "3"
[workspace.package]
version = "0.1.63"
version = "0.1.64"
edition = "2024"
license = "MIT"
repository = "https://proxy.dandaedre.com/gitea/idle-org/pdf-presenter"

View File

@ -86,6 +86,10 @@ pub fn tr<'a>(ctx: &egui::Context, text: &'a str) -> &'a str {
"Preferences" => "Préférences",
"Storage locations" => "Emplacements de stockage",
"Preparing slide…" => "Préparation de la diapositive…",
"Slide ready" => "Diapositive prête",
"Cached · loads when nearby" => "En cache · chargée à proximité",
"Queued for preparation" => "En attente de préparation",
"Could not load slide" => "Échec du chargement",
"No slide" => "Aucune diapositive",
"End of slides" => "Fin des diapositives",
"Size" => "Taille",

View File

@ -659,10 +659,34 @@ impl App {
}
// Notes editing must never turn typing or Escape into presentation commands.
// Unsaved text is only discarded through the explicit editor control.
if role == Role::Presenter && (s.notes_editor.is_some() || s.notes_import.is_some()) {
if s.notes_editor.is_some() || s.notes_import.is_some() {
return;
}
if modifiers.ctrl || modifiers.alt || modifiers.command || consumed {
if modifiers.ctrl || modifiers.alt || modifiers.command {
return;
}
// Keep the live show responsive while an operator is using All slides or
// has a presenter menu open. Text editors and modified shortcuts above
// retain priority; focused controls may still consume all other keys.
match key {
Key::Named(NamedKey::Space) if modifiers.shift => {
s.execute(Action::Go(s.requested.saturating_sub(1)));
self.redraw();
return;
}
Key::Named(NamedKey::ArrowRight | NamedKey::PageDown | NamedKey::Space) => {
s.execute(Action::Go(s.requested + 1));
self.redraw();
return;
}
Key::Named(NamedKey::ArrowLeft | NamedKey::PageUp) => {
s.execute(Action::Go(s.requested.saturating_sub(1)));
self.redraw();
return;
}
_ => {}
}
if consumed {
return;
}
match key {
@ -697,17 +721,6 @@ impl App {
s.menu_open = false;
}
}
Key::Named(NamedKey::Space) if role == Role::Presenter && modifiers.shift => {
s.execute(Action::Go(s.requested.saturating_sub(1)))
}
Key::Named(NamedKey::ArrowRight | NamedKey::PageDown | NamedKey::Space)
if role == Role::Presenter =>
{
s.execute(Action::Go(s.requested + 1))
}
Key::Named(NamedKey::ArrowLeft | NamedKey::PageUp) if role == Role::Presenter => {
s.execute(Action::Go(s.requested.saturating_sub(1)))
}
Key::Character(c) if c.eq_ignore_ascii_case("b") => s.execute(Action::Blank),
_ => {}
}
@ -1430,24 +1443,24 @@ mod buffer_tests {
for (role, consumed, modifiers, expected) in [
(Role::Presenter, false, egui::Modifiers::NONE, 1),
(Role::Presenter, false, egui::Modifiers::SHIFT, 0),
(Role::Presenter, false, egui::Modifiers::SHIFT, 0),
(Role::Presenter, false, egui::Modifiers::NONE, 1),
(Role::Presenter, true, egui::Modifiers::SHIFT, 1),
(Role::Browser, false, egui::Modifiers::NONE, 1),
(Role::Browser, false, egui::Modifiers::SHIFT, 0),
(Role::Presenter, true, egui::Modifiers::NONE, 1),
(Role::Presenter, true, egui::Modifiers::SHIFT, 0),
(
Role::Presenter,
false,
egui::Modifiers::SHIFT | egui::Modifiers::CTRL,
1,
0,
),
(
Role::Presenter,
false,
egui::Modifiers::SHIFT | egui::Modifiers::ALT,
1,
0,
),
(Role::Browser, false, egui::Modifiers::SHIFT, 1),
(Role::Presentation, false, egui::Modifiers::SHIFT, 1),
(Role::Presenter, false, egui::Modifiers::NONE, 2),
(Role::Presentation, false, egui::Modifiers::NONE, 0),
(Role::Presenter, false, egui::Modifiers::NONE, 1),
(Role::Presenter, false, egui::Modifiers::NONE, 2),
] {
app.key(role, Key::Named(NamedKey::Space), consumed, modifiers);

View File

@ -2,7 +2,7 @@ use crate::localization::tr;
// Native controls for the approved presenter layout and safe slide browser.
use crate::{
settings::{Layout, TimerMode, TimerPosition},
studio::{Action, Studio},
studio::{Action, SlideLoadState, Studio},
};
use egui::{Color32, Context, FontId, Pos2, Rect, Sense, TextureHandle, TextureOptions, Ui, Vec2};
use std::{
@ -250,10 +250,19 @@ impl UiState {
ui.painter().text(
rect.center(),
egui::Align2::CENTER_CENTER,
if page < s.count() {
tr(&locale, "Preparing slide…")
} else {
if page >= s.count() {
tr(&locale, "No slide")
} else {
tr(
&locale,
match s.slide_load_state(page) {
SlideLoadState::Ready => "Slide ready",
SlideLoadState::Preparing => "Preparing slide…",
SlideLoadState::Cached => "Cached · loads when nearby",
SlideLoadState::Queued => "Queued for preparation",
SlideLoadState::Failed => "Could not load slide",
},
)
},
FontId::proportional(18.),
Color32::GRAY,
@ -1881,7 +1890,11 @@ pub fn browser(ui: &mut Ui, s: &mut Studio, native: &mut UiState) {
}
// Reserve a stable gutter, so neither thumbnail sizing nor scrollbar placement
// depends on how much of the last row is populated.
ui.spacing_mut().scroll = egui::style::ScrollStyle::solid();
let mut scroll_style = egui::style::ScrollStyle::solid();
scroll_style.bar_width = 10.;
scroll_style.handle_min_length = 36.;
scroll_style.foreground_color = true;
ui.spacing_mut().scroll = scroll_style;
let width = (browser_width - ui.spacing().scroll.allocated_width()).max(1.);
let gap = 16.;
let cols = ((width + gap) / (s.settings.thumbnail_size + gap))

View File

@ -57,6 +57,14 @@ pub struct NotesEditor {
pub busy: bool,
pub error: Option<String>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SlideLoadState {
Ready,
Preparing,
Cached,
Queued,
Failed,
}
pub struct RouteTrial {
pub id: u64,
pub deadline: Instant,
@ -256,6 +264,21 @@ impl Studio {
.iter()
.find_map(|&edge| self.frames.get(&(page, edge)).cloned())
}
pub fn slide_load_state(&self, page: usize) -> SlideLoadState {
if self.frame(page).is_some() {
SlideLoadState::Ready
} else if self.fg_job.is_some_and(|(job, _)| job == page)
|| self.bg_job.is_some_and(|(job, _)| job == page)
{
SlideLoadState::Preparing
} else if self.failed.contains(&(page, self.target_edge)) {
SlideLoadState::Failed
} else if self.prepared.contains(&page) {
SlideLoadState::Cached
} else {
SlideLoadState::Queued
}
}
pub fn full_frame(&self, page: usize) -> Option<Arc<Frame>> {
[self.target_edge, 512, 1280]
.iter()
@ -1349,3 +1372,24 @@ impl Studio {
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn absent_frames_report_their_actual_load_state() {
let mut studio = Studio::new(true, None);
assert_eq!(studio.slide_load_state(7), SlideLoadState::Queued);
studio.prepared.insert(7);
assert_eq!(studio.slide_load_state(7), SlideLoadState::Cached);
studio.fg_job = Some((7, studio.target_edge));
assert_eq!(studio.slide_load_state(7), SlideLoadState::Preparing);
studio.fg_job = None;
studio.failed.insert((7, studio.target_edge));
assert_eq!(studio.slide_load_state(7), SlideLoadState::Failed);
}
}

View File

@ -824,9 +824,8 @@ fn browser_thumbnails_fill_resized_window_without_stretching_tiles() {
}
assert!(!rects.is_empty());
let max_right = rects.iter().map(Rect::right).fold(0., f32::max);
assert!(
(max_right + egui::style::ScrollStyle::solid().allocated_width() - right).abs() < 1.
);
// A wide, non-floating scrollbar owns the far-right gutter.
assert!((max_right + 14. - right).abs() < 1.);
for rect in &rects {
assert!((rect.height() / rect.width() - 0.5625).abs() < 0.001);
assert!(rect.right() <= right);

View File

@ -2,6 +2,15 @@
## Unreleased
### 0.1.64
- Keep previous/next shortcuts active in the presenter and All slides, even when a
menu control consumed the key; notes editing and modified shortcuts keep priority.
Restore a wider high-contrast scrollbar at the far right of All slides. Label
absent thumbnail frames accurately as preparing, queued, cached on disk or failed
instead of claiming every scrolled-to slide is preparing. Linux checks pass with
86.38% whole-application coverage; the release binary is rebuilt.
### 0.1.63
- Aim double-click fit-width zoom at the clicked page position instead of always

View File

@ -79,8 +79,9 @@ Exit fullscreen** in the header to toggle both display roles. Like other
display changes, this previews the change with Keep/Revert confirmation. While the presenter is connected, closing a presentation window blanks it; close a
presenter or choose Menu → Quit to end the application.
Arrow keys and Page Up/Down navigate from the presenter. Space moves forward;
Shift+Space moves back. Type a 1-based slide
Arrow keys and Page Up/Down navigate from the presenter or All slides, including
while a presenter menu is open. Space moves forward; Shift+Space moves back. Notes
editors and Ctrl/Alt/Command combinations retain keyboard priority. Type a 1-based slide
number then Enter to jump; Backspace edits and Escape cancels. Out-of-range numbers
do not navigate. Output windows accept B/Escape for emergency blanking.
@ -119,7 +120,9 @@ without navigating unless Change on click is checked; it resets to OFF each time
browser opens. Show selected navigates explicitly and respects output blanking.
The selected tile and current slide have distinct outlines. Closing the browser saves
its monitor and preview-size preferences. The grid uses the slides already in memory;
only visible thumbnail textures are retained.
only visible thumbnail textures are retained. Empty tiles say whether a slide is
actively preparing, queued, or cached on disk until it is close enough to load into
the bounded RAM buffer.
## Preparation, processed slides and RAM