Skip to main content

Window

Struct Window 

Source
pub struct Window {
    pub style: Style,
    pub header_color: Color,
    pub title_color: Color,
    pub button_color: Color,
    pub button_text_color: Color,
    /* private fields */
}
Expand description

Title-bar + content-area window widget (LVGL win parity).

Create with Window::new, set the title with Window::set_title, add optional header buttons with Window::add_header_button, and query geometry via Window::header_bounds and Window::content_bounds.

Fields§

§style: Style

Overall window background style (Part::MAIN).

§header_color: Color

Background color for the header bar.

§title_color: Color

Header title text color.

§button_color: Color

Header button background color (Part::ITEMS).

§button_text_color: Color

Header button icon text color.

Implementations§

Source§

impl Window

Source

pub fn new(bounds: Rect, header_height: i32) -> Window

Create a window with the given outer bounds and header height.

Use DEFAULT_HEADER_HEIGHT when no specific height is needed.

Source

pub fn set_title(&mut self, text: &str)

Set the window title displayed in the header bar.

Source

pub fn title(&self) -> &str

Return the current window title.

Source

pub fn add_header_button( &mut self, icon: Option<&str>, width: i32, ) -> WindowButtonId

Append an icon button to the header bar and return its WindowButtonId.

icon is an optional UTF-8 glyph or short string drawn inside the button. width is the button width in pixels.

Source

pub fn last_button_pressed(&mut self) -> Option<WindowButtonId>

Return and clear the most recently activated header button id.

Returns None when no button was pressed since the last poll.

Source

pub fn header_bounds(&self) -> Rect

Return the screen-space rect of the header bar.

Source

pub fn content_bounds(&self) -> Rect

Return the screen-space rect of the content area (below the header).

Source

pub fn set_font(&mut self, font: &'static dyn FontMetrics)

Assign the font used to render this widget (FONT-00 §5); resolves to FONT_6X10 when unset.

Source

pub fn set_header_height(&mut self, h: i32)

Update the header height and recompute content bounds.

Trait Implementations§

Source§

impl StyleProps for Window

Source§

fn style_mut(&mut self) -> &mut Style

Return the mutable style used by this widget’s main visual part.
Source§

fn with_style(self, style: Style) -> Self

Replace the complete main style.
Source§

fn bg(self, color: Color) -> Self

Set the background color.
Source§

fn bg_color(self, color: Color) -> Self

Set the background color.
Source§

fn border_color(self, color: Color) -> Self

Set the border color.
Source§

fn border_width(self, width: u8) -> Self

Set the border width in pixels.
Source§

fn radius(self, radius: u8) -> Self

Set the corner radius in pixels.
Source§

fn rounded(self, radius: u8) -> Self

Set the corner radius in pixels.
Source§

fn opacity(self, alpha: u8) -> Self

Set widget opacity as 0..=255.
Source§

fn alpha(self, alpha: u8) -> Self

Set widget opacity as 0..=255.
Source§

impl ThemedPartsProps for Window

Source§

fn themed_parts( self, theme: &Theme, scheme: ColorScheme, variant: Variant, size: ComponentSize, ) -> Self

Apply the theme to the main style and direct widget-specific part colors.
Source§

impl Widget for Window

Source§

fn bounds(&self) -> Rect

Return the area this widget occupies relative to its parent.
Source§

fn widget_font_mut(&mut self) -> Option<&mut WidgetFont>

Expose this widget’s font slot for cascade-driven font resolution (FONT-05 §5.B). Read more
Source§

fn set_bounds(&mut self, bounds: Rect)

Called by the LPAR-10 layout pass to notify this widget of its layout-computed bounds. Read more
Source§

fn draw(&self, renderer: &mut dyn Renderer)

Render the widget using the provided Renderer.
Source§

fn handle_event(&mut self, _event: &Event) -> bool

Handle an event and return true if it was consumed. Read more
Source§

fn clear_region(&mut self) -> Option<Rect>

Return a region (in draw/landscape coordinates) that should be restored from the pristine background copy, or None. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Window

§

impl !Send for Window

§

impl !Sync for Window

§

impl !UnwindSafe for Window

§

impl Freeze for Window

§

impl Unpin for Window

§

impl UnsafeUnpin for Window

Blanket Implementations§

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

impl<T> BoundsProps for T
where T: Widget,

Source§

fn bounds(self, bounds: Rect) -> Self

Apply a new bounding rectangle and return the widget.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ThemeProps for T
where T: StyleProps,

Source§

fn themed( self, theme: &Theme, scheme: ColorScheme, variant: Variant, size: ComponentSize, ) -> Self

Apply a complete themed style.
Source§

fn variant(self, theme: &Theme, scheme: ColorScheme, variant: Variant) -> Self

Apply a themed variant with medium sizing.
Source§

fn component_size(self, theme: &Theme, size: ComponentSize) -> Self

Apply only the sizing-affecting style fields.
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.