diff options
author | Benjamin Otte <otte@redhat.com> | 2016-12-13 19:02:12 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2016-12-20 18:01:10 +0100 |
commit | 59d638a09fc4f72efb47560d103b2adbc00ce30a (patch) | |
tree | a6dc0288f9e4e222da162ea89bfbbc20fa7049ee /gsk/gskroundedrect.h | |
parent | 0a0cbcdcb65b710fd2cce87f923d61d282892faa (diff) | |
download | gtk+-59d638a09fc4f72efb47560d103b2adbc00ce30a.tar.gz |
gsk: Add GskRoundedRect
It's essentially a port of GtkRoundedBox to graphene.
Diffstat (limited to 'gsk/gskroundedrect.h')
-rw-r--r-- | gsk/gskroundedrect.h | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/gsk/gskroundedrect.h b/gsk/gskroundedrect.h new file mode 100644 index 0000000000..96551edd43 --- /dev/null +++ b/gsk/gskroundedrect.h @@ -0,0 +1,96 @@ +/* GSK - The GTK Scene Kit + * + * Copyright 2016 Endless + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __GSK_ROUNDED_RECT_H__ +#define __GSK_ROUNDED_RECT_H__ + +#if !defined (__GSK_H_INSIDE__) && !defined (GSK_COMPILATION) +#error "Only <gsk/gsk.h> can be included directly." +#endif + +#include <gsk/gsktypes.h> + +G_BEGIN_DECLS + +/** + * GSK_ROUNDED_RECT_INIT: + * @_x: the X coordinate of the origin + * @_y: the Y coordinate of the origin + * @_w: the width + * @_h: the height + * + * Initializes a #GskRoundedRect when declaring it. + * + * Since: 3.90 + */ +#define GSK_ROUNDED_RECT_INIT(_x,_y,_w,_h) (GskRoundedRect) { .rect = GRAPHENE_RECT_INIT(_x,_y,_w,_h) } + +/** + * GskRoundedRect: + * @bounds: the bounds of the rectangle + * @corner: the size of the 4 rounded corners + * + * A rectanglular region with rounded corners. + * + * Application code should normalize rectangles using gsk_rounded_rect_normalize(); + * this function will ensure that the bounds of the rectanlge 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. + * + * Since: 3.90 + */ +typedef struct _GskRoundedRect GskRoundedRect; + +struct _GskRoundedRect +{ + graphene_rect_t bounds; + + graphene_size_t corner[4]; +}; + +GDK_AVAILABLE_IN_3_90 +GskRoundedRect * gsk_rounded_rect_init (GskRoundedRect *self, + const graphene_rect_t *rect, + const graphene_size_t *top_left, + const graphene_size_t *top_right, + const graphene_size_t *bottom_right, + const graphene_size_t *bottom_left); +GDK_AVAILABLE_IN_3_90 +GskRoundedRect * gsk_rounded_rect_init_copy (GskRoundedRect *self, + const GskRoundedRect *src); +GDK_AVAILABLE_IN_3_90 +GskRoundedRect * gsk_rounded_rect_init_from_rect (GskRoundedRect *self, + const graphene_rect_t *bounds, + float radius); + +GDK_AVAILABLE_IN_3_90 +GskRoundedRect * gsk_rounded_rect_normalize (GskRoundedRect *self); + +GDK_AVAILABLE_IN_3_90 +GskRoundedRect * gsk_rounded_rect_offset (GskRoundedRect *self, + float dx, + float dy); + +GDK_AVAILABLE_IN_3_90 +gboolean gsk_rounded_rect_is_rectilinear (GskRoundedRect *self); + +G_END_DECLS + +#endif /* __GSK_ROUNDED_RECT_H__ */ |