mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 14:50:03 -04:00
Enable and fix some more clippy lints (#7426)
One can never have too many lints
This commit is contained in:
@@ -458,7 +458,7 @@ impl<'a> Popup<'a> {
|
||||
|
||||
/// Get the expected size of the popup.
|
||||
pub fn get_expected_size(&self) -> Option<Vec2> {
|
||||
AreaState::load(&self.ctx, self.id).and_then(|area| area.size)
|
||||
AreaState::load(&self.ctx, self.id)?.size
|
||||
}
|
||||
|
||||
/// Calculate the best alignment for the popup, based on the last size and screen rect.
|
||||
|
||||
@@ -1059,7 +1059,7 @@ impl Prepared {
|
||||
|
||||
delta += delta_update;
|
||||
animation = animation_update;
|
||||
};
|
||||
}
|
||||
|
||||
if delta != 0.0 {
|
||||
let target_offset = state.offset[d] + delta;
|
||||
@@ -1090,7 +1090,7 @@ impl Prepared {
|
||||
for d in 0..2 {
|
||||
if saved_scroll_target[d].is_some() {
|
||||
state.scroll_target[d] = saved_scroll_target[d].clone();
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -616,7 +616,7 @@ impl Window<'_> {
|
||||
*where_to_put_header_background,
|
||||
RectShape::filled(title_bar.inner_rect, round, header_color),
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
if false {
|
||||
ctx.debug_painter().debug_rect(
|
||||
|
||||
@@ -1259,7 +1259,7 @@ impl Context {
|
||||
viewport.this_pass.scroll_delta.0 += DISTANCE * Vec2::RIGHT;
|
||||
}
|
||||
_ => return false,
|
||||
};
|
||||
}
|
||||
true
|
||||
});
|
||||
});
|
||||
|
||||
@@ -729,7 +729,7 @@ impl WidgetInfo {
|
||||
description = format!("{state} {description}");
|
||||
} else {
|
||||
description += if *selected { "selected" } else { "" };
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(label) = label {
|
||||
|
||||
@@ -293,7 +293,7 @@ pub(crate) fn interact(
|
||||
drag_started,
|
||||
dragged,
|
||||
drag_stopped,
|
||||
contains_pointer,
|
||||
hovered,
|
||||
contains_pointer,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -753,7 +753,7 @@ impl Layout {
|
||||
pos2(frame_rect.max.x, f32::NAN),
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Make sure we also expand where we consider adding things (the cursor):
|
||||
@@ -779,7 +779,7 @@ impl Layout {
|
||||
Direction::BottomUp => {
|
||||
cursor.max.y = widget_rect.min.y - item_spacing.y;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// Move to the next row in a wrapping layout.
|
||||
|
||||
@@ -802,15 +802,12 @@ impl Memory {
|
||||
|
||||
/// Top-most layer at the given position.
|
||||
pub fn layer_id_at(&self, pos: Pos2) -> Option<LayerId> {
|
||||
self.areas()
|
||||
.layer_id_at(pos, &self.to_global)
|
||||
.and_then(|layer_id| {
|
||||
if self.is_above_modal_layer(layer_id) {
|
||||
Some(layer_id)
|
||||
} else {
|
||||
self.top_modal_layer()
|
||||
}
|
||||
})
|
||||
let layer_id = self.areas().layer_id_at(pos, &self.to_global)?;
|
||||
if self.is_above_modal_layer(layer_id) {
|
||||
Some(layer_id)
|
||||
} else {
|
||||
self.top_modal_layer()
|
||||
}
|
||||
}
|
||||
|
||||
/// The currently set transform of a layer.
|
||||
@@ -855,7 +852,7 @@ impl Memory {
|
||||
|
||||
/// Which widget has keyboard focus?
|
||||
pub fn focused(&self) -> Option<Id> {
|
||||
self.focus().and_then(|f| f.focused())
|
||||
self.focus()?.focused()
|
||||
}
|
||||
|
||||
/// Set an event filter for a widget.
|
||||
@@ -1066,9 +1063,8 @@ impl Memory {
|
||||
/// Get the position for this popup.
|
||||
#[deprecated = "Use Popup::position_of_id instead"]
|
||||
pub fn popup_position(&self, id: Id) -> Option<Pos2> {
|
||||
self.popups
|
||||
.get(&self.viewport_id)
|
||||
.and_then(|state| if state.id == id { state.pos } else { None })
|
||||
let state = self.popups.get(&self.viewport_id)?;
|
||||
if state.id == id { state.pos } else { None }
|
||||
}
|
||||
|
||||
/// Close any currently open popup.
|
||||
|
||||
@@ -766,9 +766,8 @@ impl MenuState {
|
||||
}
|
||||
|
||||
fn submenu(&self, id: Id) -> Option<&Arc<RwLock<Self>>> {
|
||||
self.sub_menu
|
||||
.as_ref()
|
||||
.and_then(|(k, sub)| if id == *k { Some(sub) } else { None })
|
||||
let (k, sub) = self.sub_menu.as_ref()?;
|
||||
if id == *k { Some(sub) } else { None }
|
||||
}
|
||||
|
||||
/// Open submenu at position, if not already open.
|
||||
|
||||
@@ -2136,7 +2136,7 @@ impl Visuals {
|
||||
ui.color_edit_button_srgba(color);
|
||||
} else {
|
||||
*color = None;
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
ui.end_row();
|
||||
|
||||
@@ -325,7 +325,7 @@ impl<'a> Button<'a> {
|
||||
.fill(fill)
|
||||
.stroke(stroke)
|
||||
.corner_radius(corner_radius.unwrap_or(visuals.corner_radius));
|
||||
};
|
||||
}
|
||||
|
||||
prepared.paint(ui)
|
||||
} else {
|
||||
|
||||
@@ -250,7 +250,7 @@ impl Label {
|
||||
} else {
|
||||
layout_job.halign = self.halign.unwrap_or(ui.layout().horizontal_placement());
|
||||
layout_job.justify = ui.layout().horizontal_justify();
|
||||
};
|
||||
}
|
||||
|
||||
let galley = ui.fonts(|fonts| fonts.layout_job(layout_job));
|
||||
let (rect, mut response) = ui.allocate_exact_size(galley.size(), sense);
|
||||
|
||||
@@ -806,7 +806,7 @@ impl Slider<'_> {
|
||||
SliderOrientation::Vertical => {
|
||||
trailing_rail_rect.min.y = center.y - corner_radius.se as f32;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
ui.painter().rect_filled(
|
||||
trailing_rail_rect,
|
||||
@@ -936,7 +936,7 @@ impl Slider<'_> {
|
||||
|
||||
if let Some(fmt) = &self.custom_formatter {
|
||||
dv = dv.custom_formatter(fmt);
|
||||
};
|
||||
}
|
||||
if let Some(parser) = &self.custom_parser {
|
||||
dv = dv.custom_parser(parser);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user