summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLibravatar Aaron Housh <Dispersia@users.noreply.github.com>2021-05-19 07:14:26 -0700
committerLibravatar Aaron Housh <Dispersia@users.noreply.github.com>2021-05-19 07:14:26 -0700
commitae484429d30a3360893d030a17e52caa4164a052 (patch)
tree4bfe30d3b46c7e30170e0b495d9a4dd1a2a1825f /examples
parentcf6af4c2560f5996bc533402ac3e4289c0c94702 (diff)
parent3918257883dba3cf260bd9764cb7b34101c435e6 (diff)
downloadiced-ae484429d30a3360893d030a17e52caa4164a052.tar.gz
iced-ae484429d30a3360893d030a17e52caa4164a052.tar.bz2
iced-ae484429d30a3360893d030a17e52caa4164a052.zip
Merge branch 'hecrj:master' into upgrade-wgpu
Diffstat (limited to 'examples')
-rw-r--r--examples/scrollable/Cargo.toml2
-rw-r--r--examples/scrollable/src/main.rs41
2 files changed, 29 insertions, 14 deletions
diff --git a/examples/scrollable/Cargo.toml b/examples/scrollable/Cargo.toml
index 12753fb6..08502458 100644
--- a/examples/scrollable/Cargo.toml
+++ b/examples/scrollable/Cargo.toml
@@ -6,4 +6,4 @@ edition = "2018"
publish = false
[dependencies]
-iced = { path = "../.." }
+iced = { path = "../..", features = ["debug"] }
diff --git a/examples/scrollable/src/main.rs b/examples/scrollable/src/main.rs
index 8dd2e20c..a570f0f6 100644
--- a/examples/scrollable/src/main.rs
+++ b/examples/scrollable/src/main.rs
@@ -1,8 +1,8 @@
mod style;
use iced::{
- scrollable, Column, Container, Element, Length, Radio, Row, Rule, Sandbox,
- Scrollable, Settings, Space, Text,
+ button, scrollable, Button, Column, Container, Element, Length, Radio, Row,
+ Rule, Sandbox, Scrollable, Settings, Space, Text,
};
pub fn main() -> iced::Result {
@@ -63,12 +63,14 @@ impl Sandbox for ScrollableDemo {
variants
.iter_mut()
.map(|variant| {
- let mut scrollable = Scrollable::new(&mut variant.state)
- .padding(10)
- .width(Length::Fill)
- .height(Length::Fill)
- .style(*theme)
- .push(Text::new(variant.title));
+ let mut scrollable =
+ Scrollable::new(&mut variant.scrollable)
+ .padding(10)
+ .spacing(10)
+ .width(Length::Fill)
+ .height(Length::Fill)
+ .style(*theme)
+ .push(Text::new(variant.title));
if let Some(scrollbar_width) = variant.scrollbar_width {
scrollable = scrollable
@@ -108,6 +110,14 @@ impl Sandbox for ScrollableDemo {
.push(Space::with_height(Length::Units(1200)))
.push(Text::new("Middle"))
.push(Space::with_height(Length::Units(1200)))
+ .push(
+ Button::new(
+ &mut variant.button,
+ Text::new("I am a button"),
+ )
+ .width(Length::Fill)
+ .padding(10),
+ )
.push(Text::new("The End."));
Container::new(scrollable)
@@ -142,7 +152,8 @@ impl Sandbox for ScrollableDemo {
/// A version of a scrollable
struct Variant {
title: &'static str,
- state: scrollable::State,
+ scrollable: scrollable::State,
+ button: button::State,
scrollbar_width: Option<u16>,
scrollbar_margin: Option<u16>,
scroller_width: Option<u16>,
@@ -153,28 +164,32 @@ impl Variant {
vec![
Self {
title: "Default Scrollbar",
- state: scrollable::State::new(),
+ scrollable: scrollable::State::new(),
+ button: button::State::new(),
scrollbar_width: None,
scrollbar_margin: None,
scroller_width: None,
},
Self {
title: "Slimmed & Margin",
- state: scrollable::State::new(),
+ scrollable: scrollable::State::new(),
+ button: button::State::new(),
scrollbar_width: Some(4),
scrollbar_margin: Some(3),
scroller_width: Some(4),
},
Self {
title: "Wide Scroller",
- state: scrollable::State::new(),
+ scrollable: scrollable::State::new(),
+ button: button::State::new(),
scrollbar_width: Some(4),
scrollbar_margin: None,
scroller_width: Some(10),
},
Self {
title: "Narrow Scroller",
- state: scrollable::State::new(),
+ scrollable: scrollable::State::new(),
+ button: button::State::new(),
scrollbar_width: Some(10),
scrollbar_margin: None,
scroller_width: Some(4),