Commit: ce485104627fe7be5ffd2df75107eaf14d90cda4
Author: YimingWu
Date:   Tue Jun 25 16:18:58 2019 +0800
Branches: soc-2019-npr
https://developer.blender.org/rBce485104627fe7be5ffd2df75107eaf14d90cda4

LANPR: Added collection tab and put collection specific LANPR settings in it.

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

M       release/scripts/startup/bl_ui/__init__.py
A       release/scripts/startup/bl_ui/properties_collection.py
M       release/scripts/startup/bl_ui/properties_view_layer.py
M       source/blender/editors/space_buttons/buttons_context.c
M       source/blender/editors/space_buttons/space_buttons.c
M       source/blender/makesdna/DNA_space_types.h
M       source/blender/makesrna/intern/rna_space.c

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

diff --git a/release/scripts/startup/bl_ui/__init__.py 
b/release/scripts/startup/bl_ui/__init__.py
index 44229b2afdf..b11a6bfcc8f 100644
--- a/release/scripts/startup/bl_ui/__init__.py
+++ b/release/scripts/startup/bl_ui/__init__.py
@@ -65,6 +65,7 @@ _modules = [
     "properties_scene",
     "properties_texture",
     "properties_world",
+    "properties_collection",
 
     # Generic Space Modules
     #
diff --git a/release/scripts/startup/bl_ui/properties_collection.py 
b/release/scripts/startup/bl_ui/properties_collection.py
new file mode 100644
index 00000000000..73e2ef43bea
--- /dev/null
+++ b/release/scripts/startup/bl_ui/properties_collection.py
@@ -0,0 +1,82 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+#  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,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
+from bpy.types import Panel
+from bpy import data
+
+
+class CollectionButtonsPanel:
+    bl_space_type = 'PROPERTIES'
+    bl_region_type = 'WINDOW'
+    bl_context = "collection"
+    # COMPAT_ENGINES must be defined in each subclass, external engines can 
add themselves here
+
+    @classmethod
+    def poll(cls, context):
+        return (context.engine in cls.COMPAT_ENGINES)
+
+class COLLECTION_PT_collection_flags(CollectionButtonsPanel, Panel):
+    bl_label = "Collection Flags"
+
+    def draw(self, context):
+        layout=self.layout
+        collection=context.collection
+        vl = context.view_layer
+        vlc = vl.active_layer_collection
+        if vlc.name == 'Master Collection':
+            row = layout.row()
+            row.label(text="This is the master collection")
+            return
+        
+        row = layout.row()
+        col = row.column(align=True)
+        col.prop(vlc,"hide_viewport")
+        col.prop(vlc,"holdout")
+        col.prop(vlc,"indirect_only")
+        row = layout.row()
+        col = row.column(align=True)
+        col.prop(collection,"hide_select")
+        col.prop(collection,"hide_viewport")
+        col.prop(collection,"hide_render")
+            
+
+class COLLECTION_PT_lanpr_collection(CollectionButtonsPanel, Panel):
+    bl_label = "Collection LANPR"
+
+    @classmethod
+    def poll(cls, context):
+        return context.scene.lanpr.enabled
+
+    def draw(self,context):
+        layout = self.layout
+        collection = context.collection
+        row = layout.row()
+        row.prop(collection.lanpr,"usage",expand=True)
+        if collection.lanpr.usage!='INCLUDE':
+            layout.prop(collection.lanpr,"force")
+
+classes = (
+    COLLECTION_PT_collection_flags,
+    COLLECTION_PT_lanpr_collection,
+)
+
+if __name__ == "__main__":  # only for live edit.
+    from bpy.utils import register_class
+    for cls in classes:
+        register_class(cls)
diff --git a/release/scripts/startup/bl_ui/properties_view_layer.py 
b/release/scripts/startup/bl_ui/properties_view_layer.py
index 2ebe55c65d5..0fb85501235 100644
--- a/release/scripts/startup/bl_ui/properties_view_layer.py
+++ b/release/scripts/startup/bl_ui/properties_view_layer.py
@@ -82,25 +82,9 @@ class VIEWLAYER_PT_eevee_layer_passes(ViewLayerButtonsPanel, 
Panel):
         col = flow.column()
         col.prop(view_layer, "use_pass_subsurface_color", text="Subsurface 
Color")
 
-class VIEWLAYER_PT_lanpr_collection(ViewLayerButtonsPanel, Panel):
-    bl_label = "Collection LANPR"
-
-    @classmethod
-    def poll(cls, context):
-        return context.scene.lanpr.enabled
-
-    def draw(self,context):
-        layout = self.layout
-        collection = context.collection
-        row = layout.row()
-        row.prop(collection.lanpr,"usage",expand=True)
-        if collection.lanpr.usage!='INCLUDE':
-            layout.prop(collection.lanpr,"force")
-
 classes = (
     VIEWLAYER_PT_layer,
     VIEWLAYER_PT_eevee_layer_passes,
-    VIEWLAYER_PT_lanpr_collection,
 )
 
 if __name__ == "__main__":  # only for live edit.
diff --git a/source/blender/editors/space_buttons/buttons_context.c 
b/source/blender/editors/space_buttons/buttons_context.c
index fde8b8f85f8..b7177f30f71 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -164,6 +164,31 @@ static int buttons_context_path_world(ButsContextPath 
*path)
   return 0;
 }
 
+static int buttons_context_path_collection(ButsContextPath *path, wmWindow* 
window)
+{
+  Scene *scene;
+  World *world;
+  PointerRNA *ptr = &path->ptr[path->len - 1];
+
+  /* if we already have a (pinned) collection, we're done */
+  if (RNA_struct_is_a(ptr->type, &RNA_Collection)) {
+    return 1;
+  }
+  /* if we have a view layer, use the view layer's active collection */
+  else if (buttons_context_path_view_layer(path, window)) {
+    ViewLayer *view_layer = path->ptr[path->len - 1].data;
+    Collection* c = view_layer->active_collection->collection;
+    if (c) {
+      RNA_id_pointer_create(&c->id, &path->ptr[path->len]);
+      path->len++;
+      return 1;
+    }
+  }
+
+  /* no path to a collection possible */
+  return 0;
+}
+
 static int buttons_context_path_linestyle(ButsContextPath *path, wmWindow 
*window)
 {
   FreestyleLineStyle *linestyle;
@@ -575,6 +600,9 @@ static int buttons_context_path(const bContext *C, 
ButsContextPath *path, int ma
     case BCONTEXT_WORLD:
       found = buttons_context_path_world(path);
       break;
+    case BCONTEXT_COLLECTION:
+      found = buttons_context_path_collection(path, window);
+      break;
     case BCONTEXT_TOOL:
       found = true;
       break;
diff --git a/source/blender/editors/space_buttons/space_buttons.c 
b/source/blender/editors/space_buttons/space_buttons.c
index 129f249d7d0..a487379ca7a 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -160,6 +160,9 @@ static void buttons_main_region_layout_properties(const 
bContext *C,
     case BCONTEXT_WORLD:
       contexts[0] = "world";
       break;
+    case BCONTEXT_COLLECTION:
+      contexts[0] = "collection";
+      break;
     case BCONTEXT_OBJECT:
       contexts[0] = "object";
       break;
diff --git a/source/blender/makesdna/DNA_space_types.h 
b/source/blender/makesdna/DNA_space_types.h
index 20d4f7d96e4..58b39b6e0c2 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -195,6 +195,7 @@ typedef enum eSpaceButtons_Context {
   BCONTEXT_TOOL = 14,
   BCONTEXT_SHADERFX = 15,
   BCONTEXT_OUTPUT = 16,
+  BCONTEXT_COLLECTION = 17,
 
   /* always as last... */
   BCONTEXT_TOT,
diff --git a/source/blender/makesrna/intern/rna_space.c 
b/source/blender/makesrna/intern/rna_space.c
index 2b51b1eee97..9472296de7e 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -383,6 +383,7 @@ static const EnumPropertyItem buttons_context_items[] = {
     {BCONTEXT_OUTPUT, "OUTPUT", ICON_OUTPUT, "Output", "Output"},
     {BCONTEXT_VIEW_LAYER, "VIEW_LAYER", ICON_RENDER_RESULT, "View Layer", 
"View Layer"},
     {BCONTEXT_WORLD, "WORLD", ICON_WORLD, "World", "World"},
+    {BCONTEXT_COLLECTION, "COLLECTION", ICON_GROUP, "Collection", 
"Collection"},
     {BCONTEXT_OBJECT, "OBJECT", ICON_OBJECT_DATA, "Object", "Object"},
     {BCONTEXT_CONSTRAINT, "CONSTRAINT", ICON_CONSTRAINT, "Constraints", 
"Object Constraints"},
     {BCONTEXT_MODIFIER, "MODIFIER", ICON_MODIFIER, "Modifiers", "Modifiers"},
@@ -1643,6 +1644,14 @@ static const EnumPropertyItem 
*rna_SpaceProperties_context_itemf(bContext *UNUSE
     RNA_enum_item_add_separator(&item, &totitem);
   }
 
+  if (sbuts->pathflag & (1 << BCONTEXT_COLLECTION)) {
+    RNA_enum_items_add_value(&item, &totitem, buttons_context_items, 
BCONTEXT_COLLECTION);
+  }
+
+  if (totitem) {
+    RNA_enum_item_add_separator(&item, &totitem);
+  }
+
   if (sbuts->pathflag & (1 << BCONTEXT_OBJECT)) {
     RNA_enum_items_add_value(&item, &totitem, buttons_context_items, 
BCONTEXT_OBJECT);
   }

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to