Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## 1.8.2

### New

- **Audience screen settings** (Settings > Audience screen, also under Present > Audience screen). **Detect displays automatically** (on at first) finds a projector or TV plugged in or out while TeXora is open, and **Look every** sets how often, from 1 to 30 seconds; **Look for displays now** checks at once. When the slide's shape differs from the screen's, **Fit** shows the whole slide with bands at the sides, **Fill** covers the screen and trims the slide's edges, and **Stretch** stretches the slide to the screen. **High resolution** (on at first) draws the slide with the screen's own pixels, up to 4K.

### Fixed

- **A projector or TV plugged in while TeXora is open is now found.** Before, TeXora only saw the displays connected when it started; it now makes a newly connected display the audience screen and says so, and notices one being unplugged.
- **The teleprompter no longer lingers between slides.** When a slide's notes end, the script moves quickly past the blank space and the next slide's heading to the next slide's first line, then goes on at the reading speed, so the reading band never waits on empty space. The space between slides is also smaller. **Band follows lines** (off at first) puts the band on the line being read, gliding from line to line, instead of at a fixed reading line.
- **The current slide in the presenter view is again at least as large as its automatic fit.** A divider saved earlier, or in another window size, could leave the current slide smaller than the next one; it now fills its column and grows with the window.

## 1.8.1

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "texora"
version = "1.8.1"
version = "1.8.2"
edition = "2021"
description = "TeXora: a LaTeX-native presenter for Beamer and PDF slides"
license = "PolyForm-Noncommercial-1.0.0"
Expand Down
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,14 @@ Drag the dividers to resize panels; **View > Fit all panels automatically** rese
### Audience window

- **F5** opens the audience window, fullscreen on a second display; on a single display, **F11**
makes it fullscreen.
makes it fullscreen. A projector or TV plugged in while TeXora is open is found within a few
seconds; **Present > Audience screen** lists the displays.
- **Settings > Audience screen** (also under **Present > Audience screen**): **Detect displays
automatically** and how often to look; **Fit** (the whole slide, bands at the sides), **Fill** (the
whole screen, slide edges trimmed) or **Stretch** when the slide's shape differs from the screen's;
and **High resolution**, the screen's own pixels up to 4K.
- A 4:3 slide on a 16:9 TV shows bands with **Fit**. For slides that fill a widescreen display, use
`\documentclass[aspectratio=169]{beamer}`.
- **B** blanks the screen, **W** shows a whiteboard, **F** freezes the audience view.
- Ink, the laser pointer and zoom appear on the audience screen as they are used.

Expand Down Expand Up @@ -240,7 +247,9 @@ with **View > Teleprompter**, or with **K**, which also starts it.
| **Dark** | Light text on a dark background; click again for dark text on light | |
| **Background**, **Text** | Pick any colours; remembered | |

A band marks the reading line. Moving to another slide brings its notes to the reading line. The
A band marks the reading line; between slides the script moves quickly past the blank space to the
next slide's first line. **Band follows lines** puts the band on the line being read instead. Moving to another slide brings its notes
to the reading line. The
wheel, or **Down** and **Up**, move the script by hand, and Cmd/Ctrl with the wheel changes the text
size. The notes come from the source, the `.note.md` file or the text of Beamer notes pages.

Expand Down
66 changes: 61 additions & 5 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ pub const PALETTE: [[u8; 3]; 6] =
[[214, 40, 40], [240, 150, 20], [240, 210, 40], [40, 160, 70], [30, 110, 220], [170, 60, 200]];

