1/* GSK - The GTK Scene Kit
2 *
3 * Copyright 2016 Endless
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef __GSK_ROUNDED_RECT_H__
20#define __GSK_ROUNDED_RECT_H__
21
22#if !defined (__GSK_H_INSIDE__) && !defined (GTK_COMPILATION)
23#error "Only <gsk/gsk.h> can be included directly."
24#endif
25
26#include <gsk/gsktypes.h>
27
28G_BEGIN_DECLS
29
30/**
31 * GSK_ROUNDED_RECT_INIT:
32 * @_x: the X coordinate of the origin
33 * @_y: the Y coordinate of the origin
34 * @_w: the width
35 * @_h: the height
36 *
37 * Initializes a `GskRoundedRect` when declaring it.
38 * All corner sizes will be initialized to 0.
39 */
40#define GSK_ROUNDED_RECT_INIT(_x,_y,_w,_h) (GskRoundedRect) { .bounds = GRAPHENE_RECT_INIT(_x,_y,_w,_h), \
41 .corner = { \
42 GRAPHENE_SIZE_INIT(0, 0),\
43 GRAPHENE_SIZE_INIT(0, 0),\
44 GRAPHENE_SIZE_INIT(0, 0),\
45 GRAPHENE_SIZE_INIT(0, 0),\
46 }}
47
48typedef struct _GskRoundedRect GskRoundedRect;
49
50struct _GskRoundedRect
51{
52 graphene_rect_t bounds;
53
54 graphene_size_t corner[4];
55};
56
57GDK_AVAILABLE_IN_ALL
58GskRoundedRect * gsk_rounded_rect_init (GskRoundedRect *self,
59 const graphene_rect_t *bounds,
60 const graphene_size_t *top_left,
61 const graphene_size_t *top_right,
62 const graphene_size_t *bottom_right,
63 const graphene_size_t *bottom_left);
64GDK_AVAILABLE_IN_ALL
65GskRoundedRect * gsk_rounded_rect_init_copy (GskRoundedRect *self,
66 const GskRoundedRect *src);
67GDK_AVAILABLE_IN_ALL
68GskRoundedRect * gsk_rounded_rect_init_from_rect (GskRoundedRect *self,
69 const graphene_rect_t *bounds,
70 float radius);
71
72GDK_AVAILABLE_IN_ALL
73GskRoundedRect * gsk_rounded_rect_normalize (GskRoundedRect *self);
74
75GDK_AVAILABLE_IN_ALL
76GskRoundedRect * gsk_rounded_rect_offset (GskRoundedRect *self,
77 float dx,
78 float dy);
79GDK_AVAILABLE_IN_ALL
80GskRoundedRect * gsk_rounded_rect_shrink (GskRoundedRect *self,
81 float top,
82 float right,
83 float bottom,
84 float left);
85
86GDK_AVAILABLE_IN_ALL
87gboolean gsk_rounded_rect_is_rectilinear (const GskRoundedRect *self) G_GNUC_PURE;
88GDK_AVAILABLE_IN_ALL
89gboolean gsk_rounded_rect_contains_point (const GskRoundedRect *self,
90 const graphene_point_t *point) G_GNUC_PURE;
91GDK_AVAILABLE_IN_ALL
92gboolean gsk_rounded_rect_contains_rect (const GskRoundedRect *self,
93 const graphene_rect_t *rect) G_GNUC_PURE;
94GDK_AVAILABLE_IN_ALL
95gboolean gsk_rounded_rect_intersects_rect (const GskRoundedRect *self,
96 const graphene_rect_t *rect) G_GNUC_PURE;
97
98G_END_DECLS
99
100#endif /* __GSK_ROUNDED_RECT_H__ */
101

source code of gtk/gsk/gskroundedrect.h