mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-22 18:41:27 +01:00
rustfmt framework batch 4
This commit is contained in:
7 files changed
+25
-37
No files matched your search
@@ -174,10 +174,9 @@ fn lower_nodes(nodes: &[Node], targets: &mut HashMap<String, Target>) -> Vec<nat
|
||||
.map(|n| match n {
|
||||
Node::Separator => native::Node::Separator,
|
||||
// A native submenu is disabled while it has no children: a disabled one goes over empty.
|
||||
Node::Submenu { label, children, enabled, .. } => native::Node::Submenu {
|
||||
label: label.clone(),
|
||||
children: if *enabled { lower_nodes(children, targets) } else { Vec::new() },
|
||||
},
|
||||
Node::Submenu { label, children, enabled, .. } => {
|
||||
native::Node::Submenu { label: label.clone(), children: if *enabled { lower_nodes(children, targets) } else { Vec::new() } }
|
||||
}
|
||||
Node::Standard { kind, label } => native::Node::Platform {
|
||||
kind: match kind {
|
||||
Standard::Services => native::Platform::Services,
|
||||
|
||||
@@ -450,8 +450,12 @@ impl<'a> PageView<'a> {
|
||||
// The canvas keeps the view inside the shown row, as the pass does, so a wheel share that cannot pan a row at its
|
||||
// edge leaves the gesture unmoved and a page turn can follow it.
|
||||
navigation.overscroll = false;
|
||||
let canvas =
|
||||
Canvas::new(label.clone()).view(given).navigation(navigation).keys_to_body(true).body_nudges(KeyMoves::NUDGES).document(frame.document(&geo));
|
||||
let canvas = Canvas::new(label.clone())
|
||||
.view(given)
|
||||
.navigation(navigation)
|
||||
.keys_to_body(true)
|
||||
.body_nudges(KeyMoves::NUDGES)
|
||||
.document(frame.document(&geo));
|
||||
let mut held = Held::new(Bind::bound(state));
|
||||
let mut seen: Option<Seen> = None;
|
||||
let mut canvas_body = |ui: &mut Ui, cx: &mut BodyCx<'_>| {
|
||||
@@ -983,11 +987,8 @@ struct KeyMoves {
|
||||
|
||||
impl KeyMoves {
|
||||
/// The arrow modifiers `of` reads besides the plain arrows: Cmd or Ctrl, alone or with Shift. Alt is the app's.
|
||||
const NUDGES: NudgeMods = NudgeMods::NONE
|
||||
.with(Mods::CMD)
|
||||
.with(Mods::CTRL)
|
||||
.with(Mods { shift: true, ..Mods::CMD })
|
||||
.with(Mods { shift: true, ..Mods::CTRL });
|
||||
const NUDGES: NudgeMods =
|
||||
NudgeMods::NONE.with(Mods::CMD).with(Mods::CTRL).with(Mods { shift: true, ..Mods::CMD }).with(Mods { shift: true, ..Mods::CTRL });
|
||||
|
||||
/// Page Up and Down a screen less a key line (a row when not continuous, and with Cmd), Home and End the first
|
||||
/// and last page, Up and Down a key line (not continuous, a turn once the row is at its edge that way), Left and
|
||||
|
||||
@@ -847,11 +847,8 @@ impl AnnotateTool {
|
||||
// shape without adding one.
|
||||
self.finish_poly(kind, &reading.words);
|
||||
} else {
|
||||
let next = if pointer.mods.shift {
|
||||
self.poly.last().map_or(at, |&last| self.select_options.shift_lock.apply(last, at))
|
||||
} else {
|
||||
at
|
||||
};
|
||||
let next =
|
||||
if pointer.mods.shift { self.poly.last().map_or(at, |&last| self.select_options.shift_lock.apply(last, at)) } else { at };
|
||||
let repeat = reading.view.doc_len(REPEAT_POINT);
|
||||
if !self.poly.last().is_some_and(|&last| (last - next).hypot() < repeat) {
|
||||
self.poly.push(next);
|
||||
|
||||
@@ -691,9 +691,9 @@ fn place_and_erase_drags_paint_their_preview_while_held() {
|
||||
let held_shapes = callout_rig.fixture().frame_shapes();
|
||||
let held_paths = colored_paths(&held_shapes, stroke_color);
|
||||
assert!(
|
||||
held_paths
|
||||
.iter()
|
||||
.any(|p| p.points.len() == 2 && (p.points[0] - on_screen(&callout_rig, from)).length() < 0.5 && (p.points[1] - on_screen(&callout_rig, to)).length() < 0.5),
|
||||
held_paths.iter().any(|p| p.points.len() == 2
|
||||
&& (p.points[0] - on_screen(&callout_rig, from)).length() < 0.5
|
||||
&& (p.points[1] - on_screen(&callout_rig, to)).length() < 0.5),
|
||||
"Callout drag paints its leader preview while held: {held_paths:?}"
|
||||
);
|
||||
release_drag(&mut callout_rig, to, Modifiers::NONE);
|
||||
@@ -718,10 +718,7 @@ fn place_and_erase_drags_paint_their_preview_while_held() {
|
||||
hold_drag(&mut eraser_rig, Point::new(60.0, 100.0), Point::new(220.0, 100.0), Modifiers::NONE);
|
||||
let held_shapes = eraser_rig.fixture().frame_shapes();
|
||||
assert_eq!(swath_widths(&held_shapes).len(), 1, "radius {radius}: swath painted at twice the radius while held");
|
||||
let cap_circles = held_shapes
|
||||
.iter()
|
||||
.filter(|shape| matches!(shape, Shape::Circle(c) if (c.radius - radius).abs() < 0.1))
|
||||
.count();
|
||||
let cap_circles = held_shapes.iter().filter(|shape| matches!(shape, Shape::Circle(c) if (c.radius - radius).abs() < 0.1)).count();
|
||||
assert!(cap_circles >= 2, "radius {radius}: swath paints round dots along its path: {cap_circles}");
|
||||
release_drag(&mut eraser_rig, Point::new(220.0, 100.0), Modifiers::NONE);
|
||||
let after_shapes = eraser_rig.fixture().frame_shapes();
|
||||
|
||||
@@ -412,14 +412,8 @@ fn a_heading_puts_its_count_in_its_access_name() {
|
||||
});
|
||||
fixture.in_room(Room::Panel).settle();
|
||||
let names = row_names(&fixture);
|
||||
assert!(
|
||||
names.iter().any(|name| name.contains("Page 1") && name.contains('3')),
|
||||
"Page 1's heading carries its unfiltered count 3: {names:?}"
|
||||
);
|
||||
assert!(
|
||||
names.iter().any(|name| name.contains("Page 2") && name.contains('1')),
|
||||
"Page 2's heading carries its unfiltered count 1: {names:?}"
|
||||
);
|
||||
assert!(names.iter().any(|name| name.contains("Page 1") && name.contains('3')), "Page 1's heading carries its unfiltered count 3: {names:?}");
|
||||
assert!(names.iter().any(|name| name.contains("Page 2") && name.contains('1')), "Page 2's heading carries its unfiltered count 1: {names:?}");
|
||||
|
||||
state.borrow_mut().sort = CommentSort::Type;
|
||||
fixture.settle();
|
||||
|
||||
@@ -373,7 +373,8 @@ pub(crate) fn run(state: &mut TextState, mut input: AdapterIn<'_>) -> AdapterOut
|
||||
// A clearing field takes Escape while it shows text, with or without a draft, and passes it on once it is empty. In
|
||||
// a dialog a draft leaves Escape to the dialog's Cancel, which discards it with the dialog's other edits.
|
||||
let draft_takes = state.draft.is_some() && !(focused_before && keys::focus_in_dialog(ctx));
|
||||
let takes_escape = if input.options.clear_on_escape { !base.is_empty() || state.preedit.is_some() } else { draft_takes || state.preedit.is_some() };
|
||||
let takes_escape =
|
||||
if input.options.clear_on_escape { !base.is_empty() || state.preedit.is_some() } else { draft_takes || state.preedit.is_some() };
|
||||
if focused_before && takes_escape && !state.completions.open && !input.list_open && input.intents.take(Intent::Cancel) {
|
||||
// Escape over a composition alone ends the composition and leaves the text.
|
||||
if state.draft.is_some() || state.preedit.is_none() {
|
||||
|
||||
@@ -813,14 +813,13 @@ fn escape_in_a_text_field_closes_the_form_dialog_typed_or_not() {
|
||||
let mut fixture = Fixture::new(move |ui| {
|
||||
let mut is_open = shown.get();
|
||||
let mut text = value.borrow_mut();
|
||||
let out = craft_ui::patterns::form_dialogs::FormDialog::new("Protect", Bind::bound(&mut *text)).opened(Bind::bound(&mut is_open)).show(
|
||||
ui,
|
||||
|ui, _, text| {
|
||||
let out = craft_ui::patterns::form_dialogs::FormDialog::new("Protect", Bind::bound(&mut *text))
|
||||
.opened(Bind::bound(&mut is_open))
|
||||
.show(ui, |ui, _, text| {
|
||||
let field = craft_ui::text::TextField::new("Type Password", Bind::bound(text));
|
||||
let _ = if masked { field.masked() } else { field }.show(ui);
|
||||
true
|
||||
},
|
||||
);
|
||||
});
|
||||
shown.set(is_open);
|
||||
seen.set(seen.get() || out.closed.is_some());
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user