~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to source/blender/makesrna/intern/rna_ui_api.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#include <stdlib.h>
33
33
#include <stdio.h>
34
34
 
 
35
#include "BLI_utildefines.h"
 
36
 
 
37
#include "BLF_translation.h"
 
38
 
35
39
#include "RNA_define.h"
 
40
#include "RNA_enum_types.h"
 
41
 
 
42
#include "DNA_screen_types.h"
36
43
 
37
44
#include "UI_resources.h"
38
 
 
39
 
#ifdef RNA_RUNTIME
40
 
 
41
 
static void rna_uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, const char *name, int icon,
42
 
                        int expand, int slider, int toggle, int icon_only, int event, int full_event,
43
 
                        int emboss, int index)
44
 
{
45
 
        PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
46
 
        int flag = 0;
47
 
 
48
 
        if (!prop) {
49
 
                RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
50
 
                return;
51
 
        }
52
 
 
53
 
        flag |= (slider)? UI_ITEM_R_SLIDER: 0;
54
 
        flag |= (expand)? UI_ITEM_R_EXPAND: 0;
55
 
        flag |= (toggle)? UI_ITEM_R_TOGGLE: 0;
56
 
        flag |= (icon_only)? UI_ITEM_R_ICON_ONLY: 0;
57
 
        flag |= (event)? UI_ITEM_R_EVENT: 0;
58
 
        flag |= (full_event)? UI_ITEM_R_FULL_EVENT: 0;
59
 
        flag |= (emboss)? 0: UI_ITEM_R_NO_BG;
60
 
 
61
 
        uiItemFullR(layout, ptr, prop, index, 0, flag, name, icon);
62
 
}
63
 
 
64
 
static PointerRNA rna_uiItemO(uiLayout *layout, const char *opname, const char *name, int icon, int emboss)
65
 
{
66
 
        int flag = UI_ITEM_O_RETURN_PROPS;
67
 
        flag |= (emboss)? 0: UI_ITEM_R_NO_BG;
68
 
        return uiItemFullO(layout, opname, name, icon, NULL, uiLayoutGetOperatorContext(layout), flag);
69
 
}
70
 
 
71
 
#else
 
45
#include "UI_interface.h"
 
46
#include "UI_interface_icons.h"
 
47
 
 
48
#include "rna_internal.h"
72
49
 
73
50
#define DEF_ICON_BLANK_SKIP
74
51
#define DEF_ICON(name) {ICON_##name, (#name), 0, (#name), ""},
75
52
#define DEF_VICO(name) {VICO_##name, (#name), 0, (#name), ""},
76
 
static EnumPropertyItem icon_items[] = {
 
53
EnumPropertyItem icon_items[] = {
77
54
#include "UI_icons.h"
78
 
                {0, NULL, 0, NULL, NULL}};
 
55
        {0, NULL, 0, NULL, NULL}
 
56
};
79
57
#undef DEF_ICON_BLANK_SKIP
80
58
#undef DEF_ICON
81
59
#undef DEF_VICO
82
60
 
 
61
#ifdef RNA_RUNTIME
 
62
 
 
63
static const char *rna_translate_ui_text(const char *text, const char *text_ctxt, StructRNA *type, PropertyRNA *prop,
 
64
                                         int translate)
 
65
{
 
66
        /* Also return text if UI labels translation is disabled. */
 
67
        if (!text || !text[0] || !translate || !BLF_translate_iface()) {
 
68
                return text;
 
69
        }
 
70
 
 
71
        /* If a text_ctxt is specified, use it! */
 
72
        if (text_ctxt && text_ctxt[0]) {
 
73
                return BLF_pgettext(text_ctxt, text);
 
74
        }
 
75
 
 
76
        /* Else, if an RNA type or property is specified, use its context. */
 
77
#if 0
 
78
        /* XXX Disabled for now. Unfortunately, their is absolutely no way from py code to get the RNA struct corresponding
 
79
         *     to the 'data' (in functions like prop() & co), as this is pure runtime data. Hence, messages extraction
 
80
         *     script can't determine the correct context it should use for such 'text' messages...
 
81
         *     So for now, one have to explicitly specify the 'text_ctxt' when using prop() etc. functions,
 
82
         *     if default context is not suitable.
 
83
         */
 
84
        if (prop) {
 
85
                return BLF_pgettext(RNA_property_translation_context(prop), text);
 
86
        }
 
87
#else
 
88
        (void)prop;
 
89
#endif
 
90
        if (type) {
 
91
                return BLF_pgettext(RNA_struct_translation_context(type), text);
 
92
        }
 
93
 
 
94
        /* Else, default context! */
 
95
        return BLF_pgettext(BLF_I18NCONTEXT_DEFAULT, text);
 
96
}
 
97
 
 
98
static void rna_uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, const char *name, const char *text_ctxt,
 
99
                        int translate, int icon, int expand, int slider, int toggle, int icon_only, int event,
 
100
                        int full_event, int emboss, int index)
 
