aboutsummaryrefslogtreecommitdiff
path: root/include/mgui/list.h
blob: 92dce0af8b816a3634cc529b34206ed84bba3531 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef MGUI_LIST_H
#define MGUI_LIST_H

#include "widget.h"
#include <stddef.h>
#include <stdint.h>
#include <mgl/graphics/color.h>

typedef struct mgl_window mgl_window;
typedef struct mgl_event mgl_event;

typedef enum {
    MGUI_LIST_HORIZONITAL,
    MGUI_LIST_VERTICAL
} mgui_list_direction;

typedef struct {
    mgui_widget *widget;
} mgui_list_item;

typedef struct {
    mgui_widget widget;
    mgui_list_direction direction;
    int spacing;
    mgl_vec2i position;
    mgui_list_item *items;
    size_t items_capacity;
    size_t num_items;
} mgui_list;

mgui_list* mgui_list_create(mgui_list_direction direction);
void mgui_list_destroy(mgui_list *list);
mgui_widget* mgui_list_to_widget(mgui_list *list);
mgui_list* mgui_widget_to_list(mgui_widget *widget);

void mgui_list_set_spacing(mgui_list *self, int spacing);
void mgui_list_set_position(mgui_list *self, mgl_vec2i position);
void mgui_list_calculate_size(mgui_list *self, mgl_vec2i max_size);
void mgui_list_append(mgui_list *self, mgui_widget *widget);
void mgui_list_on_event(mgui_list *self, mgl_window *window, mgl_event *event);
void mgui_list_draw(mgui_list *self, mgl_window *window);

#endif /* MGUI_LIST_H */