pixels_graphics_lib/dialogs/
mod.rs

1use crate::ui::prelude::*;
2use buffer_graphics_lib::prelude::*;
3use std::fmt::Debug;
4
5#[cfg(feature = "directories")]
6pub mod load_file_dialog;
7#[cfg(feature = "directories")]
8pub mod save_file_dialog;
9
10pub const MIN_FILE_DIALOG_SIZE: (usize, usize) = (196, 168);
11
12pub trait FileDialogResults<SR: Clone + Debug + PartialEq> {
13    fn save_file_result(path: String) -> SR;
14    fn load_file_result(path: String) -> SR;
15}
16
17/// Creates a shade and outline for dialogs
18///
19/// Dialog size should be set in `style`
20///
21/// # Parameters
22/// * `width` - Screen width
23/// * `height` - Screen height
24pub fn dialog_background(width: usize, height: usize, style: &DialogStyle) -> ShapeCollection {
25    let mut background = ShapeCollection::default();
26    if let Some(color) = style.shade {
27        InsertShape::insert_above(
28            &mut background,
29            Rect::new((0, 0), (width, height)),
30            fill(color),
31        );
32    }
33    if let Some(color) = style.background {
34        InsertShape::insert_above(&mut background, style.bounds.clone(), fill(color));
35    }
36    if let Some(color) = style.shadow {
37        InsertShape::insert_above(
38            &mut background,
39            style.bounds.translate_by(coord!(1, 1)),
40            stroke(color),
41        );
42    }
43    if let Some(color) = style.border {
44        InsertShape::insert_above(&mut background, style.bounds.clone(), stroke(color));
45    }
46    background
47}