Skip to content
Open
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
4 changes: 3 additions & 1 deletion crates/ui-egui/src/dialogs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1787,7 +1787,9 @@ fn export_apple_photos_rows(ui: &mut egui::Ui, t: &Tokens, opts: &mut ExportOpti
)
});
ui.label(
egui::RichText::new(crate::i18n::tr("The first time, macOS asks whether LightCraft may control Photos.")).size(11.0).color(t.text_dim),
egui::RichText::new(crate::i18n::tr("The first time, macOS asks whether LightCraft may control Photos."))
.font(t.caption())
.color(t.text_dim),
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/ui-egui/src/dialogs/keymap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn body(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens) {
d.insert_temp(search_id, search.clone());
d.insert_temp(all_id, show_all);
});
ui.label(RichText::new(crate::i18n::tr("Click a shortcut, then press the new keys (Esc cancels).")).size(11.0).color(t.text_dim));
ui.label(RichText::new(crate::i18n::tr("Click a shortcut, then press the new keys (Esc cancels).")).font(t.caption()).color(t.text_dim));
ui.add_space(4.0);

let needle = search.trim().to_lowercase();
Expand Down
2 changes: 1 addition & 1 deletion crates/ui-egui/src/dialogs/settings/appearance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fn theme_card<V: PartialEq + Copy>(ui: &mut egui::Ui, t: &Tokens, card: ThemeCar
ui.horizontal(|ui| {
ui.label(RichText::new(crate::i18n::tr(title)).font(t.semibold(12.0)).color(t.text));
if active {
ui.label(RichText::new(crate::i18n::tr("In Use")).size(11.0).color(t.accent));
ui.label(RichText::new(crate::i18n::tr("In Use")).font(t.caption()).color(t.accent));
}
});
let shown = options.iter().find(|(v, _)| v == value).or(options.first()).map(|(_, k)| *k).unwrap_or_default();
Expand Down
6 changes: 3 additions & 3 deletions crates/ui-egui/src/dialogs/settings/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ pub(super) fn display_tab(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens
}
});
if let Some(e) = &app.display_error {
ui.label(RichText::new(e).size(11.0).color(t.reject));
ui.label(RichText::new(e).font(t.caption()).color(t.reject));
}
if let Some(d) = &current {
let info = d.describe();
if !screen {
row(ui, t, crate::i18n::tr("File"), |ui| {
path_label(ui, "settingsDisplayFile", &d.path, egui::FontId::proportional(11.0), t.text_dim, 0.0);
path_label(ui, "settingsDisplayFile", &d.path, t.caption(), t.text_dim, 0.0);
});
}
row(ui, t, crate::i18n::tr("Type"), |ui| {
Expand All @@ -61,7 +61,7 @@ pub(super) fn display_tab(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens
let p = &info["primaries"];
let xy = |(k, l): (&str, &str)| format!("{l} {:.3}, {:.3}", p[k][0].as_f64().unwrap_or(0.0), p[k][1].as_f64().unwrap_or(0.0));
let text = [("red", "R"), ("green", "G"), ("blue", "B")].map(xy).join(" ");
ui.label(RichText::new(text).size(11.0).color(t.text_dim));
ui.label(RichText::new(text).font(t.caption()).color(t.text_dim));
});
}
hint(
Expand Down
2 changes: 1 addition & 1 deletion crates/ui-egui/src/dialogs/settings/performance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub(super) fn performance_tab(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &To
// One line, the whole text on hover: the reason can be a long driver message (no adapter
// among the backends …), and the GPU state is process-wide, so it may change between frames;
// a hint that wrapped would move every control below it under the pointer.
ui.add(egui::Label::new(RichText::new(crate::i18n::tr(&status)).size(11.0).color(t.text_dim)).truncate()).on_hover_text(&status);
ui.add(egui::Label::new(RichText::new(crate::i18n::tr(&status)).font(t.caption()).color(t.text_dim)).truncate()).on_hover_text(&status);
row(ui, t, crate::i18n::tr("Preview size"), |ui| {
let opts: Vec<(u32, String)> =
PREVIEW_LIMITS.iter().map(|e| (*e, if *e == 0 { crate::i18n::tr("Automatic").to_string() } else { format!("{e} px") })).collect();
Expand Down
2 changes: 1 addition & 1 deletion crates/ui-egui/src/dialogs/settings/slide_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ pub fn preview(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens, max_h: f3
if !tpl.description.is_empty() {
said = format!("{said}\n{}", tpl.description);
}
let galley = ui.painter().layout(said, t.font(11.0), Color32::WHITE, (room.width() - 8.0).max(1.0));
let galley = ui.painter().layout(said, t.caption(), Color32::WHITE, (room.width() - 8.0).max(1.0));
let band = Rect::from_min_size(
pos2(room.left(), (room.bottom() - galley.size().y - 6.0).max(room.top())),
vec2(room.width(), galley.size().y + 6.0),
Expand Down
2 changes: 1 addition & 1 deletion crates/ui-egui/src/dialogs/settings/slide_overlays.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,6 @@ pub fn sections(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens) {
hint(ui, t, "The export watermark, drawn on the photo and sized relative to it.");
}
for warning in app.session.slide_overlays.warnings() {
ui.label(RichText::new(warning).size(11.0).color(t.caution));
ui.label(RichText::new(warning).font(t.caption()).color(t.caution));
}
}
6 changes: 3 additions & 3 deletions crates/ui-egui/src/dialogs/settings/slide_templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ fn menu(app: &mut LightcraftApp, ui: &mut egui::Ui, tpl: &Template, name: &str)
/// A group heading inside the browser.
fn group(ui: &mut egui::Ui, t: &Tokens, text: &str) {
ui.add_space(2.0);
ui.label(RichText::new(crate::i18n::tr(text)).size(11.0).color(t.text_dim));
ui.label(RichText::new(crate::i18n::tr(text)).font(t.caption()).color(t.text_dim));
}

/// The Templates section.
Expand Down Expand Up @@ -265,10 +265,10 @@ pub fn section(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens) {
}
// files that couldn't be read
for p in listing.problems.iter().take(4) {
ui.label(RichText::new(crate::i18n::tr_format!("Skipped {problem}", problem = p)).size(11.0).color(t.caution));
ui.label(RichText::new(crate::i18n::tr_format!("Skipped {problem}", problem = p)).font(t.caption()).color(t.caution));
}
if listing.problems.len() > 4 {
let more = listing.problems.len() - 4;
ui.label(RichText::new(crate::i18n::tr_format!("…and {more} more", more = more)).size(11.0).color(t.caution));
ui.label(RichText::new(crate::i18n::tr_format!("…and {more} more", more = more)).font(t.caption()).color(t.caution));
}
}
2 changes: 1 addition & 1 deletion crates/ui-egui/src/dialogs/settings/slide_titles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,6 @@ pub fn sections(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens) {
);
let warnings = s.warnings(&app.session.slide_overlays);
for w in warnings {
ui.label(egui::RichText::new(w).size(11.0).color(t.caution));
ui.label(egui::RichText::new(w).font(t.caption()).color(t.caution));
}
}
2 changes: 1 addition & 1 deletion crates/ui-egui/src/dialogs/settings/widgets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub(crate) fn row<R>(ui: &mut egui::Ui, t: &Tokens, label: &str, add: impl FnOnc
}

pub(crate) fn hint(ui: &mut egui::Ui, t: &Tokens, text: &str) {
ui.label(RichText::new(crate::i18n::tr(text)).size(11.0).color(t.text_dim));
ui.label(RichText::new(crate::i18n::tr(text)).font(t.caption()).color(t.text_dim));
}

/// A checkbox addressable as `check:{id}`; true when toggled.
Expand Down
2 changes: 1 addition & 1 deletion crates/ui-egui/src/panels/denoise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ pub fn detail_status(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId, am
let state = app.session.denoise_photo_state(id);
let pad = egui::Margin { left: 24, right: 22, top: 0, bottom: 6 };
let note = |ui: &mut egui::Ui, text: &str, color: egui::Color32| {
ui.add(egui::Label::new(RichText::new(crate::i18n::tr(text)).size(11.0).color(color)).wrap());
ui.add(egui::Label::new(RichText::new(crate::i18n::tr(text)).font(t.caption()).color(color)).wrap());
};
match state {
PhotoState::NotApplicable | PhotoState::Ready => {}
Expand Down
4 changes: 2 additions & 2 deletions crates/ui-egui/src/panels/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {
if app.session.auto_sync && n > 1 {
egui::Frame::NONE.inner_margin(egui::Margin { left: 24, right: 22, top: 0, bottom: 10 }).show(ui, |ui| {
ui.horizontal(|ui| {
ui.label(egui::RichText::new(crate::i18n::tr_format!("Auto Sync: edits apply to {n} photos", n = n)).color(t.accent).size(12.0));
ui.label(egui::RichText::new(crate::i18n::tr_format!("Auto Sync: edits apply to {n} photos", n = n)).color(t.accent).font(t.label()));
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
if text_button(ui, "autoSyncOff", crate::i18n::tr("Turn Off"), false).clicked() {
let _ = app.run("develop.autoSync", json!({"on": false}));
Expand Down Expand Up @@ -339,7 +339,7 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {
if lp && let Some(p) = app.session.catalog.photo(id).cloned() {
let text = crate::lens_db::readout(app, &p);
if !text.is_empty() {
let r = ui.label(egui::RichText::new(text).size(11.0).color(Tokens::get(ui.ctx()).text_dim));
let r = ui.label(egui::RichText::new(text).font(t.caption()).color(Tokens::get(ui.ctx()).text_dim));
crate::widgets::register(ui, "optics:lensProfile", r.rect);
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/ui-egui/src/panels/edit/mixer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ pub(super) fn point_color(app: &mut LightcraftApp, ui: &mut egui::Ui, d: &Develo
});
if n == 0 {
egui::Frame::NONE.inner_margin(egui::Margin { left: 24, right: 22, top: 2, bottom: 8 }).show(ui, |ui| {
ui.label(egui::RichText::new(crate::i18n::tr("Pick a colour on the photo with the eyedropper.")).size(12.0).color(t.text_dim));
ui.label(egui::RichText::new(crate::i18n::tr("Pick a colour on the photo with the eyedropper.")).font(t.label()).color(t.text_dim));
});
return;
}
Expand Down
2 changes: 1 addition & 1 deletion crates/ui-egui/src/panels/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,7 @@ fn folder_breadcrumbs(app: &mut LightcraftApp, ui: &mut egui::Ui, path: &str) {
let last = remaining == 1;
// Share the bounded row among the remaining crumbs, leaving room for every separator.
let width = ((ui.available_width() - separator_w * (remaining - 1) as f32) / remaining as f32).max(0.0).floor();
let text = egui::RichText::new(*part).size(13.0).color(if last { t.text } else { t.text_label });
let text = egui::RichText::new(*part).font(t.body()).color(if last { t.text } else { t.text_label });
let r = ui.add_sized(vec2(width, 24.0), egui::Label::new(if last { text.strong() } else { text }).truncate().sense(Sense::click()));
register(ui, format!("crumb:{i}"), r.rect);
if !last {
Expand Down
6 changes: 3 additions & 3 deletions crates/ui-egui/src/panels/mask_effects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ pub fn save_body(
ui.label(
egui::RichText::new(crate::i18n::tr("Highlighted: sliders this mask changes. Sliders left out stay as they are when the preset is applied."))
.color(t.text_dim)
.size(11.0),
.font(t.caption()),
);
let r = ui.checkbox(amount, crate::i18n::tr("Include Amount"));
register(ui, "check:effectAmount", r.rect);
Expand Down Expand Up @@ -575,7 +575,7 @@ pub fn manage_body(
if !e.extra.is_empty() {
info += &crate::i18n::tr_format!(" · kept, not applied: {}", e.extra.keys().cloned().collect::<Vec<_>>().join(", "));
}
ui.add(egui::Label::new(egui::RichText::new(info).color(t.text_dim).size(11.0)).truncate());
ui.add(egui::Label::new(egui::RichText::new(info).color(t.text_dim).font(t.caption())).truncate());
});
}
}
Expand Down Expand Up @@ -679,7 +679,7 @@ pub fn manage_body(
}
});
if mask.is_none() {
ui.label(egui::RichText::new(crate::i18n::tr("Select a mask to apply or update presets.")).color(t.text_dim).size(11.0));
ui.label(egui::RichText::new(crate::i18n::tr("Select a mask to apply or update presets.")).color(t.text_dim).font(t.caption()));
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/ui-egui/src/panels/masking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ fn range_controls(app: &mut LightcraftApp, ui: &mut egui::Ui, comp: usize, shape
}
app.run("mask.update", json!({"component": comp, "shape": s}))
});
ui.label(egui::RichText::new(crate::i18n::tr("− harder border · + softer border")).color(t.text_dim).size(11.0));
ui.label(egui::RichText::new(crate::i18n::tr("− harder border · + softer border")).color(t.text_dim).font(t.caption()));
}
MaskShape::ColorRange { samples, refine } => {
ui.horizontal(|ui| {
Expand Down
2 changes: 1 addition & 1 deletion crates/ui-egui/src/panels/right/crop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ pub(super) fn crop(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {
"{} of 4 guides — drag along lines that should be vertical or horizontal.",
d.geometry.guides.len()
))
.size(11.0)
.font(Tokens::get(ui.ctx()).caption())
.color(Tokens::get(ui.ctx()).text_dim),
);
}
Expand Down
8 changes: 4 additions & 4 deletions crates/ui-egui/src/panels/right/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ pub(super) fn info(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {
lightcraft_catalog::Source::File { path } => path.clone(),
lightcraft_catalog::Source::Demo { .. } => crate::i18n::tr("Generated demo photo").into(),
};
ui.add(egui::Label::new(egui::RichText::new(path).size(12.0).color(t.text_label)).truncate());
ui.add(egui::Label::new(egui::RichText::new(path).font(t.label()).color(t.text_label)).truncate());
if crate::menus::ui_enabled(app, "app.showInFinder") {
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
if crate::widgets::icon_button(ui, "infoReveal", Icon::Folder, vec2(20.0, 20.0), false, true, crate::menus::reveal_label())
Expand Down Expand Up @@ -159,7 +159,7 @@ pub(super) fn info(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {
if let Some((la, lo)) = m.gps.filter(|_| !gps_mixed) {
let pretty = format!("{:.5}° {}, {:.5}° {}", la.abs(), if la >= 0.0 { "N" } else { "S" }, lo.abs(), if lo >= 0.0 { "E" } else { "W" });
ui.horizontal(|ui| {
ui.label(egui::RichText::new(pretty).size(11.0).color(t.text_dim));
ui.label(egui::RichText::new(pretty).font(t.caption()).color(t.text_dim));
if text_button(ui, "showOnMap", crate::i18n::tr("Show on Map"), false)
.on_hover_text(crate::i18n::tr("Open the place in OpenStreetMap"))
.clicked()
Expand Down Expand Up @@ -230,7 +230,7 @@ fn camera_card(ui: &mut egui::Ui, p: &lightcraft_catalog::Photo) {
let m = &p.meta;
egui::Frame::NONE.fill(t.canvas).corner_radius(6.0).inner_margin(egui::Margin::symmetric(12, 10)).show(ui, |ui| {
ui.set_width(ui.available_width());
let dim = |s: &str| egui::RichText::new(s.to_string()).size(12.0).color(t.text_label);
let dim = |s: &str| egui::RichText::new(s.to_string()).font(t.label()).color(t.text_label);
if !m.camera.is_empty() {
ui.label(dim(&m.camera));
}
Expand Down Expand Up @@ -268,7 +268,7 @@ fn camera_card(ui: &mut egui::Ui, p: &lightcraft_catalog::Photo) {
let r = ui.horizontal_wrapped(|ui| {
ui.label(dim(crate::i18n::tr("Focus")));
ui.add_space(12.0);
ui.label(egui::RichText::new(text).size(12.0).color(t.text));
ui.label(egui::RichText::new(text).font(t.label()).color(t.text));
});
register(ui, "info:focus", r.response.rect);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/ui-egui/src/panels/second.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn body(app: &mut LightcraftApp, ui: &mut egui::Ui) {
area.center(),
egui::Align2::CENTER_CENTER,
crate::i18n::tr("No photo selected"),
egui::FontId::proportional(14.0),
crate::theme::Tokens::get(ui.ctx()).title(),
Color32::GRAY,
);
return;
Expand Down
1 change: 1 addition & 0 deletions crates/ui-egui/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ mod temp_slider;
mod text_prompt;
mod titlebar;
mod tool_overlay;
mod type_roles;
mod unsaved;
mod view_cost;
mod wb_selector;
Expand Down
66 changes: 66 additions & 0 deletions crates/ui-egui/src/tests/type_roles.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//! The type roles (`theme::TextSize` and `Tokens::caption()`, `Tokens::body_strong()` and the
//! like): seven sizes, each with a job, in a regular and a semibold face. This is the model; the
//! panels move over to it as their text is touched.

use egui::FontFamily;

use crate::theme::{FONT_SEMIBOLD, TextSize, ThemeKind, Tokens};

fn tokens() -> Tokens {
Tokens::for_kind(ThemeKind::Charcoal)
}

#[test]
fn the_sizes_are_those_of_the_scale_smallest_first() {
// Given the seven roles
let points: Vec<f32> = TextSize::ALL.iter().map(|size| size.points()).collect();
// Then their sizes are 10, 11, 12, 13, 14, 15 and 18 pt, each larger than the one before
assert_eq!(points, [10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 18.0]);
}

#[test]
fn the_sizes_of_the_scale_are_a_point_or_more_apart() {
// Two sizes closer than a point cannot be told apart, so they would not carry different jobs
for pair in TextSize::ALL.windows(2) {
assert!(pair[1].points() - pair[0].points() >= 1.0, "{pair:?}");
}
}

#[test]
fn each_role_gives_its_size_in_both_faces() {
let t = tokens();
// Given each role's regular and semibold font
let roles = [
(TextSize::Micro, t.micro(), t.micro_strong()),
(TextSize::Caption, t.caption(), t.caption_strong()),
(TextSize::Label, t.label(), t.label_strong()),
(TextSize::Body, t.body(), t.body_strong()),
(TextSize::Title, t.title(), t.title_strong()),
(TextSize::PanelTitle, t.panel_title(), t.panel_title_strong()),
(TextSize::Display, t.display(), t.display_strong()),
];
assert_eq!(roles.len(), TextSize::ALL.len());
for (size, regular, strong) in roles {
// Then both are the role's size, the regular in the proportional family and the strong in the semibold
assert_eq!((regular.size, strong.size), (size.points(), size.points()), "{size:?}");
assert_eq!(regular.family, FontFamily::Proportional, "{size:?}");
assert_eq!(strong.family, FontFamily::Name(FONT_SEMIBOLD.into()), "{size:?}");
// And asking the theme by role is the same font
assert_eq!((t.regular(size), t.strong(size)), (regular, strong), "{size:?}");
}
}

#[test]
fn the_text_styles_a_control_takes_are_roles() {
// Given the theme applied to a context
let t = tokens();
let ctx = egui::Context::default();
crate::theme::apply_kind(&ctx, ThemeKind::Charcoal);
// When a label, a button and small text take their style's font
let style = ctx.global_style();
let font = |s: egui::TextStyle| style.text_styles.get(&s).cloned();
// Then each is a named size, in the regular face
assert_eq!(font(egui::TextStyle::Body), Some(t.body()));
assert_eq!(font(egui::TextStyle::Button), Some(t.body()));
assert_eq!(font(egui::TextStyle::Small), Some(t.caption()));
}
Loading
Loading