[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [44972] branches/asset-browser: == asset browser ==

Andrea Weikert elubie at gmx.net
Sun Mar 18 19:56:53 CET 2012


Revision: 44972
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44972
Author:   elubie
Date:     2012-03-18 18:56:53 +0000 (Sun, 18 Mar 2012)
Log Message:
-----------
== asset browser ==
First skeleton implementation of the data structures for .blend file asset and directory asset type.

Functionality is still very limited.
* create/remove asset collections
* add/remove a file to an asset collection 
* add/remove a directory to an asset collection 

Linking in the asset collection from anotehr .blend file should also work (not editable).

This is just to get started on the actual implementation and commit my work before merging with trunk again..

UI and operators are in python, especially the UI needs some tweaks (layout, nicer buttons) before this is done.

Modified Paths:
--------------
    branches/asset-browser/release/scripts/startup/bl_operators/__init__.py
    branches/asset-browser/release/scripts/startup/bl_ui/space_asset.py
    branches/asset-browser/source/blender/CMakeLists.txt
    branches/asset-browser/source/blender/blenkernel/BKE_main.h
    branches/asset-browser/source/blender/blenkernel/CMakeLists.txt
    branches/asset-browser/source/blender/blenkernel/intern/idcode.c
    branches/asset-browser/source/blender/blenkernel/intern/library.c
    branches/asset-browser/source/blender/blenlib/intern/bpath.c
    branches/asset-browser/source/blender/blenloader/intern/readfile.c
    branches/asset-browser/source/blender/blenloader/intern/writefile.c
    branches/asset-browser/source/blender/editors/space_asset/space_asset.c
    branches/asset-browser/source/blender/makesdna/DNA_ID.h
    branches/asset-browser/source/blender/makesdna/DNA_space_types.h
    branches/asset-browser/source/blender/makesdna/intern/makesdna.c
    branches/asset-browser/source/blender/makesrna/RNA_access.h
    branches/asset-browser/source/blender/makesrna/intern/CMakeLists.txt
    branches/asset-browser/source/blender/makesrna/intern/makesrna.c
    branches/asset-browser/source/blender/makesrna/intern/rna_ID.c
    branches/asset-browser/source/blender/makesrna/intern/rna_armature_api.c
    branches/asset-browser/source/blender/makesrna/intern/rna_internal.h
    branches/asset-browser/source/blender/makesrna/intern/rna_main.c
    branches/asset-browser/source/blender/makesrna/intern/rna_main_api.c
    branches/asset-browser/source/blender/makesrna/intern/rna_space.c
    branches/asset-browser/source/blender/makesrna/intern/rna_userdef.c
    branches/asset-browser/source/blender/windowmanager/WM_types.h

Added Paths:
-----------
    branches/asset-browser/release/scripts/startup/bl_operators/asset_collection.py
    branches/asset-browser/source/blender/blenkernel/BKE_assets.h
    branches/asset-browser/source/blender/blenkernel/intern/assets.c
    branches/asset-browser/source/blender/makesdna/DNA_asset_types.h
    branches/asset-browser/source/blender/makesrna/intern/rna_asset.c
    branches/asset-browser/source/blender/makesrna/intern/rna_asset_api.c

Modified: branches/asset-browser/release/scripts/startup/bl_operators/__init__.py
===================================================================
--- branches/asset-browser/release/scripts/startup/bl_operators/__init__.py	2012-03-18 16:01:11 UTC (rev 44971)
+++ branches/asset-browser/release/scripts/startup/bl_operators/__init__.py	2012-03-18 18:56:53 UTC (rev 44972)
@@ -25,6 +25,7 @@
 _modules = (
     "add_mesh_torus",
     "anim",
+    "asset_collection",
     "clip",
     "console",
     "image",

Added: branches/asset-browser/release/scripts/startup/bl_operators/asset_collection.py
===================================================================
--- branches/asset-browser/release/scripts/startup/bl_operators/asset_collection.py	                        (rev 0)
+++ branches/asset-browser/release/scripts/startup/bl_operators/asset_collection.py	2012-03-18 18:56:53 UTC (rev 44972)
@@ -0,0 +1,136 @@
+import bpy
+from bpy.types import Operator
+from bpy.props import (IntProperty,
+                       BoolProperty,
+                       EnumProperty,
+                       StringProperty,
+                       )
+
+
+class AddAssetCollectionOperator(Operator):
+    '''Tooltip'''
+    bl_idname = "asset_collection.add"
+    bl_label = "Add Asset Collection"
+
+    @classmethod
+    def poll(cls, context):
+        return True
+
+    def execute(self, context):
+        bpy.data.asset_collections.new('AssetCollection')
+        return {'FINISHED'}
+
+class RemoveAssetCollectionOperator(Operator):
+    '''Tooltip'''
+    bl_idname = "asset_collection.remove"
+    bl_label = "Remove Asset Collection"
+
+    @classmethod
+    def poll(cls, context):
+        sasset = context.space_data
+        n=len(bpy.data.asset_collections)
+        return (sasset.type == 'ASSET_BROWSER') and sasset.active_collection<n
+
+    def execute(self, context):
+        sasset = context.space_data
+        ac=bpy.data.asset_collections[sasset.active_collection]
+        bpy.data.asset_collections.remove(ac)
+        return {'FINISHED'}
+    
+class AddAssetFileOperator(Operator):
+    '''Add Asset File Operator.'''
+    bl_idname= "asset_collection.add_file"
+    bl_label= "Add Asset File"
+    bl_description= "Add a file to the asset collection"
+    bl_options= {'REGISTER', 'UNDO'}
+
+    filepath= StringProperty(name="File Path", description="File path to the asset file", maxlen=1024, default="")
+
+    @classmethod
+    def poll(cls, context):
+        sasset = context.space_data
+        n=len(bpy.data.asset_collections)
+        return (sasset.type == 'ASSET_BROWSER') and n>0 and sasset.active_collection<n
+        
+    def execute(self, context):
+        sasset = context.space_data
+        ac=bpy.data.asset_collections[sasset.active_collection]
+        af=ac.asset_files.new();
+        af.filepath=self.filepath
+        return {'FINISHED'}
+
+    def invoke(self, context, event):
+        wm= context.window_manager
+        wm.fileselect_add(self)
+        return {'RUNNING_MODAL'}
+        
+class RemoveAssetFileOperator(Operator):
+    '''Remove Asset File Operator.'''
+    bl_idname= "asset_collection.remove_file"
+    bl_label= "Remove Asset File"
+    bl_description= "Remove selected file from the asset collection"
+    bl_options= {'REGISTER', 'UNDO'}
+
+    @classmethod
+    def poll(cls, context):
+        sasset = context.space_data
+        n=len(bpy.data.asset_collections)
+        return (sasset.type == 'ASSET_BROWSER') and n>0 and sasset.active_collection<n
+        
+    def execute(self, context):
+        sasset = context.space_data
+        ac=bpy.data.asset_collections[sasset.active_collection]
+        n=len(ac.asset_files)
+        if ac.active_file<n:
+            af=ac.asset_files[ac.active_file]
+            ac.asset_files.remove(af)
+        return {'FINISHED'}
+        
+class AddAssetDirOperator(Operator):
+    '''Add Asset File Operator.'''
+    bl_idname= "asset_collection.add_directory"
+    bl_label= "Add Asset Dir"
+    bl_description= "Add a directory to the asset collection"
+    bl_options= {'REGISTER', 'UNDO'}
+
+    directory= StringProperty(name="Directory", description="Directory path to the asset file", maxlen=1024, default="")
+
+    @classmethod
+    def poll(cls, context):
+        sasset = context.space_data
+        n=len(bpy.data.asset_collections)
+        return (sasset.type == 'ASSET_BROWSER') and n>0 and sasset.active_collection<n
+        
+    def execute(self, context):
+        sasset = context.space_data
+        ac=bpy.data.asset_collections[sasset.active_collection]
+        ad=ac.asset_dirs.new();
+        ad.dirpath=self.directory
+        return {'FINISHED'}
+
+    def invoke(self, context, event):
+        wm= context.window_manager
+        wm.fileselect_add(self)
+        return {'RUNNING_MODAL'}
+
+class RemoveAssetDirOperator(Operator):
+    '''Remove Asset Dir Operator.'''
+    bl_idname= "asset_collection.remove_directory"
+    bl_label= "Remove Asset Directory"
+    bl_description= "Remove selected directory from the asset collection"
+    bl_options= {'REGISTER', 'UNDO'}
+
+    @classmethod
+    def poll(cls, context):
+        sasset = context.space_data
+        n=len(bpy.data.asset_collections)
+        return (sasset.type == 'ASSET_BROWSER') and n>0 and sasset.active_collection<n
+        
+    def execute(self, context):
+        sasset = context.space_data
+        ac=bpy.data.asset_collections[sasset.active_collection]
+        n=len(ac.asset_dirs)
+        if ac.active_dir<n:
+            ad=ac.asset_dirs[ac.active_dir]
+            ac.asset_dirs.remove(ad)
+        return {'FINISHED'}


Property changes on: branches/asset-browser/release/scripts/startup/bl_operators/asset_collection.py
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: branches/asset-browser/release/scripts/startup/bl_ui/space_asset.py
===================================================================
--- branches/asset-browser/release/scripts/startup/bl_ui/space_asset.py	2012-03-18 16:01:11 UTC (rev 44971)
+++ branches/asset-browser/release/scripts/startup/bl_ui/space_asset.py	2012-03-18 18:56:53 UTC (rev 44972)
@@ -35,7 +35,79 @@
         row.template_header()
 
         layout.separator()
+        
+class AssetCollectionsPanel(bpy.types.Panel):
+    bl_label = "Asset Collections"
+    bl_idname = "ASSET_PT_collections"
+    bl_space_type = "ASSET_BROWSER"
+    bl_region_type = "TOOLS"
+    bl_context = "object"
 
+    @classmethod
+    def poll(cls, context):
+        return True
+
+    def draw(self, context):
+        layout = self.layout
+        sasset = context.space_data
+        
+        col = layout.column(align=True)
+        col.label(text="Asset Collections:")
+        col.template_list(bpy.data, 'asset_collections', sasset, 'active_collection', rows=5)
+        sub = col.row()
+        sub.operator("asset_collection.add")
+        sub.operator("asset_collection.remove")
+
+class AssetFilesPanel(bpy.types.Panel):
+    bl_label = "Asset Files"
+    bl_idname = "ASSET_PT_files"
+    bl_space_type = "ASSET_BROWSER"
+    bl_region_type = "TOOLS"
+    bl_context = "object"
+
+    @classmethod
+    def poll(cls, context):
+        sasset = context.space_data
+        n=len(bpy.data.asset_collections)
+        return n>0 and n>sasset.active_collection
+
+    def draw(self, context):
+        layout = self.layout
+        sasset = context.space_data
+        ac = bpy.data.asset_collections[sasset.active_collection]
+        
+        col = layout.column(align=True)
+        col.label(text="Asset Files:")
+        col.template_list(ac, 'asset_files', ac, 'active_file', rows=5)
+        sub = col.row()
+        sub.operator("asset_collection.add_file")
+        sub.operator("asset_collection.remove_file")
+
+class AssetDirsPanel(bpy.types.Panel):
+    bl_label = "Asset Dirs"
+    bl_idname = "ASSET_PT_dirs"
+    bl_space_type = "ASSET_BROWSER"
+    bl_region_type = "TOOLS"
+    bl_context = "object"
+
+    @classmethod
+    def poll(cls, context):
+        sasset = context.space_data
+        n=len(bpy.data.asset_collections)
+        return n>0 and n>sasset.active_collection
+
+    def draw(self, context):
+        layout = self.layout
+        sasset = context.space_data
+        ac = bpy.data.asset_collections[sasset.active_collection]
+
+        col = layout.column(align=True)
+        col.label(text="Asset Dirs:")
+        col.template_list(ac, 'asset_dirs', ac, 'active_dir', rows=5)
+        sub = col.row()
+        sub.operator("asset_collection.add_directory")
+        sub.operator("asset_collection.remove_directory")
+        
 if __name__ == "__main__":  # only for live edit.
     print("registered space library")
     bpy.utils.register_module(__name__)

Modified: branches/asset-browser/source/blender/CMakeLists.txt
===================================================================
--- branches/asset-browser/source/blender/CMakeLists.txt	2012-03-18 16:01:11 UTC (rev 44971)
+++ branches/asset-browser/source/blender/CMakeLists.txt	2012-03-18 18:56:53 UTC (rev 44972)
@@ -29,6 +29,7 @@
 	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_actuator_types.h
 	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_anim_types.h
 	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_armature_types.h
+	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_asset_types.h
 	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_boid_types.h
 	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_brush_types.h
 	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_camera_types.h

Added: branches/asset-browser/source/blender/blenkernel/BKE_assets.h
===================================================================
--- branches/asset-browser/source/blender/blenkernel/BKE_assets.h	                        (rev 0)
+++ branches/asset-browser/source/blender/blenkernel/BKE_assets.h	2012-03-18 18:56:53 UTC (rev 44972)
@@ -0,0 +1,52 @@
+/*
+ * ***** 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.
+ *

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list