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/editors/space_node/space_node.c | |
parent | d4ac65d003244db4368222f52fbc8fad1cf9a788 (diff) |
UI: Expand space sub-types into the menu
Initial support for expanding editors, see: T54744
Diffstat (limited to 'source/blender/editors/space_node/space_node.c')
-rw-r--r-- | source/blender/editors/space_node/space_node.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 28598591012..3b24500d044 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -54,6 +54,8 @@ #include "UI_view2d.h" #include "RNA_access.h" +#include "RNA_define.h" +#include "RNA_enum_types.h" #include "WM_api.h" #include "WM_types.h" @@ -942,6 +944,32 @@ static void node_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID } } + +static int node_space_subtype_get(ScrArea *sa) +{ + SpaceNode *snode = sa->spacedata.first; + return rna_node_tree_idname_to_enum(snode->tree_idname); +} + +static void node_space_subtype_set(ScrArea *sa, int value) +{ + SpaceNode *snode = sa->spacedata.first; + ED_node_set_tree_type(snode, rna_node_tree_type_from_enum(value)); +} + +static void node_space_subtype_item_extend( + bContext *C, EnumPropertyItem **item, int *totitem) +{ + bool free; + const EnumPropertyItem *item_src = RNA_enum_node_tree_types_itemf_impl(C, &free); + for (const EnumPropertyItem *item_iter = item_src; item_iter->identifier; item_iter++) { + RNA_enum_item_add(item, totitem, item_iter); + } + if (free) { + MEM_freeN((void *)item_src); + } +} + /* only called once, from space/spacetypes.c */ void ED_spacetype_node(void) { @@ -964,6 +992,10 @@ void ED_spacetype_node(void) st->manipulators = node_widgets; st->id_remap = node_id_remap; + st->space_subtype_item_extend = node_space_subtype_item_extend; + st->space_subtype_get = node_space_subtype_get; + st->space_subtype_set = node_space_subtype_set; + /* regions: main window */ art = MEM_callocN(sizeof(ARegionType), "spacetype node region"); art->regionid = RGN_TYPE_WINDOW; |