Struct immi::DrawContext [] [src]

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

Contains everything required to draw a widget.

Methods

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

fn draw(&self) -> MutexGuard<&'b mut D>

UNSTABLE. Obtains the underlying draw object.

fn matrix(&self) -> &Matrix

fn cursor_was_pressed(&self) -> bool

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.

fn cursor_was_released(&self) -> bool

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.

fn cursor_hovered_widget(&self) -> bool

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.

fn set_cursor_hovered_widget(&self)

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

fn reserve_widget_id(&self) -> WidgetId

fn get_active_widget(&self) -> Option<WidgetId>

fn write_active_widget(&self, id: WidgetId)

fn clear_active_widget(&self)

fn is_cursor_hovering(&self) -> bool

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

fn width_per_height(&self) -> f32

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

fn margin(&self, top: f32, right: f32, bottom: f32, left: f32) -> DrawContext<'a, 'b, D>

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

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

fn uniform_margin(&self, top: f32, right: f32, bottom: f32, left: f32) -> DrawContext<'a, 'b, D>

Builds a new draw context containing a subpart 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.

fn enforce_aspect_ratio_downscale(&self, width_per_height: f32, alignment: &Alignment) -> DrawContext<'a, 'b, D>

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.

fn enforce_aspect_ratio_upscale(&self, width_per_height: f32, alignment: &Alignment) -> DrawContext<'a, 'b, D>

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.

fn vertical_rescale(&self, scale: f32, alignment: &VerticalAlignment) -> DrawContext<'a, 'b, D>

Builds a new draw context containing a subpart 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.

fn horizontal_rescale(&self, scale: f32, alignment: &HorizontalAlignment) -> DrawContext<'a, 'b, D>

Builds a new draw context containing a subpart 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.

fn vertical_split(&self, splits: usize) -> Vec<DrawContext<'a, 'b, D>>

Splits the viewport in splits vertical chunks of equal size.

fn vertical_split_weights<I>(&self, weights: I) -> Vec<DrawContext<'a, 'b, D>> where I: ExactSizeIterator<Item=f32> + Clone

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.

fn horizontal_split(&self, splits: usize) -> Vec<DrawContext<'a, 'b, D>>

Splits the viewport in splits horizontal chunks of equal size.

fn horizontal_split_weights<I>(&self, weights: I) -> Vec<DrawContext<'a, 'b, D>> where I: ExactSizeIterator<Item=f32> + Clone

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.

fn rescale(&self, width_percent: f32, height_percent: f32, alignment: &Alignment) -> DrawContext<'a, 'b, D>

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.

fn animate<A, I>(&self, animation: A, interpolation: I, start_time: u64, duration_ns: u64) -> DrawContext<'a, 'b, D> where A: Animation, I: Interpolation

Trait Implementations

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

fn clone(&self) -> DrawContext<'a, 'b, D>

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more