clippy
This commit is contained in:
parent
df4b94edf2
commit
2dd6137459
19 changed files with 42 additions and 53 deletions
|
|
@ -137,12 +137,12 @@ impl From<Id> for u64 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToString for Id {
|
impl std::fmt::Display for Id {
|
||||||
fn to_string(&self) -> String {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match &self.0 {
|
match &self.0 {
|
||||||
Internal::Unique(_) => "Undefined".to_string(),
|
Internal::Unique(_) => write!(f, "Undefined"),
|
||||||
Internal::Custom(_, id) => id.to_string(),
|
Internal::Custom(_, id) => write!(f, "{}", id.to_string()),
|
||||||
Internal::Set(_) => "Set".to_string(),
|
Internal::Set(_) => write!(f, "Set"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ pub trait Clipboard {
|
||||||
/// Reads the current content of the [`Clipboard`] as text.
|
/// Reads the current content of the [`Clipboard`] as text.
|
||||||
fn read_data(
|
fn read_data(
|
||||||
&self,
|
&self,
|
||||||
kind: Kind,
|
_kind: Kind,
|
||||||
_mimes: Vec<String>,
|
_mimes: Vec<String>,
|
||||||
) -> Option<(Vec<u8>, String)> {
|
) -> Option<(Vec<u8>, String)> {
|
||||||
None
|
None
|
||||||
|
|
@ -78,7 +78,7 @@ pub trait Clipboard {
|
||||||
/// Writes the given contents to the [`Clipboard`].
|
/// Writes the given contents to the [`Clipboard`].
|
||||||
fn write_data(
|
fn write_data(
|
||||||
&mut self,
|
&mut self,
|
||||||
kind: Kind,
|
_kind: Kind,
|
||||||
_contents: ClipboardStoreData<
|
_contents: ClipboardStoreData<
|
||||||
Box<dyn Send + Sync + 'static + mime::AsMimeTypes>,
|
Box<dyn Send + Sync + 'static + mime::AsMimeTypes>,
|
||||||
>,
|
>,
|
||||||
|
|
@ -119,7 +119,7 @@ pub trait Clipboard {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Request window size
|
/// Request window size
|
||||||
fn request_logical_window_size(&self, width: f32, height: f32) {}
|
fn request_logical_window_size(&self, _width: f32, _height: f32) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The kind of [`Clipboard`].
|
/// The kind of [`Clipboard`].
|
||||||
|
|
@ -187,10 +187,7 @@ pub fn peek_dnd<T: AllowedMimeTypes>(
|
||||||
clipboard: &mut dyn Clipboard,
|
clipboard: &mut dyn Clipboard,
|
||||||
mime: Option<String>,
|
mime: Option<String>,
|
||||||
) -> Option<T> {
|
) -> Option<T> {
|
||||||
let Some(mime) = mime.or_else(|| T::allowed().first().cloned().into())
|
let mime = mime.or_else(|| T::allowed().first().cloned())?;
|
||||||
else {
|
|
||||||
return None;
|
|
||||||
};
|
|
||||||
clipboard
|
clipboard
|
||||||
.peek_dnd(mime)
|
.peek_dnd(mime)
|
||||||
.and_then(|data| T::try_from(data).ok())
|
.and_then(|data| T::try_from(data).ok())
|
||||||
|
|
@ -206,7 +203,7 @@ pub enum DndSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A list of DnD destination rectangles.
|
/// A list of DnD destination rectangles.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, Default)]
|
||||||
pub struct DndDestinationRectangles {
|
pub struct DndDestinationRectangles {
|
||||||
/// The rectangle of the DnD destination.
|
/// The rectangle of the DnD destination.
|
||||||
rectangles: Vec<DndDestinationRectangle>,
|
rectangles: Vec<DndDestinationRectangle>,
|
||||||
|
|
@ -215,9 +212,7 @@ pub struct DndDestinationRectangles {
|
||||||
impl DndDestinationRectangles {
|
impl DndDestinationRectangles {
|
||||||
/// Creates a new [`DndDestinationRectangles`].
|
/// Creates a new [`DndDestinationRectangles`].
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self::default()
|
||||||
rectangles: Vec::new(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new [`DndDestinationRectangles`] with the given capacity.
|
/// Creates a new [`DndDestinationRectangles`] with the given capacity.
|
||||||
|
|
|
||||||
|
|
@ -311,7 +311,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn diff(&mut self, tree: &mut Tree) {
|
fn diff(&mut self, tree: &mut Tree) {
|
||||||
self.widget.diff(tree)
|
self.widget.diff(tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn size(&self) -> Size<Length> {
|
fn size(&self) -> Size<Length> {
|
||||||
|
|
|
||||||
|
|
@ -75,12 +75,12 @@ impl From<Id> for NonZeroU128 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToString for Id {
|
impl std::fmt::Display for Id {
|
||||||
fn to_string(&self) -> String {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match &self.0 {
|
match &self.0 {
|
||||||
Internal::Unique(_) => "Undefined".to_string(),
|
Internal::Unique(_) => write!(f, "Undefined"),
|
||||||
Internal::Custom(_, id) => id.to_string(),
|
Internal::Custom(_, id) => write!(f, "{}", id.to_string()),
|
||||||
Internal::Set(_) => "Set".to_string(),
|
Internal::Set(_) => write!(f, "Set"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ use crate::mouse;
|
||||||
use crate::overlay;
|
use crate::overlay;
|
||||||
use crate::renderer;
|
use crate::renderer;
|
||||||
use crate::widget;
|
use crate::widget;
|
||||||
use crate::widget::Operation;
|
|
||||||
use crate::{Clipboard, Event, Layout, Overlay, Point, Rectangle, Shell, Size};
|
use crate::{Clipboard, Event, Layout, Overlay, Point, Rectangle, Shell, Size};
|
||||||
|
|
||||||
/// An [`Overlay`] container that displays multiple overlay [`overlay::Element`]
|
/// An [`Overlay`] container that displays multiple overlay [`overlay::Element`]
|
||||||
|
|
|
||||||
|
|
@ -269,13 +269,13 @@ impl Tree {
|
||||||
new_children.iter().map(|c| c.borrow().id()).collect(),
|
new_children.iter().map(|c| c.borrow().id()).collect(),
|
||||||
|tree, widget| {
|
|tree, widget| {
|
||||||
let borrowed: &mut dyn Widget<_, _, _> = widget.borrow_mut();
|
let borrowed: &mut dyn Widget<_, _, _> = widget.borrow_mut();
|
||||||
tree.diff(borrowed)
|
tree.diff(borrowed);
|
||||||
},
|
},
|
||||||
|widget| {
|
|widget| {
|
||||||
let borrowed: &dyn Widget<_, _, _> = widget.borrow();
|
let borrowed: &dyn Widget<_, _, _> = widget.borrow();
|
||||||
Self::new(borrowed)
|
Self::new(borrowed)
|
||||||
},
|
},
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reconciles the children of the tree with the provided list of widgets using custom
|
/// Reconciles the children of the tree with the provided list of widgets using custom
|
||||||
|
|
|
||||||
|
|
@ -80,8 +80,8 @@ pub fn peek_dnd<T: AllowedMimeTypes>() -> Task<Option<T>> {
|
||||||
task::oneshot(|tx| {
|
task::oneshot(|tx| {
|
||||||
Action::Dnd(DndAction::PeekDnd(
|
Action::Dnd(DndAction::PeekDnd(
|
||||||
T::allowed()
|
T::allowed()
|
||||||
.get(0)
|
.first()
|
||||||
.map_or_else(|| String::new(), |s| s.to_string()),
|
.map_or_else(String::new, std::string::ToString::to_string),
|
||||||
tx,
|
tx,
|
||||||
))
|
))
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -700,7 +700,7 @@ pub type Element<
|
||||||
/// The result of running an iced program.
|
/// The result of running an iced program.
|
||||||
pub type Result = std::result::Result<(), Error>;
|
pub type Result = std::result::Result<(), Error>;
|
||||||
|
|
||||||
#[cfg(any(feature = "winit"))]
|
#[cfg(feature = "winit")]
|
||||||
/// Runs a basic iced application with default [`Settings`] given its title,
|
/// Runs a basic iced application with default [`Settings`] given its title,
|
||||||
/// update, and view logic.
|
/// update, and view logic.
|
||||||
///
|
///
|
||||||
|
|
|
||||||
|
|
@ -620,7 +620,7 @@ impl Engine {
|
||||||
let center = physical_bounds.center();
|
let center = physical_bounds.center();
|
||||||
let radians = f32::from(svg.rotation);
|
let radians = f32::from(svg.rotation);
|
||||||
|
|
||||||
let transform = Transform::default().post_rotate_at(
|
let transform = tiny_skia::Transform::default().post_rotate_at(
|
||||||
radians.to_degrees(),
|
radians.to_degrees(),
|
||||||
center.x,
|
center.x,
|
||||||
center.y,
|
center.y,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::Primitive;
|
use crate::Primitive;
|
||||||
use crate::core::renderer::Quad;
|
use crate::core::renderer::Quad;
|
||||||
use crate::core::{
|
use crate::core::{
|
||||||
self, Background, Color, Point, Radians, Rectangle, Svg, Transformation,
|
self, Background, Color, Point, Rectangle, Svg, Transformation,
|
||||||
};
|
};
|
||||||
use crate::graphics::damage;
|
use crate::graphics::damage;
|
||||||
use crate::graphics::layer;
|
use crate::graphics::layer;
|
||||||
|
|
|
||||||
|
|
@ -289,7 +289,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn diff(&mut self, tree: &mut Tree) {
|
fn diff(&mut self, tree: &mut Tree) {
|
||||||
tree.diff_children(std::slice::from_mut(&mut self.content))
|
tree.diff_children(std::slice::from_mut(&mut self.content));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn size(&self) -> Size<Length> {
|
fn size(&self) -> Size<Length> {
|
||||||
|
|
|
||||||
|
|
@ -461,7 +461,7 @@ where
|
||||||
size,
|
size,
|
||||||
line_height,
|
line_height,
|
||||||
shaping,
|
shaping,
|
||||||
wrap,
|
wrap: _,
|
||||||
} = &self.icon;
|
} = &self.icon;
|
||||||
let size = size.unwrap_or(Pixels(bounds.height * 0.7));
|
let size = size.unwrap_or(Pixels(bounds.height * 0.7));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -592,7 +592,7 @@ pub fn visible_bounds(id: Id) -> Task<Option<Rectangle>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
task::widget(VisibleBounds {
|
task::widget(VisibleBounds {
|
||||||
target: id.into(),
|
target: id,
|
||||||
depth: 0,
|
depth: 0,
|
||||||
scrollables: Vec::new(),
|
scrollables: Vec::new(),
|
||||||
bounds: None,
|
bounds: None,
|
||||||
|
|
|
||||||
|
|
@ -164,11 +164,11 @@ impl Default for State {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
is_hovered: Default::default(),
|
is_hovered: Default::default(),
|
||||||
drag_initiated: Default::default(),
|
drag_initiated: None,
|
||||||
is_out_of_bounds: true,
|
is_out_of_bounds: true,
|
||||||
last_click: Default::default(),
|
last_click: None,
|
||||||
cursor_position: None,
|
cursor_position: None,
|
||||||
bounds: Default::default(),
|
bounds: Rectangle::default(),
|
||||||
previous_click: None,
|
previous_click: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -351,7 +351,7 @@ where
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
dnd_rectangles: &mut crate::core::clipboard::DndDestinationRectangles,
|
dnd_rectangles: &mut crate::core::clipboard::DndDestinationRectangles,
|
||||||
) {
|
) {
|
||||||
if let Some(state) = state.children.iter().next() {
|
if let Some(state) = state.children.first() {
|
||||||
self.content.as_widget().drag_destinations(
|
self.content.as_widget().drag_destinations(
|
||||||
state,
|
state,
|
||||||
layout,
|
layout,
|
||||||
|
|
@ -420,20 +420,19 @@ fn update<Message: Clone, Theme, Renderer>(
|
||||||
}
|
}
|
||||||
|
|
||||||
if !cursor.is_over(layout.bounds()) {
|
if !cursor.is_over(layout.bounds()) {
|
||||||
if !state.is_out_of_bounds {
|
if !state.is_out_of_bounds
|
||||||
if widget
|
&& widget
|
||||||
.on_enter
|
.on_enter
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.or(widget.on_exit.as_ref())
|
.or(widget.on_exit.as_ref())
|
||||||
.is_some()
|
.is_some()
|
||||||
{
|
{
|
||||||
if let Event::Mouse(mouse::Event::CursorMoved { .. }) = event {
|
if let Event::Mouse(mouse::Event::CursorMoved { .. }) = event {
|
||||||
state.is_out_of_bounds = true;
|
state.is_out_of_bounds = true;
|
||||||
if let Some(message) = widget.on_exit.as_ref() {
|
if let Some(message) = widget.on_exit.as_ref() {
|
||||||
shell.publish(message.clone());
|
shell.publish(message.clone());
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
use iced_renderer::core::widget::Operation;
|
|
||||||
|
|
||||||
use crate::container;
|
use crate::container;
|
||||||
use crate::core::layout;
|
use crate::core::layout;
|
||||||
use crate::core::mouse;
|
use crate::core::mouse;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
use iced_renderer::core::widget::Operation;
|
|
||||||
|
|
||||||
use crate::container;
|
use crate::container;
|
||||||
use crate::core::layout;
|
use crate::core::layout;
|
||||||
use crate::core::mouse;
|
use crate::core::mouse;
|
||||||
|
|
|
||||||
|
|
@ -196,7 +196,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn diff(&mut self, tree: &mut Tree) {
|
fn diff(&mut self, tree: &mut Tree) {
|
||||||
tree.diff_children(&mut self.children)
|
tree.diff_children(&mut self.children);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn size(&self) -> Size<Length> {
|
fn size(&self) -> Size<Length> {
|
||||||
|
|
|
||||||
|
|
@ -470,7 +470,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn diff(&mut self, tree: &mut Tree) {
|
fn diff(&mut self, tree: &mut Tree) {
|
||||||
tree.diff_children(std::slice::from_mut(&mut self.content))
|
tree.diff_children(std::slice::from_mut(&mut self.content));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn size(&self) -> Size<Length> {
|
fn size(&self) -> Size<Length> {
|
||||||
|
|
|
||||||
|
|
@ -189,7 +189,7 @@ where
|
||||||
tree.diff_children(&mut [
|
tree.diff_children(&mut [
|
||||||
self.content.as_widget_mut(),
|
self.content.as_widget_mut(),
|
||||||
self.tooltip.as_widget_mut(),
|
self.tooltip.as_widget_mut(),
|
||||||
])
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn layout(
|
fn layout(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue