chore: fixing linter warnings
This commit is contained in:
parent
ebcfa5f2d0
commit
8e99406a8b
17 changed files with 79 additions and 75 deletions
|
|
@ -215,7 +215,7 @@ impl Config {
|
|||
//TODO: handle errors
|
||||
}
|
||||
},
|
||||
Err(err) => {
|
||||
Err(_err) => {
|
||||
//TODO: handle errors
|
||||
}
|
||||
}
|
||||
|
|
@ -224,7 +224,7 @@ impl Config {
|
|||
f(&watch_config, &keys);
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
Err(_err) => {
|
||||
//TODO: handle errors
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ use cosmic::{
|
|||
cosmic_theme,
|
||||
iced::widget::{checkbox, column, progress_bar, radio, slider, text, text_input},
|
||||
iced::{id, Alignment, Length},
|
||||
iced_core::Color,
|
||||
theme::ThemeType,
|
||||
widget::{
|
||||
button, color_picker::ColorPickerUpdate, cosmic_container::container, dropdown, icon,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use cosmic::iced::widget::{horizontal_space, row};
|
||||
use cosmic::iced::{Alignment, Length};
|
||||
use cosmic::widget::{button, icon, segmented_button, view_switcher};
|
||||
use cosmic::{theme, Apply, Element};
|
||||
use cosmic::{Apply, Element};
|
||||
use slotmap::Key;
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ where
|
|||
fn new((core, flags): Self::Flags) -> (Self, iced::Command<Self::Message>) {
|
||||
let (model, command) = T::init(core, flags);
|
||||
|
||||
(Cosmic::new(model), command)
|
||||
(Self::new(model), command)
|
||||
}
|
||||
|
||||
#[cfg(feature = "wayland")]
|
||||
|
|
|
|||
|
|
@ -92,11 +92,11 @@ pub trait ColorExt {
|
|||
|
||||
impl ColorExt for iced::Color {
|
||||
fn blend_alpha(self, background: Self, alpha: f32) -> Self {
|
||||
Color {
|
||||
Self {
|
||||
a: 1.0,
|
||||
r: background.r + (self.r - background.r) * alpha,
|
||||
g: background.g + (self.g - background.g) * alpha,
|
||||
b: background.b + (self.b - background.b) * alpha,
|
||||
r: (self.r - background.r).mul_add(alpha, background.r),
|
||||
g: (self.g - background.g).mul_add(alpha, background.g),
|
||||
b: (self.b - background.b).mul_add(alpha, background.b),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ pub fn appearance(
|
|||
}
|
||||
|
||||
Button::Icon | Button::IconVertical => {
|
||||
if let Button::IconVertical = style {
|
||||
if matches!(style, Button::IconVertical) {
|
||||
corner_radii = &cosmic.corner_radii.radius_m;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,17 +84,17 @@ impl Button {
|
|||
fn cosmic<'a>(&'a self, theme: &'a Theme) -> &CosmicComponent {
|
||||
let cosmic = theme.cosmic();
|
||||
match self {
|
||||
Button::Primary => &cosmic.accent_button,
|
||||
Button::Secondary => &theme.current_container().component,
|
||||
Button::Positive => &cosmic.success_button,
|
||||
Button::Destructive => &cosmic.destructive_button,
|
||||
Button::Text => &cosmic.text_button,
|
||||
Button::Link => &cosmic.accent_button,
|
||||
Button::LinkActive => &cosmic.accent_button,
|
||||
Button::Transparent => &TRANSPARENT_COMPONENT,
|
||||
Button::Deactivated => &theme.current_container().component,
|
||||
Button::Card => &theme.current_container().component,
|
||||
Button::Custom { .. } => &TRANSPARENT_COMPONENT,
|
||||
Self::Primary => &cosmic.accent_button,
|
||||
Self::Secondary => &theme.current_container().component,
|
||||
Self::Positive => &cosmic.success_button,
|
||||
Self::Destructive => &cosmic.destructive_button,
|
||||
Self::Text => &cosmic.text_button,
|
||||
Self::Link => &cosmic.accent_button,
|
||||
Self::LinkActive => &cosmic.accent_button,
|
||||
Self::Transparent => &TRANSPARENT_COMPONENT,
|
||||
Self::Deactivated => &theme.current_container().component,
|
||||
Self::Card => &theme.current_container().component,
|
||||
Self::Custom { .. } => &TRANSPARENT_COMPONENT,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -950,7 +950,7 @@ pub enum Text {
|
|||
|
||||
impl From<Color> for Text {
|
||||
fn from(color: Color) -> Self {
|
||||
Text::Color(color)
|
||||
Self::Color(color)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -306,7 +306,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
if let event::Status::Captured = self.content.as_widget_mut().on_event(
|
||||
if self.content.as_widget_mut().on_event(
|
||||
&mut tree.children[0],
|
||||
event.clone(),
|
||||
layout.children().next().unwrap(),
|
||||
|
|
@ -315,7 +315,8 @@ where
|
|||
clipboard,
|
||||
shell,
|
||||
viewport,
|
||||
) {
|
||||
) == event::Status::Captured
|
||||
{
|
||||
return event::Status::Captured;
|
||||
}
|
||||
|
||||
|
|
@ -549,6 +550,7 @@ where
|
|||
|
||||
/// The local state of a [`Button`].
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
||||
#[allow(clippy::struct_field_names)]
|
||||
pub struct State {
|
||||
is_hovered: bool,
|
||||
is_pressed: bool,
|
||||
|
|
@ -557,8 +559,8 @@ pub struct State {
|
|||
|
||||
impl State {
|
||||
/// Creates a new [`State`].
|
||||
pub fn new() -> State {
|
||||
State::default()
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
/// Returns whether the [`Button`] is currently focused or not.
|
||||
|
|
@ -806,15 +808,15 @@ pub fn focus<Message: 'static>(id: Id) -> Command<Message> {
|
|||
|
||||
impl operation::Focusable for State {
|
||||
fn is_focused(&self) -> bool {
|
||||
State::is_focused(*self)
|
||||
Self::is_focused(*self)
|
||||
}
|
||||
|
||||
fn focus(&mut self) {
|
||||
State::focus(self);
|
||||
Self::focus(self);
|
||||
}
|
||||
|
||||
fn unfocus(&mut self) {
|
||||
State::unfocus(self);
|
||||
Self::unfocus(self);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -589,16 +589,20 @@ where
|
|||
let t = t.cosmic();
|
||||
let handle_radius = f32::from(t.space_xs()) / 2.0;
|
||||
let (x, y) = (
|
||||
(self.active_color.saturation * bounds.width) + bounds.position().x - handle_radius,
|
||||
((1.0 - self.active_color.value) * bounds.height) + bounds.position().y - handle_radius,
|
||||
self.active_color
|
||||
.saturation
|
||||
.mul_add(bounds.width, bounds.position().x)
|
||||
- handle_radius,
|
||||
(1.0 - self.active_color.value).mul_add(bounds.height, bounds.position().y)
|
||||
- handle_radius,
|
||||
);
|
||||
renderer.fill_quad(
|
||||
Quad {
|
||||
bounds: Rectangle {
|
||||
x,
|
||||
y,
|
||||
width: 1.0 + handle_radius * 2.0,
|
||||
height: 1.0 + handle_radius * 2.0,
|
||||
width: handle_radius.mul_add(2.0, 1.0),
|
||||
height: handle_radius.mul_add(2.0, 1.0),
|
||||
},
|
||||
border_radius: (1.0 + handle_radius).into(),
|
||||
border_width: 1.0,
|
||||
|
|
@ -654,8 +658,8 @@ where
|
|||
match event {
|
||||
Event::Mouse(mouse::Event::CursorMoved { .. } | mouse::Event::CursorEntered) => {
|
||||
if let Some(mut clamped) = cursor.position() {
|
||||
clamped.x = clamped.x.min(bounds.x + bounds.width).max(bounds.x);
|
||||
clamped.y = clamped.y.min(bounds.y + bounds.height).max(bounds.y);
|
||||
clamped.x = clamped.x.clamp(bounds.x, bounds.x + bounds.width);
|
||||
clamped.y = clamped.y.clamp(bounds.y, bounds.y + bounds.height);
|
||||
let relative_pos = clamped - bounds.position();
|
||||
let (s, v) = (
|
||||
relative_pos.x / bounds.width,
|
||||
|
|
@ -678,7 +682,7 @@ where
|
|||
}
|
||||
|
||||
let column_tree = &mut tree.children[0];
|
||||
if let event::Status::Captured = self.inner.as_widget_mut().on_event(
|
||||
if self.inner.as_widget_mut().on_event(
|
||||
column_tree,
|
||||
event.clone(),
|
||||
column_layout,
|
||||
|
|
@ -687,7 +691,8 @@ where
|
|||
clipboard,
|
||||
shell,
|
||||
viewport,
|
||||
) {
|
||||
) == event::Status::Captured
|
||||
{
|
||||
return event::Status::Captured;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ use iced_core::{
|
|||
};
|
||||
|
||||
use iced_renderer::core::widget::OperationOutputWrapper;
|
||||
pub use iced_style::container::{Appearance, StyleSheet};
|
||||
|
||||
#[must_use]
|
||||
pub struct ContextDrawer<'a, Message> {
|
||||
|
|
|
|||
|
|
@ -423,14 +423,14 @@ impl<'a, S: AsRef<str>, Message> Widget<Message, crate::Renderer> for List<'a, S
|
|||
|
||||
let bounds = Rectangle {
|
||||
x: bounds.x,
|
||||
y: bounds.y + (option_height * i as f32),
|
||||
y: option_height.mul_add(i as f32, bounds.y),
|
||||
width: bounds.width,
|
||||
height: option_height,
|
||||
};
|
||||
|
||||
let (color, font) = if self.selected_option == Some(i) {
|
||||
let item_x = bounds.x + appearance.border_width;
|
||||
let item_width = bounds.width - appearance.border_width * 2.0;
|
||||
let item_width = appearance.border_width.mul_add(-2.0, bounds.width);
|
||||
|
||||
renderer.fill_quad(
|
||||
renderer::Quad {
|
||||
|
|
@ -463,7 +463,7 @@ impl<'a, S: AsRef<str>, Message> Widget<Message, crate::Renderer> for List<'a, S
|
|||
(appearance.selected_text_color, crate::font::FONT_SEMIBOLD)
|
||||
} else if *self.hovered_option == Some(i) {
|
||||
let item_x = bounds.x + appearance.border_width;
|
||||
let item_width = bounds.width - appearance.border_width * 2.0;
|
||||
let item_width = appearance.border_width.mul_add(-2.0, bounds.width);
|
||||
|
||||
renderer.fill_quad(
|
||||
renderer::Quad {
|
||||
|
|
|
|||
|
|
@ -173,7 +173,6 @@ impl<'a, S: AsRef<str>, Message: 'a> Widget<Message, crate::Renderer> for Dropdo
|
|||
self.gap,
|
||||
self.padding,
|
||||
self.text_size.unwrap_or(14.0),
|
||||
self.font,
|
||||
self.selections,
|
||||
self.selected,
|
||||
&self.on_selected,
|
||||
|
|
@ -359,7 +358,6 @@ pub fn overlay<'a, S: AsRef<str>, Message: 'a>(
|
|||
gap: f32,
|
||||
padding: Padding,
|
||||
text_size: f32,
|
||||
font: Option<crate::font::Font>,
|
||||
selections: &'a [S],
|
||||
selected_option: Option<usize>,
|
||||
on_selected: &'a dyn Fn(usize) -> Message,
|
||||
|
|
|
|||
|
|
@ -72,8 +72,14 @@ impl Icon {
|
|||
fn into_element<Message: 'static>(self) -> Element<'static, Message> {
|
||||
let from_image = |handle| {
|
||||
Image::new(handle)
|
||||
.width(self.width.unwrap_or(Length::Fixed(f32::from(self.size))))
|
||||
.height(self.height.unwrap_or(Length::Fixed(f32::from(self.size))))
|
||||
.width(
|
||||
self.width
|
||||
.unwrap_or_else(|| Length::Fixed(f32::from(self.size))),
|
||||
)
|
||||
.height(
|
||||
self.height
|
||||
.unwrap_or_else(|| Length::Fixed(f32::from(self.size))),
|
||||
)
|
||||
.content_fit(self.content_fit)
|
||||
.into()
|
||||
};
|
||||
|
|
@ -81,8 +87,14 @@ impl Icon {
|
|||
let from_svg = |handle| {
|
||||
Svg::<Renderer>::new(handle)
|
||||
.style(self.style.clone())
|
||||
.width(self.width.unwrap_or(Length::Fixed(f32::from(self.size))))
|
||||
.height(self.height.unwrap_or(Length::Fixed(f32::from(self.size))))
|
||||
.width(
|
||||
self.width
|
||||
.unwrap_or_else(|| Length::Fixed(f32::from(self.size))),
|
||||
)
|
||||
.height(
|
||||
self.height
|
||||
.unwrap_or_else(|| Length::Fixed(f32::from(self.size))),
|
||||
)
|
||||
.content_fit(self.content_fit)
|
||||
.symbolic(self.handle.symbolic)
|
||||
.into()
|
||||
|
|
|
|||
|
|
@ -48,10 +48,10 @@ where
|
|||
let num = self.model.items.len();
|
||||
if num != 0 {
|
||||
let spacing = f32::from(self.spacing);
|
||||
bounds.width = (bounds.width - (num as f32 * spacing) + spacing) / num as f32;
|
||||
bounds.width = ((num as f32).mul_add(-spacing, bounds.width) + spacing) / num as f32;
|
||||
|
||||
if nth != 0 {
|
||||
bounds.x += (nth as f32 * bounds.width) + (nth as f32 * spacing);
|
||||
bounds.x += (nth as f32).mul_add(bounds.width, nth as f32 * spacing);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -69,7 +69,7 @@ where
|
|||
let spacing = f32::from(self.spacing);
|
||||
|
||||
if num != 0 {
|
||||
width = (num as f32 * width) + (num as f32 * spacing) - spacing;
|
||||
width = (num as f32).mul_add(width, num as f32 * spacing) - spacing;
|
||||
}
|
||||
|
||||
let size = limits
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ where
|
|||
self.storage
|
||||
.0
|
||||
.entry(TypeId::of::<Data>())
|
||||
.or_insert_with(SecondaryMap::new)
|
||||
.or_default()
|
||||
.insert(id, Box::new(data));
|
||||
}
|
||||
}
|
||||
|
|
@ -297,7 +297,7 @@ where
|
|||
}
|
||||
|
||||
pub fn indent(&self, id: Entity) -> Option<u16> {
|
||||
self.indents.get(id).map(|indent| *indent)
|
||||
self.indents.get(id).copied()
|
||||
}
|
||||
|
||||
pub fn indent_set(&mut self, id: Entity, indent: u16) -> Option<u16> {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ pub enum State {
|
|||
|
||||
impl Default for Cursor {
|
||||
fn default() -> Self {
|
||||
Cursor {
|
||||
Self {
|
||||
state: State::Index(0),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -915,7 +915,7 @@ pub fn layout<Message>(
|
|||
|
||||
text_node.move_to(Point::new(
|
||||
padding.left + leading_icon_width,
|
||||
padding.top + ((text_input_height - text_size * 1.2) / 2.0).max(0.0),
|
||||
padding.top + (text_size.mul_add(-1.2, text_input_height) / 2.0).max(0.0),
|
||||
));
|
||||
let mut node_list: Vec<_> = Vec::with_capacity(3);
|
||||
|
||||
|
|
@ -1515,18 +1515,6 @@ where
|
|||
}
|
||||
}
|
||||
#[cfg(feature = "wayland")]
|
||||
Event::PlatformSpecific(PlatformSpecific::Wayland(wayland::Event::DataSource(
|
||||
wayland::DataSourceEvent::Cancelled
|
||||
| wayland::DataSourceEvent::DndFinished
|
||||
| wayland::DataSourceEvent::Cancelled,
|
||||
))) => {
|
||||
let state = state();
|
||||
if matches!(state.dragging_state, Some(DraggingState::Dnd(..))) {
|
||||
state.dragging_state = None;
|
||||
return event::Status::Captured;
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "wayland")]
|
||||
Event::PlatformSpecific(PlatformSpecific::Wayland(wayland::Event::DataSource(
|
||||
wayland::DataSourceEvent::DndActionAccepted(action),
|
||||
))) => {
|
||||
|
|
@ -1872,8 +1860,8 @@ pub fn draw<'a, Message>(
|
|||
let offset_bounds = Rectangle {
|
||||
x: bounds.x - border_offset,
|
||||
y: bounds.y - border_offset,
|
||||
width: bounds.width + border_offset * 2.0,
|
||||
height: bounds.height + border_offset * 2.0,
|
||||
width: border_offset.mul_add(2.0, bounds.width),
|
||||
height: border_offset.mul_add(2.0, bounds.height),
|
||||
};
|
||||
renderer.fill_quad(
|
||||
renderer::Quad {
|
||||
|
|
@ -2228,6 +2216,7 @@ impl State {
|
|||
Self {
|
||||
is_focused: None,
|
||||
dragging_state: None,
|
||||
#[allow(clippy::default_constructed_unit_structs)]
|
||||
dnd_offer: DndOfferState::default(),
|
||||
is_pasting: None,
|
||||
last_click: None,
|
||||
|
|
@ -2288,33 +2277,33 @@ impl State {
|
|||
|
||||
impl operation::Focusable for State {
|
||||
fn is_focused(&self) -> bool {
|
||||
State::is_focused(self)
|
||||
Self::is_focused(self)
|
||||
}
|
||||
|
||||
fn focus(&mut self) {
|
||||
State::focus(self);
|
||||
Self::focus(self);
|
||||
}
|
||||
|
||||
fn unfocus(&mut self) {
|
||||
State::unfocus(self);
|
||||
Self::unfocus(self);
|
||||
}
|
||||
}
|
||||
|
||||
impl operation::TextInput for State {
|
||||
fn move_cursor_to_front(&mut self) {
|
||||
State::move_cursor_to_front(self);
|
||||
Self::move_cursor_to_front(self);
|
||||
}
|
||||
|
||||
fn move_cursor_to_end(&mut self) {
|
||||
State::move_cursor_to_end(self);
|
||||
Self::move_cursor_to_end(self);
|
||||
}
|
||||
|
||||
fn move_cursor_to(&mut self, position: usize) {
|
||||
State::move_cursor_to(self, position);
|
||||
Self::move_cursor_to(self, position);
|
||||
}
|
||||
|
||||
fn select_all(&mut self) {
|
||||
State::select_all(self);
|
||||
Self::select_all(self);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue