diff --git a/crates/font-manager/src/panel/app.rs b/crates/font-manager/src/panel/app.rs index d8ba162de..b54f24198 100644 --- a/crates/font-manager/src/panel/app.rs +++ b/crates/font-manager/src/panel/app.rs @@ -45,8 +45,11 @@ pub fn install_interface_fonts(ctx: &Context, language: &str, craft_faces: &[Emb UiFonts::new(&I18nScripts).languages(LANGUAGES).ui_language(language).craft_faces(craft_faces).install(ctx); } -/// The filters column takes the width of its widest section; the list and toolbar take the rest. -const PANES: [ColumnWidth; 2] = [ColumnWidth::Content, ColumnWidth::fill(1.0)]; +/// The filters column, whatever the list beside it shows; the list and toolbar take the rest. +const PANES: [ColumnWidth; 2] = [ColumnWidth::Fixed(248.0), ColumnWidth::fill(1.0)]; +/// The panes of a panel less than [`WIDE_PANEL`] wide. +const NARROW_PANES: [ColumnWidth; 2] = [ColumnWidth::Fixed(212.0), ColumnWidth::fill(1.0)]; +const WIDE_PANEL: f32 = 860.0; /// Preview downloads: at most this much per file, and this many faces in a session. const PREVIEW_LIMITS: Limits = Limits { max_file_bytes: 64 << 20, max_faces_per_file: 512, max_added_faces: 20_000 }; @@ -936,6 +939,7 @@ impl<'a> FontsPanelView<'a> { let search = ui.scope_id().with("search"); let folder = env.folder(); let wake = panel.jobs.waker(); + let panes = if ui.available_width() < WIDE_PANEL { &NARROW_PANES } else { &PANES }; let mut begun = false; let mut shown = Stack::new().fill().label(words.panel.clone()).command_scope(FontsCommand::SCOPE).show(ui, |ui, root| { if !std::mem::replace(&mut begun, true) { @@ -946,11 +950,11 @@ impl<'a> FontsPanelView<'a> { } root.publish(FontsCommand::Find, CommandState::new()); panel.top_bar(ui, &browse, texts.format, search); - let panes = Grid::new(&PANES).fill().show(ui, |ui, _| { + let shown = Grid::new(panes).fill().show(ui, |ui, _| { panel.filters(ui, &texts); panel.main(ui, &texts, &folder, host.as_ref()) }); - panes.inner.flatten() + shown.inner.flatten() }); // A measuring run has no rows on screen, and a pass that runs again may have the wrong ones. let rerun = craft_ui::runtime::frame::will_rerun(ui.ctx()); diff --git a/crates/font-manager/src/panel/browse.rs b/crates/font-manager/src/panel/browse.rs index 21acdda0d..2acbdf77a 100644 --- a/crates/font-manager/src/panel/browse.rs +++ b/crates/font-manager/src/panel/browse.rs @@ -18,7 +18,7 @@ use craft_ui::choice::{Checkbox, Radio, RadioGroup}; use craft_ui::contract::{ Access, ActivateOn, Bind, Collection, CollectionEvent, CollectionProps, CollectionResponse, Common, Component, ContainerProps, Cx, Entry, ItemOutput, MeasureCx, Name, NoValue, Outcome, PartsCx, Props as _, Role, Scroll, SelectMode, Show as _, ShowCollection as _, ShowContainer as _, - Sizing, WrapWidth, clicked, + Sizing, clicked, }; use craft_ui::display::{Badge, Progress, Shade, Spinner, Text}; use craft_ui::form::{SliderField, SliderFieldLayout}; @@ -203,7 +203,7 @@ impl FontsPanel { pub(crate) fn filters(&mut self, ui: &mut Ui, texts: &Texts<'_>) { let browse = texts.browse; - Stack::new().scroll(Scroll::vertical()).wrap_width(WrapWidth::Column).label(browse.filters.clone()).show(ui, |ui, _| { + Stack::new().fill().scroll(Scroll::vertical()).label(browse.filters.clone()).show(ui, |ui, _| { match self.tab { Tab::Catalogue => self.catalogue_filters(ui, texts), Tab::Installed => self.installed_filters(ui, texts), @@ -271,7 +271,7 @@ impl FontsPanel { .activate(ActivateOn::Click) .allow_empty(false) .header(false) - .sizing(Sizing::Content) + .sizing(Sizing::FillWidth) .natural_height(true) .selection(Bind::given(current)) .show_items(ui, &CardKeys::new(&rows, |_| None), &mut |key, _| { diff --git a/crates/font-manager/src/panel/details.rs b/crates/font-manager/src/panel/details.rs index 0e6540f80..a354954f0 100644 --- a/crates/font-manager/src/panel/details.rs +++ b/crates/font-manager/src/panel/details.rs @@ -18,19 +18,22 @@ use craft_host::Host; use craft_theme::variant::{Emphasis, Tone}; use craft_ui::buttons::{Button, Link, SplitButton}; use craft_ui::contract::overlay::Outside; -use craft_ui::contract::{Bind, CollectionEvent, Entry, NoValue, Outcome, Props as _, Show as _, ShowCollection as _, ShowContainer as _, clicked}; +use craft_ui::contract::{ + Bind, CollectionEvent, Entry, NoValue, Outcome, Props as _, Show as _, ShowCollection as _, ShowContainer as _, Sizing, clicked, +}; use craft_ui::dialog::Dialog; use craft_ui::display::{Badge, Progress, Shade, Text}; use craft_ui::layout_components::{Grid, Row, Stack}; use craft_ui::notices::{Notice, NoticeAction}; use craft_ui::primitives::Wrap; use craft_ui::runtime::env::{Env, Label}; +use craft_ui::runtime::focus::Initial; use craft_ui::style::Variant; use craft_ui::text::TextField; use egui::{Response, Ui}; use self::rows::{Action, Lines, StyleLine, StyleList, StyleRow}; -use crate::axes::{AxisSliders, AxisValues, FontAxis, read_axes}; +use crate::axes::{AxisSliders, AxisValues, FontAxis, OpticalSize, read_axes, shown_axes}; use crate::index::{Family, FontFile, Index, script_name, source_label}; use crate::panel::app::{ Detail, FontsPanel, FontsPanelWords, NotCopied, Pending, category_label, family_key, regular, source_name, style_count, style_name, @@ -50,8 +53,13 @@ const HERO_POINTS: f32 = 96.0; /// The most languages the sheet lists; the rest are counted. const LANGUAGES_SHOWN: usize = 60; -/// The lines of a licence or NOTICE text in view; the rest scrolls. +/// The most lines of a licence or NOTICE text in view; the rest scrolls. const LEGAL_LINES: usize = 10; +/// The lines its box has for a shorter text: the least of a multi-line field. +const LEGAL_LEAST_LINES: usize = 2; + +/// The sheet's sliders show the face's optical sizes, which its samples are drawn at. +const OPTICAL_SIZE: OpticalSize = OpticalSize::Slider; /// The facts' labels over their values. const FACT_COLUMNS: [ColumnWidth; 2] = [ColumnWidth::Content, ColumnWidth::fill(1.0)]; @@ -396,14 +404,16 @@ impl<'a> DetailsSheet<'a> { let points = panel.settings.size.max(MIN_SAMPLE_POINTS); let mut todo: Vec = Vec::new(); let mut open = true; + // The sheet is for reading: no field of it takes the keyboard when it opens. let mut shown = Dialog::prompt(sheet.title.clone()) + .initial_focus(Initial::Keep) .overlay(|overlay| { let dismiss = overlay.dismiss.outside(Outside::Absorb); overlay.dismiss(dismiss) }) .opened(Bind::bound(&mut open)) .show(ui, |ui, _| { - Stack::new().show(ui, |ui, _| { + Stack::new().fill_width().show(ui, |ui, _| { sheet.header(ui, &env, &words, &mut todo); sheet.body(ui, &env, &words, points, &mut panel.detail_axes, &mut todo); }); @@ -666,21 +676,16 @@ impl Sheet { out.chosen.map(Some).or_else(|| out.activated.then_some(None)) } - /// The styles, and beside them (or below, when narrow) the facts and the languages. + /// The styles, the axis sliders of each variable file under its name, the facts, the languages and the licence. fn body(&self, ui: &mut Ui, env: &Env, words: &DetailsWords, points: f32, axes: &mut HashMap, todo: &mut Vec) { - Row::new().wrap(true).show(ui, |ui, _| { - Stack::new().show(ui, |ui, _| { - self.styles(ui, env, words, points, todo); - for file in &self.axes { - let values = axes.entry(file.sha256.clone()).or_default(); - AxisSliders::new(file.label.clone(), &file.axes, Bind::bound(values)).show(ui); - } - }); - Stack::new().show(ui, |ui, _| { - self.side(ui, env, words); - self.licence(ui, words, todo); - }); - }); + self.styles(ui, env, words, points, todo); + for file in &self.axes { + Text::new(file.label.clone()).shade(Shade::Faint).show(ui); + let values = axes.entry(file.sha256.clone()).or_default(); + AxisSliders::new(file.label.clone(), &file.axes, Bind::bound(values)).optical_size(OPTICAL_SIZE).show(ui); + } + self.side(ui, env, words); + self.licence(ui, words, todo); } fn styles(&self, ui: &mut Ui, env: &Env, words: &DetailsWords, points: f32, todo: &mut Vec) { @@ -750,8 +755,9 @@ impl Sheet { LegalShown::Text(text) => { Text::new(title.clone()).shade(Shade::Faint).show(ui); TextField::new(title.clone(), Bind::given(text.clone())) - .lines(LEGAL_LINES) + .lines(LEGAL_LEAST_LINES) .max_lines(LEGAL_LINES) + .sizing(Sizing::FillWidth) .mono() .read_only(true) .show(ui); @@ -873,7 +879,8 @@ impl FamilyStyles<'_> { self.panel.subsets.detail_font(self.index, self.family, file, self.sample) } - /// The axes of the variable files among `files`: the subset's own once it is here, else the index's ranges. + /// The axes of the variable files among `files` that have a slider: the subset's own once it is here, else the index's + /// ranges. fn axes(&self, files: &[usize]) -> Vec { files .iter() @@ -883,6 +890,7 @@ impl FamilyStyles<'_> { let own = self.subset(file).map(|font| read_axes(&font.bytes, 0)).filter(|axes| !axes.is_empty()); FileAxes { sha256: file.sha256.clone(), label: file_label(file), axes: own.unwrap_or_else(|| index_axes(file)) } }) + .filter(|file| shown_axes(&file.axes, OPTICAL_SIZE).next().is_some()) .collect() } } diff --git a/crates/font-manager/src/panel/details/rows.rs b/crates/font-manager/src/panel/details/rows.rs index 9d2efd3a9..49dc15489 100644 --- a/crates/font-manager/src/panel/details/rows.rs +++ b/crates/font-manager/src/panel/details/rows.rs @@ -105,11 +105,11 @@ pub(super) struct StyleList { } impl StyleList { - /// A list named `label`; it is as tall as its rows, and shows `empty` while it has none. + /// A list named `label`; it fills the width, is as tall as its rows, and shows `empty` while it has none. pub(super) fn new(label: impl Into