Struct immi::DrawContext [] [src]

pub struct DrawContext<'b, D: ?Sized + Draw + 'b> { /* fields omitted */ }

Contains everything required to draw a widget.

Methods

impl<'b, D: ?Sized + Draw + 'b> DrawContext<'b, D>
[src]

Returns a matrix that turns a fullscreen rectangle into a rectangle that covers only the context's area.

Returns true if the cursor went from up to down in the current frame.

This is the value that was passed when constructing the context.

Returns true if the cursor went from down to up in the current frame.

This is the value that was passed when constructing the context.

Returns true if one of the elements that has been drawn is under the mouse cursor.

When you create the context, this value is initally false. Each widget that you draw can call set_cursor_hovered_widget to pass this value to true.

Signals the context that the cursor is currently hovering it. This can be later retreived with cursor_hovered_widget().

Reserves a new ID for a widget. Calling this function multiple times always returns a different id.

Returns true if the cursor is currently hovering this part of the viewport.

This is equivalent to cursor_hover_coordinates().is_some(), except more optimized.

If the cursor is hovering the context, returns the coordinates of the cursor within the context.

The result is in OpenGL-like coordinates. In other words, (-1,-1) is the bottom-left hand corner and (1,1) is the top-right hand corner.

Returns the ratio of the width of the surface divided by its height.

Builds a new draw context containing a subarea of the current context, but with a margin.

The margin is expressed in percentage of the surface (between 0.0 and 1.0).

Builds a new draw context containing a subarea of the current context, but with a margin.

If the width of the surface is inferior to the height then the margin is expressed as a percentage of the width, and vice versa.

This guarantees that the size in pixels of the margin is the same if you pass the same values.

Modifies the layout so that the given width per height ratio is respected. The size of the new viewport will always been equal or small to the existing viewport.

If the viewport needs to be reduced horizontally, then the horizontal alignment is used. If it needs to be reduced vertically, then the vertical alignment is used.

Modifies the layout so that the given width per height ratio is respected. The size of the new viewport will always been equal or greater to the existing viewport.

If the viewport needs to be increased horizontally, then the horizontal alignment is used. If it needs to be increased vertically, then the vertical alignment is used.

Builds a new draw context containing a subarea of the current context. The width of the new viewport will be the same as the current one, but its new height will be multipled by the value of scale.

The alignment is used to determine the position of the new viewport inside the old one.

Builds a new draw context containing a subarea of the current context. The height of the new viewport will be the same as the current one, but its new width will be multipled by the value of scale.

The alignment is used to determine the position of the new viewport inside the old one.

Splits the viewport in splits vertical chunks of equal size.

Same as vertical_split, but attributes a weight to each chunk. For example a chunk of weight 2 will have twice the size of a chunk of weight 1.

Splits the viewport in splits horizontal chunks of equal size.

Same as horizontal_split, but attributes a weight to each chunk. For example a chunk of weight 2 will have twice the size of a chunk of weight 1.

Changes the dimensions of the context.

The dimensions are a percentage of the current dimensions. For example to divide the width by two, you need to pass 0.5.

The alignment is used to determine the position of the newly-created context relative to the old one.

Starts an animation. The interpolation, start time and duration are used to calculate at which point of the animation we are.

At the moment where you call this function, the element must be at its starting point. After you call this function, you must add further transformations to represent the destination. Don't forget to call animation_stop if you want to add further transformations.

You can easily reverse this order (ie. the element is at its destination when you call the function and will be moved to its source) by reversing the interpolation with .reverse().

Stops the animation process. The next commands will always be applied.

Trait Implementations

impl<'a, 'b, D: ?Sized + Draw + 'b> Clone for DrawContext<'b, D>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more