Skip to content

Commit

Permalink
chore: update iced
Browse files Browse the repository at this point in the history
  • Loading branch information
wash2 committed Dec 4, 2023
1 parent 5fe4ece commit abb7656
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 99 deletions.
10 changes: 5 additions & 5 deletions examples/cosmic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ slotmap = "1.0.6"
env_logger = "0.10"
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"]
# [dependencies.cosmic-time]
# git = "https://github.com/pop-os/cosmic-time"
# default-features = false
# branch = "update-0.12"
# features = ["libcosmic", "once_cell"]
18 changes: 9 additions & 9 deletions examples/cosmic/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use cosmic::{
},
Element,
};
use cosmic_time::{Instant, Timeline};
// use cosmic_time::{Instant, Timeline};
use std::{
cell::RefCell,
rc::Rc,
Expand Down Expand Up @@ -166,7 +166,7 @@ pub struct Window {
warning_message: String,
scale_factor: f64,
scale_factor_string: String,
timeline: Rc<RefCell<Timeline>>,
// timeline: Rc<RefCell<Timeline>>,
}

impl Window {
Expand Down Expand Up @@ -211,7 +211,7 @@ pub enum Message {
ToggleNavBarCondensed,
ToggleWarning,
FontsLoaded,
Tick(Instant),
// Tick(Instant),
}

impl From<Page> for Message {
Expand Down Expand Up @@ -349,7 +349,7 @@ impl Application for Window {
window.insert_page(Page::TimeAndLanguage(None));
window.insert_page(Page::Accessibility);
window.insert_page(Page::Applications);
window.demo.timeline = window.timeline.clone();
// window.demo.timeline = window.timeline.clone();

(window, load_fonts().map(|_| Message::FontsLoaded))
}
Expand Down Expand Up @@ -381,10 +381,10 @@ impl Application for Window {
Subscription::batch(vec![
window_break.map(|_| Message::CondensedViewToggle),
keyboard_nav::subscription().map(Message::KeyboardNav),
self.timeline
.borrow()
.as_subscription()
.map(|(_, instant)| Self::Message::Tick(instant)),
// self.timeline
// .borrow()
// .as_subscription()
// .map(|(_, instant)| Self::Message::Tick(instant)),
])
}

Expand Down Expand Up @@ -452,7 +452,7 @@ impl Application for Window {
},
Message::ToggleWarning => self.toggle_warning(),
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),
// Message::Tick(instant) => self.timeline.borrow_mut().now(instant),
}
ret
}
Expand Down
118 changes: 38 additions & 80 deletions examples/cosmic/src/window/demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ use cosmic::{
},
Element,
};
use cosmic_time::{anim, chain, Timeline};
// use cosmic_time::{anim, chain, Timeline};
use fraction::{Decimal, ToPrimitive};
use once_cell::sync::Lazy;

use super::{Page, Window};

static CARDS: Lazy<cosmic_time::id::Cards> = Lazy::new(cosmic_time::id::Cards::unique);
// static CARDS: Lazy<cosmic_time::id::Cards> = Lazy::new(cosmic_time::id::Cards::unique);

