mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-17 05:14:24 +00:00
Lints: story facts initialisers, doc links, path field last edit
This commit is contained in:
@@ -114,11 +114,12 @@ impl Outcome for ColorPickerOutput {
|
||||
|
||||
#[cfg(feature = "screen-testing")]
|
||||
fn story_facts(&self) -> craft_ui::testing::StoryOutput {
|
||||
let mut facts = craft_ui::testing::StoryOutput::default();
|
||||
facts.id = Some(self.response.id);
|
||||
facts.clicked = craft_ui::contract::clicked(&self.response);
|
||||
facts.edits = self.events.iter().filter_map(craft_ui::testing::EditKind::of).collect();
|
||||
facts
|
||||
craft_ui::testing::StoryOutput {
|
||||
id: Some(self.response.id),
|
||||
clicked: craft_ui::contract::clicked(&self.response),
|
||||
edits: self.events.iter().filter_map(craft_ui::testing::EditKind::of).collect(),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,15 +84,16 @@ impl Outcome for ColorReadoutOutput {
|
||||
|
||||
#[cfg(feature = "screen-testing")]
|
||||
fn story_facts(&self) -> craft_ui::testing::StoryOutput {
|
||||
let mut facts = craft_ui::testing::StoryOutput::default();
|
||||
facts.id = Some(self.response.id);
|
||||
facts.edits = self
|
||||
.events
|
||||
.iter()
|
||||
.filter_map(craft_ui::testing::EditKind::of)
|
||||
.chain(self.channel.iter().filter_map(|edit| craft_ui::testing::EditKind::of(&edit.event)))
|
||||
.collect();
|
||||
facts
|
||||
craft_ui::testing::StoryOutput {
|
||||
id: Some(self.response.id),
|
||||
edits: self
|
||||
.events
|
||||
.iter()
|
||||
.filter_map(craft_ui::testing::EditKind::of)
|
||||
.chain(self.channel.iter().filter_map(|edit| craft_ui::testing::EditKind::of(&edit.event)))
|
||||
.collect(),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ impl<'a> PathField<'a> {
|
||||
};
|
||||
Some((after, event))
|
||||
})
|
||||
.last();
|
||||
.next_back();
|
||||
let landed = typed.or_else(|| {
|
||||
answered.map(|path| {
|
||||
let event = EditEvent::set(Mixed::Same(before.clone()), path.clone(), label.as_str().into(), None);
|
||||
|
||||
@@ -559,7 +559,7 @@ impl Keymap {
|
||||
}
|
||||
|
||||
/// Whether both commands of `conflict` have its chord among their defaults, so they share it by
|
||||
/// design and [`Keymap::clashing`] leaves them out.
|
||||
/// design and `Keymap::clashing` leaves them out.
|
||||
pub fn twins_in(&self, conflict: &Conflict) -> bool {
|
||||
let (Some(i), Some(j)) = (self.find(&conflict.a.0), self.find(&conflict.b.0)) else { return false };
|
||||
self.twins(i, j, conflict.chord)
|
||||
|
||||
@@ -83,7 +83,7 @@ const PC_EDITING: &[Chord] = &[
|
||||
|
||||
/// The chords with modifiers that edit text on `platform`, as effective chords: undo, redo,
|
||||
/// select all, the clipboard, and moving and deleting by word, line and text. While typing they go to the text
|
||||
/// field under every [`TypingRule`]; only a binding in an active context takes one. Plain keys
|
||||
/// field under every [`TypingRule`](crate::TypingRule); only a binding in an active context takes one. Plain keys
|
||||
/// (arrows, Home, End, Backspace, Delete, with or without Shift) are not listed, since every rule
|
||||
/// holds them already.
|
||||
pub fn text_editing_chords(platform: Platform) -> &'static [Chord] {
|
||||
|
||||
@@ -18,7 +18,7 @@ pub enum FadeShape {
|
||||
impl FadeShape {
|
||||
pub const ALL: [FadeShape; 5] = [FadeShape::Linear, FadeShape::EqualPower, FadeShape::SCurve, FadeShape::Exponential, FadeShape::Logarithmic];
|
||||
|
||||
/// Fade-in gain at `t` ∈ [0,1] (fade-outs use `gain(1 - t)`).
|
||||
/// Fade-in gain at `t` in `[0, 1]` (fade-outs use `gain(1 - t)`).
|
||||
pub fn gain(self, t: f32) -> f32 {
|
||||
let t = if t.is_nan() { 0.0 } else { t.clamp(0.0, 1.0) };
|
||||
match self {
|
||||
|
||||
@@ -170,7 +170,8 @@ fn a_settled_leaf_that_read_an_input_besides_its_room_runs_one_pass() {
|
||||
},
|
||||
);
|
||||
};
|
||||
let shows: [(&str, &dyn Fn(&mut Ui)); 2] = [("menu", &menu), ("title bar", &bar)];
|
||||
type Show<'a> = (&'a str, &'a dyn Fn(&mut Ui));
|
||||
let shows: [Show; 2] = [("menu", &menu), ("title bar", &bar)];
|
||||
for (name, show) in shows {
|
||||
let mut frames = Frames::new();
|
||||
frames.idle(4, show);
|
||||
|
||||
Reference in New Issue
Block a user