Commit: b0223ebc071caa447aff0800dd2e249850573358
Author: Julian Eisel
Date:   Sat Jun 18 20:46:47 2016 +0200
Branches: soc-2016-layer_manager
https://developer.blender.org/rBb0223ebc071caa447aff0800dd2e249850573358

Expose LayerTree and LayerTreeItem in RNA

Will be used for custom property support.

===================================================================

M       source/blender/makesdna/DNA_scene_types.h
M       source/blender/makesdna/DNA_space_types.h
M       source/blender/makesrna/RNA_access.h
M       source/blender/makesrna/intern/rna_scene.c

===================================================================

diff --git a/source/blender/makesdna/DNA_scene_types.h 
b/source/blender/makesdna/DNA_scene_types.h
index 6d106a5..63fc6aa 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -49,6 +49,7 @@ extern "C" {
 #include "DNA_gpu_types.h"
 #include "DNA_userdef_types.h"
 
+struct bContext;
 struct CurveMapping;
 struct Object;
 struct Brush;
@@ -64,6 +65,7 @@ struct SceneStats;
 struct bGPdata;
 struct MovieClip;
 struct ColorSpace;
+struct uiLayout;
 
 /* ************************************************************* */
 /* Scene Data */
@@ -77,6 +79,53 @@ typedef struct Base {
        struct Object *object;
 } Base;
 
+/* ------------------------------------------- */
+/* Layers */
+
+typedef struct LayerTree {
+       int type; /* eLayerTree_Type */
+
+       unsigned int tot_items; /* total items of *all hierarchy levels*, not 
only what's in "items" below */
+       /* LayerTreeItem - Only items of the first level in the hierarchy, 
these may have children then.
+        * TODO check if worth using array instead */
+       ListBase items;
+       /* Array of all layer tree items, including all childs. Using array in 
hope it speeds up iterations. */
+       struct LayerTreeItem **items_all;
+} LayerTree;
+
+/**
+ * \brief An item of the layer tree.
+ * Used as a base struct for the individual layer tree item types (layer, 
layer group, compositing layer, etc).
+ */
+typedef struct LayerTreeItem {
+       struct LayerTreeItem *next, *prev;
+
+       int type;      /* eLayerTreeItem_Type */
+       int index;     /* index of the item - stored to avoid loockups */
+       char name[64]; /* MAX_NAME */
+
+       struct LayerTree *tree; /* pointer back to layer tree - TODO check if 
needed */
+       struct LayerTreeItem *parent; /* the group this item belongs to */
+       ListBase childs; /* LayerTreeItem */
+
+       /* item is grayed out if this check fails */
+       short (*poll)(const struct bContext *, struct LayerTreeItem *); /* 
LayerItemPollFunc */
+       /* drawing of the item in the list */
+       void (*draw)(const struct bContext *, struct LayerTreeItem *, struct 
uiLayout *); /* LayerItemDrawFunc */
+       /* drawing of the expanded layer settings (gear wheel icon) */
+       void (*draw_settings)(const struct bContext *, struct LayerTreeItem *, 
struct uiLayout *); /* LayerItemDrawSettingsFunc */
+
+       /* Optional free callback. Don't free item itself! */
+       void (*free)(struct LayerTreeItem *);
+} LayerTreeItem;
+
+typedef struct LayerTypeObject {
+       LayerTreeItem litem;
+       Base **bases;           /* Array of objects assigned to this layer. */
+       unsigned int tot_bases; /* amount of objects assigned to this layer */
+       int pad;
+} LayerTypeObject;
+
 /* ************************************************************* */
 /* Output Format Data */
 
diff --git a/source/blender/makesdna/DNA_space_types.h 
b/source/blender/makesdna/DNA_space_types.h
index 4f071da..3fa7857 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -1337,50 +1337,6 @@ typedef enum eSpaceClip_GPencil_Source {
 
 /* Layer Manager ======================================= */
 
-typedef struct LayerTree {
-       int type; /* eLayerTree_Type */
-
-       unsigned int tot_items; /* total items of *all hierarchy levels*, not 
only what's in "items" below */
-       /* LayerTreeItem - Only items of the first level in the hierarchy, 
these may have children then.
-        * TODO check if worth using array instead */
-       ListBase items;
-       /* Array of all layer tree items, including all childs. Using array in 
hope it speeds up iterations. */
-       struct LayerTreeItem **items_all;
-} LayerTree;
-
-/**
- * \brief An item of the layer tree.
- * Used as a base struct for the individual layer tree item types (layer, 
layer group, compositing layer, etc).
- */
-typedef struct LayerTreeItem {
-       struct LayerTreeItem *next, *prev;
-
-       int type;      /* eLayerTreeItem_Type */
-       int index;     /* index of the item - stored to avoid loockups */
-       char name[64]; /* MAX_NAME */
-
-       struct LayerTree *tree; /* pointer back to layer tree - TODO check if 
needed */
-       struct LayerTreeItem *parent; /* the group this item belongs to */
-       ListBase childs; /* LayerTreeItem */
-
-       /* item is grayed out if this check fails */
-       short (*poll)(const struct bContext *, struct LayerTreeItem *); /* 
LayerItemPollFunc */
-       /* drawing of the item in the list */
-       void (*draw)(const struct bContext *, struct LayerTreeItem *, struct 
uiLayout *); /* LayerItemDrawFunc */
-       /* drawing of the expanded layer settings (gear wheel icon) */
-       void (*draw_settings)(const struct bContext *, struct LayerTreeItem *, 
struct uiLayout *); /* LayerItemDrawSettingsFunc */
-
-       /* Optional free callback. Don't free item itself! */
-       void (*free)(struct LayerTreeItem *);
-} LayerTreeItem;
-
-typedef struct LayerTypeObject {
-       LayerTreeItem litem;
-       Base **bases;           /* Array of objects assigned to this layer. */
-       unsigned int tot_bases; /* amount of objects assigned to this layer */
-       int pad;
-} LayerTypeObject;
-
 /* SpaceLayers->flag */
 typedef enum eSpaceLayers_Flag {
        SL_LAYERDATA_REFRESH = (1 << 0), /* recreate/update SpaceLayers layer 
data, needed for undo/read/write */
diff --git a/source/blender/makesrna/RNA_access.h 
b/source/blender/makesrna/RNA_access.h
index 92ed30d..addfc6c 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -311,6 +311,8 @@ extern StructRNA RNA_LaplacianSmoothModifier;
 extern StructRNA RNA_Lattice;
 extern StructRNA RNA_LatticeModifier;
 extern StructRNA RNA_LatticePoint;
+extern StructRNA RNA_LayerTree;
+extern StructRNA RNA_LayerTreeItem;
 extern StructRNA RNA_Library;
 extern StructRNA RNA_LimitDistanceConstraint;
 extern StructRNA RNA_LimitLocationConstraint;
diff --git a/source/blender/makesrna/intern/rna_scene.c 
b/source/blender/makesrna/intern/rna_scene.c
index 533c0f8..bb6564d 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -411,6 +411,7 @@ EnumPropertyItem rna_enum_bake_pass_filter_type_items[] = {
 #include "DNA_node_types.h"
 #include "DNA_object_types.h"
 #include "DNA_mesh_types.h"
+#include "DNA_space_types.h"
 #include "DNA_text_types.h"
 
 #include "RNA_access.h"
@@ -788,6 +789,12 @@ static void 
rna_Scene_all_keyingsets_next(CollectionPropertyIterator *iter)
        iter->valid = (internal->link != NULL);
 }
 
+static void rna_layer_tree_items_begin(CollectionPropertyIterator *iter, 
PointerRNA *ptr)
+{
+       LayerTree *ltree = ptr->data;
+       rna_iterator_array_begin(iter, ltree->items_all, sizeof(LayerTreeItem 
*), ltree->tot_items, 0, NULL);
+}
+
 static int rna_RenderSettings_stereoViews_skip(CollectionPropertyIterator 
*iter, void *UNUSED(data))
 {
        ListBaseIterator *internal = &iter->internal.listbase;
@@ -6421,6 +6428,30 @@ static void rna_def_display_safe_areas(BlenderRNA *brna)
        RNA_def_property_update(prop, NC_SCENE | ND_DRAW_RENDER_VIEWPORT, NULL);
 }
 
+static void rna_def_layer_tree_item(BlenderRNA *brna)
+{
+       StructRNA *srna = RNA_def_struct(brna, "LayerTreeItem", NULL);
+       PropertyRNA *prop;
+
+       prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+       RNA_def_property_ui_text(prop, "Name", "Name of the item");
+}
+
+static void rna_def_layer_tree(BlenderRNA *brna)
+{
+       StructRNA *srna = RNA_def_struct(brna, "LayerTree", NULL);
+       PropertyRNA *prop;
+
+       prop = RNA_def_property(srna, "tree_items", PROP_COLLECTION, PROP_NONE);
+       RNA_def_property_collection_sdna(prop, NULL, "items_all", NULL);
+       RNA_def_property_struct_type(prop, "LayerTreeItem");
+       RNA_def_property_ui_text(prop, "Layer Items", "The items of the layer 
tree that represent the "
+                                "layer types (object layer, layer group, 
compositing layer, ...)");
+       RNA_def_property_collection_funcs(prop, "rna_layer_tree_items_begin", 
"rna_iterator_array_next",
+                                         "rna_iterator_array_end", 
"rna_iterator_array_get", NULL, NULL, NULL, NULL);
+
+       rna_def_layer_tree_item(brna);
+}
 
 void RNA_def_scene(BlenderRNA *brna)
 {
@@ -6513,6 +6544,9 @@ void RNA_def_scene(BlenderRNA *brna)
        RNA_def_property_int_funcs(prop, "rna_Scene_active_layer_get", NULL, 
NULL);
        RNA_def_property_ui_text(prop, "Active Layer", "Active scene layer 
index");
 
+       prop = RNA_def_property(srna, "object_layers", PROP_POINTER, PROP_NONE);
+       RNA_def_property_ui_text(prop, "Object Layers", "Layer tree which 
contains the object layers");
+
        /* Frame Range Stuff */
        prop = RNA_def_property(srna, "frame_current", PROP_INT, PROP_TIME);
        RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
@@ -6847,6 +6881,7 @@ void RNA_def_scene(BlenderRNA *brna)
        /* *** Animated *** */
        rna_def_scene_render_data(brna);
        rna_def_scene_render_layer(brna);
+       rna_def_layer_tree(brna);
        rna_def_gpu_fx(brna);
        rna_def_scene_render_view(brna);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to