mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 21:26:43 +01:00
wip: fix implicit static
This commit is contained in:
parent
eeb323b742
commit
49d2055147
6 changed files with 27 additions and 27 deletions
|
|
@ -1,21 +1,5 @@
|
|||
use crate::*;
|
||||
|
||||
/// A UI component.
|
||||
pub trait Component<E: Engine>: Widget<Engine = E> + Handle<E> {}
|
||||
|
||||
/// Everything that implements [Render] and [Handle] is a [Component].
|
||||
impl<E: Engine, C: Widget<Engine = E> + Handle<E>> Component<E> for C {}
|
||||
|
||||
/// Marker trait for [Component]s that can [Exit]
|
||||
pub trait ExitableComponent<E>: Exit + Component<E> where E: Engine {
|
||||
/// Perform type erasure for collecting heterogeneous components.
|
||||
fn boxed (self) -> Box<dyn ExitableComponent<E>> where Self: Sized + 'static {
|
||||
Box::new(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: Engine, C: Component<E> + Exit> ExitableComponent<E> for C {}
|
||||
|
||||
pub trait Widget {
|
||||
type Engine: Engine;
|
||||
fn layout (&self, to: <<Self as Widget>::Engine as Engine>::Area) ->
|
||||
|
|
@ -23,7 +7,7 @@ pub trait Widget {
|
|||
fn render (&self, to: &mut Self::Engine) ->
|
||||
Perhaps<<<Self as Widget>::Engine as Engine>::Area>;
|
||||
}
|
||||
impl<E: Engine> Widget for Box<dyn Widget<Engine = E>> {
|
||||
impl<'a, E: Engine> Widget for Box<dyn Widget<Engine = E> + 'a> {
|
||||
type Engine = E;
|
||||
fn layout (&self, to: E::Area) -> Perhaps<E::Area> {
|
||||
(**self).layout(to)
|
||||
|
|
@ -105,3 +89,9 @@ impl<E: Engine, W> Widget for W where W: Content<Engine = E> {
|
|||
self.content().render(to)
|
||||
}
|
||||
}
|
||||
|
||||
/// A UI component.
|
||||
pub trait Component<E: Engine>: Widget<Engine = E> + Handle<E> {}
|
||||
|
||||
/// Everything that implements [Render] and [Handle] is a [Component].
|
||||
impl<E: Engine, C: Widget<Engine = E> + Handle<E>> Component<E> for C {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue