1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-20 04:48:06 +01:00

Better outline when drawing balloons

This commit is contained in:
dan
2002-11-01 13:28:59 +00:00
parent 6724ec5a6d
commit a4bc7f6a07
5 changed files with 173 additions and 64 deletions

View File

@@ -27,6 +27,7 @@ Changes since version 0.80.1:
- Removed double no-position-display when cycling position display types - Removed double no-position-display when cycling position display types
with Shift key while moving windows. with Shift key while moving windows.
- Changed the default position display while moving a window to 'Center'. - Changed the default position display while moving a window to 'Center'.
- Better outline when drawing balloons.
Changes since version 0.80.0: Changes since version 0.80.0:

View File

@@ -25,6 +25,7 @@ Changes since wmaker 0.80.1:
- Added new Bool WMIsAAFont(WMFont *font) to check if a font is AA or not. - Added new Bool WMIsAAFont(WMFont *font) to check if a font is AA or not.
- Added WMGetColorAlpha(WMColor *color) - Added WMGetColorAlpha(WMColor *color)
- Added WMCreateNonAAFont() - Added WMCreateNonAAFont()
- Better outline when drawing balloons.
Changes since wmaker 0.80.0: Changes since wmaker 0.80.0:

View File

@@ -19,11 +19,13 @@
#endif #endif
#if (!defined (__GNUC__) || __GNUC__ < 2 || \ #ifndef __ASSERT_FUNCTION
__GNUC_MINOR__ < (defined (__cplusplus) ? 6 : 4)) # if (!defined (__GNUC__) || (__GNUC__ < 2 && \
#define __ASSERT_FUNCTION ((char *) 0) __GNUC_MINOR__ < (defined (__cplusplus) ? 6 : 4)))
#else # define __ASSERT_FUNCTION ((char *) 0)
#define __ASSERT_FUNCTION __PRETTY_FUNCTION__ # else
# define __ASSERT_FUNCTION __PRETTY_FUNCTION__
# endif
#endif #endif

View File

