pub struct RoundedRect { /* private fields */ }
Expand description
A rectangular region with rounded corners.
Application code should normalize rectangles using
normalize()
; this function will ensure that
the bounds of the rectangle are normalized and ensure that the corner
values are positive and the corners do not overlap.
All functions taking a RoundedRect
as an argument will internally
operate on a normalized copy; all functions returning a RoundedRect
will always return a normalized one.
The algorithm used for normalizing corner sizes is described in the CSS specification.
GLib type: Inline allocated boxed type with stack copy semantics.
Implementations§
Source§impl RoundedRect
impl RoundedRect
pub fn as_ptr(&self) -> *mut GskRoundedRect
Sourcepub unsafe fn from_glib_ptr_borrow<'a>(ptr: *const GskRoundedRect) -> &'a Self
pub unsafe fn from_glib_ptr_borrow<'a>(ptr: *const GskRoundedRect) -> &'a Self
Borrows the underlying C value.
Sourcepub unsafe fn from_glib_ptr_borrow_mut<'a>(
ptr: *mut GskRoundedRect,
) -> &'a mut Self
pub unsafe fn from_glib_ptr_borrow_mut<'a>( ptr: *mut GskRoundedRect, ) -> &'a mut Self
Borrows the underlying C value mutably.
Source§impl RoundedRect
impl RoundedRect
Sourcepub fn new(
bounds: Rect,
top_left: Size,
top_right: Size,
bottom_right: Size,
bottom_left: Size,
) -> Self
pub fn new( bounds: Rect, top_left: Size, top_right: Size, bottom_right: Size, bottom_left: Size, ) -> Self
Initializes a rounded rectangle with the given values.
This function will implicitly normalize the rounded rectangle before returning.
§bounds
a graphene::Rect
describing the bounds
§top_left
the rounding radius of the top left corner
§top_right
the rounding radius of the top right corner
§bottom_right
the rounding radius of the bottom right corner
§bottom_left
the rounding radius of the bottom left corner
§Returns
the initialized rounded rectangle
Sourcepub fn from_rect(bounds: Rect, radius: f32) -> Self
pub fn from_rect(bounds: Rect, radius: f32) -> Self
Sourcepub fn normalize(&mut self)
pub fn normalize(&mut self)
Normalizes a rounded rectangle.
This function will ensure that the bounds of the rounded rectangle are normalized and ensure that the corner values are positive and the corners do not overlap.
§Returns
the normalized rounded rectangle
Sourcepub fn shrink(&mut self, top: f32, right: f32, bottom: f32, left: f32)
pub fn shrink(&mut self, top: f32, right: f32, bottom: f32, left: f32)
Shrinks (or grows) a rounded rectangle by moving the 4 sides according to the offsets given.
The corner radii will be changed in a way that tries to keep the center of the corner circle intact. This emulates CSS behavior.
This function also works for growing rounded rectangles if you pass negative values for the @top, @right, @bottom or @left.
§top
how far to move the top side downwards
§right
how far to move the right side to the left
§bottom
how far to move the bottom side upwards
§left
how far to move the left side to the right
§Returns
the resized rounded rectangle
Sourcepub fn is_rectilinear(&self) -> bool
pub fn is_rectilinear(&self) -> bool
Checks if all corners of a rounded rectangle are right angles and the rectangle covers all of its bounds.
This information can be used to decide if ClipNode::new()
or RoundedClipNode::new()
should be called.
§Returns
true if the rounded rectangle is rectilinear