Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Bishop <nicholasbishop@gmail.com>2010-10-19 04:45:37 +0400
committerNicholas Bishop <nicholasbishop@gmail.com>2010-10-19 04:45:37 +0400
commita377a7edf67869722c585086ac6ab1f295cbff87 (patch)
tree1736de08fe9174761607dce5d54a16af25eba049 /source/blender/editors/interface/interface_icons.c
parent08232350d5797302e3638e69ec78657d853976aa (diff)
parentb743454ce1c361e6161da8ae5f840c2befe3a081 (diff)
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r32300:32571soc-2010-nicolasbishop
Diffstat (limited to 'source/blender/editors/interface/interface_icons.c')
-rw-r--r--source/blender/editors/interface/interface_icons.c108
1 files changed, 60 insertions, 48 deletions
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index 482eece42f6..0ade3e6199f 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -28,6 +28,7 @@
#include <math.h>
#include <stdlib.h>
#include <string.h>
+#include <assert.h>
#ifndef WIN32
#include <unistd.h>
@@ -331,7 +332,7 @@ static void vicon_editmode_hlt_draw(int x, int y, int w, int h, float alpha)
viconutil_draw_points(pts, 3, 1);
}
-static void vicon_editmode_dehlt_draw(int x, int y, int w, int h, float alpha)
+static void vicon_editmode_dehlt_draw(int x, int y, int w, int h, float UNUSED(alpha))
{
GLint pts[3][2];
@@ -346,7 +347,7 @@ static void vicon_editmode_dehlt_draw(int x, int y, int w, int h, float alpha)
viconutil_draw_points(pts, 3, 1);
}
-static void vicon_disclosure_tri_right_draw(int x, int y, int w, int h, float alpha)
+static void vicon_disclosure_tri_right_draw(int x, int y, int w, int UNUSED(h), float alpha)
{
GLint pts[3][2];
int cx = x+w/2;
@@ -371,7 +372,7 @@ static void vicon_disclosure_tri_right_draw(int x, int y, int w, int h, float al
viconutil_draw_lineloop_smooth(pts, 3);
}
-static void vicon_small_tri_right_draw(int x, int y, int w, int h, float alpha)
+static void vicon_small_tri_right_draw(int x, int y, int w, int UNUSED(h), float alpha)
{
GLint pts[3][2];
int cx = x+w/2-4;
@@ -393,7 +394,7 @@ static void vicon_small_tri_right_draw(int x, int y, int w, int h, float alpha)
glShadeModel(GL_FLAT);
}
-static void vicon_disclosure_tri_down_draw(int x, int y, int w, int h, float alpha)
+static void vicon_disclosure_tri_down_draw(int x, int y, int w, int UNUSED(h), float alpha)
{
GLint pts[3][2];
int cx = x+w/2;
@@ -418,7 +419,7 @@ static void vicon_disclosure_tri_down_draw(int x, int y, int w, int h, float alp
viconutil_draw_lineloop_smooth(pts, 3);
}
-static void vicon_move_up_draw(int x, int y, int w, int h, float alpha)
+static void vicon_move_up_draw(int x, int y, int w, int h, float UNUSED(alpha))
{
int d=-2;
@@ -436,7 +437,7 @@ static void vicon_move_up_draw(int x, int y, int w, int h, float alpha)
glDisable(GL_LINE_SMOOTH);
}
-static void vicon_move_down_draw(int x, int y, int w, int h, float alpha)
+static void vicon_move_down_draw(int x, int y, int w, int h, float UNUSED(alpha))
{
int d=2;
@@ -622,20 +623,30 @@ static void init_iconfile_list(struct ListBase *list)
char *filename = dir[i].relname;
if(BLI_testextensie(filename, ".png")) {
-
+
/* check to see if the image is the right size, continue if not */
/* copying strings here should go ok, assuming that we never get back
a complete path to file longer than 256 chars */
sprintf(iconfilestr, "%s/%s", icondirstr, filename);
- if(BLI_exists(iconfilestr)) bbuf = IMB_loadiffname(iconfilestr, IB_rect);
-
- ifilex = bbuf->x;
- ifiley = bbuf->y;
- IMB_freeImBuf(bbuf);
+ if(BLI_exists(iconfilestr))
+ bbuf= IMB_loadiffname(iconfilestr, IB_rect);
+ else
+ bbuf= NULL;
+
+
+ if(bbuf) {
+ ifilex = bbuf->x;
+ ifiley = bbuf->y;
+ IMB_freeImBuf(bbuf);
+ }
+ else {
+ ifilex= ifiley= 0;
+ }
+ /* bad size or failed to load */
if ((ifilex != ICON_IMAGE_W) || (ifiley != ICON_IMAGE_H))
continue;
-
+
/* found a potential icon file, so make an entry for it in the cache list */
ifile = MEM_callocN(sizeof(IconFile), "IconFile");
@@ -833,8 +844,17 @@ static void icon_set_image(bContext *C, ID *id, PreviewImage* prv_img, int miple
prv_img->w[miplevel], prv_img->h[miplevel]);
}
-static void icon_draw_rect(float x, float y, int w, int h, float aspect, int rw, int rh, unsigned int *rect, float alpha, float *rgb)
+static void icon_draw_rect(float x, float y, int w, int h, float UNUSED(aspect), int rw, int rh, unsigned int *rect, float alpha, float *rgb, short is_preview)
{
+ ImBuf *ima= NULL;
+
+ /* sanity check */
+ if(w<=0 || h<=0 || w>2000 || h>2000) {
+ printf("icon_draw_rect: icons are %i x %i pixels?\n", w, h);
+ assert(!"invalid icon size");
+ return;
+ }
+
/* modulate color */
if(alpha != 1.0f)
glPixelTransferf(GL_ALPHA_SCALE, alpha);
@@ -844,35 +864,27 @@ static void icon_draw_rect(float x, float y, int w, int h, float aspect, int rw,
glPixelTransferf(GL_GREEN_SCALE, rgb[1]);
glPixelTransferf(GL_BLUE_SCALE, rgb[2]);
}
-
- /* draw */
- if((w<1 || h<1)) {
- // XXX - TODO 2.5 verify whether this case can happen
- if (G.f & G_DEBUG)
- printf("what the heck! - icons are %i x %i pixels?\n", w, h);
- }
- /* rect contains image in 'rendersize', we only scale if needed */
- else if(rw!=w && rh!=h) {
- if(w>2000 || h>2000) { /* something has gone wrong! */
- if (G.f & G_DEBUG)
- printf("insane icon size w=%d h=%d\n",w,h);
- }
- else {
- ImBuf *ima;
- /* first allocate imbuf for scaling and copy preview into it */
- ima = IMB_allocImBuf(rw, rh, 32, IB_rect, 0);
- memcpy(ima->rect, rect, rw*rh*sizeof(unsigned int));
-
- /* scale it */
- IMB_scaleImBuf(ima, w, h);
- glaDrawPixelsSafe(x, y, w, h, w, GL_RGBA, GL_UNSIGNED_BYTE, ima->rect);
-
- IMB_freeImBuf(ima);
- }
+ /* rect contains image in 'rendersize', we only scale if needed */
+ if(rw!=w && rh!=h) {
+ /* first allocate imbuf for scaling and copy preview into it */
+ ima = IMB_allocImBuf(rw, rh, 32, IB_rect);
+ memcpy(ima->rect, rect, rw*rh*sizeof(unsigned int));
+ IMB_scaleImBuf(ima, w, h); /* scale it */
+ rect= ima->rect;
}
- else
+
+ /* draw */
+ if(is_preview) {
glaDrawPixelsSafe(x, y, w, h, w, GL_RGBA, GL_UNSIGNED_BYTE, rect);
+ }
+ else {
+ glRasterPos2f(x, y);
+ glDrawPixels(w, h, GL_RGBA, GL_UNSIGNED_BYTE, rect);
+ }
+
+ if(ima)
+ IMB_freeImBuf(ima);
/* restore color */
if(alpha != 0.0f)
@@ -885,7 +897,7 @@ static void icon_draw_rect(float x, float y, int w, int h, float aspect, int rw,
}
}
-static void icon_draw_texture(float x, float y, float w, float h, int ix, int iy, int iw, int ih, float alpha, float *rgb)
+static void icon_draw_texture(float x, float y, float w, float h, int ix, int iy, int UNUSED(iw), int ih, float alpha, float *rgb)
{
float x1, x2, y1, y2;
@@ -928,7 +940,7 @@ static int preview_size(int miplevel)
return 0;
}
-static void icon_draw_size(float x, float y, int icon_id, float aspect, float alpha, float *rgb, int miplevel, int draw_size, int nocreate)
+static void icon_draw_size(float x, float y, int icon_id, float aspect, float alpha, float *rgb, int miplevel, int draw_size, int UNUSED(nocreate), int is_preview)
{
Icon *icon = NULL;
DrawInfo *di = NULL;
@@ -971,7 +983,7 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al
if(!iimg->rect) return; /* something has gone wrong! */
- icon_draw_rect(x, y, w, h, aspect, iimg->w, iimg->h, iimg->rect, alpha, rgb);
+ icon_draw_rect(x, y, w, h, aspect, iimg->w, iimg->h, iimg->rect, alpha, rgb, is_preview);
}
else if(di->type == ICON_TYPE_PREVIEW) {
PreviewImage* pi = BKE_previewimg_get((ID*)icon->obj);
@@ -982,7 +994,7 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al
/* preview images use premul alpha ... */
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- icon_draw_rect(x, y, w, h, aspect, pi->w[miplevel], pi->h[miplevel], pi->rect[miplevel], 1.0f, NULL);
+ icon_draw_rect(x, y, w, h, aspect, pi->w[miplevel], pi->h[miplevel], pi->rect[miplevel], 1.0f, NULL, is_preview);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
}
@@ -1072,7 +1084,7 @@ int ui_id_icon_get(bContext *C, ID *id, int preview)
static void icon_draw_mipmap(float x, float y, int icon_id, float aspect, float alpha, int miplevel, int nocreate)
{
int draw_size = preview_size(miplevel);
- icon_draw_size(x, y, icon_id, aspect, alpha, NULL, miplevel, draw_size, nocreate);
+ icon_draw_size(x, y, icon_id, aspect, alpha, NULL, miplevel, draw_size, nocreate, FALSE);
}
void UI_icon_draw_aspect(float x, float y, int icon_id, float aspect, float alpha)
@@ -1083,7 +1095,7 @@ void UI_icon_draw_aspect(float x, float y, int icon_id, float aspect, float alph
void UI_icon_draw_aspect_color(float x, float y, int icon_id, float aspect, float *rgb)
{
int draw_size = preview_size(PREVIEW_MIPMAP_ZERO);
- icon_draw_size(x, y, icon_id, aspect, 1.0f, rgb, PREVIEW_MIPMAP_ZERO, draw_size, 0);
+ icon_draw_size(x, y, icon_id, aspect, 1.0f, rgb, PREVIEW_MIPMAP_ZERO, draw_size, FALSE, FALSE);
}
void UI_icon_draw(float x, float y, int icon_id)
@@ -1093,7 +1105,7 @@ void UI_icon_draw(float x, float y, int icon_id)
void UI_icon_draw_size(float x, float y, int size, int icon_id, float alpha)
{
- icon_draw_size(x, y, icon_id, 1.0f, alpha, NULL, 0, size, 1);
+ icon_draw_size(x, y, icon_id, 1.0f, alpha, NULL, PREVIEW_MIPMAP_ZERO, size, TRUE, FALSE);
}
void UI_icon_draw_preview(float x, float y, int icon_id)
@@ -1108,6 +1120,6 @@ void UI_icon_draw_preview_aspect(float x, float y, int icon_id, float aspect)
void UI_icon_draw_preview_aspect_size(float x, float y, int icon_id, float aspect, int size)
{
- icon_draw_size(x, y, icon_id, aspect, 1.0f, NULL, PREVIEW_MIPMAP_LARGE, size, 0);
+ icon_draw_size(x, y, icon_id, aspect, 1.0f, NULL, PREVIEW_MIPMAP_LARGE, size, FALSE, TRUE);
}