summaryrefslogtreecommitdiff
path: root/modules/gdnative/godot/godot_rect2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdnative/godot/godot_rect2.cpp')
-rw-r--r--modules/gdnative/godot/godot_rect2.cpp126
1 files changed, 103 insertions, 23 deletions
diff --git a/modules/gdnative/godot/godot_rect2.cpp b/modules/gdnative/godot/godot_rect2.cpp
index b19096b79e..eea95ca6fe 100644
--- a/modules/gdnative/godot/godot_rect2.cpp
+++ b/modules/gdnative/godot/godot_rect2.cpp
@@ -28,48 +28,128 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "godot_rect2.h"
+#include "core/variant.h"
-#include "math/math_2d.h"
+#include "core/math/math_2d.h"
#ifdef __cplusplus
extern "C" {
#endif
-void _rect2_api_anchor() {
+void _rect2_api_anchor() {}
+
+void GDAPI godot_rect2_new_with_pos_and_size(godot_rect2 *r_dest, const godot_vector2 *p_pos, const godot_vector2 *p_size) {
+ const Vector2 *pos = (const Vector2 *)p_pos;
+ const Vector2 *size = (const Vector2 *)p_size;
+ Rect2 *dest = (Rect2 *)r_dest;
+ *dest = Rect2(*pos, *size);
}
-void GDAPI godot_rect2_new(godot_rect2 *p_rect) {
- Rect2 *rect = (Rect2 *)p_rect;
- *rect = Rect2();
+void GDAPI godot_rect2_new(godot_rect2 *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_width, const godot_real p_height) {
+
+ Rect2 *dest = (Rect2 *)r_dest;
+ *dest = Rect2(p_x, p_y, p_width, p_height);
}
-void GDAPI godot_rect2_new_with_pos_and_size(godot_rect2 *p_rect, const godot_vector2 *p_pos, const godot_vector2 *p_size) {
- Rect2 *rect = (Rect2 *)p_rect;
- const Vector2 *pos = (const Vector2 *)p_pos;
- const Vector2 *size = (const Vector2 *)p_size;
- *rect = Rect2(*pos, *size);
+godot_string GDAPI godot_rect2_as_string(const godot_rect2 *p_self) {
+ godot_string ret;
+ const Rect2 *self = (const Rect2 *)p_self;
+ memnew_placement(&ret, String(*self));
+ return ret;
}
-godot_vector2 GDAPI *godot_rect2_get_pos(godot_rect2 *p_rect) {
- Rect2 *rect = (Rect2 *)p_rect;
- return (godot_vector2 *)&rect->pos;
+godot_real GDAPI godot_rect2_get_area(const godot_rect2 *p_self) {
+ const Rect2 *self = (const Rect2 *)p_self;
+ return self->get_area();
}
-void GDAPI godot_rect2_set_pos(godot_rect2 *p_rect, const godot_vector2 *p_pos) {
- Rect2 *rect = (Rect2 *)p_rect;
- const Vector2 *pos = (const Vector2 *)p_pos;
- rect->pos = *pos;
+godot_bool GDAPI godot_rect2_intersects(const godot_rect2 *p_self, const godot_rect2 *p_b) {
+ const Rect2 *self = (const Rect2 *)p_self;
+ const Rect2 *b = (const Rect2 *)p_b;
+ return self->intersects(*b);
+}
+
+godot_bool GDAPI godot_rect2_encloses(const godot_rect2 *p_self, const godot_rect2 *p_b) {
+ const Rect2 *self = (const Rect2 *)p_self;
+ const Rect2 *b = (const Rect2 *)p_b;
+ return self->encloses(*b);
+}
+
+godot_bool GDAPI godot_rect2_has_no_area(const godot_rect2 *p_self) {
+ const Rect2 *self = (const Rect2 *)p_self;
+ return self->has_no_area();
+}
+
+godot_rect2 GDAPI godot_rect2_clip(const godot_rect2 *p_self, const godot_rect2 *p_b) {
+ godot_rect2 dest;
+ const Rect2 *self = (const Rect2 *)p_self;
+ const Rect2 *b = (const Rect2 *)p_b;
+ *((Rect2 *)&dest) = self->clip(*b);
+ return dest;
+}
+
+godot_rect2 GDAPI godot_rect2_merge(const godot_rect2 *p_self, const godot_rect2 *p_b) {
+ godot_rect2 dest;
+ const Rect2 *self = (const Rect2 *)p_self;
+ const Rect2 *b = (const Rect2 *)p_b;
+ *((Rect2 *)&dest) = self->merge(*b);
+ return dest;
}
-godot_vector2 GDAPI *godot_rect2_get_size(godot_rect2 *p_rect) {
- Rect2 *rect = (Rect2 *)p_rect;
- return (godot_vector2 *)&rect->size;
+godot_bool GDAPI godot_rect2_has_point(const godot_rect2 *p_self, const godot_vector2 *p_point) {
+ const Rect2 *self = (const Rect2 *)p_self;
+ const Vector2 *point = (const Vector2 *)p_point;
+ return self->has_point(*point);
+}
+
+godot_rect2 GDAPI godot_rect2_grow(const godot_rect2 *p_self, const godot_real p_by) {
+ godot_rect2 dest;
+ const Rect2 *self = (const Rect2 *)p_self;
+
+ *((Rect2 *)&dest) = self->grow(p_by);
+ return dest;
+}
+
+godot_rect2 GDAPI godot_rect2_expand(const godot_rect2 *p_self, const godot_vector2 *p_to) {
+ godot_rect2 dest;
+ const Rect2 *self = (const Rect2 *)p_self;
+ const Vector2 *to = (const Vector2 *)p_to;
+ *((Rect2 *)&dest) = self->expand(*to);
+ return dest;
+}
+
+godot_bool GDAPI godot_rect2_operator_equal(const godot_rect2 *p_self, const godot_rect2 *p_b) {
+ const Rect2 *self = (const Rect2 *)p_self;
+ const Rect2 *b = (const Rect2 *)p_b;
+ return *self == *b;
+}
+
+godot_vector2 GDAPI godot_rect2_get_pos(const godot_rect2 *p_self) {
+ godot_vector2 dest;
+ Vector2 *d = (Vector2 *)&dest;
+ const Rect2 *self = (const Rect2 *)p_self;
+ *d = self->get_pos();
+ return dest;
+}
+
+godot_vector2 GDAPI godot_rect2_get_size(const godot_rect2 *p_self) {
+ godot_vector2 dest;
+ Vector2 *d = (Vector2 *)&dest;
+ const Rect2 *self = (const Rect2 *)p_self;
+ *d = self->get_size();
+ return dest;
+}
+
+void GDAPI godot_rect2_set_pos(godot_rect2 *p_self, const godot_vector2 *p_pos) {
+ Rect2 *self = (Rect2 *)p_self;
+ const Vector2 *pos = (const Vector2 *)p_pos;
+ self->set_pos(*pos);
}
-void GDAPI godot_rect2_set_size(godot_rect2 *p_rect, const godot_vector2 *p_size) {
- Rect2 *rect = (Rect2 *)p_rect;
+void GDAPI godot_rect2_set_size(godot_rect2 *p_self, const godot_vector2 *p_size) {
+ Rect2 *self = (Rect2 *)p_self;
const Vector2 *size = (const Vector2 *)p_size;
- rect->size = *size;
+ self->set_size(*size);
}
#ifdef __cplusplus