aboutsummaryrefslogtreecommitdiff
path: root/include/mgui
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-12-07 20:20:27 +0100
committerdec05eba <dec05eba@protonmail.com>2021-12-07 20:20:27 +0100
commit864ee5f167d1e2dda9bfce24ef617d71ce49bfd8 (patch)
tree14c3bfe2d9b28dce43be9efae8e18156de7787fc /include/mgui
parentd3a5b3d579e30ce02afd5e270dfdd511af195c31 (diff)
scrollview
Diffstat (limited to 'include/mgui')
-rw-r--r--include/mgui/mgui.h12
-rw-r--r--include/mgui/scrollview.h28
-rw-r--r--include/mgui/widget.h1
3 files changed, 41 insertions, 0 deletions
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