@@ -275,40 +275,97 @@ W_BalloonHandleEnterView(WMView *view)
static void static void
drawBalloon(Display *dpy, Pixmap pix, GC gc, int x, int y, int w, int h, drawBalloon(WMScreen *scr, Pixmap bitmap, Pixmap pix, int x, int y, int w,
int side) int h, int side)
{ {
Display *dpy = scr->display;
WMColor *white = WMWhiteColor(scr);
WMColor *black = WMBlackColor(scr);
GC bgc = scr->monoGC;
GC gc = WMColorGC(white);
int rad = h*3/10; int rad = h*3/10;
XPoint pt[3]; XPoint pt[3], ipt[3];
int w1;
XFillArc(dpy, pix, gc, x, y, rad, rad, 90*64, 90*64); /* outline */
XFillArc(dpy, pix, gc, x, y+h-1-rad, rad, rad, 180*64, 90*64); XSetForeground(dpy, bgc, 1);
XFillArc(dpy, pix, gc, x+w-1-rad, y, rad, rad, 0*64, 90*64); XFillArc(dpy, bitmap, bgc, x, y, rad, rad, 90*64, 90*64);
XFillArc(dpy, pix, gc, x+w-1-rad, y+h-1-rad, rad, rad, 270*64, 90*64); XFillArc(dpy, bitmap, bgc, x, y+h-1-rad, rad, rad, 180*64, 90*64);
XFillRectangle(dpy, pix, gc, x, y+rad/2, w, h-rad); XFillArc(dpy, bitmap, bgc, x+w-1-rad, y, rad, rad, 0*64, 90*64);
XFillRectangle(dpy, pix, gc, x+rad/2, y, w-rad, h); XFillArc(dpy, bitmap, bgc, x+w-1-rad, y+h-1-rad, rad, rad, 270*64, 90*64);
XFillRectangle(dpy, bitmap, bgc, x, y+rad/2, w, h-rad);
XFillRectangle(dpy, bitmap, bgc, x+rad/2, y, w-rad, h);
/* interior */
XFillArc(dpy, pix, gc, x+1, y+1, rad, rad, 90*64, 90*64);
XFillArc(dpy, pix, gc, x+1, y+h-2-rad, rad, rad, 180*64, 90*64);
XFillArc(dpy, pix, gc, x+w-2-rad, y+1, rad, rad, 0*64, 90*64);
XFillArc(dpy, pix, gc, x+w-2-rad, y+h-2-rad, rad, rad, 270*64, 90*64);
XFillRectangle(dpy, pix, gc, x+1, y+1+rad/2, w-2, h-2-rad);
XFillRectangle(dpy, pix, gc, x+1+rad/2, y+1, w-2-rad, h-2);
if (side & BOTTOM) { if (side & BOTTOM) {
pt[0].y = y+h-1; pt[0].y = y+h-1;
pt[1].y = y+h-1+SPACE; pt[1].y = y+h-1+SPACE;
pt[2].y = y+h-1; pt[2].y = y+h-1;
ipt[0].y = pt[0].y-1;
ipt[1].y = pt[1].y-1;
ipt[2].y = pt[2].y-1;
} else { } else {
pt[0].y = y; pt[0].y = y;
pt[1].y = y-SPACE; pt[1].y = y-SPACE;
pt[2].y = y; pt[2].y = y;
ipt[0].y = pt[0].y+1;
ipt[1].y = pt[1].y+1;
ipt[2].y = pt[2].y+1;
} }
/*w1 = WMAX(h, 24);*/
w1 = WMAX(h, 21);
if (side & RIGHT) { if (side & RIGHT) {
pt[0].x = x+w-h+2*h/16; pt[0].x = x+w-w1+2*w1/16;
pt[1].x = x+w-h+11*h/16; pt[1].x = x+w-w1+11*w1/16;
pt[2].x = x+w-h+7*h/16; pt[2].x = x+w-w1+7*w1/16;
ipt[0].x = x+1+w-w1+2*(w1-1)/16;
ipt[1].x = x+1+w-w1+11*(w1-1)/16;
ipt[2].x = x+1+w-w1+7*(w1-1)/16;
/*ipt[0].x = pt[0].x+1;
ipt[1].x = pt[1].x;
ipt[2].x = pt[2].x;*/
} else { } else {
pt[0].x = x+h-2*h/16; pt[0].x = x+w1-2*w1/16;
pt[1].x = x+h-11*h/16; pt[1].x = x+w1-11*w1/16;
pt[2].x = x+h-7*h/16; pt[2].x = x+w1-7*w1/16;
ipt[0].x = x-1+w1-2*(w1-1)/16;
ipt[1].x = x-1+w1-11*(w1-1)/16;
ipt[2].x = x-1+w1-7*(w1-1)/16;
/*ipt[0].x = pt[0].x-1;
ipt[1].x = pt[1].x;
ipt[2].x = pt[2].x;*/
} }
XFillPolygon(dpy, pix, gc, pt, 3, Convex, CoordModeOrigin);
XFillPolygon(dpy, bitmap, bgc, pt, 3, Convex, CoordModeOrigin);
XFillPolygon(dpy, pix, gc, ipt, 3, Convex, CoordModeOrigin);
/* fix outline */
XDrawLines(dpy, pix, WMColorGC(black), pt, 3, CoordModeOrigin);
if (side & RIGHT) {
pt[0].x++;
pt[2].x--;
} else {
pt[0].x--;
pt[2].x++;
}
XDrawLines(dpy, pix, WMColorGC(black), pt, 3, CoordModeOrigin);
WMReleaseColor(white);
WMReleaseColor(black);
} }
@@ -320,7 +377,6 @@ makePixmap(WMScreen *scr, int width, int height, int side, Pixmap *mask)
Pixmap pixmap; Pixmap pixmap;
int x, y; int x, y;
WMColor *black = WMBlackColor(scr); WMColor *black = WMBlackColor(scr);
WMColor *white = WMWhiteColor(scr);
bitmap = XCreatePixmap(dpy, scr->rootWin, width+SPACE, height+SPACE, 1); bitmap = XCreatePixmap(dpy, scr->rootWin, width+SPACE, height+SPACE, 1);
@@ -330,8 +386,8 @@ makePixmap(WMScreen *scr, int width, int height, int side, Pixmap *mask)
pixmap = XCreatePixmap(dpy, scr->rootWin, width+SPACE, height+SPACE, pixmap = XCreatePixmap(dpy, scr->rootWin, width+SPACE, height+SPACE,
scr->depth); scr->depth);
XFillRectangle(dpy, pixmap, WMColorGC(black), 0, 0, XFillRectangle(dpy, pixmap, WMColorGC(black), 0, 0, width+SPACE,
width+SPACE, height+SPACE); height+SPACE);
if (side & BOTTOM) { if (side & BOTTOM) {
y = 0; y = 0;
@@ -340,22 +396,18 @@ makePixmap(WMScreen *scr, int width, int height, int side, Pixmap *mask)
} }
x = 0; x = 0;
XSetForeground(dpy, scr->monoGC, 1); drawBalloon(scr, bitmap, pixmap, x, y, width, height, side);
drawBalloon(dpy, bitmap, scr->monoGC, x, y, width, height, side);
drawBalloon(dpy, pixmap, WMColorGC(white), x+1, y+1, width-2, height-2,
side);
*mask = bitmap; *mask = bitmap;
WMReleaseColor(black); WMReleaseColor(black);
WMReleaseColor(white);
return pixmap; return pixmap;
} }
static void static void
showText(Balloon *bPtr, int x, int y, int h, int w, char *text) showText(Balloon *bPtr, int x, int y, int w, int h, char *text)
{ {
WMScreen *scr = bPtr->view->screen; WMScreen *scr = bPtr->view->screen;
Display *dpy = WMScreenDisplay(scr); Display *dpy = WMScreenDisplay(scr);

View File

@@ -89,39 +89,95 @@ typedef struct _WBalloon {
static void static void
drawBalloon(Pixmap pix, GC gc, int x, int y, int w, int h, int side) drawBalloon(WScreen *scr, Pixmap bitmap, Pixmap pix, int x, int y, int w,
int h, int side)
{ {
GC bgc = scr->balloon->monoGC;
GC gc = scr->draw_gc;
int rad = h*3/10; int rad = h*3/10;
XPoint pt[3]; XPoint pt[3], ipt[3];
int w1;
XFillArc(dpy, pix, gc, x, y, rad, rad, 90*64, 90*64); /* outline */
XFillArc(dpy, pix, gc, x, y+h-1-rad, rad, rad, 180*64, 90*64); XSetForeground(dpy, bgc, 1);
XFillArc(dpy, pix, gc, x+w-1-rad, y, rad, rad, 0*64, 90*64); XFillArc(dpy, bitmap, bgc, x, y, rad, rad, 90*64, 90*64);
XFillArc(dpy, pix, gc, x+w-1-rad, y+h-1-rad, rad, rad, 270*64, 90*64); XFillArc(dpy, bitmap, bgc, x, y+h-1-rad, rad, rad, 180*64, 90*64);
XFillRectangle(dpy, pix, gc, x, y+rad/2, w, h-rad); XFillArc(dpy, bitmap, bgc, x+w-1-rad, y, rad, rad, 0*64, 90*64);
XFillRectangle(dpy, pix, gc, x+rad/2, y, w-rad, h); XFillArc(dpy, bitmap, bgc, x+w-1-rad, y+h-1-rad, rad, rad, 270*64, 90*64);
XFillRectangle(dpy, bitmap, bgc, x, y+rad/2, w, h-rad);
XFillRectangle(dpy, bitmap, bgc, x+rad/2, y, w-rad, h);
/* interior */
XSetForeground(dpy, gc, scr->white_pixel);
XFillArc(dpy, pix, gc, x+1, y+1, rad, rad, 90*64, 90*64);
XFillArc(dpy, pix, gc, x+1, y+h-2-rad, rad, rad, 180*64, 90*64);
XFillArc(dpy, pix, gc, x+w-2-rad, y+1, rad, rad, 0*64, 90*64);
XFillArc(dpy, pix, gc, x+w-2-rad, y+h-2-rad, rad, rad, 270*64, 90*64);
XFillRectangle(dpy, pix, gc, x+1, y+1+rad/2, w-2, h-2-rad);
XFillRectangle(dpy, pix, gc, x+1+rad/2, y+1, w-2-rad, h-2);
if (side & BOTTOM) { if (side & BOTTOM) {
pt[0].y = y+h-1; pt[0].y = y+h-1;
pt[1].y = y+h-1+SPACE; pt[1].y = y+h-1+SPACE;
pt[2].y = y+h-1; pt[2].y = y+h-1;
ipt[0].y = pt[0].y-1;
ipt[1].y = pt[1].y-1;
ipt[2].y = pt[2].y-1;
} else { } else {
pt[0].y = y; pt[0].y = y;
pt[1].y = y-SPACE; pt[1].y = y-SPACE;
pt[2].y = y; pt[2].y = y;
ipt[0].y = pt[0].y+1;
ipt[1].y = pt[1].y+1;
ipt[2].y = pt[2].y+1;
} }
/*w1 = WMAX(h, 24);*/
w1 = WMAX(h, 21);
if (side & RIGHT) { if (side & RIGHT) {
pt[0].x = x+w-h+2*h/16; pt[0].x = x+w-w1+2*w1/16;
pt[1].x = x+w-h+11*h/16; pt[1].x = x+w-w1+11*w1/16;
pt[2].x = x+w-h+7*h/16; pt[2].x = x+w-w1+7*w1/16;
ipt[0].x = x+1+w-w1+2*(w1-1)/16;
ipt[1].x = x+1+w-w1+11*(w1-1)/16;
ipt[2].x = x+1+w-w1+7*(w1-1)/16;
/*ipt[0].x = pt[0].x+1;
ipt[1].x = pt[1].x;
ipt[2].x = pt[2].x;*/
} else { } else {
pt[0].x = x+h-2*h/16; pt[0].x = x+w1-2*w1/16;
pt[1].x = x+h-11*h/16; pt[1].x = x+w1-11*w1/16;
pt[2].x = x+h-7*h/16; pt[2].x = x+w1-7*w1/16;
ipt[0].x = x-1+w1-2*(w1-1)/16;
ipt[1].x = x-1+w1-11*(w1-1)/16;
ipt[2].x = x-1+w1-7*(w1-1)/16;
/*ipt[0].x = pt[0].x-1;
ipt[1].x = pt[1].x;
ipt[2].x = pt[2].x;*/
} }
XFillPolygon(dpy, pix, gc, pt, 3, Convex, CoordModeOrigin);
XFillPolygon(dpy, bitmap, bgc, pt, 3, Convex, CoordModeOrigin);
XFillPolygon(dpy, pix, gc, ipt, 3, Convex, CoordModeOrigin);
/* fix outline */
XSetForeground(dpy, gc, scr->black_pixel);
XDrawLines(dpy, pix, gc, pt, 3, CoordModeOrigin);
if (side & RIGHT) {
pt[0].x++;
pt[2].x--;
} else {
pt[0].x--;
pt[2].x++;
}
XDrawLines(dpy, pix, gc, pt, 3, CoordModeOrigin);
} }
@@ -153,10 +209,7 @@ makePixmap(WScreen *scr, int width, int height, int side, Pixmap *mask)
} }
x = 0; x = 0;
XSetForeground(dpy, bal->monoGC, 1); drawBalloon(scr, bitmap, pixmap, x, y, width, height, side);
drawBalloon(bitmap, bal->monoGC, x, y, width, height, side);
XSetForeground(dpy, scr->draw_gc, scr->white_pixel);
drawBalloon(pixmap, scr->draw_gc, x+1, y+1, width-2, height-2, side);
*mask = bitmap; *mask = bitmap;