pub struct PaintCtx<'a> { /* private fields */ }Expand description
A context passed to Widget::paint method.
Implementations§
Source§impl PaintCtx<'_>
impl PaintCtx<'_>
Sourcepub fn text_contexts(
&mut self,
) -> (&mut FontContext, &mut LayoutContext<BrushIndex>)
pub fn text_contexts( &mut self, ) -> (&mut FontContext, &mut LayoutContext<BrushIndex>)
Get the Parley contexts needed to build and paint text sections.
Most users should embed a pre-built label widget
(such as masonry::widgets::Label)
as a child for non-interactive text.
These contexts could however be useful for custom text editing, such as for rich text editing.
Any cached text layouts should be invalidated in the layout pass when Self::fonts_changed
returns true.
Sourcepub fn fonts_changed(&mut self) -> bool
pub fn fonts_changed(&mut self) -> bool
Whether the set of loaded fonts has changed since layout was most recently called.
Any cached text layouts should be invalidated in the layout pass when this is true.
Source§impl PaintCtx<'_>
impl PaintCtx<'_>
Sourcepub fn size(&self) -> Size
pub fn size(&self) -> Size
The layout size.
This is roughly the layout size returned by the layout method on
the previous layout pass, with some adjustment for pixel snapping.
Sourcepub fn baseline_offset(&self) -> f64
pub fn baseline_offset(&self) -> f64
The offset of the baseline relative to the bottom of the widget.
Sourcepub fn window_origin(&self) -> Point
pub fn window_origin(&self) -> Point
The origin of the widget in window coordinates, relative to the top left corner of the content area.
Sourcepub fn window_transform(&self) -> Affine
pub fn window_transform(&self) -> Affine
Global transform of this widget in the window coordinate space.
Computed from all transform and scroll_translation values from this to the root widget.
Sourcepub fn bounding_rect(&self) -> Rect
pub fn bounding_rect(&self) -> Rect
The bounding rect of the widget in window coordinates.
See bounding rect documentation for details.
Sourcepub fn paint_rect(&self) -> Rect
pub fn paint_rect(&self) -> Rect
The paint rect of the widget.
Covers the area we expect to be invalidated when the widget is painted.
Sourcepub fn clip_path(&self) -> Option<Rect>
pub fn clip_path(&self) -> Option<Rect>
The clip path of the widget, if any was set.
For more information, see
LayoutCtx::set_clip_path.
Source§impl PaintCtx<'_>
impl PaintCtx<'_>
Sourcepub fn get_scale_factor(&self) -> f64
pub fn get_scale_factor(&self) -> f64
Get DPI scaling factor.
This is not required for most widgets, and should be used only for precise
rendering, such as rendering single pixel lines or selecting image variants.
This is currently only provided in the render stages, as these are the only passes which
are re-run when the scale factor changes, except EventCtx where it is necessary to
translate pointer events which are currently in physical coordinates.
Note that accessibility nodes and paint results will automatically be scaled by Masonry. This also doesn’t account for the widget’s current transform, which cannot currently be accessed by widgets directly.
Source§impl PaintCtx<'_>
impl PaintCtx<'_>
Sourcepub fn is_hovered(&self) -> bool
pub fn is_hovered(&self) -> bool
The “hovered” status of a widget.
A widget is “hovered” when a pointer is hovering over it. Widgets will often change their appearance as a visual indication that they will respond to pointer (usually mouse) interaction.
If the pointer is captured, then only the capturing widget can have hovered status. If the pointer is captured but not hovering over the captured widget, then no widget has the hovered status.
Sourcepub fn has_hovered(&self) -> bool
pub fn has_hovered(&self) -> bool
Whether this widget or any of its descendants are hovered.
To check if only this specific widget is hovered use is_hovered.
Sourcepub fn is_active(&self) -> bool
pub fn is_active(&self) -> bool
The “active” status of a widget.
A widget is “active” when the user is “actively” interacting with it. Currently, a widget is determined to be active when it has captured a pointer, but this may change in the future to account for e.g. keyboard interactions.
Sourcepub fn has_active(&self) -> bool
pub fn has_active(&self) -> bool
Whether this widget or any of its descendants are active.
To check if only this specific widget is active use is_active.
Sourcepub fn is_pointer_capture_target(&self) -> bool
pub fn is_pointer_capture_target(&self) -> bool
Whether a pointer is captured by this widget.
The pointer will usually be the mouse. In future versions, this function will take a pointer id as input to test a specific pointer.
Sourcepub fn is_focus_target(&self) -> bool
pub fn is_focus_target(&self) -> bool
The text focus status of a widget.
The focused widget is the one that receives keyboard events.
Returns true if this specific widget is focused.
To check if any descendants are focused use has_focus_target.
Sourcepub fn has_focus_target(&self) -> bool
pub fn has_focus_target(&self) -> bool
Whether this widget or any of its descendants are focused.
To check if only this specific widget is focused use is_focus_target.
Sourcepub fn is_window_focused(&self) -> bool
pub fn is_window_focused(&self) -> bool
Whether the window is focused.
Sourcepub fn accepts_pointer_interaction(&self) -> bool
pub fn accepts_pointer_interaction(&self) -> bool
Whether this widget gets pointer events and hovered status.
Sourcepub fn accepts_focus(&self) -> bool
pub fn accepts_focus(&self) -> bool
Whether this widget gets text focus.
Sourcepub fn accepts_text_input(&self) -> bool
pub fn accepts_text_input(&self) -> bool
Whether this widget gets IME events.
Sourcepub fn is_disabled(&self) -> bool
pub fn is_disabled(&self) -> bool
Whether this widget is disabled.
Returns true if this widget or any of its ancestors is explicitly disabled.
To make this widget explicitly disabled use set_disabled.
Sourcepub fn is_stashed(&self) -> bool
pub fn is_stashed(&self) -> bool
Whether this widget is stashed.
Source§impl PaintCtx<'_>
impl PaintCtx<'_>
Sourcepub fn debug_paint_enabled(&self) -> bool
pub fn debug_paint_enabled(&self) -> bool
Whether debug paint is enabled.
If this property is set, your widget may draw additional debug information (such as the position of the text baseline). These should normally use the debug color for this widget. Please note that when debug painting is enabled, each widget’s layout boundaries are outlined by Masonry, so you should avoid duplicating that.
Debug paint can be enabled by setting the environment variable MASONRY_DEBUG_PAINT.
Sourcepub fn debug_color(&self) -> Color
pub fn debug_color(&self) -> Color
A color used for debug painting in this widget.
This is normally used to paint additional debugging information
when debug paint is enabled, see Self::debug_paint_enabled.