101
{
 
102
        PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
 
103
        int flag = 0;
 
104
 
 
105
        if (!prop) {
 
106
                RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
 
107
                return;
 
108
        }
 
109
 
 
110
        /* Get translated name (label). */
 
111
        name = rna_translate_ui_text(name, text_ctxt, NULL, prop, translate);
 
112
 
 
113
        flag |= (slider) ? UI_ITEM_R_SLIDER : 0;
 
114
        flag |= (expand) ? UI_ITEM_R_EXPAND : 0;
 
115
        flag |= (toggle) ? UI_ITEM_R_TOGGLE : 0;
 
116
        flag |= (icon_only) ? UI_ITEM_R_ICON_ONLY : 0;
 
117
        flag |= (event) ? UI_ITEM_R_EVENT : 0;
 
118
        flag |= (full_event) ? UI_ITEM_R_FULL_EVENT : 0;
 
119
        flag |= (emboss) ? 0 : UI_ITEM_R_NO_BG;
 
120
 
 
121
        uiItemFullR(layout, ptr, prop, index, 0, flag, name, icon);
 
122
}
 
123
 
 
124
static void rna_uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name,
 
125
                                const char *text_ctxt, int translate, int icon)
 
126
{
 
127
        PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
 
128
 
 
129
        if (!prop) {
 
130
                RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
 
131
                return;
 
132
        }
 
133
 
 
134
        /* Get translated name (label). */
 
135
        name = rna_translate_ui_text(name, text_ctxt, NULL, prop, translate);
 
136
 
 
137
        /* XXX This will search property again :( */
 
138
        uiItemMenuEnumR(layout, ptr, propname, name, icon);
 
139
}
 
140
 
 
141
static void rna_uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *value,
 
142
                                   const char *name, const char *text_ctxt, int translate, int icon)
 
143
{
 
144
        PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
 
145
 
 
146
        if (!prop) {
 
147
                RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
 
148
                return;
 
149
        }
 
150
 
 
151
        /* Get translated name (label). */
 
152
        name = rna_translate_ui_text(name, text_ctxt, NULL, prop, translate);
 
153
 
 
154
        /* XXX This will search property again :( */
 
155
        uiItemEnumR_string(layout, ptr, propname, value, name, icon);
 
156
}
 
157
 
 
158
static void rna_uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propname,
 
159
                               struct PointerRNA *searchptr, const char *searchpropname,
 
160
                               const char *name, const char *text_ctxt, int translate, int icon)
 
161
{
 
162
        PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
 
163
 
 
164
        if (!prop) {
 
165
                RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
 
166
                return;
 
167
        }
 
168
 
 
169
        /* Get translated name (label). */
 
170
        name = rna_translate_ui_text(name, text_ctxt, NULL, prop, translate);
 
171
 
 
172
        /* XXX This will search property again :( */
 
173
        uiItemPointerR(layout, ptr, propname, searchptr, searchpropname, name, icon);
 
174
}
 
175
 
 
176
static PointerRNA rna_uiItemO(uiLayout *layout, const char *opname, const char *name, const char *text_ctxt,
 
177
                              int translate, int icon, int emboss)
 
178
{
 
179
        wmOperatorType *ot;
 
180
        int flag;
 
181
 
 
182
        ot = WM_operatortype_find(opname, 0); /* print error next */
 
183
        if (!ot || !ot->srna) {
 
184
                RNA_warning("%s '%s'", ot ? "unknown operator" : "operator missing srna", opname);
 
185
                return PointerRNA_NULL;
 
186
        }
 
187
 
 
188
        /* Get translated name (label). */
 
189
        name = rna_translate_ui_text(name, text_ctxt, ot->srna, NULL, translate);
 
190
 
 
191
        flag = UI_ITEM_O_RETURN_PROPS;
 
192
        flag |= (emboss) ? 0 : UI_ITEM_R_NO_BG;
 
193
 
 
194
        return uiItemFullO_ptr(layout, ot, name, icon, NULL, uiLayoutGetOperatorContext(layout), flag);
 
195
}
 
196
 
 
197
static void rna_uiItemMenuEnumO(uiLayout *layout, const char *opname, const char *propname, const char *name,
 
198
                                const char *text_ctxt, int translate, int icon)
 
199
{
 
200
        wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
 
201
 
 
202
        if (!ot || !ot->srna) {
 
203
                RNA_warning("%s '%s'", ot ? "unknown operator" : "operator missing srna", opname);
 
204
                return;
 
205
        }
 
206
 
 
207
        /* Get translated name (label). */
 
208
        name = rna_translate_ui_text(name, text_ctxt, ot->srna, NULL, translate);
 
209
 
 
210
        /* XXX This will search operator again :( */
 
211
        uiItemMenuEnumO(layout, opname, propname, name, icon);
 
212
}
 
213
 
 
214
static void rna_uiItemL(uiLayout *layout, const char *name, const char *text_ctxt, int translate,
 
215
                        int icon, int icon_value)
 
216
{
 
217
        /* Get translated name (label). */
 
218
        name = rna_translate_ui_text(name, text_ctxt, NULL, NULL, translate);
 
219
 
 
220
        if (icon_value && !icon) {
 
221
                icon = icon_value;
 
222
        }
 
223
 
 
224
        uiItemL(layout, name, icon);
 
225
}
 
226
 
 
227
static void rna_uiItemM(uiLayout *layout, bContext *C, const char *menuname, const char *name, const char *text_ctxt,
 
228
                        int translate, int icon)
 
