diff --git a/crates/ui-egui/src/app/control.rs b/crates/ui-egui/src/app/control.rs index a76a34dfe5..20ec265287 100644 --- a/crates/ui-egui/src/app/control.rs +++ b/crates/ui-egui/src/app/control.rs @@ -87,16 +87,6 @@ impl VectorcraftApp { } } - /// The UI phase of a pass: counts the pass toward the captures' settling and issues the due - /// ones; a capture that expired or lost its window is answered here. - pub(crate) fn issue_captures(&mut self, ctx: &egui::Context) { - let document = self.document_identity(); - let Some(channel) = self.channel.as_mut() else { return }; - channel.captures.note_pass(); - let finished = channel.captures.issue(&WindowHost::of(ctx), motion::now(), document); - self.finish_captures(finished); - } - /// Replies to finished captures; a capture with a path is written by [`write_automation_file`]. fn finish_captures(&mut self, finished: Vec) { if finished.is_empty() { diff --git a/crates/ui-egui/src/canvas/artboards.rs b/crates/ui-egui/src/canvas/artboards.rs index 05579876ef..181f6e4cb6 100644 --- a/crates/ui-egui/src/canvas/artboards.rs +++ b/crates/ui-egui/src/canvas/artboards.rs @@ -14,9 +14,6 @@ use crate::doc_windows::Win; /// The length on screen, in points, of each arm of an artboard's center mark (a cross), at any zoom. const CENTER_MARK_ARM: f32 = 6.0; -/// The fade's color: black at 40% opacity, which shows each channel under it at 60% of its value. -pub(super) const FADE_OUTSIDE: Color32 = Color32::from_black_alpha(102); - fn closed(r: vectorcraft_geom::Rect) -> BezPath { let mut path = BezPath::new(); path.move_to(Point::new(r.x0, r.y0)); diff --git a/crates/ui-egui/src/canvas/grid.rs b/crates/ui-egui/src/canvas/grid.rs index a7dbd1fe2d..75c4a59286 100644 --- a/crates/ui-egui/src/canvas/grid.rs +++ b/crates/ui-egui/src/canvas/grid.rs @@ -1,48 +1,9 @@ -use craft::color_ui::display::DisplayTransform; use craft::ui::canvas_controls::{CanvasGrid, GridLine}; use craft::ui::style::DataColor; use egui::{Color32, Pos2, Shape, pos2}; use super::VectorcraftApp; -/// The transparency grid's 2 × 2-cell tile in the document's colours (Document Setup), converted -/// into the display profile `display` when there is one, cached per look, and its cell size in -/// screen points. -pub(crate) fn checker_texture( - ctx: &egui::Context, - setup: &vectorcraft_doc::DocSetup, - display: Option<&DisplayTransform>, -) -> (egui::TextureHandle, f32) { - // A tile of its own with a display profile, so a preview drawn in sRGB beside the canvas - // doesn't make the canvas's tile again each frame. - let id = egui::Id::unique("transparency-grid-tile").with(display.is_some()); - (checker_tile(ctx, setup.grid_colors, display, id), setup.grid_size.cell()) -} - -/// The transparency grid's 2 × 2-cell tile in the colors `grid_colors` (the first in the top-left -/// and bottom-right cells), converted into the display profile `display` when there is one, and -/// cached under `id` until the colors change. -pub(crate) fn checker_tile( - ctx: &egui::Context, - grid_colors: [vectorcraft_color::Color; 2], - display: Option<&DisplayTransform>, - id: egui::Id, -) -> egui::TextureHandle { - let colors = grid_colors.map(|c| crate::display_profile::color32(display, crate::panels::c32(&c))); - let cached = ctx.data(|d| d.get_temp::<([Color32; 2], egui::TextureHandle)>(id)).filter(|(c, _)| *c == colors); - cached.map(|(_, t)| t).unwrap_or_else(|| { - let [a, b] = colors; - let img = egui::ColorImage::new([2, 2], vec![a, b, b, a]); - let opts = egui::TextureOptions { wrap_mode: egui::TextureWrapMode::Repeat, ..egui::TextureOptions::NEAREST }; - let t = ctx.load_texture(TRANSPARENCY_GRID, img, opts); - ctx.data_mut(|d| d.insert_temp(id, (colors, t.clone()))); - t - }) -} - -/// Name of the transparency grid's texture. -pub(crate) const TRANSPARENCY_GRID: &str = "transparency grid"; - /// One quad drawn with `tex`: its corners `quad` (from the top left, clockwise) show the texture /// from (0, 0) to (`u`, `v`). pub(super) fn textured_quad(p: &egui::Painter, tex: egui::TextureId, quad: &[Pos2], (u, v): (f32, f32)) { @@ -97,25 +58,6 @@ pub(super) fn pref_color(hex: &str, fallback: Color32) -> Color32 { vectorcraft_color::Color::from_hex(hex).map_or(fallback, |c| crate::panels::c32(&c)) } -/// The part of the segment from `a` to `b` inside `r`, none when the segment misses it. -pub(super) fn clip_segment(a: Pos2, b: Pos2, r: egui::Rect) -> Option<(Pos2, Pos2)> { - let d = b - a; - let (mut t0, mut t1) = (0.0_f32, 1.0_f32); - // Each edge as (the run toward it, the room before it). - for (run, room) in [(-d.x, a.x - r.left()), (d.x, r.right() - a.x), (-d.y, a.y - r.top()), (d.y, r.bottom() - a.y)] { - if run == 0.0 { - if room < 0.0 { - return None; - } - } else if run < 0.0 { - t0 = t0.max(room / run); - } else { - t1 = t1.min(room / run); - } - } - (t0 <= t1).then(|| (a + d * t0, a + d * t1)) -} - /// A ruler label for `v` (in the ruler's unit) on a ruler whose labels are `step` apart: whole /// numbers, or the fewest decimals that write `step` exactly, so a binary step keeps its value /// (an inch ruler's 1/16 reads `0.0625`, not the `0.06` that rounding the step's magnitude gave). diff --git a/crates/ui-egui/src/chrome/control_bar.rs b/crates/ui-egui/src/chrome/control_bar.rs index b0bf95f59f..61f7786953 100644 --- a/crates/ui-egui/src/chrome/control_bar.rs +++ b/crates/ui-egui/src/chrome/control_bar.rs @@ -28,8 +28,6 @@ pub(crate) mod rank { pub const DETAIL: u8 = 3; /// Every other member of the bar. pub const GROUP: u8 = 4; - /// A section's link that stays after its fields leave. - pub const LINK: u8 = 6; } /// An anchor button: icon, tooltip, command and the convert command's `to`. diff --git a/crates/ui-egui/src/dialogs/actions.rs b/crates/ui-egui/src/dialogs/actions.rs index 85ea23796f..7d52338be2 100644 --- a/crates/ui-egui/src/dialogs/actions.rs +++ b/crates/ui-egui/src/dialogs/actions.rs @@ -132,13 +132,6 @@ impl Form { self.held.state() } - /// Applies `edit` to the values and to the values Reset returns to, for a change in the app that - /// the values follow (a set they name moved), so Reset does not go back to the old place. - pub(crate) fn follow(&mut self, edit: impl Fn(&mut V)) { - edit(&mut self.values); - edit(&mut self.opening); - } - /// The values as JSON, by their serde names. pub(crate) fn json_fields(&self) -> Option { serde_fields(&self.values) diff --git a/crates/ui-egui/src/dialogs/brush_art_options.rs b/crates/ui-egui/src/dialogs/brush_art_options.rs index 276f68d7a9..da8c05f674 100644 --- a/crates/ui-egui/src/dialogs/brush_art_options.rs +++ b/crates/ui-egui/src/dialogs/brush_art_options.rs @@ -31,9 +31,9 @@ use craft::ui::buttons::{Button, IconButton}; use craft::ui::choice::{CellMarks, Segmented, Swatch}; use craft::ui::contract::{Bind, Entry, Outcome as _, Props as _, Show as _, ShowContainer as _, clicked}; use craft::ui::dialog::{FieldRefusal, StackDialog}; -use craft::ui::display::{Picture, PictureSize, Text}; +use craft::ui::display::{Picture, Text}; use craft::ui::layout_components::{Row, Stack}; -use craft::ui::list::{ThumbAspect, ThumbSize}; +use craft::ui::list::ThumbAspect; use craft::ui::patterns::form_dialogs::{DialogFields, FieldValue, HostedParamDialog, Param, ParamKind}; use craft::ui::pickers::Select; use craft::ui::popover::Popover; @@ -48,7 +48,7 @@ use vectorcraft_brush::{ArtBrush, ArtScale, Brush, BrushKind, Colorization, Corn use vectorcraft_color::{Color, Paint}; use vectorcraft_doc::{Appearance, Document, Node, NodeId, NodeKind, PatternDef}; -use super::brush_options::{clamped, mode_key, stroke_preview}; +use super::brush_options::{clamped, mode_key}; use crate::VectorcraftApp; /// Scatter values: (field, suffix), in [`Scatter::RANGES`] order. @@ -428,18 +428,6 @@ pub(super) fn rows(ty: &str, object: bool) -> Vec { rows } -/// The row of the stroke the brush would paint, on the document `doc` the dialog opened over. -pub(super) fn preview_row(doc: Option>, ty: &str) -> Param { - let ty = ty.to_string(); - Param::custom("__stroke", tl!("Preview"), move |ui, f, _| { - let def = edited_def(f); - Picture::painter(tl!("Stroke preview"), ThumbAspect::new(7, 1), |cx, rect| stroke_preview(cx, rect, doc.as_deref(), &ty, def.clone())) - .extent(PictureSize::Thumb(ThumbSize::Medium)) - .show(ui) - }) - .full_width() -} - /// A whole-number field bound to `f[key]`, kept within `range`, named `label`. fn number_cell(ui: &mut Ui, f: &mut DialogFields, key: &str, label: &'static str, range: (f64, f64), unit: UnitKind, enabled: bool) -> Response { let typed = NumberField::new(label, Bind::given(Some(clamped(f, key, range)))) diff --git a/crates/ui-egui/src/dialogs/char_style_options.rs b/crates/ui-egui/src/dialogs/char_style_options.rs index e15111b3a8..3ad521ad04 100644 --- a/crates/ui-egui/src/dialogs/char_style_options.rs +++ b/crates/ui-egui/src/dialogs/char_style_options.rs @@ -1112,11 +1112,6 @@ impl CharStyleOptions { edited_attrs(self.inner.fields(), &self.opening) } - /// What the dialog opened with. - pub(crate) fn opening(&self) -> &Opening { - &self.opening - } - fn command(&self, attrs: Map) -> Value { let to = self.inner.fields().text("name").unwrap_or_default(); json!({"name": self.opening.style, "to": to, "attrs": attrs}) diff --git a/crates/ui-egui/src/dialogs/dimension.rs b/crates/ui-egui/src/dialogs/dimension.rs index ffefb6a8a6..5d37966bc9 100644 --- a/crates/ui-egui/src/dialogs/dimension.rs +++ b/crates/ui-egui/src/dialogs/dimension.rs @@ -87,11 +87,11 @@ const MODES: [(&str, &str); 3] = [("linear", "Linear"), ("angular", "Angular"), /// Where the floating strip sits from the canvas corner. const STRIP_OFFSET: egui::Vec2 = egui::vec2(24.0, 24.0); -/// A number field of the options: its labels, the number it edits and the range and unit it shows. -#[derive(Clone, Copy)] /// The option a number field edits. type NumSlot = fn(&mut DimensionOptions) -> &mut f64; +/// A number field of the options: its labels, the number it edits and the range and unit it shows. +#[derive(Clone, Copy)] struct Num { /// The label beside the field. label: &'static str, diff --git a/crates/ui-egui/src/dialogs/graph_data.rs b/crates/ui-egui/src/dialogs/graph_data.rs index 0605b250b0..85bb9503c1 100644 --- a/crates/ui-egui/src/dialogs/graph_data.rs +++ b/crates/ui-egui/src/dialogs/graph_data.rs @@ -390,12 +390,6 @@ fn graph_grid(app: &mut VectorcraftApp, graph: Option) -> Result) -> Result<(), String> { - replace_grid(sheet, graph_grid(app, graph)?); - Ok(()) -} - /// Whether Import Data can ask for a file here: the host has a picker and the app can read files. fn can_import(app: &VectorcraftApp) -> bool { file_asks::can(app, craft::host::PickKind::Open) && app.services.read.is_some() diff --git a/crates/ui-egui/src/dialogs/para_style_options.rs b/crates/ui-egui/src/dialogs/para_style_options.rs index c9b9d7d62c..4a66076a90 100644 --- a/crates/ui-egui/src/dialogs/para_style_options.rs +++ b/crates/ui-egui/src/dialogs/para_style_options.rs @@ -772,11 +772,6 @@ impl ParaStyleOptions { edited_attrs(self.inner.fields(), &self.opening) } - /// What the dialog opened with. - pub(crate) fn opening(&self) -> &Opening { - &self.opening - } - fn command(&self, attrs: Map) -> Value { let to = self.inner.fields().text("name").unwrap_or_default(); json!({"name": self.opening.style, "to": to, "attrs": attrs}) diff --git a/crates/ui-egui/src/dialogs/preset_manager.rs b/crates/ui-egui/src/dialogs/preset_manager.rs index a512152dbe..1ec0cead83 100644 --- a/crates/ui-egui/src/dialogs/preset_manager.rs +++ b/crates/ui-egui/src/dialogs/preset_manager.rs @@ -260,11 +260,6 @@ impl PresetManager { self.stored = stored; self.detail = detail; } - - /// Whether the selected preset is a built-in one. - fn built_in(&self) -> bool { - find(&self.rows, &self.selected).is_none_or(|row| row.built_in) - } } impl StackDialog for PresetManager { diff --git a/crates/ui-egui/src/dialogs/rearrange_artboards.rs b/crates/ui-egui/src/dialogs/rearrange_artboards.rs index bf758495aa..7c45aaeac6 100644 --- a/crates/ui-egui/src/dialogs/rearrange_artboards.rs +++ b/crates/ui-egui/src/dialogs/rearrange_artboards.rs @@ -301,7 +301,8 @@ mod tests { #[test] fn rearrange_fields_reach_the_command() { type Settings<'a> = &'a [(&'a str, Value)]; - let cases: [(u32, Settings<'_>, &[(f64, f64)]); 2] = [ + type Positions<'a> = &'a [(f64, f64)]; + let cases: [(u32, Settings<'_>, Positions<'_>); 2] = [ (3, &[("layout", json!("row")), ("order", json!("rightToLeft")), ("spacing", json!(10))], &[(220.0, 0.0), (110.0, 0.0), (0.0, 0.0)]), ( 4, diff --git a/crates/ui-egui/src/dialogs/recolor/fixture.rs b/crates/ui-egui/src/dialogs/recolor/fixture.rs index f90f44f34e..a773d34093 100644 --- a/crates/ui-egui/src/dialogs/recolor/fixture.rs +++ b/crates/ui-egui/src/dialogs/recolor/fixture.rs @@ -5,12 +5,11 @@ use std::cell::{RefCell, RefMut}; use std::rc::Rc; -use craft::behavior::PartRef; use craft::ui::dialog::{DialogHost, DialogId, HeldOk, dialog_id}; use craft::ui::runtime::access::Role; use craft::ui::testing::pointer::part_rect_of_node; use craft::ui::testing::{Fixture, Room, Target}; -use egui::{Event, Modifiers, PointerButton, Pos2, Rect, Vec2}; +use egui::{Event, Modifiers, PointerButton, Pos2, Rect}; use serde_json::{Value, json}; use super::{Fields, GROUP_ACTION, KIND, RecolorDialog}; @@ -183,25 +182,6 @@ impl Recolor { self } - /// The rect of part `part` of component `owner`, for a part with no access node. - pub(crate) fn part_rect(&self, owner: egui::Id, part: impl Into) -> Option { - self.fixture.part_rect(owner, part) - } - - /// A drag of the control named `label` by `by`, released. - pub(crate) fn drag(&mut self, label: &str, by: Vec2) -> &mut Self { - let target = self.target(label); - self.fixture.drag(&target, by); - self - } - - /// A press on the control named `label`, held. - pub(crate) fn press(&mut self, label: &str) -> &mut Self { - let target = self.target(label); - self.fixture.press(&target); - self - } - /// The rects of the graphics objects inside `area` (a bar's parts), left to right. pub(crate) fn graphics_in(&self, area: Rect) -> Vec { let mut rects: Vec = diff --git a/crates/ui-egui/src/dialogs/revolve_lights.rs b/crates/ui-egui/src/dialogs/revolve_lights.rs index 066b703f79..992ccf44ae 100644 --- a/crates/ui-egui/src/dialogs/revolve_lights.rs +++ b/crates/ui-egui/src/dialogs/revolve_lights.rs @@ -95,15 +95,6 @@ fn round(n: f64) -> f64 { (n * 10.0).round() / 10.0 } -/// The effect's lights: each light of its list, or its single light, with the effect's defaults for -/// the settings a light leaves out or the selected effects hold with different values (null). A 3D -/// (Classic) effect's lights are white whatever color a list light carries, since it shades -/// without light color. -pub(crate) fn lights(fields: &DialogFields) -> Lights { - let classic = vectorcraft_effects::is_classic_three_d(fields.text("__effect").unwrap_or_default()); - lights_for(fields, classic) -} - /// [`lights`] for a light editor that already knows whether it edits a 3D (Classic) effect. fn lights_for(fields: &DialogFields, classic: bool) -> Lights { let defaults = vectorcraft_effects::default_params(fields.text("__effect").unwrap_or_default()).unwrap_or(json!({})); diff --git a/crates/ui-egui/src/fields.rs b/crates/ui-egui/src/fields.rs index eed33e6eec..7e3de28adb 100644 --- a/crates/ui-egui/src/fields.rs +++ b/crates/ui-egui/src/fields.rs @@ -42,26 +42,11 @@ pub fn blend_entries() -> Vec> { framework_blend_entries(&entries, |entry| mode_label(entry.key)) } -/// The blend modes keyed by [`blend_key`], for a form parameter (`Param::blend`). -pub fn blend_modes() -> Vec<(BlendKeyEntry, Label)> { - blend_table().into_iter().map(|(mode, shortcut)| (BlendKeyEntry::new(blend_key(mode), shortcut), mode_label(mode))).collect() -} - /// `mode`'s name in the interface language. fn mode_label(mode: BlendMode) -> Label { Label::from(crate::i18n::t(mode.label())) } -/// The parameter value naming `mode` (`"multiply"`). -pub fn blend_key(mode: BlendMode) -> String { - mode.label().to_ascii_lowercase() -} - -/// The blend mode an effect parameter names; only a parameter called `mode` is one. -pub fn blend_of(key: &str, value: &serde_json::Value) -> Option { - value.as_str().filter(|_| key == "mode").and_then(BlendMode::parse) -} - /// `lengths` with `bare_points` (Numbers Without Units Are Points) applied: a bare number in a picas /// field counts as points. pub fn bare_points(lengths: LengthUnits, on: bool) -> LengthUnits { diff --git a/crates/ui-egui/src/io/save.rs b/crates/ui-egui/src/io/save.rs index 45a0f19c2d..07cfaace49 100644 --- a/crates/ui-egui/src/io/save.rs +++ b/crates/ui-egui/src/io/save.rs @@ -93,15 +93,6 @@ fn finish(app: &mut VectorcraftApp, uid: u64, retargets: bool, out: &Result Result { - let uid = app.session.active().ok_or("no document")?.uid; - // Saves of one document finish in order. - if app.background.busy_with(uid) { - background::wait_all(app); - } - if app.saves.flows.get(&uid).is_some_and(|f| f.is_busy()) { - return Err(SAVE_IN_PROGRESS.english.into()); - } - if let Some(old) = app.saves.done.remove(&uid).and_then(|d| d.then) { - old(app, Err("cancelled".into())); - } - let waiting = SaveDone { - mode, - params: p.clone(), - ask_options: false, - suggested: String::new(), - filters: Vec::new(), - retrying: false, - retry: None, - question: None, - then: Some(done), - }; - app.saves.done.insert(uid, waiting); - let r = save(app, mode, p, true); - if r.is_err() { - terminate(app, uid, r.clone()); - } - r -} - /// Takes what the flows and their questions have answered since the last pass: the pick, the /// changed-on-disk question's answer. A save whose document closed is cancelled and forgotten. pub(crate) fn pump(app: &mut VectorcraftApp, _ctx: &egui::Context) { diff --git a/crates/ui-egui/src/keymap.rs b/crates/ui-egui/src/keymap.rs index 2c84bd1921..12812aa507 100644 --- a/crates/ui-egui/src/keymap.rs +++ b/crates/ui-egui/src/keymap.rs @@ -104,14 +104,6 @@ pub fn stored_key(key: &str) -> String { if key.starts_with("panel:") || key.starts_with("effect:") || key.starts_with("plugin:") { command_of(key).key() } else { key.to_string() } } -/// An Effect menu item's [`Overrides`] key under the command its item does not run now -/// (`effect.apply` for one that opens its dialog, and the other way round). -pub(crate) fn other_stored_key(key: &str) -> Option { - let effect = key.strip_prefix("effect:")?; - let other = if command_of(key).id == "effect.apply" { "effect.dialog" } else { "effect.apply" }; - Some(CommandRef::with_params(other, json!({ "effect": effect })).key()) -} - /// The entry key of an [`Overrides`] key. pub fn entry_of_stored(key: &str) -> String { CommandRef::parse_key(key) diff --git a/crates/ui-egui/src/menus/invoke.rs b/crates/ui-egui/src/menus/invoke.rs index 6c55562e84..09195e00c3 100644 --- a/crates/ui-egui/src/menus/invoke.rs +++ b/crates/ui-egui/src/menus/invoke.rs @@ -24,21 +24,6 @@ pub fn click_target(label: &str, id: &str, p: &Value) -> (String, Value) { (id.to_string(), if p.is_null() { json!({}) } else { p.clone() }) } -/// What an in-window menu click on `target` (a [`click_target`]) runs with `held` held: Object › -/// Unlock All and Object › Show All chosen with Shift+Alt (Shift+Option) act only inside the groups -/// that hold the selected objects (`scope: "group"`); Select Linked, Embedded, Missing and Modified -/// chosen with Shift add to the selection (`add: true`); Object › Expand… chosen with Alt (Option) -/// expands at once with the choices its dialog last expanded with (`immediate: true`). -pub(crate) fn with_held_keys(target: (String, Value), held: egui::Modifiers) -> (String, Value) { - match target.0.as_str() { - "object.unlockAll" | "object.showAll" if held.shift && held.alt => (target.0, json!({"scope": "group"})), - "ui.expandDialog" if held.alt => (target.0, json!({"immediate": true})), - // Select Linked, Embedded, Missing and Modified with Shift add to the selection. - crate::addons::select::link_status::COMMAND if held.shift => (target.0, crate::addons::select::link_status::with_shift(target.1)), - _ => target, - } -} - /// The dialog of command `id` that shows the selection's current values (its query): its heading /// and the queried values it doesn't show. Type on a Path Options leaves the brackets where they /// are. Color Mask opens on the selected image's mask settings (the defaults without one). diff --git a/crates/ui-egui/src/panel_docking.rs b/crates/ui-egui/src/panel_docking.rs index 0f3f5b72a5..c2a6fff33b 100644 --- a/crates/ui-egui/src/panel_docking.rs +++ b/crates/ui-egui/src/panel_docking.rs @@ -1275,12 +1275,6 @@ pub(crate) fn show(app: &mut VectorcraftApp, ui: &mut egui::Ui) { settle(app); } -/// Whether a modal is open: a dialog, the command palette or a native file dialog. Floating panels -/// in OS windows of their own take no input meanwhile, as the main window behind it takes none. -pub(crate) fn modal_open(app: &VectorcraftApp) -> bool { - app.any_dialog_open() || app.ui.palette_open || app.file_dialog_open() -} - /// Is a modal window open in this pass: a modal dialog, Preferences, Keyboard Shortcuts or a file /// dialog? A popup (a menu, a dropdown, a slider strip) is no window, so it does not close itself; /// nor is the open palette's own box, so a modal layer of the last pass counts only while the diff --git a/crates/ui-egui/src/panels/align.rs b/crates/ui-egui/src/panels/align.rs index 9a884dfc52..6d14b8792b 100644 --- a/crates/ui-egui/src/panels/align.rs +++ b/crates/ui-egui/src/panels/align.rs @@ -361,9 +361,6 @@ fn align_to(app: &VectorcraftApp) -> AlignTo { if has_key(app) { AlignTo::Key } else { app.ui.align_to } } -/// The Align To choices of the Align panel and of the Control bar's Align To menu, in their order. -const ALIGN_TO: [AlignTo; 3] = [AlignTo::Selection, AlignTo::Key, AlignTo::Artboard]; - /// The icon and the translated name of Align To choice `v`; `anchor`: the key is an anchor point /// (Direct Selection), and the key choice is named Align to Key Anchor. fn align_to_icon_name(v: AlignTo, anchor: bool) -> (&'static str, &'static str) { diff --git a/crates/ui-egui/src/panels/artboards/tests.rs b/crates/ui-egui/src/panels/artboards/tests.rs index d1a6d859ac..1595711f38 100644 --- a/crates/ui-egui/src/panels/artboards/tests.rs +++ b/crates/ui-egui/src/panels/artboards/tests.rs @@ -1031,7 +1031,7 @@ fn the_artboard_tools_menu_publishes_its_cut_and_copy() { app.session.set_tool_option("selected", &json!([1])); app.view_mut().unwrap().artboard = 1; for label in ["Copy", "Cut"] { - assert_eq!(app.clipboard.write_text("").unwrap(), craft::craft_platform::clipboard::Written::Written, "{label}: the clipboard is cleared"); + assert_eq!(app.clipboard.write_text("").unwrap(), craft::platform::clipboard::Written::Written, "{label}: the clipboard is cleared"); choose(&mut app, label); assert!(app.written_clipboard_text().is_some_and(|svg| svg.contains(" Option<(f64, bool)> { Some((value, true)) } -/// The check marks of the Kerning menu's Auto and Optical entries for the selection's kerning -/// `mode` (Optical on, manual value). A manual value checks neither, as it sets the spacing even -/// with Optical on. A selection that mixes modes checks neither, and the menu still lists both. -fn kerning_methods(mode: Option<(bool, Option)>) -> (Option, Option) { - let (automatic, optical) = mode.map_or((false, false), |(optical, manual)| (!optical && manual.is_none(), optical && manual.is_none())); - (Some(automatic), Some(optical)) -} - /// The faces Type › Bold and Type › Italic switch to. #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum Face { diff --git a/crates/ui-egui/src/panels/glyphs.rs b/crates/ui-egui/src/panels/glyphs.rs index b00398ef09..b219b55483 100644 --- a/crates/ui-egui/src/panels/glyphs.rs +++ b/crates/ui-egui/src/panels/glyphs.rs @@ -335,12 +335,6 @@ impl VcGlyphs<'static> { VcGlyphs { db: FontDb::global(), family, style, face, fit, listing: None, empty } } - /// The source of `face` for the character selected now: the canvas row draws its cells with it. - pub(crate) fn for_face(app: &mut VectorcraftApp, face: Arc) -> Self { - let fit = Some(Fit::of(app, &face)); - VcGlyphs { fit, ..Self::bare(face) } - } - /// The source of `face` alone: it draws glyphs and describes nothing about the selection. fn bare(face: Arc) -> Self { VcGlyphs { diff --git a/crates/ui-egui/src/panels/swatches.rs b/crates/ui-egui/src/panels/swatches.rs index 5809cb82c6..ec48e99268 100644 --- a/crates/ui-egui/src/panels/swatches.rs +++ b/crates/ui-egui/src/panels/swatches.rs @@ -65,9 +65,6 @@ impl View { (View::SmallList, "Small List View"), (View::LargeList, "Large List View"), ]; - pub(crate) fn is_list(self) -> bool { - matches!(self, View::SmallList | View::LargeList) - } /// The browser's view and thumbnail zoom this mode stands for. pub(crate) fn preset(self) -> (PresetView, f64) { match self { diff --git a/crates/ui-egui/src/panels/swatches/libraries.rs b/crates/ui-egui/src/panels/swatches/libraries.rs index 330e46041a..62e926dd55 100644 --- a/crates/ui-egui/src/panels/swatches/libraries.rs +++ b/crates/ui-egui/src/panels/swatches/libraries.rs @@ -29,24 +29,6 @@ pub(crate) fn colour_libraries(app: &VectorcraftApp) -> Vec { library_refs(swatchlib::libraries(&app.session).into_iter().filter(|l| l.category != "gradients" && has_colours(&l.id)).collect()) } -/// The name of library choice `key` (the document's swatches or a swatch library, as Image -/// Trace's Document Library and Find Nearest Swatch pick one); a library that is gone shows its key. -pub(crate) fn library_label(app: &VectorcraftApp, key: &str) -> String { - match limit_name(app, key) { - Some(_) if key == swatchlib::DOCUMENT_SWATCHES => tl!(DOCUMENT_SWATCHES).to_string(), - Some(name) => library_panel::library_name(key, &name).to_string(), - None => key.to_string(), - } -} - -/// The library choices: the document's swatches, then the colour libraries (`current` checked) → -/// the key chosen. -pub(crate) fn library_list(app: &VectorcraftApp, ui: &mut Ui, current: &str) -> Option { - let document = item(ui, DOCUMENT_SWATCHES, true, Some(current == swatchlib::DOCUMENT_SWATCHES)).then(|| swatchlib::DOCUMENT_SWATCHES.to_string()); - ui.separator(); - library_panel::library_items(ui, &colour_libraries(app), &|id| id == current).or(document) -} - /// The library choices of a `Select`: the document's swatches, a separator, the colour libraries at /// the top level of the library menu, then each submenu's libraries under its heading. pub(crate) fn library_entries(app: &VectorcraftApp) -> Vec> { diff --git a/crates/ui-egui/src/panels/text_styles.rs b/crates/ui-egui/src/panels/text_styles.rs index ba1baf1a3d..dbd7447b34 100644 --- a/crates/ui-egui/src/panels/text_styles.rs +++ b/crates/ui-egui/src/panels/text_styles.rs @@ -39,10 +39,6 @@ impl Kind { fn what(self) -> &'static str { if self == Kind::Char { "Character" } else { "Paragraph" } } - /// `what` in the UI language, for text shown to the user. - fn what_label(self) -> &'static str { - if self == Kind::Char { tl!("Character") } else { tl!("Paragraph") } - } /// The framework panel's kind. fn panel_kind(self) -> TextStyleKind { if self == Kind::Char { TextStyleKind::Character } else { TextStyleKind::Paragraph } diff --git a/crates/ui-egui/src/panels/transform.rs b/crates/ui-egui/src/panels/transform.rs index dde9b1808a..f3608ab7dc 100644 --- a/crates/ui-egui/src/panels/transform.rs +++ b/crates/ui-egui/src/panels/transform.rs @@ -20,7 +20,7 @@ use craft::ui::display::{Shade, Text}; use craft::ui::form::Field; use craft::ui::layout_components::Row; use craft::ui::menu::PanelRow; -use craft::ui::pickers::{Anchor9, ReferencePoint, ReferencePointLook}; +use craft::ui::pickers::{Anchor9, ReferencePointLook}; use craft::ui::popover::Popover; use craft::ui::runtime::commands::{CommandState, CommandStates}; use craft::ui::text::{NumberField, NumberOutput, NumberPick, StepArrows}; @@ -95,11 +95,6 @@ fn anchor_index(anchor: Anchor9) -> usize { ANCHORS.iter().position(|a| *a == anchor).unwrap_or(4) } -/// The point `index` (0 to 8) names; the centre for an index outside the grid. -fn anchor_at(index: usize) -> Anchor9 { - ANCHORS.get(index).copied().unwrap_or(Anchor9::Centre) -} - /// Proportional size: the other dimension when one changes with the link on. pub fn constrained(w: f64, h: f64, new_w: Option, new_h: Option) -> (f64, f64) { match (new_w, new_h) { @@ -477,17 +472,6 @@ fn shear_field(app: &mut VectorcraftApp, ui: &mut Ui) { }); } -/// The reference point picker alone, for forms that have no transform fields (Artboard Options). -pub(crate) fn reference_picker(app: &mut VectorcraftApp, ui: &mut Ui) { - let at = anchor_at(app.ui.transform_panel.reference_point); - let out = ReferencePoint::new(tl!("Reference Point"), Bind::given(Some(at))).look(ReferencePointLook::Squares).show(ui); - apply_edits(app, &out, EditPath::Scope, |app, anchor, _| { - if let Some(anchor) = *anchor { - app.ui.transform_panel.reference_point = anchor_index(anchor); - } - }); -} - /// The fields of artboard `index` at `r` about the shared reference point, in the panel's form or the bar's. fn artboard_form(app: &mut VectorcraftApp, ui: &mut Ui, index: usize, r: Rect, bar: bool) -> TransformFieldsOutput { let refi = app.ui.transform_panel.reference_point; diff --git a/crates/ui-egui/src/tests/panel_harness.rs b/crates/ui-egui/src/tests/panel_harness.rs index 81918a5e5e..0949ef8c80 100644 --- a/crates/ui-egui/src/tests/panel_harness.rs +++ b/crates/ui-egui/src/tests/panel_harness.rs @@ -176,13 +176,6 @@ impl Panel { self.after(); } - /// Presses on the control named `name`, moves the pointer by `by` and keeps the button down until [`Panel::release`]. - pub(crate) fn drag_hold(&mut self, name: &str, by: Vec2) { - let target = self.find(name); - self.fixture.drag_hold_at(target.center(), by); - self.after(); - } - /// [`Panel::drag_hold`] on the control named `name` whose role is `role`, where controls of other roles share /// the name (a slider beside its number box). pub(crate) fn drag_hold_role(&mut self, name: &str, role: craft::ui::contract::Role, by: Vec2) { diff --git a/crates/ui-egui/src/updates_ui.rs b/crates/ui-egui/src/updates_ui.rs index 20be4557ce..fc6f8dde96 100644 --- a/crates/ui-egui/src/updates_ui.rs +++ b/crates/ui-egui/src/updates_ui.rs @@ -170,15 +170,6 @@ pub(crate) fn open_prompt_for_test(app: &mut VectorcraftApp) { tests::offer(app); } -/// Opens the result dialog of a running check for a test in another module. -#[cfg(all(test, not(target_arch = "wasm32")))] -pub(crate) fn open_result_window_for_test(app: &mut VectorcraftApp, ctx: &egui::Context) { - app.updates_rt.updater = tests::isolated_updater(env!("CARGO_PKG_VERSION"), "result"); - // Keeps `ctx` for the updater's threads. - app.updates_rt.updater.tick(ctx); - app.updates_rt.updater.check_now(); -} - /// Closes the update prompt and the result dialog for a test in another module. #[cfg(all(test, not(target_arch = "wasm32")))] pub(crate) fn close_dialogs_for_test(app: &mut VectorcraftApp) {