#[derive(Clone, Copy, Debug, PartialEq, PartialOrd, Ord, Eq)]
pub enum ThemeVariant {
Expand Down Expand Up @@ -113,7 +113,7 @@ pub struct State {
pub entry_value: String,
pub cards_value: bool,
cards: Vec<String>,
pub timeline: Rc<RefCell<Timeline>>,
// pub timeline: Rc<RefCell<Timeline>>,
pub color_picker_model: ColorPickerModel,
}

Expand Down Expand Up @@ -160,7 +160,7 @@ impl Default for State {
"card 3".to_string(),
"card 4".to_string(),
],
timeline: Rc::new(RefCell::new(Default::default())),
// timeline: Rc::new(RefCell::new(Default::default())),
color_picker_model: ColorPickerModel::new("Hex", "RGB", None, None),
}
}
Expand Down Expand Up @@ -243,7 +243,7 @@ impl State {

let choose_icon_theme =
segmented_selection::horizontal(&self.icon_themes).on_activate(Message::IconTheme);
let timeline = self.timeline.borrow();
// let timeline = self.timeline.borrow();
settings::view_column(vec![
window.page_title(Page::Demo),
view_switcher::horizontal(&self.view_switcher)
Expand Down Expand Up @@ -445,79 +445,37 @@ impl State {
.padding(8)
.width(Length::Fill)
.into(),
container(anim!(
//cards
CARDS,
&timeline,
self.cards
.iter()
.enumerate()
.map(|(i, c)| column![
button::text("Delete me").on_press(Message::DeleteCard(i)),
text(c).size(24).width(Length::Fill)
]
.into())
.collect(),
Message::ClearAll,
|_, e| Message::CardsToggled(e),
"Show More",
"Show Less",
"Clear All",
None,
self.cards_value,
))
.layer(cosmic::cosmic_theme::Layer::Secondary)
.padding(16)
.style(cosmic::theme::Container::Background)
.into(),
// container(anim!(
// //cards
// CARDS,
// &timeline,
// self.cards
// .iter()
// .enumerate()
// .map(|(i, c)| column![
// button::text("Delete me").on_press(Message::DeleteCard(i)),
// text(c).size(24).width(Length::Fill)
// ]
// .into())
// .collect(),
// Message::ClearAll,
// |_, e| Message::CardsToggled(e),
// "Show More",
// "Show Less",
// "Clear All",
// None,
// self.cards_value,
// ))
// .layer(cosmic::cosmic_theme::Layer::Secondary)
// .padding(16)
// .style(cosmic::theme::Container::Background)
// .into(),
text_input(
"Type to search apps or type “?” for more options...",
&self.entry_value,
)
.on_input(Message::InputChanged)
// .on_submit(Message::Activate(None))
.size(20)
.id(INPUT_ID.clone())
.into(),
cosmic::widget::text_input("test", &self.entry_value)
.on_clear(Message::InputChanged("".to_string()))
.width(Length::Fill)
.on_input(Message::InputChanged)
.into(),
cosmic::widget::text_input("test", &self.entry_value)
.width(Length::Fixed(600.0))
.padding(32)
.on_input(Message::InputChanged)
.into(),
cosmic::widget::search_input("test", &self.entry_value)
.on_clear(Message::InputChanged("".to_string()))
.width(Length::Fill)
.on_input(Message::InputChanged)
.into(),
cosmic::widget::text_input("test", &self.entry_value)
.width(Length::Fixed(600.0))
.on_input(Message::InputChanged)
.into(),
cosmic::widget::search_input("test", &self.entry_value)
.width(Length::Fixed(100.0))
.on_input(Message::InputChanged)
.into(),
cosmic::widget::search_input("test", &self.entry_value)
.on_clear(Message::InputChanged("".to_string()))
.padding([24, 48])
.width(Length::Fixed(400.0))
.on_input(Message::InputChanged)
.into(),
cosmic::widget::search_input("test", &self.entry_value)
.on_clear(Message::InputChanged("".to_string()))
.width(Length::Fixed(400.0))
.on_input(Message::InputChanged)
.into(),
cosmic::widget::search_input("test", &self.entry_value)
.on_clear(Message::InputChanged("".to_string()))
.width(Length::Fixed(800.0))
.on_input(Message::InputChanged)
.into(),
self.color_picker_model
.picker_button(Message::ColorPickerUpdate, None)
.width(Length::Fixed(128.0))
Expand All @@ -539,13 +497,13 @@ impl State {
}

fn update_cards(&mut self) {
let mut timeline = self.timeline.borrow_mut();
let chain = if self.cards_value {
chain::Cards::on(CARDS.clone(), 1.)
} else {
chain::Cards::off(CARDS.clone(), 1.)
};
timeline.set_chain(chain);
timeline.start();
// let mut timeline = self.timeline.borrow_mut();
// let chain = if self.cards_value {
// chain::Cards::on(CARDS.clone(), 1.)
// } else {
// chain::Cards::off(CARDS.clone(), 1.)
// };
// timeline.set_chain(chain);
// timeline.start();
}
}
2 changes: 1 addition & 1 deletion iced
Submodule iced updated 50 files
+1 −1 README.md
+2 −1 core/src/overlay.rs
+16 −4 core/src/overlay/element.rs
+5 −4 core/src/overlay/group.rs
+3 −0 core/src/renderer/null.rs
+4 −1 core/src/text.rs
+4 −1 core/src/widget/text.rs
+8 −13 examples/custom_shader/src/main.rs
+3 −3 examples/custom_shader/src/scene.rs
+13 −8 examples/custom_shader/src/scene/pipeline.rs
+2 −0 examples/modal/src/main.rs
+1 −1 examples/progress_bar/README.md
+1 −0 examples/toast/src/main.rs
+24 −1 futures/src/runtime.rs
+16 −10 graphics/src/primitive.rs
+6 −0 graphics/src/renderer.rs
+6 −1 graphics/src/text.rs
+10 −3 renderer/src/lib.rs
+34 −1 runtime/src/command.rs
+8 −1 runtime/src/command/action.rs
+8 −7 runtime/src/overlay/nested.rs
+23 −7 runtime/src/user_interface.rs
+5 −0 sctk/src/application.rs
+6 −2 src/lib.rs
+7 −7 tiny_skia/src/backend.rs
+9 −6 tiny_skia/src/geometry.rs
+4 −4 wgpu/src/backend.rs
+9 −6 wgpu/src/geometry.rs
+14 −8 wgpu/src/layer.rs
+17 −0 wgpu/src/layer/pipeline.rs
+5 −0 wgpu/src/layer/text.rs
+2 −3 wgpu/src/primitive/pipeline.rs
+14 −9 wgpu/src/text.rs
+3 −1 widget/src/checkbox.rs
+11 −9 widget/src/column.rs
+2 −1 widget/src/combo_box.rs
+21 −19 widget/src/container.rs
+3 −2 widget/src/lazy.rs
+2 −1 widget/src/lazy/component.rs
+4 −2 widget/src/lazy/responsive.rs
+2 −0 widget/src/overlay/menu.rs
+5 −1 widget/src/pick_list.rs
+2 −1 widget/src/radio.rs
+11 −9 widget/src/row.rs
+0 −1 widget/src/shader.rs
+2 −1 widget/src/text_editor.rs
+27 −30 widget/src/text_input/text_input.rs
+2 −1 widget/src/toggler.rs
+10 −1 widget/src/tooltip.rs
+6 −0 winit/src/application.rs
1 change: 1 addition & 0 deletions src/widget/context_drawer/overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ where
renderer: &crate::Renderer,
bounds: Size,
position: Point,
_translation: iced::Vector,
) -> layout::Node {
let limits = layout::Limits::new(Size::ZERO, bounds)
.width(self.width)
Expand Down
2 changes: 2 additions & 0 deletions src/widget/dropdown/menu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ impl<'a, Message> iced_core::Overlay<Message, crate::Renderer> for Overlay<'a, M
renderer: &crate::Renderer,
bounds: Size,
position: Point,
_translation: iced::Vector,
) -> layout::Node {
let space_below = bounds.height - (position.y + self.target_height);
let space_above = position.y;
Expand Down Expand Up @@ -514,6 +515,7 @@ impl<'a, S: AsRef<str>, Message> Widget<Message, crate::Renderer> for List<'a, S
},
bounds.position(),
color,
*viewport,
);
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/widget/dropdown/multi/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ impl<'a, Message> iced_core::Overlay<Message, crate::Renderer> for Overlay<'a, M
renderer: &crate::Renderer,
bounds: Size,
position: Point,
_translation: iced::Vector,
) -> layout::Node {
let space_below = bounds.height - (position.y + self.target_height);
let space_above = position.y;
Expand Down Expand Up @@ -603,6 +604,7 @@ where
},
bounds.position(),
color,
*viewport,
);
}