229
{
 
230
        /* Get translated name (label). */
 
231
        name = rna_translate_ui_text(name, text_ctxt, NULL, NULL, translate);
 
232
 
 
233
        uiItemM(layout, C, menuname, name, icon);
 
234
}
 
235
 
 
236
static void rna_uiTemplateAnyID(uiLayout *layout, PointerRNA *ptr, const char *propname, const char *proptypename,
 
237
                                const char *name, const char *text_ctxt, int translate)
 
238
{
 
239
        PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
 
240
 
 
241
        if (!prop) {
 
242
                RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
 
243
                return;
 
244
        }
 
245
 
 
246
        /* Get translated name (label). */
 
247
        name = rna_translate_ui_text(name, text_ctxt, NULL, prop, translate);
 
248
 
 
249
        /* XXX This will search property again :( */
 
250
        uiTemplateAnyID(layout, ptr, propname, proptypename, name);
 
251
}
 
252
 
 
253
static void rna_uiTemplatePathBuilder(uiLayout *layout, PointerRNA *ptr, const char *propname, PointerRNA *root_ptr,
 
254
                                      const char *name, const char *text_ctxt, int translate)
 
255
{
 
256
        PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
 
257
 
 
258
        if (!prop) {
 
259
                RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
 
260
                return;
 
261
        }
 
262
 
 
263
        /* Get translated name (label). */
 
264
        name = rna_translate_ui_text(name, text_ctxt, NULL, prop, translate);
 
265
 
 
266
        /* XXX This will search property again :( */
 
267
        uiTemplatePathBuilder(layout, ptr, propname, root_ptr, name);
 
268
}
 
269
 
 
270
static int rna_ui_get_rnaptr_icon(bContext *C, PointerRNA *ptr_icon)
 
271
{
 
272
        return UI_rnaptr_icon_get(C, ptr_icon, RNA_struct_ui_icon(ptr_icon->type), FALSE);
 
273
}
 
274
 
 
275
static const char *rna_ui_get_enum_name(bContext *C, PointerRNA *ptr, const char *propname, const char *identifier)
 
276
{
 
277
        PropertyRNA *prop = NULL;
 
278
        EnumPropertyItem *items = NULL, *item;
 
279
        int free;
 
280
        const char *name = "";
 
281
 
 
282
        prop = RNA_struct_find_property(ptr, propname);
 
283
        if (!prop || (RNA_property_type(prop) != PROP_ENUM)) {
 
284
                RNA_warning("Property not found or not an enum: %s.%s", RNA_struct_identifier(ptr->type), propname);
 
285
                return name;
 
286
        }
 
287
 
 
288
        RNA_property_enum_items_gettexted(C, ptr, prop, &items, NULL, &free);
 
289
 
 
290
        if (items) {
 
291
                for (item = items; item->identifier; item++) {
 
292
                        if (item->identifier[0] && strcmp(item->identifier, identifier) == 0) {
 
293
                                name = item->name;
 
294
                                break;
 
295
                        }
 
296
                }
 
297
                if (free) {
 
298
                        MEM_freeN(items);
 
299
                }
 
300
        }
 
301
 
 
302
        return name;
 
303
}
 
304
 
 
305
static const char *rna_ui_get_enum_description(bContext *C, PointerRNA *ptr, const char *propname,
 
306
                                               const char *identifier)
 
307
{
 
308
        PropertyRNA *prop = NULL;
 
309
        EnumPropertyItem *items = NULL, *item;
 
310
        int free;
 
311
        const char *desc = "";
 
312
 
 
313
        prop = RNA_struct_find_property(ptr, propname);
 
314
        if (!prop || (RNA_property_type(prop) != PROP_ENUM)) {
 
315
                RNA_warning("Property not found or not an enum: %s.%s", RNA_struct_identifier(ptr->type), propname);
 
316
                return desc;
 
317
        }
 
318
 
 
319
        RNA_property_enum_items_gettexted(C, ptr, prop, &items, NULL, &free);
 
320
 
 
321
        if (items) {
 
322
                for (item = items; item->identifier; item++) {
 
323
                        if (item->identifier[0] && strcmp(item->identifier, identifier) == 0) {
 
324
                                desc = item->description;
 
325
                                break;
 
326
                        }
 
327
                }
 
328
                if (free) {
 
329
                        MEM_freeN(items);
 
330
                }
 
331
        }
 
332
 
 
333
        return desc;
 
334
}
 
335
 
 
336
static int rna_ui_get_enum_icon(bContext *C, PointerRNA *ptr, const char *propname, const char *identifier)
 
337
{
 
338
        PropertyRNA *prop = NULL;
 
339
        EnumPropertyItem *items = NULL, *item;
 
340
        int free;
 
341
        int icon = ICON_NONE;
 
342
 
 
343
        prop = RNA_struct_find_property(ptr, propname);
 
344
        if (!prop || (RNA_property_type(prop) != PROP_ENUM)) {
 
345
                RNA_warning("Property not found or not an enum: %s.%s", RNA_struct_identifier(ptr->type), propname);
 
346
                return icon;
 
347
        }
 
348
 
 
349
        RNA_property_enum_items(C, ptr, prop, &items, NULL, &free);
 
350
 
 
351
        if (items) {
 
352
                for (item = items; item->identifier; item++) {
 
353
                        if (item->identifier[0] && strcmp(item->identifier, identifier) == 0) {
 
354
                                icon = item->icon;
 
355
                                break;
 
356
                        }
 
357
                }
 
358
                if (free) {
 
359
                        MEM_freeN(items);
 
360
                }
 
361
        }
 
362
 
 
363
        return icon;
 
364
}
 
