From b892189f8bc7f503e2e3baa433785cd6c9ebe725 Mon Sep 17 00:00:00 2001 From: kichikuou Date: Sat, 3 Oct 2020 22:35:22 +0900 Subject: [PATCH] Fix selection menu painting The new behavior matches System 3.9. - Use sel.WinFrameColor to draw selection cursor in EncloseType=0 - Implement EncloseType=1 (thick selection cursor) - It always uses color 255, not WinFrameColor (System 3.9 bug?) - EncloseType=2 uses MsgFontColor for background, WinBackgroundColor for text --- src/ags.c | 6 ------ src/ags.h | 1 - src/image.c | 23 ----------------------- src/image.h | 2 -- src/selection.c | 19 +++++++++++-------- 5 files changed, 11 insertions(+), 40 deletions(-) diff --git a/src/ags.c b/src/ags.c index cc8356e..69e113d 100644 --- a/src/ags.c +++ b/src/ags.c @@ -847,12 +847,6 @@ agsurface_t *ags_getDIB() { return nact->ags.dib; } -void ags_fillRectangleNeg(int x, int y, int w, int h, int col) { - if (!check_param(&x, &y, &w, &h)) return; - - image_fillRectangleNeg(nact->ags.dib, x, y, w, h, col); -} - void ags_autorepeat(boolean bool) { sdl_setAutoRepeat(bool); } diff --git a/src/ags.h b/src/ags.h index 7c614db..4798b08 100644 --- a/src/ags.h +++ b/src/ags.h @@ -165,7 +165,6 @@ extern void ags_setPaletteToSystem(int src, int cnt); /* 描画関係 */ extern void ags_drawRectangle(int x, int y, int w, int h, int col); extern void ags_fillRectangle(int x, int y, int w, int h, int col); -extern void ags_fillRectangleNeg(int x, int y, int w, int h, int col); extern void ags_drawLine(int x0, int y0, int x1, int y1, int col); extern void ags_copyArea(int sx, int sy, int w, int h, int dx, int dy); extern void ags_scaledCopyArea(int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, int mirror_sw); diff --git a/src/image.c b/src/image.c index 768c253..3ffa04a 100644 --- a/src/image.c +++ b/src/image.c @@ -887,10 +887,6 @@ void image_fillRectangle(agsurface_t *dib, int x, int y, int w, int h, int col) fill_rectangle(dib, x, y, w, h, col); } -void image_fillRectangleNeg(agsurface_t *dib, int x, int y, int w, int h, int col) { - fill_rectangle(dib, x, y, w, h, -1 ^ image_index2pixel(dib->depth, col)); -} - void image_copy_from_alpha(agsurface_t *dib, int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_COPY_TYPE flag) { BYTE *sdata = GETOFFSET_ALPHA(dib, sx, sy); BYTE *ddata = GETOFFSET_PIXEL(dib, dx, dy); @@ -905,25 +901,6 @@ void image_copy_to_alpha(agsurface_t *dib, int sx, int sy, int w, int h, int dx, copy_to_alpha(dib, sdata, ddata, w, h, flag); } -int image_index2pixel(int depth, int i) { - Palette256 *pal = nact->sys_pal; - - switch(depth) { - case 8: - return i; - case 15: - return PIX15(pal->red[i], pal->green[i], pal->blue[i]); - case 16: - return PIX16(pal->red[i], pal->green[i], pal->blue[i]); - case 24: - case 32: - return PIX24(pal->red[i], pal->green[i], pal->blue[i]); - default: - WARNING("Unknown depth\n"); - return i; - } -} - /* モザイク */ void image_Mosaic(agsurface_t *dib, int sx, int sy, int w, int h, int dx, int dy, int slice) { diff --git a/src/image.h b/src/image.h index 3e88ea6..f66ce5d 100644 --- a/src/image.h +++ b/src/image.h @@ -32,10 +32,8 @@ extern void image_fadeOut(agsurface_t *img, int lv, int col); extern void image_fadeIn(agsurface_t *src, agsurface_t *dst, int lv); extern void image_drawLine(agsurface_t *dib, int x0, int y0, int x1, int y1, int col); extern void image_fillRectangle(agsurface_t *dib, int x, int y, int w, int h, int col); -extern void image_fillRectangleNeg(agsurface_t *dib, int x, int y, int w, int h, int col); extern void image_copy_from_alpha(agsurface_t *dib, int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_COPY_TYPE flag); extern void image_copy_to_alpha(agsurface_t *dib, int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_COPY_TYPE flag); -extern int image_index2pixel(int depth, int pal); extern void image_Mosaic(agsurface_t *dib, int sx, int sy, int w, int h, int dx, int dy, int slice); extern BYTE *changeImage16AlphaLevel(cgdata *cg); diff --git a/src/selection.c b/src/selection.c index 5a2d814..c4fc463 100644 --- a/src/selection.c +++ b/src/selection.c @@ -340,10 +340,11 @@ static int whereElement(void) { return -1; } -static void lineEncloseElement(MyRectangle *r, int col) { - ags_drawRectangle(r->x , r->y , r->width +2, r->height +2, col); - ags_drawRectangle(r->x +1, r->y+1, r->width , r->height , col); - ags_updateArea (r->x , r->y , r->width +2, r->height +2); +static void lineEncloseElement(MyRectangle *r, int col, boolean thick) { + ags_drawRectangle(r->x, r->y, r->width + 2, r->height + 2, col); + if (thick) + ags_drawRectangle(r->x + 1, r->y + 1, r->width, r->height, col); + ags_updateArea(r->x, r->y, r->width + 2, r->height + 2); } static void encloseElement(int sw, int no) { @@ -357,8 +358,9 @@ static void encloseElement(int sw, int no) { } else { switch(sel.EncloseType) { case 0: - lineEncloseElement(r, sel.WinBackgroundColor); break; + lineEncloseElement(r, sel.WinBackgroundColor, TRUE); break; case 1: + lineEncloseElement(r, sel.WinBackgroundColor, FALSE); break; case 2: ags_fillRectangle(r->x, r->y, r->width +2, r->height +2, sel.WinBackgroundColor); ags_drawString(r->x +2, r->y +2, elm[no], sel.MsgFontColor); @@ -375,11 +377,12 @@ static void encloseElement(int sw, int no) { } switch(sel.EncloseType) { case 0: - lineEncloseElement(r, sel.MsgFontColor); break; + lineEncloseElement(r, sel.WinFrameColor, TRUE); break; case 1: + lineEncloseElement(r, 255, FALSE); break; case 2: - ags_fillRectangleNeg(r->x, r->y, r->width +2, r->height +2, sel.SelectedElementColor); - ags_drawString(r->x +2, r->y +2, elm[no], sel.SelectedElementColor); + ags_fillRectangle(r->x, r->y, r->width +2, r->height +2, sel.MsgFontColor); + ags_drawString(r->x +2, r->y +2, elm[no], sel.WinBackgroundColor); ags_updateArea(r->x, r->y, r->width +2, r->height +2); break; default: