mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-21 10:01:42 +01:00
fmt: chrome framework batch
This commit is contained in:
1 parent
56f3ca1a4a
commit
def1c54d40
25 files changed
+55
-65
No files matched your search
@@ -233,11 +233,8 @@ impl<'a> GradientPalette<'a> {
|
||||
};
|
||||
let most = Env::of(ui).tokens.size.control.sm * MAX_ROWS;
|
||||
let shape = if square { CellShape::Square } else { CellShape::ratio(wide, high) };
|
||||
let mut browser = PresetBrowser::new(self.label, self.state, &rows)
|
||||
.cell_shape(shape)
|
||||
.tiles(PresetTiles::Chips)
|
||||
.room_height(most)
|
||||
.thumb(thumb);
|
||||
let mut browser =
|
||||
PresetBrowser::new(self.label, self.state, &rows).cell_shape(shape).tiles(PresetTiles::Chips).room_height(most).thumb(thumb);
|
||||
if let Some(selected) = self.selected {
|
||||
browser = browser.selected(selected);
|
||||
}
|
||||
|
||||
@@ -65,10 +65,8 @@ fn gradient_swatch(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
fn gradient_swatch_tiles(ui: &mut Ui, _: &mut StoryData) -> StoryOutput {
|
||||
let stops = GradientStops::new(vec![stop(0.0, [0.96, 0.65, 0.14]), stop(1.0, [0.24, 0.39, 0.87])]);
|
||||
let focus = egui::Rect::from_min_max(egui::pos2(0.25, 0.25), egui::pos2(0.5, 0.5));
|
||||
let mut tiles: Vec<(String, GradientTile)> = GradientStyle::ALL
|
||||
.into_iter()
|
||||
.map(|style| (format!("{style:?}"), GradientTile::Style { style, angle: -45.0 }))
|
||||
.collect();
|
||||
let mut tiles: Vec<(String, GradientTile)> =
|
||||
GradientStyle::ALL.into_iter().map(|style| (format!("{style:?}"), GradientTile::Style { style, angle: -45.0 })).collect();
|
||||
tiles.push(("Focus, circle".to_owned(), GradientTile::Focus { outline: FocusOutline::Circle, focus }));
|
||||
tiles.push(("Focus, rectangle".to_owned(), GradientTile::Focus { outline: FocusOutline::Rect, focus }));
|
||||
Stack::new().show(ui, |ui, _| {
|
||||
|
||||
@@ -77,11 +77,11 @@ pub use crop::{
|
||||
CropPresetList, CropPresetListOutput, CropSizeTarget, PerspectiveCropBar, PerspectiveCropBarOutput, PerspectiveCropPass, PerspectiveInput,
|
||||
};
|
||||
pub use crop::{PerspectiveCropQuad, PerspectiveQuad};
|
||||
pub use gradient::{GradientFill, GradientFillEditor, GradientFillEditorOutput, GradientFillWords, GradientStyle};
|
||||
pub use gradient::{
|
||||
FocusOutline, GradientGroup, GradientItem, GradientLine, GradientMap, GradientMapEditor, GradientMapOutput, GradientOverlay, GradientPalette,
|
||||
GradientRef, GradientSwatch, GradientTile, LineGradient, LinePart,
|
||||
};
|
||||
pub use gradient::{GradientFill, GradientFillEditor, GradientFillEditorOutput, GradientFillWords, GradientStyle};
|
||||
pub use measure::{
|
||||
MIN_LINE, RulerBar, RulerBarOutput, RulerLine, RulerOverlay, RulerPass, RulerTool, RulerWords, box_distances, ruler_line_form, show_ruler,
|
||||
};
|
||||
|
||||
@@ -246,10 +246,7 @@ impl LineLook {
|
||||
/// (on a level or upright line, the side). A line of no length, or one with free ends, has none.
|
||||
fn end_parts(&self) -> impl Iterator<Item = (BoxPart, Point)> {
|
||||
let boxed = self.ends == LineEnds::Box;
|
||||
[(self.from, self.to), (self.to, self.from)]
|
||||
.into_iter()
|
||||
.filter(move |_| boxed)
|
||||
.filter_map(|(end, other)| Some((end_part(end, other)?, end)))
|
||||
[(self.from, self.to), (self.to, self.from)].into_iter().filter(move |_| boxed).filter_map(|(end, other)| Some((end_part(end, other)?, end)))
|
||||
}
|
||||
|
||||
/// Each free end with its point, in [`LineEnds::Free`]; none when the ends are box handles.
|
||||
|
||||
@@ -32,11 +32,7 @@ fn on_canvas(ui: &mut Ui, data: &mut StoryData, make: impl for<'a> Fn(Bind<'a, B
|
||||
}
|
||||
|
||||
/// [`on_canvas`] with the box's whole output.
|
||||
fn shown_on_canvas(
|
||||
ui: &mut Ui,
|
||||
data: &mut StoryData,
|
||||
make: impl for<'a> Fn(Bind<'a, BoxState>) -> TransformBox<'a>,
|
||||
) -> Option<TransformBoxOutput> {
|
||||
fn shown_on_canvas(ui: &mut Ui, data: &mut StoryData, make: impl for<'a> Fn(Bind<'a, BoxState>) -> TransformBox<'a>) -> Option<TransformBoxOutput> {
|
||||
let state = data.value("box", BoxState::from_rect(PICTURE));
|
||||
let room = craft_ui::testing::stage(ui);
|
||||
let view = craft_ui::testing::canvas_story::story_view(room, ui.pixels_per_point(), PICTURE.center(), 100.0);
|
||||
|
||||
@@ -5,7 +5,9 @@ use std::rc::Rc;
|
||||
|
||||
use craft_behavior::EditEvent;
|
||||
use craft_color_ui::ui::gradient::{ColorStop, GradientStops};
|
||||
use craft_draw::ui::gradient::{FocusOutline, GradientFill, GradientFillEditor, GradientGroup, GradientItem, GradientRef, GradientStyle, GradientTile};
|
||||
use craft_draw::ui::gradient::{
|
||||
FocusOutline, GradientFill, GradientFillEditor, GradientGroup, GradientItem, GradientRef, GradientStyle, GradientTile,
|
||||
};
|
||||
use craft_theme::Srgba;
|
||||
use craft_ui::contract::{Bind, Role};
|
||||
use craft_ui::patterns::presets::PresetState;
|
||||
|
||||
@@ -98,7 +98,6 @@ pub struct EditorHandle {
|
||||
read_only: bool,
|
||||
}
|
||||
|
||||
|
||||
impl EditorHandle {
|
||||
/// The handle of the editor part step 8b set up.
|
||||
fn of(info: &EditorInfo) -> EditorHandle {
|
||||
|
||||
@@ -80,8 +80,8 @@ pub use hosted::{Hosted, HostedKey, Hosting};
|
||||
pub use items::lead_position;
|
||||
#[doc(hidden)]
|
||||
pub use items::put_toggle_names;
|
||||
pub use items::{measure_item, show_item, show_item_in_flow};
|
||||
pub use items::{ColumnCommands, SweepApply, SweepStep, item_part_open, request_rename, section_part};
|
||||
pub use items::{measure_item, show_item, show_item_in_flow};
|
||||
#[doc(hidden)]
|
||||
pub use label::colon_of;
|
||||
pub use label::{CellWidth, FieldLabelRole, FieldLayout, GlyphLabel, InsideLabel, LabelKind, LabelScheme, Scrub, SideLabel};
|
||||
|
||||
@@ -430,8 +430,8 @@ pub(crate) fn run<C: Component>(
|
||||
// The bound caret is compared with the widget's before anything else this pass moves it (AccessKit, Select All,
|
||||
// the typing): last pass reported the widget's caret, so only an app write differs here. A composition keeps its
|
||||
// caret.
|
||||
let caret_placed = state.preedit.is_none()
|
||||
&& adapter::place_caret(&ctx, widget, state.draft.as_deref().unwrap_or(&decl.shown), decl.options.caret);
|
||||
let caret_placed =
|
||||
state.preedit.is_none() && adapter::place_caret(&ctx, widget, state.draft.as_deref().unwrap_or(&decl.shown), decl.options.caret);
|
||||
serve_access(cx, &mut state, widget, &decl.shown, read_only);
|
||||
if std::mem::take(&mut state.select_all) {
|
||||
let len = state.draft.as_deref().unwrap_or(&decl.shown).chars().count();
|
||||
|
||||
@@ -20,11 +20,11 @@ pub use board::declare_child;
|
||||
#[doc(hidden)]
|
||||
pub use board::focus_within;
|
||||
pub use board::keymap;
|
||||
#[doc(hidden)]
|
||||
pub use board::note_page_root;
|
||||
#[cfg(feature = "testing")]
|
||||
#[doc(hidden)]
|
||||
pub use board::keymap_builds;
|
||||
#[doc(hidden)]
|
||||
pub use board::note_page_root;
|
||||
pub(crate) use board::publish as publish_for;
|
||||
pub(crate) use board::take as take_for_instance;
|
||||
pub(crate) use board::{
|
||||
|
||||
@@ -14,7 +14,6 @@ fn semantic(ui: &mut Ui, _: &mut StoryData) -> StoryOutput {
|
||||
StoryOutput::default()
|
||||
}
|
||||
|
||||
|
||||
// Each surface kind in the story's own theme, with the ink that reads on it.
|
||||
#[story(Surfaces<'static>, covers = [], drive = Drive::Never, title = "Surface kinds")]
|
||||
fn surface_kinds(ui: &mut Ui, _: &mut StoryData) -> StoryOutput {
|
||||
|
||||
@@ -57,8 +57,7 @@ impl PaneContent<u32> for Panes {
|
||||
/// The two panes around a document, each docking only at `edges`.
|
||||
fn area(ui: &mut Ui, edges: PaneEdges) -> StoryOutput {
|
||||
let size = &Env::of(ui).tokens.size;
|
||||
let mut content =
|
||||
Panes { float: Vec2::new(size.float.width, size.float.height), side: size.length.field.md, layers: layer_names(), edges };
|
||||
let mut content = Panes { float: Vec2::new(size.float.width, size.float.height), side: size.length.field.md, layers: layer_names(), edges };
|
||||
let open = [0_u32, 1];
|
||||
PaneArea::new("Panes", &open, &mut content)
|
||||
.show(ui, |ui, _| {
|
||||
|
||||
@@ -67,7 +67,8 @@ fn configured(
|
||||
) -> StoryOutput {
|
||||
// The palette binds two story values; it edits a copy of `open`, which goes back after the pass.
|
||||
let mut open = *data.value("open", open_at_start);
|
||||
let palette = CommandPalette::new("Command palette", ENTRIES.as_slice(), Bind::bound(&mut open)).recents(Bind::bound(data.value("recents", recents)));
|
||||
let palette =
|
||||
CommandPalette::new("Command palette", ENTRIES.as_slice(), Bind::bound(&mut open)).recents(Bind::bound(data.value("recents", recents)));
|
||||
let out = configure(palette).show(ui);
|
||||
*data.value("open", open_at_start) = open;
|
||||
let last = data.value("last", None::<String>);
|
||||
|
||||
@@ -9,8 +9,8 @@ use super::search::{self, Listed};
|
||||
use super::window::PreferencesState;
|
||||
use super::words::PreferencesWords;
|
||||
use crate::contract::{
|
||||
ActivateOn, Bind, CollectionEvent, NoValue, Outcome, Pattern, Props, Scroll, SelectMode, Show as _, ShowCollection as _,
|
||||
ShowContainer as _, Sizing,
|
||||
ActivateOn, Bind, CollectionEvent, NoValue, Outcome, Pattern, Props, Scroll, SelectMode, Show as _, ShowCollection as _, ShowContainer as _,
|
||||
Sizing,
|
||||
};
|
||||
use crate::display::{Divider, Shade, Text};
|
||||
use crate::form::FieldGroup;
|
||||
|
||||
@@ -85,8 +85,7 @@ fn an_app_tab_shows_after_models_and_is_a_tab_field_value() {
|
||||
fixture.idle(10);
|
||||
assert_eq!(drawn.load(Ordering::Relaxed), 0, "the dialog opens on About");
|
||||
|
||||
let tabs: Vec<String> =
|
||||
fixture.by_role(Role::TAB).iter().filter_map(|tab| access::name(fixture.tree(), tab.node).map(str::to_owned)).collect();
|
||||
let tabs: Vec<String> = fixture.by_role(Role::TAB).iter().filter_map(|tab| access::name(fixture.tree(), tab.node).map(str::to_owned)).collect();
|
||||
let models = tabs.iter().position(|name| name == "Models").expect("the strip lists Models");
|
||||
assert_eq!(tabs.get(models + 1).map(String::as_str), Some("Languages"), "the app tab follows Models: {tabs:?}");
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
//! `PreferencesPage` over a model with no draft: each edit reaches the model in the pass it lands in.
|
||||
|
||||
use craft_ui::contract::{Bind, Role};
|
||||
use craft_ui::patterns::preferences::{
|
||||
PageSpec, PrefValue, PreferencesModel, PreferencesPage, PreferencesState, PreferencesWords, RowKind, RowSpec,
|
||||
};
|
||||
use craft_ui::patterns::preferences::{PageSpec, PrefValue, PreferencesModel, PreferencesPage, PreferencesState, PreferencesWords, RowKind, RowSpec};
|
||||
use craft_ui::runtime::env::Env;
|
||||
use craft_ui::runtime::words::CommonWords;
|
||||
use craft_ui::testing::pointer::{moved, press, release};
|
||||
|
||||
@@ -708,11 +708,8 @@ impl<'a, S> AppShell<'a, S> {
|
||||
edges.extend(scope.revealed_rects());
|
||||
kept.reveal.record(edges);
|
||||
// The screen bar and the drop-down slot show by the mode, never by a reveal.
|
||||
let revealed = only
|
||||
&& slots
|
||||
.iter()
|
||||
.zip(&visible)
|
||||
.any(|(placed, shown)| *shown && !placed.slot.is_screen_bar() && !placed.slot.drops_down());
|
||||
let revealed =
|
||||
only && slots.iter().zip(&visible).any(|(placed, shown)| *shown && !placed.slot.is_screen_bar() && !placed.slot.drops_down());
|
||||
*cx.keep::<ShellState>() = kept;
|
||||
Parts { regions, revealed, panels_hidden, mode, dropped: dropped_shown }
|
||||
};
|
||||
|
||||
@@ -8,7 +8,8 @@ use super::start::{
|
||||
use super::words::ShellWords;
|
||||
use crate::buttons::Button;
|
||||
use crate::contract::{
|
||||
ActivateOn, BodyCx, CollectionEvent, Gap, Props as _, Remember as _, SelectMode, Show as _, ShowCollection as _, ShowContainer as _, Sizing, clicked,
|
||||
ActivateOn, BodyCx, CollectionEvent, Gap, Props as _, Remember as _, SelectMode, Show as _, ShowCollection as _, ShowContainer as _, Sizing,
|
||||
clicked,
|
||||
};
|
||||
use crate::list::{List, ListRow, RowEvent, ThumbAspect, ThumbSize, TrailingFace};
|
||||
use crate::menu::{Menu, MenuItem};
|
||||
|
||||
@@ -329,13 +329,7 @@ impl<'p> Page<'p> {
|
||||
/// The thumbnail of `key` in `rect`, asked for at the size it paints. The store paints the placeholder while the
|
||||
/// picture is not ready and the failure mark when it failed; a key the source has no picture for (`Blank`) gets the
|
||||
/// file icon on the sunken tile.
|
||||
pub(super) fn paint_thumb(
|
||||
cx: &ContentPainterCx,
|
||||
rect: Rect,
|
||||
thumbnails: &Thumbnails<ThumbKey>,
|
||||
source: &dyn ThumbSource<ThumbKey>,
|
||||
key: &ThumbKey,
|
||||
) {
|
||||
pub(super) fn paint_thumb(cx: &ContentPainterCx, rect: Rect, thumbnails: &Thumbnails<ThumbKey>, source: &dyn ThumbSource<ThumbKey>, key: &ThumbKey) {
|
||||
let request = ThumbRequest::for_cell(rect.width().max(rect.height()), cx.pixels_per_point());
|
||||
let state = thumbnails.state(cx.painter.ctx(), source, key, &request, Priority::VISIBLE);
|
||||
if thumbnails.paint(cx, rect, &state, &ThumbPaint::default()) {
|
||||
|
||||
@@ -215,11 +215,7 @@ fn caption_widths(windows: &Windows, runs: &mut PageRuns, names: &[&str]) -> Vec
|
||||
names
|
||||
.iter()
|
||||
.map(|name| {
|
||||
buttons
|
||||
.iter()
|
||||
.find(|key| tree.name_of(**key) == Some(*name))
|
||||
.and_then(|key| tree.bounds_of(*key))
|
||||
.map_or(0.0, |rect| rect.width())
|
||||
buttons.iter().find(|key| tree.name_of(**key) == Some(*name)).and_then(|key| tree.bounds_of(*key)).map_or(0.0, |rect| rect.width())
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
@@ -265,8 +261,7 @@ fn a_page_hides_the_slots_and_its_band_keeps_the_window_ends_and_moves_the_windo
|
||||
let bands = regions.moves.iter().filter(|area| band.rect.contains_rect(**area)).count();
|
||||
let to = free + egui::vec2(40.0, 0.0);
|
||||
let mut sent = Vec::new();
|
||||
for events in [vec![craft_ui::testing::pointer::moved(free)], vec![press(free)], vec![craft_ui::testing::pointer::moved(to)], vec![release(to)]]
|
||||
{
|
||||
for events in [vec![craft_ui::testing::pointer::moved(free)], vec![press(free)], vec![craft_ui::testing::pointer::moved(to)], vec![release(to)]] {
|
||||
sent.extend(page_frame(&windows, &mut runs, false, events));
|
||||
}
|
||||
assert!(sent.contains(&egui::ViewportCommand::StartDrag), "a drag of the free band moves the window: {sent:?}");
|
||||
|
||||
@@ -129,7 +129,10 @@ fn a_recent_row_names_its_full_path_and_reveals_remove_on_hover_or_focus() {
|
||||
fixture.idle(2);
|
||||
let revealed = fixture.by_role(Role::BUTTON);
|
||||
assert!(revealed.len() > buttons_focused - 1, "hovering a row keeps its remove part shown");
|
||||
let remove = revealed.into_iter().find(|button| row.rect.contains(button.center()) && button.center().x > row.center().x).expect("hovering the row reveals its remove part");
|
||||
let remove = revealed
|
||||
.into_iter()
|
||||
.find(|button| row.rect.contains(button.center()) && button.center().x > row.center().x)
|
||||
.expect("hovering the row reveals its remove part");
|
||||
fixture.click(&remove).idle(2);
|
||||
assert!(log.borrow().contains(&StartAction::RemoveRecent(poster)), "the remove part removes that row's file: {:?}", log.borrow());
|
||||
|
||||
|
||||
@@ -150,8 +150,7 @@ fn titled(title: &'static str) -> (Fixture, Rc<Cell<TitleSeen>>) {
|
||||
let out = Rc::clone(&seen);
|
||||
let mut fixture = Fixture::new(move |ui| {
|
||||
// The title shows whatever frame the trial's host decides.
|
||||
let shown =
|
||||
TitleBar::new().title_when_native().show_titled(ui, Title::new(title).action("Rename the document"), |_, _| {}, |_, _| {});
|
||||
let shown = TitleBar::new().title_when_native().show_titled(ui, Title::new(title).action("Rename the document"), |_, _| {}, |_, _| {});
|
||||
let mut now = out.get();
|
||||
now.bar = shown.response.rect;
|
||||
now.activations += usize::from(shown.title_activated);
|
||||
|
||||
@@ -87,8 +87,17 @@ pub struct Text {
|
||||
impl Text {
|
||||
/// `text`, which is also its accessible name, in body type and the normal shade.
|
||||
pub fn new(text: impl Into<Label>) -> Self {
|
||||
Text { common: Common::new(), shade: Shade::Normal, tone: None, role: TypeRole::Body, elide: Elide::Off, spans: Vec::new(), styled: Vec::new(), italic: false }
|
||||
.label(text)
|
||||
Text {
|
||||
common: Common::new(),
|
||||
shade: Shade::Normal,
|
||||
tone: None,
|
||||
role: TypeRole::Body,
|
||||
elide: Elide::Off,
|
||||
spans: Vec::new(),
|
||||
styled: Vec::new(),
|
||||
italic: false,
|
||||
}
|
||||
.label(text)
|
||||
}
|
||||
|
||||
/// Text of `spans`, each with its own font, size, colour and lines; the joined text is its accessible name. It wraps
|
||||
|
||||
@@ -11,7 +11,6 @@ use std::rc::Rc;
|
||||
|
||||
const PROMPT: &str = "Describe this object";
|
||||
|
||||
|
||||
fn rig(start: AltText) -> (Fixture, Rc<RefCell<AltText>>) {
|
||||
let value = Rc::new(RefCell::new(start));
|
||||
let shown = value.clone();
|
||||
|
||||
@@ -21,7 +21,12 @@ const ROOM: Vec2 = Vec2::new(320.0, 240.0);
|
||||
/// Where a field's text is painted, found by a piece of it no label holds: the whole text, scrolled past the field's
|
||||
/// edges when it is taller.
|
||||
fn run_with(fixture: &Fixture, piece: &str) -> Rect {
|
||||
fixture.texts().iter().find(|run| run.text.contains(piece)).map(|run| run.rect).unwrap_or_else(|| panic!("the field paints its text holding {piece:?}"))
|
||||
fixture
|
||||
.texts()
|
||||
.iter()
|
||||
.find(|run| run.text.contains(piece))
|
||||
.map(|run| run.rect)
|
||||
.unwrap_or_else(|| panic!("the field paints its text holding {piece:?}"))
|
||||
}
|
||||
|
||||
/// Clearing a search field that has an open typing run empties it for good: the clear part goes, and leaving the
|
||||
@@ -186,7 +191,10 @@ fn a_bound_caret_moves_the_caret_and_follows_it() {
|
||||
caret.set(TEXT.len());
|
||||
fixture.idle(3);
|
||||
let (field, end) = (rect.get(), run_with(&fixture, "\nf"));
|
||||
assert!(end.top() < field.top() && end.bottom() <= field.bottom() + SNAP, "an app caret at the end scrolls the last line into view: {end:?} in {field:?}");
|
||||
assert!(
|
||||
end.top() < field.top() && end.bottom() <= field.bottom() + SNAP,
|
||||
"an app caret at the end scrolls the last line into view: {end:?} in {field:?}"
|
||||
);
|
||||
assert_eq!(caret.get(), TEXT.len(), "the caret the app wrote stays");
|
||||
|
||||
// Everything selected; the app's caret, inside "é", collapses the selection at the boundary before it.
|
||||
|
||||
Reference in new issue
Block a user