365
 
 
366
#else
 
367
 
 
368
static void api_ui_item_common_text(FunctionRNA *func)
 
369
{
 
370
        RNA_def_string(func, "text", "", 0, "", "Override automatic text of the item");
 
371
        RNA_def_string(func, "text_ctxt", "", 0, "", "Override automatic translation context of the given text");
 
372
        RNA_def_boolean(func, "translate", true, "", "Translate the given text, when UI translation is enabled");
 
373
}
 
374
 
83
375
static void api_ui_item_common(FunctionRNA *func)
84
376
{
85
377
        PropertyRNA *prop;
86
378
 
87
 
        RNA_def_string_translate(func, "text", "", 0, "", "Override automatic text of the item");
 
379
        api_ui_item_common_text(func);
88
380
 
89
381
        prop = RNA_def_property(func, "icon", PROP_ENUM, PROP_NONE);
90
382
        RNA_def_property_enum_items(prop, icon_items);
91
383
        RNA_def_property_ui_text(prop, "Icon", "Override automatic icon of the item");
92
 
 
93
384
}
94
385
 
95
386
static void api_ui_item_op(FunctionRNA *func)
110
401
        PropertyRNA *parm;
111
402
 
112
403
        parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property");
113
 
        RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL);
 
404
        RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR | PROP_NEVER_NULL);
114
405
        parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in data");
115
406
        RNA_def_property_flag(parm, PROP_REQUIRED);
116
407
}
124
415
                {0, "NONE", 0, "None", ""},
125
416
                {'v', "VECTOR", 0, "Vector", ""},
126
417
                {'c', "COLOR", 0, "Color", ""},
127
 
                {0, NULL, 0, NULL, NULL}};
128
 
        
129
 
        static EnumPropertyItem list_type_items[] = {
130
 
                {0, "DEFAULT", 0, "None", ""},
131
 
                {'c', "COMPACT", 0, "Compact", ""},
132
 
                {'i', "ICONS", 0, "Icons", ""},
133
 
                {0, NULL, 0, NULL, NULL}};
 
418
                {'h', "HUE", 0, "Hue", ""},
 
419
                {0, NULL, 0, NULL, NULL}
 
420
        };
134
421
 
135
422
        /* simple layout specifiers */
136
423
        func = RNA_def_function(srna, "row", "uiLayoutRow");
160
447
        parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
161
448
        RNA_def_function_return(func, parm);
162
449
        RNA_def_function_ui_description(func, "Sublayout (items placed in this sublayout are placed "
163
 
                                              "under each other in a column and are surrounded by a box)");
 
450
                                        "under each other in a column and are surrounded by a box)");
164
451
        
165
452
        /* split layout */
166
453
        func = RNA_def_function(srna, "split", "uiLayoutSplit");
169
456
        RNA_def_float(func, "percentage", 0.0f, 0.0f, 1.0f, "Percentage", "Percentage of width to split at", 0.0f, 1.0f);
170
457
        RNA_def_boolean(func, "align", 0, "", "Align buttons to each other");
171
458
 
 
459
        /* Icon of a rna pointer */
 
460
        func = RNA_def_function(srna, "icon", "rna_ui_get_rnaptr_icon");
 
461
        parm = RNA_def_int(func, "icon_value", ICON_NONE, 0, INT_MAX, "", "Icon identifier", 0, INT_MAX);
 
462
        RNA_def_function_return(func, parm);
 
463
        RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT);
 
464
        parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take the icon");
 
465
        RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR | PROP_NEVER_NULL);
 
466
        RNA_def_function_ui_description(func, "Return the custom icon for this data, "
 
467
                                              "use it e.g. to get materials or texture icons");
 
468
 
 
469
        /* UI name, description and icon of an enum item */
 
470
        func = RNA_def_function(srna, "enum_item_name", "rna_ui_get_enum_name");
 
471
        parm = RNA_def_string(func, "name", "", 0, "", "UI name of the enum item");
 
472
        RNA_def_function_return(func, parm);
 
473
        RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT);
 
474
        api_ui_item_rna_common(func);
 
475
        parm = RNA_def_string(func, "identifier", "", 0, "", "Identifier of the enum item");
 
476
        RNA_def_property_flag(parm, PROP_REQUIRED);
 
477
        RNA_def_function_ui_description(func, "Return the UI name for this enum item");
 
478
 
 
479
        func = RNA_def_function(srna, "enum_item_description", "rna_ui_get_enum_description");
 
480
        parm = RNA_def_string(func, "description", "", 0, "", "UI description of the enum item");
 
481
        RNA_def_function_return(func, parm);
 
482
        RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT);
 
483
        api_ui_item_rna_common(func);
 
484
        parm = RNA_def_string(func, "identifier", "", 0, "", "Identifier of the enum item");
 
485
        RNA_def_property_flag(parm, PROP_REQUIRED);
 
486
        RNA_def_function_ui_description(func, "Return the UI description for this enum item");
 
487
 
 
488
        func = RNA_def_function(srna, "enum_item_icon", "rna_ui_get_enum_icon");
 
