gtkmm 4.19.0
|
A rectangular region with rounded corners. More...
#include <gskmm/roundedrect.h>
Public Member Functions | |
RoundedRect () | |
RoundedRect (const GskRoundedRect * rounded_rect) | |
RoundedRect (const Gdk::Graphene::Rect & bounds, const Gdk::Graphene::Size & top_left, const Gdk::Graphene::Size & top_right, const Gdk::Graphene::Size & bottom_right, const Gdk::Graphene::Size & bottom_left) | |
RoundedRect (const Gdk::Graphene::Rect & bounds, float radius) | |
RoundedRect (const RoundedRect & other) noexcept | |
RoundedRect & | operator= (const RoundedRect & other) noexcept |
RoundedRect (RoundedRect && other) noexcept | |
RoundedRect & | operator= (RoundedRect && other) noexcept |
void | set (const Gdk::Graphene::Rect & bounds, const Gdk::Graphene::Size & top_left, const Gdk::Graphene::Size & top_right, const Gdk::Graphene::Size & bottom_right, const Gdk::Graphene::Size & bottom_left) |
Initializes a rounded rectangle with the given values. | |
void | set (const Gdk::Graphene::Rect & bounds, float radius) |
Initializes a rounded rectangle to the given bounds and sets the radius of all four corners equally. | |
std::pair< Gdk::Graphene::Rect, std::array< Gdk::Graphene::Size, 4 > > | get () const |
Get the bounding rectangle and the corner radii. | |
void | normalize () |
Normalizes a rounded rectangle. | |
void | offset (float dx, float dy) |
Offsets the rounded rectangle's origin by dx and dy. | |
void | shrink (float top, float right, float bottom, float left) |
Shrinks (or grows) a rounded rectangle by moving the 4 sides according to the offsets given. | |
bool | is_rectilinear () const |
Checks if all corners of a rounded rectangle are right angles and the rectangle covers all of its bounds. | |
bool | contains (const Gdk::Graphene::Point & point) const |
Checks if the given point is inside the rounded rectangle. | |
bool | contains (const Gdk::Graphene::Rect & rect) const |
Checks if the given rectangle is contained inside the rounded rectangle. | |
bool | intersects (const Gdk::Graphene::Rect & rect) const |
Checks if part a rectangle is contained inside the rounded rectangle. | |
GskRoundedRect * | gobj () |
Provides access to the underlying C GObject. | |
const GskRoundedRect * | gobj () const |
Provides access to the underlying C GObject. |
Protected Attributes | |
GskRoundedRect | gobject_ |
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 Gsk::RoundedRect as an argument will internally operate on a normalized copy; all functions returning a Gsk::RoundedRect will always return a normalized one.
The algorithm used for normalizing corner sizes is described in the CSS specification.
Gsk::RoundedRect::RoundedRect | ( | ) |
Gsk::RoundedRect::RoundedRect | ( | const GskRoundedRect * | rounded_rect | ) |
Gsk::RoundedRect::RoundedRect | ( | const Gdk::Graphene::Rect & | bounds, |
const Gdk::Graphene::Size & | top_left, | ||
const Gdk::Graphene::Size & | top_right, | ||
const Gdk::Graphene::Size & | bottom_right, | ||
const Gdk::Graphene::Size & | bottom_left ) |
Gsk::RoundedRect::RoundedRect | ( | const Gdk::Graphene::Rect & | bounds, |
float | radius ) |
|
noexcept |
|
noexcept |
bool Gsk::RoundedRect::contains | ( | const Gdk::Graphene::Point & | point | ) | const |
Checks if the given point is inside the rounded rectangle.
point | The point to check. |
bool Gsk::RoundedRect::contains | ( | const Gdk::Graphene::Rect & | rect | ) | const |
Checks if the given rectangle is contained inside the rounded rectangle.
rect | The rectangle to check. |
std::pair< Gdk::Graphene::Rect, std::array< Gdk::Graphene::Size, 4 > > Gsk::RoundedRect::get | ( | ) | const |
Get the bounding rectangle and the corner radii.
You can use the Gsk::Corner enum to select a corner.
|
inline |
Provides access to the underlying C GObject.
|
inline |
Provides access to the underlying C GObject.
bool Gsk::RoundedRect::intersects | ( | const Gdk::Graphene::Rect & | rect | ) | const |
Checks if part a rectangle is contained inside the rounded rectangle.
rect | The rectangle to check. |
bool Gsk::RoundedRect::is_rectilinear | ( | ) | const |
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 Gsk::ClipNode::new() or Gsk::RoundedClipNode::new() should be called.
void Gsk::RoundedRect::normalize | ( | ) |
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.
void Gsk::RoundedRect::offset | ( | float | dx, |
float | dy ) |
Offsets the rounded rectangle's origin by dx and dy.
The size and corners of the rounded rectangle are unchanged.
dx | The horizontal offset. |
dy | The vertical offset. |
|
noexcept |
|
noexcept |
void Gsk::RoundedRect::set | ( | const Gdk::Graphene::Rect & | bounds, |
const Gdk::Graphene::Size & | top_left, | ||
const Gdk::Graphene::Size & | top_right, | ||
const Gdk::Graphene::Size & | bottom_right, | ||
const Gdk::Graphene::Size & | bottom_left ) |
Initializes a rounded rectangle with the given values.
This function will implicitly normalize the rounded rectangle before returning.
bounds | A graphene_rect_t 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. |
void Gsk::RoundedRect::set | ( | const Gdk::Graphene::Rect & | bounds, |
float | radius ) |
Initializes a rounded rectangle to the given bounds and sets the radius of all four corners equally.
bounds | A graphene_rect_t. |
radius | The border radius. |
void Gsk::RoundedRect::shrink | ( | float | top, |
float | right, | ||
float | bottom, | ||
float | left ) |
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. |
|
protected |