const MAX_RENDER_WIDTH: u32 = 3000;
/// The widest the audience screen's slide is drawn in high resolution (a 4K display).
const AUDIENCE_MAX_WIDTH: u32 = 4096;
pub const SAMPLE_TEX: &str = include_str!("../assets/sample/texora-sample.tex");
pub const SAMPLE_PDF: &[u8] = include_bytes!("../assets/sample/texora-sample.pdf");
const SAMPLE_NAV: &str = include_str!("../assets/sample/texora-sample.nav");
Expand Down Expand Up @@ -275,6 +277,8 @@ pub struct App {
pub audience_age: u32,
pub displays: Vec<display_info::DisplayInfo>,
pub display: usize,
/// When the displays were last looked at.
pub displays_checked: Instant,

pub src: Option<Source>,
pub compiling: bool,
Expand Down Expand Up @@ -329,6 +333,10 @@ pub struct App {
pub prompter_target: Option<f32>,
pub prompter_seek: Option<usize>,
pub prompter_nudge: f32,
/// The script's lines of text, as last drawn (top and bottom, in script units), and where the
/// reading band is (its middle and height), gliding from line to line.
pub prompter_rows: Vec<(f32, f32)>,
pub prompter_band: Option<(f32, f32)>,
pub sync_mark: Option<(usize, [f32; 2], Instant)>,
/// Animations in the PDF (the animate package): where each one is in its play, by (page, number).
pub anim_play: HashMap<(usize, usize), AnimPlay>,
Expand Down Expand Up @@ -492,6 +500,7 @@ impl App {
audience_age: 0,
displays,
display,
displays_checked: Instant::now(),
src: None,
compiling: false,
compile_again: false,
Expand Down Expand Up @@ -528,6 +537,8 @@ impl App {
prompter_target: None,
prompter_seek: None,
prompter_nudge: 0.0,
prompter_rows: vec![],
prompter_band: None,
sync_mark: None,
anim_play: HashMap::new(),
anim_cache: HashMap::new(),
Expand Down Expand Up @@ -1036,8 +1047,47 @@ impl App {

// ---------- every frame ----------

/// Looks again at the connected displays, so a projector or TV plugged in (or out) while
/// TeXora is open is found without restarting it. The chosen audience display stays chosen while
/// it is connected; a newly connected second display becomes the audience display.
/// Settings > Audience screen turns this off, and sets how often it looks.
fn refresh_displays(&mut self, ctx: &Context) {
if !self.st.detect_displays {
return;
}
let every = std::time::Duration::from_secs_f32(self.st.display_check_secs.clamp(1.0, 30.0));
ctx.request_repaint_after(every);
if self.displays_checked.elapsed() >= every {
self.look_for_displays();
}
}

/// Reads the connected displays now (also **Present > Audience screen > Look for displays now**).
pub fn look_for_displays(&mut self) {
self.displays_checked = Instant::now();
let Ok(now) = display_info::DisplayInfo::all() else { return };
let ids = |l: &[display_info::DisplayInfo]| l.iter().map(|d| (d.id, d.x, d.y, d.width, d.height)).collect::<Vec<_>>();
if now.is_empty() || ids(&now) == ids(&self.displays) {
return;
}
let chosen = self.displays.get(self.display).map(|d| d.id);
let before = self.displays.len();
self.display = chosen
.and_then(|id| now.iter().position(|d| d.id == id && (now.len() < 2 || !d.is_primary)))
.or_else(|| now.iter().position(|d| !d.is_primary))
.unwrap_or(0);
let name = |d: &display_info::DisplayInfo| if d.friendly_name.is_empty() { "a display".to_string() } else { d.friendly_name.clone() };
if now.len() > before && now.len() >= 2 {
self.status = format!("{} connected: the slides will show there. Press F5 to present.", name(&now[self.display]));
} else if now.len() < before {
self.status = if now.len() < 2 { "Second display disconnected. Press F11 for fullscreen slides.".to_string() } else { "A display was disconnected.".to_string() };
}
self.displays = now;
}

pub fn pump(&mut self, ctx: &Context) {
self.tick += 1;
self.refresh_displays(ctx);
// The audience window is drawn from this one, and macOS stops drawing a hidden window, as
// it does behind a fullscreen slide on one screen. A talk must not freeze because of that.
// This request lasts one frame, so it is sent every frame.
Expand Down Expand Up @@ -1345,11 +1395,17 @@ impl App {
pub fn texture(&mut self, page: usize, region: Region, want: u32) -> Option<TextureHandle> {
// Sizes come in steps, and a page is never rendered larger than is useful, so zooming
// reuses pictures instead of queueing a new huge one for every small change.
let want = match want {
0..=1600 => want.max(64).div_ceil(32) * 32,
1601..=2000 => 2000,
2001..=2500 => 2500,
_ => MAX_RENDER_WIDTH,
// The audience screen in high resolution gets the width it really shows, up to 4K, so text
// stays sharp on a large display.
let want = if self.painting_audience && self.st.audience_hires {
want.clamp(64, AUDIENCE_MAX_WIDTH).div_ceil(64) * 64
} else {
match want {
0..=1600 => want.max(64).div_ceil(32) * 32,
1601..=2000 => 2000,
2001..=2500 => 2500,
_ => MAX_RENDER_WIDTH,
}
};
let settling = self.zoom_changed.elapsed().as_secs_f32() < 0.18;
let tick = self.tick;
Expand Down
39 changes: 39 additions & 0 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,30 @@ pub fn add_new_actions(keys: &mut Vec<(Action, Vec<KeyBind>)>) {
}
}

/// How a slide takes the audience screen when their shapes differ (a 4:3 slide on a 16:9 TV, a
/// wide slide on a tall screen).
#[derive(Clone, Copy, PartialEq, Eq, Debug, Default, Serialize, Deserialize)]
pub enum AudienceFit {
/// The whole slide, as large as fits; bands fill the rest of the screen.
#[default]
Fit,
/// The screen filled, keeping the slide's shape; the slide's edges are cut off.
Fill,
/// The screen filled by stretching the slide to its shape.
Stretch,
}

impl AudienceFit {
pub const ALL: [AudienceFit; 3] = [AudienceFit::Fit, AudienceFit::Fill, AudienceFit::Stretch];
pub fn label(self) -> &'static str {
match self {
AudienceFit::Fit => "Fit: the whole slide, bands at the sides",
AudienceFit::Fill => "Fill: the whole screen, slide edges trimmed",
AudienceFit::Stretch => "Stretch: the whole screen, slide stretched",
}
}
}

/// The teleprompter's two looks, as (background, text): dark text on light, and light text on dark.
pub const PROMPTER_LIGHT: ([u8; 3], [u8; 3]) = ([252, 251, 249], [20, 20, 20]);
pub const PROMPTER_DARK: ([u8; 3], [u8; 3]) = ([18, 18, 20], [236, 235, 230]);
Expand Down Expand Up @@ -295,6 +319,9 @@ pub struct Settings {
pub prompter_speed: f32,
/// When the teleprompter's script reaches the next slide's notes, that slide comes on show.
pub prompter_follow: bool,
/// The teleprompter's band sits on the line being read and glides from line to line, instead of
/// staying at the reading line.
pub prompter_band_lines: bool,
/// The teleprompter's background and text colours (light by default; Dark swaps them).
pub prompter_bg: [u8; 3],
pub prompter_fg: [u8; 3],
Expand All @@ -312,6 +339,13 @@ pub struct Settings {
pub vlc_path: String,
/// Videos play their sound (through ffplay, which comes with ffmpeg).
pub video_sound: bool,
/// Look for displays plugged in or out while the app is open, every `display_check_secs`.
pub detect_displays: bool,
pub display_check_secs: f32,
/// How the slide takes the audience screen, and whether it is drawn at the screen's full
/// resolution (up to 4K).
pub audience_fit: AudienceFit,
pub audience_hires: bool,
/// Look for a newer version when TeXora starts.
pub check_updates: bool,
/// A newer version the speaker chose to skip: its update notice is not shown again.
Expand All @@ -334,6 +368,7 @@ impl Default for Settings {
notes_size: 26.0,
prompter_speed: 4.0,
prompter_follow: true,
prompter_band_lines: false,
prompter_bg: PROMPTER_LIGHT.0,
prompter_fg: PROMPTER_LIGHT.1,
notes_in_tex: true,
Expand All @@ -343,6 +378,10 @@ impl Default for Settings {
ffmpeg_path: String::new(),
vlc_path: String::new(),
video_sound: true,
detect_displays: true,
display_check_secs: 2.0,
audience_fit: AudienceFit::Fit,
audience_hires: true,
check_updates: true,
skipped_update: String::new(),
last_template: String::new(),
Expand Down
2 changes: 2 additions & 0 deletions src/ui_chrome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,8 @@ impl App {
for (i, n) in names.into_iter().enumerate() {
ui.radio_value(&mut self.display, i, n);
}
ui.separator();
self.audience_settings(ui);
});
ui.separator();
self.item(ui, "Black screen", Action::Blackout);
Expand Down
31 changes: 31 additions & 0 deletions src/ui_panels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,36 @@ impl App {
});
}

/// Settings > Audience screen: finding displays, and how the slide takes the screen.
pub fn audience_settings(&mut self, ui: &mut Ui) {
let mut changed = false;
changed |= ui.checkbox(&mut self.st.detect_displays, "Detect displays automatically").on_hover_text("Finds a projector or TV plugged in, or out, while the app is open").changed();
ui.add_enabled_ui(self.st.detect_displays, |ui| {
ui.horizontal(|ui| {
ui.label("Look every");
changed |= ui.add(Slider::new(&mut self.st.display_check_secs, 1.0..=30.0).step_by(1.0).suffix(" s")).changed();
});
});
if ui.button("Look for displays now").clicked() {
self.look_for_displays();
if self.status.is_empty() {
self.status = format!("{} display{} found.", self.displays.len(), if self.displays.len() == 1 { "" } else { "s" });
}
}
ui.add_space(6.0);
ui.label(RichText::new("When the slide's shape differs from the screen's (a 4:3 slide on a 16:9 TV):").size(12.5).color(MUTED));
for f in crate::settings::AudienceFit::ALL {
changed |= ui.radio_value(&mut self.st.audience_fit, f, f.label()).changed();
}
changed |= ui
.checkbox(&mut self.st.audience_hires, "High resolution (the screen's own pixels, up to 4K)")
.on_hover_text("Sharper text on large displays; uses more memory")
.changed();
if changed {
self.save_layout();
}
}

fn settings_tab(&mut self, ui: &mut Ui) {
ScrollArea::vertical().auto_shrink([false, true]).show(ui, |ui| {
ui.label(RichText::new("Click a heading to open or close its section.").size(12.0).color(MUTED));
Expand Down Expand Up @@ -316,6 +346,7 @@ impl App {
let force = std::mem::take(&mut self.show_packages).then_some(true);
ui.add_space(4.0);
CollapsingHeader::new(strong("Required LaTeX packages", 14.5)).id_salt(("settings", "Required LaTeX packages")).default_open(false).open(force).show(ui, |ui| self.required_packages(ui));
group(ui, "Audience screen", false, &mut |ui| self.audience_settings(ui));
group(ui, "Video", false, &mut |ui| self.video_settings(ui));
group(ui, "Speaker notes", false, &mut |ui| {
// A LaTeX presentation keeps its notes in the source, as \note{} in each slide.
Expand Down
Loading
Loading