[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51698] branches/asset-browser/source/ blender: == asset browser ==
Andrea Weikert
elubie at gmx.net
Sat Oct 27 20:57:54 CEST 2012
Revision: 51698
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51698
Author: elubie
Date: 2012-10-27 18:57:54 +0000 (Sat, 27 Oct 2012)
Log Message:
-----------
== asset browser ==
Commit of current state before merge
Main changes:
* Added operators to define an Object or a Group as an Asset
* Added default filter settings
* some smaller fixes
* some code added to prepare for drag&drop of several assets at once (not working yet)
Modified Paths:
--------------
branches/asset-browser/source/blender/blenkernel/intern/assets.c
branches/asset-browser/source/blender/blenlib/BLI_fileops.h
branches/asset-browser/source/blender/blenlib/intern/storage.c
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/readfile.h
branches/asset-browser/source/blender/editors/include/UI_interface.h
branches/asset-browser/source/blender/editors/interface/interface.c
branches/asset-browser/source/blender/editors/listview/contentlist.c
branches/asset-browser/source/blender/editors/listview/listview_draw.c
branches/asset-browser/source/blender/editors/object/CMakeLists.txt
branches/asset-browser/source/blender/editors/object/object_intern.h
branches/asset-browser/source/blender/editors/object/object_ops.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_asset_types.h
branches/asset-browser/source/blender/makesdna/DNA_space_types.h
branches/asset-browser/source/blender/makesrna/intern/rna_ID.c
branches/asset-browser/source/blender/makesrna/intern/rna_space.c
branches/asset-browser/source/blender/windowmanager/WM_types.h
Added Paths:
-----------
branches/asset-browser/source/blender/editors/object/object_asset.c
Modified: branches/asset-browser/source/blender/blenkernel/intern/assets.c
===================================================================
--- branches/asset-browser/source/blender/blenkernel/intern/assets.c 2012-10-27 18:54:45 UTC (rev 51697)
+++ branches/asset-browser/source/blender/blenkernel/intern/assets.c 2012-10-27 18:57:54 UTC (rev 51698)
@@ -37,6 +37,7 @@
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_path_util.h"
+#include "BLI_fileops.h"
#include "BLO_readfile.h"
@@ -131,9 +132,16 @@
{
int updated = 0;
bAssetFile *af;
+
for (af = collection->asset_files.first; af; af= af->next) {
- if (af->assets.first == 0) {
+ time_t mtime = BLI_modified_time(af->filepath);
+ if (mtime > af->mtime) {
+ BLI_freelistN(&af->assets);
+ af->assets.first = af->assets.last = NULL;
+ }
+ if (af->assets.first == NULL) {
assets_append_from_library(&af->assets, bmain, af->filepath);
+ af->mtime = mtime;
updated = 1;
}
}
Modified: branches/asset-browser/source/blender/blenlib/BLI_fileops.h
===================================================================
--- branches/asset-browser/source/blender/blenlib/BLI_fileops.h 2012-10-27 18:54:45 UTC (rev 51697)
+++ branches/asset-browser/source/blender/blenlib/BLI_fileops.h 2012-10-27 18:57:54 UTC (rev 51698)
@@ -56,6 +56,7 @@
int BLI_move(const char *path, const char *to);
int BLI_create_symlink(const char *path, const char *to);
int BLI_stat(const char *path, struct stat *buffer);
+time_t BLI_modified_time(const char *path);
/* Directories */
Modified: branches/asset-browser/source/blender/blenlib/intern/storage.c
===================================================================
--- branches/asset-browser/source/blender/blenlib/intern/storage.c 2012-10-27 18:54:45 UTC (rev 51697)
+++ branches/asset-browser/source/blender/blenlib/intern/storage.c 2012-10-27 18:57:54 UTC (rev 51698)
@@ -150,7 +150,36 @@
return(st.st_mode);
}
+time_t BLI_modified_time(const char *path)
+{
+ #if defined(WIN32)
+#ifndef __MINGW32__
+ struct _stat64i32 st;
+#else
+ struct _stati64 st;
+#endif
+ /* in Windows stat doesn't recognize dir ending on a slash
+ * To not break code where the ending slash is expected we
+ * don't mess with the argument name directly here - elubie */
+ wchar_t *tmp_16 = alloc_utf16_from_8(path, 0);
+ int len, res;
+ len = wcslen(tmp_16);
+ if (len > 3 && (tmp_16[len - 1] == L'\\' || tmp_16[len - 1] == L'/') ) tmp_16[len - 1] = '\0';
+#ifndef __MINGW32__
+ res = _wstat(tmp_16, &st);
+#else
+ res = _wstati64(tmp_16, &st);
+#endif
+ free(tmp_16);
+ if (res == -1) return(0);
+#else
+ struct stat st;
+ if (stat(name, &st)) return(0);
+#endif
+ return(st.st_mtime);
+}
+
#ifdef WIN32
int BLI_stat(const char *path, struct stat *buffer)
{
Modified: branches/asset-browser/source/blender/blenloader/intern/readblenentry.c
===================================================================
--- branches/asset-browser/source/blender/blenloader/intern/readblenentry.c 2012-10-27 18:54:45 UTC (rev 51697)
+++ branches/asset-browser/source/blender/blenloader/intern/readblenentry.c 2012-10-27 18:57:54 UTC (rev 51698)
@@ -230,7 +230,10 @@
}
else if (BKE_idcode_is_linkable(bhead->code)) {
char *idname= bhead_id_name(fd, bhead);
- BLI_linklist_prepend(&names, strdup(idname));
+ short is_asset= bhead_id_asset(fd, bhead);
+ if (is_asset) {
+ 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 2012-10-27 18:54:45 UTC (rev 51697)
+++ branches/asset-browser/source/blender/blenloader/intern/readfile.c 2012-10-27 18:57:54 UTC (rev 51698)
@@ -849,6 +849,7 @@
fd->compflags = DNA_struct_get_compareflags(fd->filesdna, fd->memsdna);
/* used to retrieve ID names from (bhead+1) */
fd->id_name_offs = DNA_elem_offset(fd->filesdna, "ID", "char", "name[]");
+ fd->id_asset_offs = DNA_elem_offset(fd->filesdna, "ID", "short", "asset");
}
return 1;
@@ -8256,6 +8257,12 @@
return ((char *)(bhead+1)) + fd->id_name_offs;
}
+short bhead_id_asset(FileData *fd, BHead *bhead)
+{
+ short *sp = (short *)(((char *)(bhead+1)) + fd->id_asset_offs);
+ return (*sp);
+}
+
static ID *is_yet_read(FileData *fd, Main *mainvar, BHead *bhead)
{
const char *idname= bhead_id_name(fd, bhead);
Modified: branches/asset-browser/source/blender/blenloader/intern/readfile.h
===================================================================
--- branches/asset-browser/source/blender/blenloader/intern/readfile.h 2012-10-27 18:54:45 UTC (rev 51697)
+++ branches/asset-browser/source/blender/blenloader/intern/readfile.h 2012-10-27 18:57:54 UTC (rev 51698)
@@ -76,6 +76,8 @@
int fileversion;
int id_name_offs; /* used to retrieve ID names from (bhead+1) */
+ int id_asset_offs;
+
int globalf, fileflags; /* for do_versions patching */
struct OldNewMap *datamap;
@@ -136,6 +138,7 @@
BHead *blo_prevbhead(FileData *fd, BHead *thisblock);
char *bhead_id_name(FileData *fd, BHead *bhead);
+short bhead_id_asset(FileData *fd, BHead *bhead);
/* do versions stuff */
Modified: branches/asset-browser/source/blender/editors/include/UI_interface.h
===================================================================
--- branches/asset-browser/source/blender/editors/include/UI_interface.h 2012-10-27 18:54:45 UTC (rev 51697)
+++ branches/asset-browser/source/blender/editors/include/UI_interface.h 2012-10-27 18:57:54 UTC (rev 51698)
@@ -423,6 +423,7 @@
void uiButSetDragID(uiBut *but, struct ID *id);
void uiButSetDragRNA(uiBut *but, struct PointerRNA *ptr);
void uiButSetDragPath(uiBut *but, const char *path);
+void uiButSetDragPathList(uiBut *but, ListBase *list);
void uiButSetDragName(uiBut *but, const char *name);
void uiButSetDragValue(uiBut *but);
void uiButSetDragImage(uiBut *but, const char *path, int icon, struct ImBuf *ima, float scale);
Modified: branches/asset-browser/source/blender/editors/interface/interface.c
===================================================================
--- branches/asset-browser/source/blender/editors/interface/interface.c 2012-10-27 18:54:45 UTC (rev 51697)
+++ branches/asset-browser/source/blender/editors/interface/interface.c 2012-10-27 18:57:54 UTC (rev 51698)
@@ -3389,6 +3389,12 @@
but->dragpoin = (void *)path;
}
+void uiButSetDragPathList(uiBut *but, ListBase *list)
+{
+ but->dragtype = WM_DRAG_PATH;
+ but->dragpoin = (void *)list;
+}
+
void uiButSetDragName(uiBut *but, const char *name)
{
but->dragtype = WM_DRAG_NAME;
Modified: branches/asset-browser/source/blender/editors/listview/contentlist.c
===================================================================
--- branches/asset-browser/source/blender/editors/listview/contentlist.c 2012-10-27 18:54:45 UTC (rev 51697)
+++ branches/asset-browser/source/blender/editors/listview/contentlist.c 2012-10-27 18:57:54 UTC (rev 51698)
@@ -110,6 +110,7 @@
{
cl->f_read(cl, C);
contentlist_filter(cl);
+ cl->active = cl->hilite = -1;
}
int contentlist_num_entries(struct ContentList *cl)
@@ -357,7 +358,7 @@
int contentlist_get_active(struct ContentList *cl)
{
- return cl->hilite;
+ return cl->active;
}
int contentlist_get_hilite(struct ContentList *cl)
Modified: branches/asset-browser/source/blender/editors/listview/listview_draw.c
===================================================================
--- branches/asset-browser/source/blender/editors/listview/listview_draw.c 2012-10-27 18:54:45 UTC (rev 51697)
+++ branches/asset-browser/source/blender/editors/listview/listview_draw.c 2012-10-27 18:57:54 UTC (rev 51698)
@@ -34,6 +34,7 @@
#include "BIF_gl.h"
#include "BIF_glutil.h"
+#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
@@ -45,6 +46,8 @@
#include "IMB_imbuf_types.h"
+#include "MEM_guardedalloc.h"
+
#include "UI_interface.h"
#include "UI_interface_icons.h"
#include "UI_resources.h"
Modified: branches/asset-browser/source/blender/editors/object/CMakeLists.txt
===================================================================
--- branches/asset-browser/source/blender/editors/object/CMakeLists.txt 2012-10-27 18:54:45 UTC (rev 51697)
+++ branches/asset-browser/source/blender/editors/object/CMakeLists.txt 2012-10-27 18:57:54 UTC (rev 51698)
@@ -41,6 +41,7 @@
set(SRC
object_add.c
+ object_asset.c
object_bake.c
object_constraint.c
object_edit.c
Added: branches/asset-browser/source/blender/editors/object/object_asset.c
===================================================================
--- branches/asset-browser/source/blender/editors/object/object_asset.c (rev 0)
+++ branches/asset-browser/source/blender/editors/object/object_asset.c 2012-10-27 18:57:54 UTC (rev 51698)
@@ -0,0 +1,143 @@
+/*
+ * ***** 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.
+ *
+ * The Original Code is Copyright (C) Blender Foundation
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/object/object_group.c
+ * \ingroup edobj
+ */
+
+
+#include <string.h>
+
+#include "BKE_context.h"
+#include "BKE_main.h"
+#include "BKE_report.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_utildefines.h"
+
+#include "DNA_object_types.h"
+#include "DNA_group_types.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+#include "RNA_enum_types.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "object_intern.h"
+
+static int asset_set_exec(bContext *C, wmOperator *op)
+{
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list