mirror of
https://github.com/storytold/lightcraft.git
synced 2026-11-28 17:29:31 +01:00
Merge pull request #2974 from OneSlips/pr/windows-maximized-window
LR-BEHAV-WINDOW: on Windows a maximized window opens maximized
This commit is contained in:
6 files changed
+322
-11
No files matched your search
@@ -76,7 +76,7 @@ use launch::{
|
||||
};
|
||||
#[cfg(test)]
|
||||
use platform::{explorer_select_arg, explorer_select_command, windows_open_url_command};
|
||||
use prefs::{PrefsWriter, as_remembered, load_prefs, prefs_path};
|
||||
use prefs::{MAXIMIZE_LATER, PrefsWriter, as_remembered, load_prefs, prefs_path};
|
||||
#[cfg(test)]
|
||||
use prefs::{load_prefs_at, write_atomic};
|
||||
use session::{open_session, services};
|
||||
@@ -555,7 +555,7 @@ fn main() -> eframe::Result {
|
||||
let opens_as = prefs.as_ref().and_then(|ui| ui.window).and_then(lightcraft_ui_egui::window_place::WindowPlace::checked);
|
||||
let options = eframe::NativeOptions {
|
||||
renderer,
|
||||
viewport: as_remembered(egui::ViewportBuilder::default().with_title(lightcraft_ui_egui::channel::name()), opens_as)
|
||||
viewport: as_remembered(egui::ViewportBuilder::default().with_title(lightcraft_ui_egui::channel::name()), opens_as, MAXIMIZE_LATER)
|
||||
.with_min_inner_size(lightcraft_ui_egui::window_place::MIN_SIZE)
|
||||
.with_drag_and_drop(true)
|
||||
.with_transparent(window_gpu::composes_window(compose_window, window_renderer))
|
||||
@@ -640,6 +640,10 @@ fn main() -> eframe::Result {
|
||||
written: serde_json::to_vec_pretty(&app.ui).unwrap_or_default(),
|
||||
library: app.ui.settings.library_path.clone(),
|
||||
keep_file: keep_prefs_file,
|
||||
start: Some(
|
||||
lightcraft_ui_egui::window_place::StartPlace::new(MAXIMIZE_LATER && opens_as.is_some_and(|w| w.zoomed))
|
||||
.remembered(opens_as.map(|w| w.size)),
|
||||
),
|
||||
..Default::default()
|
||||
};
|
||||
// a library opened from its catalog file is the one in use from now on, as Open Library makes it
|
||||
|
||||
@@ -24,13 +24,24 @@ pub(crate) fn config_dir() -> Option<std::path::PathBuf> {
|
||||
/// The window at the size it was last used at, zoomed if it was (`window`), or at the usual size
|
||||
/// when nothing is remembered. A zoomed window is given the size it goes back to. Where it
|
||||
/// opens is the system's to say.
|
||||
pub(crate) fn as_remembered(builder: egui::ViewportBuilder, window: Option<lightcraft_ui_egui::window_place::WindowPlace>) -> egui::ViewportBuilder {
|
||||
///
|
||||
/// Windows: a window built maximized could open covering half the screen while
|
||||
/// the system took it for maximized, so there (`maximize_later`) it is built at its size and
|
||||
/// maximized once it shows ([`lightcraft_ui_egui::window_place::StartPlace`]).
|
||||
pub(crate) fn as_remembered(
|
||||
builder: egui::ViewportBuilder,
|
||||
window: Option<lightcraft_ui_egui::window_place::WindowPlace>,
|
||||
maximize_later: bool,
|
||||
) -> egui::ViewportBuilder {
|
||||
let builder = builder.with_inner_size(window.map_or(lightcraft_ui_egui::window_place::DEFAULT_SIZE, |w| w.size));
|
||||
// (only ever asked to zoom: asked not to, macOS un-zooms a window whose size fills the screen
|
||||
// to a size of its own choosing)
|
||||
if window.is_some_and(|w| w.zoomed) { builder.with_maximized(true) } else { builder }
|
||||
if window.is_some_and(|w| w.zoomed) && !maximize_later { builder.with_maximized(true) } else { builder }
|
||||
}
|
||||
|
||||
/// Windows maximizes a remembered maximized window once it shows (see [`as_remembered`]).
|
||||
pub(crate) const MAXIMIZE_LATER: bool = cfg!(target_os = "windows");
|
||||
|
||||
/// `<config>/ui.json`, the saved UI state and app settings — `None` when nothing is read or
|
||||
/// written: `LIGHTCRAFT_NO_PREFS` (tests, scripts) or no home folder.
|
||||
pub(crate) fn prefs_path() -> Option<std::path::PathBuf> {
|
||||
@@ -161,6 +172,9 @@ pub(crate) struct PrefsWriter {
|
||||
/// When the window was first looked at: its watch goes by the clock from then on, not by
|
||||
/// the interface's time, which stands still while the window is hidden.
|
||||
pub(crate) window_since: Option<std::time::Instant>,
|
||||
/// The window as it first shows: maximized then on Windows, fitted to a smaller screen.
|
||||
/// `None` once done, and in tests.
|
||||
pub(crate) start: Option<lightcraft_ui_egui::window_place::StartPlace>,
|
||||
}
|
||||
|
||||
impl PrefsWriter {
|
||||
@@ -221,7 +235,24 @@ impl PrefsWriter {
|
||||
// `run_logic` pass has no fresh content rect: keep the last known placement.
|
||||
let remembered = app.ui.window.and_then(lightcraft_ui_egui::window_place::WindowPlace::checked);
|
||||
let at = self.window_since.get_or_insert_with(std::time::Instant::now).elapsed().as_secs_f64();
|
||||
if !hidden {
|
||||
// (while the window is being placed it is not remembered: it may not be as it will be; a
|
||||
// hidden pass's stale size places nothing)
|
||||
let placing = self.start.is_some();
|
||||
if let Some(start) = &mut self.start {
|
||||
if !hidden {
|
||||
for command in start.step(&seen, at, zoom) {
|
||||
ctx.send_viewport_cmd(command);
|
||||
}
|
||||
} else {
|
||||
// (hidden: nothing to place by, but the time limit still runs)
|
||||
start.idle(at);
|
||||
}
|
||||
match start.waits() {
|
||||
Some(wait) => ctx.request_repaint_after(wait),
|
||||
None => self.start = None,
|
||||
}
|
||||
}
|
||||
if !hidden && !placing {
|
||||
app.ui.window = self.window.note(remembered, &seen, at);
|
||||
}
|
||||
if let Some(wait) = self.window.waits(at) {
|
||||
|
||||
@@ -660,12 +660,15 @@ fn ui_json_is_written_atomically() {
|
||||
#[test]
|
||||
fn the_window_opens_as_it_was() {
|
||||
use lightcraft_ui_egui::window_place::{DEFAULT_SIZE, WindowPlace};
|
||||
let fresh = as_remembered(egui::ViewportBuilder::default(), None);
|
||||
let fresh = as_remembered(egui::ViewportBuilder::default(), None, false);
|
||||
assert_eq!((fresh.inner_size, fresh.position, fresh.maximized), (Some(egui::Vec2::from(DEFAULT_SIZE)), None, None));
|
||||
let b = as_remembered(egui::ViewportBuilder::default(), Some(WindowPlace { size: [1300.0, 800.0], zoomed: true }));
|
||||
let b = as_remembered(egui::ViewportBuilder::default(), Some(WindowPlace { size: [1300.0, 800.0], zoomed: true }), false);
|
||||
assert_eq!((b.inner_size, b.position, b.maximized), (Some(egui::vec2(1300.0, 800.0)), None, Some(true)));
|
||||
// Windows: built at its size, maximized once it shows
|
||||
let b = as_remembered(egui::ViewportBuilder::default(), Some(WindowPlace { size: [1300.0, 800.0], zoomed: true }), true);
|
||||
assert_eq!((b.inner_size, b.maximized), (Some(egui::vec2(1300.0, 800.0)), None));
|
||||
// (not asked to un-zoom: macOS would then resize a window that fills its screen)
|
||||
let b = as_remembered(egui::ViewportBuilder::default(), Some(WindowPlace { size: [1300.0, 800.0], zoomed: false }));
|
||||
let b = as_remembered(egui::ViewportBuilder::default(), Some(WindowPlace { size: [1300.0, 800.0], zoomed: false }), false);
|
||||
assert_eq!((b.inner_size, b.position, b.maximized), (Some(egui::vec2(1300.0, 800.0)), None, None));
|
||||
}
|
||||
|
||||
|
||||
@@ -318,5 +318,166 @@ impl WindowWatch {
|
||||
}
|
||||
}
|
||||
|
||||
/// How long after the window first shows it is maximized (Windows): a frame or two, so that it is on
|
||||
/// its screen and the system maximizes it to that screen's work area.
|
||||
const MAXIMIZE_AFTER_SECONDS: f64 = 0.1;
|
||||
/// How long after asking the window is checked: the system animates a maximize.
|
||||
const MAXIMIZE_CHECK_SECONDS: f64 = 0.6;
|
||||
/// A maximized window this much of its screen across, and down, fills it (the taskbar, and the
|
||||
/// borders Windows keeps off screen, take the rest).
|
||||
const MAXIMIZED_ACROSS: f32 = 0.9;
|
||||
const MAXIMIZED_DOWN: f32 = 0.75;
|
||||
/// `zoom` when it is a usable interface zoom, else 1.
|
||||
fn interface_zoom(zoom: f32) -> f32 {
|
||||
if zoom.is_finite() && zoom > 0.0 { zoom } else { 1.0 }
|
||||
}
|
||||
|
||||
/// The window's minimum in the system's points: [`MIN_SIZE`] is in the interface's, which `zoom` scales (at 2× a
|
||||
/// 900 × 560 minimum holds the window to 1800 × 1120).
|
||||
fn native_min(zoom: f32) -> [f32; 2] {
|
||||
[MIN_SIZE[0] * zoom, MIN_SIZE[1] * zoom]
|
||||
}
|
||||
|
||||
/// When the window's minimum (at `zoom`) is larger than `room` (system points) on either side: the command that lowers
|
||||
/// it to `room`, in the interface's points. Nothing when the minimum fits.
|
||||
fn min_within(room: [f32; 2], zoom: f32) -> Vec<egui::ViewportCommand> {
|
||||
let min = native_min(zoom);
|
||||
if min[0] > room[0] || min[1] > room[1] {
|
||||
let lowered = [min[0].min(room[0]), min[1].min(room[1])];
|
||||
return vec![egui::ViewportCommand::MinInnerSize(egui::vec2(lowered[0] / zoom, lowered[1] / zoom))];
|
||||
}
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
/// A window opened larger than its screen is fitted to this much of it.
|
||||
const FIT_TO_SCREEN: f32 = 0.9;
|
||||
/// How long after its first frame the window is placed at most: one that stays unseen, full
|
||||
/// screen or minimized that long is left as it is.
|
||||
const PLACE_WITHIN_SECONDS: f64 = 5.0;
|
||||
|
||||
/// The window as it first shows. On Windows a window built maximized could open
|
||||
/// covering half the screen while the system took it for maximized: its maximize button then
|
||||
/// restored it, smaller. So there it opens at its remembered size and is maximized once it is on its
|
||||
/// screen ([`StartPlace::new`] with `maximize_after`); if it then says it is maximized but doesn't
|
||||
/// fill its screen, it is restored and maximized again, once. A window remembered larger than the
|
||||
/// screen it opens on (a display unplugged, a smaller one, another scale) is fitted to that screen.
|
||||
#[derive(Debug)]
|
||||
pub struct StartPlace {
|
||||
/// Maximize once the window shows.
|
||||
maximize: bool,
|
||||
/// When it was asked to (seconds), and whether it has been asked again.
|
||||
asked: Option<f64>,
|
||||
retried: bool,
|
||||
/// When the window first showed, and when it was first looked at.
|
||||
shown: Option<f64>,
|
||||
first_step: Option<f64>,
|
||||
done: bool,
|
||||
/// The size it was remembered at (system points), before the system or eframe fitted it to its screen.
|
||||
remembered: Option<[f32; 2]>,
|
||||
}
|
||||
|
||||
impl StartPlace {
|
||||
/// `maximize_after`: the window was built at its size and should be maximized once it shows.
|
||||
pub fn new(maximize_after: bool) -> StartPlace {
|
||||
StartPlace { maximize: maximize_after, asked: None, retried: false, shown: None, first_step: None, done: false, remembered: None }
|
||||
}
|
||||
|
||||
/// The size the window was remembered at and built with (`size`, system points): a window remembered larger
|
||||
/// than its screen is fitted to it even when it was clamped to the whole screen before it was first seen
|
||||
/// (eframe clamps a remembered 1600 × 1000 to a 1280 × 720 screen).
|
||||
pub fn remembered(mut self, size: Option<[f32; 2]>) -> StartPlace {
|
||||
self.remembered = size.filter(|s| s.iter().all(|v| v.is_finite()));
|
||||
self
|
||||
}
|
||||
|
||||
/// Whether there is nothing more to do.
|
||||
pub fn done(&self) -> bool {
|
||||
self.done
|
||||
}
|
||||
|
||||
/// The window is `seen` at time `now` (seconds), with the interface zoomed by `zoom`: what to
|
||||
/// tell it.
|
||||
pub fn step(&mut self, seen: &Seen, now: f64, zoom: f32) -> Vec<egui::ViewportCommand> {
|
||||
if self.done {
|
||||
return Vec::new();
|
||||
}
|
||||
// (not shown yet, its screen unknown, full screen or minimized: wait, but not for ever)
|
||||
if self.out_of_time(now) {
|
||||
return Vec::new();
|
||||
}
|
||||
if seen.full_screen || seen.minimized {
|
||||
return Vec::new();
|
||||
}
|
||||
let (Some(size), Some(screen)) = (seen.size, seen.screen) else { return Vec::new() };
|
||||
let shown = *self.shown.get_or_insert(now);
|
||||
if !self.maximize {
|
||||
self.done = true;
|
||||
// remembered larger than this screen: fitted to it, and never larger than it (a screen smaller than
|
||||
// the window's minimum lowers the minimum to the screen)
|
||||
let larger = |s: [f32; 2]| s[0] > screen[0] + SAME_WITHIN || s[1] > screen[1] + SAME_WITHIN;
|
||||
if !seen.zoomed && (larger(size) || self.remembered.is_some_and(larger)) {
|
||||
// (`seen` is in the system's points, the commands in the interface's)
|
||||
let zoom = interface_zoom(zoom);
|
||||
let min = native_min(zoom);
|
||||
let side = |i: usize| (screen[i] * FIT_TO_SCREEN).max(min[i]).min(screen[i]);
|
||||
let fit = [side(0), side(1)];
|
||||
// a minimum larger than the fitted size (a small screen, a zoomed interface) is lowered to it first
|
||||
let mut told = min_within(fit, zoom);
|
||||
told.push(egui::ViewportCommand::InnerSize(egui::vec2(fit[0] / zoom, fit[1] / zoom)));
|
||||
return told;
|
||||
}
|
||||
return Vec::new();
|
||||
}
|
||||
let fills = size[0] >= screen[0] * MAXIMIZED_ACROSS && size[1] >= screen[1] * MAXIMIZED_DOWN;
|
||||
match self.asked {
|
||||
None if now - shown >= MAXIMIZE_AFTER_SECONDS => {
|
||||
self.asked = Some(now);
|
||||
// a screen smaller than the window's minimum lowers it first, or the maximized window would stay wider
|
||||
let mut told = min_within(screen, interface_zoom(zoom));
|
||||
told.push(egui::ViewportCommand::Maximized(true));
|
||||
told
|
||||
}
|
||||
None => Vec::new(),
|
||||
Some(at) if now - at < MAXIMIZE_CHECK_SECONDS => Vec::new(),
|
||||
Some(_) if seen.zoomed && fills => {
|
||||
self.done = true;
|
||||
Vec::new()
|
||||
}
|
||||
Some(_) if !self.retried => {
|
||||
// maximized in name only (or not at all): restore it, and maximize it again
|
||||
self.retried = true;
|
||||
self.asked = Some(now);
|
||||
vec![egui::ViewportCommand::Maximized(false), egui::ViewportCommand::Maximized(true)]
|
||||
}
|
||||
Some(_) => {
|
||||
self.done = true;
|
||||
Vec::new()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A pass with nothing to place by (the window is hidden: its size is stale) at time `now`: the time limit
|
||||
/// still runs, so a window kept hidden ends the placement and stops asking to be looked at.
|
||||
pub fn idle(&mut self, now: f64) {
|
||||
if !self.done {
|
||||
self.out_of_time(now);
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether placing has gone on for longer than it may (it is then done); its clock starts at the first pass.
|
||||
fn out_of_time(&mut self, now: f64) -> bool {
|
||||
let first = *self.first_step.get_or_insert(now);
|
||||
if now - first > PLACE_WITHIN_SECONDS {
|
||||
self.done = true;
|
||||
}
|
||||
self.done
|
||||
}
|
||||
|
||||
/// When to look again while it waits (the app may have nothing else to draw).
|
||||
pub fn waits(&self) -> Option<std::time::Duration> {
|
||||
(!self.done).then(|| std::time::Duration::from_millis(100))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
@@ -592,3 +592,113 @@ fn what_was_remembered_is_checked_and_never_costs_the_other_settings() {
|
||||
assert_eq!(place(size, false).checked(), None, "{size:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// On Windows the window opens at its size and is maximized once it shows; a
|
||||
/// window that says it is maximized but covers half its screen is restored and maximized again,
|
||||
/// once; a window remembered larger than its screen is fitted to it.
|
||||
#[test]
|
||||
fn the_window_is_maximized_once_it_shows_and_again_if_it_only_says_so() {
|
||||
use egui::ViewportCommand as C;
|
||||
let mut s = StartPlace::new(true);
|
||||
assert!(s.step(&Seen::default(), 0.0, 1.0).is_empty(), "not shown yet");
|
||||
assert!(s.step(&window([1300.0, 800.0]), 0.0, 1.0).is_empty(), "a frame first");
|
||||
assert_eq!(s.step(&window([1300.0, 800.0]), 0.2, 1.0), vec![C::Maximized(true)]);
|
||||
assert!(s.step(&window([1300.0, 800.0]), 0.3, 1.0).is_empty(), "the system animates");
|
||||
// maximized in name, half the screen: once more
|
||||
let half = Seen { zoomed: true, ..window([1280.0, 1400.0]) };
|
||||
assert_eq!(s.step(&half, 1.0, 1.0), vec![C::Maximized(false), C::Maximized(true)]);
|
||||
let full = Seen { zoomed: true, ..window([2560.0, 1392.0]) };
|
||||
assert!(s.step(&full, 1.2, 1.0).is_empty());
|
||||
assert!(s.step(&full, 1.7, 1.0).is_empty() && s.done());
|
||||
assert_eq!(s.waits(), None);
|
||||
// it filled its screen the first time: nothing more
|
||||
let mut s = StartPlace::new(true);
|
||||
s.step(&window([1300.0, 800.0]), 0.0, 1.0);
|
||||
s.step(&window([1300.0, 800.0]), 0.2, 1.0);
|
||||
assert!(s.step(&full, 1.0, 1.0).is_empty() && s.done());
|
||||
// never more than one retry
|
||||
let mut s = StartPlace::new(true);
|
||||
s.step(&window([1300.0, 800.0]), 0.0, 1.0);
|
||||
s.step(&window([1300.0, 800.0]), 0.2, 1.0);
|
||||
assert_eq!(s.step(&half, 1.0, 1.0).len(), 2);
|
||||
assert!(s.step(&half, 2.0, 1.0).is_empty() && s.done());
|
||||
// not to be maximized: a window larger than its screen is fitted to it
|
||||
let mut s = StartPlace::new(false);
|
||||
let big = Seen { size: Some([3000.0, 2000.0]), screen: Some([1920.0, 1080.0]), ..Default::default() };
|
||||
assert_eq!(s.step(&big, 0.0, 1.0), vec![C::InnerSize(egui::vec2(1728.0, 972.0))]);
|
||||
assert!(s.done() && s.step(&big, 1.0, 1.0).is_empty());
|
||||
let mut s = StartPlace::new(false);
|
||||
assert!(s.step(&window([1300.0, 800.0]), 0.0, 1.0).is_empty() && s.done());
|
||||
// full screen or minimized: left alone
|
||||
let mut s = StartPlace::new(true);
|
||||
assert!(s.step(&Seen { full_screen: true, ..window([2560.0, 1440.0]) }, 1.0, 1.0).is_empty());
|
||||
// ... but not for ever: it stops asking for frames
|
||||
assert!(s.step(&Seen { full_screen: true, ..window([2560.0, 1440.0]) }, 6.5, 1.0).is_empty());
|
||||
assert!(s.done() && s.waits().is_none());
|
||||
// a window that never says its size or screen is given up on too
|
||||
let mut s = StartPlace::new(true);
|
||||
assert!(s.step(&Seen::default(), 0.0, 1.0).is_empty());
|
||||
assert!(s.step(&Seen::default(), 5.5, 1.0).is_empty() && s.done());
|
||||
// the interface zoomed 2×: the fitted size is asked for in its points, half the system's
|
||||
let mut s = StartPlace::new(false);
|
||||
// (its 900 × 560 minimum is 1800 × 1120 there, taller than the 1080 screen: lowered to the fitted size first)
|
||||
assert_eq!(s.step(&big, 0.0, 2.0), vec![C::MinInnerSize(egui::vec2(900.0, 540.0)), C::InnerSize(egui::vec2(900.0, 540.0))]);
|
||||
}
|
||||
|
||||
/// A screen smaller than the window's minimum (800 × 600 beside a 900 pt minimum): the window is fitted within it
|
||||
/// and the minimum is lowered to it, so it never asks for more than the screen (CodeRabbit on #2974).
|
||||
#[test]
|
||||
fn a_window_on_a_screen_smaller_than_its_minimum_fits_within_the_screen() {
|
||||
use egui::ViewportCommand as C;
|
||||
let mut s = StartPlace::new(false);
|
||||
let small = Seen { size: Some([900.0, 560.0]), screen: Some([800.0, 600.0]), ..Default::default() };
|
||||
assert_eq!(s.step(&small, 0.0, 1.0), vec![C::MinInnerSize(egui::vec2(800.0, 560.0)), C::InnerSize(egui::vec2(800.0, 560.0))]);
|
||||
// remembered maximized on that screen: the minimum is lowered before it is maximized, or it would stay wider
|
||||
let mut s = StartPlace::new(true);
|
||||
s.step(&small, 0.0, 1.0);
|
||||
assert_eq!(s.step(&small, 0.2, 2.0), vec![C::MinInnerSize(egui::vec2(400.0, 300.0)), C::Maximized(true)]);
|
||||
// a screen larger than the minimum, but not than the minimum the zoomed interface makes of it (CodeRabbit on #2974)
|
||||
let mut s = StartPlace::new(true);
|
||||
let laptop = Seen { size: Some([1100.0, 700.0]), screen: Some([1200.0, 800.0]), ..Default::default() };
|
||||
s.step(&laptop, 0.0, 2.0);
|
||||
assert_eq!(s.step(&laptop, 0.2, 2.0), vec![C::MinInnerSize(egui::vec2(600.0, 400.0)), C::Maximized(true)]);
|
||||
let mut s = StartPlace::new(false);
|
||||
let wide = Seen { size: Some([1600.0, 1000.0]), ..laptop };
|
||||
assert_eq!(s.step(&wide, 0.0, 2.0), vec![C::MinInnerSize(egui::vec2(600.0, 400.0)), C::InnerSize(egui::vec2(600.0, 400.0))]);
|
||||
// a screen the minimum fits on keeps the minimum
|
||||
let mut s = StartPlace::new(true);
|
||||
s.step(&window([1300.0, 800.0]), 0.0, 1.0);
|
||||
assert_eq!(s.step(&window([1300.0, 800.0]), 0.2, 1.0), vec![C::Maximized(true)]);
|
||||
let mut s = StartPlace::new(false);
|
||||
let big = Seen { size: Some([3000.0, 2000.0]), screen: Some([1920.0, 1080.0]), ..Default::default() };
|
||||
assert_eq!(s.step(&big, 0.0, 1.0), vec![C::InnerSize(egui::vec2(1728.0, 972.0))]);
|
||||
}
|
||||
|
||||
/// eframe clamps a remembered 1600 × 1000 window to a 1280 × 720 screen before it is first seen: the remembered
|
||||
/// size still has it fitted to 90 % of the screen, not left covering all of it (CodeRabbit on #2974).
|
||||
#[test]
|
||||
fn a_window_clamped_to_its_screen_before_it_shows_is_still_fitted() {
|
||||
use egui::ViewportCommand as C;
|
||||
let clamped = Seen { size: Some([1280.0, 720.0]), screen: Some([1280.0, 720.0]), ..Default::default() };
|
||||
let mut s = StartPlace::new(false).remembered(Some([1600.0, 1000.0]));
|
||||
assert_eq!(s.step(&clamped, 0.0, 1.0), vec![C::InnerSize(egui::vec2(1152.0, 648.0))]);
|
||||
// remembered within the screen: left as it is
|
||||
let mut s = StartPlace::new(false).remembered(Some([1200.0, 700.0]));
|
||||
assert!(s.step(&clamped, 0.0, 1.0).is_empty() && s.done());
|
||||
// nothing remembered: as before
|
||||
let mut s = StartPlace::new(false);
|
||||
assert!(s.step(&clamped, 0.0, 1.0).is_empty());
|
||||
}
|
||||
|
||||
/// A window kept hidden while it is being placed still ends the placement in time, and then stops asking to be
|
||||
/// looked at (CodeRabbit on #2974).
|
||||
#[test]
|
||||
fn placement_ends_in_time_while_the_window_is_hidden() {
|
||||
let mut s = StartPlace::new(true);
|
||||
s.idle(0.0);
|
||||
assert!(!s.done() && s.waits().is_some(), "still within its time");
|
||||
s.idle(PLACE_WITHIN_SECONDS + 0.1);
|
||||
assert!(s.done());
|
||||
assert_eq!(s.waits(), None);
|
||||
assert!(s.step(&window([1300.0, 800.0]), PLACE_WITHIN_SECONDS + 0.2, 1.0).is_empty());
|
||||
}
|
||||
@@ -54,13 +54,13 @@ every PR would edit and conflict on. A row marked ✅ that is wrong or incomplet
|
||||
| U. Map & location (MAP) | 0 | 1 | 1 | 0 | — | 0/1 (0%) |
|
||||
| V. Preferences (PREF) | 6 | 2 | 2 | 2 | 1/1 (100%) | 4/5 (80%) |
|
||||
| W. Cloud & AI infrastructure (CLOUD / AI) | 1 | 0 | 1 | 2 | — | — |
|
||||
| X. Cross-cutting behaviours (BEHAV) | 22 | 7 | 1 | 1 | 7/8 (88%) | 7/10 (70%) |
|
||||
| X. Cross-cutting behaviours (BEHAV) | 22 | 8 | 1 | 1 | 7/8 (88%) | 7/10 (70%) |
|
||||
| Y. Menus | 85 | 0 | 4 | 8 | 47/47 (100%) | 23/23 (100%) |
|
||||
| Z. Keyboard shortcuts (desktop) | 77 | 5 | 2 | 1 | 49/52 (94%) | 24/26 (92%) |
|
||||
| Lightroom Classic extras | 41 | 26 | 21 | 8 | — | 24/27 (89%) |
|
||||
| **Total** | 418 | 72 | 56 | 35 | 192/203 (95%) | 147/163 (90%) |
|
||||
| **Total** | 418 | 73 | 56 | 35 | 192/203 (95%) | 147/163 (90%) |
|
||||
|
||||
Weighted completion (✅ = 1, 🟡 = ½, 🚫 left out): **83.2%** of 546 in-scope rows — P0 97.3% of 203 · P1 94.2% of 163 · P2 57.0% of 179.
|
||||
Weighted completion (✅ = 1, 🟡 = ½, 🚫 left out): **83.1%** of 547 in-scope rows — P0 97.3% of 203 · P1 94.2% of 163 · P2 56.9% of 180.
|
||||
<!-- /parity:summary -->
|
||||
|
||||
## Top gaps and shortcut notes
|
||||
@@ -493,6 +493,7 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts).
|
||||
| LR-BEHAV-WHATSNEW | What's new | P2 | ✅ | `cmd:app.whatsNew`, `docs/whats-new.md` | Help ▸ What's New: release highlights |
|
||||
| LR-BEHAV-AI-EA | Early-access badges | P2 | ⬜ | | |
|
||||
| LR-BEHAV-TITLEBAR | Title bar drag and double-click zoom (macOS) | P2 | 🟡 | `crates/ui-egui/src/panels/topbar.rs`, `crates/ui-egui/src/tests/titlebar.rs` | the native title bar is hidden on macOS, so the top bar's empty space (including the traffic-light margin) moves the window and a double-click does what System Settings › “Double-click a window's title bar to” says (zoom or restore, minimize, nothing; craft-window's `title_bar`); buttons and the search field keep their clicks; ignored in full screen, where the traffic lights are gone and the bar's left buttons move into their space (#1763). A press that starts on a button, the search field or a panel floating over the bar never moves the window (AppKit's `movable` is off while the pointer is there). While a dialog is open the bar is not dimmed, so it stays level with the window buttons AppKit draws over it (as under a macOS sheet): its controls are inactive, a click on it does not close the dialog, and its empty space still moves the window; not on a window with its native title bar, nor in full screen. Known gap: egui-winit reads the zoomed state only at start-up and after our own `Maximized` command, so a window zoomed another way (green button, Window ▸ Zoom, snapping) makes the first double-click a no-op before the toggle catches up. Checked by hand on a real macOS window (drag, zoom, restore) |
|
||||
| LR-BEHAV-WINDOW | Window size and maximized state remembered | P2 | 🟡 | `crates/ui-egui/src/window_place.rs`, `apps/lightcraft/src/prefs.rs`, `apps/lightcraft/src/main.rs` | the window opens at the size it was left at, zoomed / maximized if it was; full screen and the place on the desktop are not remembered; Windows: a maximized window is built at its size and maximized once it shows (built maximized it could cover half the screen while Windows took it for maximized), and restored and maximized again once if it only says so; a window remembered larger than its screen is fitted to it. Not verified on several monitors with different scales on hardware |
|
||||
|
||||
## Y. Menus
|
||||
|
||||
@@ -830,6 +831,7 @@ Latin stays upright. Advanced Japanese composition remains open. Regression cove
|
||||
| 2026-10-28 | minor | LR-EDIT-OPTICS-PROFILE: lensfun's database offered once on the first launch and downloaded on request (Download / Not Now, Settings) (pinned, CC BY-SA, never bundled), the library looked up when it arrives or Enable Lens Corrections is ticked, the Optics panel names the profile or the lens without one; status unchanged (🟡) |
|
||||
| 2026-10-26 | minor | LR-BEHAV-PANEL-RESIZE, KEY-INFO: closing a tool panel (Crop, Remove, Masking, Red Eye) puts back the panel shown before it, hidden if it was hidden, at the same width and scroll position; a panel key or button (I, M, C, H…) pressed again puts back exactly what the right column showed before it (Edit → I → I = Edit, closed → I → I = closed); status unchanged (✅) |
|
||||
| 2026-10-25 | patch | LRC-LIB-KEYWORDS: a file whose keyword list is one `dc:subject` (or `lr:hierarchicalSubject`) entry with a keyword a line is read as one keyword a line; a library holding such a keyword is repaired when it opens (journaled, not an undo step); sidebar and Keyword List rows draw a name on one line; status unchanged |
|
||||
| 2026-10-25 | minor | LR-BEHAV-WINDOW (new row, 🟡): on Windows a window remembered maximized is built at its size and maximized once it shows (built maximized it could cover half the screen while Windows took it for maximized), and restored and maximized again once if it only says so; a window remembered larger than the screen it opens on is fitted to it, on every platform |
|
||||
| 2026-10-30 | patch | LR-BEHAV-ACCESS: the Flatpak manifests grant `--talk-name=org.a11y.Bus`, so AccessKit can find out whether a screen reader is running and publish the window inside the sandbox; packaging lint requires it in both manifests; status unchanged (🟡), not tried with Orca |
|
||||
| 2026-10-27 | patch | LR-LIB-LABEL, MENU-PHOTO-LABEL, KEY-LABELS: Clear Color Label (`photo.clearLabel`) is a command of its own, so Help → Keyboard Shortcuts can give it a key (#2980); the Photo ▸ Set Color Label ▸ None row runs it; status unchanged |
|
||||
| 2026-10-25 | minor | KEYC-METADATA, LRC-LIB-KEYWORDS: ⌘⌥⇧K / Ctrl+Alt+Shift+K (`dialog.keywordShortcut`, Set Keyword Shortcut) and ⇧K (`keyword.toggleShortcut`) add and remove the keyword shortcut's keywords; Keyword Shortcut leaves LRC-LIB-KEYWORDS' Not yet list; status counts unchanged (KEYC-METADATA stays 🟡) |
|
||||
|
||||
Reference in new issue
Block a user