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
11 changes: 11 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog — CalcDex

## Unreleased

### Fixed
- **Projection mode keeps the History rail.** Turning on classroom
projection enlarges the whole window (1.5x), which used to make
the History rail drop away and the top row run off the right edge
on ordinary screens. The rail's fit is now judged on the physical
window width, both side rails start narrower while projection is
on so all three panes stay on screen together, and the top row
wraps instead of clipping.

## 0.9.0 — 2026-11-02

**Engineering-contract conformance release.** No calculator
Expand Down
15 changes: 15 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ pub mod settings;
pub mod students;
pub mod teachers;

/// Below this window width the history rail collapses: the header
/// LOG toggle then switches the centre to the log view. The width is
/// measured on the physical screen (see `history_rail_visible`).
pub const HISTORY_RAIL_MIN_WIDTH: f32 = 1100.0;

/// Whether the history rail fits beside the mode rail and the centre.
/// `content_width` is the window's layout width in points and
/// `zoom_factor` the UI zoom (1.5 in classroom projection mode). The
/// product is the physical width, so turning projection on — which
/// enlarges everything — never makes the rail vanish from a window
/// that showed it at normal size: the panes give way instead.
pub fn history_rail_visible(content_width: f32, zoom_factor: f32) -> bool {
content_width * zoom_factor >= HISTORY_RAIL_MIN_WIDTH
}

pub type CalcFn = Box<dyn Fn(&[f64]) -> Result<String, String> + Sync + Send>;
/// A text-input calculator (v0.4.0 expression calculator): the second
/// argument is the angle mode, true = degrees, false = radians.
Expand Down
31 changes: 21 additions & 10 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3235,10 +3235,10 @@ const MUTED_PROJ: egui::Color32 = egui::Color32::from_rgb(0xb8, 0xb8, 0xb8);
const DISPLAY_BG: egui::Color32 = egui::Color32::from_rgb(0x0c, 0x0c, 0x0c);
/// Raised fill for chips and raised controls (#181818).
const RAISED: egui::Color32 = egui::Color32::from_rgb(0x18, 0x18, 0x18);
/// Below this window width (points) the history rail collapses: the
/// header LOG toggle then switches the centre to the log view, as in
/// v0.1.x. At the 760 pt minimum window the rail is always collapsed.
const HISTORY_RAIL_MIN_WIDTH: f32 = 1100.0;
// The history rail's width threshold lives in the library
// (`calcdex::HISTORY_RAIL_MIN_WIDTH`, with the pure visibility rule
// `calcdex::history_rail_visible`): it is judged on the physical
// window width, so projection zoom never hides the rail.

/// One mode-rail row: short label on the left, shortcut hint on the
/// right, full category name in the hover tooltip. Selected styling
Expand Down Expand Up @@ -3864,7 +3864,10 @@ impl eframe::App for App {
.map(|idx| !self.calcs[idx].list && self.calcs[idx].text_run.is_none())
.unwrap_or(false);

let wide = ctx.content_rect().width() >= HISTORY_RAIL_MIN_WIDTH;
// Judged on the physical width (layout points x zoom), so the
// history rail that fits at normal size still fits — and is
// still shown — in projection mode (field report, 2026-11-02).
let wide = calcdex::history_rail_visible(ctx.content_rect().width(), ctx.zoom_factor());
let mut hist_restore: Option<LogEntry> = None;
let mut hist_clear = false;
let mut hist_restore_cleared = false;
Expand All @@ -3873,7 +3876,11 @@ impl eframe::App for App {
let mut hist_export: Option<(LogFilter, String)> = None;

egui::TopBottomPanel::top("top").show(ctx, |ui| {
ui.horizontal(|ui| {
// Wrapped, not plain horizontal: at projection zoom the
// logical window is narrower and this long row (title,
// BATCH/HELP, the FORMAT group, LOG) used to run off the
// right edge and clip (field report, 2026-11-02).
ui.horizontal_wrapped(|ui| {
ui.label(
egui::RichText::new("CALCDEX")
.color(GREEN)
Expand Down Expand Up @@ -4166,10 +4173,14 @@ impl eframe::App for App {
});

// ---- Mode rail (far left) ----
// In projection mode both rails start narrower, so the centre
// keeps a workable share of the zoomed (logically smaller)
// window and all three panes stay on screen together.
let proj = self.settings.projection;
egui::SidePanel::left("modes")
.resizable(true)
.default_width(178.0)
.width_range(140.0..=240.0)
.default_width(if proj { 150.0 } else { 178.0 })
.width_range(if proj { 120.0..=200.0 } else { 140.0..=240.0 })
.show(ctx, |ui| {
ui.label(
egui::RichText::new("SEARCH")
Expand Down Expand Up @@ -4292,8 +4303,8 @@ impl eframe::App for App {
if self.show_log && wide {
egui::SidePanel::right("history")
.resizable(true)
.default_width(300.0)
.width_range(240.0..=420.0)
.default_width(if proj { 260.0 } else { 300.0 })
.width_range(if proj { 220.0..=340.0 } else { 240.0..=420.0 })
.show(ctx, |ui| {
let out = history_ui(
ui,
Expand Down
16 changes: 16 additions & 0 deletions tests/v060.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,3 +538,19 @@ fn set_entries_hold_display_tokens_for_dates() {
let line = calcdex::teachers::entry_problem_line(&e).unwrap();
assert!(line.contains("Birth Date = 04/23/1988"), "{line}");
}

// ---------- history rail under projection zoom (field fix) ----------

#[test]
fn history_rail_visibility_is_judged_on_physical_width() {
use calcdex::history_rail_visible;
// Normal size: the 1100 pt threshold applies as before.
assert!(history_rail_visible(1200.0, 1.0));
assert!(!history_rail_visible(1000.0, 1.0));
assert!(!history_rail_visible(760.0, 1.0));
// The field case: a wide physical window at 1.5x projection zoom
// has ~1045 pt of layout width, yet the rail must stay visible.
assert!(history_rail_visible(1045.0, 1.5));
// A genuinely small screen stays collapsed even zoomed.
assert!(!history_rail_visible(700.0, 1.5));
}
Loading