Skip to content

Commit

Permalink
Add alpha to HighlightColor::NoHighlightColor
Browse files Browse the repository at this point in the history
  • Loading branch information
rbran committed May 11, 2024
1 parent 5a06604 commit 26619bf
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions rust/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3375,7 +3375,9 @@ impl HighlightStandardColor {

#[derive(Debug, Copy, Clone)]
pub enum HighlightColor {
NoHighlightColor,
NoHighlightColor {
alpha: u8,
},
StandardHighlightColor {
color: HighlightStandardColor,
alpha: u8,
Expand Down Expand Up @@ -3403,7 +3405,7 @@ impl HighlightColor {
HIGHLIGHT_COLOR => {
let Some(color) = HighlightStandardColor::from_raw(raw.color) else {
// StandardHighlightColor with NoHighlightColor, is no color
return Self::NoHighlightColor;
return Self::NoHighlightColor { alpha: raw.alpha };
};
Self::StandardHighlightColor {
color,
Expand Down Expand Up @@ -3431,16 +3433,17 @@ impl HighlightColor {
alpha: raw.alpha,
},
// other color style is just no color
_ => Self::NoHighlightColor,
_ => Self::NoHighlightColor { alpha: u8::MAX },
}
}

pub fn into_raw(self) -> BNHighlightColor {
let zeroed: BNHighlightColor = unsafe { core::mem::zeroed() };
match self {
Self::NoHighlightColor => BNHighlightColor {
Self::NoHighlightColor { alpha } => BNHighlightColor {
style: BNHighlightColorStyle::StandardHighlightColor,
color: BNHighlightStandardColor::NoHighlightColor,
alpha,
..zeroed
},
Self::StandardHighlightColor { color, alpha } => BNHighlightColor {
Expand Down

0 comments on commit 26619bf

Please sign in to comment.