489
        parm = RNA_def_int(func, "icon_value", ICON_NONE, 0, INT_MAX, "", "Icon identifier", 0, INT_MAX);
 
490
        RNA_def_function_return(func, parm);
 
491
        RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT);
 
492
        api_ui_item_rna_common(func);
 
493
        parm = RNA_def_string(func, "identifier", "", 0, "", "Identifier of the enum item");
 
494
        RNA_def_property_flag(parm, PROP_REQUIRED);
 
495
        RNA_def_function_ui_description(func, "Return the icon for this enum item");
 
496
 
172
497
        /* items */
173
498
        func = RNA_def_function(srna, "prop", "rna_uiItemR");
174
499
        RNA_def_function_ui_description(func, "Item. Exposes an RNA item and places it into the layout");
188
513
        func = RNA_def_function(srna, "props_enum", "uiItemsEnumR");
189
514
        api_ui_item_rna_common(func);
190
515
 
191
 
        func = RNA_def_function(srna, "prop_menu_enum", "uiItemMenuEnumR");
 
516
        func = RNA_def_function(srna, "prop_menu_enum", "rna_uiItemMenuEnumR");
192
517
        api_ui_item_rna_common(func);
193
518
        api_ui_item_common(func);
194
519
 
195
 
        func = RNA_def_function(srna, "prop_enum", "uiItemEnumR_string");
 
520
        func = RNA_def_function(srna, "prop_enum", "rna_uiItemEnumR_string");
196
521
        api_ui_item_rna_common(func);
197
522
        parm = RNA_def_string(func, "value", "", 0, "", "Enum property value");
198
523
        RNA_def_property_flag(parm, PROP_REQUIRED);
199
524
        api_ui_item_common(func);
200
525
 
201
 
        func = RNA_def_function(srna, "prop_search", "uiItemPointerR");
 
526
        func = RNA_def_function(srna, "prop_search", "rna_uiItemPointerR");
202
527
        api_ui_item_rna_common(func);
203
528
        parm = RNA_def_pointer(func, "search_data", "AnyType", "", "Data from which to take collection to search in");
204
 
        RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL);
 
529
        RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR | PROP_NEVER_NULL);
205
530
        parm = RNA_def_string(func, "search_property", "", 0, "", "Identifier of search collection property");
206
531
        RNA_def_property_flag(parm, PROP_REQUIRED);
207
532
        api_ui_item_common(func);
210
535
        api_ui_item_op_common(func);
211
536
        RNA_def_boolean(func, "emboss", 1, "", "Draw the button itself, just the icon/text");
212
537
        parm = RNA_def_pointer(func, "properties", "OperatorProperties", "",
213
 
                              "Operator properties to fill in, return when 'properties' is set to true");
214
 
        RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR);
 
538
                               "Operator properties to fill in, return when 'properties' is set to true");
 
539
        RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR);
215
540
        RNA_def_function_return(func, parm);
216
541
        RNA_def_function_ui_description(func, "Item. Places a button into the layout to call an Operator");
217
542
 
218
 
/*      func= RNA_def_function(srna, "operator_enum_single", "uiItemEnumO_string");
219
 
        api_ui_item_op_common(func);
220
 
        parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator");
221
 
        RNA_def_property_flag(parm, PROP_REQUIRED);
222
 
        parm= RNA_def_string(func, "value", "", 0, "", "Enum property value");
223
 
        RNA_def_property_flag(parm, PROP_REQUIRED); */
224
 
 
225
543
        func = RNA_def_function(srna, "operator_enum", "uiItemsEnumO");
226
544
        parm = RNA_def_string(func, "operator", "", 0, "", "Identifier of the operator");
227
545
        RNA_def_property_flag(parm, PROP_REQUIRED);
228
546
        parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator");
229
547
        RNA_def_property_flag(parm, PROP_REQUIRED);
230
548
 
231
 
        func = RNA_def_function(srna, "operator_menu_enum", "uiItemMenuEnumO");
 
549
        func = RNA_def_function(srna, "operator_menu_enum", "rna_uiItemMenuEnumO");
232
550
        api_ui_item_op(func); /* cant use api_ui_item_op_common because property must come right after */
233
551
        parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator");
234
552
        RNA_def_property_flag(parm, PROP_REQUIRED);
235
553
        api_ui_item_common(func);
236
554
 
237
 
/*      func= RNA_def_function(srna, "operator_boolean", "uiItemBooleanO");
238
 
        api_ui_item_op_common(func);
239
 
        parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator");
240
 
        RNA_def_property_flag(parm, PROP_REQUIRED);
241
 
        parm= RNA_def_boolean(func, "value", 0, "", "Value of the property to call the operator with");
 
555
        /* useful in C but not in python */
 
556
#if 0
 
557
 
 
558
        func = RNA_def_function(srna, "operator_enum_single", "uiItemEnumO_string");
 
559
        api_ui_item_op_common(func);
 
560
        parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator");
 
561
        RNA_def_property_flag(parm, PROP_REQUIRED);
 
562
        parm = RNA_def_string(func, "value", "", 0, "", "Enum property value");
 
563
        RNA_def_property_flag(parm, PROP_REQUIRED);
 
564
 
 
565
        func = RNA_def_function(srna, "operator_boolean", "uiItemBooleanO");
 
