From 1cb0f0c87b1e85315940ac7db80f83446ec2dbbf Mon Sep 17 00:00:00 2001 From: Howard Su Date: Tue, 19 Feb 2019 15:32:50 +0800 Subject: [PATCH 1/2] combine spin normal/press image --- src/fs/320x240x16/media/spin32.bmp | Bin 1096 -> 2118 bytes src/fs/320x240x16/media/spin64.bmp | Bin 2120 -> 4166 bytes src/fs/320x240x16/media/spin96.bmp | Bin 3144 -> 6214 bytes src/fs/320x240x16/media/spinp32.bmp | Bin 1096 -> 0 bytes src/fs/320x240x16/media/spinp64.bmp | Bin 2120 -> 0 bytes src/fs/320x240x16/media/spinp96.bmp | Bin 3144 -> 0 bytes src/gui/320x240x16/_gui.c | 3 --- src/gui/320x240x16/_gui.h | 3 --- src/gui/320x240x16/_textsel.c | 6 ++++-- src/gui/textsel.c | 8 ++++---- 10 files changed, 8 insertions(+), 12 deletions(-) delete mode 100644 src/fs/320x240x16/media/spinp32.bmp delete mode 100644 src/fs/320x240x16/media/spinp64.bmp delete mode 100644 src/fs/320x240x16/media/spinp96.bmp diff --git a/src/fs/320x240x16/media/spin32.bmp b/src/fs/320x240x16/media/spin32.bmp index 64c1c4204a729b0c938bca34c9bc58eabf8c9914..ac3691775221b39f6ab8f27386df3c119788a846 100644 GIT binary patch literal 2118 zcmZ?rb>mBt08c!TX#fBK delta 52 vcmX>maDqd{$=8F00Sw%Lqy-Qw0I>iNGXhCwAkD-wQ6*(_2g^QYCI$uovfl=Y diff --git a/src/fs/320x240x16/media/spin64.bmp b/src/fs/320x240x16/media/spin64.bmp index df42f0f4946eade432fd438f6a89349269a835d1..fa3cfdc0881eda6d63715d968f7efafd1c168d3d 100644 GIT binary patch literal 4166 zcmeHIu?>Vk3^SsnK`a1cP`)VWej_Aq2uh}6fYa|lapk=OL%4CQB#N%EE{c=oyY_f& zWt{0B`b2Ngqh)5o(7hhzV;k_};}}H(>dq)bu$O#XD#XvvyJQWH%lz)Y=TD=)*gMvr p^>^MXl#HalziNJVKxmK!`|tVFb-?iNGXhCwAkD-vQDw>I6C8EyObiSFzW)ai diff --git a/src/fs/320x240x16/media/spin96.bmp b/src/fs/320x240x16/media/spin96.bmp index 3dede7949195372e84a10c16dbc0640fd871dd7d..e47bfb1e991edcfd9a3d26f49ccc1941d15518dd 100644 GIT binary patch literal 6214 zcmeH}u?fRK3`J#9x-qHJC1bcw;m$i`kU%_yOHbtij_ly#O8d(hL529?OX!Z{(D8W^ zho0kbv(pBwJ>rFUAR6oJg57X`ZGYj%)81xZT;BaKne88}wC?I_nO9bK^2=5Wr_ZbO zXI4)9GwJ)kqyEpVfcR(9SO4eI{~!L##_6@##6CZ>>qiBM&F2SV`MdPzR!{uJKSDtL Y6QLK+75_NH$P3~hp%>5P=g&SrA6HjL+W-In delta 52 vcmX?Ra6&@G$=8F20Sw%Lqy-Qs0I>iNGXhCwAkD-xQRT^I4qiKMCI$uo#3crr diff --git a/src/fs/320x240x16/media/spinp32.bmp b/src/fs/320x240x16/media/spinp32.bmp deleted file mode 100644 index 2c0203c5af913ac3c85011688e825bda4ccc2f1e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1096 zcmZ?r^TQ-|vwJr(7DqwXKbm>UiMfed|6xigyn2Qmgm!+#({e>D9MZ0HZ4 T@SpQ}Xu|LJ7#fCr`type == TEXTSELECT_VERT_64) { GUI_DrawImageHelper(box->x, - box->y + ARROW_HEIGHT, select->button, DRAW_NORMAL); + box->y + ARROW_HEIGHT, select->button, + select->enable & 0x02 ? DRAW_PRESSED : DRAW_NORMAL); if (select->enable & 0x01) { GUI_DrawImageHelper(box->x + (box->width - ARROW_WIDTH) / 2, box->y, ARROW_UP, select->state & 0x02 ? DRAW_PRESSED : DRAW_NORMAL); @@ -36,7 +37,8 @@ void _DrawTextSelectHelper(struct guiTextSelect *select, const char *str) #endif { GUI_DrawImageHelper(box->x + ARROW_WIDTH, - box->y, select->button, DRAW_NORMAL); + box->y, select->button, + select->enable & 0x02 ? DRAW_PRESSED : DRAW_NORMAL); if (select->enable & 0x01) { GUI_DrawImageHelper(box->x, box->y, ARROW_LEFT, select->state & 0x01 ? DRAW_PRESSED : DRAW_NORMAL); diff --git a/src/gui/textsel.c b/src/gui/textsel.c index a9d314372f..bfb42ea3e8 100644 --- a/src/gui/textsel.c +++ b/src/gui/textsel.c @@ -283,10 +283,10 @@ void GUI_TextSelectEnablePress(guiTextSelect_t *select, u8 enable) } enum ImageNames fileidx; switch (select->type) { - case TEXTSELECT_224: fileidx = FILE_SPIN192; /* enable ? FILE_SPIN192 : FILE_SPIN192;*/ break; - case TEXTSELECT_128: fileidx = enable ? FILE_SPINPRESS96 : FILE_SPIN96; break; - case TEXTSELECT_96: fileidx = enable ? FILE_SPINPRESS64 : FILE_SPIN64; break; - case TEXTSELECT_64: fileidx = enable ? FILE_SPINPRESS32 : FILE_SPIN32; break; + case TEXTSELECT_224: fileidx = FILE_SPIN192; break; + case TEXTSELECT_128: fileidx = FILE_SPIN96; break; + case TEXTSELECT_96: fileidx = FILE_SPIN64; break; + case TEXTSELECT_64: fileidx = FILE_SPIN32; break; default: fileidx = FILE_SPIN32; break; } if (select->button != &image_map[fileidx]) { From 31800295020c6bc70c0f71dc5603ce4dd374855a Mon Sep 17 00:00:00 2001 From: Howard Su Date: Thu, 21 Feb 2019 20:21:17 +0800 Subject: [PATCH 2/2] Use code to draw button and textsel --- src/gui/320x240x16/_gui.c | 19 +++++++ src/gui/gui.c | 103 +++++++++++++++++++++++++++++++++++++- 2 files changed, 121 insertions(+), 1 deletion(-) diff --git a/src/gui/320x240x16/_gui.c b/src/gui/320x240x16/_gui.c index ffbe701227..0271404c13 100644 --- a/src/gui/320x240x16/_gui.c +++ b/src/gui/320x240x16/_gui.c @@ -13,6 +13,7 @@ along with Deviation. If not, see . */ +#if 0 const struct ImageMap image_map[] = { {"media/btn96_24" IMG_EXT, 96, 24, 0, 0}, /*FILE_BTN96_24 */ {"media/btn48_24" IMG_EXT, 48, 24, 0, 0}, /*FILE_BTN48_24 */ @@ -29,6 +30,24 @@ const struct ImageMap image_map[] = { {"media/arrows16" IMG_EXT, 16, 16, 32, 0}, /*FILE_ARROW_16_RIGHT */ {"media/arrows16" IMG_EXT, 16, 16, 48, 0}, /*FILE_ARROW_16_LEFT */ }; +#else +const struct ImageMap image_map[] = { + {NULL, 96, 24, 0, 0}, /*FILE_BTN96_24 */ + {NULL, 48, 24, 0, 0}, /*FILE_BTN48_24 */ + {NULL, 96, 16, 0, 0}, /*FILE_BTN96_16 */ + {NULL, 64, 16, 0, 0}, /*FILE_BTN64_16 */ + {NULL, 48, 16, 0, 0}, /*FILE_BTN48_16 */ + {NULL, 32, 16, 0, 0}, /*FILE_BTN32_16 */ + {NULL,192, 16, 1, 0}, /*FILE_SPIN192 */ + {NULL, 96, 16, 1, 0}, /*FILE_SPIN96 */ + {NULL, 64, 16, 1, 0}, /*FILE_SPIN64 */ + {NULL, 32, 16, 1, 0}, /*FILE_SPIN32 */ + {NULL, 16, 16, 2, 1}, /*FILE_ARROW_16_UP */ + {NULL, 16, 16, 2, 2}, /*FILE_ARROW_16_DOWN */ + {NULL, 16, 16, 2, 3}, /*FILE_ARROW_16_RIGHT */ + {NULL, 16, 16, 2, 4}, /*FILE_ARROW_16_LEFT */ +}; +#endif void _gui_hilite_selected(struct guiObject *obj) { diff --git a/src/gui/gui.c b/src/gui/gui.c index b22fce7c64..43bc7e3ab1 100644 --- a/src/gui/gui.c +++ b/src/gui/gui.c @@ -801,9 +801,110 @@ u8 GUI_ObjectNeedsRedraw(guiObject_t *obj) return OBJ_IS_DIRTY(obj); } +static void _DrawButtonBackground(u16 x, u16 y, const struct ImageMap *map, u8 idx) +{ + // determine size + + // draw border + LCD_DrawFastHLine(x + 1, y, map->width - 2, 0); + LCD_DrawFastHLine(x + 1, y + map->height - 1, map->width - 2, 0); + LCD_DrawFastVLine(x, y + 1, map->height - 2, 0); + LCD_DrawFastVLine(x + map->width - 1, y + 1, map->height - 2, 0); + + // draw up/down effect + u16 fillcolor = 0; + u16 uppercolor = 0; + u16 bottomcolor = 0; + + switch(map->x_off) { + case 0: + case 2: + { + // this is a button + if (idx) { + fillcolor = 0xffff; + uppercolor = 0xa534; + bottomcolor = 0xe73c; + } else { + fillcolor = 0xbdf7; + uppercolor = 0xe73c; + bottomcolor = 0xa534; + } + } + break; + + case 1: + { + // this is textself + if (!idx) { + fillcolor = 0xffff; + } else { + fillcolor = 0xbdf7; + } + } + break; + } + + if (map->x_off != 1) { + LCD_DrawFastHLine(x + 1, y + 1, map->width - 3, uppercolor); + LCD_DrawFastVLine(x + 1, y + 1, map->height - 3, uppercolor); + + LCD_DrawFastHLine(x + 2, y + map->height - 2, map->width - 3, bottomcolor); + LCD_DrawFastVLine(x + map->width - 2, y + 2, map->height - 3, bottomcolor); + + LCD_DrawPixelXY(x + 1, y + map->height - 2, 0xbdf7); + LCD_DrawPixelXY(x + map->width - 2, y + 1, 0xbdf7); + + LCD_FillRect(x + 2, y + 2, map->width - 4, map->height - 4, fillcolor); + } + else + { + LCD_FillRect(x + 1, y + 1, map->width - 2, map->height - 2, fillcolor); + } + + if (map->x_off != 2) + return; + + u16 color = idx ? 0xf800 : 0x0000; + u16 x_start, y_start, x_end, y_end; + u16 size = map->height - 1; + + // up coordinates + x_start = size / 4; + y_start = size / 3 * 2 - 1; + x_end = size / 2; + y_end = size / 3; + + // draw additional arrows + switch(map->y_off) + { + case 1: + LCD_DrawLine(x + x_start, y + y_start, x + x_end, y + y_end, color); + LCD_DrawLine(x + x_end + 1, y + y_end, x + size - x_start, y + y_start, color); + break; + case 2: + LCD_DrawLine(x + x_start, y + size - y_start, x + x_end, y + size - y_end, color); + LCD_DrawLine(x + x_end + 1, y + size - y_end, x + size - x_start, y + size - y_start, color); + break; + case 3: + LCD_DrawLine(x + size - y_start, y + x_start, x + size - y_end, y + x_end, color); + LCD_DrawLine(x + size - y_end, y + x_end + 1, x + size - y_start, y + size - x_start, color); + break; + case 4: + LCD_DrawLine(x + y_start, y + x_start, x + y_end, y + x_end, color); + LCD_DrawLine(x + y_end, y + x_end + 1, x + y_start, y + size - x_start, color); + break; + default: + return; + } +} + void GUI_DrawImageHelper(u16 x, u16 y, const struct ImageMap *map, u8 idx) { - LCD_DrawWindowedImageFromFile(x, y, map->file, map->width, map->height, + if (map->file == NULL) + _DrawButtonBackground(x, y, map, idx); + else + LCD_DrawWindowedImageFromFile(x, y, map->file, map->width, map->height, map->x_off, map->y_off + idx * map->height); }