mirror of
https://github.com/aljazceru/notedeck.git
synced 2025-12-18 09:04:21 +01:00
note: options: streamline bit macro
Include has method in the bit note options macro
This commit is contained in:
@@ -24,8 +24,8 @@ impl Default for NoteOptions {
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! create_setter {
|
||||
($fn_name:ident, $option:ident) => {
|
||||
macro_rules! create_bit_methods {
|
||||
($fn_name:ident, $has_name:ident, $option:ident) => {
|
||||
#[inline]
|
||||
pub fn $fn_name(&mut self, enable: bool) {
|
||||
if enable {
|
||||
@@ -34,19 +34,24 @@ macro_rules! create_setter {
|
||||
*self &= !NoteOptions::$option;
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn $has_name(self) -> bool {
|
||||
(self & NoteOptions::$option) == NoteOptions::$option
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
impl NoteOptions {
|
||||
create_setter!(set_small_pfp, small_pfp);
|
||||
create_setter!(set_medium_pfp, medium_pfp);
|
||||
create_setter!(set_note_previews, note_previews);
|
||||
create_setter!(set_selectable_text, selectable_text);
|
||||
create_setter!(set_textmode, textmode);
|
||||
create_setter!(set_actionbar, actionbar);
|
||||
create_setter!(set_wide, wide);
|
||||
create_setter!(set_options_button, options_button);
|
||||
create_setter!(set_hide_media, hide_media);
|
||||
create_bit_methods!(set_small_pfp, has_small_pfp, small_pfp);
|
||||
create_bit_methods!(set_medium_pfp, has_medium_pfp, medium_pfp);
|
||||
create_bit_methods!(set_note_previews, has_note_previews, note_previews);
|
||||
create_bit_methods!(set_selectable_text, has_selectable_text, selectable_text);
|
||||
create_bit_methods!(set_textmode, has_textmode, textmode);
|
||||
create_bit_methods!(set_actionbar, has_actionbar, actionbar);
|
||||
create_bit_methods!(set_wide, has_wide, wide);
|
||||
create_bit_methods!(set_options_button, has_options_button, options_button);
|
||||
create_bit_methods!(set_hide_media, has_hide_media, hide_media);
|
||||
|
||||
pub fn new(is_universe_timeline: bool) -> Self {
|
||||
let mut options = NoteOptions::default();
|
||||
@@ -54,51 +59,6 @@ impl NoteOptions {
|
||||
options
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn has_actionbar(self) -> bool {
|
||||
(self & NoteOptions::actionbar) == NoteOptions::actionbar
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn has_hide_media(self) -> bool {
|
||||
(self & NoteOptions::hide_media) == NoteOptions::hide_media
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn has_selectable_text(self) -> bool {
|
||||
(self & NoteOptions::selectable_text) == NoteOptions::selectable_text
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn has_textmode(self) -> bool {
|
||||
(self & NoteOptions::textmode) == NoteOptions::textmode
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn has_note_previews(self) -> bool {
|
||||
(self & NoteOptions::note_previews) == NoteOptions::note_previews
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn has_small_pfp(self) -> bool {
|
||||
(self & NoteOptions::small_pfp) == NoteOptions::small_pfp
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn has_medium_pfp(self) -> bool {
|
||||
(self & NoteOptions::medium_pfp) == NoteOptions::medium_pfp
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn has_wide(self) -> bool {
|
||||
(self & NoteOptions::wide) == NoteOptions::wide
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn has_options_button(self) -> bool {
|
||||
(self & NoteOptions::options_button) == NoteOptions::options_button
|
||||
}
|
||||
|
||||
pub fn pfp_size(&self) -> f32 {
|
||||
if self.has_small_pfp() {
|
||||
ProfilePic::small_size()
|
||||
|
||||
Reference in New Issue
Block a user