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 | |
parent | d4ac65d003244db4368222f52fbc8fad1cf9a788 (diff) |
UI: Expand space sub-types into the menu
Initial support for expanding editors, see: T54744
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/RNA_enum_types.h | 3 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_screen.c | 67 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 8 |
3 files changed, 77 insertions, 1 deletions
diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index bb09fe585ba..da2705d4660 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -245,4 +245,7 @@ const EnumPropertyItem *RNA_movieclip_local_itemf(struct bContext *C, struct Poi const EnumPropertyItem *RNA_mask_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free); const EnumPropertyItem *RNA_mask_local_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, bool *r_free); +/* Non confirming, utility function. */ +const EnumPropertyItem *RNA_enum_node_tree_types_itemf_impl(struct bContext *C, bool *r_free); + #endif /* __RNA_ENUM_TYPES_H__ */ 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); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index e4107ee00ef..828a1c61460 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1494,11 +1494,17 @@ static int rna_SpaceNodeEditor_tree_type_poll(void *Cv, bNodeTreeType *type) else return true; } + +const EnumPropertyItem *RNA_enum_node_tree_types_itemf_impl(bContext *C, bool *r_free) +{ + return rna_node_tree_type_itemf(C, rna_SpaceNodeEditor_tree_type_poll, r_free); +} + static const EnumPropertyItem *rna_SpaceNodeEditor_tree_type_itemf( bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) { - return rna_node_tree_type_itemf(C, rna_SpaceNodeEditor_tree_type_poll, r_free); + return RNA_enum_node_tree_types_itemf_impl(C, r_free); } static void rna_SpaceNodeEditor_path_get(PointerRNA *ptr, char *value) |