cleanup
This commit is contained in:
parent
9316537d64
commit
8149faca4d
13 changed files with 43 additions and 43 deletions
|
|
@ -7,7 +7,7 @@ edition = "2021"
|
|||
name = "cosmic"
|
||||
|
||||
[features]
|
||||
default = ["tiny_skia", "winit", "tokio", "a11y", "lazy"]
|
||||
default = ["tiny_skia", "wayland", "applet", "tokio", "a11y", "lazy"]
|
||||
debug = ["iced/debug"]
|
||||
lazy = ["iced/lazy"]
|
||||
a11y = ["iced/a11y", "iced_accessibility"]
|
||||
|
|
|
|||
2
iced
2
iced
|
|
@ -1 +1 @@
|
|||
Subproject commit afaabc4ec9cfecae443b5da98bae905d31baa97b
|
||||
Subproject commit c95da35ad4e88689bba6b0f94edad21db1600fb6
|
||||
|
|
@ -5,12 +5,12 @@ use iced::{
|
|||
widget::{self, Container},
|
||||
Color, Element, Length, Rectangle, Settings,
|
||||
};
|
||||
use iced_core::BorderRadius;
|
||||
use iced_native::command::platform_specific::wayland::{
|
||||
use iced_core::layout::Limits;
|
||||
use iced_style::{button::StyleSheet, container::Appearance};
|
||||
use iced_widget::runtime::command::platform_specific::wayland::{
|
||||
popup::{SctkPopupSettings, SctkPositioner},
|
||||
window::SctkWindowSettings,
|
||||
};
|
||||
use iced_style::{button::StyleSheet, container::Appearance};
|
||||
use sctk::reexports::protocols::xdg::shell::client::xdg_positioner::{Anchor, Gravity};
|
||||
|
||||
use crate::{theme::Button, Renderer};
|
||||
|
|
@ -19,14 +19,15 @@ pub use cosmic_panel_config;
|
|||
|
||||
const APPLET_PADDING: u32 = 8;
|
||||
|
||||
#[must_use]
|
||||
pub fn applet_button_theme() -> Button {
|
||||
Button::Custom {
|
||||
active: Box::new(|t| iced_style::button::Appearance {
|
||||
border_radius: BorderRadius::from(0.0),
|
||||
border_radius: 0.0,
|
||||
..t.active(&Button::Text)
|
||||
}),
|
||||
hover: Box::new(|t| iced_style::button::Appearance {
|
||||
border_radius: BorderRadius::from(0.0),
|
||||
border_radius: 0.0,
|
||||
..t.hovered(&Button::Text)
|
||||
}),
|
||||
}
|
||||
|
|
@ -63,6 +64,7 @@ impl Default for CosmicAppletHelper {
|
|||
}
|
||||
|
||||
impl CosmicAppletHelper {
|
||||
#[must_use]
|
||||
pub fn suggested_size(&self) -> (u16, u16) {
|
||||
match &self.size {
|
||||
Size::PanelSize(size) => match size {
|
||||
|
|
@ -87,18 +89,20 @@ impl CosmicAppletHelper {
|
|||
}
|
||||
|
||||
#[must_use]
|
||||
#[allow(clippy::cast_precision_loss)]
|
||||
pub fn window_settings_with_flags<F>(&self, flags: F) -> Settings<F> {
|
||||
let (width, height) = self.suggested_size();
|
||||
let width = u32::from(width);
|
||||
let height = u32::from(height);
|
||||
Settings {
|
||||
initial_surface: InitialSurface::XdgWindow(SctkWindowSettings {
|
||||
iced_settings: iced_native::window::Settings {
|
||||
size: (width + APPLET_PADDING * 2, height + APPLET_PADDING * 2),
|
||||
min_size: Some((width + APPLET_PADDING * 2, height + APPLET_PADDING * 2)),
|
||||
max_size: Some((width + APPLET_PADDING * 2, height + APPLET_PADDING * 2)),
|
||||
..Default::default()
|
||||
},
|
||||
size: (width + APPLET_PADDING * 2, height + APPLET_PADDING * 2),
|
||||
size_limits: Limits::NONE
|
||||
.min_height(height as f32 + APPLET_PADDING as f32 * 2.0)
|
||||
.max_height(height as f32 + APPLET_PADDING as f32 * 2.0)
|
||||
.min_width(width as f32 + APPLET_PADDING as f32 * 2.0)
|
||||
.max_width(width as f32 + APPLET_PADDING as f32 * 2.0),
|
||||
|
||||
..Default::default()
|
||||
}),
|
||||
..crate::settings_with_flags(flags)
|
||||
|
|
@ -124,7 +128,7 @@ impl CosmicAppletHelper {
|
|||
&self,
|
||||
content: impl Into<Element<'a, Message, Renderer>>,
|
||||
) -> Container<'a, Message, Renderer> {
|
||||
let (valign, halign) = match self.anchor {
|
||||
let (vertical_align, horizontal_align) = match self.anchor {
|
||||
PanelAnchor::Left => (Vertical::Center, Horizontal::Left),
|
||||
PanelAnchor::Right => (Vertical::Center, Horizontal::Right),
|
||||
PanelAnchor::Top => (Vertical::Top, Horizontal::Center),
|
||||
|
|
@ -142,15 +146,16 @@ impl CosmicAppletHelper {
|
|||
))
|
||||
.width(Length::Shrink)
|
||||
.height(Length::Shrink)
|
||||
.align_x(halign)
|
||||
.align_y(valign)
|
||||
.align_x(horizontal_align)
|
||||
.align_y(vertical_align)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
#[allow(clippy::cast_possible_wrap)]
|
||||
pub fn get_popup_settings(
|
||||
&self,
|
||||
parent: iced_native::window::Id,
|
||||
id: iced_native::window::Id,
|
||||
parent: iced_core::window::Id,
|
||||
id: iced_core::window::Id,
|
||||
size: Option<(u32, u32)>,
|
||||
width_padding: Option<i32>,
|
||||
height_padding: Option<i32>,
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ pub enum Message {
|
|||
Search,
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn subscription() -> Subscription<Message> {
|
||||
subscription::events_with(|event, status| match (event, status) {
|
||||
// Focus
|
||||
|
|
@ -61,7 +60,6 @@ pub fn subscription() -> Subscription<Message> {
|
|||
}
|
||||
|
||||
/// Unfocuses any actively-focused widget.
|
||||
#[must_use]
|
||||
pub fn unfocus<Message: 'static>() -> Command<Message> {
|
||||
Command::<Message>::widget(unfocus_operation())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,12 +12,10 @@ pub use self::segmented_button::SegmentedButton;
|
|||
|
||||
use cosmic_theme::Component;
|
||||
use cosmic_theme::LayeredTheme;
|
||||
use iced_core::renderer::BorderRadius;
|
||||
use iced_style::application;
|
||||
use iced_style::button;
|
||||
use iced_style::checkbox;
|
||||
use iced_style::container;
|
||||
use iced_style::core::text;
|
||||
use iced_style::menu;
|
||||
use iced_style::pane_grid;
|
||||
use iced_style::pick_list;
|
||||
|
|
@ -865,7 +863,7 @@ impl scrollable::StyleSheet for Theme {
|
|||
fn hovered(
|
||||
&self,
|
||||
_style: &Self::Style,
|
||||
is_mouse_over_scrollbar: bool,
|
||||
_is_mouse_over_scrollbar: bool,
|
||||
) -> scrollable::Scrollbar {
|
||||
let theme = self.cosmic();
|
||||
|
||||
|
|
@ -1082,11 +1080,11 @@ impl text_input::StyleSheet for Theme {
|
|||
palette.accent.base.into()
|
||||
}
|
||||
|
||||
fn disabled_color(&self, style: &Self::Style) -> Color {
|
||||
fn disabled_color(&self, _style: &Self::Style) -> Color {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn disabled(&self, style: &Self::Style) -> text_input::Appearance {
|
||||
fn disabled(&self, _style: &Self::Style) -> text_input::Appearance {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use iced_core::layout;
|
|||
use iced_core::mouse;
|
||||
use iced_core::overlay;
|
||||
use iced_core::renderer;
|
||||
use iced_core::widget::{Operation, Tree};
|
||||
use iced_core::widget::Tree;
|
||||
use iced_core::{Clipboard, Element, Layout, Length, Padding, Point, Rectangle, Shell, Widget};
|
||||
|
||||
pub use iced_style::container::{Appearance, StyleSheet};
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use iced_core::layout;
|
|||
use iced_core::mouse;
|
||||
use iced_core::overlay;
|
||||
use iced_core::renderer;
|
||||
use iced_core::widget::{Operation, Tree};
|
||||
use iced_core::widget::Tree;
|
||||
use iced_core::{Clipboard, Element, Layout, Length, Padding, Point, Rectangle, Shell, Widget};
|
||||
pub use iced_style::container::{Appearance, StyleSheet};
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ impl<'a> IconSource<'a> {
|
|||
} else if let Some(icon) = icon {
|
||||
Handle::Image(icon.into())
|
||||
} else {
|
||||
eprintln!("icon '{:?}' size {} not found", self, size);
|
||||
eprintln!("icon '{self:?}' size {size} not found");
|
||||
Handle::Image(image::Handle::from_memory(Vec::new()))
|
||||
}
|
||||
}
|
||||
|
|
@ -236,8 +236,8 @@ pub fn icon<'a>(source: impl Into<IconSource<'a>>, size: u16) -> Icon<'a> {
|
|||
impl<'a> Icon<'a> {
|
||||
fn raster_element<Message: 'static>(&self, handle: image::Handle) -> Element<'static, Message> {
|
||||
Image::new(handle)
|
||||
.width(self.width.unwrap_or(Length::Fixed(self.size as f32)))
|
||||
.height(self.height.unwrap_or(Length::Fixed(self.size as f32)))
|
||||
.width(self.width.unwrap_or(Length::Fixed(f32::from(self.size))))
|
||||
.height(self.height.unwrap_or(Length::Fixed(f32::from(self.size))))
|
||||
.content_fit(self.content_fit)
|
||||
.into()
|
||||
}
|
||||
|
|
@ -245,8 +245,8 @@ impl<'a> Icon<'a> {
|
|||
fn svg_element<Message: 'static>(&self, handle: svg::Handle) -> Element<'static, Message> {
|
||||
svg::Svg::<Renderer>::new(handle)
|
||||
.style(self.style.clone())
|
||||
.width(self.width.unwrap_or(Length::Fixed(self.size as f32)))
|
||||
.height(self.height.unwrap_or(Length::Fixed(self.size as f32)))
|
||||
.width(self.width.unwrap_or(Length::Fixed(f32::from(self.size))))
|
||||
.height(self.height.unwrap_or(Length::Fixed(f32::from(self.size))))
|
||||
.content_fit(self.content_fit)
|
||||
.into()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use iced_core::layout;
|
|||
use iced_core::mouse;
|
||||
use iced_core::overlay;
|
||||
use iced_core::renderer;
|
||||
use iced_core::widget::{Operation, Tree};
|
||||
use iced_core::widget::Tree;
|
||||
use iced_core::{Clipboard, Element, Layout, Length, Padding, Point, Rectangle, Shell, Widget};
|
||||
use std::{fmt::Debug, hash::Hash};
|
||||
|
||||
|
|
|
|||
|
|
@ -41,10 +41,10 @@ async fn start_listening<I: Copy, R: 'static + Hash + Copy + Send + Sync + Debug
|
|||
Some(u) => {
|
||||
if let Some(prev) = map.get(&u.0) {
|
||||
let new = u.1;
|
||||
if prev.width != new.width
|
||||
|| prev.height != new.height
|
||||
|| prev.x != new.x
|
||||
|| prev.y != new.y
|
||||
if (prev.width - new.width).abs() > 0.1
|
||||
|| (prev.height - new.height).abs() > 0.1
|
||||
|| (prev.x - new.x).abs() > 0.1
|
||||
|| (prev.y - new.y).abs() > 0.1
|
||||
{
|
||||
map.insert(u.0, new);
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ pub struct Model {
|
|||
|
||||
impl Model {
|
||||
/// Focuses the search field.
|
||||
#[must_use]
|
||||
pub fn focus<Message: 'static>(&mut self) -> crate::iced::Command<Message> {
|
||||
self.state = State::Active;
|
||||
iced::widget::text_input::focus(self.input_id.clone())
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use iced::{
|
|||
};
|
||||
use iced_core::renderer::BorderRadius;
|
||||
use iced_core::text::{LineHeight, Shaping};
|
||||
use iced_core::widget::{self, operation, tree, Operation};
|
||||
use iced_core::widget::{self, operation, tree};
|
||||
use iced_core::{layout, renderer, widget::Tree, Clipboard, Layout, Shell, Widget};
|
||||
use std::marker::PhantomData;
|
||||
|
||||
|
|
@ -391,7 +391,7 @@ where
|
|||
&self,
|
||||
tree: &mut Tree,
|
||||
_layout: Layout<'_>,
|
||||
renderer: &Renderer,
|
||||
_renderer: &Renderer,
|
||||
operation: &mut dyn iced_core::widget::Operation<
|
||||
iced_core::widget::OperationOutputWrapper<Message>,
|
||||
>,
|
||||
|
|
@ -568,10 +568,10 @@ where
|
|||
// Draw the text in this button.
|
||||
renderer.fill_text(iced_core::text::Text {
|
||||
content: text,
|
||||
size: f32::from(self.font_size),
|
||||
size: self.font_size,
|
||||
bounds,
|
||||
color: status_appearance.text_color,
|
||||
font: font.clone(),
|
||||
font,
|
||||
horizontal_alignment,
|
||||
vertical_alignment: alignment::Vertical::Center,
|
||||
shaping: Shaping::Advanced,
|
||||
|
|
@ -642,7 +642,6 @@ where
|
|||
}
|
||||
|
||||
/// A command that focuses a segmented item stored in a widget.
|
||||
#[must_use]
|
||||
pub fn focus<Message: 'static>(id: Id) -> Command<Message> {
|
||||
Command::widget(operation::focusable::focus(id.0))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ impl<'a, Message: 'static + Clone> From<Warning<'a, Message>> for Element<'a, Me
|
|||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn warning_container(theme: &Theme) -> widget::container::Appearance {
|
||||
widget::container::Appearance {
|
||||
text_color: Some(theme.cosmic().warning.on.into()),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue