pub struct DrawMgr<'a> { /* private fields */ }
Expand description

Draw interface

This interface is provided to widgets in crate::Layout::draw. Lower-level interfaces may be accessed through Self::draw_device.

DrawMgr is not a Copy or Clone type; instead it may be “reborrowed” via Self::re_id or Self::re_clone.

  • draw.check_box(&*self, self.state); — note &*self to convert from to &W from &mut W, since the latter would cause borrow conflicts

Implementations

Reborrow with a new lifetime and new id

Rust allows references like &T or &mut T to be “reborrowed” through coercion: essentially, the pointer is copied under a new, shorter, lifetime. Until rfcs#1403 lands, reborrows on user types require a method call.

Reborrow with a new lifetime and same id

Rust allows references like &T or &mut T to be “reborrowed” through coercion: essentially, the pointer is copied under a new, shorter, lifetime. Until rfcs#1403 lands, reborrows on user types require a method call.

Recurse drawing to a child

Access event-management state

Access a SizeMgr

Access a ConfigMgr

Access a DrawShared

Access the low-level draw device

Note: this drawing API is modular, with limited functionality in the base trait Draw. To access further functionality, it is necessary to downcast with crate::draw::DrawIface::downcast_from.

Draw to a new pass

Adds a new draw pass for purposes of enforcing draw order. Content of the new pass will be drawn after content in the parent pass.

Draw to a new pass with clipping and offset (e.g. for scrolling)

Adds a new draw pass of type PassType::Clip, with draw operations clipped to rect and translated by `offset.

Draw to a new pass as an overlay (e.g. for pop-up menus)

Adds a new draw pass of type PassType::Overlay, with draw operations clipped to rect.

The theme is permitted to enlarge the rect for the purpose of drawing a frame or shadow around this overlay, thus the Self::get_clip_rect may be larger than expected.

Target area for drawing

Drawing is restricted to this Rect, which may be the whole window, a clip region or an overlay. This may be used to cull hidden items from lists inside a scrollable view.

Draw a frame inside the given rect

The frame dimensions are given by SizeMgr::frame.

Draw a separator in the given rect

Draw a selection box

This appears as a dashed box or similar around this rect. Note that the selection indicator is drawn outside of this rect, within a margin of size SizeMgr::inner_margins that is expected to be present around this box.

Draw text

Text is drawn from rect.pos and clipped to rect. If the text scrolls, rect should be the size of the whole text, not the window.

ConfigMgr::text_set_size should be called prior to this method to select a font, font size and wrap options (based on the TextClass).

Draw text with effects

Text is drawn from rect.pos and clipped to rect. If the text scrolls, rect should be the size of the whole text, not the window.

Self::text already supports font effects: bold, emphasis, text size. In addition, this method supports underline and strikethrough effects.

ConfigMgr::text_set_size should be called prior to this method to select a font, font size and wrap options (based on the TextClass).

Draw some text using the standard font, with a subset selected

Other than visually highlighting the selection, this method behaves identically to Self::text. It is likely to be replaced in the future by a higher-level API.

Draw an edit marker at the given byte index on this text

The text cursor is draw from rect.pos and clipped to rect. If the text scrolls, rect should be the size of the whole text, not the window.

ConfigMgr::text_set_size should be called prior to this method to select a font, font size and wrap options (based on the TextClass).

Draw UI element: check box (without label)

The check box is a small visual element, typically a distinctive square box with or without a “check” selection mark.

The theme may animate transitions. To achieve this, last_change should be the time of the last state change caused by the user, or none when the last state change was programmatic.

Draw UI element: radio box (without label)

The radio box is a small visual element, typically a disinctive circular box with or without a “radio” selection mark.

The theme may animate transitions. To achieve this, last_change should be the time of the last state change caused by the user, or none when the last state change was programmatic.

Draw UI element: mark

Draw UI element: scroll bar

Draw UI element: slider

Draw UI element: progress bar

  • rect: area of whole widget
  • dir: direction of progress bar
  • state: highlighting information
  • value: progress value, between 0.0 and 1.0

Draw an image

Trait Implementations

Performs the |= operation. Read more

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

Cast from Self to T Read more

Try converting from Self to T Read more

Try approximate conversion from Self to T Read more

Cast approximately from Self to T Read more

Cast to integer, truncating Read more

Cast to the nearest integer Read more

Cast the floor to an integer Read more

Cast the ceiling to an integer Read more

Try converting to integer with truncation Read more

Try converting to the nearest integer Read more

Try converting the floor to an integer Read more

Try convert the ceiling to an integer Read more

Returns the argument unchanged.

Calls U::from(self).

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

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.