diff options
author | 2020-12-22 14:58:39 +0100 | |
---|---|---|
committer | 2020-12-22 14:58:39 +0100 | |
commit | f8aef03456ecc185098b6305a8cd0e22f5297d06 (patch) | |
tree | bdd8fd190980840235c4d10365cac98f3a260c21 /examples | |
parent | a366600e7347c24bbb6679118a12b616a031deff (diff) | |
parent | e815c5bbd72f618ad890e1d3c5a67c811cd07108 (diff) | |
download | iced-f8aef03456ecc185098b6305a8cd0e22f5297d06.tar.gz iced-f8aef03456ecc185098b6305a8cd0e22f5297d06.tar.bz2 iced-f8aef03456ecc185098b6305a8cd0e22f5297d06.zip |
Merge pull request #657 from clarkmoody/feature/pane-grid-title-contents
Generic Element Content in Pane Grid TitleBar
Diffstat (limited to 'examples')
-rw-r--r-- | examples/pane_grid/src/main.rs | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/examples/pane_grid/src/main.rs b/examples/pane_grid/src/main.rs index 3c3256cf..c44d24fd 100644 --- a/examples/pane_grid/src/main.rs +++ b/examples/pane_grid/src/main.rs @@ -1,7 +1,7 @@ use iced::{ button, executor, keyboard, pane_grid, scrollable, Align, Application, - Button, Column, Command, Container, Element, HorizontalAlignment, Length, - PaneGrid, Scrollable, Settings, Subscription, Text, + Button, Color, Column, Command, Container, Element, HorizontalAlignment, + Length, PaneGrid, Row, Scrollable, Settings, Subscription, Text, }; use iced_native::{event, subscription, Event}; @@ -141,10 +141,21 @@ impl Application for Example { let pane_grid = PaneGrid::new(&mut self.panes, |pane, content| { let is_focused = focus == Some(pane); - let title_bar = - pane_grid::TitleBar::new(format!("Pane {}", content.id)) - .padding(10) - .style(style::TitleBar { is_focused }); + let title = Row::with_children(vec![ + Text::new("Pane").into(), + Text::new(content.id.to_string()) + .color(if is_focused { + PANE_ID_COLOR_FOCUSED + } else { + PANE_ID_COLOR_UNFOCUSED + }) + .into(), + ]) + .spacing(5); + + let title_bar = pane_grid::TitleBar::new(title) + .padding(10) + .style(style::TitleBar { is_focused }); pane_grid::Content::new(content.view(pane, total_panes)) .title_bar(title_bar) @@ -165,6 +176,17 @@ impl Application for Example { } } +const PANE_ID_COLOR_UNFOCUSED: Color = Color::from_rgb( + 0xFF as f32 / 255.0, + 0xC7 as f32 / 255.0, + 0xC7 as f32 / 255.0, +); +const PANE_ID_COLOR_FOCUSED: Color = Color::from_rgb( + 0xFF as f32 / 255.0, + 0x47 as f32 / 255.0, + 0x47 as f32 / 255.0, +); + fn handle_hotkey(key_code: keyboard::KeyCode) -> Option<Message> { use keyboard::KeyCode; use pane_grid::{Axis, Direction}; |