summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/bezier_tool/src/main.rs13
-rw-r--r--examples/component/src/main.rs10
-rw-r--r--examples/game_of_life/src/main.rs6
-rw-r--r--examples/geometry/src/main.rs4
-rw-r--r--examples/gradient/src/main.rs2
-rw-r--r--examples/layout/src/main.rs8
-rw-r--r--examples/loading_spinners/src/circular.rs2
-rw-r--r--examples/pane_grid/src/main.rs28
-rw-r--r--examples/scrollable/src/main.rs4
-rw-r--r--examples/sierpinski_triangle/src/main.rs4
-rw-r--r--examples/solar_system/src/main.rs4
-rw-r--r--examples/svg/src/main.rs2
-rw-r--r--examples/toast/src/main.rs24
13 files changed, 39 insertions, 72 deletions
diff --git a/examples/bezier_tool/src/main.rs b/examples/bezier_tool/src/main.rs
index cf70bd40..289c919b 100644
--- a/examples/bezier_tool/src/main.rs
+++ b/examples/bezier_tool/src/main.rs
@@ -143,23 +143,18 @@ mod bezier {
bounds: Rectangle,
cursor: mouse::Cursor,
) -> Vec<Geometry> {
- let content = self.state.cache.draw(
- renderer,
- bounds.size(),
- |frame: &mut Frame| {
+ let content =
+ self.state.cache.draw(renderer, bounds.size(), |frame| {
Curve::draw_all(self.curves, frame);
frame.stroke(
&Path::rectangle(Point::ORIGIN, frame.size()),
Stroke::default().with_width(2.0),
);
- },
- );
+ });
if let Some(pending) = state {
- let pending_curve = pending.draw(renderer, bounds, cursor);
-
- vec![content, pending_curve]
+ vec![content, pending.draw(renderer, bounds, cursor)]
} else {
vec![content]
}
diff --git a/examples/component/src/main.rs b/examples/component/src/main.rs
index 43ba3187..b2c71b3f 100644
--- a/examples/component/src/main.rs
+++ b/examples/component/src/main.rs
@@ -73,10 +73,7 @@ mod numeric_input {
impl<Message, Theme> Component<Message, Theme> for NumericInput<Message>
where
- Theme: text::DefaultStyle
- + button::DefaultStyle
- + text_input::DefaultStyle
- + 'static,
+ Theme: text::Catalog + button::Catalog + text_input::Catalog + 'static,
{
type State = ();
type Event = Event;
@@ -151,10 +148,7 @@ mod numeric_input {
impl<'a, Message, Theme> From<NumericInput<Message>>
for Element<'a, Message, Theme>
where
- Theme: text::DefaultStyle
- + button::DefaultStyle
- + text_input::DefaultStyle
- + 'static,
+ Theme: text::Catalog + button::Catalog + text_input::Catalog + 'static,
Message: 'a,
{
fn from(numeric_input: NumericInput<Message>) -> Self {
diff --git a/examples/game_of_life/src/main.rs b/examples/game_of_life/src/main.rs
index 2b0fae0b..0716b2a4 100644
--- a/examples/game_of_life/src/main.rs
+++ b/examples/game_of_life/src/main.rs
@@ -602,9 +602,7 @@ mod grid {
frame.into_geometry()
};
- if self.scaling < 0.2 || !self.show_lines {
- vec![life, overlay]
- } else {
+ if self.scaling >= 0.2 && self.show_lines {
let grid =
self.grid_cache.draw(renderer, bounds.size(), |frame| {
frame.translate(center);
@@ -641,6 +639,8 @@ mod grid {
});
vec![life, grid, overlay]
+ } else {
+ vec![life, overlay]
}
}
diff --git a/examples/geometry/src/main.rs b/examples/geometry/src/main.rs
index 63efcbdd..16cdb86f 100644
--- a/examples/geometry/src/main.rs
+++ b/examples/geometry/src/main.rs
@@ -44,7 +44,9 @@ mod rainbow {
cursor: mouse::Cursor,
_viewport: &Rectangle,
) {
- use iced::advanced::graphics::mesh::{self, Mesh, SolidVertex2D};
+ use iced::advanced::graphics::mesh::{
+ self, Mesh, Renderer as _, SolidVertex2D,
+ };
use iced::advanced::Renderer as _;
let bounds = layout.bounds();
diff --git a/examples/gradient/src/main.rs b/examples/gradient/src/main.rs
index 22c21cdd..2b906c32 100644
--- a/examples/gradient/src/main.rs
+++ b/examples/gradient/src/main.rs
@@ -60,7 +60,7 @@ impl Gradient {
} = *self;
let gradient_box = container(horizontal_space())
- .style(move |_theme, _status| {
+ .style(move |_theme| {
let gradient = gradient::Linear::new(angle)
.add_stop(0.0, start)
.add_stop(1.0, end);
diff --git a/examples/layout/src/main.rs b/examples/layout/src/main.rs
index 713e2b70..66d79091 100644
--- a/examples/layout/src/main.rs
+++ b/examples/layout/src/main.rs
@@ -81,10 +81,10 @@ impl Layout {
} else {
self.example.view()
})
- .style(|theme, _status| {
+ .style(|theme| {
let palette = theme.extended_palette();
- container::Appearance::default()
+ container::Style::default()
.with_border(palette.background.strong.color, 4.0)
})
.padding(4)
@@ -245,10 +245,10 @@ fn application<'a>() -> Element<'a, Message> {
.padding(10)
.align_items(Alignment::Center),
)
- .style(|theme, _status| {
+ .style(|theme| {
let palette = theme.extended_palette();
- container::Appearance::default()
+ container::Style::default()
.with_border(palette.background.strong.color, 1)
});
diff --git a/examples/loading_spinners/src/circular.rs b/examples/loading_spinners/src/circular.rs
index 12670ed1..de728af2 100644
--- a/examples/loading_spinners/src/circular.rs
+++ b/examples/loading_spinners/src/circular.rs
@@ -358,7 +358,7 @@ where
|renderer| {
use iced::advanced::graphics::geometry::Renderer as _;
- renderer.draw(vec![geometry]);
+ renderer.draw_geometry(geometry);
},
);
}
diff --git a/examples/pane_grid/src/main.rs b/examples/pane_grid/src/main.rs
index 829996d8..17112785 100644
--- a/examples/pane_grid/src/main.rs
+++ b/examples/pane_grid/src/main.rs
@@ -338,39 +338,30 @@ mod style {
use iced::widget::container;
use iced::{Border, Theme};
- pub fn title_bar_active(
- theme: &Theme,
- _status: container::Status,
- ) -> container::Appearance {
+ pub fn title_bar_active(theme: &Theme) -> container::Style {
let palette = theme.extended_palette();
- container::Appearance {
+ container::Style {
text_color: Some(palette.background.strong.text),
background: Some(palette.background.strong.color.into()),
..Default::default()
}
}
- pub fn title_bar_focused(
- theme: &Theme,
- _status: container::Status,
- ) -> container::Appearance {
+ pub fn title_bar_focused(theme: &Theme) -> container::Style {
let palette = theme.extended_palette();
- container::Appearance {
+ container::Style {
text_color: Some(palette.primary.strong.text),
background: Some(palette.primary.strong.color.into()),
..Default::default()
}
}
- pub fn pane_active(
- theme: &Theme,
- _status: container::Status,
- ) -> container::Appearance {
+ pub fn pane_active(theme: &Theme) -> container::Style {
let palette = theme.extended_palette();
- container::Appearance {
+ container::Style {
background: Some(palette.background.weak.color.into()),
border: Border {
width: 2.0,
@@ -381,13 +372,10 @@ mod style {
}
}
- pub fn pane_focused(
- theme: &Theme,
- _status: container::Status,
- ) -> container::Appearance {
+ pub fn pane_focused(theme: &Theme) -> container::Style {
let palette = theme.extended_palette();
- container::Appearance {
+ container::Style {
background: Some(palette.background.weak.color.into()),
border: Border {
width: 2.0,
diff --git a/examples/scrollable/src/main.rs b/examples/scrollable/src/main.rs
index 240ae908..c02e754b 100644
--- a/examples/scrollable/src/main.rs
+++ b/examples/scrollable/src/main.rs
@@ -341,8 +341,8 @@ impl Default for ScrollableDemo {
}
}
-fn progress_bar_custom_style(theme: &Theme) -> progress_bar::Appearance {
- progress_bar::Appearance {
+fn progress_bar_custom_style(theme: &Theme) -> progress_bar::Style {
+ progress_bar::Style {
background: theme.extended_palette().background.strong.color.into(),
bar: Color::from_rgb8(250, 85, 134).into(),
border: Border::default(),
diff --git a/examples/sierpinski_triangle/src/main.rs b/examples/sierpinski_triangle/src/main.rs
index 07ae05d6..9cd6237f 100644
--- a/examples/sierpinski_triangle/src/main.rs
+++ b/examples/sierpinski_triangle/src/main.rs
@@ -1,6 +1,6 @@
use iced::mouse;
use iced::widget::canvas::event::{self, Event};
-use iced::widget::canvas::{self, Canvas};
+use iced::widget::canvas::{self, Canvas, Geometry};
use iced::widget::{column, row, slider, text};
use iced::{Color, Length, Point, Rectangle, Renderer, Size, Theme};
@@ -111,7 +111,7 @@ impl canvas::Program<Message> for SierpinskiGraph {
_theme: &Theme,
bounds: Rectangle,
_cursor: mouse::Cursor,
- ) -> Vec<canvas::Geometry> {
+ ) -> Vec<Geometry> {
let geom = self.cache.draw(renderer, bounds.size(), |frame| {
frame.stroke(
&canvas::Path::rectangle(Point::ORIGIN, frame.size()),
diff --git a/examples/solar_system/src/main.rs b/examples/solar_system/src/main.rs
index b5228f09..deb211d8 100644
--- a/examples/solar_system/src/main.rs
+++ b/examples/solar_system/src/main.rs
@@ -10,7 +10,7 @@ use iced::mouse;
use iced::widget::canvas;
use iced::widget::canvas::gradient;
use iced::widget::canvas::stroke::{self, Stroke};
-use iced::widget::canvas::Path;
+use iced::widget::canvas::{Geometry, Path};
use iced::window;
use iced::{
Color, Element, Length, Point, Rectangle, Renderer, Size, Subscription,
@@ -130,7 +130,7 @@ impl<Message> canvas::Program<Message> for State {
_theme: &Theme,
bounds: Rectangle,
_cursor: mouse::Cursor,
- ) -> Vec<canvas::Geometry> {
+ ) -> Vec<Geometry> {
use std::f32::consts::PI;
let background =
diff --git a/examples/svg/src/main.rs b/examples/svg/src/main.rs
index cc686dca..0dcf9bc1 100644
--- a/examples/svg/src/main.rs
+++ b/examples/svg/src/main.rs
@@ -31,7 +31,7 @@ impl Tiger {
));
let svg = svg(handle).width(Length::Fill).height(Length::Fill).style(
- |_theme, _status| svg::Appearance {
+ |_theme, _status| svg::Style {
color: if self.apply_color_filter {
Some(color!(0x0000ff))
} else {
diff --git a/examples/toast/src/main.rs b/examples/toast/src/main.rs
index fdae1dc1..9968962c 100644
--- a/examples/toast/src/main.rs
+++ b/examples/toast/src/main.rs
@@ -651,45 +651,33 @@ mod toast {
}
}
- fn styled(pair: theme::palette::Pair) -> container::Appearance {
- container::Appearance {
+ fn styled(pair: theme::palette::Pair) -> container::Style {
+ container::Style {
background: Some(pair.color.into()),
text_color: pair.text.into(),
..Default::default()
}
}
- fn primary(
- theme: &Theme,
- _status: container::Status,
- ) -> container::Appearance {
+ fn primary(theme: &Theme) -> container::Style {
let palette = theme.extended_palette();
styled(palette.primary.weak)
}
- fn secondary(
- theme: &Theme,
- _status: container::Status,
- ) -> container::Appearance {
+ fn secondary(theme: &Theme) -> container::Style {
let palette = theme.extended_palette();
styled(palette.secondary.weak)
}
- fn success(
- theme: &Theme,
- _status: container::Status,
- ) -> container::Appearance {
+ fn success(theme: &Theme) -> container::Style {
let palette = theme.extended_palette();
styled(palette.success.weak)
}
- fn danger(
- theme: &Theme,
- _status: container::Status,
- ) -> container::Appearance {
+ fn danger(theme: &Theme) -> container::Style {
let palette = theme.extended_palette();
styled(palette.danger.weak)