566
        api_ui_item_op_common(func);
 
567
        parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator");
 
568
        RNA_def_property_flag(parm, PROP_REQUIRED);
 
569
        parm = RNA_def_boolean(func, "value", 0, "", "Value of the property to call the operator with");
242
570
        RNA_def_property_flag(parm, PROP_REQUIRED); */
243
571
 
244
 
/*      func= RNA_def_function(srna, "operator_int", "uiItemIntO");
 
572
        func = RNA_def_function(srna, "operator_int", "uiItemIntO");
245
573
        api_ui_item_op_common(func);
246
 
        parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator");
 
574
        parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator");
247
575
        RNA_def_property_flag(parm, PROP_REQUIRED);
248
 
        parm= RNA_def_int(func, "value", 0, INT_MIN, INT_MAX, "",
 
576
        parm = RNA_def_int(func, "value", 0, INT_MIN, INT_MAX, "",
249
577
                          "Value of the property to call the operator with", INT_MIN, INT_MAX);
250
578
        RNA_def_property_flag(parm, PROP_REQUIRED); */
251
579
 
252
 
/*      func= RNA_def_function(srna, "operator_float", "uiItemFloatO");
 
580
        func = RNA_def_function(srna, "operator_float", "uiItemFloatO");
253
581
        api_ui_item_op_common(func);
254
 
        parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator");
 
582
        parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator");
255
583
        RNA_def_property_flag(parm, PROP_REQUIRED);
256
 
        parm= RNA_def_float(func, "value", 0, -FLT_MAX, FLT_MAX, "",
 
584
        parm = RNA_def_float(func, "value", 0, -FLT_MAX, FLT_MAX, "",
257
585
                            "Value of the property to call the operator with", -FLT_MAX, FLT_MAX);
258
586
        RNA_def_property_flag(parm, PROP_REQUIRED); */
259
587
 
260
 
/*      func= RNA_def_function(srna, "operator_string", "uiItemStringO");
 
588
        func = RNA_def_function(srna, "operator_string", "uiItemStringO");
261
589
        api_ui_item_op_common(func);
262
 
        parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator");
263
 
        RNA_def_property_flag(parm, PROP_REQUIRED);
264
 
        parm= RNA_def_string(func, "value", "", 0, "", "Value of the property to call the operator with");
265
 
        RNA_def_property_flag(parm, PROP_REQUIRED); */
266
 
 
267
 
        func = RNA_def_function(srna, "label", "uiItemL");
268
 
        RNA_def_function_ui_description(func, "Item. Display text in the layout");
269
 
        api_ui_item_common(func);
270
 
 
271
 
        func = RNA_def_function(srna, "menu", "uiItemM");
 
590
        parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator");
 
591
        RNA_def_property_flag(parm, PROP_REQUIRED);
 
592
        parm = RNA_def_string(func, "value", "", 0, "", "Value of the property to call the operator with");
 
593
        RNA_def_property_flag(parm, PROP_REQUIRED);
 
594
#endif
 
595
 
 
596
        func = RNA_def_function(srna, "label", "rna_uiItemL");
 
597
        RNA_def_function_ui_description(func, "Item. Display text and/or icon in the layout");
 
598
         api_ui_item_common(func);
 
599
        parm = RNA_def_property(func, "icon_value", PROP_INT, PROP_UNSIGNED);
 
600
        RNA_def_property_ui_text(parm, "Icon Value",
 
601
                                 "Override automatic icon of the item "
 
602
                                 "(use it e.g. with custom material icons returned by icon()...)");
 
603
 
 
604
        func = RNA_def_function(srna, "menu", "rna_uiItemM");
272
605
        RNA_def_function_flag(func, FUNC_USE_CONTEXT);
273
606
        parm = RNA_def_string(func, "menu", "", 0, "", "Identifier of the menu");
274
607
        api_ui_item_common(func);
282
615
        parm = RNA_def_string(func, "name", "", 0, "Name", "Name of entry in the context");
283
616
        RNA_def_property_flag(parm, PROP_REQUIRED);
284
617
        parm = RNA_def_pointer(func, "data", "AnyType", "", "Pointer to put in context");
285
 
        RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR);
 
618
        RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR);
286
619
        
287
620
        /* templates */
288
621
        func = RNA_def_function(srna, "template_header", "uiTemplateHeader");
305
638
        RNA_def_int(func, "rows", 0, 0, INT_MAX, "Number of thumbnail preview rows to display", "", 0, INT_MAX);
306
639
        RNA_def_int(func, "cols", 0, 0, INT_MAX, "Number of thumbnail preview columns to display", "", 0, INT_MAX);
307
640
        
308
 
        func = RNA_def_function(srna, "template_any_ID", "uiTemplateAnyID");
 
641
        func = RNA_def_function(srna, "template_any_ID", "rna_uiTemplateAnyID");
309
642
        parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property");
310
 
        RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL);
 
643
        RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR | PROP_NEVER_NULL);
311
644
        parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in data");
312
645
        RNA_def_property_flag(parm, PROP_REQUIRED);
313
646
        parm = RNA_def_string(func, "type_property", "", 0, "",
314
 
                             "Identifier of property in data giving the type of the ID-blocks to use");
 
647
                              "Identifier of property in data giving the type of the ID-blocks to use");
