Package ch.bailu.gtk.gsk
Class RoundedRect
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.type.Record
ch.bailu.gtk.gsk.RoundedRect
- All Implemented Interfaces:
PointerInterface
A rectangular region with rounded corners.
Application code should normalize rectangles using
[method@Gsk.RoundedRect.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](https://drafts.csswg.org/css-backgrounds-3/#border-radius).
Application code should normalize rectangles using
[method@Gsk.RoundedRect.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](https://drafts.csswg.org/css-backgrounds-3/#border-radius).
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
the bounds of the rectangle
Private field: direct-type -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
containsPoint
(Point point) Checks if the given @point is inside the rounded rectangle.boolean
containsRect
(Rect rect) Checks if the given @rect is contained inside the rounded rectangle.static ClassHandler
Initializes the given `GskRoundedRect` with the given values.initCopy
(RoundedRect src) Initializes @self using the given @src rectangle.initFromRect
(Rect bounds, float radius) Initializes @self to the given @bounds and sets the radius
of all four corners to @radius.boolean
intersectsRect
(Rect rect) Checks if part of the given @rect is contained inside the rounded rectangle.boolean
Checks if all corners of @self 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 by @dx and @dy.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.Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Field Details
-
BOUNDS
the bounds of the rectangle
Private field: direct-type- See Also:
-
-
Constructor Details
-
RoundedRect
-
-
Method Details
-
getClassHandler
-
containsPoint
Checks if the given @point is inside the rounded rectangle.- Parameters:
point
- the point to check- Returns:
- %TRUE if the @point is inside the rounded rectangle
-
containsRect
Checks if the given @rect is contained inside the rounded rectangle.- Parameters:
rect
- the rectangle to check- Returns:
- %TRUE if the @rect is fully contained inside the rounded rectangle
-
init
public RoundedRect init(@Nonnull Rect bounds, @Nonnull Size top_left, @Nonnull Size top_right, @Nonnull Size bottom_right, @Nonnull Size bottom_left) Initializes the given `GskRoundedRect` with the given values.
This function will implicitly normalize the `GskRoundedRect`
before returning.- Parameters:
bounds
- a `graphene_rect_t` describing the boundstop_left
- the rounding radius of the top left cornertop_right
- the rounding radius of the top right cornerbottom_right
- the rounding radius of the bottom right cornerbottom_left
- the rounding radius of the bottom left corner- Returns:
- the initialized rectangle
-
initCopy
Initializes @self using the given @src rectangle.
This function will not normalize the `GskRoundedRect`,
so make sure the source is normalized.- Parameters:
src
- a `GskRoundedRect`- Returns:
- the initialized rectangle
-
initFromRect
Initializes @self to the given @bounds and sets the radius
of all four corners to @radius.- Parameters:
bounds
- a `graphene_rect_t`radius
- the border radius- Returns:
- the initialized rectangle
-
intersectsRect
Checks if part of the given @rect is contained inside the rounded rectangle.- Parameters:
rect
- the rectangle to check- Returns:
- %TRUE if the @rect intersects with the rounded rectangle
-
isRectilinear
public boolean isRectilinear()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 [ctor@Gsk.ClipNode.new]
or [ctor@Gsk.RoundedClipNode.new] 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 by @dx and @dy.
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 or @left.- 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`
-