pub struct Pod<V> { /* private fields */ }Expand description
A view that has separate ViewState from its content.
When calling for example View::event, an EventCx is passed to the
function. This EventCx contains a mutable reference to a ViewState that is used to
keep track of state like whether the view is hovered or active. If a pod is not used when
implementing a view, the View and the content share the same ViewState. This is
almost always an issue when the View wants to have a diffrent transform or size than
the content. See for example the Pad view.
§Examples
ⓘ
use ori::prelude::*;
struct ContainerView<V> {
    // We wrap the content in a Pod here
    content: Pod<V>,
}
impl<V: View<T>, T> View<T> for ContainerView<V> {
    // We use the Pod's state here
    type State = State<T, V>;
    fn build(&mut self, cx: &mut BuildCx, data: &mut T) -> Self::State {
        self.content.build(cx, data)
    }
    // ...
}Implementations§
Trait Implementations§
Source§impl<T, V> View<T> for Pod<V>where
    V: View<T>,
 
impl<T, V> View<T> for Pod<V>where
    V: View<T>,
Source§type State = PodState<T, V>
 
type State = PodState<T, V>
The state of the view, see top-level documentation for more information.
Source§fn build(
    &mut self,
    cx: &mut BuildCx<'_, '_>,
    data: &mut T,
) -> <Pod<V> as View<T>>::State
 
fn build( &mut self, cx: &mut BuildCx<'_, '_>, data: &mut T, ) -> <Pod<V> as View<T>>::State
Build the view state, see top-level documentation for more information.
Source§fn rebuild(
    &mut self,
    state: &mut <Pod<V> as View<T>>::State,
    cx: &mut RebuildCx<'_, '_>,
    data: &mut T,
    old: &Pod<V>,
)
 
fn rebuild( &mut self, state: &mut <Pod<V> as View<T>>::State, cx: &mut RebuildCx<'_, '_>, data: &mut T, old: &Pod<V>, )
Rebuild the view state, see top-level documentation for more information.
Source§fn event(
    &mut self,
    state: &mut <Pod<V> as View<T>>::State,
    cx: &mut EventCx<'_, '_>,
    data: &mut T,
    event: &Event,
) -> bool
 
fn event( &mut self, state: &mut <Pod<V> as View<T>>::State, cx: &mut EventCx<'_, '_>, data: &mut T, event: &Event, ) -> bool
Handle an event, see top-level documentation for more information.
impl<V> Copy for Pod<V>where
    V: Copy,
impl<V> Eq for Pod<V>where
    V: Eq,
impl<V> StructuralPartialEq for Pod<V>
Auto Trait Implementations§
impl<V> Freeze for Pod<V>where
    V: Freeze,
impl<V> RefUnwindSafe for Pod<V>where
    V: RefUnwindSafe,
impl<V> Send for Pod<V>where
    V: Send,
impl<V> Sync for Pod<V>where
    V: Sync,
impl<V> Unpin for Pod<V>where
    V: Unpin,
impl<V> UnwindSafe for Pod<V>where
    V: UnwindSafe,
Blanket Implementations§
Source§impl<T, V> AnyView<T> for V
 
impl<T, V> AnyView<T> for V
Source§fn dyn_build(&mut self, cx: &mut BuildCx<'_, '_>, data: &mut T) -> Box<dyn Any>
 
fn dyn_build(&mut self, cx: &mut BuildCx<'_, '_>, data: &mut T) -> Box<dyn Any>
Build the view.
Source§fn dyn_rebuild(
    &mut self,
    state: &mut Box<dyn Any>,
    cx: &mut RebuildCx<'_, '_>,
    data: &mut T,
    old: &dyn AnyView<T>,
)
 
fn dyn_rebuild( &mut self, state: &mut Box<dyn Any>, cx: &mut RebuildCx<'_, '_>, data: &mut T, old: &dyn AnyView<T>, )
Rebuild the view.
Source§fn dyn_event(
    &mut self,
    state: &mut Box<dyn Any>,
    cx: &mut EventCx<'_, '_>,
    data: &mut T,
    event: &Event,
) -> bool
 
fn dyn_event( &mut self, state: &mut Box<dyn Any>, cx: &mut EventCx<'_, '_>, data: &mut T, event: &Event, ) -> bool
Handle an event.
Source§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more