315
648
        RNA_def_property_flag(parm, PROP_REQUIRED);
316
 
        RNA_def_string_translate(func, "text", "", 0, "", "Custom label to display in UI");
 
649
        api_ui_item_common_text(func);
317
650
        
318
 
        func = RNA_def_function(srna, "template_path_builder", "uiTemplatePathBuilder");
 
651
        func = RNA_def_function(srna, "template_path_builder", "rna_uiTemplatePathBuilder");
319
652
        parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property");
320
 
        RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL);
 
653
        RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR | PROP_NEVER_NULL);
321
654
        parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in data");
322
655
        RNA_def_property_flag(parm, PROP_REQUIRED);
323
656
        parm = RNA_def_pointer(func, "root", "ID", "", "ID-block from which path is evaluated from");
324
 
        RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR);
325
 
        RNA_def_string_translate(func, "text", "", 0, "", "Custom label to display in UI");
 
657
        RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR);
 
658
        api_ui_item_common_text(func);
326
659
        
327
660
        func = RNA_def_function(srna, "template_modifier", "uiTemplateModifier");
328
661
        RNA_def_function_flag(func, FUNC_USE_CONTEXT);
329
662
        RNA_def_function_ui_description(func, "Layout . Generates the UI layout for modifiers");
330
663
        parm = RNA_def_pointer(func, "data", "Modifier", "", "Modifier data");
331
 
        RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL);
 
664
        RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR | PROP_NEVER_NULL);
332
665
        parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
333
666
        RNA_def_function_return(func, parm);
334
667
 
335
668
        func = RNA_def_function(srna, "template_constraint", "uiTemplateConstraint");
336
669
        RNA_def_function_ui_description(func, "Layout . Generates the UI layout for constraints");
337
670
        parm = RNA_def_pointer(func, "data", "Constraint", "", "Constraint data");
338
 
        RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL);
 
671
        RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR | PROP_NEVER_NULL);
339
672
        parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
340
673
        RNA_def_function_return(func, parm);
341
674
 
359
692
        api_ui_item_rna_common(func);
360
693
        RNA_def_boolean(func, "expand", 0, "", "Expand button to show more detail");
361
694
        
 
695
        func = RNA_def_function(srna, "template_icon_view", "uiTemplateIconView");
 
696
        RNA_def_function_ui_description(func, "Enum. Large widget showing Icon previews");
 
697
        api_ui_item_rna_common(func);
 
698
        
362
699
        func = RNA_def_function(srna, "template_histogram", "uiTemplateHistogram");
363
700
        RNA_def_function_ui_description(func, "Item. A histogramm widget to analyze imaga data");
364
701
        api_ui_item_rna_common(func);
374
711
        func = RNA_def_function(srna, "template_layers", "uiTemplateLayers");
375
712
        api_ui_item_rna_common(func);
376
713
        parm = RNA_def_pointer(func, "used_layers_data", "AnyType", "", "Data from which to take property");
377
 
        RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR);
 
714
        RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR);
378
715
        parm = RNA_def_string(func, "used_layers_property", "", 0, "", "Identifier of property in data");
379
716
        RNA_def_property_flag(parm, PROP_REQUIRED);
380
717
        parm = RNA_def_int(func, "active_layer", 0, 0, INT_MAX, "Active Layer", "", 0, INT_MAX);
381
718
        RNA_def_property_flag(parm, PROP_REQUIRED);
382
719
        
383
 
        func = RNA_def_function(srna, "template_color_wheel", "uiTemplateColorWheel");
 
720
        func = RNA_def_function(srna, "template_color_picker", "uiTemplateColorPicker");
384
721
        RNA_def_function_ui_description(func, "Item. A color wheel widget to pick colors");
385
722
        api_ui_item_rna_common(func);
386
723
        RNA_def_boolean(func, "value_slider", 0, "", "Display the value slider to the right of the color wheel");
400
737
        RNA_def_function_flag(func, FUNC_USE_CONTEXT);
401
738
        api_ui_item_rna_common(func);
402
739
        parm = RNA_def_pointer(func, "image_user", "ImageUser", "", "");
403
 
        RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL);
 
740
        RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR | PROP_NEVER_NULL);
404
741
        RNA_def_boolean(func, "compact", 0, "", "Use more compact layout");
405
742
 
406
743
        func = RNA_def_function(srna, "template_image_settings", "uiTemplateImageSettings");
407
744
        RNA_def_function_ui_description(func, "User interface for setting image format options");
408
745
        parm = RNA_def_pointer(func, "image_settings", "ImageFormatSettings", "", "");
409
 
        RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL);
 
746
        RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR | PROP_NEVER_NULL);
 
747
        RNA_def_boolean(func, "color_management", 0, "", "Show color management settings");
410
748
 
411
749
        func = RNA_def_function(srna, "template_movieclip", "uiTemplateMovieClip");
412
750
        RNA_def_function_ui_description(func, "Item(s). User interface for selecting movie clips and their source paths");
422
760
        RNA_def_function_ui_description(func, "Item. A widget to control single marker settings.");
423
761
        api_ui_item_rna_common(func);
424
762
        parm = RNA_def_pointer(func, "clip_user", "MovieClipUser", "", "");
425
 
        RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL);
 
763
        RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR | PROP_NEVER_NULL);
