Skip to content

Commit

Permalink
chore: update to 0.12
Browse files Browse the repository at this point in the history
  • Loading branch information
wash2 committed Nov 30, 2023
1 parent d6c8fbe commit ff73a92
Show file tree
Hide file tree
Showing 34 changed files with 712 additions and 454 deletions.
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,3 @@ exclude = ["examples/design-demo", "iced"]
[patch."https://github.com/pop-os/libcosmic"]
libcosmic = { path = "./" }

# [patch."https://github.com/pop-os/cosmic-time"]
# cosmic-time = { path = "../cosmic-time" }
Empty file.
1 change: 1 addition & 0 deletions examples/cosmic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ log = "0.4.17"
[dependencies.cosmic-time]
git = "https://github.com/pop-os/cosmic-time"
default-features = false
branch = "update-0.12"
features = ["libcosmic", "once_cell"]
5 changes: 3 additions & 2 deletions examples/cosmic/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use cosmic::{
widget::{self, column, container, horizontal_space, row, text},
window::{self, close, drag, minimize, toggle_maximize},
},
iced_futures::event::listen_raw,
keyboard_nav,
prelude::*,
theme::{self, Theme},
Expand Down Expand Up @@ -358,7 +359,7 @@ impl Application for Window {
}

fn subscription(&self) -> Subscription<Message> {
let window_break = subscription::events_with(|event, _| match event {
let window_break = listen_raw(|event, _| match event {
cosmic::iced::Event::Window(
_window_id,
window::Event::Resized { width, height: _ },
Expand Down Expand Up @@ -450,7 +451,7 @@ impl Application for Window {
_ => (),
},
Message::ToggleWarning => self.toggle_warning(),
Message::FontsLoaded => {}
Message::FontsLoaded => {} // Message::Tick(instant) => self.timeline.borrow_mut().now(instant), Message::Tick(instant) => self.timeline.borrow_mut().now(instant),
Message::Tick(instant) => self.timeline.borrow_mut().now(instant),
}
ret
Expand Down
4 changes: 2 additions & 2 deletions examples/cosmic/src/window/demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ use apply::Apply;
use cosmic::{
cosmic_theme,
iced::widget::{checkbox, column, progress_bar, radio, slider, text, text_input},
iced::{id, Alignment, Length},
iced::{Alignment, Length},
iced_core::id,
theme::ThemeType,
widget::{
button, color_picker::ColorPickerUpdate, cosmic_container::container, dropdown, icon,
Expand Down Expand Up @@ -498,7 +499,6 @@ impl State {
.on_input(Message::InputChanged)
.into(),
cosmic::widget::search_input("test", &self.entry_value)
.on_clear(Message::InputChanged("".to_string()))
.width(Length::Fixed(100.0))
.on_input(Message::InputChanged)
.into(),
Expand Down
2 changes: 1 addition & 1 deletion iced
Submodule iced updated 342 files
3 changes: 2 additions & 1 deletion src/app/cosmic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use iced::event::wayland::{self, WindowEvent};
#[cfg(feature = "wayland")]
use iced::event::PlatformSpecific;
use iced::window;
use iced_futures::event::listen_raw;
#[cfg(not(feature = "wayland"))]
use iced_runtime::command::Action;
#[cfg(not(feature = "wayland"))]
Expand Down Expand Up @@ -126,7 +127,7 @@ where
}

fn subscription(&self) -> Subscription<Self::Message> {
let window_events = iced::subscription::events_with(|event, _| {
let window_events = listen_raw(|event, _| {
match event {
iced::Event::Window(id, window::Event::Resized { width, height }) => {
return Some(Message::WindowResize(id, width, height));
Expand Down
2 changes: 1 addition & 1 deletion src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub(crate) fn iced_settings<App: Application>(

iced.antialiasing = settings.antialiasing;
iced.default_font = settings.default_font;
iced.default_text_size = settings.default_text_size;
iced.default_text_size = iced::Pixels(settings.default_text_size);
iced.exit_on_close_request = settings.exit_on_close;
iced.id = Some(App::APP_ID.to_owned());

Expand Down
2 changes: 1 addition & 1 deletion src/app/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use crate::{font, Theme};
#[cfg(feature = "wayland")]
use iced::Limits;
use iced_core::layout::Limits;
use iced_core::Font;

/// Configure a new COSMIC application.
Expand Down
10 changes: 5 additions & 5 deletions src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub const FONT: Font = Font {
family: Family::Name("Fira Sans"),
weight: iced_core::font::Weight::Normal,
stretch: iced_core::font::Stretch::Normal,
monospaced: false,
style: iced_core::font::Style::Normal,
};

pub const FONT_DATA: &[u8] = include_bytes!("../res/Fira/FiraSans-Regular.otf");
Expand All @@ -25,7 +25,7 @@ pub const FONT_LIGHT: Font = Font {
family: Family::Name("Fira Sans"),
weight: iced_core::font::Weight::Light,
stretch: iced_core::font::Stretch::Normal,
monospaced: false,
style: iced_core::font::Style::Normal,
};

pub const FONT_LIGHT_DATA: &[u8] = include_bytes!("../res/Fira/FiraSans-Light.otf");
Expand All @@ -34,7 +34,7 @@ pub const FONT_SEMIBOLD: Font = Font {
family: Family::Name("Fira Sans"),
weight: iced_core::font::Weight::Semibold,
stretch: iced_core::font::Stretch::Normal,
monospaced: false,
style: iced_core::font::Style::Normal,
};

pub const FONT_SEMIBOLD_DATA: &[u8] = include_bytes!("../res/Fira/FiraSans-SemiBold.otf");
Expand All @@ -43,7 +43,7 @@ pub const FONT_BOLD: Font = Font {
family: Family::Name("Fira Sans"),
weight: iced_core::font::Weight::Bold,
stretch: iced_core::font::Stretch::Normal,
monospaced: false,
style: iced_core::font::Style::Normal,
};

pub const FONT_BOLD_DATA: &[u8] = include_bytes!("../res/Fira/FiraSans-Bold.otf");
Expand All @@ -52,7 +52,7 @@ pub const FONT_MONO_REGULAR: Font = Font {
family: Family::Name("Fira Mono"),
weight: iced_core::font::Weight::Normal,
stretch: iced_core::font::Stretch::Normal,
monospaced: true,
style: iced_core::font::Style::Normal,
};

pub const FONT_MONO_REGULAR_DATA: &[u8] = include_bytes!("../res/Fira/FiraMono-Regular.otf");
Expand Down
3 changes: 2 additions & 1 deletion src/keyboard_nav.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use iced_core::{
widget::{operation, Id, Operation},
Rectangle,
};
use iced_futures::event::listen_raw;

#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum Message {
Expand All @@ -24,7 +25,7 @@ pub enum Message {
}

pub fn subscription() -> Subscription<Message> {
subscription::events_with(|event, status| {
listen_raw(|event, status| {
if event::Status::Ignored != status {
return None;
}
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,6 @@ pub use theme::{style, Theme};

pub mod widget;

type Paragraph = <Renderer as iced_core::text::Renderer>::Paragraph;
pub type Renderer = iced::Renderer<Theme>;
pub type Element<'a, Message> = iced::Element<'a, Message, Renderer>;
17 changes: 0 additions & 17 deletions src/theme/style/iced.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,23 +146,6 @@ impl iced_button::StyleSheet for Theme {
}
}

fn focused(&self, style: &Self::Style) -> iced_button::Appearance {
if let Button::Custom { hover, .. } = style {
return hover(self);
}

let active = self.active(style);
let component = style.cosmic(self);
iced_button::Appearance {
background: match style {
Button::Link => None,
Button::LinkActive => Some(Background::Color(component.divider.into())),
_ => Some(Background::Color(component.hover.into())),
},
..active
}
}

fn disabled(&self, style: &Self::Style) -> iced_button::Appearance {
let active = self.active(style);

Expand Down
10 changes: 8 additions & 2 deletions src/widget/aspect_ratio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,18 @@ where
Widget::height(&self.container)
}

fn layout(&self, renderer: &Renderer, limits: &layout::Limits) -> layout::Node {
fn layout(
&self,
tree: &mut Tree,
renderer: &Renderer,
limits: &layout::Limits,
) -> layout::Node {
let custom_limits = layout::Limits::new(
self.constrain_limits(limits.min()),
self.constrain_limits(limits.max()),
);
self.container.layout(renderer, &custom_limits)
self.container
.layout(&mut tree.children[0], renderer, &custom_limits)
}

fn operate(
Expand Down
13 changes: 11 additions & 2 deletions src/widget/button/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,23 @@ where
self.height
}

fn layout(&self, renderer: &Renderer, limits: &layout::Limits) -> layout::Node {
fn layout(
&self,
tree: &mut Tree,
renderer: &Renderer,
limits: &layout::Limits,
) -> layout::Node {
layout(
renderer,
limits,
self.width,
self.height,
self.padding,
|renderer, limits| self.content.as_widget().layout(renderer, limits),
|renderer, limits| {
self.content
.as_widget()
.layout(&mut tree.children[0], renderer, limits)
},
)
}

Expand Down
11 changes: 9 additions & 2 deletions src/widget/color_picker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,15 @@ where
Length::Shrink
}

fn layout(&self, renderer: &crate::Renderer, limits: &layout::Limits) -> layout::Node {
self.inner.as_widget().layout(renderer, limits)
fn layout(
&self,
tree: &mut Tree,
renderer: &crate::Renderer,
limits: &layout::Limits,
) -> layout::Node {
self.inner
.as_widget()
.layout(&mut tree.children[0], renderer, limits)
}

#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
Expand Down
12 changes: 10 additions & 2 deletions src/widget/context_drawer/overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,20 @@ impl<'a, 'b, Message> overlay::Overlay<Message, crate::Renderer> for Overlay<'a,
where
Message: Clone,
{
fn layout(&self, renderer: &crate::Renderer, bounds: Size, position: Point) -> layout::Node {
fn layout(
&mut self,
renderer: &crate::Renderer,
bounds: Size,
position: Point,
) -> layout::Node {
let limits = layout::Limits::new(Size::ZERO, bounds)
.width(self.width)
.height(bounds.height - 8.0 - position.y);

let mut node = self.content.as_widget().layout(renderer, &limits);
let mut node =
self.content
.as_widget()
.layout(&mut self.tree.children[0], renderer, &limits);
let node_size = node.size();

node.move_to(Point {
Expand Down
11 changes: 9 additions & 2 deletions src/widget/context_drawer/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,15 @@ impl<'a, Message: Clone> Widget<Message, Renderer> for ContextDrawer<'a, Message
self.content.as_widget().height()
}

fn layout(&self, renderer: &Renderer, limits: &layout::Limits) -> layout::Node {
self.content.as_widget().layout(renderer, limits)
fn layout(
&self,
tree: &mut Tree,
renderer: &Renderer,
limits: &layout::Limits,
) -> layout::Node {
self.content
.as_widget()
.layout(&mut tree.children[0], renderer, limits)
}

fn operate(
Expand Down
13 changes: 11 additions & 2 deletions src/widget/cosmic_container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ where
self.container.diff(tree);
}

fn state(&self) -> iced_core::widget::tree::State {
self.container.state()
}

fn width(&self) -> Length {
Widget::width(&self.container)
}
Expand All @@ -152,8 +156,13 @@ where
Widget::height(&self.container)
}

fn layout(&self, renderer: &Renderer, limits: &layout::Limits) -> layout::Node {
self.container.layout(renderer, limits)
fn layout(
&self,
tree: &mut Tree,
renderer: &Renderer,
limits: &layout::Limits,
) -> layout::Node {
self.container.layout(tree, renderer, limits)
}

fn operate(
Expand Down
Loading

0 comments on commit ff73a92

Please sign in to comment.