From e657dc2ecd2ffa72c0abd87f9a59dcc1acbc7083 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 24 Mar 2024 02:08:20 +0100 Subject: Fine-tune `Catalog` approach for `button`, `checkbox`, and `svg` --- examples/svg/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples/svg/src/main.rs') 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 { -- cgit From 15057a05c118dafcb8cf90d4119e66caaa6026c5 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 3 May 2024 09:11:46 +0200 Subject: Introduce `center` widget helper ... and also make `center_x` and `center_y` set `width` and `height` to `Length::Fill`, respectively. This targets the most common use case when centering things and removes a bunch of boilerplate as a result. --- examples/svg/src/main.rs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'examples/svg/src/main.rs') diff --git a/examples/svg/src/main.rs b/examples/svg/src/main.rs index 0dcf9bc1..45b46716 100644 --- a/examples/svg/src/main.rs +++ b/examples/svg/src/main.rs @@ -1,4 +1,4 @@ -use iced::widget::{checkbox, column, container, svg}; +use iced::widget::{center, checkbox, column, container, svg}; use iced::{color, Element, Length}; pub fn main() -> iced::Result { @@ -44,19 +44,12 @@ impl Tiger { checkbox("Apply a color filter", self.apply_color_filter) .on_toggle(Message::ToggleColorFilter); - container( - column![ - svg, - container(apply_color_filter).width(Length::Fill).center_x() - ] - .spacing(20) - .height(Length::Fill), + center( + column![svg, container(apply_color_filter).center_x()] + .spacing(20) + .height(Length::Fill), ) - .width(Length::Fill) - .height(Length::Fill) .padding(20) - .center_x() - .center_y() .into() } } -- cgit From 05f69f495e9b52e9a7d7bada420558d4c4f6730c Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 13 May 2024 17:56:02 +0200 Subject: Ask for explicit `Length` in `center_*` methods --- examples/svg/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples/svg/src/main.rs') diff --git a/examples/svg/src/main.rs b/examples/svg/src/main.rs index 45b46716..e071c3af 100644 --- a/examples/svg/src/main.rs +++ b/examples/svg/src/main.rs @@ -45,7 +45,7 @@ impl Tiger { .on_toggle(Message::ToggleColorFilter); center( - column![svg, container(apply_color_filter).center_x()] + column![svg, container(apply_color_filter).center_x(Length::Fill)] .spacing(20) .height(Length::Fill), ) -- cgit