diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-12-08 03:37:27 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-12-08 03:37:27 +0100 |
commit | 319accba370d3f0872501de6386833fea140fbac (patch) | |
tree | f024ac1070837693b39b6624eea3bd104f8a0f0b /include | |
parent | 864ee5f167d1e2dda9bfce24ef617d71ce49bfd8 (diff) |
Add richtext, support multi language
Diffstat (limited to 'include')
-rw-r--r-- | include/mgui/richtext.h | 38 | ||||
-rw-r--r-- | include/mgui/widget.h | 1 |
2 files changed, 39 insertions, 0 deletions
diff --git a/include/mgui/richtext.h b/include/mgui/richtext.h new file mode 100644 index 0000000..52706f5 --- /dev/null +++ b/include/mgui/richtext.h @@ -0,0 +1,38 @@ +#ifndef MGUI_RICHTEXT_H +#define MGUI_RICHTEXT_H + +#include "widget.h" +#include <stddef.h> +#include <stdbool.h> + +typedef struct mgl_vertex mgl_vertex; + +typedef struct { + mgl_vertex *vertices; + size_t vertices_capacity; + size_t vertex_count; +} mgui_richtext_vertex_data; + +typedef struct { + mgui_widget widget; + char *str; + size_t str_size; + unsigned int character_size; + mgl_vec2i position; + mgl_vec2i render_size; + int width; + mgui_richtext_vertex_data vertex_data[2]; + bool dirty; +} mgui_richtext; + +mgui_richtext* mgui_richtext_create(const char *str, size_t size, unsigned char character_size); +mgui_widget* mgui_richtext_to_widget(mgui_richtext *list); +mgui_richtext* mgui_widget_to_richtext(mgui_widget *widget); + +void mgui_richtext_set_position(mgui_richtext *self, mgl_vec2i position); +void mgui_richtext_set_width(mgui_richtext *self, int width); +void mgui_richtext_on_event(mgui_richtext *self, mgl_window *window, mgl_event *event); +/* Returns the size of the widget */ +mgl_vec2i mgui_richtext_draw(mgui_richtext *self, mgl_window *window); + +#endif /* MGUI_RICHTEXT_H */ diff --git a/include/mgui/widget.h b/include/mgui/widget.h index 2edc3b1..ee3a9f1 100644 --- a/include/mgui/widget.h +++ b/include/mgui/widget.h @@ -12,6 +12,7 @@ typedef enum { MGUI_WIDGET_SCROLLVIEW, MGUI_WIDGET_BUTTON, MGUI_WIDGET_LABEL, + MGUI_WIDGET_RICHTEXT, MGUI_WIDGET_IMAGE } mgui_widget_type; |