mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-18 23:12:11 +00:00
Clippy: lints the gate denies in ui-contract and window (identical if blocks, then_some, an Option mask in the icon trial, items after the test module); the it tests name epaint_default_fonts' special emojis and use Id::unique
This commit is contained in:
@@ -473,9 +473,7 @@ pub(crate) fn run(state: &mut TextState, mut input: AdapterIn<'_>) -> AdapterOut
|
||||
if input.options.multiline() {
|
||||
input.intents.take(Intent::SubmitForce);
|
||||
}
|
||||
} else if separated {
|
||||
state.end = Some(End::Separator);
|
||||
} else if stepped && state.end.is_none() {
|
||||
} else if separated || (stepped && state.end.is_none()) {
|
||||
state.end = Some(End::Separator);
|
||||
} else if shown.lost_focus && !input.held && state.draft.is_some() && state.end.is_none() {
|
||||
state.end = Some(End::Blur);
|
||||
|
||||
@@ -132,7 +132,7 @@ pub(crate) fn begin(ctx: &Context) {
|
||||
}
|
||||
// A value control that owns the running gesture hears its end without a timer of its own: a pass at the gap.
|
||||
let value_owner = state.gesture.owner.is_some_and(|owner| state.last.iter().any(|taker| taker.owner == owner && taker.value));
|
||||
(value_owner && state.gesture.runs(now)).then(|| state.gesture.last + GESTURE_GAP - now)
|
||||
(value_owner && state.gesture.runs(now)).then_some(state.gesture.last + GESTURE_GAP - now)
|
||||
});
|
||||
if let Some(seconds) = wake {
|
||||
repaint::request_after(ctx, viewport, seconds.max(0.0));
|
||||
|
||||
@@ -23,8 +23,8 @@ fn icon(name: &'static str) -> Option<SvgIcon> {
|
||||
SvgIcon::of(&tokens, Direction::Ltr, 24.0, &IconId::from(std::borrow::Cow::Borrowed(name)), IconSet::default(), Mirror::Auto)
|
||||
}
|
||||
|
||||
fn mask(name: &'static str) -> ColorImage {
|
||||
icon(name).expect("the name resolves").mask(24.0, 1.0)
|
||||
fn mask(name: &'static str) -> Option<ColorImage> {
|
||||
icon(name).map(|icon| icon.mask(24.0, 1.0))
|
||||
}
|
||||
|
||||
#[trial]
|
||||
|
||||
@@ -340,7 +340,7 @@ fn the_deflated_defaults_are_eguis_default_faces_and_draw_its_icons() {
|
||||
frames.frame(vec![], |_| {});
|
||||
}
|
||||
for family in [FontId::proportional(14.0), FontId::monospace(14.0)] {
|
||||
for icon in [egui::special_emojis::GITHUB, egui::special_emojis::OS_LINUX] {
|
||||
for icon in [epaint_default_fonts::special_emojis::GITHUB, epaint_default_fonts::special_emojis::OS_LINUX] {
|
||||
assert!(frames.ctx.fonts_mut(|f| f.has_glyph(&family, icon)), "{icon} in {:?}", family.family);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,8 +207,7 @@ fn in_line() -> [Rect; 3] {
|
||||
});
|
||||
});
|
||||
fixture.room(Vec2::splat(800.0)).settle();
|
||||
let rects = [tall.borrow().rect, held.get(), leaf.borrow().rect];
|
||||
rects
|
||||
[tall.borrow().rect, held.get(), leaf.borrow().rect]
|
||||
}
|
||||
|
||||
#[trial]
|
||||
|
||||
@@ -57,7 +57,7 @@ fn a_fractional_ctrl_wheel_is_a_pinch_and_a_whole_notch_stays_a_scroll() {
|
||||
for os in [Os::Windows, Os::Linux, Os::Mac] {
|
||||
let seen = Rc::new(RefCell::new(Vec::new()));
|
||||
let shares = Rc::clone(&seen);
|
||||
let view = Id::new("pinch_view");
|
||||
let view = Id::unique("pinch_view");
|
||||
let mut fixture = Fixture::new(move |ui| {
|
||||
register(ui.ctx(), WheelTaker::new(view, Rect::from_min_size(Pos2::ZERO, Vec2::new(400.0, 300.0))).vertical(true).zoom(true));
|
||||
shares.borrow_mut().extend(take_share(ui.ctx(), view));
|
||||
@@ -101,9 +101,9 @@ fn a_fractional_ctrl_wheel_is_a_pinch_and_a_whole_notch_stays_a_scroll() {
|
||||
|
||||
#[trial]
|
||||
fn a_wheel_gesture_ends_for_a_value_control_in_any_wheel_scope_and_not_for_a_scroll_region_or_the_canvas() {
|
||||
let panel = Id::new("gesture_panel");
|
||||
let slider = Id::new("gesture_slider");
|
||||
let canvas = Id::new("gesture_canvas");
|
||||
let panel = Id::unique("gesture_panel");
|
||||
let slider = Id::unique("gesture_slider");
|
||||
let canvas = Id::unique("gesture_canvas");
|
||||
let seen: RefCell<Vec<(Id, Wheel)>> = RefCell::new(Vec::new());
|
||||
let mut show_frame = |ui: &mut egui::Ui| {
|
||||
let ctx = ui.ctx();
|
||||
|
||||
@@ -143,7 +143,7 @@ fn oversized_text_events_are_cut_before_components_see_them() {
|
||||
assert_eq!(composing(&inside), Some((INPUT_TEXT_LIMIT, Some(2..4))), "a range inside the cut stays");
|
||||
|
||||
// A paste reaches an app's own focused widget cut too.
|
||||
let field = Id::new("app_field");
|
||||
let field = Id::unique("app_field");
|
||||
let pasted = RefCell::new(None);
|
||||
let mut frames = Frames::new();
|
||||
let mut host = |ui: &mut egui::Ui| {
|
||||
|
||||
+11
-11
@@ -287,6 +287,17 @@ pub fn apply(builder: egui::ViewportBuilder, frame: &Frame) -> egui::ViewportBui
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&crate::Frame> for Frame {
|
||||
/// The old two-way frame as a new one: `Desktop` is `Native`, `App(layout)` is integrated
|
||||
/// with generic captions.
|
||||
fn from(old: &crate::Frame) -> Self {
|
||||
match old {
|
||||
crate::Frame::Desktop => Frame::Native,
|
||||
crate::Frame::App(layout) => Frame::Integrated(Captions { family: CaptionFamily::Generic, layout: layout.clone() }),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -333,14 +344,3 @@ mod tests {
|
||||
assert_eq!(decided(TitleBarPref::System, Some("breeze"), Some("close:")), Frame::Native, "a native frame has no captions to change");
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&crate::Frame> for Frame {
|
||||
/// The old two-way frame as a new one: `Desktop` is `Native`, `App(layout)` is integrated
|
||||
/// with generic captions.
|
||||
fn from(old: &crate::Frame) -> Self {
|
||||
match old {
|
||||
crate::Frame::Desktop => Frame::Native,
|
||||
crate::Frame::App(layout) => Frame::Integrated(Captions { family: CaptionFamily::Generic, layout: layout.clone() }),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user