Expand Down Expand Up @@ -651,6 +653,7 @@ where
},
bounds.position(),
appearance.description_color,
*viewport,
);
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/widget/dropdown/multi/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl<'a, S: AsRef<str>, Message: 'a, Item: Clone + PartialEq + 'static>
_style: &iced_core::renderer::Style,
layout: Layout<'_>,
cursor: mouse::Cursor,
_viewport: &Rectangle,
viewport: &Rectangle,
) {
let font = self
.font
Expand All @@ -168,6 +168,7 @@ impl<'a, S: AsRef<str>, Message: 'a, Item: Clone + PartialEq + 'static>
.as_ref()
.and_then(|id| self.selections.get(id)),
tree.state.downcast_ref::<State<Item>>(),
viewport,
);
}

Expand Down Expand Up @@ -486,6 +487,7 @@ pub fn draw<'a, S, Item: Clone + PartialEq + 'static>(
font: crate::font::Font,
selected: Option<&'a S>,
state: &'a State<Item>,
viewport: &Rectangle,
) where
S: AsRef<str> + 'a,
{
Expand Down Expand Up @@ -547,6 +549,7 @@ pub fn draw<'a, S, Item: Clone + PartialEq + 'static>(
},
bounds.position(),
style.text_color,
*viewport,
);
}
}
5 changes: 4 additions & 1 deletion src/widget/dropdown/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl<'a, S: AsRef<str>, Message: 'a> Widget<Message, crate::Renderer> for Dropdo
_style: &iced_core::renderer::Style,
layout: Layout<'_>,
cursor: mouse::Cursor,
_viewport: &Rectangle,
viewport: &Rectangle,
) {
let font = self
.font
Expand All @@ -209,6 +209,7 @@ impl<'a, S: AsRef<str>, Message: 'a> Widget<Message, crate::Renderer> for Dropdo
font,
self.selected.and_then(|id| self.selections.get(id)),
tree.state.downcast_ref::<State>(),
viewport,
);
}

