mirror of
https://github.com/storytold/craft-launcher.git
synced 2026-11-12 05:03:07 +00:00
* fix(ui): the release notes card grows with its zoom (#594) The card's size limit now scales with notes_zoom, and sheet::size still holds it inside the window. Below 100% it keeps the usual size. * test(ui): the notes card's height follows the zoom too (#594) * test(ui): the notes card stays in the smallest window, and keeps its size below 100% (#594)
This commit is contained in:
1 parent
8c651be747
commit
651e392960
2 files changed
+73
-1
No files matched your search
@@ -115,7 +115,7 @@ impl LauncherUi {
|
||||
let Some(entry) = self.entry(id).cloned() else { return true };
|
||||
let Some(release) = entry.release().cloned() else { return true };
|
||||
let t = Tokens::get(ui.ctx());
|
||||
let size = crate::sheet::size(ui.ctx(), vec2(880.0, 760.0));
|
||||
let size = crate::sheet::size(ui.ctx(), vec2(880.0, 760.0) * self.notes_zoom.max(1.0));
|
||||
ui.set_width(size.x);
|
||||
ui.set_max_height(size.y);
|
||||
let date = release.published_at.map(|d| fmt(tl!("Released {date}"), &[("date", &crate::views::date_text(d))])).unwrap_or_default();
|
||||
|
||||
@@ -2784,6 +2784,78 @@ fn changelog_shortcuts_zoom_only_the_notes_text() {
|
||||
assert!(h.ctx.zoom_factor() > global, "main-UI keyboard zoom should still work after closing notes");
|
||||
}
|
||||
|
||||
#[test]
|
||||
/// The notes card grows with the zoomed text, stops at the window, and comes back on reset (#594).
|
||||
fn the_notes_card_follows_the_zoom_within_the_window() {
|
||||
let (mut h, _) = harness(ViewMode::Grid, egui::Theme::Dark, true);
|
||||
h.run_steps(4);
|
||||
h.get_by_label("More actions for PhotoCraft").click();
|
||||
h.run_steps(2);
|
||||
h.get_by_label("Release notes").click();
|
||||
h.run_steps(4);
|
||||
let span = |h: &Harness<'_, Option<LauncherUi>>| h.get_by_label("Close").rect().right() - h.get_by_label("Open on GitHub").rect().left();
|
||||
let usual = span(&h);
|
||||
for _ in 0..3 {
|
||||
h.key_press_modifiers(egui::Modifiers::COMMAND, egui::Key::Plus);
|
||||
h.run_steps(3);
|
||||
}
|
||||
assert!(span(&h) > usual * 1.2, "the card kept its width: {usual} -> {}", span(&h));
|
||||
for _ in 0..30 {
|
||||
h.key_press_modifiers(egui::Modifiers::COMMAND, egui::Key::Plus);
|
||||
h.run_steps(3);
|
||||
}
|
||||
let in_window = |h: &Harness<'_, Option<LauncherUi>>| {
|
||||
let window = h.ctx.content_rect();
|
||||
for label in ["Close", "Open on GitHub"] {
|
||||
assert!(window.contains_rect(h.get_by_label(label).rect()), "{label} left {window:?}");
|
||||
}
|
||||
};
|
||||
in_window(&h);
|
||||
// The launcher's smallest window.
|
||||
let full = h.ctx.content_rect().size();
|
||||
h.set_size(egui::vec2(720.0, 500.0));
|
||||
h.run_steps(3);
|
||||
in_window(&h);
|
||||
h.set_size(full);
|
||||
h.key_press_modifiers(egui::Modifiers::COMMAND, egui::Key::Num0);
|
||||
h.run_steps(3);
|
||||
assert!((span(&h) - usual).abs() < 0.5, "reset left the card at {}, was {usual}", span(&h));
|
||||
// Below 100% only the text shrinks.
|
||||
for _ in 0..3 {
|
||||
h.key_press_modifiers(egui::Modifiers::COMMAND, egui::Key::Minus);
|
||||
h.run_steps(3);
|
||||
}
|
||||
assert!((span(&h) - usual).abs() < 0.5, "zooming out left the card at {}, was {usual}", span(&h));
|
||||
}
|
||||
|
||||
#[test]
|
||||
/// Notes too long to fit take the zoom's extra height too (#594).
|
||||
fn long_notes_get_a_taller_card_when_zoomed() {
|
||||
let notes: String = (0..200).map(|n| format!("Line {n}\n\n")).collect();
|
||||
let mut ev = events();
|
||||
for e in &mut ev {
|
||||
if let Event::Latest { latest: LatestRelease::Found(r), .. } = e {
|
||||
r.notes.clone_from(¬es);
|
||||
}
|
||||
}
|
||||
let (mut h, _) = harness_with(ev, ViewMode::Grid, egui::Theme::Dark, true, 1.0);
|
||||
h.run_steps(4);
|
||||
h.get_by_label("More actions for PhotoCraft").click();
|
||||
h.run_steps(2);
|
||||
h.get_by_label("Release notes").click();
|
||||
h.run_steps(4);
|
||||
let bottom = |h: &Harness<'_, Option<LauncherUi>>| h.get_by_label("Close").rect().bottom();
|
||||
let usual = bottom(&h);
|
||||
for _ in 0..3 {
|
||||
h.key_press_modifiers(egui::Modifiers::COMMAND, egui::Key::Plus);
|
||||
h.run_steps(3);
|
||||
}
|
||||
assert!(bottom(&h) > usual + 60.0, "the card kept its height: {usual} -> {}", bottom(&h));
|
||||
h.key_press_modifiers(egui::Modifiers::COMMAND, egui::Key::Num0);
|
||||
h.run_steps(3);
|
||||
assert!((bottom(&h) - usual).abs() < 0.5, "reset left the card at {}, was {usual}", bottom(&h));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn command_m_minimizes_the_mac_window_only() {
|
||||
use artcraft_launcher_ui_egui::TitleBar;
|
||||
|
||||
Reference in new issue
Block a user