Skip to main content

Layout

Trait Layout 

Source
pub trait Layout: Widget + Sized {
Show 24 methods // Provided methods fn size(self, w: i32, h: i32) -> Self { ... } fn width(self, w: i32) -> Self { ... } fn height(self, h: i32) -> Self { ... } fn pos(self, x: i32, y: i32) -> Self { ... } fn center(self) -> Self { ... } fn align(self, a: u8, x_ofs: i32, y_ofs: i32) -> Self { ... } fn hide(self) -> Self { ... } fn show(self) -> Self { ... } fn visible(self, v: bool) -> Self { ... } fn add_flag(self, f: u32) -> Self { ... } fn remove_flag(self, f: u32) -> Self { ... } fn add_state(self, s: u32) -> Self { ... } fn remove_state(self, s: u32) -> Self { ... } fn clickable(self, on: bool) -> Self { ... } fn grid_dsc(self, cols: &'static [i32], rows: &'static [i32]) -> Self { ... } fn grid_cell( self, col_align: u32, col_pos: i32, col_span: i32, row_align: u32, row_pos: i32, row_span: i32, ) -> Self { ... } fn flex_flow(self, flow: FlexFlow) -> Self { ... } fn flex_align( self, main: FlexAlign, cross: FlexAlign, track: FlexAlign, ) -> Self { ... } fn flex_grow(self, grow: u8) -> Self { ... } fn layout(self, kind: LayoutKind) -> Self { ... } fn scroll_to_y(self, y: i32, anim: bool) -> Self { ... } fn update_layout(self) -> Self { ... } fn content_width(self) -> i32 { ... } fn scroll_bottom(self) -> i32 { ... }
}
Expand description

Fluent positioning, sizing, and flag manipulation. Blanket-implemented for all Widget types.

Provided Methods§

Source

fn size(self, w: i32, h: i32) -> Self

Set both width and height of the widget in pixels.

Source

fn width(self, w: i32) -> Self

Set the width of the widget in pixels.

Source

fn height(self, h: i32) -> Self

Set the height of the widget in pixels.

Source

fn pos(self, x: i32, y: i32) -> Self

Set the position of the widget relative to its parent’s top-left corner.

Source

fn center(self) -> Self

Center the widget within its parent.

Source

fn align(self, a: u8, x_ofs: i32, y_ofs: i32) -> Self

Align the widget using an LVGL alignment constant and pixel offsets.

a must be one of the ALIGN_* constants (e.g. ALIGN_CENTER).

Source

fn hide(self) -> Self

Hide the widget by setting LV_OBJ_FLAG_HIDDEN.

Source

fn show(self) -> Self

Make the widget visible by removing LV_OBJ_FLAG_HIDDEN.

Source

fn visible(self, v: bool) -> Self

Show or hide the widget. Equivalent to calling show or hide.

Source

fn add_flag(self, f: u32) -> Self

Add one or more LVGL object flags (bitwise OR of LV_OBJ_FLAG_* values).

Source

fn remove_flag(self, f: u32) -> Self

Remove one or more LVGL object flags.

Source

fn add_state(self, s: u32) -> Self

Add one or more LVGL object state bits (e.g. LV_STATE_CHECKED).

Source

fn remove_state(self, s: u32) -> Self

Remove one or more LVGL object state bits.

Source

fn clickable(self, on: bool) -> Self

Enable or disable click events on the widget.

Source

fn grid_dsc(self, cols: &'static [i32], rows: &'static [i32]) -> Self

Configure this widget as a grid container.

Both arrays must terminate with GRID_TEMPLATE_LAST. Track sizes can be fixed pixel values, GRID_CONTENT, or grid_fr for fractional units. Switches the widget’s layout to grid mode.

§Safety

The caller must ensure cols and rows outlive the widget, since LVGL retains the pointer rather than copying. 'static slices are the typical choice.

Source

fn grid_cell( self, col_align: u32, col_pos: i32, col_span: i32, row_align: u32, row_pos: i32, row_span: i32, ) -> Self

Place this widget into a cell of its parent grid.

Source

fn flex_flow(self, flow: FlexFlow) -> Self

Configure this widget as a flex container with the given main-axis flow.

Source

fn flex_align(self, main: FlexAlign, cross: FlexAlign, track: FlexAlign) -> Self

Set flex container alignment along the main, cross (per item), and cross (per track) axes. Equivalent to lv_obj_set_flex_align.

Source

fn flex_grow(self, grow: u8) -> Self

Set this child’s flex grow factor (0 disables growing).

Source

fn layout(self, kind: LayoutKind) -> Self

Switch the widget’s layout engine (None / Flex / Grid).

Source

fn scroll_to_y(self, y: i32, anim: bool) -> Self

Scroll the widget so the given Y coordinate is visible. anim enables animation.

Source

fn update_layout(self) -> Self

Force layout recomputation immediately (for queries that need live values).

Source

fn content_width(self) -> i32

Width of the inner content area (excludes paddings/scrollbars).

Source

fn scroll_bottom(self) -> i32

Distance the widget can still scroll towards its bottom edge.

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.

Implementors§

Source§

impl<T: Widget> Layout for T