diff --git a/crates/summit-gui/src/main.rs b/crates/summit-gui/src/main.rs index 12ab5d7..26e3c52 100644 --- a/crates/summit-gui/src/main.rs +++ b/crates/summit-gui/src/main.rs @@ -70,7 +70,7 @@ impl App { source: data::source_label(e.source).into(), kind: data::kind_label(e.kind).into(), installed: e.installed, pinned: self.state.borrow().is_pinned(&e.id), cover: keep.map(|g| g.cover.clone()).unwrap_or_default(), has_cover: keep.map_or(false, |g| g.has_cover), - c1: rgb(c1), c2: rgb(c2), reasons: e.reasons.join(" · ").into(), action: action.into(), + c1: rgb(c1), c2: rgb(c2), reasons: short(&e.reasons.join(" · ")).into(), action: action.into(), } } @@ -187,10 +187,10 @@ impl App { launch::Plan::Run(_) => ("PLAY", true, "Summit starts it, applies the launch profile and tracks the session.".to_string()), launch::Plan::Unsupported(why) => ("PLAY", false, format!("Summit cannot start this yet: {why}.")), }; - let reasons: Vec = e.reasons.iter().map(|r| r.as_str().into()).collect(); + let reasons: Vec = e.reasons.iter().map(|r| short(r).into()).collect(); self.ui.global::().set_detail(Detail { idx, sessions: sessions.into(), sessions_note: note.into(), reasons: ModelRc::new(VecModel::from(reasons)), - path: e.path.clone().unwrap_or_default().into(), + path: short(&e.path.clone().unwrap_or_default()).into(), monitor: p.monitor.into(), mode: p.mode.into(), upscaler: p.upscaler.into(), framegen: p.framegen.into(), window: p.window.into(), profile_set: p.set, play_label: label.into(), play_note: play_note.into(), can_play: can, }); @@ -327,9 +327,10 @@ impl App { fn nearest(all: &[f32], v: f32) -> usize { (0..all.len()).min_by(|a, b| (all[*a] - v).abs().total_cmp(&(all[*b] - v).abs())).unwrap_or(0) } -fn tilde(p: &std::path::Path) -> String { - let s = p.to_string_lossy().into_owned(); - match std::env::var("HOME") { Ok(h) if !h.is_empty() && s.starts_with(&h) => format!("~{}", &s[h.len()..]), _ => s } +fn tilde(p: &std::path::Path) -> String { short(&p.to_string_lossy()) } +/// Paths under the home folder read better as ~/...; detection reasons are full of them. +fn short(text: &str) -> String { + match std::env::var("HOME") { Ok(h) if h.len() > 1 => text.replace(&format!("{h}/"), "~/"), _ => text.to_string() } } /// Look a name up in a list ("grid", "violet") or take a number. diff --git a/crates/summit-gui/ui/library.slint b/crates/summit-gui/ui/library.slint index b8a913e..c2f1b71 100644 --- a/crates/summit-gui/ui/library.slint +++ b/crates/summit-gui/ui/library.slint @@ -249,10 +249,9 @@ export component UnfilteredView inherits Rectangle { border-width: focused ? 2px : 0px; border-color: Theme.p.focus; animate background { duration: Theme.ms(120); } Rectangle { x: 12px; y: 14px; width: 4px; height: 24px; border-radius: 2px; background: g.c1; } - Text { x: 28px; y: 8px; width: parent.width - 28px - 220px; text: g.title; color: Theme.p.text; font-size: Theme.t-md - 1px; font-weight: 600; overflow: elide; } - Text { x: 28px; y: 29px; width: parent.width - 28px - 220px; text: g.reasons; color: Theme.p.dim; font-size: Theme.t-sm - 1px; overflow: elide; } - Text { x: parent.width - 200px; width: 100px; height: parent.height; horizontal-alignment: right; vertical-alignment: center; text: g.hours-short == "" ? "Not played" : g.hours-short; color: g.hours-short == "" ? Theme.p.faint : Theme.p.text; font-size: Theme.t-sm; font-weight: 600; } - Text { x: parent.width - 84px; width: 72px; height: parent.height; horizontal-alignment: right; vertical-alignment: center; text: g.kind; color: Theme.p.faint; font-size: Theme.t-xs; font-weight: 700; letter-spacing: 0.8px; } + Text { x: 28px; y: 8px; width: parent.width - 28px - 160px; text: g.title; color: Theme.p.text; font-size: Theme.t-md - 1px; font-weight: 600; overflow: elide; } + Text { x: 28px; y: 29px; width: parent.width - 28px - 160px; text: g.reasons; color: Theme.p.dim; font-size: Theme.t-sm - 1px; overflow: elide; } + Text { x: parent.width - 132px; width: 116px; height: parent.height; horizontal-alignment: right; vertical-alignment: center; text: g.hours-short == "" ? "Not played" : g.hours-short; color: g.hours-short == "" ? Theme.p.faint : Theme.p.text; font-size: Theme.t-sm; font-weight: 600; } ta := TouchArea { mouse-cursor: pointer; clicked => { if (root.sel == i) { Lib.open-detail(r.idx); } else { root.sel = i; } } } } } diff --git a/crates/summit-gui/ui/settings.slint b/crates/summit-gui/ui/settings.slint index 5b21d0d..04974bc 100644 --- a/crates/summit-gui/ui/settings.slint +++ b/crates/summit-gui/ui/settings.slint @@ -46,7 +46,7 @@ export component SettingsView inherits Rectangle { in-out property srow: 0; callback exit-up(); property cw: Math.min(root.width - 2 * Theme.pad, 1040px); - property cx: Theme.pad; + property cx: Math.max(Theme.pad, (root.width - root.cw) / 2); pure function ry(i: int) -> length { return i == 0 ? 136px : i == 1 ? 216px : i == 2 ? 384px : i == 3 ? 520px : i == 4 ? 600px : i == 5 ? 736px : i == 6 ? 816px : i == 7 ? 952px : 1032px; }