diff options
Diffstat (limited to 'src/options.rs')
| -rw-r--r-- | src/options.rs | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/src/options.rs b/src/options.rs index 2dc25d7..2ebdd5f 100644 --- a/src/options.rs +++ b/src/options.rs @@ -1,9 +1,10 @@ use std::collections::BTreeMap; use std::str::FromStr; +use iced::widget::grid::Sizing; use iced::widget::text::LineHeight; #[allow(unused_imports)] -use iced::widget::{Button, Column, Container, Image, Row, Svg, Text}; +use iced::widget::{Button, Column, Container, Grid, Image, Row, Svg, Text}; use iced::{Alignment, ContentFit, Length, Padding, Pixels, Rotation}; use crate::values::Value; @@ -258,6 +259,39 @@ impl<Message> ApplyOptions for Row<'_, Message> { } } +impl<'a, Message> ApplyOptions for Grid<'a, Message> { + fn apply_options(self, options: BTreeMap<String, Option<String>>) -> Self { + let mut grid = self; + + if let Some(spacing) = options.get("spacing").expect("spacing key") { + let spacing = f32::from_str(spacing).unwrap(); + grid = grid.spacing(spacing); + } + + if let Some(width) = options.get("width").expect("width key") { + let width = Pixels::from_str(width).unwrap(); + grid = grid.width(width); + } + + if let Some(height) = options.get("height").expect("height key") { + let height = Sizing::from_str(height).unwrap(); + grid = grid.height(height); + } + + if let Some(columns) = options.get("columns").expect("columns key") { + let columns = usize::from_str(columns).unwrap(); + grid = grid.columns(columns); + } + + if let Some(fluid) = options.get("fluid").expect("fluid key") { + let fluid = Pixels::from_str(fluid).unwrap(); + grid = grid.fluid(fluid); + } + + grid + } +} + impl<Handle> ApplyOptions for Image<Handle> { fn apply_options(self, options: BTreeMap<String, Option<String>>) -> Self { let mut image = self; |
