udpate iced to use latest rebase

This commit is contained in:
Ashley Wulber 2023-06-15 11:16:32 -04:00 committed by Michael Murphy
parent 804b183492
commit 850968715c
13 changed files with 87 additions and 73 deletions

View file

@ -7,23 +7,21 @@ edition = "2021"
name = "cosmic"
[features]
default = ["tiny_skia", "winit", "tokio", "a11y"]
default = ["winit", "tokio", "a11y"]
debug = ["iced/debug"]
a11y = ["iced/a11y", "iced_accessibility"]
tiny_skia = ["iced/tiny-skia", "iced_tiny_skia"]
wayland = ["iced/wayland", "iced_sctk", "sctk",]
wgpu = ["iced/wgpu", "iced_wgpu"]
tokio = ["dep:tokio", "iced/tokio"]
smol = ["iced/smol"]
winit = ["iced/winit", "iced_winit"]
winit_tiny_skia = ["winit", "tiny_skia"]
winit_wgpu = ["winit", "wgpu"]
[dependencies]
apply = "0.3.0"
derive_setters = "0.1.5"
lazy_static = "1.4.0"
palette = "0.6.1"
palette = "0.7"
tokio = { version = "1.24.2", optional = true }
sctk = { package = "smithay-client-toolkit", git = "https://github.com/pop-os/client-toolkit", optional = true, tag = "themed-pointer"}
slotmap = "1.0.6"
@ -61,9 +59,9 @@ path = "iced/futures"
path = "iced/accessibility"
optional = true
[dependencies.iced_tiny_skia]
path = "iced/tiny_skia"
optional = true
[dependencies.iced_style]
path = "iced/style"

View file