426
764
        parm = RNA_def_pointer(func, "track", "MovieTrackingTrack", "", "");
427
 
        RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL);
 
765
        RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR | PROP_NEVER_NULL);
428
766
        RNA_def_boolean(func, "compact", 0, "", "Use more compact layout");
429
767
 
430
768
        func = RNA_def_function(srna, "template_list", "uiTemplateList");
431
 
        RNA_def_function_ui_description(func, "Item. A list widget to display data. e.g. vertexgroups");
 
769
        RNA_def_function_ui_description(func, "Item. A list widget to display data, e.g. vertexgroups.");
432
770
        RNA_def_function_flag(func, FUNC_USE_CONTEXT);
433
 
        parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property");
434
 
        RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR);
435
 
        parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in data");
436
 
        RNA_def_property_flag(parm, PROP_REQUIRED);
437
 
        parm = RNA_def_pointer(func, "active_data", "AnyType", "",
438
 
                               "Data from which to take property for the active element");
439
 
        RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL);
440
 
        parm = RNA_def_string(func, "active_property", "", 0, "",
441
 
                              "Identifier of property in data, for the active element");
442
 
        RNA_def_property_flag(parm, PROP_REQUIRED);
443
 
        RNA_def_string(func, "prop_list", "", 0, "",
444
 
                       "Identifier of a string property in each data member, specifying which "
445
 
                       "of its properties should have a widget displayed in its row "
446
 
                       "(format: \"propname1:propname2:propname3:...\")");
 
771
        parm = RNA_def_string(func, "listtype_name", "", 0, "", "Identifier of the list type to use");
 
772
        RNA_def_property_flag(parm, PROP_REQUIRED);
 
773
        parm = RNA_def_string(func, "list_id", "", 0, "",
 
774
                              "Identifier of this list widget (mandatory when using default \"" UI_UL_DEFAULT_CLASS_NAME
 
775
                              "\" class). "
 
776
                              "If this is set, the uilist gets a custom ID, otherwise it takes the "
 
777
                              "name of the class used to define the uilist (for example, if the "
 
778
                              "class name is \"OBJECT_UL_vgroups\", and list_id is not set by the "
 
779
                              "script, then bl_idname = \"OBJECT_UL_vgroups\")");
 
780
        parm = RNA_def_pointer(func, "dataptr", "AnyType", "", "Data from which to take the Collection property");
 
781
        RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR);
 
782
        parm = RNA_def_string(func, "propname", "", 0, "", "Identifier of the Collection property in data");
 
783
        RNA_def_property_flag(parm, PROP_REQUIRED);
 
784
        parm = RNA_def_pointer(func, "active_dataptr", "AnyType", "",
 
785
                               "Data from which to take the integer property, index of the active item");
 
786
        RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR | PROP_NEVER_NULL);
 
787
        parm = RNA_def_string(func, "active_propname", "", 0, "",
 
788
                              "Identifier of the integer property in active_data, index of the active item");
 
789
        RNA_def_property_flag(parm, PROP_REQUIRED);
447
790
        RNA_def_int(func, "rows", 5, 0, INT_MAX, "", "Number of rows to display", 0, INT_MAX);
448
791
        RNA_def_int(func, "maxrows", 5, 0, INT_MAX, "", "Maximum number of rows to display", 0, INT_MAX);
449
 
        RNA_def_enum(func, "type", list_type_items, 0, "Type", "Type of list to use");
 
792
        RNA_def_enum(func, "type", uilist_layout_type_items, UILST_LAYOUT_DEFAULT, "Type", "Type of layout to use");
450
793
 
451
794
        func = RNA_def_function(srna, "template_running_jobs", "uiTemplateRunningJobs");
452
795
        RNA_def_function_flag(func, FUNC_USE_CONTEXT);
484
827
 
485
828
        func = RNA_def_function(srna, "template_keymap_item_properties", "uiTemplateKeymapItemProperties");
486
829
        parm = RNA_def_pointer(func, "item", "KeyMapItem", "", "");
487
 
        RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL);
 
830
        RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR | PROP_NEVER_NULL);
488
831
 
489
832
        func = RNA_def_function(srna, "introspect", "uiLayoutIntrospect");
490
 
        parm = RNA_def_string(func, "string", "", 1024*1024, "Descr", "DESCR");
 
833
        parm = RNA_def_string(func, "string", "", 1024 * 1024, "Descr", "DESCR");
491
834
        RNA_def_function_return(func, parm);
 
835
 
 
836
        /* color management templates */
 
837
        func = RNA_def_function(srna, "template_colorspace_settings", "uiTemplateColorspaceSettings");
 
838
        RNA_def_function_ui_description(func, "Item. A widget to control input color space settings.");
 
839
        api_ui_item_rna_common(func);
 
840
 
 
841
        func = RNA_def_function(srna, "template_colormanaged_view_settings", "uiTemplateColormanagedViewSettings");
 
842
        RNA_def_function_ui_description(func, "Item. A widget to control color managed view settings settings.");
 
843
        RNA_def_function_flag(func, FUNC_USE_CONTEXT);
 
844
        api_ui_item_rna_common(func);
 
845
        /* RNA_def_boolean(func, "show_global_settings", 0, "", "Show widgets to control global color management settings"); */
492
846
}
493
847
 
494
848
#endif