mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-16 13:40:31 +00:00
Add clipping apis to GtkRoundedBox
This adds two functions for checking whether an axis-aligned rectangle is completely outside or inside of a rounded box. These are not trying to be exact, but fast.
This commit is contained in:
parent
579c7f80a0
commit
73e6a05e38
@ -536,3 +536,50 @@ _gtk_rounded_box_clip_path (const GtkRoundedBox *box,
|
||||
box->box.width, box->box.height);
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gtk_rounded_box_intersects_rectangle (const GtkRoundedBox *box,
|
||||
gdouble x1,
|
||||
gdouble y1,
|
||||
gdouble x2,
|
||||
gdouble y2)
|
||||
{
|
||||
if (x2 < box->box.x ||
|
||||
y2 < box->box.y ||
|
||||
x1 >= box->box.x + box->box.width ||
|
||||
y1 >= box->box.y + box->box.height)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gtk_rounded_box_contains_rectangle (const GtkRoundedBox *box,
|
||||
gdouble x1,
|
||||
gdouble y1,
|
||||
gdouble x2,
|
||||
gdouble y2)
|
||||
{
|
||||
if (x1 < box->box.x ||
|
||||
y1 < box->box.y ||
|
||||
x2 >= box->box.x + box->box.width ||
|
||||
y2 >= box->box.y + box->box.width)
|
||||
return FALSE;
|
||||
|
||||
if (x1 < box->box.x + box->corner[GTK_CSS_TOP_LEFT].horizontal &&
|
||||
y1 < box->box.y + box->corner[GTK_CSS_TOP_LEFT].vertical)
|
||||
return FALSE;
|
||||
|
||||
if (x2 > box->box.x + box->box.width - box->corner[GTK_CSS_TOP_RIGHT].horizontal &&
|
||||
y1 < box->box.y + box->corner[GTK_CSS_TOP_RIGHT].vertical)
|
||||
return FALSE;
|
||||
|
||||
if (x2 > box->box.x + box->box.width - box->corner[GTK_CSS_BOTTOM_RIGHT].horizontal &&
|
||||
y2 > box->box.y + box->box.height - box->corner[GTK_CSS_BOTTOM_RIGHT].vertical)
|
||||
return FALSE;
|
||||
|
||||
if (x1 < box->box.x + box->corner[GTK_CSS_BOTTOM_LEFT].horizontal &&
|
||||
y2 > box->box.y + box->box.height - box->corner[GTK_CSS_BOTTOM_LEFT].vertical)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -91,6 +91,16 @@ void _gtk_rounded_box_path_left (const GtkRounde
|
||||
cairo_t *cr);
|
||||
void _gtk_rounded_box_clip_path (const GtkRoundedBox *box,
|
||||
cairo_t *cr);
|
||||
gboolean _gtk_rounded_box_intersects_rectangle (const GtkRoundedBox *box,
|
||||
gdouble x1,
|
||||
gdouble y1,
|
||||
gdouble x2,
|
||||
gdouble y2);
|
||||
gboolean _gtk_rounded_box_contains_rectangle (const GtkRoundedBox *box,
|
||||
gdouble x1,
|
||||
gdouble y1,
|
||||
gdouble x2,
|
||||
gdouble y2);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user