Set style can be part of the trait definition
This commit is contained in:
parent
b132edc6fc
commit
a72622e1c8
|
@ -95,10 +95,6 @@ pub trait Object: NativeObject {
|
|||
}
|
||||
}
|
||||
|
||||
fn set_style(&mut self, style: Style);
|
||||
}
|
||||
|
||||
impl Object for ObjectX {
|
||||
fn set_style(&mut self, style: Style) {
|
||||
unsafe {
|
||||
let boxed = Box::new(style.raw);
|
||||
|
@ -107,6 +103,8 @@ impl Object for ObjectX {
|
|||
}
|
||||
}
|
||||
|
||||
impl Object for ObjectX {}
|
||||
|
||||
macro_rules! define_object {
|
||||
($item:ident) => {
|
||||
pub struct $item {
|
||||
|
@ -119,17 +117,7 @@ macro_rules! define_object {
|
|||
}
|
||||
}
|
||||
|
||||
impl $crate::support::Object for $item {
|
||||
fn set_style(&mut self, style: $crate::support::Style) {
|
||||
unsafe {
|
||||
let boxed = alloc::boxed::Box::new(style.raw);
|
||||
lvgl_sys::lv_obj_set_style(
|
||||
self.raw().as_mut(),
|
||||
alloc::boxed::Box::into_raw(boxed),
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
impl $crate::support::Object for $item {}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue