From 319accba370d3f0872501de6386833fea140fbac Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 8 Dec 2021 03:37:27 +0100 Subject: Add richtext, support multi language --- include/mgui/richtext.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 include/mgui/richtext.h (limited to 'include/mgui/richtext.h') 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 +#include + +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 */ -- cgit v1.2.3