macro_rules! impl_styled {
($ty:ty) => {
impl gpui::Styled for $ty {
fn style(&mut self) -> &mut gpui::StyleRefinement {
&mut self.style
}
}
};
($ty:ty, $field:ident) => {
impl gpui::Styled for $ty {
fn style(&mut self) -> &mut gpui::StyleRefinement {
&mut self.$field
}
}
};
}
macro_rules! impl_sizable {
($ty:ty) => {
impl $crate::Sizable for $ty {
fn with_size(mut self, size: impl Into<$crate::Size>) -> Self {
self.size = size.into();
self
}
}
};
}
macro_rules! impl_disableable {
($ty:ty) => {
impl $crate::Disableable for $ty {
fn disabled(mut self, disabled: bool) -> Self {
self.disabled = disabled;
self
}
}
};
}
macro_rules! impl_selectable {
($ty:ty) => {
impl $crate::Selectable for $ty {
fn selected(mut self, selected: bool) -> Self {
self.selected = selected;
self
}
fn is_selected(&self) -> bool {
self.selected
}
}
};
($ty:ty, $field:ident) => {
impl $crate::Selectable for $ty {
fn selected(mut self, selected: bool) -> Self {
self.$field = selected;
self
}
fn is_selected(&self) -> bool {
self.$field
}
}
};
}
macro_rules! impl_parent_element {
($ty:ty) => {
impl gpui::ParentElement for $ty {
fn extend(&mut self, elements: impl IntoIterator<Item = gpui::AnyElement>) {
self.children.extend(elements);
}
}
};
}