[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [10903] branches/imgbrowser-elubie: Initial commit of new image browser.

Andrea Weikert elubie at gmx.net
Sat Jun 9 21:35:02 CEST 2007


Revision: 10903
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=10903
Author:   elubie
Date:     2007-06-09 21:35:01 +0200 (Sat, 09 Jun 2007)

Log Message:
-----------
Initial commit of new image browser.

Summary of changes:
- The interface icons have been generalized to allow preview images as a new category of 'icons'
- The SpaceImaSel space type has been completely rewritten, including theme settings.
- The SDNA types that have preview images, now contain a PreviewImage struct* to store the internal previews in the .blend file. Code for loading these when linking from an external library has also been added.
- When browsing for externam files previews for images and movies are loaded, provided codec etc. can be handled. Currently frame half-way through the movie is displayed.
- Handling of directories has been refactored out of filesel, which still needs to be refactored to use the new filelist struct.
- User setting for specifying if these previews should be stored have been added.

Some changes are refactorings and small improvements/fixes that could go to the trunk svn independently. 

A more detailed documentation and file by file report of changes can be found here:
http://wiki.blender.org/index.php/User:Elubie/PreviewImageBrowser

Modified Paths:
--------------
    branches/imgbrowser-elubie/projectfiles_vc7/blender/src/BL_src.vcproj
    branches/imgbrowser-elubie/source/blender/blenkernel/BKE_icons.h
    branches/imgbrowser-elubie/source/blender/blenkernel/intern/icons.c
    branches/imgbrowser-elubie/source/blender/blenkernel/intern/image.c
    branches/imgbrowser-elubie/source/blender/blenkernel/intern/material.c
    branches/imgbrowser-elubie/source/blender/blenkernel/intern/object.c
    branches/imgbrowser-elubie/source/blender/blenkernel/intern/texture.c
    branches/imgbrowser-elubie/source/blender/blenkernel/intern/world.c
    branches/imgbrowser-elubie/source/blender/blenlib/BLI_storage_types.h
    branches/imgbrowser-elubie/source/blender/blenloader/BLO_readfile.h
    branches/imgbrowser-elubie/source/blender/blenloader/intern/readblenentry.c
    branches/imgbrowser-elubie/source/blender/blenloader/intern/readfile.c
    branches/imgbrowser-elubie/source/blender/blenloader/intern/writefile.c
    branches/imgbrowser-elubie/source/blender/imbuf/IMB_imbuf.h
    branches/imgbrowser-elubie/source/blender/imbuf/intern/anim.c
    branches/imgbrowser-elubie/source/blender/include/BIF_imasel.h
    branches/imgbrowser-elubie/source/blender/include/BIF_interface_icons.h
    branches/imgbrowser-elubie/source/blender/include/BSE_drawimasel.h
    branches/imgbrowser-elubie/source/blender/include/BSE_filesel.h
    branches/imgbrowser-elubie/source/blender/include/blendef.h
    branches/imgbrowser-elubie/source/blender/include/datatoc.h
    branches/imgbrowser-elubie/source/blender/include/interface.h
    branches/imgbrowser-elubie/source/blender/makesdna/DNA_ID.h
    branches/imgbrowser-elubie/source/blender/makesdna/DNA_image_types.h
    branches/imgbrowser-elubie/source/blender/makesdna/DNA_lamp_types.h
    branches/imgbrowser-elubie/source/blender/makesdna/DNA_material_types.h
    branches/imgbrowser-elubie/source/blender/makesdna/DNA_space_types.h
    branches/imgbrowser-elubie/source/blender/makesdna/DNA_texture_types.h
    branches/imgbrowser-elubie/source/blender/makesdna/DNA_userdef_types.h
    branches/imgbrowser-elubie/source/blender/makesdna/DNA_world_types.h
    branches/imgbrowser-elubie/source/blender/python/api2_2x/Window.c
    branches/imgbrowser-elubie/source/blender/quicktime/apple/quicktime_import.c
    branches/imgbrowser-elubie/source/blender/src/buttons_scene.c
    branches/imgbrowser-elubie/source/blender/src/buttons_shading.c
    branches/imgbrowser-elubie/source/blender/src/drawimasel.c
    branches/imgbrowser-elubie/source/blender/src/drawnode.c
    branches/imgbrowser-elubie/source/blender/src/editimasel.c
    branches/imgbrowser-elubie/source/blender/src/editscreen.c
    branches/imgbrowser-elubie/source/blender/src/editsima.c
    branches/imgbrowser-elubie/source/blender/src/filesel.c
    branches/imgbrowser-elubie/source/blender/src/glutil.c
    branches/imgbrowser-elubie/source/blender/src/header_imasel.c
    branches/imgbrowser-elubie/source/blender/src/headerbuttons.c
    branches/imgbrowser-elubie/source/blender/src/imasel.c
    branches/imgbrowser-elubie/source/blender/src/interface_draw.c
    branches/imgbrowser-elubie/source/blender/src/interface_icons.c
    branches/imgbrowser-elubie/source/blender/src/resources.c
    branches/imgbrowser-elubie/source/blender/src/space.c
    branches/imgbrowser-elubie/source/blender/src/toets.c
    branches/imgbrowser-elubie/source/blender/src/usiblender.c

Added Paths:
-----------
    branches/imgbrowser-elubie/source/blender/include/BIF_filelist.h
    branches/imgbrowser-elubie/source/blender/src/filelist.c
    branches/imgbrowser-elubie/source/blender/src/prvicons.c

Modified: branches/imgbrowser-elubie/projectfiles_vc7/blender/src/BL_src.vcproj
===================================================================
--- branches/imgbrowser-elubie/projectfiles_vc7/blender/src/BL_src.vcproj	2007-06-09 14:25:05 UTC (rev 10902)
+++ branches/imgbrowser-elubie/projectfiles_vc7/blender/src/BL_src.vcproj	2007-06-09 19:35:01 UTC (rev 10903)
@@ -329,6 +329,9 @@
 				RelativePath="..\..\..\source\blender\src\eventdebug.c">
 			</File>
 			<File
+				RelativePath="..\..\..\source\blender\src\filelist.c">
+			</File>
+			<File
 				RelativePath="..\..\..\source\blender\src\filesel.c">
 			</File>
 			<File
@@ -461,6 +464,9 @@
 				RelativePath="..\..\..\source\blender\src\previewrender.c">
 			</File>
 			<File
+				RelativePath="..\..\..\source\blender\src\prvicons.c">
+			</File>
+			<File
 				RelativePath="..\..\..\source\blender\src\renderwin.c">
 			</File>
 			<File
@@ -675,6 +681,9 @@
 				RelativePath="..\..\..\source\blender\include\BIF_editview.h">
 			</File>
 			<File
+				RelativePath="..\..\..\source\blender\include\BIF_filelist.h">
+			</File>
+			<File
 				RelativePath="..\..\..\source\blender\include\BIF_fsmenu.h">
 			</File>
 			<File

Modified: branches/imgbrowser-elubie/source/blender/blenkernel/BKE_icons.h
===================================================================
--- branches/imgbrowser-elubie/source/blender/blenkernel/BKE_icons.h	2007-06-09 14:25:05 UTC (rev 10902)
+++ branches/imgbrowser-elubie/source/blender/blenkernel/BKE_icons.h	2007-06-09 19:35:01 UTC (rev 10903)
@@ -1,34 +1,32 @@
 /**
- * $Id$
- *
- * ***** BEGIN GPL/BL DUAL 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. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License.  See http://www.blender.org/BL/ for information
- * about this.
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- * 
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
+* $Id$
+*
+* ***** 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+* 
+* The Original Code is Copyright (C) 2006-2007 Blender Foundation.
+* All rights reserved.
+* 
+* The Original Code is: all of this file.
+* 
+* Contributor(s): none yet.
+* 
+* ***** END GPL LICENSE BLOCK *****
+*
+*/
 
 #ifndef BKE_ICONS_H
 #define BKE_ICONS_H
@@ -44,7 +42,6 @@
 	void *drawinfo;
 	void *obj;
 	short type;
-	short changed;
 	DrawInfoFreeFP drawinfo_free;
 };
 
