oxedyne/fe2o3/fe2o3_tui/src/lib_tui/cfg/status.rs
2.4 KiB, 7 runs
created by r1870400018:1161, which is this file's identity for as long as the history lasts, whatever it is later renamed to
download · who wrote it · its history
| 1 | use crate::lib_tui::{ |
| 2 | cfg::style::StyleLibrary, |
| 3 | draw::status::{ |
| 4 | StatusStripConfig, |
| 5 | StatusStripContent, |
| 6 | StatusStripLeft, |
| 7 | StatusStripRight, |
| 8 | StatusStripType, |
| 9 | }, |
| 10 | style::{ |
| 11 | Colour, |
| 12 | Style, |
| 13 | }, |
| 14 | }; |
| 15 | |
| 16 | use oxedyne_fe2o3_core::prelude::*; |
| 17 | use oxedyne_fe2o3_geom::dim::Coord; |
| 18 | |
| 19 | |
| 20 | #[derive(Clone, Debug, Default)] |
| 21 | pub struct StatusStripLibrary; |
| 22 | |
| 23 | impl StatusStripLibrary {} |
| 24 | |
| 25 | impl StyleLibrary { |
| 26 | |
| 27 | pub fn standard_header_config( |
| 28 | &self, |
| 29 | fore: Option<Colour>, |
| 30 | back: Option<Colour>, |
| 31 | ) |
| 32 | -> StatusStripConfig |
| 33 | { |
| 34 | StatusStripConfig { |
| 35 | style: Style::new(fore, back, None), |
| 36 | typ: StatusStripType::Header, |
| 37 | ..Default::default() |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | pub fn standard_footer_config( |
| 42 | &self, |
| 43 | fore: Option<Colour>, |
| 44 | back: Option<Colour>, |
| 45 | ) |
| 46 | -> StatusStripConfig |
| 47 | { |
| 48 | StatusStripConfig { |
| 49 | style: Style::new(fore, back, None), |
| 50 | typ: StatusStripType::Footer, |
| 51 | ..Default::default() |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | pub fn status_strip_labels<S: Into<String>>( |
| 56 | &self, |
| 57 | left: Option<S>, |
| 58 | right: S, |
| 59 | ) |
| 60 | -> StatusStripContent |
| 61 | { |
| 62 | StatusStripContent { |
| 63 | left: match left { |
| 64 | Some(left) => Some(StatusStripLeft::Origin(left.into())), |
| 65 | None => None, |
| 66 | }, |
| 67 | right: Some(StatusStripRight::Label(right.into())), |
| 68 | ..Default::default() |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | pub fn status_strip_labels_with_mode<S: Into<String>>( |
| 73 | &self, |
| 74 | left: Option<S>, |
| 75 | right: S, |
| 76 | ) |
| 77 | -> StatusStripContent |
| 78 | { |
| 79 | StatusStripContent { |
| 80 | left: match left { |
| 81 | Some(left) => Some(StatusStripLeft::Origin(left.into())), |
| 82 | None => None, |
| 83 | }, |
| 84 | right: Some(StatusStripRight::ModeLabel(None, right.into())), |
| 85 | ..Default::default() |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | pub fn status_strip_cursor<S: Into<String>>( |
| 90 | &self, |
| 91 | left: Option<S>, |
| 92 | ) |
| 93 | -> StatusStripContent |
| 94 | { |
| 95 | StatusStripContent { |
| 96 | left: match left { |
| 97 | Some(left) => Some(StatusStripLeft::Origin(left.into())), |
| 98 | None => None, |
| 99 | }, |
| 100 | right: Some(StatusStripRight::Cursor(Coord::default())), |
| 101 | ..Default::default() |
| 102 | } |
| 103 | } |
| 104 | } |