summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-02-11 18:42:15 +0700
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-02-11 18:42:15 +0700
commit43a7ad72ef070929278e6d03d98077ac267fe2a6 (patch)
tree335a946dd0c91a3914b6e15bf2d18141372d1f6e /examples
parent66d69b5c9a183091e05e82bbe21b3203f75c1b18 (diff)
downloadiced-43a7ad72ef070929278e6d03d98077ac267fe2a6.tar.gz
iced-43a7ad72ef070929278e6d03d98077ac267fe2a6.tar.bz2
iced-43a7ad72ef070929278e6d03d98077ac267fe2a6.zip
Expose function helpers to build widgets in `pure::widget`
`button("Hello")` is easier to write and read than `Button::new("Hello")`.
Diffstat (limited to 'examples')
-rw-r--r--examples/pure/counter/src/main.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/examples/pure/counter/src/main.rs b/examples/pure/counter/src/main.rs
index 00cb3fc7..4cb79a0e 100644
--- a/examples/pure/counter/src/main.rs
+++ b/examples/pure/counter/src/main.rs
@@ -1,4 +1,5 @@
-use iced::pure::{Button, Column, Element, Sandbox, Text};
+use iced::pure::widget::{button, column, text};
+use iced::pure::{Element, Sandbox};
use iced::{Alignment, Settings};
pub fn main() -> iced::Result {
@@ -38,12 +39,12 @@ impl Sandbox for Counter {
}
fn view(&self) -> Element<Message> {
- Column::new()
+ column()
.padding(20)
.align_items(Alignment::Center)
- .push(Button::new("Increment").on_press(Message::IncrementPressed))
- .push(Text::new(self.value.to_string()).size(50))
- .push(Button::new("Decrement").on_press(Message::DecrementPressed))
+ .push(button("Increment").on_press(Message::IncrementPressed))
+ .push(text(self.value).size(50))
+ .push(button("Decrement").on_press(Message::DecrementPressed))
.into()
}
}