mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-16 22:14:30 +00:00
cargo fmt
This commit is contained in:
@@ -24,7 +24,13 @@ pub struct AgentSettings {
|
||||
|
||||
impl Default for AgentSettings {
|
||||
fn default() -> Self {
|
||||
Self { allow_agent_control: true, control_port: 0, read_root: String::new(), write_root: String::new(), when_app_closed: WhenAppClosed::Launch }
|
||||
Self {
|
||||
allow_agent_control: true,
|
||||
control_port: 0,
|
||||
read_root: String::new(),
|
||||
write_root: String::new(),
|
||||
when_app_closed: WhenAppClosed::Launch,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ mod words;
|
||||
|
||||
pub use body::{ActionMove, ActionPlace};
|
||||
pub use menu::{ActionsMenuAction, ActionsMenuFacts, ActionsPanelCommands, panel_rows};
|
||||
pub use prompt::LibraryPrompt;
|
||||
pub use panel::{ActionSelection, ActionsEvent, ActionsHost, ActionsPanel, ActionsPanelOutput, ActionsPanelState, ActionsSettings, ShortcutChoice};
|
||||
pub use prompt::LibraryPrompt;
|
||||
pub use rows::{DIALOG_COLUMN, INCLUDE_COLUMN};
|
||||
pub use words::ActionsWords;
|
||||
|
||||
@@ -127,7 +127,8 @@ impl<'a> AgentsPage<'a> {
|
||||
|
||||
for (name, label) in [("readRoot", &words.read_root), ("writeRoot", &words.write_root)] {
|
||||
let folder_key = key(name);
|
||||
let out = PathSetting::new(label.clone(), &folder_key, draft, PickRequest::folder(PICK_PURPOSE)).placeholder(words.none.clone()).show(ui);
|
||||
let out =
|
||||
PathSetting::new(label.clone(), &folder_key, draft, PickRequest::folder(PICK_PURPOSE)).placeholder(words.none.clone()).show(ui);
|
||||
changed |= out.changed;
|
||||
browsing = browsing.or(out.browsing);
|
||||
}
|
||||
|
||||
@@ -87,7 +87,19 @@ pub struct Wheel {
|
||||
impl Wheel {
|
||||
/// A scroll of `scroll` points with no zoom.
|
||||
pub const fn new(scroll: Vec2, mods: Mods, unit: WheelUnit, phase: WheelPhase) -> Self {
|
||||
Wheel { scroll, zoom: 1.0, mods, unit, phase, source: WheelSource::Unknown, at: None, zooms: false, touch_zoom: 1.0, rotation: 0.0, touch_rotation: 0.0 }
|
||||
Wheel {
|
||||
scroll,
|
||||
zoom: 1.0,
|
||||
mods,
|
||||
unit,
|
||||
phase,
|
||||
source: WheelSource::Unknown,
|
||||
at: None,
|
||||
zooms: false,
|
||||
touch_zoom: 1.0,
|
||||
rotation: 0.0,
|
||||
touch_rotation: 0.0,
|
||||
}
|
||||
}
|
||||
|
||||
/// The same gesture with zoom factor `zoom`.
|
||||
@@ -495,9 +507,7 @@ fn split_at<O: Copy + PartialEq>(
|
||||
under.sort_by(|a, b| a.rect.area().total_cmp(&b.rect.area()));
|
||||
// A trackpad steps a value control only while it is focused or armed: over anything else it scrolls the panel.
|
||||
let fingers = wheel.source.fingers();
|
||||
let open = |taker: &WheelTaker<O>| {
|
||||
(!taker.gated && !(fingers && taker.value)) || armed == Some(taker.owner) || focused == Some(taker.owner)
|
||||
};
|
||||
let open = |taker: &WheelTaker<O>| (!taker.gated && !(fingers && taker.value)) || armed == Some(taker.owner) || focused == Some(taker.owner);
|
||||
// The running gesture's owner, while it is registered and open; it takes its axes wherever the pointer is. A
|
||||
// focused field holds the wheel by the field rule alone, so a wheel with Alt or Cmd/Ctrl still reaches the view.
|
||||
let held: Option<&WheelTaker<O>> = latch
|
||||
|
||||
@@ -388,7 +388,8 @@ fn the_info_panel_shows_the_rulers_measure_while_it_has_one() {
|
||||
assert_eq!(measure_names(Some(InfoMeasure::protractor("45.0°", "200.00", "141.42"))), [true, false, true, true], "a protractor: A, L1 and L2");
|
||||
assert_eq!(measure_names(None), [false; 4], "no ruler, no measure names");
|
||||
let mut fixture = Fixture::new(|ui| {
|
||||
let readings = craft_color::ui::InfoReadings::new().measure(Some(InfoMeasure::protractor("45.0°", "200.00", "141.42"))).document(Some([640, 480]));
|
||||
let readings =
|
||||
craft_color::ui::InfoReadings::new().measure(Some(InfoMeasure::protractor("45.0°", "200.00", "141.42"))).document(Some([640, 480]));
|
||||
let _ = craft_color::ui::InfoPanel::new("Info", &readings).show(ui);
|
||||
});
|
||||
fixture.settle();
|
||||
|
||||
@@ -27,8 +27,8 @@ const CLOSED: &[&str] = &[
|
||||
"SetPosition",
|
||||
"States",
|
||||
"StateMix",
|
||||
"ShowReadouts", // the one Show Transformation Values flag: a bool, fixed by meaning
|
||||
"PenDraft", // whose anchors a pen draft holds: own or foreign, fixed by meaning
|
||||
"ShowReadouts", // the one Show Transformation Values flag: a bool, fixed by meaning
|
||||
"PenDraft", // whose anchors a pen draft holds: own or foreign, fixed by meaning
|
||||
"CollectionEvent", // built or matched in craft-ui-patterns
|
||||
"ColumnAlign", // built or matched in craft-ui-widgets
|
||||
"ColumnEvent", // built or matched in craft-ui-widgets
|
||||
|
||||
@@ -15,8 +15,8 @@ mod words;
|
||||
use kurbo::Point;
|
||||
|
||||
pub use style::CornerStyle;
|
||||
pub use widgets::{CornerWidgets, CornerWidgetsOutput};
|
||||
pub(crate) use widgets::paint_widget;
|
||||
pub use widgets::{CornerWidgets, CornerWidgetsOutput};
|
||||
pub use words::CornerWords;
|
||||
|
||||
/// How a corner is cut. Only shown and cycled with [`CornerWidgets::kinds`] (VectorCraft).
|
||||
|
||||
@@ -82,7 +82,9 @@ pub use gradient::{
|
||||
GradientGroup, GradientItem, GradientLine, GradientMap, GradientMapEditor, GradientMapOutput, GradientOverlay, GradientPalette, GradientRef,
|
||||
GradientSwatch, LineGradient, LinePart,
|
||||
};
|
||||
pub use measure::{MIN_LINE, RulerBar, RulerBarOutput, RulerLine, RulerOverlay, RulerPass, RulerTool, RulerWords, box_distances, ruler_line_form, show_ruler};
|
||||
pub use measure::{
|
||||
MIN_LINE, RulerBar, RulerBarOutput, RulerLine, RulerOverlay, RulerPass, RulerTool, RulerWords, box_distances, ruler_line_form, show_ruler,
|
||||
};
|
||||
pub use paint_bar::{
|
||||
EraserMode, MIXER_COMBINATIONS, MIXER_GROUP_STARTS, MixerValues, PaintBar, PaintBarOutput, PaintBarWords, PaintTool, PaintValues, Smoothing,
|
||||
};
|
||||
|
||||
@@ -57,12 +57,7 @@ pub struct AdjustDialogCx<'a> {
|
||||
impl<'a> AdjustDialogCx<'a> {
|
||||
/// The context for an editor shown in `context` over the dialog's own `picker`, `channel` and `clipping` state, with
|
||||
/// no canvas, no curve point to select and no edit phase; the fields set the rest.
|
||||
pub fn new(
|
||||
context: AdjustContext,
|
||||
picker: &'a mut Option<TonePicker>,
|
||||
channel: &'a mut usize,
|
||||
clipping: &'a mut Option<LevelsClip>,
|
||||
) -> Self {
|
||||
pub fn new(context: AdjustContext, picker: &'a mut Option<TonePicker>, channel: &'a mut usize, clipping: &'a mut Option<LevelsClip>) -> Self {
|
||||
Self { context, canvas: None, picker, channel, select_point: None, clipping, edit: None }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@ use std::sync::{Arc, Mutex, PoisonError};
|
||||
|
||||
use craft_host::queue::Cancel;
|
||||
use craft_ui::primitives::{
|
||||
LoadFailure, LoadResult, LoadedPicture, LoaderOptions, Priority, Revision, TextureLoader, TextureState, TextureStatistics, TextureStore, TextureStoreOptions,
|
||||
LoadFailure, LoadResult, LoadedPicture, LoaderOptions, Priority, Revision, TextureLoader, TextureState, TextureStatistics, TextureStore,
|
||||
TextureStoreOptions,
|
||||
};
|
||||
use egui::{Color32, ColorImage, Context, TextureId, TextureOptions};
|
||||
|
||||
|
||||
@@ -96,7 +96,8 @@ pub fn read(text: &str) -> Result<ForeignSet, KysError> {
|
||||
return Err(KysError::TooLarge);
|
||||
}
|
||||
let text = text.trim_start_matches('\u{feff}');
|
||||
let options = Options { limits: Limits { max_depth: MAX_DEPTH, ..Limits::DEFAULT }, doctype: Doctype::Reject, strict: true, ..Options::default() };
|
||||
let options =
|
||||
Options { limits: Limits { max_depth: MAX_DEPTH, ..Limits::DEFAULT }, doctype: Doctype::Reject, strict: true, ..Options::default() };
|
||||
let mut events = options.events(text.as_bytes());
|
||||
let not_a_set = |e: craft_xml::Error| KysError::NotASet(e.to_string());
|
||||
let (mut depth, mut rooted, mut set_name) = (0_usize, false, None);
|
||||
|
||||
@@ -34,9 +34,5 @@ fn a_row_left_out_of_the_style_takes_no_input_and_its_check_includes_it() {
|
||||
|
||||
let include = fixture.by_label("Include Font size").expect("the include check is shown");
|
||||
fixture.click(&include).idle(4);
|
||||
assert_eq!(
|
||||
changes(&edits),
|
||||
vec![StyleOptionsChange::include(StyleAttribute::Size, true)],
|
||||
"the check of a row that is not included includes it"
|
||||
);
|
||||
assert_eq!(changes(&edits), vec![StyleOptionsChange::include(StyleAttribute::Size, true)], "the check of a row that is not included includes it");
|
||||
}
|
||||
|
||||
@@ -1313,6 +1313,10 @@ fn readout_during_a_drag(hud: bool, shown: Option<bool>) -> (bool, bool) {
|
||||
#[trial]
|
||||
fn show_transformation_values_gates_the_readouts_paint_and_never_the_hud() {
|
||||
assert_eq!(readout_during_a_drag(false, None), (true, true), "by default a tool's readout paints and is reported");
|
||||
assert_eq!(readout_during_a_drag(false, Some(false)), (false, true), "Show Transformation Values off: nothing paints, the rows are still reported");
|
||||
assert_eq!(
|
||||
readout_during_a_drag(false, Some(false)),
|
||||
(false, true),
|
||||
"Show Transformation Values off: nothing paints, the rows are still reported"
|
||||
);
|
||||
assert_eq!(readout_during_a_drag(true, Some(false)), (true, true), "a hud paints with Show Transformation Values off");
|
||||
}
|
||||
|
||||
@@ -289,7 +289,10 @@ fn the_rotate_commands_step_fifteen_degrees_on_screen_in_a_flipped_view_too() {
|
||||
let mut view = before;
|
||||
assert!(command.apply(&mut view, &target, 1.0), "{command:?} turns the view");
|
||||
let turned_by = (angle(&view) - angle(&before) + 540.0).rem_euclid(360.0) - 180.0;
|
||||
assert!((turned_by - screen_turn).abs() < 0.01, "flip {flip_x}: {command:?} turns the image {screen_turn} degrees on screen, got {turned_by}");
|
||||
assert!(
|
||||
(turned_by - screen_turn).abs() < 0.01,
|
||||
"flip {flip_x}: {command:?} turns the image {screen_turn} degrees on screen, got {turned_by}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
use crate::primitives::SvgIcon;
|
||||
use crate::runtime::cursor::{CursorArt, CursorBitmap};
|
||||
use egui::{Color32, Painter, Pos2, Rect, Shape, Stroke, Vec2};
|
||||
use craft_svg::tree::draw::tiny_skia;
|
||||
use egui::{Color32, Painter, Pos2, Rect, Shape, Stroke, Vec2};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// How far past a mark's geometry its antialiasing reaches, in device pixels.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! The SVG icon catalog the build embeds, the app icon sets registered beside it, and their rasteriser.
|
||||
|
||||
use egui::{Color32, ColorImage};
|
||||
use craft_svg::tree::draw::{self as svg_draw, tiny_skia};
|
||||
use egui::{Color32, ColorImage};
|
||||
use std::sync::{PoisonError, RwLock};
|
||||
|
||||
use super::svg_tree;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! The intents routed to a component and what it leaves untaken: Submit, Cancel, Escape and context requests.
|
||||
|
||||
use super::{Stage, current};
|
||||
use super::route::push;
|
||||
use super::{Stage, current};
|
||||
use crate::runtime::focus::{self};
|
||||
use craft_behavior::focus::{EscapeFacts, EscapeStep, escape_step};
|
||||
use craft_behavior::{AccessRequest, CancelRule, EditCommand, EditorInput, Intent, MoveMods, NavMove, PartRef};
|
||||
|
||||
@@ -288,7 +288,8 @@ fn a_full_window_viewport_fills_the_main_window_without_viewports_and_opens_its_
|
||||
/// in, and the dialog stays open.
|
||||
#[trial]
|
||||
fn a_viewport_mount_stays_in_a_full_screen_or_wayland_maximized_window() {
|
||||
let state = |fullscreen: bool, maximized: bool| ViewportInfo { fullscreen: Some(fullscreen), maximized: Some(maximized), ..ViewportInfo::default() };
|
||||
let state =
|
||||
|fullscreen: bool, maximized: bool| ViewportInfo { fullscreen: Some(fullscreen), maximized: Some(maximized), ..ViewportInfo::default() };
|
||||
let frame = |windows: &Windows| {
|
||||
windows.frame(vec![], vec![], |ui| {
|
||||
Palette::full_window("Workspace").show(ui, |_, _| {});
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
use super::PathSetting;
|
||||
use crate::patterns::preferences::SettingsDraft;
|
||||
use craft_host::PickRequest;
|
||||
use crate::testing::{Drive, StoryData, StoryOutput, story};
|
||||
use craft_host::PickRequest;
|
||||
use egui::Ui;
|
||||
|
||||
fn draft(path: &str) -> SettingsDraft {
|
||||
|
||||
@@ -31,10 +31,7 @@ fn texture() -> SizedTexture {
|
||||
|
||||
/// Two side-by-side slices, 1 on the left half and 2 on the right.
|
||||
fn slices() -> Vec<WebSlice> {
|
||||
[(1, 0.0), (2, 100.0)]
|
||||
.into_iter()
|
||||
.map(|(number, left)| WebSlice::new(number, Rect::from_min_size(pos2(left, 0.0), vec2(100.0, 100.0))))
|
||||
.collect()
|
||||
[(1, 0.0), (2, 100.0)].into_iter().map(|(number, left)| WebSlice::new(number, Rect::from_min_size(pos2(left, 0.0), vec2(100.0, 100.0)))).collect()
|
||||
}
|
||||
|
||||
/// A host running `web` every pass, in a room large enough for the dialog.
|
||||
|
||||
@@ -116,11 +116,7 @@ fn relative_columns() {
|
||||
|
||||
/// A degenerate or negative column size falls back to 180 pt / 12 pt, a negative gutter counts as none.
|
||||
fn degenerate_column_sizes() {
|
||||
let degenerate = [
|
||||
ColumnSize::new(0.0, f64::NAN),
|
||||
ColumnSize::new(f64::NAN, f64::INFINITY),
|
||||
ColumnSize::new(-5.0, f64::NAN),
|
||||
];
|
||||
let degenerate = [ColumnSize::new(0.0, f64::NAN), ColumnSize::new(f64::NAN, f64::INFINITY), ColumnSize::new(-5.0, f64::NAN)];
|
||||
for column_size in degenerate {
|
||||
let mut size = document().column_size(column_size);
|
||||
assert!(size.set_width_unit(UnitKind::Columns));
|
||||
|
||||
@@ -14,16 +14,15 @@ fn rig(source: Option<HistoryKey>, with_source: bool) -> (Fixture, Seen) {
|
||||
let seen: Seen = Rc::new(RefCell::new(Vec::new()));
|
||||
let sink = seen.clone();
|
||||
let rows = vec![HistoryRow::state(1, "Open"), HistoryRow::state(2, "Brush"), HistoryRow::state(3, "Fill"), HistoryRow::snapshot(7, "Snapshot 1")];
|
||||
let fixture =
|
||||
Fixture::new(move |ui| {
|
||||
let mut panel = HistoryPanel::new(&rows, Some(HistoryKey::State(2)))
|
||||
.can_delete(|key| *key != HistoryKey::State(1))
|
||||
.footer(HistoryFooter::default().delete(true));
|
||||
if with_source {
|
||||
panel = panel.source(source);
|
||||
}
|
||||
sink.borrow_mut().extend(panel.show(ui).events);
|
||||
});
|
||||
let fixture = Fixture::new(move |ui| {
|
||||
let mut panel = HistoryPanel::new(&rows, Some(HistoryKey::State(2)))
|
||||
.can_delete(|key| *key != HistoryKey::State(1))
|
||||
.footer(HistoryFooter::default().delete(true));
|
||||
if with_source {
|
||||
panel = panel.source(source);
|
||||
}
|
||||
sink.borrow_mut().extend(panel.show(ui).events);
|
||||
});
|
||||
(fixture, seen)
|
||||
}
|
||||
|
||||
|
||||
@@ -61,8 +61,7 @@ fn a_path_setting_writes_the_picked_folder_into_its_draft_entry() {
|
||||
});
|
||||
fixture.host(Arc::new(Host::builder(AppInfo { id: "test", name: "Test", version: "1.0" }).files(files.clone()).build()));
|
||||
fixture.settle();
|
||||
let browse: Vec<_> =
|
||||
fixture.by_role(Role::BUTTON).into_iter().filter(|button| fixture.tree().name_of(button.node) == Some("Browse…")).collect();
|
||||
let browse: Vec<_> = fixture.by_role(Role::BUTTON).into_iter().filter(|button| fixture.tree().name_of(button.node) == Some("Browse…")).collect();
|
||||
assert_eq!(browse.len(), 2, "one Browse per entry");
|
||||
fixture.click(&browse[1]);
|
||||
fixture.settle();
|
||||
|
||||
@@ -32,9 +32,17 @@ fn hostile_svgs_render_nothing() {
|
||||
/// Icons parse on the UI thread: a document nested deeper than its stack takes is refused, not a stack overflow.
|
||||
#[trial]
|
||||
fn an_icon_nested_past_its_depth_is_refused_not_a_crash() {
|
||||
let deep = format!(r#"<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16">{}<path d="M4 4h8v8H4z"/>{}</svg>"#, "<g>".repeat(200), "</g>".repeat(200));
|
||||
let deep = format!(
|
||||
r#"<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16">{}<path d="M4 4h8v8H4z"/>{}</svg>"#,
|
||||
"<g>".repeat(200),
|
||||
"</g>".repeat(200)
|
||||
);
|
||||
assert!(mask_of(deep.as_bytes(), GLYPH_PX).is_none());
|
||||
let shallow = format!(r#"<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16">{}<path d="M4 4h8v8H4z"/>{}</svg>"#, "<g>".repeat(8), "</g>".repeat(8));
|
||||
let shallow = format!(
|
||||
r#"<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16">{}<path d="M4 4h8v8H4z"/>{}</svg>"#,
|
||||
"<g>".repeat(8),
|
||||
"</g>".repeat(8)
|
||||
);
|
||||
assert!(mask_of(shallow.as_bytes(), GLYPH_PX).is_some_and(|mask| mask.iter().any(|coverage| *coverage > 0)), "a shallow icon draws");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user