diff options
| author | 2022-01-13 15:42:40 +0700 | |
|---|---|---|
| committer | 2022-01-13 15:42:40 +0700 | |
| commit | 15a13a76b4b0534d08afc0328b90267048e41b9d (patch) | |
| tree | dd5fa045c9fd3f8f116f230c3e70dcba2d32d011 /examples | |
| parent | 1a31aefab401712e44cd613fc1337ab90579d926 (diff) | |
| parent | f6c436aec1acb674078bf7e878b9e49f28e947a7 (diff) | |
| download | iced-15a13a76b4b0534d08afc0328b90267048e41b9d.tar.gz iced-15a13a76b4b0534d08afc0328b90267048e41b9d.tar.bz2 iced-15a13a76b4b0534d08afc0328b90267048e41b9d.zip | |
Merge pull request #1193 from iced-rs/responsive-widget
`Responsive` widget
Diffstat (limited to '')
| -rw-r--r-- | examples/pane_grid/Cargo.toml | 1 | ||||
| -rw-r--r-- | examples/pane_grid/src/main.rs | 47 |
2 files changed, 32 insertions, 16 deletions
diff --git a/examples/pane_grid/Cargo.toml b/examples/pane_grid/Cargo.toml index e489f210..03e6cd4a 100644 --- a/examples/pane_grid/Cargo.toml +++ b/examples/pane_grid/Cargo.toml @@ -8,3 +8,4 @@ publish = false [dependencies] iced = { path = "../..", features = ["debug"] } iced_native = { path = "../../native" } +iced_lazy = { path = "../../lazy" } diff --git a/examples/pane_grid/src/main.rs b/examples/pane_grid/src/main.rs index 8225e9e7..2962ca25 100644 --- a/examples/pane_grid/src/main.rs +++ b/examples/pane_grid/src/main.rs @@ -1,8 +1,14 @@ +use iced::alignment::{self, Alignment}; +use iced::button::{self, Button}; +use iced::executor; +use iced::keyboard; +use iced::pane_grid::{self, PaneGrid}; +use iced::scrollable::{self, Scrollable}; use iced::{ - alignment, button, executor, keyboard, pane_grid, scrollable, Alignment, - Application, Button, Color, Column, Command, Container, Element, Length, - PaneGrid, Row, Scrollable, Settings, Subscription, Text, + Application, Color, Column, Command, Container, Element, Length, Row, + Settings, Size, Subscription, Text, }; +use iced_lazy::responsive::{self, Responsive}; use iced_native::{event, subscription, Event}; pub fn main() -> iced::Result { @@ -154,17 +160,24 @@ impl Application for Example { let pane_grid = PaneGrid::new(&mut self.panes, |id, pane| { let is_focused = focus == Some(id); - let text = if pane.is_pinned { "Unpin" } else { "Pin" }; - let pin_button = - Button::new(&mut pane.pin_button, Text::new(text).size(14)) - .on_press(Message::TogglePin(id)) - .style(style::Button::Pin) - .padding(3); + let Pane { + responsive, + pin_button, + is_pinned, + content, + .. + } = pane; + + let text = if *is_pinned { "Unpin" } else { "Pin" }; + let pin_button = Button::new(pin_button, Text::new(text).size(14)) + .on_press(Message::TogglePin(id)) + .style(style::Button::Pin) + .padding(3); let title = Row::with_children(vec