Skip to main content

ChildView

Struct ChildView 

Source
pub struct ChildView<'a, ViewId> {
    pub id: ViewId,
    pub kind: ViewKind,
    pub frame: Rectangle,
    pub properties: ViewProperties<'a>,
}
Expand description

A child view registered by a parent crate::UiView.

Fields§

§id: ViewId

Application-defined child identifier.

§kind: ViewKind

Semantic type used by higher-level tooling or presenters.

§frame: Rectangle

Child frame in parent coordinates.

§properties: ViewProperties<'a>

Child properties advertised by the parent.

Implementations§

Source§

impl<'a, ViewId> ChildView<'a, ViewId>

Source

pub const fn new(id: ViewId, frame: Rectangle) -> Self

Creates a custom child view registration.

Examples found in repository?
examples/runtime_shell.rs (line 29)
27    fn configure(&mut self, registration: &mut ViewRegistration<'static, RootId, 1>) {
28        let _ = registration.add_child(
29            ChildView::new(RootId::Surface, registration.frame()).with_kind(ViewKind::Custom),
30        );
31    }
More examples
Hide additional examples
examples/uikit_root.rs (line 47)
42    fn configure(&mut self, registration: &mut ViewRegistration<'static, DemoViewId, 2>) {
43        registration.set_title(Localized::new("root.title", "Devices"));
44        registration.set_clips_to_bounds(true);
45        let list_frame = registration.frame();
46        let _ = registration.add_child(
47            ChildView::new(DemoViewId::DevicesList, list_frame)
48                .with_kind(ViewKind::List)
49                .with_title(Localized::new("devices.title", "Devices")),
50        );
51        let _ = registration.add_child(
52            ChildView::new(
53                DemoViewId::AlertOverlay,
54                Rectangle::new(Point::new(16, 16), Size::new(0, 0)),
55            )
56            .with_kind(ViewKind::AlertHost)
57            .with_hidden(true)
58            .with_alpha(0),
59        );
60    }
Source

pub const fn with_kind(self, kind: ViewKind) -> Self

Marks the child as a specific view kind.

Examples found in repository?
examples/runtime_shell.rs (line 29)
27    fn configure(&mut self, registration: &mut ViewRegistration<'static, RootId, 1>) {
28        let _ = registration.add_child(
29            ChildView::new(RootId::Surface, registration.frame()).with_kind(ViewKind::Custom),
30        );
31    }
More examples
Hide additional examples
examples/uikit_root.rs (line 48)
42    fn configure(&mut self, registration: &mut ViewRegistration<'static, DemoViewId, 2>) {
43        registration.set_title(Localized::new("root.title", "Devices"));
44        registration.set_clips_to_bounds(true);
45        let list_frame = registration.frame();
46        let _ = registration.add_child(
47            ChildView::new(DemoViewId::DevicesList, list_frame)
48                .with_kind(ViewKind::List)
49                .with_title(Localized::new("devices.title", "Devices")),
50        );
51        let _ = registration.add_child(
52            ChildView::new(
53                DemoViewId::AlertOverlay,
54                Rectangle::new(Point::new(16, 16), Size::new(0, 0)),
55            )
56            .with_kind(ViewKind::AlertHost)
57            .with_hidden(true)
58            .with_alpha(0),
59        );
60    }
Source

