Struct druid::LayoutCtx

source ·
pub struct LayoutCtx<'a, 'b> { /* private fields */ }
Expand description

A context provided to layout-handling methods of widgets.

As of now, the main service provided is access to a factory for creating text layout objects, which are likely to be useful during widget layout.

Implementations§

get the WidgetId of the current widget.

Returns a reference to the current WindowHandle.

Get the WindowId of the current window.

Get an object which can create text layouts.

The current window’s Scale.

The returned Scale is a copy and thus its information will be stale after the platform changes the window’s scale. This means you can only rely on it until the next Event::WindowScale event happens.

Indicate that your ViewContext has changed.

This event is sent after layout is done and before paint is called. Note that you can still receive this event even if there was no prior call to layout.

Widgets must call this method after changing the clip region of their children. Changes to the other parts of ViewContext (cursor position and global origin) are tracked internally.

Submit a Command to be run after this event is handled.

Commands are run in the order they are submitted; all commands submitted during the handling of an event are executed before the update method is called; events submitted during update are handled after painting.

Target::Auto commands will be sent to the window containing the widget.

Returns an ExtEventSink that can be moved between threads, and can be used to submit commands back to the application.

Request a timer event.

The return value is a token, which can be used to associate the request with the event.

Set explicit paint Insets for this widget.

You are not required to set explicit paint bounds unless you need to paint outside of your layout bounds. In this case, the argument should be an Insets struct that indicates where your widget needs to overpaint, relative to its bounds.

For more information, see WidgetPod::paint_insets.

Set an explicit baseline position for this widget.

The baseline position is used to align widgets that contain text, such as buttons, labels, and other controls. It may also be used by other widgets that are opinionated about how they are aligned relative to neighbouring text, such as switches or checkboxes.

The provided value should be the distance from the bottom of the widget to the baseline.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

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

Calls U::from(self).

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

Performs the conversion.
Performs the conversion.
Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more