summaryrefslogtreecommitdiff
path: root/src/bin/egui_gui/props_helper.h
blob: 866e0c7709cec863cff30ea4f32e899689e0fc50 (plain) (blame)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#ifndef _PROPS_HELPER_H
#define _PROPS_HELPER_H

#include <Evas.h>
#include "gui_widget.h"
#include "egui_layout.h"

#define PROP_HOVERSEL_NONE_VALUE "                           "

/* pass Gui_Widget or Item_Container_Item */
#define IT_DATA_BUILD(type_v, wi) \
   ({ \
    It_Data *_it = calloc(1, sizeof(It_Data)); \
    _it->type = type_v; \
    if (type_v == ITEM_TYPE) \
    {\
      _it->item = (Item_Container_Item *) wi; \
    }\
    else \
    { \
      _it->wdg = (Gui_Widget *)(wi); \
    }\
    _it; \
    })

#define _STR_EDITOR "editor"

typedef enum
{
   DESCRIPTION_TYPE, // description view
   PROPERTY_TYPE,    // properties view
   CALLBACK_TYPE,     // callback view
   CONTENT_TYPE,     // content view
   ITEM_TYPE     // content->item view
} It_Data_Type;

/* Struct to assosiate item with its data: widget and op_desc */
typedef struct
{
   It_Data_Type type;
   union
     {
        const Gui_Widget *wdg;
        const Item_Container_Item *item;
     };
   union
     {
        /* Property and Content. */
        struct
          {
             /* This Op_Desc is needed when we want to create empty property or content. */
             /* For both: property and container. */
             const Op_Desc *op_desc;
             const Gui_Widget_Property *prop;
             /* Index of content in container. */
             int idx;
          };
        /* Callback */
        Gui_Widget_Callback *cb;

        /* Description */
        char *desc;

     };
   Eo *box;
   Egui_Layout_Cb_Item_Widgets *cb_wdgs;
   Eina_List *cb_dyn_objs;
} It_Data;

/* Struct to assosiate item's value edit field with its data: item_data and par index */
typedef struct
{
   It_Data *it_data;
   int par_idx;
} Par_Field_Data;

typedef struct
{
   char* classname;
   const Gui_Widget *wdg;
} Classname_Data;

void
_it_data_free(void *data);

Eo *
props_entry_add(Eo *box, const char *str, Gui_Type t);

Eo *
props_label_add(Eo *box, const char *str);

Eo *
props_check_add(Eo *box, Eina_Bool state);

Eo *
props_button_add(Eo *box, char *text);

Eo *
props_hoversel_enums_add(Eo *box, Eo *hover_parent, const char *default_val, const char **enums_lst);

Eo *
props_hoversel_objects_add(Eo *box, Eo *hoversel, Eo *hover_parent, const char *default_val, const Eina_List *wdgs_list, const Gui_Widget *wdg);

Eo *
props_hoversel_object_ops_add(Eo *box, Eo *hover_parent, const char *default_val, const Gui_Widget *wdg);

Eo *
props_hoversel_resources_add(Eo *box, Eo *hoversel, Eo *hover_parent, const char *default_val, const Gui_Context *ctx, Gui_Resource_Type type);

Eo *
props_value_add(Eo *box, const Gui_Widget *wdg, const Gui_Value *value, const Op_Desc *op, unsigned int par_idx);

const char*
_filter_string_get();

Eina_Bool
_str_nocase_prefix(const char *str, const char *prefix);

void
_prop_field_update(const Gui_Widget_Property *prop, Eo *item_box, It_Data *it_data);

void
_mempool_hash_del(void* data);
void
_mempool_cache_init();
void
_mempool_cache_free();
void*
_mempool_cache_data_get(const char *key);
void
_mempool_cache_data_put(const char *key, void *ptr);
#endif