[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17572] branches/blender2.5/blender/source /blender/editors: Bringing back icons:
Andrea Weikert
elubie at gmx.net
Tue Nov 25 19:27:41 CET 2008
Revision: 17572
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17572
Author: elubie
Date: 2008-11-25 19:27:41 +0100 (Tue, 25 Nov 2008)
Log Message:
-----------
Bringing back icons:
- Step 1/3: move relevant files to branch
Added Paths:
-----------
branches/blender2.5/blender/source/blender/editors/include/BIF_interface_icons.c
branches/blender2.5/blender/source/blender/editors/interface/interface_icons.c
Copied: branches/blender2.5/blender/source/blender/editors/include/BIF_interface_icons.c (from rev 17566, trunk/blender/source/blender/include/BIF_interface_icons.h)
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/BIF_interface_icons.c (rev 0)
+++ branches/blender2.5/blender/source/blender/editors/include/BIF_interface_icons.c 2008-11-25 18:27:41 UTC (rev 17572)
@@ -0,0 +1,69 @@
+/**
+ * $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) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef BIF_PREVIEW_ICONS_H
+#define BIF_PREVIEW_ICONS_H
+
+struct Image;
+struct ImBuf;
+struct World;
+struct Tex;
+struct Lamp;
+struct Material;
+
+typedef struct IconFile {
+ struct IconFile *next, *prev;
+ char filename[80]; // FILE_MAXFILE size
+ int index;
+} IconFile;
+
+
+#define ICON_DEFAULT_HEIGHT 16
+#define PREVIEW_DEFAULT_HEIGHT 96
+
+/*
+ Resizable Icons for Blender
+*/
+void BIF_icons_init(int first_dyn_id);
+int BIF_icon_get_width(int icon_id);
+int BIF_icon_get_height(int icon_id);
+
+void BIF_icon_draw(float x, float y, int icon_id);
+void BIF_icon_draw_preview(float x, float y, int icon_id, int nocreate);
+
+void BIF_icon_draw_aspect(float x, float y, int icon_id, float aspect);
+void BIF_icon_draw_aspect_blended(float x, float y, int icon_id, float aspect, int shade);
+void BIF_icons_free();
+void BIF_icons_free_drawinfo(void *drawinfo);
+
+struct ListBase *BIF_iconfile_list(void);
+int BIF_iconfile_get_index(char *filename);
+
+
+#endif /* BIF_ICONS_H */
Copied: branches/blender2.5/blender/source/blender/editors/interface/interface_icons.c (from rev 17566, trunk/blender/source/blender/src/interface_icons.c)
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_icons.c (rev 0)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_icons.c 2008-11-25 18:27:41 UTC (rev 17572)
@@ -0,0 +1,1071 @@
+/**
+ * $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) 2001-2002 by NaN Holding BV.
+ * 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>
+#include <string.h>
+
+#ifndef WIN32
+#include <unistd.h>
+#else
+#include <io.h>
+#include <direct.h>
+#endif
+#include "MEM_guardedalloc.h"
+
+#include "BLI_arithb.h"
+#include "BLI_blenlib.h"
+#include "BLI_storage_types.h"
+
+#include "DNA_material_types.h"
+#include "DNA_texture_types.h"
+#include "DNA_world_types.h"
+#include "DNA_object_types.h"
+#include "DNA_lamp_types.h"
+#include "DNA_image_types.h"
+#include "DNA_texture_types.h"
+#include "DNA_world_types.h"
+#include "DNA_camera_types.h"
+#include "DNA_image_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_space_types.h"
+#include "DNA_userdef_types.h"
+
+#include "BKE_global.h"
+#include "BKE_material.h"
+#include "BKE_texture.h"
+#include "BKE_world.h"
+#include "BKE_image.h"
+#include "BKE_object.h"
+#include "BKE_utildefines.h"
+#include "BKE_icons.h"
+#include "BKE_packedFile.h"
+
+#include "IMB_imbuf.h"
+#include "IMB_imbuf_types.h"
+
+#include "BIF_gl.h"
+#include "BIF_glutil.h"
+#include "BIF_interface.h"
+#include "BIF_interface_icons.h"
+#include "BIF_previewrender.h"
+#include "BIF_screen.h"
+#include "BIF_resources.h" /* elubie: should be removed once the enum for the ICONS is in BIF_preview_icons.h */
+
+#include "interface.h"
+
+#include "PIL_time.h"
+
+#include "blendef.h" // CLAMP
+#include "datatoc.h"
+#include "mydevice.h"
+
+#define ICON_IMAGE_W 512
+#define ICON_IMAGE_H 256
+
+#define ICON_GRID_COLS 25
+#define ICON_GRID_ROWS 12
+
+#define ICON_GRID_MARGIN 5
+#define ICON_GRID_W 15
+#define ICON_GRID_H 16
+
+typedef struct IconImage {
+ int w;
+ int h;
+ unsigned int *rect;
+} IconImage;
+
+typedef struct DrawInfo {
+ int w;
+ int h;
+ float aspect;
+ VectorDrawFunc drawFunc; /* If drawFunc is defined then it is a vector icon, otherwise use rect */
+ IconImage* icon;
+} DrawInfo;
+
+/* ******************* STATIC LOCAL VARS ******************* */
+/* static here to cache results of icon directory scan, so it's not
+ * scanning the filesystem each time the menu is drawn */
+static struct ListBase iconfilelist = {0, 0};
+
+
+static int preview_render_size(int miplevel);
+
+/* **************************************************** */
+
+static void def_internal_icon(ImBuf *bbuf, int icon_id, int xofs, int yofs)
+{
+ Icon *new_icon = NULL;
+ IconImage *iimg = NULL;
+ DrawInfo *di;
+ int y = 0;
+
+ new_icon = MEM_callocN(sizeof(Icon), "texicon");
+
+ new_icon->obj = 0; /* icon is not for library object */
+ new_icon->type = 0;
+
+ di = MEM_callocN(sizeof(DrawInfo), "drawinfo");
+ di->drawFunc = 0;
+ di->w = ICON_DEFAULT_HEIGHT;
+ di->h = ICON_DEFAULT_HEIGHT;
+ di->aspect = 1.0f;
+
+ iimg = MEM_mallocN(sizeof(IconImage), "icon_img");
+ iimg->rect = MEM_mallocN(ICON_DEFAULT_HEIGHT*ICON_DEFAULT_HEIGHT*sizeof(unsigned int), "icon_rect");
+ iimg->w = ICON_DEFAULT_HEIGHT;
+ iimg->h = ICON_DEFAULT_HEIGHT;
+
+ /* Here we store the rect in the icon - same as before */
+ for (y=0; y<ICON_DEFAULT_HEIGHT; y++) {
+ memcpy(&iimg->rect[y*ICON_DEFAULT_HEIGHT], &bbuf->rect[(y+yofs)*512+xofs], ICON_DEFAULT_HEIGHT*sizeof(int));
+ }
+
+ di->icon = iimg;
+
+ new_icon->drawinfo_free = BIF_icons_free_drawinfo;
+ new_icon->drawinfo = di;
+
+ BKE_icon_set(icon_id, new_icon);
+}
+
+static void def_internal_vicon( int icon_id, VectorDrawFunc drawFunc)
+{
+ Icon *new_icon = NULL;
+ DrawInfo* di;
+
+ new_icon = MEM_callocN(sizeof(Icon), "texicon");
+
+ new_icon->obj = 0; /* icon is not for library object */
+ new_icon->type = 0;
+
+ di = MEM_callocN(sizeof(DrawInfo), "drawinfo");
+ di->drawFunc =drawFunc;
+ di->w = ICON_DEFAULT_HEIGHT;
+ di->h = ICON_DEFAULT_HEIGHT;
+ di->aspect = 1.0f;
+ di->icon = NULL;
+
+ new_icon->drawinfo_free = 0;
+ new_icon->drawinfo = di;
+
+ BKE_icon_set(icon_id, new_icon);
+}
+
+/* Vector Icon Drawing Routines */
+
+ /* Utilities */
+
+static void viconutil_set_point(GLint pt[2], int x, int y)
+{
+ pt[0] = x;
+ pt[1] = y;
+}
+
+static void viconutil_draw_tri(GLint (*pts)[2])
+{
+ glBegin(GL_TRIANGLES);
+ glVertex2iv(pts[0]);
+ glVertex2iv(pts[1]);
+ glVertex2iv(pts[2]);
+ glEnd();
+}
+
+#if 0
+static void viconutil_draw_quad(GLint (*pts)[2])
+{
+ glBegin(GL_QUADS);
+ glVertex2iv(pts[0]);
+ glVertex2iv(pts[1]);
+ glVertex2iv(pts[2]);
+ glVertex2iv(pts[3]);
+ glEnd();
+}
+#endif
+
+static void viconutil_draw_lineloop(GLint (*pts)[2], int numPoints)
+{
+ int i;
+
+ glBegin(GL_LINE_LOOP);
+ for (i=0; i<numPoints; i++) {
+ glVertex2iv(pts[i]);
+ }
+ glEnd();
+}
+
+static void viconutil_draw_lineloop_smooth(GLint (*pts)[2], int numPoints)
+{
+ glEnable(GL_LINE_SMOOTH);
+ viconutil_draw_lineloop(pts, numPoints);
+ glDisable(GL_LINE_SMOOTH);
+}
+
+static void viconutil_draw_points(GLint (*pts)[2], int numPoints, int pointSize)
+{
+ int i;
+
+ glBegin(GL_QUADS);
+ for (i=0; i<numPoints; i++) {
+ int x = pts[i][0], y = pts[i][1];
+
+ glVertex2i(x-pointSize,y-pointSize);
+ glVertex2i(x+pointSize,y-pointSize);
+ glVertex2i(x+pointSize,y+pointSize);
+ glVertex2i(x-pointSize,y+pointSize);
+ }
+ glEnd();
+}
+
+ /* Drawing functions */
+
+static void vicon_x_draw(int x, int y, int w, int h, float alpha)
+{
+ x += 3;
+ y += 3;
+ w -= 6;
+ h -= 6;
+
+ glEnable( GL_LINE_SMOOTH );
+
+ glLineWidth(2.5);
+
+ glColor4f(0.0, 0.0, 0.0, alpha);
+ glBegin(GL_LINES);
+ glVertex2i(x ,y );
+ glVertex2i(x+w,y+h);
+ glVertex2i(x+w,y );
+ glVertex2i(x ,y+h);
+ glEnd();
+
+ glLineWidth(1.0);
+
+ glDisable( GL_LINE_SMOOTH );
+}
+
+static void vicon_view3d_draw(int x, int y, int w, int h, float alpha)
+{
+ int cx = x + w/2;
+ int cy = y + h/2;
+ int d = MAX2(2, h/3);
+
+ glColor4f(0.5, 0.5, 0.5, alpha);
+ glBegin(GL_LINES);
+ glVertex2i(x , cy-d);
+ glVertex2i(x+w, cy-d);
+ glVertex2i(x , cy+d);
+ glVertex2i(x+w, cy+d);
+
+ glVertex2i(cx-d, y );
+ glVertex2i(cx-d, y+h);
+ glVertex2i(cx+d, y );
+ glVertex2i(cx+d, y+h);
+ glEnd();
+
+ glColor4f(0.0, 0.0, 0.0, alpha);
+ glBegin(GL_LINES);
+ glVertex2i(x , cy);
+ glVertex2i(x+w, cy);
+ glVertex2i(cx, y );
+ glVertex2i(cx, y+h);
+ glEnd();
+}
+
+static void vicon_edit_draw(int x, int y, int w, int h, float alpha)
+{
+ GLint pts[4][2];
+
+ viconutil_set_point(pts[0], x+3 , y+3 );
+ viconutil_set_point(pts[1], x+w-3, y+3 );
+ viconutil_set_point(pts[2], x+w-3, y+h-3);
+ viconutil_set_point(pts[3], x+3 , y+h-3);
+
+ glColor4f(0.0, 0.0, 0.0, alpha);
+ viconutil_draw_lineloop(pts, 4);
+
+ glColor3f(1, 1, 0.0);
+ viconutil_draw_points(pts, 4, 1);
+}
+
+static void vicon_editmode_hlt_draw(int x, int y, int w, int h, float alpha)
+{
+ GLint pts[3][2];
+
+ viconutil_set_point(pts[0], x+w/2, y+h-2);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list