Replace expanding pack managers with compact searchable browsers
This commit is contained in:
parent
0f232ac4e8
commit
3d40d9c05e
|
|
@ -548,7 +548,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "canvas-pilot"
|
||||
version = "0.9.34"
|
||||
version = "0.9.35"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"craft-dwg",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ default-members = ["crates/canvas-pilot"]
|
|||
resolver = "3"
|
||||
|
||||
[workspace.package]
|
||||
version = "0.9.34"
|
||||
version = "0.9.35"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
repository = "https://proxy.dandaedre.com/gitea/idle-org/canvas-pilot"
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ mod input_ui;
|
|||
mod layers_ui;
|
||||
#[path = "menu_ui.rs"]
|
||||
mod menu_ui;
|
||||
#[path = "pack_browser_ui.rs"]
|
||||
mod pack_browser_ui;
|
||||
#[path = "preferences_ui.rs"]
|
||||
mod preferences_ui;
|
||||
#[path = "project_ui.rs"]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,347 @@
|
|||
//! Compact, session-only browsing shared by installed language and theme packs.
|
||||
use super::*;
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
struct Browser {
|
||||
query: String,
|
||||
selected: Option<String>,
|
||||
reveal: bool,
|
||||
}
|
||||
|
||||
pub(super) struct Row {
|
||||
pub id: String,
|
||||
pub summary: String,
|
||||
pub search: String,
|
||||
pub active: bool,
|
||||
}
|
||||
|
||||
pub(super) fn focus(ctx: &egui::Context, kind: &str, pack: &str) {
|
||||
ctx.data_mut(|data| {
|
||||
data.insert_temp(
|
||||
egui::Id::new(("pack-browser", kind)),
|
||||
Browser {
|
||||
query: String::new(),
|
||||
selected: Some(pack.into()),
|
||||
reveal: true,
|
||||
},
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
pub(super) fn show(
|
||||
ui: &mut egui::Ui,
|
||||
kind: &str,
|
||||
mut rows: Vec<Row>,
|
||||
details: impl FnOnce(&mut egui::Ui, &str, f32),
|
||||
) {
|
||||
let id = egui::Id::new(("pack-browser", kind));
|
||||
let mut state = ui
|
||||
.data(|data| data.get_temp::<Browser>(id))
|
||||
.unwrap_or_default();
|
||||
let previous_query = state.query.clone();
|
||||
let previous_selection = state.selected.clone();
|
||||
rows.sort_by(|a, b| a.id.cmp(&b.id));
|
||||
ui.horizontal(|ui| {
|
||||
ui.add(
|
||||
egui::TextEdit::singleline(&mut state.query)
|
||||
.id(id.with("search"))
|
||||
.hint_text("Search packs or contents…")
|
||||
.desired_width((ui.available_width() - 60.0).max(80.0)),
|
||||
);
|
||||
if ui
|
||||
.add_enabled(!state.query.is_empty(), egui::Button::new("Clear"))
|
||||
.clicked()
|
||||
{
|
||||
state.query.clear();
|
||||
}
|
||||
});
|
||||
let query = state.query.trim().to_lowercase();
|
||||
let filtered: Vec<_> = rows
|
||||
.iter()
|
||||
.filter(|row| {
|
||||
query.is_empty()
|
||||
|| row.search.to_lowercase().contains(&query)
|
||||
|| row.id.contains(&query)
|
||||
})
|
||||
.collect();
|
||||
ui.weak(format!(
|
||||
"{} of {} packs · select a pack to inspect its contents",
|
||||
filtered.len(),
|
||||
rows.len()
|
||||
));
|
||||
if !filtered
|
||||
.iter()
|
||||
.any(|row| state.selected.as_ref() == Some(&row.id))
|
||||
{
|
||||
state.selected = filtered
|
||||
.iter()
|
||||
.find(|row| row.active)
|
||||
.or_else(|| filtered.first())
|
||||
.map(|row| row.id.clone());
|
||||
}
|
||||
ui.spacing_mut().scroll = egui::style::ScrollStyle {
|
||||
bar_width: 10.0,
|
||||
foreground_color: true,
|
||||
..egui::style::ScrollStyle::solid()
|
||||
};
|
||||
let wide = ui.available_width() >= 460.0;
|
||||
let height = (ui.ctx().content_rect().height() - 330.0).clamp(180.0, 360.0);
|
||||
let reveal =
|
||||
state.reveal || previous_query != state.query || previous_selection != state.selected;
|
||||
let list = |ui: &mut egui::Ui, height: f32, selected: &mut Option<String>| {
|
||||
egui::ScrollArea::vertical()
|
||||
.id_salt(id.with("list"))
|
||||
.max_height(height)
|
||||
.auto_shrink([false, false])
|
||||
.show(ui, |ui| {
|
||||
if filtered.is_empty() {
|
||||
ui.weak(if rows.is_empty() {
|
||||
"No packs installed. Install a ZIP to get started."
|
||||
} else {
|
||||
"No matches. Try a name, pack ID or language code."
|
||||
});
|
||||
}
|
||||
ui.spacing_mut().item_spacing.y = 4.0;
|
||||
for row in &filtered {
|
||||
let title_size = egui::TextStyle::Body.resolve(ui.style()).size;
|
||||
let summary_size = egui::TextStyle::Small.resolve(ui.style()).size;
|
||||
let (_, rect) = ui.allocate_space(Vec2::new(
|
||||
ui.available_width(),
|
||||
(title_size + summary_size + 14.0).max(40.0),
|
||||
));
|
||||
let response = ui.interact(rect, id.with(&row.id), egui::Sense::click());
|
||||
response.widget_info(|| {
|
||||
egui::WidgetInfo::labeled(
|
||||
egui::WidgetType::Button,
|
||||
true,
|
||||
format!("{} · {}", row.id, row.summary),
|
||||
)
|
||||
});
|
||||
let chosen = selected.as_ref() == Some(&row.id);
|
||||
let visuals = ui.style().interact_selectable(&response, chosen);
|
||||
ui.painter().rect_filled(rect, 3.0, visuals.bg_fill);
|
||||
ui.painter()
|
||||
.rect_stroke(rect, 3.0, visuals.bg_stroke, StrokeKind::Inside);
|
||||
let title = format!("{}{}", if row.active { "● " } else { "" }, row.id);
|
||||
for (text, y, size, color) in [
|
||||
(title, 4.0, title_size, visuals.text_color()),
|
||||
(
|
||||
row.summary.clone(),
|
||||
title_size + 9.0,
|
||||
summary_size,
|
||||
visuals.text_color(),
|
||||
),
|
||||
] {
|
||||
let galley = egui::WidgetText::from(egui::RichText::new(text).size(size))
|
||||
.into_galley(
|
||||
ui,
|
||||
Some(egui::TextWrapMode::Truncate),
|
||||
rect.width() - 12.0,
|
||||
egui::TextStyle::Body,
|
||||
);
|
||||
ui.painter()
|
||||
.galley(rect.min + Vec2::new(6.0, y), galley, color);
|
||||
}
|
||||
if chosen && reveal {
|
||||
response.scroll_to_me(Some(egui::Align::Center));
|
||||
}
|
||||
if response
|
||||
.on_hover_text(format!(
|
||||
"{}\n{}{}",
|
||||
row.id,
|
||||
row.summary,
|
||||
if row.active { "\nIn use" } else { "" }
|
||||
))
|
||||
.clicked()
|
||||
{
|
||||
*selected = Some(row.id.clone());
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
if wide {
|
||||
let width = (ui.available_width() * 0.38).clamp(160.0, 240.0);
|
||||
ui.horizontal_top(|ui| {
|
||||
ui.set_height(height);
|
||||
ui.allocate_ui_with_layout(
|
||||
Vec2::new(width, height),
|
||||
egui::Layout::top_down(egui::Align::Min),
|
||||
|ui| list(ui, height, &mut state.selected),
|
||||
);
|
||||
ui.separator();
|
||||
ui.vertical(|ui| {
|
||||
ui.set_width(ui.available_width());
|
||||
if let Some(selected) = &state.selected {
|
||||
details(ui, selected, height);
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
list(ui, 110.0, &mut state.selected);
|
||||
ui.separator();
|
||||
if let Some(selected) = &state.selected {
|
||||
details(ui, selected, height.min(220.0));
|
||||
}
|
||||
}
|
||||
state.reveal = false;
|
||||
ui.data_mut(|data| data.insert_temp(id, state));
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
fn rows(count: usize) -> Vec<Row> {
|
||||
(0..count)
|
||||
.map(|i| Row {
|
||||
id: format!("pack-{i:03}"),
|
||||
summary: "16 themes · r2".into(),
|
||||
search: format!("Palette {i:03} 日本語"),
|
||||
active: i == 1,
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
#[test]
|
||||
fn row_selection_search_and_clear_work_with_pointer_and_keyboard() {
|
||||
let ctx = egui::Context::default();
|
||||
ctx.global_style_mut(|s| s.animation_time = 0.0);
|
||||
let id = egui::Id::new(("pack-browser", "themes"));
|
||||
let run = |events| {
|
||||
let mut selected = None;
|
||||
let output = ctx.run_ui(
|
||||
egui::RawInput {
|
||||
screen_rect: Some(Rect::from_min_size(Pos2::ZERO, Vec2::new(700.0, 720.0))),
|
||||
events,
|
||||
..Default::default()
|
||||
},
|
||||
|ui| {
|
||||
show(ui, "themes", rows(20), |_, pack, _| {
|
||||
selected = Some(pack.to_owned())
|
||||
})
|
||||
},
|
||||
);
|
||||
(selected, output)
|
||||
};
|
||||
run(vec![]);
|
||||
run(vec![]);
|
||||
let pos = ctx
|
||||
.read_response(id.with("pack-005"))
|
||||
.unwrap()
|
||||
.rect
|
||||
.center();
|
||||
run(vec![
|
||||
egui::Event::PointerMoved(pos),
|
||||
super::super::tests::mouse(pos, true),
|
||||
]);
|
||||
assert_eq!(
|
||||
run(vec![super::super::tests::mouse(pos, false)])
|
||||
.0
|
||||
.as_deref(),
|
||||
Some("pack-005")
|
||||
);
|
||||
ctx.memory_mut(|m| m.request_focus(id.with("search")));
|
||||
assert_eq!(
|
||||
run(vec![egui::Event::Text("Palette 019".into())])
|
||||
.0
|
||||
.as_deref(),
|
||||
Some("pack-019")
|
||||
);
|
||||
let output = run(vec![]).1;
|
||||
let clear = output
|
||||
.shapes
|
||||
.iter()
|
||||
.find_map(|s| match &s.shape {
|
||||
egui::Shape::Text(t) if t.galley.text() == "Clear" => {
|
||||
Some(t.pos + t.galley.size() / 2.0)
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.unwrap();
|
||||
run(vec![
|
||||
egui::Event::PointerMoved(clear),
|
||||
super::super::tests::mouse(clear, true),
|
||||
]);
|
||||
run(vec![super::super::tests::mouse(clear, false)]);
|
||||
assert!(
|
||||
ctx.data(|d| d.get_temp::<Browser>(id))
|
||||
.unwrap()
|
||||
.query
|
||||
.is_empty()
|
||||
);
|
||||
focus(&ctx, "themes", "pack-007");
|
||||
assert_eq!(run(vec![]).0.as_deref(), Some("pack-007"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn collections_stay_bounded_and_search_selects_contents_without_crossing_sections() {
|
||||
for width in [340.0, 700.0] {
|
||||
let ctx = egui::Context::default();
|
||||
ctx.global_style_mut(|s| s.animation_time = 0.0);
|
||||
let run = |kind, count| {
|
||||
let mut bounds = Rect::NOTHING;
|
||||
let mut selected = None;
|
||||
let _ = ctx.run_ui(
|
||||
egui::RawInput {
|
||||
screen_rect: Some(Rect::from_min_size(Pos2::ZERO, Vec2::new(width, 720.0))),
|
||||
..Default::default()
|
||||
},
|
||||
|ui| {
|
||||
ui.set_width(width - 20.0);
|
||||
show(ui, kind, rows(count), |ui, id, _| {
|
||||
selected = Some(id.to_owned());
|
||||
ui.label("Contents");
|
||||
});
|
||||
bounds = ui.min_rect();
|
||||
},
|
||||
);
|
||||
(bounds, selected)
|
||||
};
|
||||
let (small, selected) = run("themes", 2);
|
||||
assert_eq!(selected.as_deref(), Some("pack-001"));
|
||||
let (large, _) = run("themes", 200);
|
||||
assert!((small.height() - large.height()).abs() < 2.0);
|
||||
assert!(large.width() <= width);
|
||||
assert!(
|
||||
large.height() < 500.0,
|
||||
"width={width} small={small:?} large={large:?}"
|
||||
);
|
||||
let id = egui::Id::new(("pack-browser", "themes"));
|
||||
ctx.data_mut(|d| {
|
||||
d.insert_temp(
|
||||
id,
|
||||
Browser {
|
||||
query: "Palette 199".into(),
|
||||
selected: Some("pack-001".into()),
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
});
|
||||
assert_eq!(run("themes", 200).1.as_deref(), Some("pack-199"));
|
||||
assert_eq!(run("languages", 2).1.as_deref(), Some("pack-001"));
|
||||
ctx.data_mut(|d| {
|
||||
d.insert_temp(
|
||||
id,
|
||||
Browser {
|
||||
query: "missing".into(),
|
||||
selected: None,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
});
|
||||
assert!(run("themes", 200).1.is_none());
|
||||
ctx.data_mut(|d| {
|
||||
d.insert_temp(
|
||||
id,
|
||||
Browser {
|
||||
query: "日本語".into(),
|
||||
selected: Some("pack-199".into()),
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
});
|
||||
assert_eq!(run("themes", 200).1.as_deref(), Some("pack-199"));
|
||||
// Removal or update cannot leave details attached to a stale pack.
|
||||
assert_eq!(run("themes", 2).1.as_deref(), Some("pack-001"));
|
||||
assert!(run("themes", 0).1.is_none());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -189,10 +189,16 @@ impl Editor {
|
|||
Ok(pending) if pending.needs_confirmation() => {
|
||||
self.language_pack_action = Some(PackAction::Install(pending))
|
||||
}
|
||||
Ok(pending) => match crate::language_packs::commit(ctx, pending, false) {
|
||||
Ok(()) => self.refresh_pack_language(ctx, &previous),
|
||||
Err(error) => self.error = error,
|
||||
},
|
||||
Ok(pending) => {
|
||||
let id = pending.id().to_owned();
|
||||
match crate::language_packs::commit(ctx, pending, false) {
|
||||
Ok(()) => {
|
||||
super::pack_browser_ui::focus(ctx, "languages", &id);
|
||||
self.refresh_pack_language(ctx, &previous);
|
||||
}
|
||||
Err(error) => self.error = error,
|
||||
}
|
||||
}
|
||||
Err(error) => self.error = error,
|
||||
}
|
||||
}
|
||||
|
|
@ -207,29 +213,58 @@ impl Editor {
|
|||
{
|
||||
self.prepare_language_pack(&ctx, &path);
|
||||
}
|
||||
ui.weak("Choose a ZIP to install or update. Newer revisions update immediately; equal or older revisions ask before replacing.");
|
||||
let packs = crate::language_packs::installed(&ctx);
|
||||
if packs.is_empty() {
|
||||
ui.label("No language packs installed.");
|
||||
}
|
||||
for pack in packs {
|
||||
let rows = packs
|
||||
.iter()
|
||||
.map(|pack| super::pack_browser_ui::Row {
|
||||
id: pack.id.clone(),
|
||||
summary: format!("Languages: {} · r{}", pack.languages.len(), pack.revision),
|
||||
search: pack
|
||||
.languages
|
||||
.iter()
|
||||
.map(|l| format!("{} {} {}", l.locale, l.name, l.native_name))
|
||||
.collect::<Vec<_>>()
|
||||
.join(" "),
|
||||
active: pack
|
||||
.languages
|
||||
.iter()
|
||||
.any(|l| self.language == localization::Language::Pack(l.locale.clone())),
|
||||
})
|
||||
.collect();
|
||||
super::pack_browser_ui::show(ui, "languages", rows, |ui, id, height| {
|
||||
let pack = packs.iter().find(|p| p.id == id).unwrap();
|
||||
ui.label(egui::RichText::new(&pack.id).strong());
|
||||
ui.weak(format!(
|
||||
"Revision {} · Languages: {}",
|
||||
pack.revision,
|
||||
pack.languages.len()
|
||||
));
|
||||
if ui.button(tr(&ctx, "language.remove-pack")).clicked() {
|
||||
self.finish_language_preview(&ctx, false);
|
||||
self.language_pack_action = Some(PackAction::Remove(pack.clone()));
|
||||
}
|
||||
ui.separator();
|
||||
egui::CollapsingHeader::new(
|
||||
egui::RichText::new(format!("{} · revision {}", pack.id, pack.revision)).strong(),
|
||||
)
|
||||
.id_salt(("language-pack", &pack.id))
|
||||
.default_open(true)
|
||||
.show(ui, |ui| {
|
||||
for language in &pack.languages {
|
||||
ui.label(format!("{} — {}", language.native_name, language.name));
|
||||
}
|
||||
ui.add_space(4.0);
|
||||
if ui.button(tr(&ctx, "language.remove-pack")).clicked() {
|
||||
self.finish_language_preview(&ctx, false);
|
||||
self.language_pack_action = Some(PackAction::Remove(pack.clone()));
|
||||
}
|
||||
});
|
||||
}
|
||||
egui::ScrollArea::vertical()
|
||||
.id_salt(("pack-languages", id))
|
||||
.max_height((height - 90.0).max(80.0))
|
||||
.show(ui, |ui| {
|
||||
for language in &pack.languages {
|
||||
let choice = localization::Language::Pack(language.locale.clone());
|
||||
let label = format!("{} — {}", language.native_name, language.name);
|
||||
if ui
|
||||
.add(
|
||||
egui::Button::new(&label)
|
||||
.selected(self.language == choice)
|
||||
.wrap(),
|
||||
)
|
||||
.clicked()
|
||||
{
|
||||
self.preview_language(&ctx, choice);
|
||||
}
|
||||
ui.weak(&language.locale);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
fn refresh_pack_theme(&mut self, ctx: &egui::Context, was_available: bool) {
|
||||
|
|
@ -263,8 +298,12 @@ impl Editor {
|
|||
}
|
||||
Ok(pending) => {
|
||||
let was_available = theme::Theme::current(ctx).available(ctx);
|
||||
let id = pending.id().to_owned();
|
||||
match crate::theme_packs::commit(ctx, pending, false) {
|
||||
Ok(()) => self.refresh_pack_theme(ctx, was_available),
|
||||
Ok(()) => {
|
||||
super::pack_browser_ui::focus(ctx, "themes", &id);
|
||||
self.refresh_pack_theme(ctx, was_available);
|
||||
}
|
||||
Err(error) => self.error = error,
|
||||
}
|
||||
}
|
||||
|
|
@ -281,51 +320,78 @@ impl Editor {
|
|||
{
|
||||
self.prepare_theme_pack(&ctx, &path);
|
||||
}
|
||||
ui.weak("Choose a ZIP to install or update. Newer revisions update immediately; equal or older revisions ask before replacing.");
|
||||
let packs = crate::theme_packs::installed(&ctx);
|
||||
if packs.is_empty() {
|
||||
ui.label("No theme packs installed.");
|
||||
}
|
||||
for pack in packs {
|
||||
let current = theme::Theme::current(&ctx);
|
||||
let rows = packs
|
||||
.iter()
|
||||
.map(|pack| super::pack_browser_ui::Row {
|
||||
id: pack.id.clone(),
|
||||
summary: format!("Themes: {} · r{}", pack.themes.len(), pack.revision),
|
||||
search: pack
|
||||
.themes
|
||||
.iter()
|
||||
.map(|t| format!("{} {}", t.id, t.name))
|
||||
.collect::<Vec<_>>()
|
||||
.join(" "),
|
||||
active: pack
|
||||
.themes
|
||||
.iter()
|
||||
.any(|t| current == theme::Theme::Pack(format!("{}/{}", pack.id, t.id))),
|
||||
})
|
||||
.collect();
|
||||
super::pack_browser_ui::show(ui, "themes", rows, |ui, id, height| {
|
||||
let pack = packs.iter().find(|p| p.id == id).unwrap();
|
||||
ui.label(egui::RichText::new(&pack.id).strong());
|
||||
ui.weak(format!(
|
||||
"Revision {} · Themes: {}",
|
||||
pack.revision,
|
||||
pack.themes.len()
|
||||
));
|
||||
if ui.button(tr(&ctx, "language.remove-pack")).clicked() {
|
||||
self.language_pack_action = Some(PackAction::RemoveTheme(pack.clone()));
|
||||
}
|
||||
ui.separator();
|
||||
egui::CollapsingHeader::new(
|
||||
egui::RichText::new(format!("{} · revision {}", pack.id, pack.revision)).strong(),
|
||||
)
|
||||
.id_salt(("theme-pack", &pack.id))
|
||||
.default_open(true)
|
||||
.show(ui, |ui| {
|
||||
for entry in &pack.themes {
|
||||
let choice = theme::Theme::Pack(format!("{}/{}", pack.id, entry.id));
|
||||
ui.horizontal(|ui| {
|
||||
egui::ScrollArea::vertical()
|
||||
.id_salt(("pack-themes", id))
|
||||
.max_height((height - 90.0).max(80.0))
|
||||
.show(ui, |ui| {
|
||||
for entry in &pack.themes {
|
||||
let choice = theme::Theme::Pack(format!("{}/{}", pack.id, entry.id));
|
||||
let palette = choice.resolved_palette(&ctx);
|
||||
for color in [palette.bg, palette.layer, palette.cyan] {
|
||||
let (rect, _) =
|
||||
ui.allocate_exact_size(Vec2::splat(10.0), egui::Sense::hover());
|
||||
ui.painter().rect_filled(rect, 2.0, color);
|
||||
}
|
||||
if ui
|
||||
.stable_selectable_label(
|
||||
choice == theme::Theme::current(&ctx),
|
||||
&entry.name,
|
||||
)
|
||||
.clicked()
|
||||
{
|
||||
choice.select(&ctx);
|
||||
}
|
||||
});
|
||||
}
|
||||
if !pack.notices.is_empty() {
|
||||
egui::CollapsingHeader::new("Attribution and licenses")
|
||||
.id_salt(("theme-notices", &pack.id))
|
||||
.show(ui, |ui| {
|
||||
ui.label(&pack.notices);
|
||||
ui.horizontal(|ui| {
|
||||
for color in [palette.bg, palette.layer, palette.cyan] {
|
||||
let (rect, _) =
|
||||
ui.allocate_exact_size(Vec2::splat(12.0), egui::Sense::hover());
|
||||
ui.painter().rect_filled(rect, 2.0, color);
|
||||
}
|
||||
if ui
|
||||
.add(
|
||||
egui::Button::new(&entry.name)
|
||||
.selected(choice == theme::Theme::current(&ctx))
|
||||
.wrap(),
|
||||
)
|
||||
.clicked()
|
||||
{
|
||||
choice.select(&ctx);
|
||||
}
|
||||
});
|
||||
}
|
||||
if ui.button(tr(&ctx, "language.remove-pack")).clicked() {
|
||||
self.language_pack_action = Some(PackAction::RemoveTheme(pack.clone()));
|
||||
}
|
||||
});
|
||||
}
|
||||
ui.weak(if choice == theme::Theme::current(&ctx) {
|
||||
"In use"
|
||||
} else if entry.light {
|
||||
"Light"
|
||||
} else {
|
||||
"Dark"
|
||||
});
|
||||
}
|
||||
if !pack.notices.is_empty() {
|
||||
egui::CollapsingHeader::new("Attribution and licenses")
|
||||
.id_salt(("theme-notices", id))
|
||||
.show(ui, |ui| {
|
||||
ui.label(&pack.notices);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
pub(super) fn language_pack_confirmation(&mut self, ctx: &egui::Context) {
|
||||
|
|
@ -373,12 +439,22 @@ impl Editor {
|
|||
self.language_pack_action,
|
||||
Some(PackAction::InstallTheme(_) | PackAction::RemoveTheme(_))
|
||||
);
|
||||
let focus = match self.language_pack_action.as_ref() {
|
||||
Some(PackAction::Install(pack)) => Some(("languages", pack.id().to_owned())),
|
||||
Some(PackAction::InstallTheme(pack)) => Some(("themes", pack.id().to_owned())),
|
||||
_ => None,
|
||||
};
|
||||
let result = match self.language_pack_action.take().unwrap() {
|
||||
PackAction::Install(pack) => crate::language_packs::commit(ctx, pack, true),
|
||||
PackAction::Remove(pack) => crate::language_packs::remove(ctx, &pack),
|
||||
PackAction::InstallTheme(pack) => crate::theme_packs::commit(ctx, pack, true),
|
||||
PackAction::RemoveTheme(pack) => crate::theme_packs::remove(ctx, &pack),
|
||||
};
|
||||
if result.is_ok()
|
||||
&& let Some((kind, id)) = focus
|
||||
{
|
||||
super::pack_browser_ui::focus(ctx, kind, &id);
|
||||
}
|
||||
match result {
|
||||
Ok(()) if theme_action => self.refresh_pack_theme(ctx, theme_was_available),
|
||||
Ok(()) => self.refresh_pack_language(ctx, &previous),
|
||||
|
|
@ -681,7 +757,8 @@ mod tests {
|
|||
std::fs::write(&source, manager_pack(1, "test-manager")).unwrap();
|
||||
app.prepare_language_pack(&ctx, &source);
|
||||
assert!(app.language_pack_action.is_none());
|
||||
app.preview_language(&ctx, localization::Language::Pack("test-manager".into()));
|
||||
click_label(&mut app, &ctx, "Manager test — Manager test");
|
||||
assert!(app.language_preview.is_some());
|
||||
app.finish_language_preview(&ctx, true);
|
||||
std::fs::write(&source, manager_pack(2, "test-manager")).unwrap();
|
||||
app.prepare_language_pack(&ctx, &source);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,14 @@
|
|||
|
||||
## Unreleased
|
||||
|
||||
### v0.9.35
|
||||
|
||||
- Replaced expanding theme/language pack stacks with a searchable pack browser:
|
||||
bounded collection list, one selected pack's details, in-use indicators, counts
|
||||
and revisions. Search includes pack contents; narrow windows stack the panes.
|
||||
- Kept live theme switching, language confirmation, overwrite review and removal
|
||||
safeguards. Pack browsing is session-only and changes no archive/settings schema.
|
||||
|
||||
## Release v0.9.34 — 2026-11-17
|
||||
|
||||
### v0.9.34
|
||||
|
|
|
|||
|
|
@ -25,9 +25,17 @@ These packs reuse the fonts already bundled with Canvas Pilot. Version 1 and 2 p
|
|||
contain translations only: they neither install fonts nor reduce the current
|
||||
application download size. Ukrainian uses the existing Cyrillic coverage.
|
||||
|
||||
Installed packs appear under bold, collapsible headings showing the pack ID and
|
||||
revision. Click a heading or its arrow to hide or show the indented language list
|
||||
and **Remove pack…** action. Packs start expanded.
|
||||
Installed packs appear in a compact, searchable list. Search by pack ID, language
|
||||
name, native name or locale code; **Clear** restores the full list. Each row shows
|
||||
the language count and revision, with a dot marking the pack currently in use.
|
||||
Only the selected pack's contents are shown, beside the list on wide windows or
|
||||
below it on narrow windows. Both lists stay bounded and scroll independently.
|
||||
|
||||
Click a language in the selected pack to preview it with the same 20-second
|
||||
confirmation and rollback as the main language picker. **Remove pack…** stays
|
||||
above the contents and still asks for confirmation. Newly installed or updated packs are selected automatically.
|
||||
Search and selection remain
|
||||
separate from the theme manager and are remembered only during the session.
|
||||
|
||||
## Make your own pack
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ device transfers, imported pictures, fonts or interface size.
|
|||
## Install and try the examples
|
||||
|
||||
Download a ZIP, leave it zipped, then open **Settings → Theme packs → Install theme
|
||||
pack…**. Click a theme beneath its pack heading to try it immediately. It also
|
||||
pack…**. Select a pack, then click one of its themes to try it immediately. It also
|
||||
appears in **More themes…** and recent themes. The picker stays open while you
|
||||
try alternatives. Selecting **High Contrast** twice returns to your last theme,
|
||||
including an installed one.
|
||||
|
|
@ -27,9 +27,17 @@ they include no game artwork, fonts or code and are not endorsed by the games' o
|
|||
|
||||
## Manage packs
|
||||
|
||||
Each pack has a bold, collapsible heading with its ID and revision. Expand it to
|
||||
see theme swatches, select a theme, read its attribution or choose **Remove pack…**.
|
||||
Packs start expanded. Theme changes save immediately and survive restart.
|
||||
The manager uses a compact, searchable pack list and shows the contents of only
|
||||
one selected pack. Search by pack ID or theme name; **Clear** restores the full
|
||||
list. Rows show the theme count and revision, with a dot marking packs currently
|
||||
in use. Large collections scroll within the list instead of stretching Settings.
|
||||
|
||||
Select a pack to see its theme swatches, light/dark labels, attribution and
|
||||
**Remove pack…** action. The contents and license text scroll independently;
|
||||
removal stays above them. On narrower windows, details appear below the list.
|
||||
Newly installed or updated packs are selected automatically.
|
||||
Search and selection are remembered during the session, separately from language
|
||||
packs. Theme changes save immediately and survive restart.
|
||||
|
||||
Install a newer revision of the same pack to update it immediately. Equal or older
|
||||
revisions ask before replacing the installed copy. Updating an active theme refreshes
|
||||
|
|
|
|||
Loading…
Reference in New Issue