[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60835] branches/asset-browser/source/ blender: == asset browser ==
Andrea Weikert
elubie at gmx.net
Thu Oct 17 22:17:04 CEST 2013
Revision: 60835
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60835
Author: elubie
Date: 2013-10-17 20:17:03 +0000 (Thu, 17 Oct 2013)
Log Message:
-----------
== asset browser ==
* Load assets in the background to not block UI
* Update notifications likely will need to be improved
Modified Paths:
--------------
branches/asset-browser/source/blender/blenkernel/intern/assets.c
branches/asset-browser/source/blender/blenloader/BLO_readfile.h
branches/asset-browser/source/blender/blenloader/intern/readblenentry.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/listview/contentlist.c
branches/asset-browser/source/blender/editors/listview/contentlist.h
branches/asset-browser/source/blender/editors/listview/contentlist_intern.h
branches/asset-browser/source/blender/editors/listview/listview_ops.c
branches/asset-browser/source/blender/editors/space_asset/assetlist.c
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_api.h
Modified: branches/asset-browser/source/blender/blenkernel/intern/assets.c
===================================================================
--- branches/asset-browser/source/blender/blenkernel/intern/assets.c 2013-10-17 19:57:14 UTC (rev 60834)
+++ branches/asset-browser/source/blender/blenkernel/intern/assets.c 2013-10-17 20:17:03 UTC (rev 60835)
@@ -105,23 +105,24 @@
if (libfiledata == NULL) return;
- names= BLO_blendhandle_get_linkable_assets(libfiledata);
- nnames= BLI_linklist_length(names);
-
- for (l= names; l; l= l->next) {
- char *blockname= l->link;
- const char *group= BKE_idcode_to_name(GS(blockname));
- if (group) {
- asset = MEM_callocN(sizeof(bAsset), "asset item");
- BLI_strncpy(asset->group, group, sizeof(asset->group));
- BLI_strncpy(asset->name, blockname+2, sizeof(asset->name));
- BLI_strncpy(asset->lib, filename, sizeof(asset->lib));
- BLI_snprintf(asset->path, sizeof(asset->path), "%s/%s/%s", asset->lib, asset->group, asset->name);
- BLI_addtail(assets, asset);
+ names= BLO_blendhandle_get_linkable_assets(libfiledata, false);
+ if (names) {
+ nnames= BLI_linklist_length(names);
+ for (l= names; l; l= l->next) {
+ char *blockname= l->link;
+ const char *group= BKE_idcode_to_name(GS(blockname));
+ if (group) {
+ asset = MEM_callocN(sizeof(bAsset), "asset item");
+ BLI_strncpy(asset->group, group, sizeof(asset->group));
+ BLI_strncpy(asset->name, blockname+2, sizeof(asset->name));
+ BLI_strncpy(asset->lib, filename, sizeof(asset->lib));
+ BLI_snprintf(asset->path, sizeof(asset->path), "%s/%s/%s", asset->lib, asset->group, asset->name);
+ BLI_addtail(assets, asset);
+ }
}
+
+ BLI_linklist_free(names, free);
}
-
- BLI_linklist_free(names, free);
BLO_blendhandle_close(libfiledata);
BLI_strncpy(bmain->name, current_filename, sizeof(bmain->name)); // prevent bmain->name to change
@@ -240,5 +241,10 @@
void BKE_asset_dir_remove(struct bAssetCollection *collection, struct bAssetDir *dir)
{
+ BLI_freelistN(&dir->assets);
BLI_freelinkN(&collection->asset_dirs, dir);
+
+ /* signal that the collection has been changed and the contentlist
+ needs to be updated */
+ collection->changed = 1;
}
Modified: branches/asset-browser/source/blender/blenloader/BLO_readfile.h
===================================================================
--- branches/asset-browser/source/blender/blenloader/BLO_readfile.h 2013-10-17 19:57:14 UTC (rev 60834)
+++ branches/asset-browser/source/blender/blenloader/BLO_readfile.h 2013-10-17 20:17:03 UTC (rev 60835)
@@ -161,7 +161,7 @@
* \return A BLI_linklist of strings. The string links
* should be freed with free (they were allocated with malloc).
*/
-struct LinkNode *BLO_blendhandle_get_linkable_assets(struct BlendHandle *bh);
+struct LinkNode *BLO_blendhandle_get_linkable_assets(struct BlendHandle *bh, bool onlyAssets);
/**
* Gets the previews of all the datablocks in a file
Modified: branches/asset-browser/source/blender/blenloader/intern/readblenentry.c
===================================================================
--- branches/asset-browser/source/blender/blenloader/intern/readblenentry.c 2013-10-17 19:57:14 UTC (rev 60834)
+++ branches/asset-browser/source/blender/blenloader/intern/readblenentry.c 2013-10-17 20:17:03 UTC (rev 60835)
@@ -219,7 +219,7 @@
return previews;
}
-LinkNode *BLO_blendhandle_get_linkable_assets(BlendHandle *bh)
+LinkNode *BLO_blendhandle_get_linkable_assets(BlendHandle *bh, bool onlyAssets)
{
FileData *fd= (FileData*) bh;
LinkNode *names= NULL;
@@ -231,8 +231,12 @@
}
else if (BKE_idcode_is_linkable(bhead->code)) {
char *idname= bhead_id_name(fd, bhead);
- short is_asset= bhead_id_asset(fd, bhead);
- if (is_asset) {
+ if (onlyAssets) {
+ short is_asset= bhead_id_asset(fd, bhead);
+ if (is_asset) {
+ BLI_linklist_prepend(&names, strdup(idname));
+ }
+ } else {
BLI_linklist_prepend(&names, strdup(idname));
}
}
Modified: branches/asset-browser/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/asset-browser/source/blender/blenloader/intern/readfile.c 2013-10-17 19:57:14 UTC (rev 60834)
+++ branches/asset-browser/source/blender/blenloader/intern/readfile.c 2013-10-17 20:17:03 UTC (rev 60835)
@@ -9958,8 +9958,16 @@
short bhead_id_asset(FileData *fd, BHead *bhead)
{
- short *sp = (short *)(((char *)(bhead+1)) + fd->id_asset_offs);
- return (*sp);
+ short *sp;
+
+ if (fd->id_asset_offs > 0) {
+ sp = (short *)(((char *)(bhead+1)) + fd->id_asset_offs);
+ return (*sp);
+ }
+ else {
+ return 0;
+ }
+
}
static ID *is_yet_read(FileData *fd, Main *mainvar, BHead *bhead)
Modified: branches/asset-browser/source/blender/blenloader/intern/writefile.c
===================================================================
--- branches/asset-browser/source/blender/blenloader/intern/writefile.c 2013-10-17 19:57:14 UTC (rev 60834)
+++ branches/asset-browser/source/blender/blenloader/intern/writefile.c 2013-10-17 20:17:03 UTC (rev 60835)
@@ -3061,9 +3061,15 @@
static void write_asset_dirs(WriteData *wd, ListBase *asset_dirs)
{
bAssetDir *asset_dir;
+ bAsset *asset;
+
for(asset_dir = asset_dirs->first; asset_dir; asset_dir= asset_dir->next ) {
writestruct(wd, DATA, "bAssetDir", 1, asset_dir);
+ for (asset = asset_dir->assets.first; asset; asset = asset->next) {
+ writestruct(wd, DATA, "bAsset", 1, asset);
+ }
+
/* Write ID Properties -- and copy this comment EXACTLY for easy finding
of library blocks that implement this.*/
if (asset_dir->properties) {
Modified: branches/asset-browser/source/blender/editors/listview/contentlist.c
===================================================================
--- branches/asset-browser/source/blender/editors/listview/contentlist.c 2013-10-17 19:57:14 UTC (rev 60834)
+++ branches/asset-browser/source/blender/editors/listview/contentlist.c 2013-10-17 20:17:03 UTC (rev 60835)
@@ -105,9 +105,9 @@
contentlist_filter(cl);
}
-void contentlist_read(struct ContentList *cl, struct bContext *C)
+void contentlist_read(struct ContentList *cl, void *datasource)
{
- cl->f_read(cl, C);
+ cl->f_read(cl, datasource);
contentlist_filter(cl);
cl->active = cl->hilite = -1;
}
Modified: branches/asset-browser/source/blender/editors/listview/contentlist.h
===================================================================
--- branches/asset-browser/source/blender/editors/listview/contentlist.h 2013-10-17 19:57:14 UTC (rev 60834)
+++ branches/asset-browser/source/blender/editors/listview/contentlist.h 2013-10-17 20:17:03 UTC (rev 60835)
@@ -92,7 +92,7 @@
int contentlist_empty(struct ContentList *cl);
void contentlist_sort(struct ContentList *cl, int col, short ascending);
void contentlist_filter(struct ContentList *cl);
-void contentlist_read(struct ContentList *cl, struct bContext *C);
+void contentlist_read(struct ContentList *cl, void *datasource);
int contentlist_num_entries(struct ContentList *cl);
int contentlist_num_columns(struct ContentList *cl);
void contentlist_filters_clear(struct ContentList *cl);
Modified: branches/asset-browser/source/blender/editors/listview/contentlist_intern.h
===================================================================
--- branches/asset-browser/source/blender/editors/listview/contentlist_intern.h 2013-10-17 19:57:14 UTC (rev 60834)
+++ branches/asset-browser/source/blender/editors/listview/contentlist_intern.h 2013-10-17 20:17:03 UTC (rev 60835)
@@ -66,7 +66,7 @@
int active;
int hilite;
- void (*f_read)(struct ContentList *, struct bContext *);
+ void (*f_read)(struct ContentList *, void *);
void (*f_free)(struct ContentList *);
void (*f_sort)(struct ContentList *, int, short);
char * (*f_entry_get_formatted)(struct ContentList *, int, int);
Modified: branches/asset-browser/source/blender/editors/listview/listview_ops.c
===================================================================
--- branches/asset-browser/source/blender/editors/listview/listview_ops.c 2013-10-17 19:57:14 UTC (rev 60834)
+++ branches/asset-browser/source/blender/editors/listview/listview_ops.c 2013-10-17 20:17:03 UTC (rev 60835)
@@ -155,7 +155,7 @@
}
-static int listview_border_select_modal(bContext *C, wmOperator *op, wmEvent *event)
+static int listview_border_select_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
ARegion *ar = CTX_wm_region(C);
ScrArea *sa = CTX_wm_area(C);
@@ -238,7 +238,7 @@
WM_operator_properties_gesture_border(ot, 1);
}
-static int listview_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
+static int listview_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
ARegion *ar = CTX_wm_region(C);
struct ContentList *cl = ar->regiondata;
@@ -369,7 +369,7 @@
return (active_file != -1) && (active_file != origfile);
}
-static int listview_highlight_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
+static int listview_highlight_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
{
ARegion *ar = CTX_wm_region(C);
Modified: branches/asset-browser/source/blender/editors/space_asset/assetlist.c
===================================================================
--- branches/asset-browser/source/blender/editors/space_asset/assetlist.c 2013-10-17 19:57:14 UTC (rev 60834)
+++ branches/asset-browser/source/blender/editors/space_asset/assetlist.c 2013-10-17 20:17:03 UTC (rev 60835)
@@ -33,13 +33,13 @@
/* global includes */
#include "MEM_guardedalloc.h"
-#include "BKE_main.h"
#include "BKE_global.h"
#include "BKE_utildefines.h"
#include "BKE_assets.h"
#include "BKE_context.h"
#include "BKE_idcode.h"
+#include "BLI_array.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
@@ -314,24 +314,29 @@
static void assetlist_free_entries(struct ContentList *cl)
{
int i;
- for (i = 0; i < cl->num_entries; ++i) {
- struct ContentListEntry *le = &cl->entries[i];
- MEM_freeN(le->data);
- le->data = NULL;
- if (le->image) {
- IMB_freeImBuf(le->image);
- le->image = NULL;
+ if (cl->entries != NULL) {
+ printf("assetlist_free: deallocating %d entries\n", cl->num_entries);
+ for (i = 0; i < cl->num_entries; ++i) {
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list