gsk4

Struct RoundedRect

Source
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

Source

pub fn as_ptr(&self) -> *mut GskRoundedRect

Source

pub unsafe fn from_glib_ptr_borrow<'a>(ptr: *const GskRoundedRect) -> &'a Self

Borrows the underlying C value.

Source

pub unsafe fn from_glib_ptr_borrow_mut<'a>( ptr: *mut GskRoundedRect, ) -> &'a mut Self

Borrows the underlying C value mutably.

Source§

impl RoundedRect

Source

pub fn new( bounds: Rect, top_left: Size, top_right: Size, bottom_right: Size, bottom_left: Size, ) -> Self

Initializes the given RoundedRect with the given values.

This function will implicitly normalize the RoundedRect 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 rectangle

Source

pub fn from_rect(bounds: Rect, radius: f32) -> Self

Initializes @self to the given @bounds and sets the radius of all four corners to @radius.

§bounds

a graphene::Rect

§radius

the border radius

§Returns

the initialized rectangle

Source

pub fn normalize(&mut self)

Normalizes the passed rectangle.

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.

§Returns

the normalized rectangle

Source

pub fn offset(&mut self, dx: f32, dy: f32)

Offsets the bound’s origin by @dx and @dy.

The size and corners of the rectangle are unchanged.

§dx

the horizontal offset

§dy

the vertical offset

§Returns

the offset rectangle

Source

pub fn shrink(&mut self, top: f32, right: f32, bottom: f32, left: f32)

Shrinks (or grows) the given 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 rectangles if you pass negative values for the @top, @right, @bottom or @left.

§top

How far to move the top side downwards

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 RoundedRect

Source

pub fn is_rectilinear(&self) -> bool

Checks if all corners of @self 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 rectangle is rectilinear

Source

pub fn contains_point(&self, point: Point) -> bool

Checks if the given @point is inside the rounded rectangle.

§point

the point to check

§Returns

true if the @point is inside the rounded rectangle

Source

pub fn contains_rect(&self, rect: Rect) -> bool

Checks if the given @rect is contained inside the rounded rectangle.

§rect

the rectangle to check

§Returns

true if the @rect is fully contained inside the rounded rectangle

Source

pub fn intersects_rect(&self, rect: Rect) -> bool

Checks if part of the given @rect is contained inside the rounded rectangle.

§rect

the rectangle to check

§Returns

true if the @rect intersects with the rounded rectangle

Source

pub fn bounds(&self) -> &Rect

Source

pub fn corner(&self) -> &[Size; 4]

Trait Implementations§

Source§

impl Clone for RoundedRect

Source§

fn clone(&self) -> Self

Copies the inline boxed type by value with the type-specific copy function.

1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for RoundedRect

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Copy for RoundedRect

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for T

Source§

unsafe fn from_glib_none_num_as_vec(ptr: *const GList, num: usize) -> Vec<T>

Source§

unsafe fn from_glib_container_num_as_vec(_: *const GList, _: usize) -> Vec<T>

Source§

unsafe fn from_glib_full_num_as_vec(_: *const GList, _: usize) -> Vec<T>

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for T

Source§

unsafe fn from_glib_none_num_as_vec(ptr: *const GPtrArray, num: usize) -> Vec<T>

Source§

unsafe fn from_glib_container_num_as_vec( _: *const GPtrArray, _: usize, ) -> Vec<T>

Source§

unsafe fn from_glib_full_num_as_vec(_: *const GPtrArray, _: usize) -> Vec<T>

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for T

Source§

unsafe fn from_glib_none_num_as_vec(ptr: *const GSList, num: usize) -> Vec<T>

Source§

unsafe fn from_glib_container_num_as_vec(_: *const GSList, _: usize) -> Vec<T>

Source§

unsafe fn from_glib_full_num_as_vec(_: *const GSList, _: usize) -> Vec<T>

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for T

Source§

unsafe fn from_glib_none_num_as_vec(ptr: *mut GList, num: usize) -> Vec<T>

Source§

unsafe fn from_glib_container_num_as_vec(ptr: *mut GList, num: usize) -> Vec<T>

Source§

unsafe fn from_glib_full_num_as_vec(ptr: *mut GList, num: usize) -> Vec<T>

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for T

Source§

unsafe fn from_glib_none_num_as_vec(ptr: *mut GPtrArray, num: usize) -> Vec<T>

Source§

unsafe fn from_glib_container_num_as_vec( ptr: *mut GPtrArray, num: usize, ) -> Vec<T>

Source§

unsafe fn from_glib_full_num_as_vec(ptr: *mut GPtrArray, num: usize) -> Vec<T>

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for T

Source§

unsafe fn from_glib_none_num_as_vec(ptr: *mut GSList, num: usize) -> Vec<T>

Source§

unsafe fn from_glib_container_num_as_vec(ptr: *mut GSList, num: usize) -> Vec<T>

Source§

unsafe fn from_glib_full_num_as_vec(ptr: *mut GSList, num: usize) -> Vec<T>

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for T

Source§

unsafe fn from_glib_none_as_vec(ptr: *const GList) -> Vec<T>

Source§

unsafe fn from_glib_container_as_vec(_: *const GList) -> Vec<T>

Source§

unsafe fn from_glib_full_as_vec(_: *const GList) -> Vec<T>

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for T

Source§

unsafe fn from_glib_none_as_vec(ptr: *const GPtrArray) -> Vec<T>

Source§

unsafe fn from_glib_container_as_vec(_: *const GPtrArray) -> Vec<T>

Source§

unsafe fn from_glib_full_as_vec(_: *const GPtrArray) -> Vec<T>

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for T

Source§

unsafe fn from_glib_none_as_vec(ptr: *const GSList) -> Vec<T>

Source§

unsafe fn from_glib_container_as_vec(_: *const GSList) -> Vec<T>

Source§

unsafe fn from_glib_full_as_vec(_: *const GSList) -> Vec<T>

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for T

Source§

unsafe fn from_glib_none_as_vec(ptr: *mut GList) -> Vec<T>

Source§

unsafe fn from_glib_container_as_vec(ptr: *mut GList) -> Vec<T>

Source§

unsafe fn from_glib_full_as_vec(ptr: *mut GList) -> Vec<T>

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for T

Source§

unsafe fn from_glib_none_as_vec(ptr: *mut GPtrArray) -> Vec<T>

Source§

unsafe fn from_glib_container_as_vec(ptr: *mut GPtrArray) -> Vec<T>

Source§

unsafe fn from_glib_full_as_vec(ptr: *mut GPtrArray) -> Vec<T>

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for T

Source§

unsafe fn from_glib_none_as_vec(ptr: *mut GSList) -> Vec<T>

Source§

unsafe fn from_glib_container_as_vec(ptr: *mut GSList) -> Vec<T>

Source§

unsafe fn from_glib_full_as_vec(ptr: *mut GSList) -> Vec<T>

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.