diff options
| author | Max Verevkin <maxxverrr@gmail.com> | 2022-04-01 21:50:19 +0300 |
|---|---|---|
| committer | Max Verevkin <maxxverrr@gmail.com> | 2022-04-01 21:50:19 +0300 |
| commit | 7bcaa341b8685ba411d206c1a89dc3ca77aa71bb (patch) | |
| tree | 917dec11c47ce71fe9486e56f94015bd12c496b7 /src/tags.rs | |
| download | i3bar-mango-7bcaa341b8685ba411d206c1a89dc3ca77aa71bb.tar.gz | |
initial commit
Diffstat (limited to 'src/tags.rs')
| -rw-r--r-- | src/tags.rs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/tags.rs b/src/tags.rs new file mode 100644 index 0000000..8114a74 --- /dev/null +++ b/src/tags.rs @@ -0,0 +1,44 @@ +use crate::text::{Attributes, ComputedText, Text}; +use cairo::Context; +use pango::FontDescription; +use pangocairo::{cairo, pango}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum TagState { + Focused, + Inactive, + Urgent, +} + +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] +pub struct TagsInfo { + pub focused: u32, + pub urgent: u32, +} + +impl TagsInfo { + pub fn get_state(self, tag: usize) -> TagState { + if self.urgent >> tag & 1 == 1 { + TagState::Urgent + } else if self.focused >> tag & 1 == 1 { + TagState::Focused + } else { + TagState::Inactive + } + } +} + +pub fn compute_tag_label(label: String, font: FontDescription, context: &Context) -> ComputedText { + let text = Text { + attr: Attributes { + font, + padding_left: 25.0, + padding_right: 25.0, + min_width: None, + align: Default::default(), + markup: false, + }, + text: label, + }; + text.compute(context) +} |
