Derive Macro gui_derive::Widget
source · #[derive(Widget)]
{
// Attributes available to this derive:
#[gui]
}
Expand description
Custom derive functionality for the gui::Widget
trait.
Using this macro a default implementation of the gui::Widget
trait can be created. Note that this trait is just a unification of
the gui::Object
, gui::Renderable
, and gui::Handleable
traits.
Note furthermore that only implementations of the former two will be
auto generated. The reason for this behavior is that
gui::Handleable
most likely needs customization to accommodate for
custom event handling behavior.
This macro roughly expands to the following code:
impl gui::Renderable for TestWidget {
fn type_id(&self) -> TypeId {
TypeId::of::<TestWidget>()
}
fn render(
&self,
cap: &dyn gui::Cap,
renderer: &dyn gui::Renderer,
bbox: gui::BBox,
) -> gui::BBox {
renderer.render(self, cap, bbox)
}
}
impl gui::Object for TestWidget {
fn id(&self) -> gui::Id {
self.id
}
}
impl gui::Widget<Event, Message> for TestWidget {
fn type_id(&self) -> TypeId {
TypeId::of::<TestWidget>()
}
}