vizia_core/style/
pseudoclass.rs
1use std::hash::Hash;
2
3use std::cmp::{Eq, PartialEq};
4
5use bitflags::bitflags;
6
7bitflags! {
8 #[derive(Debug, Clone, Copy)]
10 pub struct PseudoClassFlags: u32 {
11 const HOVER = 1;
12 const ACTIVE = 1 << 1;
13 const OVER = 1 << 2;
14 const FOCUS = 1 << 3;
15 const FOCUS_VISIBLE = 1 << 4;
16 const FOCUS_WITHIN = 1 << 5;
17 const READ_ONLY = 1 << 6;
18 const READ_WRITE = 1 << 7;
19 const PLACEHOLDER_SHOWN = 1 << 8;
20 const DEFAULT = 1 << 9;
21 const CHECKED = 1 << 10;
22 const INDETERMINATE = 1 << 11;
23 const BLANK = 1 << 12;
24 const VALID = 1 << 13;
25 const INVALID = 1 << 14;
26 const IN_RANGE = 1 << 15;
27 const OUT_OF_RANGE = 1 << 16;
28 const REQUIRED = 1 << 17;
29 const OPTIONAL = 1 << 18;
30 const USER_VALID = 1 << 19;
31 const USER_INVALID = 1 << 20;
32 }
33}
34
35impl Default for PseudoClassFlags {
36 fn default() -> Self {
37 PseudoClassFlags::empty()
38 }
39}
40
41impl std::fmt::Display for PseudoClassFlags {
43 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
44 if self.contains(PseudoClassFlags::HOVER) {
45 write!(f, ":hover")?;
46 }
47 if self.contains(PseudoClassFlags::OVER) {
48 write!(f, ":over")?;
49 }
50 if self.contains(PseudoClassFlags::ACTIVE) {
51 write!(f, ":active")?;
52 }
53 if self.contains(PseudoClassFlags::FOCUS) {
54 write!(f, ":focus")?;
55 }
56 if self.contains(PseudoClassFlags::CHECKED) {
57 write!(f, ":checked")?;
58 }
59 if self.contains(PseudoClassFlags::FOCUS_WITHIN) {
60 write!(f, ":focus-within")?;
61 }
62 if self.contains(PseudoClassFlags::FOCUS_VISIBLE) {
63 write!(f, ":focus-visible")?;
64 }
65
66 Ok(())
67 }
68}