libvisual  0.5.0
lv_rectangle_c.cpp
1 #include "config.h"
2 #include "lv_rectangle.h"
3 #include "lv_common.h"
4 
5 extern "C" {
6 
7  VisRectangle *visual_rectangle_new (int x, int y, int width, int height)
8  {
9  return new LV::Rect (x, y, width, height);
10  }
11 
12  VisRectangle *visual_rectangle_new_empty ()
13  {
14  return new LV::Rect;
15  }
16 
17  void visual_rectangle_free (VisRectangle *self)
18  {
19  delete self;
20  }
21 
22  void visual_rectangle_set (VisRectangle *self, int x, int y, int width, int height)
23  {
24  visual_return_if_fail (self != nullptr);
25  }
26 
27  void visual_rectangle_copy (VisRectangle *self, VisRectangle *src)
28  {
29  visual_return_if_fail (self != nullptr);
30  visual_return_if_fail (src != nullptr);
31 
32  *self = *src;
33  }
34 
35  VisRectangle *visual_rectangle_clone (VisRectangle *self)
36  {
37  visual_return_val_if_fail (self != nullptr, nullptr);
38 
39  return visual_rectangle_new (self->x, self->y, self->width, self->height);
40  }
41 
42  void visual_rectangle_set_x (VisRectangle *self, int x)
43  {
44  visual_return_if_fail (self != nullptr);
45 
46  self->x = x;
47  }
48 
49  int visual_rectangle_get_x (VisRectangle *self)
50  {
51  visual_return_val_if_fail (self != nullptr, 0);
52 
53  return self->x;
54  }
55 
56  void visual_rectangle_set_y (VisRectangle *self, int y)
57  {
58  visual_return_if_fail (self != nullptr);
59 
60  self->y = y;
61  }
62 
63  int visual_rectangle_get_y (VisRectangle *self)
64  {
65  visual_return_val_if_fail (self != nullptr, 0);
66 
67  return self->y;
68  }
69 
70  void visual_rectangle_set_width (VisRectangle *self, int width)
71  {
72  visual_return_if_fail (self != nullptr);
73 
74  self->width = width;
75  }
76 
77  int visual_rectangle_get_width (VisRectangle *self)
78  {
79  visual_return_val_if_fail (self != nullptr, 0);
80 
81  return self->width;
82  }
83 
84  void visual_rectangle_set_height (VisRectangle *self, int height)
85  {
86  visual_return_if_fail (self != nullptr);
87 
88  self->height = height;
89  }
90 
91  int visual_rectangle_get_height (VisRectangle *self)
92  {
93  visual_return_val_if_fail (self != nullptr, 0);
94 
95  return self->height;
96  }
97 
98  int visual_rectangle_is_empty (VisRectangle *self)
99  {
100  visual_return_val_if_fail (self != nullptr, TRUE);
101 
102  return self->empty ();
103  }
104 
105  int visual_rectangle_intersects (VisRectangle *self, VisRectangle *src)
106  {
107  visual_return_val_if_fail (self != nullptr, FALSE);
108  visual_return_val_if_fail (src != nullptr, FALSE);
109 
110  return self->intersects (*src);
111  }
112 
113  int visual_rectangle_contains_point (VisRectangle *self, int x, int y)
114  {
115  visual_return_val_if_fail (self != nullptr, FALSE);
116 
117  return self->contains (x, y);
118  }
119 
120  int visual_rectangle_contains_rect (VisRectangle *self, VisRectangle *src)
121  {
122  visual_return_val_if_fail (self != nullptr, FALSE);
123  visual_return_val_if_fail (src != nullptr, FALSE);
124 
125  return self->contains (*src);
126  }
127 
128  void visual_rectangle_clip (VisRectangle *result, VisRectangle *bounds, VisRectangle *src)
129  {
130  visual_return_if_fail (result != nullptr);
131  visual_return_if_fail (bounds != nullptr);
132  visual_return_if_fail (src != nullptr);
133 
134  *result = bounds->clip (*src);
135  }
136 
137  void visual_rectangle_normalize (VisRectangle *self)
138  {
139  visual_return_if_fail (self != nullptr);
140 
141  self->normalize ();
142  }
143 
144  void visual_rectangle_normalize_to (VisRectangle *self, VisRectangle *src)
145  {
146  visual_return_if_fail (self != nullptr);
147  visual_return_if_fail (src != nullptr);
148 
149  self->normalize_to (*src);
150  }
151 
152  void visual_rectangle_denormalize_point (VisRectangle *self, float fx, float fy, int32_t *x, int32_t *y)
153  {
154  visual_return_if_fail (self != nullptr);
155  visual_return_if_fail (x != nullptr);
156  visual_return_if_fail (y != nullptr);
157 
158  self->denormalize_point (fx, fy, *x, *y);
159  }
160 
161  void visual_rectangle_denormalize_point_neg (VisRectangle *self, float fx, float fy, int32_t *x, int32_t *y)
162  {
163  visual_return_if_fail (self != nullptr);
164  visual_return_if_fail (x != nullptr);
165  visual_return_if_fail (y != nullptr);
166 
167  self->denormalize_point_neg (fx, fy, *x, *y);
168  }
169 
170  void visual_rectangle_denormalize_points (VisRectangle *self, const float *fxlist, const float *fylist, int32_t *xlist, int32_t *ylist, unsigned int size)
171  {
172  visual_return_if_fail (self != nullptr);
173 
174  self->denormalize_points (fxlist, fylist, xlist, ylist, size);
175  }
176 
177  void visual_rectangle_denormalise_points_neg (VisRectangle *self, const float *fxlist, const float *fylist, int32_t *xlist, int32_t *ylist, unsigned int size)
178  {
179  visual_return_if_fail (self != nullptr);
180 
181  self->denormalize_points_neg (fxlist, fylist, xlist, ylist, size);
182  }
183 
184 } // extern C