mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-17 19:14:26 +00:00
cargo fmt
This commit is contained in:
@@ -71,9 +71,7 @@ impl<P: Clone + Eq + Hash> Layout<P> {
|
||||
let allowed = policy.movable
|
||||
&& match to {
|
||||
Target::Float { .. } => policy.floatable,
|
||||
Target::At { anchor, placement } => {
|
||||
placement.allowed_by(permissions(anchor)) && (!floats(anchor) || policy.floatable)
|
||||
}
|
||||
Target::At { anchor, placement } => placement.allowed_by(permissions(anchor)) && (!floats(anchor) || policy.floatable),
|
||||
Target::NewDock { .. } => true,
|
||||
};
|
||||
if !allowed {
|
||||
|
||||
@@ -143,7 +143,11 @@ fn the_checkerboard_starts_with_a_light_cell_at_the_document_corner() {
|
||||
let at_corner = checker.vertices.iter().find(|vertex| vertex.pos.distance(corner) < 0.5).expect("a checkerboard corner at the document's");
|
||||
let whole = |v: f32| (v - v.round()).abs() < 1e-3;
|
||||
// The texture repeats every two cells, light first: a whole texture coordinate is a light cell's top-left.
|
||||
assert!(whole(at_corner.uv.x) && whole(at_corner.uv.y), "{width} x {height} at {zoom}: a light cell starts at the document's corner: {:?}", at_corner.uv);
|
||||
assert!(
|
||||
whole(at_corner.uv.x) && whole(at_corner.uv.y),
|
||||
"{width} x {height} at {zoom}: a light cell starts at the document's corner: {:?}",
|
||||
at_corner.uv
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,10 +19,10 @@ use craft_ui::runtime::commands::{CommandGate, CommandSet as _};
|
||||
use craft_ui::runtime::frame;
|
||||
use craft_ui::runtime::windows::WindowHost;
|
||||
use craft_ui::style::DataColor;
|
||||
use craft_ui::text::NumberField;
|
||||
use craft_ui::testing::input::key_press;
|
||||
use craft_ui::testing::layout::in_region;
|
||||
use craft_ui::testing::{Fixture, ToolFixture, pointer, trial};
|
||||
use craft_ui::text::NumberField;
|
||||
use egui::{Color32, Id, Key, Modifiers, Pos2, Rect, Shape, Vec2};
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::rc::Rc;
|
||||
|
||||
@@ -1202,7 +1202,8 @@ pub(crate) fn begin(ctx: &Context) {
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
let Some(hit) = keys.press(&shortcuts.layout, &shortcut.input, shortcuts.typing && !shortcut.canvas, Some((&mut matcher, now))) else {
|
||||
let Some(hit) = keys.press(&shortcuts.layout, &shortcut.input, shortcuts.typing && !shortcut.canvas, Some((&mut matcher, now)))
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
let (app, instance) = with(ctx, |board| board.target_of(ctx, &hit.command, &board.here));
|
||||
|
||||
@@ -40,7 +40,8 @@ pub use intents::settle;
|
||||
pub use intents::take_submit;
|
||||
pub use intents::with_window_intents;
|
||||
pub(crate) use intents::{
|
||||
Lent, context_part, context_request, give_back, lend, request_context, route_whole_reset, scope_escape, take_cancel, take_every_escape, take_window_cancel,
|
||||
Lent, context_part, context_request, give_back, lend, request_context, route_whole_reset, scope_escape, take_cancel, take_every_escape,
|
||||
take_window_cancel,
|
||||
};
|
||||
pub(crate) use nodes::{redirect_node, register_expanded, register_node};
|
||||
pub use route::focus_holds;
|
||||
|
||||
@@ -704,9 +704,11 @@ fn layer_past_window(ctx: &Context, viewport: ViewportId, at: Pos2) -> Option<La
|
||||
PerViewport::<Shapes>::with(ctx, viewport, |record| {
|
||||
record.last.get(layer).is_some_and(|roots| {
|
||||
roots.values().any(|entry| {
|
||||
entry.shapes.iter().zip(&entry.placed).any(|(shape, placed)| {
|
||||
shape.sense.takes_press() && shape.hits(point) && shape.shape.bounds().intersects(placed.clip)
|
||||
})
|
||||
entry
|
||||
.shapes
|
||||
.iter()
|
||||
.zip(&entry.placed)
|
||||
.any(|(shape, placed)| shape.sense.takes_press() && shape.hits(point) && shape.shape.bounds().intersects(placed.clip))
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -735,7 +737,9 @@ fn diag_layers(ctx: &Context, viewport: ViewportId, at: Pos2, chosen: Layer, tes
|
||||
.iter()
|
||||
.zip(&entry.placed)
|
||||
.filter(|(shape, _)| shape.hits(point))
|
||||
.map(|(shape, placed)| format!("{} {:?} {:?} clip_in {}", diag_id(shape.owner), shape.part, shape.sense, placed.clip.contains(point)))
|
||||
.map(|(shape, placed)| {
|
||||
format!("{} {:?} {:?} clip_in {}", diag_id(shape.owner), shape.part, shape.sense, placed.clip.contains(point))
|
||||
})
|
||||
.collect();
|
||||
format!("root {} shapes {} under {under:?}", diag_id(*root), entry.shapes.len())
|
||||
})
|
||||
|
||||
@@ -8,9 +8,9 @@ use super::words::DockWords;
|
||||
use super::{PanelDrag, PanelKey, PanelTitle};
|
||||
use crate::buttons::IconButton;
|
||||
use crate::contract::{
|
||||
Access, Bind, BindMut, BodyCx, Common, Component, Container, ContainerProps, ContextMenuRequest, Cx, HeaderEdge, HeaderParts, HeaderRegion, ListDrag, MeasureCx,
|
||||
Name, Outcome, OverlayUi, Overlays as _, PaintUi, PartsCx, Pointer as _, PopupKind, Props as _, Role, ShowCollection as _, ShowContainer as _,
|
||||
Sizing, WordSetCx as _,
|
||||
Access, Bind, BindMut, BodyCx, Common, Component, Container, ContainerProps, ContextMenuRequest, Cx, HeaderEdge, HeaderParts, HeaderRegion,
|
||||
ListDrag, MeasureCx, Name, Outcome, OverlayUi, Overlays as _, PaintUi, PartsCx, Pointer as _, PopupKind, Props as _, Role, ShowCollection as _,
|
||||
ShowContainer as _, Sizing, WordSetCx as _,
|
||||
};
|
||||
use crate::menu::{GroupItem, Menu, PanelMenu, PanelRow};
|
||||
use crate::runtime::commands::{CommandSet as _, CommandState, Commands as _};
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
use super::stories::tools;
|
||||
use super::{LastUsed, ToolRail, ToolSlot};
|
||||
use crate::buttons::Button;
|
||||
use crate::contract::Show as _;
|
||||
use crate::contract::Props as _;
|
||||
use crate::contract::Show as _;
|
||||
use crate::testing::pointer::{moved, wheel};
|
||||
use crate::testing::relations::{above, grows_with};
|
||||
use crate::testing::{Fixture, trial};
|
||||
|
||||
@@ -6,8 +6,8 @@ use craft_quit::{CloseAnswer, CloseScope};
|
||||
use craft_ui::contract::{Common, Component, Cx, MeasureCx, PartsCx, Props as _, Role, Show as _, ShowContainer as _};
|
||||
use craft_ui::dialog::stories::hosted;
|
||||
use craft_ui::dialog::{
|
||||
Alert, Dialog, DialogHost, DialogId, DialogResult, DialogStack, HostedAlert, PromptKind, StackDialog, StandardPrompt, StartupStage, UnsavedChangesDialog,
|
||||
dialog_id,
|
||||
Alert, Dialog, DialogHost, DialogId, DialogResult, DialogStack, HostedAlert, PromptKind, StackDialog, StandardPrompt, StartupStage,
|
||||
UnsavedChangesDialog, dialog_id,
|
||||
};
|
||||
use craft_ui::runtime::windows::{WindowHit, WindowHost};
|
||||
use craft_ui::sections::{DialogRole, FooterButton};
|
||||
|
||||
@@ -150,11 +150,8 @@ struct GridSizes {
|
||||
|
||||
impl GridSizes {
|
||||
fn of(cx: &StyleCx<'_>, card: bool, rows: RowHeight) -> GridSizes {
|
||||
let spacing = ArrangeSpacing::new(
|
||||
if card { cx.tokens.space.gap.section } else { cx.tokens.space.gap.stack },
|
||||
cx.tokens.space.gap.inline,
|
||||
rows.of(cx),
|
||||
);
|
||||
let spacing =
|
||||
ArrangeSpacing::new(if card { cx.tokens.space.gap.section } else { cx.tokens.space.gap.stack }, cx.tokens.space.gap.inline, rows.of(cx));
|
||||
GridSizes {
|
||||
card: cx.tokens.size.thumb.card,
|
||||
thumbs: [cx.tokens.size.thumb.sm, cx.tokens.size.thumb.md, cx.tokens.size.thumb.lg],
|
||||
|
||||
Reference in New Issue
Block a user