pub struct ViewRegistration<'a, ViewId, const N: usize> { /* private fields */ }Expand description
Mutable registration object passed to crate::UiView::configure.
Implementations§
Source§impl<'a, ViewId, const N: usize> ViewRegistration<'a, ViewId, N>
impl<'a, ViewId, const N: usize> ViewRegistration<'a, ViewId, N>
Sourcepub fn new(frame: Rectangle) -> Self
pub fn new(frame: Rectangle) -> Self
Creates a registration rooted at the given frame.
Examples found in repository?
src/system.rs (line 30)
29 pub fn new(display: Display, root: Root, theme: FsTheme, i18n: I18n<'text>) -> Self {
30 let registration = ViewRegistration::new(display.bounds());
31 let mut system = Self {
32 display,
33 root,
34 theme,
35 i18n,
36 registration,
37 marker: PhantomData,
38 };
39 system.configure_root();
40 system
41 }Sourcepub const fn frame(&self) -> Rectangle
pub const fn frame(&self) -> Rectangle
Returns the current root frame for the view.
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 }
32
33 fn handle_touch(
34 &mut self,
35 _touch: TouchEvent,
36 _registration: &ViewRegistration<'static, RootId, 1>,
37 _env: &ViewEnvironment<'_, 'static>,
38 ) -> ViewEvent<()> {
39 ViewEvent::redraw(ViewRedraw::Full)
40 }
41
42 fn draw<D>(
43 &self,
44 display: &mut D,
45 registration: &ViewRegistration<'static, RootId, 1>,
46 _env: &ViewEnvironment<'_, 'static>,
47 ) where
48 D: DrawTarget<Color = Rgb565>,
49 {
50 registration
51 .frame()
52 .into_styled(PrimitiveStyle::with_fill(Rgb565::new(31, 63, 31)))
53 .draw(display)
54 .ok();
55 }More examples
examples/uikit_root.rs (line 45)
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 }Sourcepub const fn properties(&self) -> &ViewProperties<'a>
pub const fn properties(&self) -> &ViewProperties<'a>
Returns the accumulated properties for the registered view.
Sourcepub fn set_title(&mut self, title: Localized<'a>)
pub fn set_title(&mut self, title: Localized<'a>)
Sets the view title.
Examples found in repository?
examples/uikit_root.rs (line 43)
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 }Marks the registered view as hidden or visible.
Sourcepub fn set_clips_to_bounds(&mut self, clips_to_bounds: bool)
pub fn set_clips_to_bounds(&mut self, clips_to_bounds: bool)
Enables or disables clipping to bounds.
Examples found in repository?
examples/uikit_root.rs (line 44)
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 }Sourcepub fn set_user_interaction_enabled(&mut self, enabled: bool)
pub fn set_user_interaction_enabled(&mut self, enabled: bool)
Enables or disables touch handling for the view.
Sourcepub fn clear_children(&mut self)
pub fn clear_children(&mut self)
Removes all previously registered child views.
Sourcepub fn add_child(
&mut self,
child: ChildView<'a, ViewId>,
) -> Result<(), ChildView<'a, ViewId>>
pub fn add_child( &mut self, child: ChildView<'a, ViewId>, ) -> Result<(), ChildView<'a, ViewId>>
Registers one child view.
Examples found in repository?
More examples
examples/uikit_root.rs (lines 46-50)
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 }Sourcepub fn children(&self) -> &[ChildView<'a, ViewId>]
pub fn children(&self) -> &[ChildView<'a, ViewId>]
Returns the registered children as a slice.
Examples found in repository?
examples/uikit_root.rs (line 68)
62 fn update(
63 &mut self,
64 dt_ms: u32,
65 registration: &ViewRegistration<'static, DemoViewId, 2>,
66 _env: &ViewEnvironment<'_, 'static>,
67 ) -> ViewEvent<DemoMessage> {
68 let list = registration.children()[0].frame;
69 ViewEvent::redraw(self.list.tick(dt_ms, list))
70 }
71
72 fn handle_touch(
73 &mut self,
74 touch: TouchEvent,
75 registration: &ViewRegistration<'static, DemoViewId, 2>,
76 _env: &ViewEnvironment<'_, 'static>,
77 ) -> ViewEvent<DemoMessage> {
78 self.list
79 .handle_touch(touch, registration.children()[0].frame)
80 .into_view_event()
81 }
82
83 fn draw<D>(
84 &self,
85 display: &mut D,
86 registration: &ViewRegistration<'static, DemoViewId, 2>,
87 env: &ViewEnvironment<'_, 'static>,
88 ) where
89 D: DrawTarget<Color = Rgb565>,
90 {
91 self.list
92 .draw(display, registration.children()[0].frame, env);
93 }Trait Implementations§
Source§impl<'a, ViewId: Clone, const N: usize> Clone for ViewRegistration<'a, ViewId, N>
impl<'a, ViewId: Clone, const N: usize> Clone for ViewRegistration<'a, ViewId, N>
Source§fn clone(&self) -> ViewRegistration<'a, ViewId, N>
fn clone(&self) -> ViewRegistration<'a, ViewId, N>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'a, ViewId: PartialEq, const N: usize> PartialEq for ViewRegistration<'a, ViewId, N>
impl<'a, ViewId: PartialEq, const N: usize> PartialEq for ViewRegistration<'a, ViewId, N>
Source§fn eq(&self, other: &ViewRegistration<'a, ViewId, N>) -> bool
fn eq(&self, other: &ViewRegistration<'a, ViewId, N>) -> bool
Tests for
self and other values to be equal, and is used by ==.impl<'a, ViewId: Eq, const N: usize> Eq for ViewRegistration<'a, ViewId, N>
impl<'a, ViewId, const N: usize> StructuralPartialEq for ViewRegistration<'a, ViewId, N>
Auto Trait Implementations§
impl<'a, ViewId, const N: usize> Freeze for ViewRegistration<'a, ViewId, N>where
ViewId: Freeze,
impl<'a, ViewId, const N: usize> RefUnwindSafe for ViewRegistration<'a, ViewId, N>where
ViewId: RefUnwindSafe,
impl<'a, ViewId, const N: usize> Send for ViewRegistration<'a, ViewId, N>where
ViewId: Send,
impl<'a, ViewId, const N: usize> Sync for ViewRegistration<'a, ViewId, N>where
ViewId: Sync,
impl<'a, ViewId, const N: usize> Unpin for ViewRegistration<'a, ViewId, N>where
ViewId: Unpin,
impl<'a, ViewId, const N: usize> UnsafeUnpin for ViewRegistration<'a, ViewId, N>where
ViewId: UnsafeUnpin,
impl<'a, ViewId, const N: usize> UnwindSafe for ViewRegistration<'a, ViewId, N>where
ViewId: UnwindSafe,
Blanket Implementations§
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
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Casts the value.
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
Source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
Source§fn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
Source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
Source§fn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.