note: don't allow nested note previews

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2024-04-14 16:50:51 -07:00
parent 6f2aa56b9e
commit a8185d9a75
3 changed files with 91 additions and 29 deletions

41
src/ui/note/options.rs Normal file
View File

@@ -0,0 +1,41 @@
use bitflags::bitflags;
bitflags! {
// Attributes can be applied to flags types
#[repr(transparent)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NoteOptions: u32 {
const actionbar = 0b00000001;
const note_previews = 0b00000010;
}
}
impl NoteOptions {
#[inline]
pub fn has_actionbar(self) -> bool {
(self & NoteOptions::actionbar) == NoteOptions::actionbar
}
#[inline]
pub fn has_note_previews(self) -> bool {
(self & NoteOptions::note_previews) == NoteOptions::note_previews
}
#[inline]
pub fn set_note_previews(&mut self, enable: bool) {
if enable {
*self = *self | NoteOptions::note_previews;
} else {
*self = *self & !NoteOptions::note_previews;
}
}
#[inline]
pub fn set_actionbar(&mut self, enable: bool) {
if enable {
*self = *self | NoteOptions::actionbar;
} else {
*self = *self & !NoteOptions::actionbar;
}
}
}