@ -17,7 +17,7 @@ theme-from-image = ["kmeans_colors", "contrast-derivation", "float-cmp", "image"
hex-color = ["hex"]
[dependencies]
palette = {version = "0.6", features = ["serializing"] }
palette = {version = "0.7", features = ["serializing"] }
anyhow = "1.0"
hex = {version = "0.4.3", optional = true}
kmeans_colors = { version = "0.5", features = ["palette_color"], default-features = false, optional = true }

View file

@ -6,4 +6,4 @@ edition = "2021"
publish = false
[dependencies]
libcosmic = { path = "../..", default-features = false, features = ["wayland", "tokio", "tiny_skia", "a11y"] }
libcosmic = { path = "../..", default-features = false, features = ["wayland", "tokio", "a11y"] }

View file

@ -8,7 +8,7 @@ publish = false
[dependencies]
apply = "0.3.0"
fraction = "0.13.0"
libcosmic = { path = "../..", default-features = false, features = ["debug", "winit_tiny_skia", "a11y"] }
libcosmic = { path = "../..", default-features = false, features = ["debug", "winit", "a11y"] }
once_cell = "1.15"
slotmap = "1.0.6"
env_logger = "0.10"

2
iced

@ -1 +1 @@
Subproject commit 978e9fe8142bb301ce27ad23ce0afb12ef8918a7
Subproject commit c308e2266867a7bb4dfadb2dc8bdf310b7c87ee8

View file

@ -4,6 +4,7 @@
pub mod expander;
mod segmented_button;
use std::f32::consts::PI;
use std::hash::Hash;
use std::hash::Hasher;
use std::rc::Rc;
@ -16,7 +17,9 @@ use cosmic_config::CosmicConfigEntry;
use cosmic_theme::util::CssColor;
use cosmic_theme::Component;
use cosmic_theme::LayeredTheme;
use iced_core::renderer::BorderRadius;
use iced_core::gradient::Linear;
use iced_core::BorderRadius;
use iced_core::Radians;
use iced_futures::Subscription;
use iced_style::application;
use iced_style::button;
@ -233,8 +236,8 @@ impl button::StyleSheet for Theme {
let component = style.cosmic(self);
button::Appearance {
border_radius: match style {
Button::Link => 0.0,
_ => 24.0,
Button::Link => 0.0.into(),
_ => 24.0.into(),
},
background: match style {
Button::Link | Button::Text => None,
@ -317,7 +320,7 @@ impl checkbox::StyleSheet for Theme {
palette.background.base.into()
}),
icon_color: palette.accent.on.into(),
border_radius: 4.0,
border_radius: 4.0.into(),
border_width: if is_checked { 0.0 } else { 1.0 },
border_color: if is_checked {
palette.accent.base
@ -334,7 +337,7 @@ impl checkbox::StyleSheet for Theme {
palette.background.base.into()
}),
icon_color: palette.background.on.into(),
border_radius: 4.0,
border_radius: 4.0.into(),
border_width: if is_checked { 0.0 } else { 1.0 },
border_color: neutral_7.into(),
text_color: None,
@ -346,7 +349,7 @@ impl checkbox::StyleSheet for Theme {
palette.background.base.into()
}),
icon_color: palette.success.on.into(),
border_radius: 4.0,
border_radius: 4.0.into(),
border_width: if is_checked { 0.0 } else { 1.0 },
border_color: if is_checked {
palette.success.base
@ -363,7 +366,7 @@ impl checkbox::StyleSheet for Theme {
palette.background.base.into()
}),
icon_color: palette.destructive.on.into(),
border_radius: 4.0,
border_radius: 4.0.into(),
border_width: if is_checked { 0.0 } else { 1.0 },
border_color: if is_checked {
palette.destructive.base
@ -390,7 +393,7 @@ impl checkbox::StyleSheet for Theme {
neutral_10.into()
}),
icon_color: palette.accent.on.into(),
border_radius: 4.0,
border_radius: 4.0.into(),
border_width: if is_checked { 0.0 } else { 1.0 },
border_color: if is_checked {
palette.accent.base
@ -407,7 +410,7 @@ impl checkbox::StyleSheet for Theme {
neutral_10.into()
}),
icon_color: self.current_container().on.into(),
border_radius: 4.0,
border_radius: 4.0.into(),
border_width: if is_checked { 0.0 } else { 1.0 },
border_color: if is_checked {
self.current_container().base
@ -424,7 +427,7 @@ impl checkbox::StyleSheet for Theme {
neutral_10.into()
}),
icon_color: palette.success.on.into(),
border_radius: 4.0,
border_radius: 4.0.into(),
border_width: if is_checked { 0.0 } else { 1.0 },
border_color: if is_checked {
palette.success.base
@ -441,7 +444,7 @@ impl checkbox::StyleSheet for Theme {
neutral_10.into()
}),
icon_color: palette.destructive.on.into(),
border_radius: 4.0,
border_radius: 4.0.into(),
border_width: if is_checked { 0.0 } else { 1.0 },
border_color: if is_checked {
palette.destructive.base
@ -519,10 +522,17 @@ impl container::StyleSheet for Theme {
}
Container::HeaderBar => {
let palette = self.cosmic();
let mut header_top = palette.background.base;
let header_bottom = palette.background.base;
header_top.alpha = 0.8;
container::Appearance {
text_color: Some(Color::from(palette.background.on)),
background: Some(iced::Background::Color(palette.background.base.into())),
background: Some(iced::Background::Gradient(iced_core::Gradient::Linear(
Linear::new(Radians(3.0 * PI / 2.0))
.add_stop(0.0, header_top.into())
.add_stop(1.0, header_bottom.into()),
))),
border_radius: BorderRadius::from([16.0, 16.0, 0.0, 0.0]),
border_width: 0.0,
border_color: Color::TRANSPARENT,
@ -572,6 +582,7 @@ impl slider::StyleSheet for Theme {
Color::TRANSPARENT,
),
width: 4.0,
border_radius: 2.0.into(),
},
handle: slider::Handle {
@ -616,7 +627,7 @@ impl menu::StyleSheet for Theme {
text_color: cosmic.on_bg_color().into(),
background: Background::Color(cosmic.background.base.into()),
border_width: 0.0,
border_radius: 16.0,
border_radius: 16.0.into(),
border_color: Color::TRANSPARENT,
selected_text_color: cosmic.on_bg_color().into(),
// TODO doesn't seem to be specified
@ -638,7 +649,7 @@ impl pick_list::StyleSheet for Theme {
text_color: cosmic.on_bg_color().into(),
background: Color::TRANSPARENT.into(),
placeholder_color: cosmic.on_bg_color().into(),
border_radius: 24.0,
border_radius: 24.0.into(),
border_width: 0.0,
border_color: Color::TRANSPARENT,
// icon_size: 0.7, // TODO: how to replace
@ -772,6 +783,16 @@ impl pane_grid::StyleSheet for Theme {
width: 2.0,
})
}
fn hovered_region(&self, style: &Self::Style) -> pane_grid::Appearance {
let theme = self.cosmic();
pane_grid::Appearance {
background: Background::Color(theme.bg_color().into()),
border_width: 2.0,
border_color: theme.bg_divider().into(),
border_radius: 0.0.into(),
}
}
}
/*
@ -802,17 +823,17 @@ impl progress_bar::StyleSheet for Theme {
ProgressBar::Primary => progress_bar::Appearance {
background: Color::from(theme.background.divider).into(),
bar: Color::from(theme.accent.base).into(),
border_radius: 2.0,
border_radius: 2.0.into(),
},
ProgressBar::Success => progress_bar::Appearance {
background: Color::from(theme.background.divider).into(),
bar: Color::from(theme.success.base).into(),
border_radius: 2.0,
border_radius: 2.0.into(),
},
ProgressBar::Danger => progress_bar::Appearance {
background: Color::from(theme.background.divider).into(),
bar: Color::from(theme.destructive.base).into(),
border_radius: 2.0,
border_radius: 2.0.into(),
},
ProgressBar::Custom(f) => f(self),
}
@ -845,19 +866,19 @@ impl rule::StyleSheet for Theme {
Rule::Default => rule::Appearance {
color: self.current_container().divider.into(),
width: 1,
radius: 0.0,
radius: 0.0.into(),
fill_mode: rule::FillMode::Full,
},
Rule::LightDivider => rule::Appearance {
color: self.current_container().divider.into(),
width: 1,
radius: 0.0,
radius: 0.0.into(),
fill_mode: rule::FillMode::Padded(10),
},
Rule::HeavyDivider => rule::Appearance {
color: self.current_container().divider.into(),
width: 4,
radius: 4.0,
radius: 4.0.into(),
fill_mode: rule::FillMode::Full,
},
Rule::Custom(f) => f(self),
@ -876,12 +897,12 @@ impl scrollable::StyleSheet for Theme {
background: Some(Background::Color(
self.current_container().component.base.into(),
)),
border_radius: 4.0,
border_radius: 4.0.into(),
border_width: 0.0,
border_color: Color::TRANSPARENT,
scroller: scrollable::Scroller {
color: self.current_container().component.divider.into(),
border_radius: 4.0,
border_radius: 4.0.into(),
border_width: 0.0,
border_color: Color::TRANSPARENT,
},
@ -899,12 +920,12 @@ impl scrollable::StyleSheet for Theme {
background: Some(Background::Color(
self.current_container().component.hover.into(),
)),
border_radius: 4.0,
border_radius: 4.0.into(),
border_width: 0.0,
border_color: Color::TRANSPARENT,
scroller: scrollable::Scroller {
color: theme.accent.base.into(),
border_radius: 4.0,
border_radius: 4.0.into(),
border_width: 0.0,
border_color: Color::TRANSPARENT,
},
@ -1028,14 +1049,14 @@ impl text_input::StyleSheet for Theme {
match style {
TextInput::Default => text_input::Appearance {
background: Color::from(bg).into(),
border_radius: 8.0,
border_radius: 8.0.into(),
border_width: 1.0,
border_color: self.current_container().component.divider.into(),
icon_color: self.current_container().on.into(),
},
TextInput::Search => text_input::Appearance {
background: Color::from(bg).into(),
border_radius: 24.0,
border_radius: 24.0.into(),
border_width: 0.0,
border_color: Color::TRANSPARENT,
icon_color: self.current_container().on.into(),
@ -1051,14 +1072,14 @@ impl text_input::StyleSheet for Theme {
match style {
TextInput::Default => text_input::Appearance {
background: Color::from(bg).into(),
border_radius: 8.0,
border_radius: 8.0.into(),
border_width: 1.0,
border_color: palette.accent.base.into(),
icon_color: self.current_container().on.into(),
},
TextInput::Search => text_input::Appearance {
background: Color::from(bg).into(),
border_radius: 24.0,
border_radius: 24.0.into(),
border_width: 0.0,
border_color: Color::TRANSPARENT,
icon_color: self.current_container().on.into(),
@ -1074,14 +1095,14 @@ impl text_input::StyleSheet for Theme {
match style {
TextInput::Default => text_input::Appearance {
background: Color::from(bg).into(),
border_radius: 8.0,
border_radius: 8.0.into(),
border_width: 1.0,
border_color: palette.accent.base.into(),
icon_color: self.current_container().on.into(),
},
TextInput::Search => text_input::Appearance {
background: Color::from(bg).into(),
border_radius: 24.0,
border_radius: 24.0.into(),
border_width: 0.0,
border_color: Color::TRANSPARENT,
icon_color: self.current_container().on.into(),

View file

@ -3,7 +3,7 @@
use crate::widget::segmented_button::{Appearance, ItemAppearance, StyleSheet};
use crate::{theme::Theme, widget::segmented_button::ItemStatusAppearance};
use iced_core::{renderer::BorderRadius, Background};
use iced_core::{Background, BorderRadius};
use palette::{rgb::Rgb, Alpha};
#[derive(Default)]
@ -141,7 +141,7 @@ impl StyleSheet for Theme {
mod horizontal {
use crate::widget::segmented_button::{ItemAppearance, ItemStatusAppearance};
use iced_core::{renderer::BorderRadius, Background};
use iced_core::{Background, BorderRadius};
use palette::{rgb::Rgb, Alpha};
pub fn selection_active(cosmic: &cosmic_theme::Theme<Alpha<Rgb, f32>>) -> ItemStatusAppearance {
@ -222,7 +222,7 @@ pub fn hover(
mod vertical {
use crate::widget::segmented_button::{ItemAppearance, ItemStatusAppearance};
use iced_core::{renderer::BorderRadius, Background};
use iced_core::{Background, BorderRadius};
use palette::{rgb::Rgb, Alpha};
pub fn selection_active(cosmic: &cosmic_theme::Theme<Alpha<Rgb, f32>>) -> ItemStatusAppearance {

View file

@ -186,7 +186,7 @@ where
tree: &mut Tree,
event: Event,
layout: Layout<'_>,
cursor_position: Point,
cursor_position: mouse::Cursor,
renderer: &Renderer,
clipboard: &mut dyn Clipboard,
shell: &mut Shell<'_, Message>,
@ -206,7 +206,7 @@ where
&self,
tree: &Tree,
layout: Layout<'_>,
cursor_position: Point,
cursor_position: mouse::Cursor,
viewport: &Rectangle,
renderer: &Renderer,
) -> mouse::Interaction {
@ -221,7 +221,7 @@ where
theme: &Renderer::Theme,
renderer_style: &renderer::Style,
layout: Layout<'_>,
cursor_position: Point,
cursor_position: mouse::Cursor,
viewport: &Rectangle,
) {
self.container.draw(

View file

@ -173,7 +173,7 @@ where
tree: &mut Tree,
event: Event,
layout: Layout<'_>,
cursor_position: Point,
cursor_position: mouse::Cursor,
renderer: &Renderer,
clipboard: &mut dyn Clipboard,
shell: &mut Shell<'_, Message>,
@ -193,7 +193,7 @@ where
&self,
tree: &Tree,
layout: Layout<'_>,
cursor_position: Point,
cursor_position: mouse::Cursor,
viewport: &Rectangle,
renderer: &Renderer,
) -> mouse::Interaction {
@ -208,7 +208,7 @@ where
theme: &Renderer::Theme,
renderer_style: &renderer::Style,
layout: Layout<'_>,
cursor_position: Point,
cursor_position: mouse::Cursor,
viewport: &Rectangle,
) {
let theme = if let Some(layer) = self.layer {

View file

@ -83,7 +83,7 @@ where
tree: &mut Tree,
event: Event,
layout: Layout<'_>,
cursor_position: Point,
cursor_position: mouse::Cursor,
renderer: &Renderer,
clipboard: &mut dyn Clipboard,
shell: &mut Shell<'_, Message>,
@ -103,7 +103,7 @@ where
&self,
tree: &Tree,
layout: Layout<'_>,
cursor_position: Point,
cursor_position: mouse::Cursor,
viewport: &Rectangle,
renderer: &Renderer,
) -> mouse::Interaction {
@ -123,7 +123,7 @@ where
theme: &Renderer::Theme,
renderer_style: &renderer::Style,
layout: Layout<'_>,
cursor_position: Point,
cursor_position: mouse::Cursor,
viewport: &Rectangle,
) {
self.content.as_widget().draw(
@ -208,7 +208,7 @@ where
&mut self,
event: Event,
layout: Layout<'_>,
cursor_position: Point,
cursor_position: mouse::Cursor,
renderer: &Renderer,
clipboard: &mut dyn Clipboard,
shell: &mut Shell<'_, Message>,
@ -227,7 +227,7 @@ where
fn mouse_interaction(
&self,
layout: Layout<'_>,
cursor_position: Point,
cursor_position: mouse::Cursor,
viewport: &Rectangle,
renderer: &Renderer,
) -> mouse::Interaction {
@ -246,7 +246,7 @@ where
theme: &Renderer::Theme,
style: &renderer::Style,
layout: Layout<'_>,
cursor_position: Point,
cursor_position: mouse::Cursor,
) {
let bounds = layout.bounds();
self.content.borrow().as_widget().draw(

View file

@ -185,7 +185,7 @@ where
tree: &mut Tree,
event: Event,
layout: Layout<'_>,
cursor_position: Point,
cursor_position: mouse::Cursor,
renderer: &Renderer,
clipboard: &mut dyn Clipboard,
shell: &mut Shell<'_, Message>,
@ -205,7 +205,7 @@ where
&self,
tree: &Tree,
layout: Layout<'_>,
cursor_position: Point,
cursor_position: mouse::Cursor,
viewport: &Rectangle,
renderer: &Renderer,
) -> mouse::Interaction {
@ -220,7 +220,7 @@ where
theme: &Renderer::Theme,
renderer_style: &renderer::Style,
layout: Layout<'_>,
cursor_position: Point,
cursor_position: mouse::Cursor,
viewport: &Rectangle,
) {
let _ = self.tx.unbounded_send((self.id, layout.bounds()));

View file

@ -1,7 +1,7 @@
// Copyright 2022 System76 <info@system76.com>
// SPDX-License-Identifier: MPL-2.0
use iced_core::{renderer::BorderRadius, Background, Color};
use iced_core::{Background, BorderRadius, Color};
/// Appearance of the segmented button.
#[derive(Default, Clone, Copy)]

View file

@ -10,9 +10,9 @@ use iced::{
alignment, event, keyboard, mouse, touch, Background, Color, Command, Element, Event, Length,
Point, Rectangle, Size,
};
use iced_core::renderer::BorderRadius;
use iced_core::text::{LineHeight, Shaping};
use iced_core::widget::{self, operation, tree};
use iced_core::BorderRadius;
use iced_core::{layout, renderer, widget::Tree, Clipboard, Layout, Shell, Widget};
use std::marker::PhantomData;
@ -303,7 +303,7 @@ where
tree: &mut Tree,
event: Event,
layout: Layout<'_>,
cursor_position: Point,
cursor_position: mouse::Cursor,
_renderer: &Renderer,
_clipboard: &mut dyn Clipboard,
shell: &mut Shell<'_, Message>,
@ -311,10 +311,10 @@ where
let bounds = layout.bounds();
let state = tree.state.downcast_mut::<LocalState>();
if bounds.contains(cursor_position) {
if cursor_position.is_over(bounds) {
for (nth, key) in self.model.order.iter().copied().enumerate() {
let bounds = self.variant_button_bounds(bounds, nth);
if bounds.contains(cursor_position) {
if cursor_position.is_over(bounds) {
if self.model.items[key].enabled {
// Record that the mouse is hovering over this button.
state.hovered = key;
@ -322,13 +322,11 @@ where
// If marked as closable, show a close icon.
if self.model.items[key].closable {
if let Some(on_close) = self.on_close.as_ref() {
if close_bounds(
if cursor_position.is_over(close_bounds(
bounds,
f32::from(self.icon_size),
self.button_padding,
)
.contains(cursor_position)
{
)) {
if let Event::Mouse(mouse::Event::ButtonReleased(
mouse::Button::Left,
))
@ -404,18 +402,15 @@ where
&self,
_tree: &Tree,
layout: Layout<'_>,
cursor_position: iced::Point,
cursor_position: mouse::Cursor,
_viewport: &iced::Rectangle,
_renderer: &Renderer,
) -> iced_core::mouse::Interaction {
let bounds = layout.bounds();
if bounds.contains(cursor_position) {
if cursor_position.is_over(bounds) {
for (nth, key) in self.model.order.iter().copied().enumerate() {
if self
.variant_button_bounds(bounds, nth)
.contains(cursor_position)
{
if cursor_position.is_over(self.variant_button_bounds(bounds, nth)) {
return if self.model.items[key].enabled {
iced_core::mouse::Interaction::Pointer
} else {
@ -436,7 +431,7 @@ where
theme: &<Renderer as iced_core::Renderer>::Theme,
_style: &renderer::Style,
layout: Layout<'_>,
_cursor_position: iced::Point,
_cursor_position: mouse::Cursor,
_viewport: &iced::Rectangle,
) {
let state = tree.state.downcast_ref::<LocalState>();