Expand Down Expand Up @@ -479,6 +480,7 @@ pub fn draw<'a, S>(
font: crate::font::Font,
selected: Option<&'a S>,
state: &'a State,
viewport: &Rectangle,
) where
S: AsRef<str> + 'a,
{
Expand Down Expand Up @@ -538,6 +540,7 @@ pub fn draw<'a, S>(
},
bounds.position(),
style.text_color,
*viewport,
);
}
}
8 changes: 7 additions & 1 deletion src/widget/menu/menu_inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,13 @@ where
Renderer: renderer::Renderer,
Renderer::Theme: StyleSheet,
{
fn layout(&mut self, renderer: &Renderer, bounds: Size, position: Point) -> Node {
fn layout(
&mut self,
renderer: &Renderer,
bounds: Size,
position: Point,
_translation: iced::Vector,
) -> Node {
// layout children
let state = self.tree.state.downcast_mut::<MenuBarState>();
let overlay_offset = Point::ORIGIN - position;
Expand Down
8 changes: 7 additions & 1 deletion src/widget/popover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,13 @@ impl<'a, 'b, Message, Renderer> overlay::Overlay<Message, Renderer>
where
Renderer: iced_core::Renderer,
{
fn layout(&mut self, renderer: &Renderer, bounds: Size, mut position: Point) -> layout::Node {
fn layout(
&mut self,
renderer: &Renderer,
bounds: Size,
mut position: Point,
_translation: iced::Vector,
) -> layout::Node {
let limits = layout::Limits::new(Size::UNIT, bounds);
let mut node = self
.content
Expand Down
Loading

0 comments on commit abb7656

Please sign in to comment.