Skip to main content

CaptionButtons

Struct CaptionButtons 

Source
pub struct CaptionButtons { /* private fields */ }
Expand description

The caption buttons over the trailing end of a title bar, above any dialog, or nothing where the system draws them. Render it once per window, as a child of the root; a super::TitleBar renders its own, so a window with one needs no other.

CaptionButtons::preview instead draws them in place, e.g. in a catalog page: inert, in the page’s flow, never over the real title bar.

Implementations§

Source§

impl CaptionButtons

Source

pub fn new(height: Pixels, labels: CaptionLabels) -> Self

Buttons for a title bar height tall, announced with labels.

Source

pub fn preview(self, id: impl Into<ElementId>) -> Self

Draw the buttons inline, where the parent lays them out, instead of pinning them to the window’s top-right corner above every dialog. A preview shows minimize, maximize and close for its caption style (nothing for Caption::System) and keeps the hover and press states, but its buttons are not window control areas and do not act on the window. id keeps several previews in one window apart.

Source

pub fn labels(self, labels: CaptionLabels) -> Self

Source

pub fn caption(self, caption: Caption) -> Self

Force a caption style instead of detecting it, e.g. for screenshots.

Source

pub fn on_close( self, request: impl Fn(&mut Window, &mut App) -> bool + 'static, ) -> Self

Asked before the Linux close button removes the window; return false to keep it (e.g. to save first). Windows routes close through the system, which the application observes as a window close.

Source

pub fn width(window: &Window) -> f32

The width the buttons take from the title bar’s trailing edge.

Source

pub fn trailing(window: &Window) -> f32

Where the title bar’s own content should end: before the buttons with a little open space, or a 16px inset where the system draws them.

Trait Implementations§

Source§

impl IntoElement for CaptionButtons

Source§

type Element = ViewElement<CaptionButtons>

The specific type of element into which the implementing type is converted. Useful for converting other types into elements automatically, like Strings
Source§

fn into_element(self) -> Self::Element

Convert self into a type that implements [Element].
Source§

fn into_any_element(self) -> AnyElement

Convert self into a dynamically-typed [AnyElement].
Source§

impl RenderOnce for CaptionButtons

Source§

fn render(self, window: &mut Window, _: &mut App) -> impl IntoElement

Render this component into an element tree. Note that this method takes ownership of self, as compared to [Render::render()] method which takes a mutable reference.

Auto Trait Implementations§

Blanket Implementations§

§

impl<E> AnimationExt for E
where E: IntoElement + 'static,

§

fn with_animation( self, id: impl Into<ElementId>, animation: Animation, animator: impl Fn(Self, f32) -> Self + 'static, ) -> AnimationElement<Self>
where Self: Sized,

Render this component or element with an animation
§

fn with_animations( self, id: impl Into<ElementId>, animations: Vec<Animation>, animator: impl Fn(Self, usize, f32) -> Self + 'static, ) -> AnimationElement<Self>
where Self: Sized,

Render this component or element with a chain of animations
§

fn with_spring<T>( self, id: impl Into<ElementId>, animation: SpringAnimation<T>, animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static, ) -> SpringAnimationElement<Self>
where Self: Sized, T: SpringTarget, <T as SpringTarget>::Output: 'static,

Renders this component or element at the value produced by a spring. Read more
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,

Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> FluentBuilder for T
where T: IntoElement,

§

fn map<U>(self, f: impl FnOnce(Self) -> U) -> U
where Self: Sized,

Imperatively modify self with the given closure.
§

fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
where Self: Sized,

Conditionally modify self with the given closure.
§

fn when_else( self, condition: bool, then: impl FnOnce(Self) -> Self, else_fn: impl FnOnce(Self) -> Self, ) -> Self
where Self: Sized,

Conditionally modify self with the given closure.
§

fn when_some<T>( self, option: Option<T>, then: impl FnOnce(Self, T) -> Self, ) -> Self
where Self: Sized,

Conditionally unwrap and modify self with the given closure, if the given option is Some.
§

fn when_none<T>( self, option: &Option<T>, then: impl FnOnce(Self) -> Self, ) -> Self
where Self: Sized,

Conditionally unwrap and modify self with the given closure, if the given option is None.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<E> TestTextExt for E
where E: IntoElement,

§

fn test_text(self, text: impl Into<SharedString>) -> Self::Element

With test-support, records text each time the element paints. Otherwise returns the element it builds.
§

fn test_alt_text(self, text: impl Into<SharedString>) -> Self::Element

Like [Self::test_text] for an image’s alternative text, which stands in for what the element draws.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> View for T
where T: RenderOnce,

§

fn entity_id(&self) -> Option<EntityId>

This view’s identity, if it has one. A view typically holds the backing entity as a field and returns its [EntityId] here. Read more
§

fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement

Render this view into an element tree, consuming self.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more