Class RoundedRect
- All Implemented Interfaces:
Proxy
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 GskRoundedRect
as an argument will internally
operate on a normalized copy; all functions returning a GskRoundedRect
will always return a normalized one.
The algorithm used for normalizing corner sizes is described in the CSS specification.
-
Constructor Summary
ConstructorDescriptionAllocate a new RoundedRect.RoundedRect
(Arena arena) Allocate a new RoundedRect.RoundedRect
(MemorySegment address) Create a RoundedRect proxy instance for the provided memory address.RoundedRect
(Rect bounds, Size[] corner) Allocate a new RoundedRect with the fields set to the provided values.RoundedRect
(Rect bounds, Size[] corner, Arena arena) Allocate a new RoundedRect with the fields set to the provided values. -
Method Summary
Modifier and TypeMethodDescriptionboolean
containsPoint
(Point point) Checks if the givenpoint
is inside the rounded rectangle.boolean
containsRect
(Rect rect) Checks if the givenrect
is contained inside the rounded rectangle.static MemoryLayout
The memory layout of the native struct.Initializes the givenGskRoundedRect
with the given values.initCopy
(RoundedRect src) Initializes this RoundedRect using the givensrc
rectangle.initFromRect
(Rect bounds, float radius) Initializes this RoundedRect to the givenbounds
and sets the radius of all four corners toradius
.boolean
intersectsRect
(Rect rect) Checks if part of the givenrect
is contained inside the rounded rectangle.boolean
Checks if all corners of this RoundedRect are right angles and the rectangle covers all of its bounds.Normalizes the passed rectangle.offset
(float dx, float dy) Offsets the bound's origin bydx
anddy
.Read the value of the fieldbounds
.Size[]
Read the value of the fieldcorner
.shrink
(float top, float right, float bottom, float left) Shrinks (or grows) the given rectangle by moving the 4 sides according to the offsets given.void
writeBounds
(Rect bounds) Write a value in the fieldbounds
.void
writeCorner
(Size[] corner, Arena _arena) Write a value in the fieldcorner
.Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
RoundedRect
Create a RoundedRect proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
RoundedRect
Allocate a new RoundedRect.- Parameters:
arena
- to control the memory allocation scope
-
RoundedRect
public RoundedRect()Allocate a new RoundedRect. The memory is allocated withArena.ofAuto()
. -
RoundedRect
-
RoundedRect
Allocate a new RoundedRect with the fields set to the provided values. The memory is allocated withArena.ofAuto()
.- Parameters:
bounds
- value for the fieldbounds
corner
- value for the fieldcorner
-
-
Method Details
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
readBounds
-
writeBounds
Write a value in the fieldbounds
.- Parameters:
bounds
- The new value for the fieldbounds
-
readCorner
Read the value of the fieldcorner
.- Returns:
- The value of the field
corner
-
writeCorner
-
containsPoint
Checks if the givenpoint
is inside the rounded rectangle.- Parameters:
point
- the point to check- Returns:
true
if thepoint
is inside the rounded rectangle
-
containsRect
Checks if the givenrect
is contained inside the rounded rectangle.- Parameters:
rect
- the rectangle to check- Returns:
true
if therect
is fully contained inside the rounded rectangle
-
init
public RoundedRect init(Rect bounds, Size topLeft, Size topRight, Size bottomRight, Size bottomLeft) Initializes the givenGskRoundedRect
with the given values.This function will implicitly normalize the
GskRoundedRect
before returning.- Parameters:
bounds
- agraphene_rect_t
describing the boundstopLeft
- the rounding radius of the top left cornertopRight
- the rounding radius of the top right cornerbottomRight
- the rounding radius of the bottom right cornerbottomLeft
- the rounding radius of the bottom left corner- Returns:
- the initialized rectangle
-
initCopy
Initializes this RoundedRect using the givensrc
rectangle.This function will not normalize the
GskRoundedRect
, so make sure the source is normalized.- Parameters:
src
- aGskRoundedRect
- Returns:
- the initialized rectangle
-
initFromRect
Initializes this RoundedRect to the givenbounds
and sets the radius of all four corners toradius
.- Parameters:
bounds
- agraphene_rect_t
radius
- the border radius- Returns:
- the initialized rectangle
-
intersectsRect
Checks if part of the givenrect
is contained inside the rounded rectangle.- Parameters:
rect
- the rectangle to check- Returns:
true
if therect
intersects with the rounded rectangle
-
isRectilinear
public boolean isRectilinear()Checks if all corners of this RoundedRect are right angles and the rectangle covers all of its bounds.This information can be used to decide if
ClipNode(org.gnome.gsk.RenderNode, org.gnome.graphene.Rect)
orRoundedClipNode(org.gnome.gsk.RenderNode, org.gnome.gsk.RoundedRect)
should be called.- Returns:
true
if the rectangle is rectilinear
-
normalize
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
-
offset
Offsets the bound's origin bydx
anddy
.The size and corners of the rectangle are unchanged.
- Parameters:
dx
- the horizontal offsetdy
- the vertical offset- Returns:
- the offset rectangle
-
shrink
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
orleft
.- Parameters:
top
- How far to move the top side downwardsright
- How far to move the right side to the leftbottom
- How far to move the bottom side upwardsleft
- How far to move the left side to the right- Returns:
- the resized
GskRoundedRect
-