added iff, lbm and bmp filetypes to the fileselect. added loading of bmp images,
modified drawing of the imageselect, and a bugfix for popups.
This commit is contained in:
@@ -30,6 +30,8 @@
|
||||
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#define OLD_IMASEL 0
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -70,6 +72,64 @@
|
||||
/* GLOBALS */
|
||||
extern char *fsmenu;
|
||||
|
||||
void rectwrite_imasel(int winxmin, int winymin, int winxmax, int winymax, int x1, int y1, int xim, int yim, float zoomx, float zoomy, unsigned int *rect)
|
||||
{
|
||||
int cx, cy, oldxim, x2, y2;
|
||||
|
||||
oldxim= xim;
|
||||
|
||||
/* coordinaten hoe 't op scherm komt */
|
||||
x2= x1+ zoomx*xim;
|
||||
y2= y1+ zoomy*yim;
|
||||
|
||||
/* partiele clip */
|
||||
if(x1<=winxmin) {
|
||||
/* recten bij OpenGL mogen niet links/onder van windowrand beginnen */
|
||||
cx= winxmin-x1+(int)zoomx;
|
||||
/* zorg ervoor dat de rect pixelnauwkeurig wordt neergezet */
|
||||
cx/= zoomx;
|
||||
cx++;
|
||||
x1+= zoomx*cx;
|
||||
xim-= cx;
|
||||
rect+= cx;
|
||||
}
|
||||
if(y1<=winymin) {
|
||||
cy= winymin-y1+(int)zoomy;
|
||||
cy/= zoomy;
|
||||
cy++;
|
||||
y1+= zoomy*cy;
|
||||
rect+= cy*oldxim;
|
||||
yim-= cy;
|
||||
}
|
||||
if(x2>=winxmax) {
|
||||
cx= x2-winxmax;
|
||||
cx/= zoomx;
|
||||
xim-= cx+3;
|
||||
}
|
||||
if(y2>=winymax) {
|
||||
cy= y2-winymax;
|
||||
cy/= zoomy;
|
||||
yim-= cy+3;
|
||||
}
|
||||
|
||||
if(xim<=0) return;
|
||||
if(yim<=0) return;
|
||||
|
||||
// mywinset(curarea->win);
|
||||
glScissor(winxmin, winymin, winxmax-winxmin+1, winymax-winymin+1);
|
||||
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, oldxim);
|
||||
|
||||
glPixelZoom(zoomx, zoomy);
|
||||
|
||||
glRasterPos2i(x1, y1);
|
||||
glDrawPixels(xim, yim, GL_RGBA, GL_UNSIGNED_BYTE, rect);
|
||||
|
||||
glPixelZoom(1.0, 1.0);
|
||||
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
}
|
||||
|
||||
void viewgate(short sx, short sy, short ex, short ey)
|
||||
{
|
||||
short wx, wy;
|
||||
@@ -302,7 +362,8 @@ void make_sima_area(SpaceImaSel *simasel)
|
||||
|
||||
dm = 1;
|
||||
if (simasel->curimay-2 < simasel->fesy) dm = 0;
|
||||
if (simasel->curimay+80 > simasel->feey) dm = 0;
|
||||
// let first row of icons remain selectable
|
||||
if(OLD_IMASEL) if (simasel->curimay+80 > simasel->feey) dm = 0;
|
||||
if (simasel->curimax+72 > simasel->feex) dm = 0;
|
||||
|
||||
simasel->total_selected = 0;
|
||||
@@ -324,8 +385,11 @@ void make_sima_area(SpaceImaSel *simasel)
|
||||
simasel->curimay -= 100;
|
||||
|
||||
dm = 1;
|
||||
if (simasel->curimay+80 > simasel->feey) dm = 0;
|
||||
if (simasel->curimay-8 < simasel->fesy) dm = 0;
|
||||
// let icons that fall off (top/bottom) be selectable
|
||||
if(OLD_IMASEL) {
|
||||
if (simasel->curimay+80 > simasel->feey) dm = 0;
|
||||
if (simasel->curimay-8 < simasel->fesy) dm = 0;
|
||||
}
|
||||
|
||||
}
|
||||
ima = ima->next;
|
||||
@@ -348,6 +412,7 @@ static void str_image_type(int ftype, char *name)
|
||||
if( ftype & JPG ) { strcat(name, "jpeg "); }
|
||||
if( ftype & TGA ) { strcat(name, "targa "); }
|
||||
if( ftype & PNG ) { strcat(name, "png "); }
|
||||
if( ftype & BMP ) { strcat(name, "bmp "); }
|
||||
if( ftype & AMI ) { strcat(name, "iff "); }
|
||||
}
|
||||
|
||||
@@ -529,7 +594,12 @@ void draw_sima_area(SpaceImaSel *simasel)
|
||||
|
||||
if ((ima) && (ima->pict) && (ima->pict->rect)){
|
||||
if ( (ey > simasel->fesy) && (sy < simasel->feey)){
|
||||
lrectwrite(sx, sy, ex-1, ey-1, ima->pict->rect);
|
||||
if(OLD_IMASEL) {
|
||||
lrectwrite(sx, sy, ex-1, ey-1, ima->pict->rect);
|
||||
} else
|
||||
rectwrite_imasel(simasel->fesx, simasel->fesy,
|
||||
curarea->winrct.xmax, curarea->winrct.ymax - 64, //simasel->feey*1.5,
|
||||
sx, sy, ima->pict->x, ima->pict->y, 1.0, 1.0, ima->pict->rect);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -554,7 +624,12 @@ void draw_sima_area(SpaceImaSel *simasel)
|
||||
/* glRecti(sx-7, sy-7, ex+7, ey+7); */
|
||||
uiEmboss(sx-1,sy-1, ex+1,ey+1, 0);
|
||||
|
||||
lrectwrite(sx, sy, sx+ (ima->ex - ima->sx)-1, sy+ (ima->ey - ima->sy)-1, ima->pict->rect);
|
||||
if(OLD_IMASEL) {
|
||||
lrectwrite(sx, sy, sx+ (ima->ex - ima->sx)-1, sy+ (ima->ey - ima->sy)-1, ima->pict->rect);
|
||||
} else
|
||||
rectwrite_imasel(simasel->fesx, simasel->fesy,
|
||||
curarea->winrct.xmax, curarea->winrct.ymax - 64, //simasel->feey*1.5,
|
||||
sx, sy, ima->pict->x, ima->pict->y, 2.0, 2.0, ima->pict->rect);
|
||||
|
||||
glPixelZoom(1.0, 1.0);
|
||||
}
|
||||
|
@@ -504,10 +504,13 @@ void test_flags_file(SpaceFile *sfile)
|
||||
file->flags |= PSXFILE;
|
||||
}
|
||||
} else if (sfile->type==FILE_SPECIAL){
|
||||
if(BLI_testextensie(file->relname, ".jpg") ||
|
||||
if( BLI_testextensie(file->relname, ".jpg") ||
|
||||
BLI_testextensie(file->relname, ".tga") ||
|
||||
BLI_testextensie(file->relname, ".rgb") ||
|
||||
BLI_testextensie(file->relname, ".png") ||
|
||||
BLI_testextensie(file->relname, ".bmp") ||
|
||||
BLI_testextensie(file->relname, ".iff") ||
|
||||
BLI_testextensie(file->relname, ".lbm") ||
|
||||
BLI_testextensie(file->relname, ".sgi")) {
|
||||
file->flags |= IMAGEFILE;
|
||||
}
|
||||
|
@@ -203,6 +203,7 @@ static void window_handle(Window *win, short event, short val)
|
||||
win->handler(win, win->user_data, event, val, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void window_handle_ext(Window *win, short event, short val, short extra)
|
||||
{
|
||||
if (win->handler) {
|
||||
@@ -321,6 +322,7 @@ void window_make_active(Window *win) {
|
||||
GHOST_ActivateWindowDrawingContext(win->ghostwin);
|
||||
}
|
||||
}
|
||||
|
||||
void window_swap_buffers(Window *win) {
|
||||
GHOST_SwapWindowBuffers(win->ghostwin);
|
||||
}
|
||||
@@ -348,9 +350,11 @@ static int query_qual(char qual) {
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static int change_bit(int val, int bit, int to_on) {
|
||||
return to_on?(val|bit):(val&~bit);
|
||||
}
|
||||
|
||||
static int event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) {
|
||||
GHOST_TEventType type= GHOST_GetEventType(evt);
|
||||
|
||||
@@ -442,20 +446,16 @@ static int event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) {
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case GHOST_kEventWheel:
|
||||
{
|
||||
|
||||
case GHOST_kEventWheel: {
|
||||
GHOST_TEventWheelData* wheelData = (GHOST_TEventWheelData*) data;
|
||||
if (wheelData->z > 0)
|
||||
{
|
||||
if (wheelData->z > 0) {
|
||||
window_handle(win, WHEELUPMOUSE, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
window_handle(win, WHEELDOWNMOUSE, 1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case GHOST_kEventWindowDeactivate:
|
||||
case GHOST_kEventWindowActivate: {
|
||||
@@ -526,6 +526,7 @@ char *window_get_title(Window *win) {
|
||||
|
||||
return mem_title;
|
||||
}
|
||||
|
||||
void window_set_title(Window *win, char *title) {
|
||||
GHOST_SetTitle(win->ghostwin, title);
|
||||
}
|
||||
@@ -533,17 +534,21 @@ void window_set_title(Window *win, char *title) {
|
||||
short window_get_qual(Window *win) {
|
||||
return win->lqual;
|
||||
}
|
||||
|
||||
short window_get_mbut(Window *win) {
|
||||
return win->lmbut;
|
||||
}
|
||||
|
||||
void window_get_mouse(Window *win, short *mval) {
|
||||
mval[0]= win->lmouse[0];
|
||||
mval[1]= win->lmouse[1];
|
||||
}
|
||||
|
||||
void window_get_position(Window *win, int *posx_r, int *posy_r) {
|
||||
*posx_r= win->position[0];
|
||||
*posy_r= win->position[1];
|
||||
}
|
||||
|
||||
void window_get_size(Window *win, int *width_r, int *height_r) {
|
||||
*width_r= win->size[0];
|
||||
*height_r= win->size[1];
|
||||
@@ -556,6 +561,7 @@ void window_set_size(Window *win, int width, int height) {
|
||||
void window_lower(Window *win) {
|
||||
GHOST_SetWindowOrder(win->ghostwin, GHOST_kWindowOrderBottom);
|
||||
}
|
||||
|
||||
void window_raise(Window *win) {
|
||||
GHOST_SetWindowOrder(win->ghostwin, GHOST_kWindowOrderTop);
|
||||
}
|
||||
|
@@ -3052,6 +3052,8 @@ static int ui_do_block(uiBlock *block, uiEvent *uevent)
|
||||
}
|
||||
|
||||
if(uevent->event==ESCKEY && uevent->val==1) return UI_RETURN_CANCEL;
|
||||
|
||||
if((uevent->event==RETKEY || uevent->event==PADENTER) && uevent->val==1) return UI_RETURN_OK;
|
||||
|
||||
/* check outside */
|
||||
if(block->direction==UI_RIGHT) count= 140; else count= 40;
|
||||
|
Reference in New Issue
Block a user