@@ -71,5 +68,19 @@
 /* free all icons */
 void BKE_icons_free();
 
+/* free the preview image */
+void BKE_previewimg_free(PreviewImage **prv);
 
+/* free the preview image belonging to the id */
+void BKE_previewimg_free_id(ID *id);
+
+/* create a new preview image */
+struct PreviewImage* BKE_previewimg_create() ;
+
+/* create a copy of the preview image */
+struct PreviewImage* BKE_previewimg_copy(PreviewImage *prv);
+
+/* retrieve existing or create new preview image */
+PreviewImage* BKE_previewimg_get(ID *id);
+
 #endif /*  BKE_ICONS_H */

Modified: branches/imgbrowser-elubie/source/blender/blenkernel/intern/icons.c
===================================================================
--- branches/imgbrowser-elubie/source/blender/blenkernel/intern/icons.c	2007-06-09 14:25:05 UTC (rev 10902)
+++ branches/imgbrowser-elubie/source/blender/blenkernel/intern/icons.c	2007-06-09 19:35:01 UTC (rev 10903)
@@ -1,34 +1,32 @@
 /**
- * $Id$
- *
- * ***** BEGIN GPL/BL DUAL 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. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License.  See http://www.blender.org/BL/ for information
- * about this.
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
+* $Id$
+*
+* ***** 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+* 
+* The Original Code is Copyright (C) 2006-2007 Blender Foundation.
+* All rights reserved.
+* 
+* The Original Code is: all of this file.
+* 
+* Contributor(s): none yet.
+* 
+* ***** END GPL LICENSE BLOCK *****
+*
+*/
 
 #include <math.h>
 #include <stdlib.h>
