pub struct FocusBuilder { /* private fields */ }Expand description
Builder for the Focus.
Implementations§
Source§impl FocusBuilder
impl FocusBuilder
pub fn new(last: Option<Focus>) -> FocusBuilder
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 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 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) -> Self
pub fn enable_log(self) -> Self
Do some logging of the build.
Sourcepub fn widget(&mut self, widget: &dyn HasFocus) -> &mut Self
pub fn widget(&mut self, widget: &dyn HasFocus) -> &mut Self
Add a widget by calling its build function. The build function of the HasFocus trait can
The widget is added to all open containers.
Sourcepub fn widgets<const N: usize>(
&mut self,
widgets: [&dyn HasFocus; N],
) -> &mut Self
pub fn widgets<const N: usize>( &mut self, widgets: [&dyn HasFocus; N], ) -> &mut Self
Add a bunch of widget.
The widget is added to all open containers.
Sourcepub fn append_leaf(&mut self, widget: &dyn HasFocus) -> &mut Self
pub fn append_leaf(&mut self, widget: &dyn HasFocus) -> &mut Self
Directly add the given widget’s flags. Doesn’t call build() instead it uses focus(), etc. and appends a single widget.
Sourcepub fn append_flags(
&mut self,
focus: FocusFlag,
area: Rect,
area_z: u16,
navigable: Navigation,
)
pub fn append_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