Skip to main content

Ui

Struct Ui 

Source
pub struct Ui<'a> {
Show 57 fields pub width: f32, pub height: f32, pub scale_factor: f32, pub mouse_x: f32, pub mouse_y: f32, pub mouse_down: bool, pub cursor_icon: CursorIcon, pub draws: Vec<DrawCommand>, pub overlays: Vec<DrawCommand>, pub cursor_x: f32, pub cursor_y: f32, pub base_x: f32, pub base_y: f32, pub direction: Direction, pub line_height: f32, pub child_sizes: Vec<(f32, f32)>, pub child_draw_ranges: Vec<(usize, usize)>, pub child_origins: Vec<(f32, f32)>, pub id_log: Vec<Id>, pub id_ranges: Vec<(usize, usize)>, pub last_w: f32, pub last_h: f32, pub max_x: f32, pub max_y: f32, pub offset_x: f32, pub offset_y: f32, pub font_system: Option<Arc<Mutex<FontSystem>>>, pub input_events: Vec<PlatformEvent>, pub focused_id: Option<Id>, pub id_counter: u64, pub scroll_state: &'a mut HashMap<Id, (f32, f32)>, pub cursor_state: &'a mut HashMap<Id, usize>, pub interaction_state: &'a mut HashMap<Id, f32>, pub active_drag: Option<ScrollDrag>, pub clicked: bool, pub right_clicked: bool, pub elapsed_time: f32, pub semantic_nodes: Vec<SemanticNode>, pub semantic_stack: Vec<Id>, pub render_mode_stack: Vec<RenderMode>, pub needs_redraw: bool, pub layout_cache: &'a HashMap<Id, (Rect, u64)>, pub next_layout_cache: &'a mut HashMap<Id, (Rect, u64)>, pub screen_layout_cache: &'a HashMap<Id, Rect>, pub next_screen_layout_cache: &'a mut HashMap<Id, Rect>, pub image_sizes: &'a HashMap<ImageSource, (u32, u32)>, pub available_width: f32, pub skip_clip_stack: Vec<bool>, pub current_viewport: Rect, pub window_overlays: Vec<(Id, Vec<DrawCommand>)>, pub current_window_id: Option<Id>, pub widget_window_map: &'a HashMap<Id, Id>, pub next_widget_window_map: &'a mut HashMap<Id, Id>, pub requested_redraw_at: Option<Instant>, pub event_listeners: HashMap<Id, Vec<EventHandler<'a>>>, pub window_actions: Vec<WindowAction>, pub active_overlay_stack: Vec<Id>,
}

Fields§

§width: f32§height: f32§scale_factor: f32§mouse_x: f32§mouse_y: f32§mouse_down: bool§cursor_icon: CursorIcon§draws: Vec<DrawCommand>§overlays: Vec<DrawCommand>§cursor_x: f32§cursor_y: f32§base_x: f32§base_y: f32§direction: Direction§line_height: f32§child_sizes: Vec<(f32, f32)>§child_draw_ranges: Vec<(usize, usize)>§child_origins: Vec<(f32, f32)>§id_log: Vec<Id>§id_ranges: Vec<(usize, usize)>§last_w: f32§last_h: f32§max_x: f32§max_y: f32§offset_x: f32§offset_y: f32§font_system: Option<Arc<Mutex<FontSystem>>>§input_events: Vec<PlatformEvent>§focused_id: Option<Id>§id_counter: u64§scroll_state: &'a mut HashMap<Id, (f32, f32)>§cursor_state: &'a mut HashMap<Id, usize>§interaction_state: &'a mut HashMap<Id, f32>§active_drag: Option<ScrollDrag>§clicked: bool§right_clicked: bool§elapsed_time: f32§semantic_nodes: Vec<SemanticNode>§semantic_stack: Vec<Id>§render_mode_stack: Vec<RenderMode>§needs_redraw: bool§layout_cache: &'a HashMap<Id, (Rect, u64)>§next_layout_cache: &'a mut HashMap<Id, (Rect, u64)>§screen_layout_cache: &'a HashMap<Id, Rect>§next_screen_layout_cache: &'a mut HashMap<Id, Rect>§image_sizes: &'a HashMap<ImageSource, (u32, u32)>§available_width: f32§skip_clip_stack: Vec<bool>§current_viewport: Rect§window_overlays: Vec<(Id, Vec<DrawCommand>)>§current_window_id: Option<Id>§widget_window_map: &'a HashMap<Id, Id>§next_widget_window_map: &'a mut HashMap<Id, Id>§requested_redraw_at: Option<Instant>§event_listeners: HashMap<Id, Vec<EventHandler<'a>>>§window_actions: Vec<WindowAction>§active_overlay_stack: Vec<Id>

