pub trait PushTarget {
// Required methods
fn push_inner<PW: Widget>(
&self,
pa: &mut Pass,
widget: PW,
specs: PushSpecs,
) -> Handle<PW>;
fn push_outer<PW: Widget>(
&self,
pa: &mut Pass,
widget: PW,
specs: PushSpecs,
) -> Handle<PW>;
fn try_downcast<W: Widget>(&self) -> Option<Handle<W>>;
}Expand description
A target for pushing Widgets to
This can either be a Handle, which will push around a Widget
or a Window, which will push around the window.
This trait is useful if you wish to let your Widget both be
pushed around other Widgets and also around the window with the
Window. One example of this is the StatusLine widget,
which behaves differently depending on if it was pushed to a
Handle<Buffer>.
Required Methods§
Sourcefn push_inner<PW: Widget>(
&self,
pa: &mut Pass,
widget: PW,
specs: PushSpecs,
) -> Handle<PW>
fn push_inner<PW: Widget>( &self, pa: &mut Pass, widget: PW, specs: PushSpecs, ) -> Handle<PW>
Pushes a Widget around self
If self is a Handle, this will push around the
Handle’s own Area. If this is a Window,
this will push around the master Area of the central
region of buffers.
This Widget will be placed internally, i.e., around the
Area of self. This is in contrast to
Handle::push_outer_widget, which will push around the
“cluster master” of self.
A cluster master is the collection of every Widget that was
pushed around a central one with PushSpecs::cluster set to
true.
Both of these functions behave identically in the situation
where no other Widgets were pushed around self.
However, if, for example, a Widget was previously pushed
below self, when pushing to the left, the following would
happen:
╭────────────────╮ ╭─────┬──────────╮
│ │ │ │ │
│ self │ │ new │ self │
│ │ -> │ │ │
├────────────────┤ ├─────┴──────────┤
│ old │ │ old │
╰────────────────╯ ╰────────────────╯While in Handle::push_outer_widget, this happens instead:
╭────────────────╮ ╭─────┬──────────╮
│ │ │ │ │
│ self │ │ │ self │
│ │ -> │ new │ │
├────────────────┤ │ ├──────────┤
│ old │ │ │ old │
╰────────────────╯ ╰─────┴──────────╯Note that new was pushed around other clustered widgets in
the second case, not just around self.
Sourcefn push_outer<PW: Widget>(
&self,
pa: &mut Pass,
widget: PW,
specs: PushSpecs,
) -> Handle<PW>
fn push_outer<PW: Widget>( &self, pa: &mut Pass, widget: PW, specs: PushSpecs, ) -> Handle<PW>
Pushes a Widget around the “master region” of self
If self is a Handle, this will push its “cluster
master”. If this is a Window, this will push the
Widget to the edges of the window.
A cluster master is the collection of every Widget that was
pushed around a central one with PushSpecs::cluster set to
true.
This Widget will be placed externally, i.e., around every
other Widget that was pushed around self. This is in
contrast to Handle::push_inner_widget, which will push
only around self.
Both of these functions behave identically in the situation
where no other Widgets were pushed around self.
However, if, for example, a Widget was previously pushed
to the left of self, when pushing to the left again, the
following would happen:
╭──────┬──────────╮ ╭─────┬─────┬──────╮
│ │ │ │ │ │ │
│ │ │ │ │ │ │
│ old │ self │ -> │ new │ old │ self │
│ │ │ │ │ │ │
│ │ │ │ │ │ │
╰──────┴──────────╯ ╰─────┴─────┴──────╯While in Handle::push_inner_widget, this happens instead:
╭──────┬──────────╮ ╭─────┬─────┬──────╮
│ │ │ │ │ │ │
│ │ │ │ │ │ │
│ old │ self │ -> │ old │ new │ self │
│ │ │ │ │ │ │
│ │ │ │ │ │ │
╰──────┴──────────╯ ╰─────┴─────┴──────╯Note that new was pushed around other clustered widgets in
the first case, not just around self.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.