@@ -41,6 +39,11 @@
 #include "MEM_guardedalloc.h"
 
 #include "DNA_ID.h"
+#include "DNA_image_types.h"
+#include "DNA_lamp_types.h"
+#include "DNA_material_types.h"
+#include "DNA_texture_types.h"
+#include "DNA_world_types.h"
 
 #include "BLI_ghash.h"
 
@@ -111,7 +114,104 @@
 	gIcons = NULL;
 }
 
+struct PreviewImage* BKE_previewimg_create() 
+{
+	PreviewImage* prv_img = NULL;
+	int i;
 
+	prv_img = MEM_callocN(sizeof(PreviewImage), "img_prv");
+
+	for (i=0; i<PREVIEW_MIPMAPS; ++i) {
+		prv_img->changed[i] = 1;
+	}
+	return prv_img;
+}
+
+void BKE_previewimg_free(PreviewImage **prv)
+{
+	if(prv && (*prv)) {
+		int i;
+		
+		for (i=0; i<PREVIEW_MIPMAPS;++i) {
+			if ((*prv)->rect[i]) {
+				MEM_freeN((*prv)->rect[i]);
+				(*prv)->rect[i] = NULL;
+			}
+		}
+		MEM_freeN((*prv));
+		*prv = NULL;
+	}
+}
+
+struct PreviewImage* BKE_previewimg_copy(PreviewImage *prv) 
+{
+	PreviewImage* prv_img = NULL;
+	int i;
+
+	if (prv) {
+		prv_img = MEM_dupallocN(prv);
+		for (i=0; i < PREVIEW_MIPMAPS; ++i) {
+			if (prv->rect[i]) {
+				prv_img->rect[i] = MEM_dupallocN(prv->rect[i]);
+			} else {
+				prv_img->rect[i] = NULL;
+			}
+		}
+	}
+	return prv_img;
+}
+
+void BKE_previewimg_free_id(ID *id) 
+{
+	PreviewImage* prv_img = NULL;
+
+	if (GS(id->name) == ID_MA) {
+		Material *mat = (Material*)id;	
+		BKE_previewimg_free(&mat->preview);
+	} else if (GS(id->name) == ID_TE) {
+		Tex *tex = (Tex*)id;
+		BKE_previewimg_free(&tex->preview);
+	} else if (GS(id->name) == ID_WO) {
+		World *wo = (World*)id;
+		BKE_previewimg_free(&wo->preview);
+	} else if (GS(id->name) == ID_LA) {
+		Lamp *la  = (Lamp*)id;
+		BKE_previewimg_free(&la->preview);
+	} else if (GS(id->name) == ID_IM) {
+		Image *img  = (Image*)id;
+		BKE_previewimg_free(&img->preview);
+	}
+}
+
+PreviewImage* BKE_previewimg_get(ID *id) 
+{
+	PreviewImage* prv_img = NULL;
+
+	if (GS(id->name) == ID_MA) {
+		Material *mat = (Material*)id;	
+		if (!mat->preview) mat->preview = BKE_previewimg_create();
+		prv_img = mat->preview;
+	} else if (GS(id->name) == ID_TE) {
+		Tex *tex = (Tex*)id;
+		if (!tex->preview) tex->preview = BKE_previewimg_create();
+		prv_img = tex->preview;
+	} else if (GS(id->name) == ID_WO) {
+		World *wo = (World*)id;
+		if (!wo->preview) wo->preview = BKE_previewimg_create();
+		prv_img = wo->preview;
+	} else if (GS(id->name) == ID_LA) {
+		Lamp *la  = (Lamp*)id;
+		if (!la->preview) la->preview = BKE_previewimg_create();
+		prv_img = la->preview;
+	} else if (GS(id->name) == ID_IM) {
+		Image *img  = (Image*)id;
+		if (!img->preview) img->preview = BKE_previewimg_create();
+		prv_img = img->preview;
+	} 
+
+	return prv_img;
+}
+
 void BKE_icon_changed(int id)
 {
 	Icon* icon = 0;
@@ -122,7 +222,15 @@
 	
 	if (icon)
 	{
-		icon->changed = 1;
+		PreviewImage *prv = BKE_previewimg_get((ID*)icon->obj);
+
+		/* all previews changed */
+		if (prv) {
+			int i;
+			for (i=0; i<PREVIEW_MIPMAPS; ++i) {
+				prv->changed[i] = 1;
+			}
+		}
 	}	
 }
 
@@ -151,7 +259,6 @@
 	/* next two lines make sure image gets created */
 	new_icon->drawinfo = 0;
 	new_icon->drawinfo_free = 0;
-	new_icon->changed = 1; 
 
 	BLI_ghash_insert(gIcons, (void *)id->icon_id, new_icon);
 	

Modified: branches/imgbrowser-elubie/source/blender/blenkernel/intern/image.c
===================================================================
--- branches/imgbrowser-elubie/source/blender/blenkernel/intern/image.c	2007-06-09 14:25:05 UTC (rev 10902)

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list