summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-11-11 05:26:08 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-11-11 05:26:08 +0100
commitceb02f4a36769c488c2525db2fb73f092a6c2706 (patch)
treed7a43c6b9444fb3079501e49ca1f80e31f1b4740 /examples
parentbfe19193b95e9d1be0694bbc6a96e20a9aefdc09 (diff)
downloadiced-ceb02f4a36769c488c2525db2fb73f092a6c2706.tar.gz
iced-ceb02f4a36769c488c2525db2fb73f092a6c2706.tar.bz2
iced-ceb02f4a36769c488c2525db2fb73f092a6c2706.zip
Implement `Container` widget
Remove `align_self` and `justify_content` methods
Diffstat (limited to 'examples')
-rw-r--r--examples/todos.rs7
-rw-r--r--examples/tour.rs58
2 files changed, 31 insertions, 34 deletions
diff --git a/examples/todos.rs b/examples/todos.rs
index 4caad949..7f37300b 100644
--- a/examples/todos.rs
+++ b/examples/todos.rs
@@ -1,6 +1,6 @@
use iced::{
- scrollable, text::HorizontalAlignment, text_input, Align, Application,
- Checkbox, Color, Column, Element, Scrollable, Text, TextInput,
+ scrollable, text::HorizontalAlignment, text_input, Application, Checkbox,
+ Color, Column, Container, Element, Length, Scrollable, Text, TextInput,
};
pub fn main() {
@@ -78,7 +78,6 @@ impl Application for Todos {
let content = Column::new()
.max_width(800)
- .align_self(Align::Center)
.spacing(20)
.push(title)
.push(input)
@@ -86,7 +85,7 @@ impl Application for Todos {
Scrollable::new(&mut self.scroll)
.padding(40)
- .push(content)
+ .push(Container::new(content).width(Length::Fill).center_x())
.into()
}
}
diff --git a/examples/tour.rs b/examples/tour.rs
index 9e93170a..2e60f090 100644
--- a/examples/tour.rs
+++ b/examples/tour.rs
@@ -1,7 +1,7 @@
use iced::{
button, scrollable, slider, text::HorizontalAlignment, text_input, Align,
- Application, Background, Button, Checkbox, Color, Column, Element, Image,
- Justify, Length, Radio, Row, Scrollable, Slider, Text, TextInput,
+ Application, Background, Button, Checkbox, Color, Column, Container,
+ Element, Image, Length, Radio, Row, Scrollable, Slider, Text, TextInput,
};
pub fn main() {
@@ -78,7 +78,7 @@ impl Application for Tour {
);
}
- let element: Element<_> = Column::new()
+ let content: Element<_> = Column::new()
.max_width(540)
.spacing(20)
.padding(20)
@@ -86,20 +86,18 @@ impl Application for Tour {
.push(controls)
.into();
- let element = if self.debug {
- element.explain(Color::BLACK)
+ let content = if self.debug {
+ content.explain(Color::BLACK)
} else {
- element
+ content
};
- Column::new()
+ let scrollable = Scrollable::new(scroll)
+ .push(Container::new(content).width(Length::Fill).center_x());
+
+ Container::new(scrollable)
.height(Length::Fill)
- .justify_content(Justify::Center)
- .push(
- Scrollable::new(scroll)
- .align_items(Align::Center)
- .push(element),
- )
+ .center_y()
.into()
}
}
@@ -340,10 +338,7 @@ impl<'a> Step {
}
fn container(title: &str) -> Column<'a, StepMessage> {
- Column::new()
- .spacing(20)
- .align_items(Align::Stretch)
- .push(Text::new(title).size(50))
+ Column::new().spacing(20).push(Text::new(title).size(50))
}
fn welcome() -> Column<'a, StepMessage> {
@@ -646,19 +641,22 @@ impl<'a> Step {
}
}
-fn ferris(width: u16) -> Image {
- // This should go away once we unify resource loading on native
- // platforms
- if cfg!(target_arch = "wasm32") {
- Image::new("resources/ferris.png")
- } else {
- Image::new(format!(
- "{}/examples/resources/ferris.png",
- env!("CARGO_MANIFEST_DIR")
- ))
- }
- .width(Length::Units(width))
- .align_self(Align::Center)
+fn ferris<'a>(width: u16) -> Container<'a, StepMessage> {
+ Container::new(
+ // This should go away once we unify resource loading on native
+ // platforms
+ if cfg!(target_arch = "wasm32") {
+ Image::new("resources/ferris.png")
+ } else {
+ Image::new(format!(
+ "{}/examples/resources/ferris.png",
+ env!("CARGO_MANIFEST_DIR")
+ ))
+ }
+ .width(Length::Units(width)),
+ )
+ .width(Length::Fill)
+ .center_x()
}
fn button<'a, Message>(