This commit is contained in:
Ashley Wulber 2023-05-10 18:48:14 -04:00
parent 9316537d64
commit 8149faca4d
No known key found for this signature in database
GPG key ID: 5216D4F46A90A820
13 changed files with 43 additions and 43 deletions

View file

@ -7,7 +7,7 @@ edition = "2021"
name = "cosmic" name = "cosmic"
[features] [features]
default = ["tiny_skia", "winit", "tokio", "a11y", "lazy"] default = ["tiny_skia", "wayland", "applet", "tokio", "a11y", "lazy"]
debug = ["iced/debug"] debug = ["iced/debug"]
lazy = ["iced/lazy"] lazy = ["iced/lazy"]
a11y = ["iced/a11y", "iced_accessibility"] a11y = ["iced/a11y", "iced_accessibility"]

2
iced

@ -1 +1 @@
Subproject commit afaabc4ec9cfecae443b5da98bae905d31baa97b Subproject commit c95da35ad4e88689bba6b0f94edad21db1600fb6

View file

@ -5,12 +5,12 @@ use iced::{
widget::{self, Container}, widget::{self, Container},
Color, Element, Length, Rectangle, Settings, Color, Element, Length, Rectangle, Settings,
}; };
use iced_core::BorderRadius; use iced_core::layout::Limits;
use iced_native::command::platform_specific::wayland::{ use iced_style::{button::StyleSheet, container::Appearance};
use iced_widget::runtime::command::platform_specific::wayland::{
popup::{SctkPopupSettings, SctkPositioner}, popup::{SctkPopupSettings, SctkPositioner},
window::SctkWindowSettings, window::SctkWindowSettings,
}; };
use iced_style::{button::StyleSheet, container::Appearance};
use sctk::reexports::protocols::xdg::shell::client::xdg_positioner::{Anchor, Gravity}; use sctk::reexports::protocols::xdg::shell::client::xdg_positioner::{Anchor, Gravity};
use crate::{theme::Button, Renderer}; use crate::{theme::Button, Renderer};
@ -19,14 +19,15 @@ pub use cosmic_panel_config;
const APPLET_PADDING: u32 = 8; const APPLET_PADDING: u32 = 8;
#[must_use]
pub fn applet_button_theme() -> Button { pub fn applet_button_theme() -> Button {
Button::Custom { Button::Custom {
active: Box::new(|t| iced_style::button::Appearance { active: Box::new(|t| iced_style::button::Appearance {
border_radius: BorderRadius::from(0.0), border_radius: 0.0,
..t.active(&Button::Text) ..t.active(&Button::Text)
}), }),
hover: Box::new(|t| iced_style::button::Appearance { hover: Box::new(|t| iced_style::button::Appearance {
border_radius: BorderRadius::from(0.0), border_radius: 0.0,
..t.hovered(&Button::Text) ..t.hovered(&Button::Text)
}), }),
} }
@ -63,6 +64,7 @@ impl Default for CosmicAppletHelper {
} }
impl CosmicAppletHelper { impl CosmicAppletHelper {
#[must_use]
pub fn suggested_size(&self) -> (u16, u16) { pub fn suggested_size(&self) -> (u16, u16) {
match &self.size { match &self.size {
Size::PanelSize(size) => match size { Size::PanelSize(size) => match size {
@ -87,18 +89,20 @@ impl CosmicAppletHelper {
} }
#[must_use] #[must_use]
#[allow(clippy::cast_precision_loss)]
pub fn window_settings_with_flags<F>(&self, flags: F) -> Settings<F> { pub fn window_settings_with_flags<F>(&self, flags: F) -> Settings<F> {
let (width, height) = self.suggested_size(); let (width, height) = self.suggested_size();
let width = u32::from(width); let width = u32::from(width);
let height = u32::from(height); let height = u32::from(height);
Settings { Settings {
initial_surface: InitialSurface::XdgWindow(SctkWindowSettings { initial_surface: InitialSurface::XdgWindow(SctkWindowSettings {
iced_settings: iced_native::window::Settings { size: (width + APPLET_PADDING * 2, height + APPLET_PADDING * 2),
size: (width + APPLET_PADDING * 2, height + APPLET_PADDING * 2), size_limits: Limits::NONE
min_size: Some((width + APPLET_PADDING * 2, height + APPLET_PADDING * 2)), .min_height(height as f32 + APPLET_PADDING as f32 * 2.0)
max_size: Some((width + APPLET_PADDING * 2, height + APPLET_PADDING * 2)), .max_height(height as f32 + APPLET_PADDING as f32 * 2.0)
..Default::default() .min_width(width as f32 + APPLET_PADDING as f32 * 2.0)
}, .max_width(width as f32 + APPLET_PADDING as f32 * 2.0),
..Default::default() ..Default::default()
}), }),
..crate::settings_with_flags(flags) ..crate::settings_with_flags(flags)
@ -124,7 +128,7 @@ impl CosmicAppletHelper {
&self, &self,
content: impl Into<Element<'a, Message, Renderer>>, content: impl Into<Element<'a, Message, Renderer>>,
) -> Container<'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::Left => (Vertical::Center, Horizontal::Left),
PanelAnchor::Right => (Vertical::Center, Horizontal::Right), PanelAnchor::Right => (Vertical::Center, Horizontal::Right),
PanelAnchor::Top => (Vertical::Top, Horizontal::Center), PanelAnchor::Top => (Vertical::Top, Horizontal::Center),
@ -142,15 +146,16 @@ impl CosmicAppletHelper {
)) ))
.width(Length::Shrink) .width(Length::Shrink)
.height(Length::Shrink) .height(Length::Shrink)
.align_x(halign) .align_x(horizontal_align)
.align_y(valign) .align_y(vertical_align)
} }
#[must_use] #[must_use]
#[allow(clippy::cast_possible_wrap)]
pub fn get_popup_settings( pub fn get_popup_settings(
&self, &self,
parent: iced_native::window::Id, parent: iced_core::window::Id,
id: iced_native::window::Id, id: iced_core::window::Id,
size: Option<(u32, u32)>, size: Option<(u32, u32)>,
width_padding: Option<i32>, width_padding: Option<i32>,
height_padding: Option<i32>, height_padding: Option<i32>,

View file

@ -14,7 +14,6 @@ pub enum Message {
Search, Search,
} }
#[must_use]
pub fn subscription() -> Subscription<Message> { pub fn subscription() -> Subscription<Message> {
subscription::events_with(|event, status| match (event, status) { subscription::events_with(|event, status| match (event, status) {
// Focus // Focus
@ -61,7 +60,6 @@ pub fn subscription() -> Subscription<Message> {
} }
/// Unfocuses any actively-focused widget. /// Unfocuses any actively-focused widget.
#[must_use]
pub fn unfocus<Message: 'static>() -> Command<Message> { pub fn unfocus<Message: 'static>() -> Command<Message> {
Command::<Message>::widget(unfocus_operation()) Command::<Message>::widget(unfocus_operation())
} }

View file

@ -12,12 +12,10 @@ pub use self::segmented_button::SegmentedButton;
use cosmic_theme::Component; use cosmic_theme::Component;
use cosmic_theme::LayeredTheme; use cosmic_theme::LayeredTheme;
use iced_core::renderer::BorderRadius;
use iced_style::application; use iced_style::application;
use iced_style::button; use iced_style::button;
use iced_style::checkbox; use iced_style::checkbox;
use iced_style::container; use iced_style::container;
use iced_style::core::text;
use iced_style::menu; use iced_style::menu;
use iced_style::pane_grid; use iced_style::pane_grid;
use iced_style::pick_list; use iced_style::pick_list;
@ -865,7 +863,7 @@ impl scrollable::StyleSheet for Theme {
fn hovered( fn hovered(
&self, &self,
_style: &Self::Style, _style: &Self::Style,
is_mouse_over_scrollbar: bool, _is_mouse_over_scrollbar: bool,
) -> scrollable::Scrollbar { ) -> scrollable::Scrollbar {
let theme = self.cosmic(); let theme = self.cosmic();
@ -1082,11 +1080,11 @@ impl text_input::StyleSheet for Theme {
palette.accent.base.into() palette.accent.base.into()
} }
fn disabled_color(&self, style: &Self::Style) -> Color { fn disabled_color(&self, _style: &Self::Style) -> Color {
todo!() todo!()
} }
fn disabled(&self, style: &Self::Style) -> text_input::Appearance { fn disabled(&self, _style: &Self::Style) -> text_input::Appearance {
todo!() todo!()
} }
} }

View file

@ -6,7 +6,7 @@ use iced_core::layout;
use iced_core::mouse; use iced_core::mouse;
use iced_core::overlay; use iced_core::overlay;
use iced_core::renderer; 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 iced_core::{Clipboard, Element, Layout, Length, Padding, Point, Rectangle, Shell, Widget};
pub use iced_style::container::{Appearance, StyleSheet}; pub use iced_style::container::{Appearance, StyleSheet};

View file

@ -6,7 +6,7 @@ use iced_core::layout;
use iced_core::mouse; use iced_core::mouse;
use iced_core::overlay; use iced_core::overlay;
use iced_core::renderer; 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 iced_core::{Clipboard, Element, Layout, Length, Padding, Point, Rectangle, Shell, Widget};
pub use iced_style::container::{Appearance, StyleSheet}; pub use iced_style::container::{Appearance, StyleSheet};

View file

@ -79,7 +79,7 @@ impl<'a> IconSource<'a> {
} else if let Some(icon) = icon { } else if let Some(icon) = icon {
Handle::Image(icon.into()) Handle::Image(icon.into())
} else { } else {
eprintln!("icon '{:?}' size {} not found", self, size); eprintln!("icon '{self:?}' size {size} not found");
Handle::Image(image::Handle::from_memory(Vec::new())) 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> { impl<'a> Icon<'a> {
fn raster_element<Message: 'static>(&self, handle: image::Handle) -> Element<'static, Message> { fn raster_element<Message: 'static>(&self, handle: image::Handle) -> Element<'static, Message> {
Image::new(handle) Image::new(handle)
.width(self.width.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(self.size as f32))) .height(self.height.unwrap_or(Length::Fixed(f32::from(self.size))))
.content_fit(self.content_fit) .content_fit(self.content_fit)
.into() .into()
} }
@ -245,8 +245,8 @@ impl<'a> Icon<'a> {
fn svg_element<Message: 'static>(&self, handle: svg::Handle) -> Element<'static, Message> { fn svg_element<Message: 'static>(&self, handle: svg::Handle) -> Element<'static, Message> {
svg::Svg::<Renderer>::new(handle) svg::Svg::<Renderer>::new(handle)
.style(self.style.clone()) .style(self.style.clone())
.width(self.width.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(self.size as f32))) .height(self.height.unwrap_or(Length::Fixed(f32::from(self.size))))
.content_fit(self.content_fit) .content_fit(self.content_fit)
.into() .into()
} }

View file

@ -10,7 +10,7 @@ use iced_core::layout;
use iced_core::mouse; use iced_core::mouse;
use iced_core::overlay; use iced_core::overlay;
use iced_core::renderer; 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 iced_core::{Clipboard, Element, Layout, Length, Padding, Point, Rectangle, Shell, Widget};
use std::{fmt::Debug, hash::Hash}; use std::{fmt::Debug, hash::Hash};

View file

@ -41,10 +41,10 @@ async fn start_listening<I: Copy, R: 'static + Hash + Copy + Send + Sync + Debug
Some(u) => { Some(u) => {
if let Some(prev) = map.get(&u.0) { if let Some(prev) = map.get(&u.0) {
let new = u.1; let new = u.1;
if prev.width != new.width if (prev.width - new.width).abs() > 0.1
|| prev.height != new.height || (prev.height - new.height).abs() > 0.1
|| prev.x != new.x || (prev.x - new.x).abs() > 0.1
|| prev.y != new.y || (prev.y - new.y).abs() > 0.1
{ {
map.insert(u.0, new); map.insert(u.0, new);
return ( return (

View file

@ -13,7 +13,6 @@ pub struct Model {
impl Model { impl Model {
/// Focuses the search field. /// Focuses the search field.
#[must_use]
pub fn focus<Message: 'static>(&mut self) -> crate::iced::Command<Message> { pub fn focus<Message: 'static>(&mut self) -> crate::iced::Command<Message> {
self.state = State::Active; self.state = State::Active;
iced::widget::text_input::focus(self.input_id.clone()) iced::widget::text_input::focus(self.input_id.clone())

View file

@ -12,7 +12,7 @@ use iced::{
}; };
use iced_core::renderer::BorderRadius; use iced_core::renderer::BorderRadius;
use iced_core::text::{LineHeight, Shaping}; 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 iced_core::{layout, renderer, widget::Tree, Clipboard, Layout, Shell, Widget};
use std::marker::PhantomData; use std::marker::PhantomData;
@ -391,7 +391,7 @@ where
&self, &self,
tree: &mut Tree, tree: &mut Tree,
_layout: Layout<'_>, _layout: Layout<'_>,
renderer: &Renderer, _renderer: &Renderer,
operation: &mut dyn iced_core::widget::Operation< operation: &mut dyn iced_core::widget::Operation<
iced_core::widget::OperationOutputWrapper<Message>, iced_core::widget::OperationOutputWrapper<Message>,
>, >,
@ -568,10 +568,10 @@ where
// Draw the text in this button. // Draw the text in this button.
renderer.fill_text(iced_core::text::Text { renderer.fill_text(iced_core::text::Text {
content: text, content: text,
size: f32::from(self.font_size), size: self.font_size,
bounds, bounds,
color: status_appearance.text_color, color: status_appearance.text_color,
font: font.clone(), font,
horizontal_alignment, horizontal_alignment,
vertical_alignment: alignment::Vertical::Center, vertical_alignment: alignment::Vertical::Center,
shaping: Shaping::Advanced, shaping: Shaping::Advanced,
@ -642,7 +642,6 @@ where
} }
/// A command that focuses a segmented item stored in a widget. /// A command that focuses a segmented item stored in a widget.
#[must_use]
pub fn focus<Message: 'static>(id: Id) -> Command<Message> { pub fn focus<Message: 'static>(id: Id) -> Command<Message> {
Command::widget(operation::focusable::focus(id.0)) Command::widget(operation::focusable::focus(id.0))
} }

View file

@ -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 { pub fn warning_container(theme: &Theme) -> widget::container::Appearance {
widget::container::Appearance { widget::container::Appearance {
text_color: Some(theme.cosmic().warning.on.into()), text_color: Some(theme.cosmic().warning.on.into()),