- Fixed bug with Ellipse objects when exporting to SVG

- Fixed slowdown when creating new links
This commit is contained in:
Rob Pearce 2009-03-10 21:01:21 +00:00
parent 9d04b4f215
commit e009df29e9
3 changed files with 50 additions and 38 deletions

View File

@ -3,6 +3,19 @@ Ideas for future versions:
Solaris (and possibly other platforms)
- Perhaps change to SVG for objects
Version 1.8d:
- Fixed bug with Ellipse objects when exporting to SVG
- Fixed slowdown when creating new links
Version 1.8c:
- now re-calcing scrollbar size whenever diagram is modified
- can no longer accidentally change maps while scrolling vertically
- fixed graphical glitch when editting text while scrolled
- clicking mouse while entering text is now the same as pressing enter
- findnext now works again
- when searching, the found object is more obviously highlighted
Version 1.8b:
- Fixed placement of text fields in dialog screens

View File

@ -1,4 +1,4 @@
#define VERSION "1.8c"
#define VERSION "1.8d"
/* variable sizes */
#define SMALLBUFLEN 64 /* small text buffer */

View File

@ -102,9 +102,9 @@ char searchtext[BUFLEN];
int grid = TRUE;
int gridsize = 15;
int gridsizelist[] = {10, 15, 20};
int gridsizelist[] = {0, 10, 15, 20};
int gridsizeindex = 1;
int gridsizenum = 3;
int gridsizenum = 4;
SDL_Color gridcol = {192, 192, 192, 0 };
int oldshowflows = FALSE;
@ -303,9 +303,9 @@ int main (int argc, char **argv) {
/* set screen size */
screen = SDL_SetVideoMode(event.resize.w > MINSCREENX ? event.resize.w : MINSCREENX,
event.resize.h > MINSCREENY ? event.resize.h : MINSCREENY,
map[curmap].bpp, SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_RESIZABLE);
map[curmap].bpp, SDL_SWSURFACE|SDL_DOUBLEBUF|SDL_RESIZABLE);
SDL_FreeSurface(buffer);
buffer = SDL_CreateRGBSurface(SDL_HWSURFACE,screen->w - SIDEBARW,screen->h - STATUSH,
buffer = SDL_CreateRGBSurface(SDL_SWSURFACE,screen->w - SIDEBARW,screen->h - STATUSH,
screen->format->BitsPerPixel, screen->format->Rmask,
screen->format->Gmask,screen->format->Bmask,
screen->format->Amask);
@ -1445,7 +1445,7 @@ int main (int argc, char **argv) {
}
/* copy background of this button */
if (selection <= TB_SAVE) {
toolbg = SDL_CreateRGBSurface(SDL_HWSURFACE,toolbox.gridsize+3, toolbox.gridsize+3,
toolbg = SDL_CreateRGBSurface(SDL_SWSURFACE,toolbox.gridsize+3, toolbox.gridsize+3,
screen->format->BitsPerPixel, screen->format->Rmask,
screen->format->Gmask,screen->format->Bmask,
screen->format->Amask);
@ -2768,7 +2768,7 @@ void adjustendpoint(SDL_Surface *screen, int *adjx, int *adjy, double x1, double
/*
temps = SDL_CreateRGBSurface(SDL_HWSURFACE,10,10,
temps = SDL_CreateRGBSurface(SDL_SWSURFACE,10,10,
screen->format->BitsPerPixel, screen->format->Rmask,
screen->format->Gmask,screen->format->Bmask,
screen->format->Amask);
@ -2793,7 +2793,7 @@ void adjustendpoint(SDL_Surface *screen, int *adjx, int *adjy, double x1, double
SDL_Rect area;
int tid;
temps = SDL_CreateRGBSurface(SDL_HWSURFACE,map[curmap].obj[o].w+3, map[curmap].obj[o].h+3,
temps = SDL_CreateRGBSurface(SDL_SWSURFACE,map[curmap].obj[o].w+3, map[curmap].obj[o].h+3,
screen->format->BitsPerPixel, screen->format->Rmask,
screen->format->Gmask,screen->format->Bmask,
screen->format->Amask);
@ -3366,7 +3366,6 @@ int findpointpos(link_t *l, int px, int py) {
return pos;
}
void drawline(SDL_Surface *screen, int x1, int y1, int x2, int y2, SDL_Color c, int linestyle) {
int deltax, deltay;
int numpixels;
@ -3710,7 +3709,7 @@ void drawobject(SDL_Surface *dest, mapobject_t *o, int doublebuffer, int adjust)
fflush(stdout);
}
if (doublebuffer) {
temps = SDL_CreateRGBSurface(SDL_HWSURFACE,o->w+3, o->h+3,
temps = SDL_CreateRGBSurface(SDL_SWSURFACE,o->w+3, o->h+3,
screen->format->BitsPerPixel, screen->format->Rmask,
screen->format->Gmask,screen->format->Bmask,
screen->format->Amask);
@ -4289,7 +4288,7 @@ void drawsearchflash(void) {
SDL_BlitSurface(searchbg, NULL, screen, &area);
/* draw hilight */
temps = SDL_CreateRGBSurface(SDL_HWSURFACE,area.w, area.h,
temps = SDL_CreateRGBSurface(SDL_SWSURFACE,area.w, area.h,
screen->format->BitsPerPixel, screen->format->Rmask,
screen->format->Gmask,screen->format->Bmask,
screen->format->Amask);
@ -5167,7 +5166,7 @@ void drawvector(SDL_Surface *dest, vectorimg_t *vimg, int x, int y, int w, int h
/* create temp surface */
if ((vimg->vector[i].type == VT_POLY) || (vimg->vector[i].type == VT_SUBOBJ)) {
if (temp == NULL) {
temp = SDL_CreateRGBSurface(SDL_HWSURFACE,w+3, h+3,
temp = SDL_CreateRGBSurface(SDL_SWSURFACE,w+3, h+3,
screen->format->BitsPerPixel, screen->format->Rmask,
screen->format->Gmask,screen->format->Bmask, screen->format->Amask);
// clear temp surface to bg colour
@ -5185,7 +5184,7 @@ void drawvector(SDL_Surface *dest, vectorimg_t *vimg, int x, int y, int w, int h
}
} else if (vimg->vector[i].type != VT_ENDPOLY) {
if (!insubobj) {
temp = SDL_CreateRGBSurface(SDL_HWSURFACE,w+3, h+3,
temp = SDL_CreateRGBSurface(SDL_SWSURFACE,w+3, h+3,
screen->format->BitsPerPixel, screen->format->Rmask,
screen->format->Gmask,screen->format->Bmask, screen->format->Amask);
// clear temp surface to bg colour
@ -5464,10 +5463,12 @@ void drawvectorSVG(vectorimg_t *vimg, int x, int y, int w, int h, SDL_Color *ove
sprintf(temp, "\" style=\"fill:rgb(%d,%d,%d);stroke:rgb(%d,%d,%d);stroke-width:1\"/>\n", fillcol.r, fillcol.g, fillcol.b, polycol.r, polycol.g, polycol.b);
strcat(svgbuf, temp);
fprintf(svgfile, svgbuf);
} else if (insubobj) {
/*} else if (insubobj) {
sprintf(svgbuf, "\" style=\"fill:rgb(%d,%d,%d);stroke:rgb(%d,%d,%d);stroke-width:1\"/>\n", fillcol.r, fillcol.g, fillcol.b, polycol.r, polycol.g, polycol.b);
fprintf(svgfile, svgbuf);
*/
}
//sprintf(svgbuf, "<g id=\"group%d\" fill:rgb(%d,%d,%d) >\n", gnum,
insubobj = FALSE;
@ -5489,7 +5490,6 @@ void drawvectorSVG(vectorimg_t *vimg, int x, int y, int w, int h, SDL_Color *ove
sprintf(svgbuf,"<ellipse cx=\"%d\" cy=\"%d\" rx=\"%d\" ry=\"%d\" style=\"stroke-width:1;stroke:rgb(%d,%d,%d)\"/>\n", realx1, realy1, realx2-x, realy2-y,linecol.r,linecol.g,linecol.b);
}
fprintf(svgfile, svgbuf);
break;
case VT_BEZIER:
/*TODO: implement */
@ -6423,8 +6423,8 @@ void pasteline(SDL_Surface *screen, int *lbuf) {
}
//SDL_UpdateRect(screen, tlx, tly,w,h);
SDL_Flip(screen);
SDL_UpdateRect(screen, tlx, tly,w,h);
//SDL_Flip(screen);
}
@ -6454,16 +6454,16 @@ int initgraphics(void) {
}
/* open window */
screen = SDL_SetVideoMode(DEFSCREENW, DEFSCREENH, 16, (SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_RESIZABLE));
screen = SDL_SetVideoMode(DEFSCREENW, DEFSCREENH, 16, (SDL_SWSURFACE|SDL_DOUBLEBUF|SDL_RESIZABLE));
if(!screen) {
printf("SDL_SetVideoMode: %s\n", SDL_GetError());
return -1;
}
if (screen->flags & SDL_HWSURFACE) {
if (screen->flags & SDL_SWSURFACE) {
printf("SWSurface set ok.\n"); fflush(stdout);
}
if (screen->flags & SDL_HWSURFACE) {
if (screen->flags & SDL_SWSURFACE) {
printf("HWSurface set ok.\n"); fflush(stdout);
}
if (screen->flags & SDL_DOUBLEBUF) {
@ -6618,7 +6618,7 @@ int initgraphics(void) {
updatewm();
/* set up toolbox highlight image */
toolhilite = SDL_CreateRGBSurface(SDL_HWSURFACE,toolbox.gridsize+3, toolbox.gridsize+3,
toolhilite = SDL_CreateRGBSurface(SDL_SWSURFACE,toolbox.gridsize+3, toolbox.gridsize+3,
screen->format->BitsPerPixel, screen->format->Rmask,
screen->format->Gmask,screen->format->Bmask,
screen->format->Amask);
@ -6632,7 +6632,7 @@ screen->format->Amask);
SDL_SetAlpha(toolhilite, SDL_SRCALPHA, 128);
/* initialise buffer */
buffer = SDL_CreateRGBSurface(SDL_HWSURFACE,screen->w - SIDEBARW,screen->h - STATUSH,
buffer = SDL_CreateRGBSurface(SDL_SWSURFACE,screen->w - SIDEBARW,screen->h - STATUSH,
screen->format->BitsPerPixel, screen->format->Rmask,
screen->format->Gmask,screen->format->Bmask,
screen->format->Amask);
@ -7059,7 +7059,7 @@ screen->format->Amask);
/* allocate mem */
button[numbuttons].img = SDL_CreateRGBSurface(SDL_HWSURFACE,toolbox.gridsize-2,toolbox.gridsize-2,
button[numbuttons].img = SDL_CreateRGBSurface(SDL_SWSURFACE,toolbox.gridsize-2,toolbox.gridsize-2,
screen->format->BitsPerPixel, screen->format->Rmask,
screen->format->Gmask,screen->format->Bmask,
screen->format->Amask);
@ -7659,7 +7659,7 @@ void setsearchflash (int num) {
area.x = map[curmap].textob[map[curmap].selecteditem].x - screenx + txoff;
area.y = map[curmap].textob[map[curmap].selecteditem].y - screeny + tyoff;
searchbg = SDL_CreateRGBSurface(SDL_HWSURFACE,area.w, area.h,
searchbg = SDL_CreateRGBSurface(SDL_SWSURFACE,area.w, area.h,
screen->format->BitsPerPixel, screen->format->Rmask,
screen->format->Gmask,screen->format->Bmask,
screen->format->Amask);
@ -7706,7 +7706,7 @@ int savemap(void) {
((filename[eoff+2] == 'm') || (filename[eoff+2] == 'M')) &&
((filename[eoff+3] == 'p') || (filename[eoff+3] == 'P'))
) {
exportmap = SDL_CreateRGBSurface(SDL_HWSURFACE,map[curmap].width, map[curmap].height,
exportmap = SDL_CreateRGBSurface(SDL_SWSURFACE,map[curmap].width, map[curmap].height,
buffer->format->BitsPerPixel, buffer->format->Rmask,
buffer->format->Gmask,buffer->format->Bmask,
buffer->format->Amask);
@ -7921,7 +7921,7 @@ int showfiledialog(void) {
SDL_FreeSurface(bg);
bg = NULL;
}
bg = SDL_CreateRGBSurface(SDL_HWSURFACE,sarea.w, sarea.h,
bg = SDL_CreateRGBSurface(SDL_SWSURFACE,sarea.w, sarea.h,
buffer->format->BitsPerPixel, buffer->format->Rmask,
buffer->format->Gmask,buffer->format->Bmask,
buffer->format->Amask);
@ -8062,7 +8062,7 @@ int startlinkpointmove(int x, int y) {
SDL_FreeSurface(bg);
bg = NULL;
}
bg = SDL_CreateRGBSurface(SDL_HWSURFACE, LINESELHANDLESIZE, LINESELHANDLESIZE,
bg = SDL_CreateRGBSurface(SDL_SWSURFACE, LINESELHANDLESIZE, LINESELHANDLESIZE,
screen->format->BitsPerPixel, screen->format->Rmask,
screen->format->Gmask,screen->format->Bmask,
screen->format->Amask);
@ -8165,7 +8165,7 @@ int startobjmove (int x, int y) {
SDL_FreeSurface(bg);
bg = NULL;
}
bg = SDL_CreateRGBSurface(SDL_HWSURFACE,map[curmap].obj[map[curmap].curobj].w,map[curmap].obj[map[curmap].curobj].h,
bg = SDL_CreateRGBSurface(SDL_SWSURFACE,map[curmap].obj[map[curmap].curobj].w,map[curmap].obj[map[curmap].curobj].h,
screen->format->BitsPerPixel, screen->format->Rmask,
screen->format->Gmask,screen->format->Bmask,
screen->format->Amask);
@ -8184,7 +8184,7 @@ int startobjmove (int x, int y) {
SDL_FreeSurface(shadow);
shadow = NULL;
}
shadow = SDL_CreateRGBSurface(SDL_HWSURFACE,map[curmap].obj[map[curmap].curobj].w+3, map[curmap].obj[map[curmap].curobj].h+3,
shadow = SDL_CreateRGBSurface(SDL_SWSURFACE,map[curmap].obj[map[curmap].curobj].w+3, map[curmap].obj[map[curmap].curobj].h+3,
screen->format->BitsPerPixel, screen->format->Rmask,
screen->format->Gmask,screen->format->Bmask,
screen->format->Amask);
@ -8210,7 +8210,7 @@ int startresize (int x, int y) {
SDL_FreeSurface(bg);
bg = NULL;
}
bg = SDL_CreateRGBSurface(SDL_HWSURFACE,MAXOBJWIDTH+2,MAXOBJHEIGHT+2,
bg = SDL_CreateRGBSurface(SDL_SWSURFACE,MAXOBJWIDTH+2,MAXOBJHEIGHT+2,
screen->format->BitsPerPixel, screen->format->Rmask,
screen->format->Gmask,screen->format->Bmask,
screen->format->Amask);
@ -8266,7 +8266,7 @@ int startresizetext(int x, int y) {
SDL_FreeSurface(bg);
bg = NULL;
}
bg = SDL_CreateRGBSurface(SDL_HWSURFACE,map[curmap].width,map[curmap].height,
bg = SDL_CreateRGBSurface(SDL_SWSURFACE,map[curmap].width,map[curmap].height,
screen->format->BitsPerPixel, screen->format->Rmask,
screen->format->Gmask,screen->format->Bmask,
screen->format->Amask);
@ -8326,7 +8326,7 @@ int starttextmove (int x, int y) {
SDL_FreeSurface(bg);
bg = NULL;
}
bg = SDL_CreateRGBSurface(SDL_HWSURFACE,map[curmap].textob[map[curmap].curtext].w,th+5,
bg = SDL_CreateRGBSurface(SDL_SWSURFACE,map[curmap].textob[map[curmap].curtext].w,th+5,
screen->format->BitsPerPixel, screen->format->Rmask,
screen->format->Gmask,screen->format->Bmask,
screen->format->Amask);
@ -8491,7 +8491,7 @@ int updatefilename(void) {
SDL_FreeSurface(bg);
bg = NULL;
}
bg = SDL_CreateRGBSurface(SDL_HWSURFACE,sarea.w, sarea.h,
bg = SDL_CreateRGBSurface(SDL_SWSURFACE,sarea.w, sarea.h,
screen->format->BitsPerPixel, screen->format->Rmask,
screen->format->Gmask,screen->format->Bmask,
screen->format->Amask);
@ -8562,9 +8562,8 @@ int updatelinkshadow(int x, int y) {
h = y - starty;
}
}
//SDL_UpdateRect(screen, tlx, tly ,w,h);
SDL_Flip(screen);
SDL_UpdateRect(screen, tlx, tly ,w,h);
//SDL_Flip(screen);
return 0;
}
@ -8596,7 +8595,7 @@ int updatelinkpointshadow(int x, int y) {
SDL_FreeSurface(bg);
bg = NULL;
}
bg = SDL_CreateRGBSurface(SDL_HWSURFACE, LINESELHANDLESIZE, LINESELHANDLESIZE,
bg = SDL_CreateRGBSurface(SDL_SWSURFACE, LINESELHANDLESIZE, LINESELHANDLESIZE,
screen->format->BitsPerPixel, screen->format->Rmask,
screen->format->Gmask,screen->format->Bmask,
screen->format->Amask);
@ -8891,7 +8890,7 @@ int updatetextcursor(void) {
SDL_FreeSurface(bg);
bg = NULL;
}
bg = SDL_CreateRGBSurface(SDL_HWSURFACE,sarea.w, sarea.h,
bg = SDL_CreateRGBSurface(SDL_SWSURFACE,sarea.w, sarea.h,
screen->format->BitsPerPixel, screen->format->Rmask,
screen->format->Gmask,screen->format->Bmask,
screen->format->Amask);