pub struct FocusBuilder { /* private fields */ }Expand description
Builder for the Focus.
Implementations§
Source§impl FocusBuilder
impl FocusBuilder
Sourcepub fn new(last: Option<Focus>) -> FocusBuilder
pub fn new(last: Option<Focus>) -> FocusBuilder
Create a new FocusBuilder.
This can take the previous Focus and ensures that widgets that are no longer part of the focus list have their focus-flag cleared.
It will also recycle the storage of the old Focus.
Sourcepub fn log_build_for(container: &dyn HasFocus) -> Focus
pub fn log_build_for(container: &dyn HasFocus) -> Focus
The same as build_for but with logs enabled.
Sourcepub fn build_for(container: &dyn HasFocus) -> Focus
pub fn build_for(container: &dyn HasFocus) -> Focus
Shortcut for building the focus for a container that implements HasFocus.
This creates a fresh Focus.
See
Use rebuild_for if you want to ensure that widgets that are no longer in the widget structure have their focus flag reset properly. If you don’t have some logic to conditionally add widgets to the focus, this function is probably fine.
Sourcepub fn log_rebuild_for(container: &dyn HasFocus, old: Option<Focus>) -> Focus
pub fn log_rebuild_for(container: &dyn HasFocus, old: Option<Focus>) -> Focus
The same as rebuild_for but with logs enabled.
Sourcepub fn rebuild_for(container: &dyn HasFocus, old: Option<Focus>) -> Focus
pub fn rebuild_for(container: &dyn HasFocus, old: Option<Focus>) -> Focus
Shortcut function for building the focus for a container that implements HasFocus
This takes the old Focus and reuses most of its allocations. It also ensures that any widgets no longer in the widget structure have their focus-flags reset.
Sourcepub fn enable_log(&self)
pub fn enable_log(&self)
Do some logging of the build.
Sourcepub fn disable_log(&self)
pub fn disable_log(&self)
Do some logging of the build.
Sourcepub fn enable_panic(&self)
pub fn enable_panic(&self)
Enable insta-panic for certain failures.
Sourcepub fn disable_panic(&self)
pub fn disable_panic(&self)
Disable insta-panic for certain failures.
Sourcepub fn widget(&mut self, widget: &dyn HasFocus) -> &mut FocusBuilder
pub fn widget(&mut self, widget: &dyn HasFocus) -> &mut FocusBuilder
Add a widget by calling its build function.
Add a widget by calling its build function.
This tries to override the default navigation for the given widget. This will fail if the widget is a container. It may also fail for other reasons. Depends on the widget.
Enable log to check.
Sourcepub fn widgets<const N: usize>(
&mut self,
widgets: [&dyn HasFocus; N],
) -> &mut FocusBuilder
pub fn widgets<const N: usize>( &mut self, widgets: [&dyn HasFocus; N], ) -> &mut FocusBuilder
Add a bunch of widgets.
Sourcepub fn leaf_widget(&mut self, widget: &dyn HasFocus) -> &mut FocusBuilder
pub fn leaf_widget(&mut self, widget: &dyn HasFocus) -> &mut FocusBuilder
Directly add the given widget’s flags. Doesn’t call build() instead it uses focus(), etc. and appends a single widget.
This is intended to be used when implementing HasFocus::build() for a widget.
In all other situations it’s better to use widget().
Panic
Panics if the same focus-flag is added twice.
Sourcepub fn widget_with_flags(
&mut self,
focus: FocusFlag,
area: Rect,
area_z: u16,
navigable: Navigation,
)
pub fn widget_with_flags( &mut self, focus: FocusFlag, area: Rect, area_z: u16, navigable: Navigation, )
Manually add a widgets flags.
This is intended to be used when implementing HasFocus::build() for a widget.
In all other situations it’s better to use widget().
Panic
Panics if the same focus-flag is added twice. Except it is allowable to add the flag a second time with Navigation::Mouse or Navigation::None
Trait Implementations§
Source§impl Debug for FocusBuilder
impl Debug for FocusBuilder
Source§impl Default for FocusBuilder
impl Default for FocusBuilder
Source§fn default() -> FocusBuilder
fn default() -> FocusBuilder
Auto Trait Implementations§
impl !Freeze for FocusBuilder
impl !RefUnwindSafe for FocusBuilder
impl !Send for FocusBuilder
impl !Sync for FocusBuilder
impl Unpin for FocusBuilder
impl !UnwindSafe for FocusBuilder
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more