Implementations§

Source§

impl<'a> Ui<'a>

Source

pub fn new( width: u32, height: u32, scale_factor: f64, font_system: Option<Arc<Mutex<FontSystem>>>, events: Vec<PlatformEvent>, initial_focused_id: Option<Id>, mouse_pos: (f32, f32), mouse_down: bool, scroll_state: &'a mut HashMap<Id, (f32, f32)>, cursor_state: &'a mut HashMap<Id, usize>, interaction_state: &'a mut HashMap<Id, f32>, active_drag: Option<ScrollDrag>, clicked: bool, right_clicked: bool, elapsed_time: f32, layout_cache: &'a HashMap<Id, (Rect, u64)>, next_layout_cache: &'a mut HashMap<Id, (Rect, u64)>, screen_layout_cache: &'a HashMap<Id, Rect>, next_screen_layout_cache: &'a mut HashMap<Id, Rect>, widget_window_map: &'a HashMap<Id, Id>, next_widget_window_map: &'a mut HashMap<Id, Id>, image_sizes: &'a HashMap<ImageSource, (u32, u32)>, ) -> Self

Source

pub fn request_redraw_at(&mut self, instant: Instant)

Source

pub fn add_listener<F>(&mut self, id: Id, phase: EventPhase, callback: F)
where F: FnMut(&mut EventContext, &WidgetEvent) + 'a,

Source

pub fn dispatch_event(&mut self, target_id: Id, event: WidgetEvent)

Source

pub fn request_redraw_after(&mut self, duration: Duration)

Source

pub fn id(&mut self) -> Id

Source

pub fn record_layout(&mut self, id: Id, rect: Rect)

Source

pub fn is_occluded(&self, id: Id, x: f32, y: f32) -> bool

Source

pub fn is_hovered( &self, id: Id, fallback_x: f32, fallback_y: f32, fallback_w: f32, fallback_h: f32, ) -> bool

Source

pub fn overlay<F>(&mut self, f: F)
where F: FnOnce(&mut Ui<'_>),

Source

pub fn get_recorded_layout(&self, id: Id) -> Option<(Rect, u64)>

Source

pub fn current_render_mode(&self) -> RenderMode

Source

pub fn request_redraw(&mut self)

Source

pub fn get_max_bounds(&self) -> (f32, f32)

Source

pub fn row(&mut self) -> ContainerBuilder<'_, 'a>

Source

pub fn column(&mut self) -> ContainerBuilder<'_, 'a>

Source

pub fn container(&mut self) -> ContainerBuilder<'_, 'a>

Source

pub fn lazy_container(&mut self) -> LazyContainerBuilder<'_, 'a>

Source

pub fn button(&mut self, label: &str) -> ButtonBuilder<'_, 'a>

Source

pub fn image(&mut self, source: ImageSource) -> ImageBuilder<'_, 'a>

Source

pub fn spacing(&mut self, size: f32)

Source

pub fn add_space(&mut self, h: f32)

Moves the cursor down by h pixels WITHOUT registering a layout child. Use this inside a lazy/virtual list to offset visible items below invisible ones.

Source

pub fn set_min_size(&mut self, w: f32, h: f32)

Registers an invisible zero-draw child with the given size. This forces the parent container’s layout engine to account for this size when calculating total content height for scroll area sizing.

Source

pub fn input<'b>( &mut self, buffer: &'b mut String, id: impl Hash, ) -> InputBuilder<'_, 'a, 'b>

