diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-05-29 10:19:06 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-05-29 13:15:26 +0300 |
commit | 756b70c6c34d596558f6fadf808ecb2a4bf8e3bf (patch) | |
tree | fe1c1e6ca51d4a3e5d2a3e0918d442642ad933f1 /source/blender/makesrna/intern/rna_screen.c | |
parent | d4ac65d003244db4368222f52fbc8fad1cf9a788 (diff) |
UI: Expand space sub-types into the menu
Initial support for expanding editors, see: T54744
Diffstat (limited to 'source/blender/makesrna/intern/rna_screen.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_screen.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c index b8c7eff6241..deaf73bc9a5 100644 --- a/source/blender/makesrna/intern/rna_screen.c +++ b/source/blender/makesrna/intern/rna_screen.c @@ -58,6 +58,7 @@ const EnumPropertyItem rna_enum_region_type_items[] = { #include "BKE_global.h" #include "BKE_workspace.h" +#include "BKE_screen.h" #include "DEG_depsgraph.h" @@ -214,6 +215,63 @@ static void rna_Area_type_update(bContext *C, PointerRNA *ptr) } } + +static const EnumPropertyItem *rna_Area_ui_type_itemf( + bContext *C, PointerRNA *UNUSED(ptr), + PropertyRNA *UNUSED(prop), bool *r_free) +{ + EnumPropertyItem *item = NULL; + int totitem = 0; + + /* +1 to skip SPACE_EMPTY */ + for (const EnumPropertyItem *item_from = rna_enum_space_type_items + 1; item_from->identifier; item_from++) { + if (ELEM(item_from->value, SPACE_TOPBAR, SPACE_STATUSBAR)) { + continue; + } + + SpaceType *st = item_from->identifier[0] ? BKE_spacetype_from_id(item_from->value) : NULL; + int totitem_prev = totitem; + if (st && st->space_subtype_item_extend != NULL) { + st->space_subtype_item_extend(C, &item, &totitem); + while (totitem_prev < totitem) { + item[totitem_prev++].value |= item_from->value << 16; + } + } + else { + RNA_enum_item_add(&item, &totitem, item_from); + item[totitem_prev++].value = item_from->value << 16; + } + } + RNA_enum_item_end(&item, &totitem); + *r_free = true; + + return item; +} + +static int rna_Area_ui_type_get(PointerRNA *ptr) +{ + int value = rna_Area_type_get(ptr) << 16; + ScrArea *sa = (ScrArea *)ptr->data; + if (sa->type->space_subtype_item_extend != NULL) { + value |= sa->type->space_subtype_get(sa); + } + return value; +} + +static void rna_Area_ui_type_set(PointerRNA *ptr, int value) +{ + rna_Area_type_set(ptr, value >> 16); + ScrArea *sa = (ScrArea *)ptr->data; + if (sa->type->space_subtype_item_extend != NULL) { + sa->type->space_subtype_set(sa, value & 0xffff); + } +} + +static void rna_Area_ui_type_update(bContext *C, PointerRNA *ptr) +{ + rna_Area_type_update(C, ptr); +} + static void rna_View2D_region_to_view(struct View2D *v2d, int x, int y, float result[2]) { UI_view2d_region_to_view(v2d, x, y, &result[0], &result[1]); @@ -284,6 +342,15 @@ static void rna_def_area(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_update(prop, 0, "rna_Area_type_update"); + prop = RNA_def_property(srna, "ui_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, DummyRNA_DEFAULT_items); /* infact dummy */ + RNA_def_property_enum_default(prop, 0); + RNA_def_property_enum_funcs(prop, "rna_Area_ui_type_get", "rna_Area_ui_type_set", "rna_Area_ui_type_itemf"); + RNA_def_property_ui_text(prop, "Editor Type", "Current editor type for this area"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_update(prop, 0, "rna_Area_ui_type_update"); + prop = RNA_def_property(srna, "x", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "totrct.xmin"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); |