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&*selfto convert from to&Wfrom&mut W, since the latter would cause borrow conflicts
Implementations
sourceimpl<'a> DrawMgr<'a>
impl<'a> DrawMgr<'a>
sourcepub fn re_id<'b>(&'b mut self, id: WidgetId) -> DrawMgr<'b>where
'a: 'b,
pub fn re_id<'b>(&'b mut self, id: WidgetId) -> DrawMgr<'b>where
'a: 'b,
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.
sourcepub fn re_clone<'b>(&'b mut self) -> DrawMgr<'b>where
'a: 'b,
pub fn re_clone<'b>(&'b mut self) -> DrawMgr<'b>where
'a: 'b,
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.
sourcepub fn ev_state(&mut self) -> &EventState
pub fn ev_state(&mut self) -> &EventState
Access event-management state
sourcepub fn config_mgr<F: FnMut(&mut ConfigMgr<'_>) -> T, T>(&mut self, f: F) -> T
pub fn config_mgr<F: FnMut(&mut ConfigMgr<'_>) -> T, T>(&mut self, f: F) -> T
Access a ConfigMgr
Access a DrawShared
sourcepub fn draw_device(&mut self) -> &mut dyn Draw
pub fn draw_device(&mut self) -> &mut dyn Draw
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.
sourcepub fn with_pass<F: FnOnce(DrawMgr<'_>)>(&mut self, f: F)
pub fn with_pass<F: FnOnce(DrawMgr<'_>)>(&mut self, f: F)
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.
sourcepub fn with_clip_region<F: FnOnce(DrawMgr<'_>)>(
&mut self,
rect: Rect,
offset: Offset,
f: F
)
pub fn with_clip_region<F: FnOnce(DrawMgr<'_>)>(
&mut self,
rect: Rect,
offset: Offset,
f: F
)
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.
sourcepub fn with_overlay<F: FnOnce(DrawMgr<'_>)>(&mut self, rect: Rect, f: F)
pub fn with_overlay<F: FnOnce(DrawMgr<'_>)>(&mut self, rect: Rect, f: F)
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.
sourcepub fn get_clip_rect(&mut self) -> Rect
pub fn get_clip_rect(&mut self) -> Rect
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.
sourcepub fn frame(&mut self, rect: Rect, style: FrameStyle, bg: Background)
pub fn frame(&mut self, rect: Rect, style: FrameStyle, bg: Background)
Draw a frame inside the given rect
The frame dimensions are given by SizeMgr::frame.
sourcepub fn selection_box(&mut self, rect: Rect)
pub fn selection_box(&mut self, rect: 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.
sourcepub fn text(&mut self, rect: Rect, text: impl AsRef<TextDisplay>, class: TextClass)
pub fn text(&mut self, rect: Rect, text: impl AsRef<TextDisplay>, class: TextClass)
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).
sourcepub fn text_effects(&mut self, rect: Rect, text: &dyn TextApi, class: TextClass)
pub fn text_effects(&mut self, rect: Rect, text: &dyn TextApi, class: 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).
sourcepub fn text_selected<R: RangeBounds<usize>>(
&mut self,
rect: Rect,
text: impl AsRef<TextDisplay>,
range: R,
class: TextClass
)
pub fn text_selected<R: RangeBounds<usize>>(
&mut self,
rect: Rect,
text: impl AsRef<TextDisplay>,
range: R,
class: 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.
sourcepub fn text_cursor(
&mut self,
rect: Rect,
text: impl AsRef<TextDisplay>,
class: TextClass,
byte: usize
)
pub fn text_cursor(
&mut self,
rect: Rect,
text: impl AsRef<TextDisplay>,
class: TextClass,
byte: usize
)
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).
sourcepub fn check_box(
&mut self,
rect: Rect,
checked: bool,
last_change: Option<Instant>
)
pub fn check_box(
&mut self,
rect: Rect,
checked: bool,
last_change: Option<Instant>
)
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.
sourcepub fn radio_box(
&mut self,
rect: Rect,
checked: bool,
last_change: Option<Instant>
)
pub fn radio_box(
&mut self,
rect: Rect,
checked: bool,
last_change: Option<Instant>
)
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.
sourcepub fn scroll_bar<W: Widget>(
&mut self,
track_rect: Rect,
handle: &W,
dir: Direction
)
pub fn scroll_bar<W: Widget>(
&mut self,
track_rect: Rect,
handle: &W,
dir: Direction
)
Draw UI element: scroll bar
sourcepub fn slider<W: Widget>(&mut self, track_rect: Rect, handle: &W, dir: Direction)
pub fn slider<W: Widget>(&mut self, track_rect: Rect, handle: &W, dir: Direction)
Draw UI element: slider
sourcepub fn progress_bar(&mut self, rect: Rect, dir: Direction, value: f32)
pub fn progress_bar(&mut self, rect: Rect, dir: Direction, value: f32)
Draw UI element: progress bar
rect: area of whole widgetdir: direction of progress barstate: highlighting informationvalue: progress value, between 0.0 and 1.0
Trait Implementations
sourceimpl<'a> BitOrAssign<TkAction> for DrawMgr<'a>
impl<'a> BitOrAssign<TkAction> for DrawMgr<'a>
sourcefn bitor_assign(&mut self, action: TkAction)
fn bitor_assign(&mut self, action: TkAction)
Performs the |= operation. Read more
Auto Trait Implementations
impl<'a> !RefUnwindSafe for DrawMgr<'a>
impl<'a> !Send for DrawMgr<'a>
impl<'a> !Sync for DrawMgr<'a>
impl<'a> Unpin for DrawMgr<'a>
impl<'a> !UnwindSafe for DrawMgr<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
sourcefn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
Try approximate conversion from Self to T Read more
sourcefn cast_approx(self) -> T
fn cast_approx(self) -> T
Cast approximately from Self to T Read more
sourceimpl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
sourcefn cast_trunc(self) -> T
fn cast_trunc(self) -> T
Cast to integer, truncating Read more
sourcefn cast_nearest(self) -> T
fn cast_nearest(self) -> T
Cast to the nearest integer Read more
sourcefn cast_floor(self) -> T
fn cast_floor(self) -> T
Cast the floor to an integer Read more
sourcefn try_cast_trunc(self) -> Result<T, Error>
fn try_cast_trunc(self) -> Result<T, Error>
Try converting to integer with truncation Read more
sourcefn try_cast_nearest(self) -> Result<T, Error>
fn try_cast_nearest(self) -> Result<T, Error>
Try converting to the nearest integer Read more
sourcefn try_cast_floor(self) -> Result<T, Error>
fn try_cast_floor(self) -> Result<T, Error>
Try converting the floor to an integer Read more
sourcefn try_cast_ceil(self) -> Result<T, Error>
fn try_cast_ceil(self) -> Result<T, Error>
Try convert the ceiling to an integer Read more