aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/common.h3
-rw-r--r--include/mgui/mgui.h12
-rw-r--r--include/mgui/scrollview.h28
-rw-r--r--include/mgui/widget.h1
4 files changed, 44 insertions, 0 deletions
diff --git a/include/common.h b/include/common.h
index 3fb4f6f..b60476c 100644
--- a/include/common.h
+++ b/include/common.h
@@ -4,6 +4,9 @@
#include <mgl/system/vec.h>
#include <stdbool.h>
+typedef struct mgl_window mgl_window;
+
bool mgui_rectangle_contains(mgl_vec2f rectangle_pos, mgl_vec2f rectangle_size, mgl_vec2f point);
+bool mgui_rectangle_intersects_with_scissor(mgl_vec2i rectangle_pos, mgl_vec2i rectangle_size, mgl_window *window);
#endif /* MGUI_COMMON_H */
diff --git a/include/mgui/mgui.h b/include/mgui/mgui.h
new file mode 100644
index 0000000..d76226f
--- /dev/null
+++ b/include/mgui/mgui.h
@@ -0,0 +1,12 @@
+#ifndef MGUI_H
+#define MGUI_H
+
+typedef struct mgui_widget mgui_widget;
+typedef struct mgl_window mgl_window;
+
+void mgui_init();
+void mgui_draw(mgui_widget *root_widget, mgl_window *window);
+/* Clamped to 1.0 second */
+double mgui_get_seconds_since_last_update();
+
+#endif /* MGUI_H */
diff --git a/include/mgui/scrollview.h b/include/mgui/scrollview.h
new file mode 100644
index 0000000..d394e50
--- /dev/null
+++ b/include/mgui/scrollview.h
@@ -0,0 +1,28 @@
+#ifndef MGUI_SCROLLVIEW_H
+#define MGUI_SCROLLVIEW_H
+
+#include "widget.h"
+
+typedef struct {
+ mgui_widget widget;
+ mgui_widget *child;
+ mgl_vec2i child_size;
+ mgl_vec2i position;
+ mgl_vec2i size;
+ mgl_vec2i scroll;
+ mgl_vec2f mouse_scroll;
+} mgui_scrollview;
+
+mgui_scrollview* mgui_scrollview_create();
+mgui_widget* mgui_scrollview_to_widget(mgui_scrollview *list);
+mgui_scrollview* mgui_widget_to_scrollview(mgui_widget *widget);
+
+void mgui_scrollview_set_child(mgui_scrollview *self, mgui_widget *child);
+void mgui_scrollview_set_position(mgui_scrollview *self, mgl_vec2i position);
+void mgui_scrollview_set_size(mgui_scrollview *self, mgl_vec2i size);
+void mgui_scrollview_set_width(mgui_scrollview *self, int width);
+void mgui_scrollview_on_event(mgui_scrollview *self, mgl_window *window, mgl_event *event);
+/* Returns the size of the widget */
+mgl_vec2i mgui_scrollview_draw(mgui_scrollview *self, mgl_window *window);
+
+#endif /* MGUI_SCROLLVIEW_H */
diff --git a/include/mgui/widget.h b/include/mgui/widget.h
index ec19a98..2edc3b1 100644
--- a/include/mgui/widget.h
+++ b/include/mgui/widget.h
@@ -9,6 +9,7 @@ typedef struct mgui_widget mgui_widget;
typedef enum {
MGUI_WIDGET_LIST,
+ MGUI_WIDGET_SCROLLVIEW,
MGUI_WIDGET_BUTTON,
MGUI_WIDGET_LABEL,
MGUI_WIDGET_IMAGE