#ifndef UI_TREE_H
#define UI_TREE_H
#include "toolkit.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct UiModel UiModel;
typedef struct UiListCallbacks UiListCallbacks;
typedef struct UiListDnd UiListDnd;
typedef struct UiListArgs UiListArgs;
typedef struct UiSourceListArgs UiSourceListArgs;
typedef struct UiSubList UiSubList;
typedef struct UiSubListItem UiSubListItem;
typedef enum UiModelType {
UI_STRING =
0,
UI_STRING_FREE,
UI_INTEGER,
UI_ICON,
UI_ICON_TEXT,
UI_ICON_TEXT_FREE
} UiModelType;
struct UiModel {
int columns;
UiModelType *types;
char **titles;
int *columnsize;
void*(*getvalue)(
void*,
int);
};
struct UiListCallbacks {
ui_callback activate;
ui_callback selection;
void *userdata;
};
struct UiListArgs {
UiTri fill;
UiBool hexpand;
UiBool vexpand;
UiBool hfill;
UiBool vfill;
int colspan;
int rowspan;
const char *name;
const char *style_class;
UiList* list;
const char* varname;
UiModel* model;
ui_getvaluefunc getvalue;
ui_callback onactivate;
void* onactivatedata;
ui_callback onselection;
void* onselectiondata;
ui_callback ondragstart;
void* ondragstartdata;
ui_callback ondragcomplete;
void* ondragcompletedata;
ui_callback ondrop;
void* ondropsdata;
UiBool multiselection;
UiMenuBuilder *contextmenu;
const int *groups;
};
typedef void (*ui_sublist_getvalue_func)(
void *sublist_userdata,
void *rowdata,
int index, UiSubListItem *item);
struct UiSubList {
UiList *value;
const char *varname;
const char *header;
UiBool separator;
void *userdata;
};
struct UiSubListItem {
char *icon;
char *label;
char *button_icon;
char *button_label;
char *badge;
void *eventdata;
};
struct UiSourceListArgs {
UiTri fill;
UiBool hexpand;
UiBool vexpand;
UiBool hfill;
UiBool vfill;
int colspan;
int rowspan;
const char *name;
const char *style_class;
const int *groups;
UiSubList *sublists;
size_t numsublists;
ui_sublist_getvalue_func getvalue;
ui_callback onactivate;
void *onactivatedata;
ui_callback onbuttonclick;
void *onbuttonclickdata;
};
#define UI_SUBLIST(...) (UiSubList){
__VA_ARGS__ }
#define UI_SUBLISTS(...) (UiSubList[]){
__VA_ARGS__, (UiSubList){
NULL,
NULL,
NULL,
0} }
UIEXPORT UiModel* ui_model(UiContext *ctx, ...);
UIEXPORT UiModel* ui_model_copy(UiContext *ctx, UiModel* model);
UIEXPORT void ui_model_free(UiContext *ctx, UiModel *mi);
#define ui_listview(obj, ...) ui_listview_create(obj, (UiListArgs) {
__VA_ARGS__ } )
#define ui_table(obj, ...) ui_table_create(obj, (UiListArgs) {
__VA_ARGS__ } )
#define ui_combobox(obj, ...) ui_combobox_create(obj, (UiListArgs) {
__VA_ARGS__ } )
#define ui_breadcrumbbar(obj, ...) ui_breadcrumbbar_create(obj, (UiListArgs) {
__VA_ARGS__ } )
#define ui_sourcelist(obj, ...) ui_sourcelist_create(obj, (UiSourceListArgs) {
__VA_ARGS__ } )
UIEXPORT UIWIDGET ui_listview_create(UiObject* obj, UiListArgs args);
UIEXPORT UIWIDGET ui_table_create(UiObject* obj, UiListArgs args);
UIEXPORT UIWIDGET ui_combobox_create(UiObject* obj, UiListArgs args);
UIEXPORT UIWIDGET ui_breadcrumbbar_create(UiObject* obj, UiListArgs args);
UIEXPORT UIWIDGET ui_sourcelist_create(UiObject *obj, UiSourceListArgs args);
#ifdef __cplusplus
}
#endif
#endif