cadmus_core/view/settings_editor/
editor_utils.rs1use crate::color::BLACK;
8use crate::device::CURRENT_DEVICE;
9use crate::geom::{halves, Rectangle};
10use crate::unit::scale_by_dpi;
11use crate::view::filler::Filler;
12use crate::view::{View, SMALL_BAR_HEIGHT, THICKNESS_MEDIUM};
13
14use super::bottom_bar::{BottomBarVariant, SettingsEditorBottomBar};
15
16pub fn calculate_dimensions() -> (i32, i32, i32, i32) {
19 let dpi = CURRENT_DEVICE.dpi;
20 let small_height = scale_by_dpi(SMALL_BAR_HEIGHT, dpi) as i32;
21 let separator_thickness = scale_by_dpi(THICKNESS_MEDIUM, dpi) as i32;
22 let (separator_top_half, separator_bottom_half) = halves(separator_thickness);
23 let bar_height = small_height;
24
25 (
26 bar_height,
27 separator_thickness,
28 separator_top_half,
29 separator_bottom_half,
30 )
31}
32
33pub fn build_bottom_separator(
35 rect: Rectangle,
36 bar_height: i32,
37 separator_top_half: i32,
38 separator_bottom_half: i32,
39) -> Box<dyn View> {
40 let separator = Filler::new(
41 rect![
42 rect.min.x,
43 rect.max.y - bar_height - separator_top_half,
44 rect.max.x,
45 rect.max.y - bar_height + separator_bottom_half
46 ],
47 BLACK,
48 );
49 Box::new(separator) as Box<dyn View>
50}
51
52pub fn build_two_button_bottom_bar(
54 rect: Rectangle,
55 bar_height: i32,
56 separator_bottom_half: i32,
57 variant: BottomBarVariant,
58) -> Box<dyn View> {
59 let bottom_bar_rect = rect![
60 rect.min.x,
61 rect.max.y - bar_height + separator_bottom_half,
62 rect.max.x,
63 rect.max.y
64 ];
65
66 Box::new(SettingsEditorBottomBar::new(bottom_bar_rect, variant)) as Box<dyn View>
67}