pub const fn with_title(self, title: Localized<'a>) -> Self

Sets the child title.

Examples found in repository?
examples/uikit_root.rs (line 49)
42    fn configure(&mut self, registration: &mut ViewRegistration<'static, DemoViewId, 2>) {
43        registration.set_title(Localized::new("root.title", "Devices"));
44        registration.set_clips_to_bounds(true);
45        let list_frame = registration.frame();
46        let _ = registration.add_child(
47            ChildView::new(DemoViewId::DevicesList, list_frame)
48                .with_kind(ViewKind::List)
49                .with_title(Localized::new("devices.title", "Devices")),
50        );
51        let _ = registration.add_child(
52            ChildView::new(
53                DemoViewId::AlertOverlay,
54                Rectangle::new(Point::new(16, 16), Size::new(0, 0)),
55            )
56            .with_kind(ViewKind::AlertHost)
57            .with_hidden(true)
58            .with_alpha(0),
59        );
60    }
Source

pub const fn with_alpha(self, alpha: u8) -> Self

Sets the child alpha.

Examples found in repository?
examples/uikit_root.rs (line 58)
42    fn configure(&mut self, registration: &mut ViewRegistration<'static, DemoViewId, 2>) {
43        registration.set_title(Localized::new("root.title", "Devices"));
44        registration.set_clips_to_bounds(true);
45        let list_frame = registration.frame();
46        let _ = registration.add_child(
47            ChildView::new(DemoViewId::DevicesList, list_frame)
48                .with_kind(ViewKind::List)
49                .with_title(Localized::new("devices.title", "Devices")),
50        );
51        let _ = registration.add_child(
52            ChildView::new(
53                DemoViewId::AlertOverlay,
54                Rectangle::new(Point::new(16, 16), Size::new(0, 0)),
55            )
56            .with_kind(ViewKind::AlertHost)
57            .with_hidden(true)
58            .with_alpha(0),
59        );
60    }
Source

pub const fn with_hidden(self, hidden: bool) -> Self

Marks the child as hidden or visible.

Examples found in repository?
examples/uikit_root.rs (line 57)
42    fn configure(&mut self, registration: &mut ViewRegistration<'static, DemoViewId, 2>) {
43        registration.set_title(Localized::new("root.title", "Devices"));
44        registration.set_clips_to_bounds(true);
45        let list_frame = registration.frame();
46        let _ = registration.add_child(
47            ChildView::new(DemoViewId::DevicesList, list_frame)
48                .with_kind(ViewKind::List)
49                .with_title(Localized::new("devices.title", "Devices")),
50        );
51        let _ = registration.add_child(
52            ChildView::new(
53                DemoViewId::AlertOverlay,
54                Rectangle::new(Point::new(16, 16), Size::new(0, 0)),
55            )
56            .with_kind(ViewKind::AlertHost)
57            .with_hidden(true)
58            .with_alpha(0),
59        );
60    }
Source

pub const fn with_clipping(self, clips_to_bounds: bool) -> Self

Enables or disables clipping for this child.

Trait Implementations§

Source§

impl<'a, ViewId: Clone> Clone for ChildView<'a, ViewId>

Source§

fn clone(&self) -> ChildView<'a, ViewId>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, ViewId: Debug> Debug for ChildView<'a, ViewId>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, ViewId: PartialEq> PartialEq for ChildView<'a, ViewId>

Source§

fn eq(&self, other: &ChildView<'a, ViewId>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, ViewId: Copy> Copy for ChildView<'a, ViewId>

Source§

impl<'a, ViewId: Eq> Eq for ChildView<'a, ViewId>

Source§

impl<'a, ViewId> StructuralPartialEq for ChildView<'a, ViewId>

Auto Trait Implementations§

§

impl<'a, ViewId> Freeze for ChildView<'a, ViewId>
where ViewId: Freeze,

§

impl<'a, ViewId> RefUnwindSafe for ChildView<'a, ViewId>
where ViewId: RefUnwindSafe,

§

impl<'a, ViewId> Send for ChildView<'a, ViewId>
where ViewId: Send,

§

impl<'a, ViewId> Sync for ChildView<'a, ViewId>
where ViewId: Sync,

§

impl<'a, ViewId> Unpin for ChildView<'a, ViewId>
where ViewId: Unpin,

§

impl<'a, ViewId> UnsafeUnpin for ChildView<'a, ViewId>
where ViewId: UnsafeUnpin,

§

impl<'a, ViewId> UnwindSafe for ChildView<'a, ViewId>
where ViewId: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.