[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50004] branches/asset-browser: == assetbrowser ==
Andrea Weikert
elubie at gmx.net
Sun Aug 19 12:20:27 CEST 2012
Revision: 50004
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50004
Author: elubie
Date: 2012-08-19 10:20:25 +0000 (Sun, 19 Aug 2012)
Log Message:
-----------
== assetbrowser ==
WIP commit - nothing too interesting yet
* fixed memory issues
* added (Active) asset collection name to allow changing it.
* added filtering
* added operator to close panel region
Modified Paths:
--------------
branches/asset-browser/release/scripts/startup/bl_ui/space_asset.py
branches/asset-browser/source/blender/blenkernel/BKE_assets.h
branches/asset-browser/source/blender/blenkernel/intern/assets.c
branches/asset-browser/source/blender/blenlib/intern/directory.c
branches/asset-browser/source/blender/editors/include/ED_screen.h
branches/asset-browser/source/blender/editors/listview/contentlist.c
branches/asset-browser/source/blender/editors/listview/contentlist.h
branches/asset-browser/source/blender/editors/screen/screen_ops.c
branches/asset-browser/source/blender/editors/space_asset/asset_ops.c
branches/asset-browser/source/blender/editors/space_asset/asset_ops.h
branches/asset-browser/source/blender/editors/space_asset/space_asset.c
branches/asset-browser/source/blender/makesdna/DNA_asset_types.h
branches/asset-browser/source/blender/makesdna/DNA_space_types.h
branches/asset-browser/source/blender/makesrna/intern/rna_asset.c
branches/asset-browser/source/blender/makesrna/intern/rna_space.c
branches/asset-browser/source/blender/windowmanager/WM_types.h
Modified: branches/asset-browser/release/scripts/startup/bl_ui/space_asset.py
===================================================================
--- branches/asset-browser/release/scripts/startup/bl_ui/space_asset.py 2012-08-19 04:08:43 UTC (rev 50003)
+++ branches/asset-browser/release/scripts/startup/bl_ui/space_asset.py 2012-08-19 10:20:25 UTC (rev 50004)
@@ -26,18 +26,41 @@
def draw(self, context):
layout = self.layout
+ sasset = context.space_data
- print("draw space asset")
window = context.window
scene = context.scene
- rd = scene.render
row = layout.row(align=True)
row.template_header()
layout.separator()
+ row = layout.row(align=True)
+ row.prop(sasset, "show_scenes", text="")
+ row.prop(sasset, "show_groups", text="")
+ row.prop(sasset, "show_objects", text="")
+ row.prop(sasset, "show_actions", text="")
+ row.prop(sasset, "show_armatures", text="")
+ row.prop(sasset, "show_brushes", text="")
+ row.prop(sasset, "show_cameras", text="")
+ row.prop(sasset, "show_curves", text="")
+ row.prop(sasset, "show_gpencils", text="")
+ row.prop(sasset, "show_images", text="")
+ row.prop(sasset, "show_lamps", text="")
+ row.prop(sasset, "show_lattices", text="")
+ row.prop(sasset, "show_materials", text="")
+ row.prop(sasset, "show_metaballs", text="")
+ row.prop(sasset, "show_meshes", text="")
+ row.prop(sasset, "show_nodetrees", text="")
+ row.prop(sasset, "show_speakers", text="")
+ row.prop(sasset, "show_textures", text="")
+ row.prop(sasset, "show_texts", text="")
+ row.prop(sasset, "show_vfonts", text="")
+ row.prop(sasset, "show_worlds", text="")
+ row.prop(sasset, "show_movieclips", text="")
+ row.prop(sasset, "show_masks", text="")
+ row.prop(sasset, "show_asset_collections", text="")
-
class NODE_MT_view(Menu):
bl_label = "View"
@@ -45,57 +68,7 @@
layout = self.layout
layout.operator("asset.properties", icon='MENU_PANEL')
-
-class AssetItemList(bpy.types.ItemList):
- bl_space_type = "ASSET_BROWSER"
- bl_region_type = "WINDOW"
- bl_label = "Asset Item List"
-
- @classmethod
- def poll(cls, context):
- return True
-
- def draw(self, context):
- layout = self.layout
- col_flow = layout.column_flow()
-
- for ac in context.blend_data.asset_collections:
- for af in ac.asset_files:
- for asset in af.assets:
- col_flow.label(text=asset.name, icon=self.icon_for_group(asset.group))
-
- def icon_for_group(self, group):
- icon = 'NONE'
- if group == 'Action': icon = 'ACTION'
- if group == 'Armature': icon = 'ARMATURE_DATA'
- if group == 'Brush': icon = 'BRUSH_DATA'
- if group == 'Camera': icon = 'CAMERA_DATA'
- if group == 'Curve': icon = 'CURVE_DATA'
- if group == 'GPencil': icon = 'GREASEPENCIL'
- if group == 'Group': icon = 'GROUP'
- if group == 'Image': icon = 'IMAGE_DATA'
- if group == 'Lamp': icon = 'LAMP'
- if group == 'Lattice': icon = 'LATTICE_DATA'
- if group == 'Material': icon = 'MATERIAL_DATA'
- if group == 'Metaball': icon = 'META_DATA'
- if group == 'Mesh': icon = 'MESH_DATA'
- if group == 'NodeTree': icon = 'NODETREE'
- if group == 'Object': icon = 'OBJECT_DATA'
- if group == 'Scene': icon = 'SCENE_DATA'
- if group == 'Speaker': icon = 'SPEAKER'
- if group == 'Sound': icon = 'SOUND'
- if group == 'Texture': icon = 'TEXTURE_DATA'
- if group == 'Text': icon = 'TEXT'
- if group == 'VFont': icon = 'FONT_DATA'
- if group == 'World': icon = 'WORLD_DATA'
- if group == 'MovieClip': icon = 'CLIP'
- if group == 'AssetCollection': icon = 'ASSET_MANAGER'
- return icon
-
- def draw_item(self, context, entry, group):
- pass
-
class AssetCollectionsPanel(bpy.types.Panel):
bl_space_type = "ASSET_BROWSER"
bl_region_type = "UI"
@@ -111,7 +84,15 @@
col = row.column(align=True)
col.operator("asset_collection.add", icon='ZOOMIN', text="")
col.operator("asset_collection.remove", icon='ZOOMOUT', text="")
+
+ n=len(bpy.data.asset_collections)
+ if n>0 and n>sasset.active_collection:
+ ac = context.blend_data.asset_collections[sasset.active_collection]
+ row = layout.row()
+ row.prop(ac, "name", text="")
+
+
class AssetFilesPanel(bpy.types.Panel):
bl_space_type = "ASSET_BROWSER"
bl_region_type = "UI"
Modified: branches/asset-browser/source/blender/blenkernel/BKE_assets.h
===================================================================
--- branches/asset-browser/source/blender/blenkernel/BKE_assets.h 2012-08-19 04:08:43 UTC (rev 50003)
+++ branches/asset-browser/source/blender/blenkernel/BKE_assets.h 2012-08-19 10:20:25 UTC (rev 50004)
@@ -39,11 +39,13 @@
void *asset_collection_add(const char *name);
struct bAssetCollection *asset_collection_copy(struct bAssetCollection *collection);
-void asset_collection_update(struct Main *bmain, struct bAssetCollection *collection);
void asset_file_update(struct Main *bmain, struct bAssetFile *af);
+int asset_collection_update(struct Main *bmain, struct bAssetCollection *collection);
void asset_collection_make_local(struct Main *bmain, struct bAssetCollection *collection);
void asset_collection_free(struct bAssetCollection *collection);
+void assets_append_from_library(ListBase *assets, struct Main *bmain, char *filename);
+
struct bAssetFile* BKE_asset_file_add(struct bAssetCollection *collection);
void BKE_asset_file_remove(struct bAssetCollection *collection, struct bAssetFile *file);
Modified: branches/asset-browser/source/blender/blenkernel/intern/assets.c
===================================================================
--- branches/asset-browser/source/blender/blenkernel/intern/assets.c 2012-08-19 04:08:43 UTC (rev 50003)
+++ branches/asset-browser/source/blender/blenkernel/intern/assets.c 2012-08-19 10:20:25 UTC (rev 50004)
@@ -125,23 +125,30 @@
}
-void asset_collection_update(Main *bmain, bAssetCollection *collection)
+int asset_collection_update(Main *bmain, bAssetCollection *collection)
{
+ int updated = 0;
bAssetFile *af;
for (af = collection->asset_files.first; af; af= af->next) {
- if (af->changed) {
- BLI_freelistN(&af->assets);
+ if (af->assets.first == 0) {
assets_append_from_library(&af->assets, bmain, af->filepath);
- af->changed = 0;
+ updated = 1;
}
}
+
+ /* We also need to rebuild the contentlist if file has been removed */
+ if (collection->changed) {
+ updated = 1;
+ }
+ return updated;
}
void asset_file_update(struct Main *bmain, struct bAssetFile *af)
{
- BLI_freelistN(&af->assets);
- assets_append_from_library(&af->assets, bmain, af->filepath);
- af->changed = 0;
+ if (af->assets.first) {
+ BLI_freelistN(&af->assets);
+ af->assets.first = af->assets.last = 0;
+ }
}
void asset_collection_make_local(Main *bmain, bAssetCollection *ac)
@@ -180,7 +187,12 @@
void BKE_asset_file_remove(bAssetCollection *collection, struct bAssetFile *file)
{
+ BLI_freelistN(&file->assets);
BLI_freelinkN(&collection->asset_files, file);
+
+ /* signal that the collection has been changed and the contentlist
+ needs to be updated */
+ collection->changed = 1;
}
struct bAssetDir* BKE_asset_dir_add(bAssetCollection *collection)
Modified: branches/asset-browser/source/blender/blenlib/intern/directory.c
===================================================================
--- branches/asset-browser/source/blender/blenlib/intern/directory.c 2012-08-19 04:08:43 UTC (rev 50003)
+++ branches/asset-browser/source/blender/blenlib/intern/directory.c 2012-08-19 10:20:25 UTC (rev 50004)
@@ -411,18 +411,20 @@
{
int i;
struct direntry *files = filelist;
- for (i = 0; i < num_files; ++i) {
- if (files[i].image) {
- IMB_freeImBuf(files[i].image);
+ if (files != NULL) {
+ for (i = 0; i < num_files; ++i) {
+ if (files[i].image) {
+ IMB_freeImBuf(files[i].image);
+ }
+ files[i].image = NULL;
+ if (files[i].relname)
+ MEM_freeN(files[i].relname);
+ if (files[i].path)
+ MEM_freeN(files[i].path);
+ files[i].relname = NULL;
}
- files[i].image = NULL;
- if (files[i].relname)
- MEM_freeN(files[i].relname);
- if (files[i].path)
- MEM_freeN(files[i].path);
- files[i].relname = NULL;
+ MEM_freeN(files);
}
- MEM_freeN(files);
}
Modified: branches/asset-browser/source/blender/editors/include/ED_screen.h
===================================================================
--- branches/asset-browser/source/blender/editors/include/ED_screen.h 2012-08-19 04:08:43 UTC (rev 50003)
+++ branches/asset-browser/source/blender/editors/include/ED_screen.h 2012-08-19 10:20:25 UTC (rev 50004)
@@ -141,6 +141,7 @@
int ED_operator_outliner_active(struct bContext *C);
int ED_operator_outliner_active_no_editobject(struct bContext *C);
int ED_operator_file_active(struct bContext *C);
+int ED_operator_assetbrowser_active(struct bContext *C);
int ED_operator_action_active(struct bContext *C);
int ED_operator_buttons_active(struct bContext *C);
int ED_operator_node_active(struct bContext *C);
Modified: branches/asset-browser/source/blender/editors/listview/contentlist.c
===================================================================
--- branches/asset-browser/source/blender/editors/listview/contentlist.c 2012-08-19 04:08:43 UTC (rev 50003)
+++ branches/asset-browser/source/blender/editors/listview/contentlist.c 2012-08-19 10:20:25 UTC (rev 50004)
@@ -78,6 +78,23 @@
cl->f_free(cl);
}
+struct ContentList *contentlist_duplicate(struct ContentList *cl)
+{
+ ContentList *cl_new = (ContentList *)MEM_dupallocN(cl);
+ int entry;
+
+ cl_new->entries = MEM_dupallocN(cl->entries);
+ cl_new->columns = MEM_dupallocN(cl->columns);
+ cl_new->filter_index = MEM_dupallocN(cl->filter_index);
+ BLI_duplicatelist(&cl_new->filters, &cl->filters);
+
+ for (entry = 0; entry < cl_new->num_entries; ++entry) {
+ cl_new->entries[entry].data = MEM_dupallocN(cl->entries[entry].data);
+ }
+ cl_new->layout = MEM_dupallocN(cl->layout);
+ return cl_new;
+}
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list