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 | |
28 | G_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 | |
48 | typedef struct _GskRoundedRect GskRoundedRect; |
49 | |
50 | struct _GskRoundedRect |
51 | { |
52 | graphene_rect_t bounds; |
53 | |
54 | graphene_size_t corner[4]; |
55 | }; |
56 | |
57 | GDK_AVAILABLE_IN_ALL |
58 | GskRoundedRect * 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); |
64 | GDK_AVAILABLE_IN_ALL |
65 | GskRoundedRect * gsk_rounded_rect_init_copy (GskRoundedRect *self, |
66 | const GskRoundedRect *src); |
67 | GDK_AVAILABLE_IN_ALL |
68 | GskRoundedRect * gsk_rounded_rect_init_from_rect (GskRoundedRect *self, |
69 | const graphene_rect_t *bounds, |
70 | float radius); |
71 | |
72 | GDK_AVAILABLE_IN_ALL |
73 | GskRoundedRect * gsk_rounded_rect_normalize (GskRoundedRect *self); |
74 | |
75 | GDK_AVAILABLE_IN_ALL |
76 | GskRoundedRect * gsk_rounded_rect_offset (GskRoundedRect *self, |
77 | float dx, |
78 | float dy); |
79 | GDK_AVAILABLE_IN_ALL |
80 | GskRoundedRect * gsk_rounded_rect_shrink (GskRoundedRect *self, |
81 | float top, |
82 | float right, |
83 | float bottom, |
84 | float left); |
85 | |
86 | GDK_AVAILABLE_IN_ALL |
87 | gboolean gsk_rounded_rect_is_rectilinear (const GskRoundedRect *self) G_GNUC_PURE; |
88 | GDK_AVAILABLE_IN_ALL |
89 | gboolean gsk_rounded_rect_contains_point (const GskRoundedRect *self, |
90 | const graphene_point_t *point) G_GNUC_PURE; |
91 | GDK_AVAILABLE_IN_ALL |
92 | gboolean gsk_rounded_rect_contains_rect (const GskRoundedRect *self, |
93 | const graphene_rect_t *rect) G_GNUC_PURE; |
94 | GDK_AVAILABLE_IN_ALL |
95 | gboolean gsk_rounded_rect_intersects_rect (const GskRoundedRect *self, |
96 | const graphene_rect_t *rect) G_GNUC_PURE; |
97 | |
98 | G_END_DECLS |
99 | |
100 | #endif /* __GSK_ROUNDED_RECT_H__ */ |
101 | |