2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2009-04-08 16:40:46 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-04-08 16:40:46 +00:00
|
|
|
*/
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup RNA
|
2011-02-27 20:20:01 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2009-04-08 16:40:46 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2009-06-16 00:52:21 +00:00
|
|
|
#include "DNA_screen_types.h"
|
2018-10-26 15:05:07 +11:00
|
|
|
#include "DNA_space_types.h"
|
2009-06-16 00:52:21 +00:00
|
|
|
|
2015-08-16 17:32:01 +10:00
|
|
|
#include "BLT_translation.h"
|
2013-03-15 14:32:29 +00:00
|
|
|
|
2013-08-29 12:55:31 +00:00
|
|
|
#include "BKE_idprop.h"
|
|
|
|
|
2009-04-08 16:40:46 +00:00
|
|
|
#include "RNA_define.h"
|
|
|
|
|
|
|
|
#include "rna_internal.h"
|
2009-04-19 17:12:16 +00:00
|
|
|
#include "RNA_enum_types.h"
|
2009-04-08 16:40:46 +00:00
|
|
|
|
2009-05-28 23:37:55 +00:00
|
|
|
#include "UI_interface.h"
|
|
|
|
|
2009-06-09 10:30:11 +00:00
|
|
|
#include "WM_types.h"
|
2018-10-26 15:05:07 +11:00
|
|
|
#include "WM_toolsystem.h"
|
2009-06-09 10:30:11 +00:00
|
|
|
|
2010-02-10 11:10:38 +00:00
|
|
|
/* see WM_types.h */
|
2017-10-18 15:07:26 +11:00
|
|
|
const EnumPropertyItem rna_enum_operator_context_items[] = {
|
2010-02-10 11:10:38 +00:00
|
|
|
{WM_OP_INVOKE_DEFAULT, "INVOKE_DEFAULT", 0, "Invoke Default", ""},
|
|
|
|
{WM_OP_INVOKE_REGION_WIN, "INVOKE_REGION_WIN", 0, "Invoke Region Window", ""},
|
|
|
|
{WM_OP_INVOKE_REGION_CHANNELS, "INVOKE_REGION_CHANNELS", 0, "Invoke Region Channels", ""},
|
|
|
|
{WM_OP_INVOKE_REGION_PREVIEW, "INVOKE_REGION_PREVIEW", 0, "Invoke Region Preview", ""},
|
|
|
|
{WM_OP_INVOKE_AREA, "INVOKE_AREA", 0, "Invoke Area", ""},
|
|
|
|
{WM_OP_INVOKE_SCREEN, "INVOKE_SCREEN", 0, "Invoke Screen", ""},
|
|
|
|
{WM_OP_EXEC_DEFAULT, "EXEC_DEFAULT", 0, "Exec Default", ""},
|
|
|
|
{WM_OP_EXEC_REGION_WIN, "EXEC_REGION_WIN", 0, "Exec Region Window", ""},
|
|
|
|
{WM_OP_EXEC_REGION_CHANNELS, "EXEC_REGION_CHANNELS", 0, "Exec Region Channels", ""},
|
|
|
|
{WM_OP_EXEC_REGION_PREVIEW, "EXEC_REGION_PREVIEW", 0, "Exec Region Preview", ""},
|
|
|
|
{WM_OP_EXEC_AREA, "EXEC_AREA", 0, "Exec Area", ""},
|
|
|
|
{WM_OP_EXEC_SCREEN, "EXEC_SCREEN", 0, "Exec Screen", ""},
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
2012-05-12 11:01:29 +00:00
|
|
|
};
|
2010-02-10 11:10:38 +00:00
|
|
|
|
2017-10-18 15:07:26 +11:00
|
|
|
const EnumPropertyItem rna_enum_uilist_layout_type_items[] = {
|
2013-08-29 12:55:31 +00:00
|
|
|
{UILST_LAYOUT_DEFAULT, "DEFAULT", 0, "Default Layout", "Use the default, multi-rows layout"},
|
|
|
|
{UILST_LAYOUT_COMPACT, "COMPACT", 0, "Compact Layout", "Use the compact, single-row layout"},
|
|
|
|
{UILST_LAYOUT_GRID, "GRID", 0, "Grid Layout", "Use the grid-based layout"},
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
};
|
|
|
|
|
2009-04-08 16:40:46 +00:00
|
|
|
#ifdef RNA_RUNTIME
|
|
|
|
|
2011-11-15 14:58:14 +00:00
|
|
|
#include <assert.h>
|
|
|
|
|
2009-04-19 13:37:59 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
|
|
|
|
#include "BLI_dynstr.h"
|
|
|
|
|
|
|
|
#include "BKE_context.h"
|
|
|
|
#include "BKE_report.h"
|
|
|
|
#include "BKE_screen.h"
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
|
2009-04-19 17:12:16 +00:00
|
|
|
static ARegionType *region_type_find(ReportList *reports, int space_type, int region_type)
|
2009-04-19 13:37:59 +00:00
|
|
|
{
|
2009-04-19 17:12:16 +00:00
|
|
|
SpaceType *st;
|
|
|
|
ARegionType *art;
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
st = BKE_spacetype_from_id(space_type);
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
for (art = (st) ? st->regiontypes.first : NULL; art; art = art->next) {
|
2012-03-05 23:30:41 +00:00
|
|
|
if (art->regionid == region_type)
|
2009-04-19 17:12:16 +00:00
|
|
|
break;
|
|
|
|
}
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2009-04-19 17:12:16 +00:00
|
|
|
/* region type not found? abort */
|
2012-03-05 23:30:41 +00:00
|
|
|
if (art == NULL) {
|
2012-10-13 13:40:05 +00:00
|
|
|
BKE_report(reports, RPT_ERROR, "Region not found in space type");
|
2009-04-19 17:12:16 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2009-04-19 17:12:16 +00:00
|
|
|
return art;
|
2009-04-19 13:37:59 +00:00
|
|
|
}
|
|
|
|
|
2009-04-19 17:12:16 +00:00
|
|
|
/* Panel */
|
|
|
|
|
2018-07-02 11:47:00 +02:00
|
|
|
static bool panel_poll(const bContext *C, PanelType *pt)
|
2009-04-19 13:37:59 +00:00
|
|
|
{
|
2011-10-19 22:40:03 +00:00
|
|
|
extern FunctionRNA rna_Panel_poll_func;
|
|
|
|
|
2009-04-19 13:37:59 +00:00
|
|
|
PointerRNA ptr;
|
2009-07-17 02:31:28 +00:00
|
|
|
ParameterList list;
|
2009-04-19 13:37:59 +00:00
|
|
|
FunctionRNA *func;
|
|
|
|
void *ret;
|
2018-09-08 07:27:29 +10:00
|
|
|
bool visible;
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2009-07-21 20:05:16 +00:00
|
|
|
RNA_pointer_create(NULL, pt->ext.srna, NULL, &ptr); /* dummy */
|
2012-03-05 23:30:41 +00:00
|
|
|
func = &rna_Panel_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2009-07-17 02:31:28 +00:00
|
|
|
RNA_parameter_list_create(&list, &ptr, func);
|
|
|
|
RNA_parameter_set_lookup(&list, "context", &C);
|
2010-12-07 04:12:15 +00:00
|
|
|
pt->ext.call((bContext *)C, &ptr, func, &list);
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2009-07-17 02:31:28 +00:00
|
|
|
RNA_parameter_get_lookup(&list, "visible", &ret);
|
2018-07-01 15:47:09 +02:00
|
|
|
visible = *(bool *)ret;
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2009-07-17 02:31:28 +00:00
|
|
|
RNA_parameter_list_free(&list);
|
2009-04-19 13:37:59 +00:00
|
|
|
|
|
|
|
return visible;
|
|
|
|
}
|
|
|
|
|
2009-04-19 17:12:16 +00:00
|
|
|
static void panel_draw(const bContext *C, Panel *pnl)
|
2009-04-19 13:37:59 +00:00
|
|
|
{
|
2011-10-19 22:40:03 +00:00
|
|
|
extern FunctionRNA rna_Panel_draw_func;
|
|
|
|
|
2009-04-19 17:12:16 +00:00
|
|
|
PointerRNA ptr;
|
2009-07-17 02:31:28 +00:00
|
|
|
ParameterList list;
|
2009-04-19 17:12:16 +00:00
|
|
|
FunctionRNA *func;
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2009-07-21 20:05:16 +00:00
|
|
|
RNA_pointer_create(&CTX_wm_screen(C)->id, pnl->type->ext.srna, pnl, &ptr);
|
2012-05-12 11:01:29 +00:00
|
|
|
func = &rna_Panel_draw_func; /* RNA_struct_find_function(&ptr, "draw"); */
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2009-07-17 02:31:28 +00:00
|
|
|
RNA_parameter_list_create(&list, &ptr, func);
|
|
|
|
RNA_parameter_set_lookup(&list, "context", &C);
|
2010-12-07 04:12:15 +00:00
|
|
|
pnl->type->ext.call((bContext *)C, &ptr, func, &list);
|
2009-04-19 17:12:16 +00:00
|
|
|
|
2009-07-17 02:31:28 +00:00
|
|
|
RNA_parameter_list_free(&list);
|
2009-04-19 13:37:59 +00:00
|
|
|
}
|
|
|
|
|
2009-05-19 17:13:33 +00:00
|
|
|
static void panel_draw_header(const bContext *C, Panel *pnl)
|
|
|
|
{
|
2011-10-19 22:40:03 +00:00
|
|
|
extern FunctionRNA rna_Panel_draw_header_func;
|
|
|
|
|
2009-05-19 17:13:33 +00:00
|
|
|
PointerRNA ptr;
|
2009-07-17 02:31:28 +00:00
|
|
|
ParameterList list;
|
2009-05-19 17:13:33 +00:00
|
|
|
FunctionRNA *func;
|
|
|
|
|
2009-07-21 20:05:16 +00:00
|
|
|
RNA_pointer_create(&CTX_wm_screen(C)->id, pnl->type->ext.srna, pnl, &ptr);
|
2012-03-05 23:30:41 +00:00
|
|
|
func = &rna_Panel_draw_header_func; /* RNA_struct_find_function(&ptr, "draw_header"); */
|
2009-05-19 17:13:33 +00:00
|
|
|
|
2009-07-17 02:31:28 +00:00
|
|
|
RNA_parameter_list_create(&list, &ptr, func);
|
|
|
|
RNA_parameter_set_lookup(&list, "context", &C);
|
2010-12-07 04:12:15 +00:00
|
|
|
pnl->type->ext.call((bContext *)C, &ptr, func, &list);
|
2009-05-19 17:13:33 +00:00
|
|
|
|
2009-07-17 02:31:28 +00:00
|
|
|
RNA_parameter_list_free(&list);
|
2009-05-19 17:13:33 +00:00
|
|
|
}
|
|
|
|
|
2018-04-27 13:50:26 +02:00
|
|
|
static void panel_draw_header_preset(const bContext *C, Panel *pnl)
|
|
|
|
{
|
|
|
|
extern FunctionRNA rna_Panel_draw_header_preset_func;
|
|
|
|
|
|
|
|
PointerRNA ptr;
|
|
|
|
ParameterList list;
|
|
|
|
FunctionRNA *func;
|
|
|
|
|
|
|
|
RNA_pointer_create(&CTX_wm_screen(C)->id, pnl->type->ext.srna, pnl, &ptr);
|
|
|
|
func = &rna_Panel_draw_header_preset_func;
|
|
|
|
|
|
|
|
RNA_parameter_list_create(&list, &ptr, func);
|
|
|
|
RNA_parameter_set_lookup(&list, "context", &C);
|
|
|
|
pnl->type->ext.call((bContext *)C, &ptr, func, &list);
|
|
|
|
|
|
|
|
RNA_parameter_list_free(&list);
|
|
|
|
}
|
|
|
|
|
2013-09-20 06:35:28 +00:00
|
|
|
static void rna_Panel_unregister(Main *UNUSED(bmain), StructRNA *type)
|
2009-04-19 13:37:59 +00:00
|
|
|
{
|
|
|
|
ARegionType *art;
|
2012-03-05 23:30:41 +00:00
|
|
|
PanelType *pt = RNA_struct_blender_type_get(type);
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!pt)
|
2009-04-19 17:12:16 +00:00
|
|
|
return;
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!(art = region_type_find(NULL, pt->space_type, pt->region_type)))
|
2009-04-19 17:12:16 +00:00
|
|
|
return;
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2009-08-16 07:26:29 +00:00
|
|
|
RNA_struct_free_extension(type, &pt->ext);
|
2017-08-11 19:09:03 +10:00
|
|
|
RNA_struct_free(&BLENDER_RNA, type);
|
2009-08-14 12:29:55 +00:00
|
|
|
|
2018-06-03 13:32:36 +02:00
|
|
|
if (pt->parent) {
|
|
|
|
LinkData *link = BLI_findptr(&pt->parent->children, pt, offsetof(LinkData, data));
|
|
|
|
BLI_freelinkN(&pt->parent->children, link);
|
|
|
|
}
|
|
|
|
|
2018-10-01 10:31:24 +10:00
|
|
|
WM_paneltype_remove(pt);
|
|
|
|
|
2018-10-06 20:56:08 +02:00
|
|
|
for (LinkData *link = pt->children.first; link; link = link->next) {
|
|
|
|
PanelType *child_pt = link->data;
|
|
|
|
child_pt->parent = NULL;
|
|
|
|
}
|
|
|
|
|
2018-06-03 13:32:36 +02:00
|
|
|
BLI_freelistN(&pt->children);
|
2009-04-19 17:12:16 +00:00
|
|
|
BLI_freelinkN(&art->paneltypes, pt);
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2009-04-19 17:12:16 +00:00
|
|
|
/* update while blender is running */
|
2013-01-09 13:15:23 +00:00
|
|
|
WM_main_add_notifier(NC_WINDOW, NULL);
|
2009-04-19 13:37:59 +00:00
|
|
|
}
|
|
|
|
|
2017-09-13 21:52:57 +10:00
|
|
|
static StructRNA *rna_Panel_register(
|
|
|
|
Main *bmain, ReportList *reports, void *data, const char *identifier,
|
|
|
|
StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
|
2009-04-19 13:37:59 +00:00
|
|
|
{
|
|
|
|
ARegionType *art;
|
2018-06-03 13:32:36 +02:00
|
|
|
PanelType *pt, *parent = NULL, dummypt = {NULL};
|
2012-03-05 23:30:41 +00:00
|
|
|
Panel dummypanel = {NULL};
|
2009-04-19 13:37:59 +00:00
|
|
|
PointerRNA dummyptr;
|
2018-04-27 13:50:26 +02:00
|
|
|
int have_function[4];
|
2009-04-19 13:37:59 +00:00
|
|
|
|
|
|
|
/* setup dummy panel & panel type to store static properties in */
|
2012-03-05 23:30:41 +00:00
|
|
|
dummypanel.type = &dummypt;
|
2009-04-19 13:37:59 +00:00
|
|
|
RNA_pointer_create(NULL, &RNA_Panel, &dummypanel, &dummyptr);
|
|
|
|
|
2013-03-19 19:37:22 +00:00
|
|
|
/* We have to set default context! Else we get a void string... */
|
2015-08-16 17:32:01 +10:00
|
|
|
strcpy(dummypt.translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
|
2013-03-19 19:37:22 +00:00
|
|
|
|
2009-04-19 13:37:59 +00:00
|
|
|
/* validate the python class */
|
2012-03-05 23:30:41 +00:00
|
|
|
if (validate(&dummyptr, data, have_function) != 0)
|
2009-04-19 13:37:59 +00:00
|
|
|
return NULL;
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (strlen(identifier) >= sizeof(dummypt.idname)) {
|
2012-10-21 14:02:30 +00:00
|
|
|
BKE_reportf(reports, RPT_ERROR, "Registering panel class: '%s' is too long, maximum length is %d",
|
2011-09-19 13:23:58 +00:00
|
|
|
identifier, (int)sizeof(dummypt.idname));
|
2009-12-22 10:04:15 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2014-08-27 10:53:16 +10:00
|
|
|
|
2018-10-26 15:05:07 +11:00
|
|
|
if ((1 << dummypt.region_type) & RGN_TYPE_HAS_CATEGORY_MASK) {
|
|
|
|
if (dummypt.category[0] == '\0') {
|
|
|
|
/* Use a fallback, otherwise an empty value will draw the panel in every category. */
|
|
|
|
strcpy(dummypt.category, PNL_CATEGORY_FALLBACK);
|
2018-11-21 21:39:19 +01:00
|
|
|
#ifndef NDEBUG
|
|
|
|
printf("Registering panel class: '%s' misses category, please update the script\n", dummypt.idname);
|
|
|
|
#endif
|
2018-10-26 15:05:07 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (dummypt.category[0] != '\0') {
|
|
|
|
if ((1 << dummypt.space_type) & WM_TOOLSYSTEM_SPACE_MASK) {
|
|
|
|
BKE_reportf(reports, RPT_ERROR, "Registering panel class: '%s' has category '%s' ",
|
|
|
|
dummypt.idname, dummypt.category);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2014-08-27 10:53:16 +10:00
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!(art = region_type_find(reports, dummypt.space_type, dummypt.region_type)))
|
2009-04-19 13:37:59 +00:00
|
|
|
return NULL;
|
|
|
|
|
2009-04-19 17:12:16 +00:00
|
|
|
/* check if we have registered this panel type before, and remove it */
|
2012-03-05 23:30:41 +00:00
|
|
|
for (pt = art->paneltypes.first; pt; pt = pt->next) {
|
2015-01-26 16:03:11 +01:00
|
|
|
if (STREQ(pt->idname, dummypt.idname)) {
|
2012-03-05 23:30:41 +00:00
|
|
|
if (pt->ext.srna)
|
2011-05-18 10:56:26 +00:00
|
|
|
rna_Panel_unregister(bmain, pt->ext.srna);
|
2009-07-10 11:59:45 +00:00
|
|
|
else
|
|
|
|
BLI_freelinkN(&art->paneltypes, pt);
|
2009-04-19 13:37:59 +00:00
|
|
|
break;
|
2009-04-19 17:12:16 +00:00
|
|
|
}
|
2018-06-03 13:32:36 +02:00
|
|
|
|
|
|
|
if (dummypt.parent_id[0] && STREQ(pt->idname, dummypt.parent_id)) {
|
|
|
|
parent = pt;
|
|
|
|
}
|
2009-04-19 13:37:59 +00:00
|
|
|
}
|
2017-08-31 18:42:48 +10:00
|
|
|
if (!RNA_struct_available_or_report(reports, dummypt.idname)) {
|
2017-08-23 14:59:14 +10:00
|
|
|
return NULL;
|
|
|
|
}
|
2017-09-01 00:58:18 +10:00
|
|
|
if (!RNA_struct_bl_idname_ok_or_report(reports, dummypt.idname, "_PT_")) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2018-06-03 13:32:36 +02:00
|
|
|
if (dummypt.parent_id[0] && !parent) {
|
|
|
|
BKE_reportf(reports, RPT_ERROR, "Registering panel class: parent '%s' for '%s' not found",
|
|
|
|
dummypt.parent_id, dummypt.idname);
|
|
|
|
return NULL;
|
|
|
|
}
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2009-04-19 17:12:16 +00:00
|
|
|
/* create a new panel type */
|
2012-03-05 23:30:41 +00:00
|
|
|
pt = MEM_callocN(sizeof(PanelType), "python buttons panel");
|
2009-04-19 17:12:16 +00:00
|
|
|
memcpy(pt, &dummypt, sizeof(dummypt));
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2013-01-09 05:32:15 +00:00
|
|
|
pt->ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, pt->idname, &RNA_Panel);
|
2013-03-15 14:32:29 +00:00
|
|
|
RNA_def_struct_translation_context(pt->ext.srna, pt->translation_context);
|
2012-03-05 23:30:41 +00:00
|
|
|
pt->ext.data = data;
|
|
|
|
pt->ext.call = call;
|
|
|
|
pt->ext.free = free;
|
2009-07-21 20:05:16 +00:00
|
|
|
RNA_struct_blender_type_set(pt->ext.srna, pt);
|
2010-08-19 10:16:30 +00:00
|
|
|
RNA_def_struct_flag(pt->ext.srna, STRUCT_NO_IDPROPERTIES);
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
pt->poll = (have_function[0]) ? panel_poll : NULL;
|
|
|
|
pt->draw = (have_function[1]) ? panel_draw : NULL;
|
|
|
|
pt->draw_header = (have_function[2]) ? panel_draw_header : NULL;
|
2018-04-27 13:50:26 +02:00
|
|
|
pt->draw_header_preset = (have_function[3]) ? panel_draw_header_preset : NULL;
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2011-01-23 13:52:24 +00:00
|
|
|
/* XXX use "no header" flag for some ordering of panels until we have real panel ordering */
|
2012-03-05 23:30:41 +00:00
|
|
|
if (pt->flag & PNL_NO_HEADER) {
|
2011-01-23 13:52:24 +00:00
|
|
|
PanelType *pth = art->paneltypes.first;
|
2012-03-05 23:30:41 +00:00
|
|
|
while (pth && pth->flag & PNL_NO_HEADER)
|
|
|
|
pth = pth->next;
|
2011-01-23 13:52:24 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (pth)
|
2011-01-23 13:52:24 +00:00
|
|
|
BLI_insertlinkbefore(&art->paneltypes, pth, pt);
|
|
|
|
else
|
|
|
|
BLI_addtail(&art->paneltypes, pt);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
BLI_addtail(&art->paneltypes, pt);
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2018-06-03 13:32:36 +02:00
|
|
|
if (parent) {
|
|
|
|
pt->parent = parent;
|
|
|
|
BLI_addtail(&parent->children, BLI_genericNodeN(pt));
|
|
|
|
}
|
|
|
|
|
2018-03-01 01:26:02 +11:00
|
|
|
{
|
|
|
|
const char *owner_id = RNA_struct_state_owner_get();
|
|
|
|
if (owner_id) {
|
|
|
|
BLI_strncpy(pt->owner_id, owner_id, sizeof(pt->owner_id));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-13 18:39:46 +02:00
|
|
|
WM_paneltype_add(pt);
|
|
|
|
|
2009-04-19 13:37:59 +00:00
|
|
|
/* update while blender is running */
|
2013-01-09 13:15:23 +00:00
|
|
|
WM_main_add_notifier(NC_WINDOW, NULL);
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2009-07-21 20:05:16 +00:00
|
|
|
return pt->ext.srna;
|
2009-04-19 13:37:59 +00:00
|
|
|
}
|
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
static StructRNA *rna_Panel_refine(PointerRNA *ptr)
|
2009-04-19 17:12:16 +00:00
|
|
|
{
|
2018-06-04 19:09:52 +02:00
|
|
|
Panel *menu = (Panel *)ptr->data;
|
|
|
|
return (menu->type && menu->type->ext.srna) ? menu->type->ext.srna : &RNA_Panel;
|
2009-04-19 17:12:16 +00:00
|
|
|
}
|
|
|
|
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
/* UIList */
|
2013-09-20 06:35:28 +00:00
|
|
|
static unsigned int rna_UIList_filter_const_FILTER_ITEM_get(PointerRNA *UNUSED(ptr))
|
2013-08-29 12:55:31 +00:00
|
|
|
{
|
|
|
|
return UILST_FLT_ITEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
static IDProperty *rna_UIList_idprops(PointerRNA *ptr, bool create)
|
|
|
|
{
|
|
|
|
uiList *ui_list = (uiList *)ptr->data;
|
|
|
|
if (create && !ui_list->properties) {
|
|
|
|
IDPropertyTemplate val = {0};
|
|
|
|
ui_list->properties = IDP_New(IDP_GROUP, &val, "RNA_UIList IDproperties group");
|
|
|
|
}
|
|
|
|
|
|
|
|
return ui_list->properties;
|
|
|
|
}
|
|
|
|
|
2012-12-28 10:32:49 +00:00
|
|
|
static void uilist_draw_item(uiList *ui_list, bContext *C, uiLayout *layout, PointerRNA *dataptr, PointerRNA *itemptr,
|
2013-08-29 12:55:31 +00:00
|
|
|
int icon, PointerRNA *active_dataptr, const char *active_propname, int index, int flt_flag)
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
{
|
|
|
|
extern FunctionRNA rna_UIList_draw_item_func;
|
|
|
|
|
2012-12-28 10:32:49 +00:00
|
|
|
PointerRNA ul_ptr;
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
ParameterList list;
|
|
|
|
FunctionRNA *func;
|
|
|
|
|
2012-12-28 10:32:49 +00:00
|
|
|
RNA_pointer_create(&CTX_wm_screen(C)->id, ui_list->type->ext.srna, ui_list, &ul_ptr);
|
|
|
|
func = &rna_UIList_draw_item_func; /* RNA_struct_find_function(&ul_ptr, "draw_item"); */
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
|
2012-12-28 10:32:49 +00:00
|
|
|
RNA_parameter_list_create(&list, &ul_ptr, func);
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
RNA_parameter_set_lookup(&list, "context", &C);
|
|
|
|
RNA_parameter_set_lookup(&list, "layout", &layout);
|
|
|
|
RNA_parameter_set_lookup(&list, "data", dataptr);
|
|
|
|
RNA_parameter_set_lookup(&list, "item", itemptr);
|
|
|
|
RNA_parameter_set_lookup(&list, "icon", &icon);
|
|
|
|
RNA_parameter_set_lookup(&list, "active_data", active_dataptr);
|
|
|
|
RNA_parameter_set_lookup(&list, "active_property", &active_propname);
|
|
|
|
RNA_parameter_set_lookup(&list, "index", &index);
|
2013-08-29 12:55:31 +00:00
|
|
|
RNA_parameter_set_lookup(&list, "flt_flag", &flt_flag);
|
2012-12-28 10:32:49 +00:00
|
|
|
ui_list->type->ext.call((bContext *)C, &ul_ptr, func, &list);
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
|
|
|
|
RNA_parameter_list_free(&list);
|
|
|
|
}
|
|
|
|
|
2019-01-09 15:48:09 +01:00
|
|
|
static void uilist_draw_filter(uiList *ui_list, bContext *C, uiLayout *layout)
|
2013-08-29 12:55:31 +00:00
|
|
|
{
|
|
|
|
extern FunctionRNA rna_UIList_draw_filter_func;
|
|
|
|
|
|
|
|
PointerRNA ul_ptr;
|
|
|
|
ParameterList list;
|
|
|
|
FunctionRNA *func;
|
|
|
|
|
|
|
|
RNA_pointer_create(&CTX_wm_screen(C)->id, ui_list->type->ext.srna, ui_list, &ul_ptr);
|
|
|
|
func = &rna_UIList_draw_filter_func; /* RNA_struct_find_function(&ul_ptr, "draw_filter"); */
|
|
|
|
|
|
|
|
RNA_parameter_list_create(&list, &ul_ptr, func);
|
|
|
|
RNA_parameter_set_lookup(&list, "context", &C);
|
|
|
|
RNA_parameter_set_lookup(&list, "layout", &layout);
|
|
|
|
ui_list->type->ext.call((bContext *)C, &ul_ptr, func, &list);
|
|
|
|
|
|
|
|
RNA_parameter_list_free(&list);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void uilist_filter_items(uiList *ui_list, bContext *C, PointerRNA *dataptr, const char *propname)
|
|
|
|
{
|
|
|
|
extern FunctionRNA rna_UIList_filter_items_func;
|
|
|
|
|
|
|
|
PointerRNA ul_ptr;
|
|
|
|
ParameterList list;
|
|
|
|
FunctionRNA *func;
|
|
|
|
PropertyRNA *parm;
|
|
|
|
|
|
|
|
uiListDyn *flt_data = ui_list->dyn_data;
|
|
|
|
int *filter_flags, *filter_neworder;
|
|
|
|
void *ret1, *ret2;
|
|
|
|
int ret_len;
|
|
|
|
int len = flt_data->items_len = RNA_collection_length(dataptr, propname);
|
|
|
|
|
|
|
|
RNA_pointer_create(&CTX_wm_screen(C)->id, ui_list->type->ext.srna, ui_list, &ul_ptr);
|
|
|
|
func = &rna_UIList_filter_items_func; /* RNA_struct_find_function(&ul_ptr, "filter_items"); */
|
|
|
|
|
|
|
|
RNA_parameter_list_create(&list, &ul_ptr, func);
|
|
|
|
RNA_parameter_set_lookup(&list, "context", &C);
|
|
|
|
RNA_parameter_set_lookup(&list, "data", dataptr);
|
|
|
|
RNA_parameter_set_lookup(&list, "property", &propname);
|
|
|
|
|
|
|
|
ui_list->type->ext.call((bContext *)C, &ul_ptr, func, &list);
|
|
|
|
|
|
|
|
parm = RNA_function_find_parameter(NULL, func, "filter_flags");
|
|
|
|
ret_len = RNA_parameter_dynamic_length_get(&list, parm);
|
|
|
|
if (ret_len != len && ret_len != 0) {
|
2014-01-24 22:12:38 +01:00
|
|
|
printf("%s: Error, py func returned %d items in %s, %d or none were expected.\n", __func__,
|
2013-08-29 12:55:31 +00:00
|
|
|
RNA_parameter_dynamic_length_get(&list, parm), "filter_flags", len);
|
2014-01-24 22:12:38 +01:00
|
|
|
/* Note: we cannot return here, we would let flt_data in inconsistent state... see T38356. */
|
|
|
|
filter_flags = NULL;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
RNA_parameter_get(&list, parm, &ret1);
|
|
|
|
filter_flags = (int *)ret1;
|
2013-08-29 12:55:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
parm = RNA_function_find_parameter(NULL, func, "filter_neworder");
|
|
|
|
ret_len = RNA_parameter_dynamic_length_get(&list, parm);
|
|
|
|
if (ret_len != len && ret_len != 0) {
|
2014-01-24 22:12:38 +01:00
|
|
|
printf("%s: Error, py func returned %d items in %s, %d or none were expected.\n", __func__,
|
2013-08-29 12:55:31 +00:00
|
|
|
RNA_parameter_dynamic_length_get(&list, parm), "filter_neworder", len);
|
2014-01-24 22:12:38 +01:00
|
|
|
/* Note: we cannot return here, we would let flt_data in inconsistent state... see T38356. */
|
|
|
|
filter_neworder = NULL;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
RNA_parameter_get(&list, parm, &ret2);
|
|
|
|
filter_neworder = (int *)ret2;
|
2013-08-29 12:55:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* We have to do some final checks and transforms... */
|
|
|
|
{
|
|
|
|
int i, filter_exclude = ui_list->filter_flag & UILST_FLT_EXCLUDE;
|
|
|
|
if (filter_flags) {
|
2014-01-24 22:12:38 +01:00
|
|
|
flt_data->items_filter_flags = MEM_mallocN(sizeof(int) * len, __func__);
|
2013-08-29 12:55:31 +00:00
|
|
|
memcpy(flt_data->items_filter_flags, filter_flags, sizeof(int) * len);
|
|
|
|
|
|
|
|
if (filter_neworder) {
|
|
|
|
/* For sake of simplicity, py filtering is expected to filter all items, but we actually only want
|
|
|
|
* reordering data for shown items!
|
|
|
|
*/
|
|
|
|
int items_shown, shown_idx;
|
|
|
|
int t_idx, t_ni, prev_ni;
|
|
|
|
flt_data->items_shown = 0;
|
|
|
|
for (i = 0, shown_idx = 0; i < len; i++) {
|
|
|
|
if ((filter_flags[i] & UILST_FLT_ITEM) ^ filter_exclude) {
|
|
|
|
filter_neworder[shown_idx++] = filter_neworder[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
items_shown = flt_data->items_shown = shown_idx;
|
2014-01-24 22:12:38 +01:00
|
|
|
flt_data->items_filter_neworder = MEM_mallocN(sizeof(int) * items_shown, __func__);
|
2013-08-29 12:55:31 +00:00
|
|
|
/* And now, bring back new indices into the [0, items_shown[ range!
|
|
|
|
* XXX This is O(N²)... :/
|
|
|
|
*/
|
|
|
|
for (shown_idx = 0, prev_ni = -1; shown_idx < items_shown; shown_idx++) {
|
|
|
|
for (i = 0, t_ni = len, t_idx = -1; i < items_shown; i++) {
|
|
|
|
int ni = filter_neworder[i];
|
|
|
|
if (ni > prev_ni && ni < t_ni) {
|
|
|
|
t_idx = i;
|
|
|
|
t_ni = ni;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (t_idx >= 0) {
|
|
|
|
prev_ni = t_ni;
|
|
|
|
flt_data->items_filter_neworder[t_idx] = shown_idx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* we still have to set flt_data->items_shown... */
|
|
|
|
flt_data->items_shown = 0;
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
if ((filter_flags[i] & UILST_FLT_ITEM) ^ filter_exclude) {
|
|
|
|
flt_data->items_shown++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
flt_data->items_shown = len;
|
|
|
|
|
|
|
|
if (filter_neworder) {
|
2014-01-24 22:12:38 +01:00
|
|
|
flt_data->items_filter_neworder = MEM_mallocN(sizeof(int) * len, __func__);
|
2013-08-29 12:55:31 +00:00
|
|
|
memcpy(flt_data->items_filter_neworder, filter_neworder, sizeof(int) * len);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RNA_parameter_list_free(&list);
|
|
|
|
}
|
|
|
|
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
static void rna_UIList_unregister(Main *UNUSED(bmain), StructRNA *type)
|
|
|
|
{
|
|
|
|
uiListType *ult = RNA_struct_blender_type_get(type);
|
|
|
|
|
|
|
|
if (!ult)
|
|
|
|
return;
|
|
|
|
|
|
|
|
RNA_struct_free_extension(type, &ult->ext);
|
2017-08-11 19:09:03 +10:00
|
|
|
RNA_struct_free(&BLENDER_RNA, type);
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
|
|
|
|
WM_uilisttype_freelink(ult);
|
|
|
|
|
|
|
|
/* update while blender is running */
|
2013-01-09 13:15:23 +00:00
|
|
|
WM_main_add_notifier(NC_WINDOW, NULL);
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
}
|
|
|
|
|
2017-09-13 21:52:57 +10:00
|
|
|
static StructRNA *rna_UIList_register(
|
|
|
|
Main *bmain, ReportList *reports, void *data, const char *identifier,
|
|
|
|
StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
{
|
|
|
|
uiListType *ult, dummyult = {NULL};
|
|
|
|
uiList dummyuilist = {NULL};
|
2012-12-28 10:32:49 +00:00
|
|
|
PointerRNA dummyul_ptr;
|
2013-08-29 12:55:31 +00:00
|
|
|
int have_function[3];
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
size_t over_alloc = 0; /* warning, if this becomes a bess, we better do another alloc */
|
|
|
|
|
|
|
|
/* setup dummy menu & menu type to store static properties in */
|
|
|
|
dummyuilist.type = &dummyult;
|
2012-12-28 10:32:49 +00:00
|
|
|
RNA_pointer_create(NULL, &RNA_UIList, &dummyuilist, &dummyul_ptr);
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
|
|
|
|
/* validate the python class */
|
2012-12-28 10:32:49 +00:00
|
|
|
if (validate(&dummyul_ptr, data, have_function) != 0)
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (strlen(identifier) >= sizeof(dummyult.idname)) {
|
|
|
|
BKE_reportf(reports, RPT_ERROR, "Registering uilist class: '%s' is too long, maximum length is %d",
|
|
|
|
identifier, (int)sizeof(dummyult.idname));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check if we have registered this uilist type before, and remove it */
|
2014-04-01 11:34:00 +11:00
|
|
|
ult = WM_uilisttype_find(dummyult.idname, true);
|
2017-08-23 14:59:14 +10:00
|
|
|
if (ult && ult->ext.srna) {
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
rna_UIList_unregister(bmain, ult->ext.srna);
|
2017-08-23 14:59:14 +10:00
|
|
|
}
|
2017-08-31 18:42:48 +10:00
|
|
|
if (!RNA_struct_available_or_report(reports, dummyult.idname)) {
|
2017-08-23 14:59:14 +10:00
|
|
|
return NULL;
|
|
|
|
}
|
2017-09-01 00:58:18 +10:00
|
|
|
if (!RNA_struct_bl_idname_ok_or_report(reports, dummyult.idname, "_UL_")) {
|
|
|
|
return NULL;
|
|
|
|
}
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
|
|
|
|
/* create a new menu type */
|
|
|
|
ult = MEM_callocN(sizeof(uiListType) + over_alloc, "python uilist");
|
|
|
|
memcpy(ult, &dummyult, sizeof(dummyult));
|
|
|
|
|
2013-01-09 05:32:15 +00:00
|
|
|
ult->ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, ult->idname, &RNA_UIList);
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
ult->ext.data = data;
|
|
|
|
ult->ext.call = call;
|
|
|
|
ult->ext.free = free;
|
|
|
|
RNA_struct_blender_type_set(ult->ext.srna, ult);
|
|
|
|
|
|
|
|
ult->draw_item = (have_function[0]) ? uilist_draw_item : NULL;
|
2013-08-29 12:55:31 +00:00
|
|
|
ult->draw_filter = (have_function[1]) ? uilist_draw_filter : NULL;
|
|
|
|
ult->filter_items = (have_function[2]) ? uilist_filter_items : NULL;
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
|
|
|
|
WM_uilisttype_add(ult);
|
|
|
|
|
|
|
|
/* update while blender is running */
|
2013-01-09 13:15:23 +00:00
|
|
|
WM_main_add_notifier(NC_WINDOW, NULL);
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
|
|
|
|
return ult->ext.srna;
|
|
|
|
}
|
|
|
|
|
|
|
|
static StructRNA *rna_UIList_refine(PointerRNA *ptr)
|
|
|
|
{
|
2012-12-28 10:32:49 +00:00
|
|
|
uiList *ui_list = (uiList *)ptr->data;
|
|
|
|
return (ui_list->type && ui_list->type->ext.srna) ? ui_list->type->ext.srna : &RNA_UIList;
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
}
|
|
|
|
|
2009-04-19 17:12:16 +00:00
|
|
|
/* Header */
|
|
|
|
|
|
|
|
static void header_draw(const bContext *C, Header *hdr)
|
|
|
|
{
|
2011-10-19 22:40:03 +00:00
|
|
|
extern FunctionRNA rna_Header_draw_func;
|
|
|
|
|
2009-04-19 17:12:16 +00:00
|
|
|
PointerRNA htr;
|
2009-07-17 02:31:28 +00:00
|
|
|
ParameterList list;
|
2009-04-19 17:12:16 +00:00
|
|
|
FunctionRNA *func;
|
|
|
|
|
2009-07-21 20:05:16 +00:00
|
|
|
RNA_pointer_create(&CTX_wm_screen(C)->id, hdr->type->ext.srna, hdr, &htr);
|
2012-03-05 23:30:41 +00:00
|
|
|
func = &rna_Header_draw_func; /* RNA_struct_find_function(&htr, "draw"); */
|
2009-04-19 17:12:16 +00:00
|
|
|
|
2009-07-17 02:31:28 +00:00
|
|
|
RNA_parameter_list_create(&list, &htr, func);
|
|
|
|
RNA_parameter_set_lookup(&list, "context", &C);
|
2010-12-07 04:12:15 +00:00
|
|
|
hdr->type->ext.call((bContext *)C, &htr, func, &list);
|
2009-04-19 17:12:16 +00:00
|
|
|
|
2009-07-17 02:31:28 +00:00
|
|
|
RNA_parameter_list_free(&list);
|
2009-04-19 17:12:16 +00:00
|
|
|
}
|
|
|
|
|
2011-05-31 02:14:25 +00:00
|
|
|
static void rna_Header_unregister(Main *UNUSED(bmain), StructRNA *type)
|
2009-04-19 13:37:59 +00:00
|
|
|
{
|
|
|
|
ARegionType *art;
|
2012-03-05 23:30:41 +00:00
|
|
|
HeaderType *ht = RNA_struct_blender_type_get(type);
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!ht)
|
2009-04-19 17:12:16 +00:00
|
|
|
return;
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
if (!(art = region_type_find(NULL, ht->space_type, ht->region_type)))
|
2009-04-19 13:37:59 +00:00
|
|
|
return;
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2009-08-16 07:26:29 +00:00
|
|
|
RNA_struct_free_extension(type, &ht->ext);
|
2017-08-11 19:09:03 +10:00
|
|
|
RNA_struct_free(&BLENDER_RNA, type);
|
2009-08-14 12:29:55 +00:00
|
|
|
|
2009-04-19 17:12:16 +00:00
|
|
|
BLI_freelinkN(&art->headertypes, ht);
|
2009-04-19 13:37:59 +00:00
|
|
|
|
|
|
|
/* update while blender is running */
|
2013-01-09 13:15:23 +00:00
|
|
|
WM_main_add_notifier(NC_WINDOW, NULL);
|
2009-04-19 13:37:59 +00:00
|
|
|
}
|
|
|
|
|
2017-09-13 21:52:57 +10:00
|
|
|
static StructRNA *rna_Header_register(
|
|
|
|
Main *bmain, ReportList *reports, void *data, const char *identifier,
|
|
|
|
StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
|
2009-04-19 13:37:59 +00:00
|
|
|
{
|
2009-04-19 17:12:16 +00:00
|
|
|
ARegionType *art;
|
2011-03-03 17:58:06 +00:00
|
|
|
HeaderType *ht, dummyht = {NULL};
|
2012-03-05 23:30:41 +00:00
|
|
|
Header dummyheader = {NULL};
|
2009-04-19 17:12:16 +00:00
|
|
|
PointerRNA dummyhtr;
|
|
|
|
int have_function[1];
|
|
|
|
|
|
|
|
/* setup dummy header & header type to store static properties in */
|
2012-03-05 23:30:41 +00:00
|
|
|
dummyheader.type = &dummyht;
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
dummyht.region_type = RGN_TYPE_HEADER; /* RGN_TYPE_HEADER by default, may be overridden */
|
2009-04-19 17:12:16 +00:00
|
|
|
RNA_pointer_create(NULL, &RNA_Header, &dummyheader, &dummyhtr);
|
|
|
|
|
|
|
|
/* validate the python class */
|
2012-03-05 23:30:41 +00:00
|
|
|
if (validate(&dummyhtr, data, have_function) != 0)
|
2009-04-19 17:12:16 +00:00
|
|
|
return NULL;
|
2009-12-22 10:04:15 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (strlen(identifier) >= sizeof(dummyht.idname)) {
|
2012-10-21 14:02:30 +00:00
|
|
|
BKE_reportf(reports, RPT_ERROR, "Registering header class: '%s' is too long, maximum length is %d",
|
2011-09-19 13:23:58 +00:00
|
|
|
identifier, (int)sizeof(dummyht.idname));
|
2009-12-22 10:04:15 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
if (!(art = region_type_find(reports, dummyht.space_type, dummyht.region_type)))
|
2009-04-19 17:12:16 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* check if we have registered this header type before, and remove it */
|
2012-03-05 23:30:41 +00:00
|
|
|
for (ht = art->headertypes.first; ht; ht = ht->next) {
|
2015-01-26 16:03:11 +01:00
|
|
|
if (STREQ(ht->idname, dummyht.idname)) {
|
2012-03-05 23:30:41 +00:00
|
|
|
if (ht->ext.srna)
|
2011-05-18 10:56:26 +00:00
|
|
|
rna_Header_unregister(bmain, ht->ext.srna);
|
2009-04-19 17:12:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-08-31 18:42:48 +10:00
|
|
|
if (!RNA_struct_available_or_report(reports, dummyht.idname)) {
|
2017-08-23 14:59:14 +10:00
|
|
|
return NULL;
|
|
|
|
}
|
2017-09-01 00:58:18 +10:00
|
|
|
if (!RNA_struct_bl_idname_ok_or_report(reports, dummyht.idname, "_HT_")) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2009-04-19 17:12:16 +00:00
|
|
|
/* create a new header type */
|
2012-03-05 23:30:41 +00:00
|
|
|
ht = MEM_callocN(sizeof(HeaderType), "python buttons header");
|
2009-04-19 17:12:16 +00:00
|
|
|
memcpy(ht, &dummyht, sizeof(dummyht));
|
|
|
|
|
2013-01-09 05:32:15 +00:00
|
|
|
ht->ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, ht->idname, &RNA_Header);
|
2012-03-05 23:30:41 +00:00
|
|
|
ht->ext.data = data;
|
|
|
|
ht->ext.call = call;
|
|
|
|
ht->ext.free = free;
|
2009-07-21 20:05:16 +00:00
|
|
|
RNA_struct_blender_type_set(ht->ext.srna, ht);
|
2009-04-19 17:12:16 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
ht->draw = (have_function[0]) ? header_draw : NULL;
|
2009-04-19 17:12:16 +00:00
|
|
|
|
|
|
|
BLI_addtail(&art->headertypes, ht);
|
|
|
|
|
|
|
|
/* update while blender is running */
|
2013-01-09 13:15:23 +00:00
|
|
|
WM_main_add_notifier(NC_WINDOW, NULL);
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2009-07-21 20:05:16 +00:00
|
|
|
return ht->ext.srna;
|
2009-04-19 17:12:16 +00:00
|
|
|
}
|
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
static StructRNA *rna_Header_refine(PointerRNA *htr)
|
2009-04-19 17:12:16 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
Header *hdr = (Header *)htr->data;
|
|
|
|
return (hdr->type && hdr->type->ext.srna) ? hdr->type->ext.srna : &RNA_Header;
|
2009-04-19 13:37:59 +00:00
|
|
|
}
|
|
|
|
|
2009-04-22 18:39:44 +00:00
|
|
|
/* Menu */
|
|
|
|
|
2018-07-02 11:47:00 +02:00
|
|
|
static bool menu_poll(const bContext *C, MenuType *pt)
|
2009-04-22 18:39:44 +00:00
|
|
|
{
|
2011-10-19 22:40:03 +00:00
|
|
|
extern FunctionRNA rna_Menu_poll_func;
|
|
|
|
|
2009-04-22 18:39:44 +00:00
|
|
|
PointerRNA ptr;
|
2009-07-17 02:31:28 +00:00
|
|
|
ParameterList list;
|
2009-04-22 18:39:44 +00:00
|
|
|
FunctionRNA *func;
|
|
|
|
void *ret;
|
2018-07-02 11:47:00 +02:00
|
|
|
bool visible;
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2009-07-21 20:05:16 +00:00
|
|
|
RNA_pointer_create(NULL, pt->ext.srna, NULL, &ptr); /* dummy */
|
2012-03-05 23:30:41 +00:00
|
|
|
func = &rna_Menu_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2009-07-17 02:31:28 +00:00
|
|
|
RNA_parameter_list_create(&list, &ptr, func);
|
|
|
|
RNA_parameter_set_lookup(&list, "context", &C);
|
2010-12-07 04:12:15 +00:00
|
|
|
pt->ext.call((bContext *)C, &ptr, func, &list);
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2009-07-17 02:31:28 +00:00
|
|
|
RNA_parameter_get_lookup(&list, "visible", &ret);
|
2018-07-01 15:47:09 +02:00
|
|
|
visible = *(bool *)ret;
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2009-07-17 02:31:28 +00:00
|
|
|
RNA_parameter_list_free(&list);
|
2009-04-22 18:39:44 +00:00
|
|
|
|
|
|
|
return visible;
|
|
|
|
}
|
|
|
|
|
2018-06-04 19:09:52 +02:00
|
|
|
static void menu_draw(const bContext *C, Menu *menu)
|
2009-04-22 18:39:44 +00:00
|
|
|
{
|
2011-10-19 22:40:03 +00:00
|
|
|
extern FunctionRNA rna_Menu_draw_func;
|
|
|
|
|
2009-04-22 18:39:44 +00:00
|
|
|
PointerRNA mtr;
|
2009-07-17 02:31:28 +00:00
|
|
|
ParameterList list;
|
2009-04-22 18:39:44 +00:00
|
|
|
FunctionRNA *func;
|
|
|
|
|
2018-06-04 19:09:52 +02:00
|
|
|
RNA_pointer_create(&CTX_wm_screen(C)->id, menu->type->ext.srna, menu, &mtr);
|
2012-03-05 23:30:41 +00:00
|
|
|
func = &rna_Menu_draw_func; /* RNA_struct_find_function(&mtr, "draw"); */
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2009-07-17 02:31:28 +00:00
|
|
|
RNA_parameter_list_create(&list, &mtr, func);
|
|
|
|
RNA_parameter_set_lookup(&list, "context", &C);
|
2018-06-04 19:09:52 +02:00
|
|
|
menu->type->ext.call((bContext *)C, &mtr, func, &list);
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2009-07-17 02:31:28 +00:00
|
|
|
RNA_parameter_list_free(&list);
|
2009-04-22 18:39:44 +00:00
|
|
|
}
|
|
|
|
|
2011-05-31 02:14:25 +00:00
|
|
|
static void rna_Menu_unregister(Main *UNUSED(bmain), StructRNA *type)
|
2009-04-22 18:39:44 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
MenuType *mt = RNA_struct_blender_type_get(type);
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (!mt)
|
2009-04-22 18:39:44 +00:00
|
|
|
return;
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2009-08-16 07:26:29 +00:00
|
|
|
RNA_struct_free_extension(type, &mt->ext);
|
2017-08-11 19:09:03 +10:00
|
|
|
RNA_struct_free(&BLENDER_RNA, type);
|
2009-08-14 12:29:55 +00:00
|
|
|
|
2009-10-08 19:06:32 +00:00
|
|
|
WM_menutype_freelink(mt);
|
|
|
|
|
2009-04-22 18:39:44 +00:00
|
|
|
/* update while blender is running */
|
2013-01-09 13:15:23 +00:00
|
|
|
WM_main_add_notifier(NC_WINDOW, NULL);
|
2009-04-22 18:39:44 +00:00
|
|
|
}
|
|
|
|
|
2017-09-13 21:52:57 +10:00
|
|
|
static StructRNA *rna_Menu_register(
|
|
|
|
Main *bmain, ReportList *reports, void *data, const char *identifier,
|
|
|
|
StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
|
2009-04-22 18:39:44 +00:00
|
|
|
{
|
2011-03-03 17:58:06 +00:00
|
|
|
MenuType *mt, dummymt = {NULL};
|
2012-03-05 23:30:41 +00:00
|
|
|
Menu dummymenu = {NULL};
|
2009-04-22 18:39:44 +00:00
|
|
|
PointerRNA dummymtr;
|
|
|
|
int have_function[2];
|
2012-03-05 23:30:41 +00:00
|
|
|
size_t over_alloc = 0; /* warning, if this becomes a bess, we better do another alloc */
|
|
|
|
size_t description_size = 0;
|
2014-02-07 07:39:44 +11:00
|
|
|
char _menu_descr[RNA_DYN_DESCR_MAX];
|
2009-04-22 18:39:44 +00:00
|
|
|
|
|
|
|
/* setup dummy menu & menu type to store static properties in */
|
2012-03-05 23:30:41 +00:00
|
|
|
dummymenu.type = &dummymt;
|
2014-02-07 07:39:44 +11:00
|
|
|
_menu_descr[0] = '\0';
|
2012-03-05 23:30:41 +00:00
|
|
|
dummymenu.type->description = _menu_descr;
|
2009-04-22 18:39:44 +00:00
|
|
|
RNA_pointer_create(NULL, &RNA_Menu, &dummymenu, &dummymtr);
|
|
|
|
|
2013-03-19 19:37:22 +00:00
|
|
|
/* We have to set default context! Else we get a void string... */
|
2015-08-16 17:32:01 +10:00
|
|
|
strcpy(dummymt.translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
|
2011-11-15 14:58:14 +00:00
|
|
|
|
2009-04-22 18:39:44 +00:00
|
|
|
/* validate the python class */
|
2012-03-05 23:30:41 +00:00
|
|
|
if (validate(&dummymtr, data, have_function) != 0)
|
2009-04-22 18:39:44 +00:00
|
|
|
return NULL;
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (strlen(identifier) >= sizeof(dummymt.idname)) {
|
2012-10-21 14:02:30 +00:00
|
|
|
BKE_reportf(reports, RPT_ERROR, "Registering menu class: '%s' is too long, maximum length is %d",
|
2011-09-19 13:23:58 +00:00
|
|
|
identifier, (int)sizeof(dummymt.idname));
|
2009-12-22 10:04:15 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2009-04-22 18:39:44 +00:00
|
|
|
|
|
|
|
/* check if we have registered this menu type before, and remove it */
|
2014-04-01 11:34:00 +11:00
|
|
|
mt = WM_menutype_find(dummymt.idname, true);
|
2017-08-23 14:59:14 +10:00
|
|
|
if (mt && mt->ext.srna) {
|
2011-05-18 10:56:26 +00:00
|
|
|
rna_Menu_unregister(bmain, mt->ext.srna);
|
2017-08-23 14:59:14 +10:00
|
|
|
}
|
2017-08-31 18:42:48 +10:00
|
|
|
if (!RNA_struct_available_or_report(reports, dummymt.idname)) {
|
2017-08-23 14:59:14 +10:00
|
|
|
return NULL;
|
|
|
|
}
|
2017-09-01 00:58:18 +10:00
|
|
|
if (!RNA_struct_bl_idname_ok_or_report(reports, dummymt.idname, "_MT_")) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2009-04-22 18:39:44 +00:00
|
|
|
/* create a new menu type */
|
2011-11-15 14:58:14 +00:00
|
|
|
if (_menu_descr[0]) {
|
2012-03-05 23:30:41 +00:00
|
|
|
description_size = strlen(_menu_descr) + 1;
|
2011-11-15 14:58:14 +00:00
|
|
|
over_alloc += description_size;
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
mt = MEM_callocN(sizeof(MenuType) + over_alloc, "python buttons menu");
|
2009-04-22 18:39:44 +00:00
|
|
|
memcpy(mt, &dummymt, sizeof(dummymt));
|
|
|
|
|
2011-11-15 14:58:14 +00:00
|
|
|
if (_menu_descr[0]) {
|
2012-03-05 23:30:41 +00:00
|
|
|
char *buf = (char *)(mt + 1);
|
2011-11-15 14:58:14 +00:00
|
|
|
memcpy(buf, _menu_descr, description_size);
|
2012-03-05 23:30:41 +00:00
|
|
|
mt->description = buf;
|
2011-11-15 14:58:14 +00:00
|
|
|
}
|
2018-11-14 09:47:23 +11:00
|
|
|
else {
|
|
|
|
mt->description = NULL;
|
|
|
|
}
|
2011-11-15 14:58:14 +00:00
|
|
|
|
2013-01-09 05:32:15 +00:00
|
|
|
mt->ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, mt->idname, &RNA_Menu);
|
2013-03-15 14:32:29 +00:00
|
|
|
RNA_def_struct_translation_context(mt->ext.srna, mt->translation_context);
|
2012-03-05 23:30:41 +00:00
|
|
|
mt->ext.data = data;
|
|
|
|
mt->ext.call = call;
|
|
|
|
mt->ext.free = free;
|
2009-07-21 20:05:16 +00:00
|
|
|
RNA_struct_blender_type_set(mt->ext.srna, mt);
|
2010-08-19 10:16:30 +00:00
|
|
|
RNA_def_struct_flag(mt->ext.srna, STRUCT_NO_IDPROPERTIES);
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
mt->poll = (have_function[0]) ? menu_poll : NULL;
|
|
|
|
mt->draw = (have_function[1]) ? menu_draw : NULL;
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2018-03-01 01:26:02 +11:00
|
|
|
{
|
|
|
|
const char *owner_id = RNA_struct_state_owner_get();
|
|
|
|
if (owner_id) {
|
|
|
|
BLI_strncpy(mt->owner_id, owner_id, sizeof(mt->owner_id));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-08 19:06:32 +00:00
|
|
|
WM_menutype_add(mt);
|
2009-04-22 18:39:44 +00:00
|
|
|
|
|
|
|
/* update while blender is running */
|
2013-01-09 13:15:23 +00:00
|
|
|
WM_main_add_notifier(NC_WINDOW, NULL);
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2009-07-21 20:05:16 +00:00
|
|
|
return mt->ext.srna;
|
2009-04-22 18:39:44 +00:00
|
|
|
}
|
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
static StructRNA *rna_Menu_refine(PointerRNA *mtr)
|
2009-04-22 18:39:44 +00:00
|
|
|
{
|
2018-06-04 19:09:52 +02:00
|
|
|
Menu *menu = (Menu *)mtr->data;
|
|
|
|
return (menu->type && menu->type->ext.srna) ? menu->type->ext.srna : &RNA_Menu;
|
2009-04-22 18:39:44 +00:00
|
|
|
}
|
|
|
|
|
2011-11-15 14:58:14 +00:00
|
|
|
static void rna_Menu_bl_description_set(PointerRNA *ptr, const char *value)
|
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
Menu *data = (Menu *)(ptr->data);
|
2012-03-05 23:30:41 +00:00
|
|
|
char *str = (char *)data->type->description;
|
2012-05-12 11:01:29 +00:00
|
|
|
if (!str[0]) BLI_strncpy(str, value, RNA_DYN_DESCR_MAX); /* utf8 already ensured */
|
|
|
|
else assert(!"setting the bl_description on a non-builtin menu");
|
2011-11-15 14:58:14 +00:00
|
|
|
}
|
|
|
|
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
/* UILayout */
|
|
|
|
|
2018-07-05 22:25:34 +02:00
|
|
|
static bool rna_UILayout_active_get(PointerRNA *ptr)
|
2009-05-28 23:37:55 +00:00
|
|
|
{
|
|
|
|
return uiLayoutGetActive(ptr->data);
|
|
|
|
}
|
|
|
|
|
2018-07-05 22:25:34 +02:00
|
|
|
static void rna_UILayout_active_set(PointerRNA *ptr, bool value)
|
2009-05-28 23:37:55 +00:00
|
|
|
{
|
RNA
* Mesh.add_geometry, Mesh.update and make indices editable. This
is without checking if they are valid still, no time now to
implement this.
* Also fix warnings in rna_ui.c, and a bug in CDDM_calc_edges.
Example code:
co = [0.0, 0.0, 0.0] + [1.0, 0.0, 0.0] + [0.0, 1.0, 0.0] + [1.0, 1.0, 0.0]
faces = [0, 1, 2, 0] + [1, 3, 2, 0]
mesh.add_geometry(4, 0, 2)
mesh.verts.foreach_set("co", co)
mesh.faces.foreach_set("verts", faces)
mesh.update()
2009-07-01 12:19:00 +00:00
|
|
|
uiLayoutSetActive(ptr->data, value);
|
2009-05-28 23:37:55 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 22:40:38 +11:00
|
|
|
static bool rna_UILayout_activate_init_get(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
return uiLayoutGetActivateInit(ptr->data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_UILayout_activate_init_set(PointerRNA *ptr, bool value)
|
|
|
|
{
|
|
|
|
uiLayoutSetActivateInit(ptr->data, value);
|
|
|
|
}
|
|
|
|
|
2018-07-05 22:25:34 +02:00
|
|
|
static bool rna_UILayout_alert_get(PointerRNA *ptr)
|
2011-01-02 23:47:48 +00:00
|
|
|
{
|
|
|
|
return uiLayoutGetRedAlert(ptr->data);
|
|
|
|
}
|
|
|
|
|
2018-07-05 22:25:34 +02:00
|
|
|
static void rna_UILayout_alert_set(PointerRNA *ptr, bool value)
|
2011-01-02 23:47:48 +00:00
|
|
|
{
|
|
|
|
uiLayoutSetRedAlert(ptr->data, value);
|
|
|
|
}
|
|
|
|
|
2009-07-21 01:26:17 +00:00
|
|
|
static void rna_UILayout_op_context_set(PointerRNA *ptr, int value)
|
2009-06-09 10:30:11 +00:00
|
|
|
{
|
RNA
* Mesh.add_geometry, Mesh.update and make indices editable. This
is without checking if they are valid still, no time now to
implement this.
* Also fix warnings in rna_ui.c, and a bug in CDDM_calc_edges.
Example code:
co = [0.0, 0.0, 0.0] + [1.0, 0.0, 0.0] + [0.0, 1.0, 0.0] + [1.0, 1.0, 0.0]
faces = [0, 1, 2, 0] + [1, 3, 2, 0]
mesh.add_geometry(4, 0, 2)
mesh.verts.foreach_set("co", co)
mesh.faces.foreach_set("verts", faces)
mesh.update()
2009-07-01 12:19:00 +00:00
|
|
|
uiLayoutSetOperatorContext(ptr->data, value);
|
2009-06-09 10:30:11 +00:00
|
|
|
}
|
|
|
|
|
2009-07-21 01:26:17 +00:00
|
|
|
static int rna_UILayout_op_context_get(PointerRNA *ptr)
|
2009-06-09 10:30:11 +00:00
|
|
|
{
|
|
|
|
return uiLayoutGetOperatorContext(ptr->data);
|
|
|
|
}
|
|
|
|
|
2018-07-05 22:25:34 +02:00
|
|
|
static bool rna_UILayout_enabled_get(PointerRNA *ptr)
|
2009-05-28 23:37:55 +00:00
|
|
|
{
|
|
|
|
return uiLayoutGetEnabled(ptr->data);
|
|
|
|
}
|
|
|
|
|
2018-07-05 22:25:34 +02:00
|
|
|
static void rna_UILayout_enabled_set(PointerRNA *ptr, bool value)
|
2009-05-28 23:37:55 +00:00
|
|
|
{
|
RNA
* Mesh.add_geometry, Mesh.update and make indices editable. This
is without checking if they are valid still, no time now to
implement this.
* Also fix warnings in rna_ui.c, and a bug in CDDM_calc_edges.
Example code:
co = [0.0, 0.0, 0.0] + [1.0, 0.0, 0.0] + [0.0, 1.0, 0.0] + [1.0, 1.0, 0.0]
faces = [0, 1, 2, 0] + [1, 3, 2, 0]
mesh.add_geometry(4, 0, 2)
mesh.verts.foreach_set("co", co)
mesh.faces.foreach_set("verts", faces)
mesh.update()
2009-07-01 12:19:00 +00:00
|
|
|
uiLayoutSetEnabled(ptr->data, value);
|
2009-05-28 23:37:55 +00:00
|
|
|
}
|
|
|
|
|
2009-07-21 01:26:17 +00:00
|
|
|
#if 0
|
|
|
|
static int rna_UILayout_red_alert_get(PointerRNA *ptr)
|
2009-05-28 23:37:55 +00:00
|
|
|
{
|
|
|
|
return uiLayoutGetRedAlert(ptr->data);
|
|
|
|
}
|
|
|
|
|
2018-07-05 22:25:34 +02:00
|
|
|
static void rna_UILayout_red_alert_set(PointerRNA *ptr, bool value)
|
2009-05-28 23:37:55 +00:00
|
|
|
{
|
RNA
* Mesh.add_geometry, Mesh.update and make indices editable. This
is without checking if they are valid still, no time now to
implement this.
* Also fix warnings in rna_ui.c, and a bug in CDDM_calc_edges.
Example code:
co = [0.0, 0.0, 0.0] + [1.0, 0.0, 0.0] + [0.0, 1.0, 0.0] + [1.0, 1.0, 0.0]
faces = [0, 1, 2, 0] + [1, 3, 2, 0]
mesh.add_geometry(4, 0, 2)
mesh.verts.foreach_set("co", co)
mesh.faces.foreach_set("verts", faces)
mesh.update()
2009-07-01 12:19:00 +00:00
|
|
|
uiLayoutSetRedAlert(ptr->data, value);
|
2009-05-28 23:37:55 +00:00
|
|
|
}
|
|
|
|
|
2018-07-05 22:25:34 +02:00
|
|
|
static bool rna_UILayout_keep_aspect_get(PointerRNA *ptr)
|
2009-05-28 23:37:55 +00:00
|
|
|
{
|
|
|
|
return uiLayoutGetKeepAspect(ptr->data);
|
|
|
|
}
|
|
|
|
|
2009-07-21 01:26:17 +00:00
|
|
|
static void rna_UILayout_keep_aspect_set(PointerRNA *ptr, int value)
|
2009-05-28 23:37:55 +00:00
|
|
|
{
|
RNA
* Mesh.add_geometry, Mesh.update and make indices editable. This
is without checking if they are valid still, no time now to
implement this.
* Also fix warnings in rna_ui.c, and a bug in CDDM_calc_edges.
Example code:
co = [0.0, 0.0, 0.0] + [1.0, 0.0, 0.0] + [0.0, 1.0, 0.0] + [1.0, 1.0, 0.0]
faces = [0, 1, 2, 0] + [1, 3, 2, 0]
mesh.add_geometry(4, 0, 2)
mesh.verts.foreach_set("co", co)
mesh.faces.foreach_set("verts", faces)
mesh.update()
2009-07-01 12:19:00 +00:00
|
|
|
uiLayoutSetKeepAspect(ptr->data, value);
|
2009-05-28 23:37:55 +00:00
|
|
|
}
|
2009-07-21 01:26:17 +00:00
|
|
|
#endif
|
2009-05-28 23:37:55 +00:00
|
|
|
|
2009-07-21 01:26:17 +00:00
|
|
|
static int rna_UILayout_alignment_get(PointerRNA *ptr)
|
2009-05-28 23:37:55 +00:00
|
|
|
{
|
|
|
|
return uiLayoutGetAlignment(ptr->data);
|
|
|
|
}
|
|
|
|
|
2009-07-21 01:26:17 +00:00
|
|
|
static void rna_UILayout_alignment_set(PointerRNA *ptr, int value)
|
2009-05-28 23:37:55 +00:00
|
|
|
{
|
RNA
* Mesh.add_geometry, Mesh.update and make indices editable. This
is without checking if they are valid still, no time now to
implement this.
* Also fix warnings in rna_ui.c, and a bug in CDDM_calc_edges.
Example code:
co = [0.0, 0.0, 0.0] + [1.0, 0.0, 0.0] + [0.0, 1.0, 0.0] + [1.0, 1.0, 0.0]
faces = [0, 1, 2, 0] + [1, 3, 2, 0]
mesh.add_geometry(4, 0, 2)
mesh.verts.foreach_set("co", co)
mesh.faces.foreach_set("verts", faces)
mesh.update()
2009-07-01 12:19:00 +00:00
|
|
|
uiLayoutSetAlignment(ptr->data, value);
|
2009-05-28 23:37:55 +00:00
|
|
|
}
|
|
|
|
|
2018-12-20 11:59:31 +11:00
|
|
|
static int rna_UILayout_direction_get(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
return uiLayoutGetLocalDir(ptr->data);
|
|
|
|
}
|
|
|
|
|
2009-07-21 01:26:17 +00:00
|
|
|
static float rna_UILayout_scale_x_get(PointerRNA *ptr)
|
2009-05-28 23:37:55 +00:00
|
|
|
{
|
2009-06-03 00:04:48 +00:00
|
|
|
return uiLayoutGetScaleX(ptr->data);
|
2009-05-28 23:37:55 +00:00
|
|
|
}
|
|
|
|
|
2009-07-21 01:26:17 +00:00
|
|
|
static void rna_UILayout_scale_x_set(PointerRNA *ptr, float value)
|
2009-05-28 23:37:55 +00:00
|
|
|
{
|
RNA
* Mesh.add_geometry, Mesh.update and make indices editable. This
is without checking if they are valid still, no time now to
implement this.
* Also fix warnings in rna_ui.c, and a bug in CDDM_calc_edges.
Example code:
co = [0.0, 0.0, 0.0] + [1.0, 0.0, 0.0] + [0.0, 1.0, 0.0] + [1.0, 1.0, 0.0]
faces = [0, 1, 2, 0] + [1, 3, 2, 0]
mesh.add_geometry(4, 0, 2)
mesh.verts.foreach_set("co", co)
mesh.faces.foreach_set("verts", faces)
mesh.update()
2009-07-01 12:19:00 +00:00
|
|
|
uiLayoutSetScaleX(ptr->data, value);
|
2009-06-03 00:04:48 +00:00
|
|
|
}
|
|
|
|
|
2009-07-21 01:26:17 +00:00
|
|
|
static float rna_UILayout_scale_y_get(PointerRNA *ptr)
|
2009-06-03 00:04:48 +00:00
|
|
|
{
|
|
|
|
return uiLayoutGetScaleY(ptr->data);
|
|
|
|
}
|
|
|
|
|
2009-07-21 01:26:17 +00:00
|
|
|
static void rna_UILayout_scale_y_set(PointerRNA *ptr, float value)
|
2009-06-03 00:04:48 +00:00
|
|
|
{
|
RNA
* Mesh.add_geometry, Mesh.update and make indices editable. This
is without checking if they are valid still, no time now to
implement this.
* Also fix warnings in rna_ui.c, and a bug in CDDM_calc_edges.
Example code:
co = [0.0, 0.0, 0.0] + [1.0, 0.0, 0.0] + [0.0, 1.0, 0.0] + [1.0, 1.0, 0.0]
faces = [0, 1, 2, 0] + [1, 3, 2, 0]
mesh.add_geometry(4, 0, 2)
mesh.verts.foreach_set("co", co)
mesh.faces.foreach_set("verts", faces)
mesh.update()
2009-07-01 12:19:00 +00:00
|
|
|
uiLayoutSetScaleY(ptr->data, value);
|
2009-05-28 23:37:55 +00:00
|
|
|
}
|
|
|
|
|
2018-09-26 17:44:35 +02:00
|
|
|
static float rna_UILayout_units_x_get(PointerRNA *ptr)
|
2018-09-25 20:59:04 +02:00
|
|
|
{
|
|
|
|
return uiLayoutGetUnitsX(ptr->data);
|
|
|
|
}
|
|
|
|
|
2018-09-26 17:44:35 +02:00
|
|
|
static void rna_UILayout_units_x_set(PointerRNA *ptr, float value)
|
2018-09-25 20:59:04 +02:00
|
|
|
{
|
|
|
|
uiLayoutSetUnitsX(ptr->data, value);
|
|
|
|
}
|
|
|
|
|
2018-09-26 17:44:35 +02:00
|
|
|
static float rna_UILayout_units_y_get(PointerRNA *ptr)
|
2018-09-25 20:59:04 +02:00
|
|
|
{
|
|
|
|
return uiLayoutGetUnitsY(ptr->data);
|
|
|
|
}
|
|
|
|
|
2018-09-26 17:44:35 +02:00
|
|
|
static void rna_UILayout_units_y_set(PointerRNA *ptr, float value)
|
2018-09-25 20:59:04 +02:00
|
|
|
{
|
|
|
|
uiLayoutSetUnitsY(ptr->data, value);
|
|
|
|
}
|
|
|
|
|
2018-05-13 12:57:31 +02:00
|
|
|
static int rna_UILayout_emboss_get(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
return uiLayoutGetEmboss(ptr->data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_UILayout_emboss_set(PointerRNA *ptr, int value)
|
|
|
|
{
|
|
|
|
uiLayoutSetEmboss(ptr->data, value);
|
|
|
|
}
|
|
|
|
|
2018-07-05 22:46:04 +02:00
|
|
|
static bool rna_UILayout_property_split_get(PointerRNA *ptr)
|
2018-05-28 16:40:27 +02:00
|
|
|
{
|
|
|
|
return uiLayoutGetPropSep(ptr->data);
|
|
|
|
}
|
|
|
|
|
2018-07-05 22:46:04 +02:00
|
|
|
static void rna_UILayout_property_split_set(PointerRNA *ptr, bool value)
|
2018-05-28 16:40:27 +02:00
|
|
|
{
|
|
|
|
uiLayoutSetPropSep(ptr->data, value);
|
|
|
|
}
|
|
|
|
|
2018-07-05 22:46:04 +02:00
|
|
|
static bool rna_UILayout_property_decorate_get(PointerRNA *ptr)
|
2018-06-16 14:48:21 +02:00
|
|
|
{
|
|
|
|
return uiLayoutGetPropDecorate(ptr->data);
|
|
|
|
}
|
|
|
|
|
2018-07-05 22:46:04 +02:00
|
|
|
static void rna_UILayout_property_decorate_set(PointerRNA *ptr, bool value)
|
2018-06-16 14:48:21 +02:00
|
|
|
{
|
|
|
|
uiLayoutSetPropDecorate(ptr->data, value);
|
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
#else /* RNA_RUNTIME */
|
2009-04-08 16:40:46 +00:00
|
|
|
|
|
|
|
static void rna_def_ui_layout(BlenderRNA *brna)
|
|
|
|
{
|
|
|
|
StructRNA *srna;
|
2009-05-28 23:37:55 +00:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem alignment_items[] = {
|
2009-06-16 00:52:21 +00:00
|
|
|
{UI_LAYOUT_ALIGN_EXPAND, "EXPAND", 0, "Expand", ""},
|
|
|
|
{UI_LAYOUT_ALIGN_LEFT, "LEFT", 0, "Left", ""},
|
|
|
|
{UI_LAYOUT_ALIGN_CENTER, "CENTER", 0, "Center", ""},
|
2009-10-22 16:35:51 +00:00
|
|
|
{UI_LAYOUT_ALIGN_RIGHT, "RIGHT", 0, "Right", ""},
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
2012-05-12 11:01:29 +00:00
|
|
|
};
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2018-12-20 11:59:31 +11:00
|
|
|
static const EnumPropertyItem direction_items[] = {
|
|
|
|
{UI_LAYOUT_HORIZONTAL, "HORIZONTAL", 0, "Horizontal", ""},
|
|
|
|
{UI_LAYOUT_VERTICAL, "VERTICAL", 0, "Vertical", ""},
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
2018-12-20 11:59:31 +11:00
|
|
|
};
|
|
|
|
|
2018-05-13 12:57:31 +02:00
|
|
|
static const EnumPropertyItem emboss_items[] = {
|
2019-02-12 21:28:04 +01:00
|
|
|
{UI_EMBOSS, "NORMAL", 0, "Regular", "Draw standard button emboss style"},
|
2018-05-13 12:57:31 +02:00
|
|
|
{UI_EMBOSS_NONE, "NONE", 0, "None", "Draw only text and icons"},
|
|
|
|
{UI_EMBOSS_PULLDOWN, "PULLDOWN_MENU", 0, "Pulldown Menu", "Draw pulldown menu style"},
|
|
|
|
{UI_EMBOSS_RADIAL, "RADIAL_MENU", 0, "Radial Menu", "Draw radial menu style"},
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
2018-05-13 12:57:31 +02:00
|
|
|
};
|
|
|
|
|
2009-07-21 01:26:17 +00:00
|
|
|
/* layout */
|
2009-04-08 16:40:46 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = RNA_def_struct(brna, "UILayout", NULL);
|
2009-04-08 16:40:46 +00:00
|
|
|
RNA_def_struct_sdna(srna, "uiLayout");
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "UI Layout", "User interface layout in a panel or header");
|
2009-04-08 16:40:46 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
|
2009-05-28 23:37:55 +00:00
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_UILayout_active_get", "rna_UILayout_active_set");
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2019-03-20 22:40:38 +11:00
|
|
|
prop = RNA_def_property(srna, "activate_init", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_UILayout_activate_init_get", "rna_UILayout_activate_init_set");
|
|
|
|
RNA_def_property_ui_text(
|
|
|
|
prop, "Activate on Init",
|
|
|
|
"When true, buttons defined in popups will be activated on first display "
|
|
|
|
"(use so you can type into a field without having to click on it first)");
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "operator_context", PROP_ENUM, PROP_NONE);
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_def_property_enum_items(prop, rna_enum_operator_context_items);
|
2009-06-09 10:30:11 +00:00
|
|
|
RNA_def_property_enum_funcs(prop, "rna_UILayout_op_context_get", "rna_UILayout_op_context_set", NULL);
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE);
|
2009-05-28 23:37:55 +00:00
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_UILayout_enabled_get", "rna_UILayout_enabled_set");
|
2012-07-03 19:09:07 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Enabled", "When false, this (sub)layout is grayed out");
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "alert", PROP_BOOLEAN, PROP_NONE);
|
2011-01-03 13:33:07 +00:00
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_UILayout_alert_get", "rna_UILayout_alert_set");
|
2009-05-28 23:37:55 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "alignment", PROP_ENUM, PROP_NONE);
|
2009-05-28 23:37:55 +00:00
|
|
|
RNA_def_property_enum_items(prop, alignment_items);
|
|
|
|
RNA_def_property_enum_funcs(prop, "rna_UILayout_alignment_get", "rna_UILayout_alignment_set", NULL);
|
|
|
|
|
2018-12-20 11:59:31 +11:00
|
|
|
prop = RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE);
|
|
|
|
RNA_def_property_enum_items(prop, direction_items);
|
|
|
|
RNA_def_property_enum_funcs(prop, "rna_UILayout_direction_get", NULL, NULL);
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
|
2009-07-21 01:26:17 +00:00
|
|
|
#if 0
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "keep_aspect", PROP_BOOLEAN, PROP_NONE);
|
2009-05-28 23:37:55 +00:00
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_UILayout_keep_aspect_get", "rna_UILayout_keep_aspect_set");
|
2009-07-21 01:26:17 +00:00
|
|
|
#endif
|
2009-05-28 23:37:55 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "scale_x", PROP_FLOAT, PROP_UNSIGNED);
|
2009-06-03 00:04:48 +00:00
|
|
|
RNA_def_property_float_funcs(prop, "rna_UILayout_scale_x_get", "rna_UILayout_scale_x_set", NULL);
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Scale X", "Scale factor along the X for items in this (sub)layout");
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "scale_y", PROP_FLOAT, PROP_UNSIGNED);
|
2009-06-03 00:04:48 +00:00
|
|
|
RNA_def_property_float_funcs(prop, "rna_UILayout_scale_y_get", "rna_UILayout_scale_y_set", NULL);
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Scale Y", "Scale factor along the Y for items in this (sub)layout");
|
2018-09-25 20:59:04 +02:00
|
|
|
|
2018-09-26 17:44:35 +02:00
|
|
|
prop = RNA_def_property(srna, "ui_units_x", PROP_FLOAT, PROP_UNSIGNED);
|
|
|
|
RNA_def_property_float_funcs(prop, "rna_UILayout_units_x_get", "rna_UILayout_units_x_set", NULL);
|
2018-09-25 20:59:04 +02:00
|
|
|
RNA_def_property_ui_text(prop, "Units X", "Fixed Size along the X for items in this (sub)layout");
|
|
|
|
|
2018-09-26 17:44:35 +02:00
|
|
|
prop = RNA_def_property(srna, "ui_units_y", PROP_FLOAT, PROP_UNSIGNED);
|
|
|
|
RNA_def_property_float_funcs(prop, "rna_UILayout_units_y_get", "rna_UILayout_units_y_set", NULL);
|
2018-09-25 20:59:04 +02:00
|
|
|
RNA_def_property_ui_text(prop, "Units Y", "Fixed Size along the Y for items in this (sub)layout");
|
2009-04-08 16:40:46 +00:00
|
|
|
RNA_api_ui_layout(srna);
|
2018-05-13 12:57:31 +02:00
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "emboss", PROP_ENUM, PROP_NONE);
|
|
|
|
RNA_def_property_enum_items(prop, emboss_items);
|
|
|
|
RNA_def_property_enum_funcs(prop, "rna_UILayout_emboss_get", "rna_UILayout_emboss_set", NULL);
|
2018-06-09 14:42:01 +02:00
|
|
|
|
2018-05-28 16:40:27 +02:00
|
|
|
prop = RNA_def_property(srna, "use_property_split", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_UILayout_property_split_get", "rna_UILayout_property_split_set");
|
2018-06-16 14:48:21 +02:00
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "use_property_decorate", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_UILayout_property_decorate_get", "rna_UILayout_property_decorate_set");
|
2009-04-08 16:40:46 +00:00
|
|
|
}
|
|
|
|
|
2009-04-19 13:37:59 +00:00
|
|
|
static void rna_def_panel(BlenderRNA *brna)
|
|
|
|
{
|
|
|
|
StructRNA *srna;
|
|
|
|
PropertyRNA *prop;
|
2009-12-26 17:49:08 +00:00
|
|
|
PropertyRNA *parm;
|
2009-04-19 13:37:59 +00:00
|
|
|
FunctionRNA *func;
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem panel_flag_items[] = {
|
2012-05-12 11:01:29 +00:00
|
|
|
{PNL_DEFAULT_CLOSED, "DEFAULT_CLOSED", 0, "Default Closed",
|
|
|
|
"Defines if the panel has to be open or collapsed at the time of its creation"},
|
2012-12-12 12:50:45 +00:00
|
|
|
{PNL_NO_HEADER, "HIDE_HEADER", 0, "Hide Header",
|
|
|
|
"If set to False, the panel shows a header, which contains a clickable "
|
2012-05-12 11:01:29 +00:00
|
|
|
"arrow to collapse the panel and the label (see bl_label)"},
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
2012-05-12 11:01:29 +00:00
|
|
|
};
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = RNA_def_struct(brna, "Panel", NULL);
|
2010-08-04 16:57:24 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Panel", "Panel containing UI elements");
|
2009-04-19 13:37:59 +00:00
|
|
|
RNA_def_struct_sdna(srna, "Panel");
|
|
|
|
RNA_def_struct_refine_func(srna, "rna_Panel_refine");
|
2011-05-18 11:21:10 +00:00
|
|
|
RNA_def_struct_register_funcs(srna, "rna_Panel_register", "rna_Panel_unregister", NULL);
|
2015-08-16 17:32:01 +10:00
|
|
|
RNA_def_struct_translation_context(srna, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
|
2017-08-31 23:32:21 +10:00
|
|
|
RNA_def_struct_flag(srna, STRUCT_PUBLIC_NAMESPACE_INHERIT);
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2009-04-19 17:12:16 +00:00
|
|
|
/* poll */
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "poll", NULL);
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_function_ui_description(func, "If this method returns a non-null output, then the panel can be drawn");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_REGISTER_OPTIONAL);
|
2009-04-19 13:37:59 +00:00
|
|
|
RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", ""));
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "context", "Context", "", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2009-04-19 17:12:16 +00:00
|
|
|
/* draw */
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "draw", NULL);
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_function_ui_description(func, "Draw UI elements into the panel UI layout");
|
2009-04-19 13:37:59 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_REGISTER);
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "context", "Context", "", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "draw_header", NULL);
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_function_ui_description(func, "Draw UI elements into the panel's header UI layout");
|
2013-01-28 12:18:00 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "context", "Context", "", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
|
2009-05-19 17:13:33 +00:00
|
|
|
|
2018-04-27 13:50:26 +02:00
|
|
|
func = RNA_def_function(srna, "draw_header_preset", NULL);
|
|
|
|
RNA_def_function_ui_description(func, "Draw UI elements for presets in the panel's header");
|
|
|
|
RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
|
|
|
|
parm = RNA_def_pointer(func, "context", "Context", "", "");
|
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE);
|
2009-04-19 13:37:59 +00:00
|
|
|
RNA_def_property_struct_type(prop, "UILayout");
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Layout", "Defines the structure of the panel in the UI");
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "text", PROP_STRING, PROP_NONE);
|
2009-07-28 16:46:14 +00:00
|
|
|
RNA_def_property_string_sdna(prop, NULL, "drawname");
|
2010-08-04 16:57:24 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Text", "XXX todo");
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2009-04-19 17:12:16 +00:00
|
|
|
/* registration */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
|
2009-04-19 17:12:16 +00:00
|
|
|
RNA_def_property_string_sdna(prop, NULL, "type->idname");
|
2014-02-09 05:51:22 +11:00
|
|
|
RNA_def_property_flag(prop, PROP_REGISTER);
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "ID Name",
|
|
|
|
"If this is set, the panel gets a custom ID, otherwise it takes the "
|
|
|
|
"name of the class used to define the panel. For example, if the "
|
|
|
|
"class name is \"OBJECT_PT_hello\", and bl_idname is not set by the "
|
|
|
|
"script, then bl_idname = \"OBJECT_PT_hello\"");
|
2012-02-16 15:53:30 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
|
2009-04-19 17:12:16 +00:00
|
|
|
RNA_def_property_string_sdna(prop, NULL, "type->label");
|
2009-04-19 13:37:59 +00:00
|
|
|
RNA_def_property_flag(prop, PROP_REGISTER);
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Label",
|
|
|
|
"The panel label, shows up in the panel header at the right of the "
|
|
|
|
"triangle used to collapse the panel");
|
2013-03-15 14:32:29 +00:00
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "bl_translation_context", PROP_STRING, PROP_NONE);
|
|
|
|
RNA_def_property_string_sdna(prop, NULL, "type->translation_context");
|
2015-08-16 17:32:01 +10:00
|
|
|
RNA_def_property_string_default(prop, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
|
2013-03-15 14:32:29 +00:00
|
|
|
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
|
2014-04-01 11:34:00 +11:00
|
|
|
RNA_define_verify_sdna(true);
|
2013-03-15 14:32:29 +00:00
|
|
|
|
2013-12-17 03:21:55 +11:00
|
|
|
prop = RNA_def_property(srna, "bl_category", PROP_STRING, PROP_NONE);
|
|
|
|
RNA_def_property_string_sdna(prop, NULL, "type->category");
|
|
|
|
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
|
|
|
|
|
2018-03-01 01:26:02 +11:00
|
|
|
prop = RNA_def_property(srna, "bl_owner_id", PROP_STRING, PROP_NONE);
|
|
|
|
RNA_def_property_string_sdna(prop, NULL, "type->owner_id");
|
|
|
|
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "bl_space_type", PROP_ENUM, PROP_NONE);
|
2009-04-19 17:12:16 +00:00
|
|
|
RNA_def_property_enum_sdna(prop, NULL, "type->space_type");
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_def_property_enum_items(prop, rna_enum_space_type_items);
|
2009-04-19 13:37:59 +00:00
|
|
|
RNA_def_property_flag(prop, PROP_REGISTER);
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Space type", "The space where the panel is going to be used in");
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "bl_region_type", PROP_ENUM, PROP_NONE);
|
2009-04-19 17:12:16 +00:00
|
|
|
RNA_def_property_enum_sdna(prop, NULL, "type->region_type");
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_def_property_enum_items(prop, rna_enum_region_type_items);
|
2009-04-19 13:37:59 +00:00
|
|
|
RNA_def_property_flag(prop, PROP_REGISTER);
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Region Type", "The region where the panel is going to be used in");
|
2009-04-19 13:37:59 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "bl_context", PROP_STRING, PROP_NONE);
|
2009-04-19 17:12:16 +00:00
|
|
|
RNA_def_property_string_sdna(prop, NULL, "type->context");
|
2012-04-28 08:27:09 +00:00
|
|
|
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); /* Only used in Properties Editor and 3D View - Thomas */
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Context",
|
|
|
|
"The context in which the panel belongs to. (TODO: explain the "
|
|
|
|
"possible combinations bl_context/bl_region_type/bl_space_type)");
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE);
|
2010-08-26 01:05:37 +00:00
|
|
|
RNA_def_property_enum_sdna(prop, NULL, "type->flag");
|
|
|
|
RNA_def_property_enum_items(prop, panel_flag_items);
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG);
|
2010-08-26 01:05:37 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Options", "Options for this panel type");
|
2013-12-17 03:21:55 +11:00
|
|
|
|
2018-06-03 13:32:36 +02:00
|
|
|
prop = RNA_def_property(srna, "bl_parent_id", PROP_STRING, PROP_NONE);
|
|
|
|
RNA_def_property_string_sdna(prop, NULL, "type->parent_id");
|
|
|
|
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
|
2018-12-24 12:31:39 +01:00
|
|
|
RNA_def_property_ui_text(prop, "Parent ID Name", "If this is set, the panel becomes a sub-panel");
|
2018-06-03 13:32:36 +02:00
|
|
|
|
2018-07-03 19:50:00 +02:00
|
|
|
prop = RNA_def_property(srna, "bl_ui_units_x", PROP_INT, PROP_UNSIGNED);
|
|
|
|
RNA_def_property_int_sdna(prop, NULL, "type->ui_units_x");
|
|
|
|
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
|
|
|
|
RNA_def_property_ui_text(prop, "Units X", "When set, defines popup panel width");
|
|
|
|
|
2013-12-17 03:21:55 +11:00
|
|
|
prop = RNA_def_property(srna, "use_pin", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
RNA_def_property_boolean_sdna(prop, NULL, "flag", PNL_PIN);
|
|
|
|
RNA_def_property_ui_text(prop, "Pin", "");
|
|
|
|
/* XXX, should only tag region for redraw */
|
|
|
|
RNA_def_property_update(prop, NC_WINDOW, NULL);
|
2018-06-09 17:36:28 +02:00
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "is_popover", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
RNA_def_property_boolean_sdna(prop, NULL, "flag", PNL_POPOVER);
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
RNA_def_property_ui_text(prop, "Popover", "");
|
2009-04-19 17:12:16 +00:00
|
|
|
}
|
|
|
|
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
static void rna_def_uilist(BlenderRNA *brna)
|
|
|
|
{
|
|
|
|
StructRNA *srna;
|
|
|
|
PropertyRNA *prop;
|
|
|
|
PropertyRNA *parm;
|
|
|
|
FunctionRNA *func;
|
|
|
|
|
|
|
|
srna = RNA_def_struct(brna, "UIList", NULL);
|
|
|
|
RNA_def_struct_ui_text(srna, "UIList", "UI list containing the elements of a collection");
|
|
|
|
RNA_def_struct_sdna(srna, "uiList");
|
|
|
|
RNA_def_struct_refine_func(srna, "rna_UIList_refine");
|
|
|
|
RNA_def_struct_register_funcs(srna, "rna_UIList_register", "rna_UIList_unregister", NULL);
|
2013-08-29 12:55:31 +00:00
|
|
|
RNA_def_struct_idprops_func(srna, "rna_UIList_idprops");
|
2017-08-31 23:32:21 +10:00
|
|
|
RNA_def_struct_flag(srna, STRUCT_NO_DATABLOCK_IDPROPERTIES | STRUCT_PUBLIC_NAMESPACE_INHERIT);
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
|
2013-08-29 12:55:31 +00:00
|
|
|
/* Registration */
|
|
|
|
prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
|
|
|
|
RNA_def_property_string_sdna(prop, NULL, "type->idname");
|
2014-02-09 05:51:22 +11:00
|
|
|
RNA_def_property_flag(prop, PROP_REGISTER);
|
2013-08-29 12:55:31 +00:00
|
|
|
RNA_def_property_ui_text(prop, "ID Name",
|
|
|
|
"If this is set, the uilist gets a custom ID, otherwise it takes the "
|
|
|
|
"name of the class used to define the uilist (for example, if the "
|
|
|
|
"class name is \"OBJECT_UL_vgroups\", and bl_idname is not set by the "
|
|
|
|
"script, then bl_idname = \"OBJECT_UL_vgroups\")");
|
|
|
|
|
|
|
|
/* Data */
|
|
|
|
prop = RNA_def_property(srna, "layout_type", PROP_ENUM, PROP_NONE);
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_def_property_enum_items(prop, rna_enum_uilist_layout_type_items);
|
2013-08-29 12:55:31 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
|
|
|
|
/* Filter options */
|
|
|
|
prop = RNA_def_property(srna, "use_filter_show", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
RNA_def_property_boolean_sdna(prop, NULL, "filter_flag", UILST_FLT_SHOW);
|
|
|
|
RNA_def_property_ui_text(prop, "Show Filter", "Show filtering options");
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "filter_name", PROP_STRING, PROP_NONE);
|
|
|
|
RNA_def_property_string_sdna(prop, NULL, "filter_byname");
|
2014-12-25 12:53:13 +01:00
|
|
|
RNA_def_property_flag(prop, PROP_TEXTEDIT_UPDATE);
|
2013-08-29 12:55:31 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Filter by Name", "Only show items matching this name (use '*' as wildcard)");
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "use_filter_invert", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
RNA_def_property_boolean_sdna(prop, NULL, "filter_flag", UILST_FLT_EXCLUDE);
|
|
|
|
RNA_def_property_ui_text(prop, "Invert", "Invert filtering (show hidden items, and vice-versa)");
|
|
|
|
|
2019-01-09 15:48:09 +01:00
|
|
|
/* WARNING: This is sort of an abuse, sort-by-alpha is actually a value, should even be an enum in full logic
|
|
|
|
* (of two values, sort by index and sort by name).
|
|
|
|
* But for default UIList, it's nicer (better UI-wise) to show this as a boolean bit-flag option,
|
|
|
|
* avoids having to define custom setters/getters using UILST_FLT_SORT_MASK to mask out
|
|
|
|
* actual bitflags on same var, etc.
|
|
|
|
*/
|
2013-08-30 11:49:35 +00:00
|
|
|
prop = RNA_def_property(srna, "use_filter_sort_alpha", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
RNA_def_property_boolean_sdna(prop, NULL, "filter_sort_flag", UILST_FLT_SORT_ALPHA);
|
|
|
|
RNA_def_property_ui_icon(prop, ICON_SORTALPHA, 0);
|
|
|
|
RNA_def_property_ui_text(prop, "Sort by Name", "Sort items by their name");
|
2013-08-29 12:55:31 +00:00
|
|
|
|
2013-08-30 11:49:35 +00:00
|
|
|
prop = RNA_def_property(srna, "use_filter_sort_reverse", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
RNA_def_property_boolean_sdna(prop, NULL, "filter_sort_flag", UILST_FLT_SORT_REVERSE);
|
2019-01-09 15:48:09 +01:00
|
|
|
RNA_def_property_ui_text(prop, "Reverse", "Reverse the order of shown items");
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "use_filter_sort_lock", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
RNA_def_property_boolean_sdna(prop, NULL, "filter_sort_flag", UILST_FLT_SORT_LOCK);
|
|
|
|
RNA_def_property_ui_text(prop, "Lock Order", "Lock the order of shown items (user cannot change it)");
|
2013-08-29 12:55:31 +00:00
|
|
|
|
|
|
|
/* draw_item */
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
func = RNA_def_function(srna, "draw_item", NULL);
|
|
|
|
RNA_def_function_ui_description(func, "Draw an item in the list (NOTE: when you define your own draw_item "
|
|
|
|
"function, you may want to check given 'item' is of the right type...)");
|
2013-01-28 18:46:04 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
parm = RNA_def_pointer(func, "context", "Context", "", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
parm = RNA_def_pointer(func, "layout", "UILayout", "", "Layout to draw the item");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take Collection property");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED | PARM_RNAPTR);
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
parm = RNA_def_pointer(func, "item", "AnyType", "", "Item of the collection property");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED | PARM_RNAPTR);
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
parm = RNA_def_int(func, "icon", 0, 0, INT_MAX, "", "Icon of the item in the collection", 0, INT_MAX);
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
parm = RNA_def_pointer(func, "active_data", "AnyType", "",
|
|
|
|
"Data from which to take property for the active element");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
|
2014-01-16 21:43:22 +11:00
|
|
|
parm = RNA_def_string(func, "active_property", NULL, 0, "",
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
"Identifier of property in active_data, for the active element");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
RNA_def_int(func, "index", 0, 0, INT_MAX, "", "Index of the item in the collection", 0, INT_MAX);
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED | PARM_PYFUNC_OPTIONAL);
|
2013-08-29 12:55:31 +00:00
|
|
|
prop = RNA_def_property(func, "flt_flag", PROP_INT, PROP_UNSIGNED);
|
|
|
|
RNA_def_property_ui_text(prop, "", "The filter-flag result for this item");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED | PARM_PYFUNC_OPTIONAL);
|
2013-08-29 12:55:31 +00:00
|
|
|
|
|
|
|
/* draw_filter */
|
|
|
|
func = RNA_def_function(srna, "draw_filter", NULL);
|
|
|
|
RNA_def_function_ui_description(func, "Draw filtering options");
|
|
|
|
RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
|
|
|
|
parm = RNA_def_pointer(func, "context", "Context", "", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2013-08-29 12:55:31 +00:00
|
|
|
parm = RNA_def_pointer(func, "layout", "UILayout", "", "Layout to draw the item");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
|
2013-08-29 12:55:31 +00:00
|
|
|
/* filter */
|
|
|
|
func = RNA_def_function(srna, "filter_items", NULL);
|
|
|
|
RNA_def_function_ui_description(func, "Filter and/or re-order items of the collection (output filter results in "
|
|
|
|
"filter_flags, and reorder results in filter_neworder arrays)");
|
|
|
|
RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
|
|
|
|
parm = RNA_def_pointer(func, "context", "Context", "", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2013-08-29 12:55:31 +00:00
|
|
|
parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take Collection property");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED | PARM_RNAPTR);
|
2014-01-16 21:43:22 +11:00
|
|
|
parm = RNA_def_string(func, "property", NULL, 0, "", "Identifier of property in data, for the collection");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2013-08-29 12:55:31 +00:00
|
|
|
prop = RNA_def_property(func, "filter_flags", PROP_INT, PROP_UNSIGNED);
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_property_flag(prop, PARM_REQUIRED | PROP_DYNAMIC);
|
2013-08-29 12:55:31 +00:00
|
|
|
RNA_def_property_array(prop, 1); /* XXX Dummy value, default 0 does not work */
|
|
|
|
RNA_def_property_ui_text(prop, "", "An array of filter flags, one for each item in the collection (NOTE: "
|
|
|
|
"FILTER_ITEM bit is reserved, it defines whether the item is shown or not)");
|
|
|
|
RNA_def_function_output(func, prop);
|
|
|
|
prop = RNA_def_property(func, "filter_neworder", PROP_INT, PROP_UNSIGNED);
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_property_flag(prop, PARM_REQUIRED | PROP_DYNAMIC);
|
2013-08-29 12:55:31 +00:00
|
|
|
RNA_def_property_array(prop, 1); /* XXX Dummy value, default 0 does not work */
|
|
|
|
RNA_def_property_ui_text(prop, "", "An array of indices, one for each item in the collection, mapping the org "
|
|
|
|
"index to the new one");
|
|
|
|
RNA_def_function_output(func, prop);
|
|
|
|
|
|
|
|
/* "Constants"! */
|
|
|
|
RNA_define_verify_sdna(0); /* not in sdna */
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "bitflag_filter_item", PROP_INT, PROP_UNSIGNED);
|
|
|
|
RNA_def_property_ui_text(prop, "FILTER_ITEM",
|
2013-09-09 20:22:01 +00:00
|
|
|
"The value of the reserved bitflag 'FILTER_ITEM' (in filter_flags values)");
|
2013-08-29 12:55:31 +00:00
|
|
|
RNA_def_property_int_funcs(prop, "rna_UIList_filter_const_FILTER_ITEM_get", NULL, NULL);
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
}
|
|
|
|
|
2009-04-19 17:12:16 +00:00
|
|
|
static void rna_def_header(BlenderRNA *brna)
|
|
|
|
{
|
|
|
|
StructRNA *srna;
|
|
|
|
PropertyRNA *prop;
|
2009-12-26 17:49:08 +00:00
|
|
|
PropertyRNA *parm;
|
2009-04-19 17:12:16 +00:00
|
|
|
FunctionRNA *func;
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = RNA_def_struct(brna, "Header", NULL);
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Header", "Editor header containing UI elements");
|
2009-04-19 17:12:16 +00:00
|
|
|
RNA_def_struct_sdna(srna, "Header");
|
|
|
|
RNA_def_struct_refine_func(srna, "rna_Header_refine");
|
2011-05-18 11:21:10 +00:00
|
|
|
RNA_def_struct_register_funcs(srna, "rna_Header_register", "rna_Header_unregister", NULL);
|
2017-08-31 23:32:21 +10:00
|
|
|
RNA_def_struct_flag(srna, STRUCT_PUBLIC_NAMESPACE_INHERIT);
|
2009-04-19 17:12:16 +00:00
|
|
|
|
|
|
|
/* draw */
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "draw", NULL);
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_function_ui_description(func, "Draw UI elements into the header UI layout");
|
2009-04-19 17:12:16 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_REGISTER);
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "context", "Context", "", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2009-04-19 17:12:16 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
RNA_define_verify_sdna(0); /* not in sdna */
|
2009-07-21 01:14:55 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE);
|
2009-07-21 01:14:55 +00:00
|
|
|
RNA_def_property_pointer_sdna(prop, NULL, "layout");
|
2009-04-19 17:12:16 +00:00
|
|
|
RNA_def_property_struct_type(prop, "UILayout");
|
2011-09-29 14:41:11 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Layout", "Structure of the header in the UI");
|
2009-04-19 17:12:16 +00:00
|
|
|
|
|
|
|
/* registration */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
|
2009-04-19 17:12:16 +00:00
|
|
|
RNA_def_property_string_sdna(prop, NULL, "type->idname");
|
2014-02-09 05:51:22 +11:00
|
|
|
RNA_def_property_flag(prop, PROP_REGISTER);
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "ID Name",
|
|
|
|
"If this is set, the header gets a custom ID, otherwise it takes the "
|
2011-09-29 14:41:11 +00:00
|
|
|
"name of the class used to define the panel; for example, if the "
|
2011-09-19 13:23:58 +00:00
|
|
|
"class name is \"OBJECT_HT_hello\", and bl_idname is not set by the "
|
|
|
|
"script, then bl_idname = \"OBJECT_HT_hello\"");
|
2009-04-19 17:12:16 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "bl_space_type", PROP_ENUM, PROP_NONE);
|
2009-04-19 17:12:16 +00:00
|
|
|
RNA_def_property_enum_sdna(prop, NULL, "type->space_type");
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_def_property_enum_items(prop, rna_enum_space_type_items);
|
2009-04-19 13:37:59 +00:00
|
|
|
RNA_def_property_flag(prop, PROP_REGISTER);
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Space type", "The space where the header is going to be used in");
|
2009-07-21 01:14:55 +00:00
|
|
|
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
prop = RNA_def_property(srna, "bl_region_type", PROP_ENUM, PROP_NONE);
|
|
|
|
RNA_def_property_enum_sdna(prop, NULL, "type->region_type");
|
|
|
|
RNA_def_property_enum_default(prop, RGN_TYPE_HEADER);
|
|
|
|
RNA_def_property_enum_items(prop, rna_enum_region_type_items);
|
|
|
|
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
|
|
|
|
RNA_def_property_ui_text(prop, "Region Type", "The region where the header is going to be used in "
|
|
|
|
"(defaults to header region)");
|
|
|
|
|
2009-07-21 01:14:55 +00:00
|
|
|
RNA_define_verify_sdna(1);
|
2009-04-19 13:37:59 +00:00
|
|
|
}
|
|
|
|
|
2009-04-22 18:39:44 +00:00
|
|
|
static void rna_def_menu(BlenderRNA *brna)
|
|
|
|
{
|
|
|
|
StructRNA *srna;
|
|
|
|
PropertyRNA *prop;
|
2009-12-26 17:49:08 +00:00
|
|
|
PropertyRNA *parm;
|
2009-04-22 18:39:44 +00:00
|
|
|
FunctionRNA *func;
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = RNA_def_struct(brna, "Menu", NULL);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Menu", "Editor menu containing buttons");
|
2009-04-22 18:39:44 +00:00
|
|
|
RNA_def_struct_sdna(srna, "Menu");
|
|
|
|
RNA_def_struct_refine_func(srna, "rna_Menu_refine");
|
2011-05-18 11:21:10 +00:00
|
|
|
RNA_def_struct_register_funcs(srna, "rna_Menu_register", "rna_Menu_unregister", NULL);
|
2015-08-16 17:32:01 +10:00
|
|
|
RNA_def_struct_translation_context(srna, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
|
2017-08-31 23:32:21 +10:00
|
|
|
RNA_def_struct_flag(srna, STRUCT_PUBLIC_NAMESPACE_INHERIT);
|
2009-04-22 18:39:44 +00:00
|
|
|
|
|
|
|
/* poll */
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "poll", NULL);
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_function_ui_description(func, "If this method returns a non-null output, then the menu can be drawn");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_REGISTER_OPTIONAL);
|
2009-04-22 18:39:44 +00:00
|
|
|
RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", ""));
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "context", "Context", "", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2009-04-22 18:39:44 +00:00
|
|
|
|
|
|
|
/* draw */
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "draw", NULL);
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_function_ui_description(func, "Draw UI elements into the menu UI layout");
|
2009-04-22 18:39:44 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_REGISTER);
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "context", "Context", "", "");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
RNA_define_verify_sdna(false); /* not in sdna */
|
2009-07-21 01:14:55 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE);
|
2009-07-21 01:14:55 +00:00
|
|
|
RNA_def_property_pointer_sdna(prop, NULL, "layout");
|
2009-04-22 18:39:44 +00:00
|
|
|
RNA_def_property_struct_type(prop, "UILayout");
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Layout", "Defines the structure of the menu in the UI");
|
2009-04-22 18:39:44 +00:00
|
|
|
|
|
|
|
/* registration */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
|
2009-04-22 18:39:44 +00:00
|
|
|
RNA_def_property_string_sdna(prop, NULL, "type->idname");
|
2014-02-09 05:51:22 +11:00
|
|
|
RNA_def_property_flag(prop, PROP_REGISTER);
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_property_ui_text(prop, "ID Name",
|
|
|
|
"If this is set, the menu gets a custom ID, otherwise it takes the "
|
2011-10-02 08:46:46 +00:00
|
|
|
"name of the class used to define the menu (for example, if the "
|
2011-09-19 13:23:58 +00:00
|
|
|
"class name is \"OBJECT_MT_hello\", and bl_idname is not set by the "
|
2011-10-02 08:46:46 +00:00
|
|
|
"script, then bl_idname = \"OBJECT_MT_hello\")");
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
|
2009-04-22 18:39:44 +00:00
|
|
|
RNA_def_property_string_sdna(prop, NULL, "type->label");
|
|
|
|
RNA_def_property_flag(prop, PROP_REGISTER);
|
2010-08-04 16:57:24 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Label", "The menu label");
|
2009-04-22 18:39:44 +00:00
|
|
|
|
2013-03-15 14:32:29 +00:00
|
|
|
prop = RNA_def_property(srna, "bl_translation_context", PROP_STRING, PROP_NONE);
|
|
|
|
RNA_def_property_string_sdna(prop, NULL, "type->translation_context");
|
2015-08-16 17:32:01 +10:00
|
|
|
RNA_def_property_string_default(prop, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
|
2013-03-15 14:32:29 +00:00
|
|
|
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
|
|
|
|
|
2013-01-05 13:52:41 +00:00
|
|
|
prop = RNA_def_property(srna, "bl_description", PROP_STRING, PROP_NONE);
|
2011-11-15 14:58:14 +00:00
|
|
|
RNA_def_property_string_sdna(prop, NULL, "type->description");
|
2011-11-15 15:24:57 +00:00
|
|
|
RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */
|
2011-11-15 14:58:14 +00:00
|
|
|
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Menu_bl_description_set");
|
2012-03-05 23:30:41 +00:00
|
|
|
/* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
|
2011-11-15 14:58:14 +00:00
|
|
|
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
|
2012-04-09 04:39:47 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_NEVER_NULL); /* check for NULL */
|
2011-11-15 14:58:14 +00:00
|
|
|
|
2018-03-01 01:26:02 +11:00
|
|
|
prop = RNA_def_property(srna, "bl_owner_id", PROP_STRING, PROP_NONE);
|
|
|
|
RNA_def_property_string_sdna(prop, NULL, "type->owner_id");
|
|
|
|
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
|
|
|
|
|
2009-07-21 01:14:55 +00:00
|
|
|
RNA_define_verify_sdna(1);
|
2009-04-22 18:39:44 +00:00
|
|
|
}
|
|
|
|
|
2009-04-08 16:40:46 +00:00
|
|
|
void RNA_def_ui(BlenderRNA *brna)
|
|
|
|
{
|
|
|
|
rna_def_ui_layout(brna);
|
2009-04-19 13:37:59 +00:00
|
|
|
rna_def_panel(brna);
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
rna_def_uilist(brna);
|
2009-04-19 17:12:16 +00:00
|
|
|
rna_def_header(brna);
|
2009-04-22 18:39:44 +00:00
|
|
|
rna_def_menu(brna);
|
2009-04-08 16:40:46 +00:00
|
|
|
}
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
#endif /* RNA_RUNTIME */
|