Source

pub fn slider<'b>( &mut self, value: &'b mut f32, id: impl Hash, ) -> SliderBuilder<'_, 'a, 'b>

Source

pub fn progress_bar(&mut self, value: f32) -> ProgressBarBuilder<'_, 'a>

Source

pub fn checkbox<'b>( &mut self, value: &'b mut bool, label: &str, ) -> CheckboxBuilder<'_, 'a, 'b>

Source

pub fn toggle<'b>( &mut self, value: &'b mut bool, label: impl Into<Option<&'b str>>, ) -> ToggleBuilder<'_, 'a, 'b>

Source

pub fn radio<'b, T: PartialEq + Clone>( &mut self, state: &'b mut T, value: T, label: &str, ) -> RadioBuilder<'_, 'a, 'b, T>

Source

pub fn dropdown<'b, T: PartialEq + Clone + ToString>( &mut self, selected: &'b mut T, options: Vec<T>, ) -> DropdownBuilder<'_, 'a, 'b, T>

Source

pub fn text_area<'b>( &mut self, buffer: &'b mut String, id: impl Hash, ) -> TextAreaBuilder<'_, 'a, 'b>

Source

pub fn window<'b>( &mut self, title: &str, is_open: &'b mut bool, pos: &'b mut [f32; 2], ) -> FloatingWindowBuilder<'_, 'a, 'b>

Source

pub fn menu_bar(&mut self) -> MenuBarBuilder<'_, 'a>

Source

pub fn menu(&mut self, label: &str) -> MenuBuilder<'_, 'a>

Source

pub fn sub_menu(&mut self, label: &str) -> SubMenuBuilder<'_, 'a>

Source

pub fn menu_item(&mut self, label: &str) -> MenuItemBuilder<'_, 'a>

Source

pub fn register_semantic(&mut self, node: SemanticNode)

Registers a widget in the semantic tree.

Source

pub fn set_mouse(&mut self, x: f32, y: f32, down: bool)

Source

pub fn mouse_in_rect(&self, x: f32, y: f32, w: f32, h: f32) -> bool

Source

pub fn is_rect_visible(&self, rect: Rect) -> bool

Source

pub fn physical_clip(&self, x: f32, y: f32, w: f32, h: f32) -> [f32; 4]

Converts a logical [x, y, w, h] rect to physical pixels for GPU clipping.

Source

pub fn advance(&mut self, w: f32, h: f32, draw_start: usize)

Called by widgets after pushing their draws. Records draw range and advances cursor.

Source

pub fn text(&mut self, content: &str) -> TextBuilder<'_, 'a>

Source

pub fn h1(&mut self, content: &str) -> TextBuilder<'_, 'a>

Source

pub fn h2(&mut self, content: &str) -> TextBuilder<'_, 'a>

Source

pub fn h3(&mut self, content: &str) -> TextBuilder<'_, 'a>

Source

pub fn h4(&mut self, content: &str) -> TextBuilder<'_, 'a>

Source

pub fn card(&mut self) -> CardBuilder<'_, 'a>

Source

pub fn panel<'b>(&mut self) -> PanelBuilder<'_, 'a, 'b>

Source

pub fn card_header<F>(&mut self, title: &str, subtitle: &str, actions: F)
where F: FnOnce(&mut Ui<'_>),

Source

pub fn card_divider(&mut self)

Source

pub fn stack(&mut self) -> StackBuilder<'_, 'a>

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Ui<'a>

§

impl<'a> !Send for Ui<'a>

§

impl<'a> !Sync for Ui<'a>

§

impl<'a> !UnwindSafe for Ui<'a>

§

impl<'a> Freeze for Ui<'a>

§

impl<'a> Unpin for Ui<'a>

§

impl<'a> UnsafeUnpin for Ui<'a>

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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