pub struct PopupCore<'a> {
pub style: Style,
pub constraint: Cell<PopupConstraint>,
pub offset: (i16, i16),
pub boundary_area: Option<Rect>,
pub block: Option<Block<'a>>,
pub h_scroll: Option<Scroll<'a>>,
pub v_scroll: Option<Scroll<'a>>,
pub non_exhaustive: NonExhaustive,
}Expand description
Provides the core for popup widgets.
This widget can calculate the placement of a popup widget using placement, offset and the outer boundary.
It provides the widget area as area.
After rendering the PopupCore the main widget can render it’s content in the calculated PopupCoreState::area.
§Event handling
Will detect any mouse-clicks outside its area and return PopupOutcome::Hide. Actually showing/hiding the popup is the job of the main widget.
See See the examples some variants.
Fields§
§style: Styleconstraint: Cell<PopupConstraint>Constraints for the popup.
offset: (i16, i16)Extra offset after calculating the position with constraint.
boundary_area: Option<Rect>Outer boundary for the popup-placement. If not set uses the buffer-area.
block: Option<Block<'a>>h_scroll: Option<Scroll<'a>>v_scroll: Option<Scroll<'a>>non_exhaustive: NonExhaustiveImplementations§
Source§impl<'a> PopupCore<'a>
impl<'a> PopupCore<'a>
Sourcepub fn ref_constraint(&self, constraint: PopupConstraint) -> &PopupCore<'a>
pub fn ref_constraint(&self, constraint: PopupConstraint) -> &PopupCore<'a>
Placement constraints for the popup widget.
Sourcepub fn constraint(self, constraint: PopupConstraint) -> PopupCore<'a>
pub fn constraint(self, constraint: PopupConstraint) -> PopupCore<'a>
Placement constraints for the popup widget.
Sourcepub fn offset(self, offset: (i16, i16)) -> PopupCore<'a>
pub fn offset(self, offset: (i16, i16)) -> PopupCore<'a>
Adds an extra offset to the widget area.
This can be used to
- place the widget under the mouse cursor.
- align the widget not by the outer bounds but by the text content.
Sourcepub fn boundary(self, boundary: Rect) -> PopupCore<'a>
pub fn boundary(self, boundary: Rect) -> PopupCore<'a>
Sets outer boundaries for the popup widget.
This will be used to ensure that the popup widget is fully visible. First it tries to move the popup in a way that is fully inside this area. If this is not enought the popup area will be clipped.
If this is not set, Buffer::area will be used instead.
Sourcepub fn styles(self, styles: PopupStyle) -> PopupCore<'a>
pub fn styles(self, styles: PopupStyle) -> PopupCore<'a>
Set styles
Sourcepub fn style(self, style: Style) -> PopupCore<'a>
👎Deprecated since 1.2.0: job for the main widget
pub fn style(self, style: Style) -> PopupCore<'a>
Base style for the popup.
Sourcepub fn block(self, block: Block<'a>) -> PopupCore<'a>
👎Deprecated since 1.2.0: job for the main widget
pub fn block(self, block: Block<'a>) -> PopupCore<'a>
Block
Sourcepub fn block_opt(self, block: Option<Block<'a>>) -> PopupCore<'a>
👎Deprecated since 1.2.0: job for the main widget
pub fn block_opt(self, block: Option<Block<'a>>) -> PopupCore<'a>
Block
Sourcepub fn h_scroll(self, h_scroll: Scroll<'a>) -> PopupCore<'a>
👎Deprecated since 1.2.0: job for the main widget
pub fn h_scroll(self, h_scroll: Scroll<'a>) -> PopupCore<'a>
Horizontal scroll
Sourcepub fn h_scroll_opt(self, h_scroll: Option<Scroll<'a>>) -> PopupCore<'a>
👎Deprecated since 1.2.0: job for the main widget
pub fn h_scroll_opt(self, h_scroll: Option<Scroll<'a>>) -> PopupCore<'a>
Horizontal scroll
Sourcepub fn v_scroll(self, v_scroll: Scroll<'a>) -> PopupCore<'a>
👎Deprecated since 1.2.0: job for the main widget
pub fn v_scroll(self, v_scroll: Scroll<'a>) -> PopupCore<'a>
Vertical scroll
Sourcepub fn v_scroll_opt(self, v_scroll: Option<Scroll<'a>>) -> PopupCore<'a>
👎Deprecated since 1.2.0: job for the main widget
pub fn v_scroll_opt(self, v_scroll: Option<Scroll<'a>>) -> PopupCore<'a>
Vertical scroll
Sourcepub fn get_block_size(&self) -> Size
👎Deprecated since 1.2.0: job for the main widget
pub fn get_block_size(&self) -> Size
Get the padding the block imposes as Size.
Sourcepub fn get_block_padding(&self) -> Padding
👎Deprecated since 1.2.0: job for the main widget
pub fn get_block_padding(&self) -> Padding
Get the padding the block imposes as Padding.
Trait Implementations§
Source§impl<'a> StatefulWidget for &'a PopupCore<'a>
impl<'a> StatefulWidget for &'a PopupCore<'a>
Source§type State = PopupCoreState
type State = PopupCoreState
Source§impl StatefulWidget for PopupCore<'_>
impl StatefulWidget for PopupCore<'_>
Source§type State = PopupCoreState
type State = PopupCoreState
Auto Trait Implementations§
impl<'a> !Freeze for PopupCore<'a>
impl<'a> !RefUnwindSafe for PopupCore<'a>
impl<'a> Send for PopupCore<'a>
impl<'a> !Sync for PopupCore<'a>
impl<'a> Unpin for PopupCore<'a>
impl<'a> UnwindSafe for PopupCore<'a>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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