[−][src]Derive Macro gui_derive::Widget
#[derive(Widget)] { // Attributes available to this derive: #[gui] }
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::Renderer
, 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, renderer: &gui::Renderer, bbox: gui::BBox, cap: &gui::Cap) -> gui::BBox { renderer.render(self, bbox, cap) } } impl gui::Object for TestWidget { fn id(&self) -> gui::Id { self.id } } impl gui::Widget<Event> for TestWidget { fn type_id(&self) -> TypeId { TypeId::of::<TestWidget>() } }