From 1dbe751b4ee1cb883eab28a2c306461f9af6d104 Mon Sep 17 00:00:00 2001 From: Pere Pujal i Carabantes Date: Mon, 31 Mar 2014 13:50:23 +0000 Subject: [PATCH] Using PNGs as symbols in some onscreen keyboard keys. --- data/images/ui/osk_capslock.png | Bin 0 -> 371 bytes data/images/ui/osk_delete.png | Bin 0 -> 344 bytes data/images/ui/osk_enter.png | Bin 0 -> 444 bytes data/images/ui/osk_shift.png | Bin 0 -> 367 bytes data/images/ui/osk_tab.png | Bin 0 -> 479 bytes osk/abc.h_layout | 27 ++++++++++++++---------- osk/qwerty.h_layout | 12 +++++------ src/onscreen_keyboard.c | 36 +++++++++++++++++++++++++++++--- src/onscreen_keyboard.h | 7 ++++++- src/tuxpaint.c | 23 ++++++++++++++++++-- 10 files changed, 82 insertions(+), 23 deletions(-) create mode 100644 data/images/ui/osk_capslock.png create mode 100644 data/images/ui/osk_delete.png create mode 100644 data/images/ui/osk_enter.png create mode 100644 data/images/ui/osk_shift.png create mode 100644 data/images/ui/osk_tab.png diff --git a/data/images/ui/osk_capslock.png b/data/images/ui/osk_capslock.png new file mode 100644 index 0000000000000000000000000000000000000000..c571dd2d710b43de342d109ac11cf4a819ce0a0d GIT binary patch literal 371 zcmV-(0gV2MP)Way9AfGNJHtL6xBy7Y9_9*DH4u}QRcbB$>nL@c*p3|wCyHh)fphw72KI*ld*y$h zmKr+`z=svEs`hQk6veK|kPzMh@16xolAL4Y*bpx)?iAj57gb&_C8^j;IUc)JUzV4T zW*jM`*uop|q&#-O?Ne#t5m+ei`rl8`Mn^LA4GRBd!8NO-?+qgGlc?N9sc-N2tHKql z;3ySag{zi&60K4&szjSN7;i1=^OYO)Tw!Vv=qo}pHUsRz55PC@1v~?5(sHCem+{MZ;uXe`lZq$<7yWF1w&<%h%Kq2(W_W zoVo)WAjBDT*BBB&HQbL?&hj3Jy11jQ#L!!IwdqdEhkOF&z^w577gDjDQ?Z_+|HW8} z0^0%#Y^$@ZO;g|sj1Ab2rNr|kur~BSTJ}H!?0~6(2Nu?qEHy literal 0 HcmV?d00001 diff --git a/data/images/ui/osk_enter.png b/data/images/ui/osk_enter.png new file mode 100644 index 0000000000000000000000000000000000000000..f15ede2258e0de6895080902f24fd724b0deafb5 GIT binary patch literal 444 zcmV;t0YmG@&!;OeahN`Bxo6|5blIx(Z4l z&N+3?dn}C)rAmQ)_eZuY<57Ou6xgP~i|4{RD}zs@1(N)usNtayd4N}!ND9n1z=p@_ z8L;VdCu>4OE3lf}q-b~iN5G1K8#wU5LM598sMn2FMb`i~N@ mNQiV!RZSs6k1^~TvG@lK6I05R-!*Ii0000I6kOZ{!NI{r#kfQ$#nfE2wx#_b1d_Y&lKYo{2Mn;aGdi}RfW4jl zaD34usm{JM=G~%p2=9P3rGjzY!6iJADh;JxD&8U92!y2fg!4Y8nDz+Wi!8FvUZ%*1 z45-8ifHn|1_Nh*kD-9!6P#MY9uMHUB@g_08s)J-3n*%djY~C)@0)KCS6>ydGQc0op zfNo5u9EDbW0}Tp?%8}dr!S+_Ku9ska9kw6`OSij{3Yb%>^3N9Z&VxL|1~H+-Cp) N002ovPDHLkV1i)vnIQlG literal 0 HcmV?d00001 diff --git a/data/images/ui/osk_tab.png b/data/images/ui/osk_tab.png new file mode 100644 index 0000000000000000000000000000000000000000..0f6a10fdc747319379518dee477b6e1be87c3413 GIT binary patch literal 479 zcmV<50U-W~P)|FF-R?qM@8p1g(c65U?%77gMRmU{pb zJqe6}OP~YvEZkAzz$f~9tmE~8ePCO8jc=26;|+M!(?{1iHWf8zq|otRfL-0xqYHq0 z+WP|Dt?i*_iA@PNFH>QePm3h@M{0UZ61am)q)A;)Yp$kJwe6+hjuRTFt__a)$2SF9 VXG8J#{W|~v002ovPDHLkV1l^4!Fd1x literal 0 HcmV?d00001 diff --git a/osk/abc.h_layout b/osk/abc.h_layout index f024bab99..4cbb9ad87 100644 --- a/osk/abc.h_layout +++ b/osk/abc.h_layout @@ -14,12 +14,14 @@ WIDTH 15 HEIGHT 5 -#FONTPATH FreeMonoBold.ttf +FONTPATH FreeMonoBold.ttf # For the purpose of osk should be: # KEY keycode width label_plain label_top label_altgr label_shift_altgr shiftcaps # shiftcaps means if the value of the key should be shifted if capslock is active +# DELETE TAB ENTER CAPSLOCK and SHIFT will be replaced by corresponding images +# SPACE will be replaced by blank # KEY 49 1.0 ` ~ ` ~ 0 @@ -35,15 +37,15 @@ KEY 18 1.0 9 ( ‘ ˘ 0 KEY 19 1.0 0 ) ’ ° 0 KEY 20 1.0 - _ ¥ ̣ 0 KEY 21 1.0 = + × ÷ 0 -KEY 22 2.0 Back Back Back Back 0 - - +#KEY 22 2.0 <--- <--- <--- <--- 0 +KEY 22 2.0 DELETE DELETE DELETE DELETE 0 NEWLINE # Tab -KEY 23 1.5 |<->| |<->| |<->| |<->| 0 +KEY 23 1.5 TAB TAB TAB TAB 0 +# |<->| |<->| |<->| |<->| 0 # Some tests to see how fonts works #KEY 38 1.0 耳 NULL NULL @@ -71,7 +73,8 @@ KEY 51 1.5 \ | ¬ ¦ 0 NEWLINE # CAPSLOCK -KEY 66 2.0 Caps Caps Caps Caps 0 +KEY 66 2.0 CAPSLOCK CAPSLOCK CAPSLOCK CAPSLOCK 0 +# ↥ ↥ ↥ ↥ 0 KEY 45 1.0 k K œ Œ 1 KEY 46 1.0 l L ø Ø 1 KEY 58 1.0 m M µ µ 1 @@ -85,12 +88,13 @@ KEY 47 1.0 ; : ¶ ° 0 KEY 48 1.0 ´ ¨ ' " 0 # Return -KEY 36 2.0 Enter Enter Enter Enter 0 - - +KEY 36 2.0 ENTER ENTER ENTER ENTER 0 +#KEY 36 2.0 ↵ ↵ ↵ ↵ 0 +#KEY 36 2.0 ⤶ ⤶ ⤶ ⤶ 0 NEWLINE -KEY 50 2.5 Shift Shift Shift Shift 0 +KEY 50 2.5 SHIFT SHIFT SHIFT SHIFT 0 +# __↑__ __↑__ __↑__ __↑__ 0 KEY 28 1.0 t T þ Þ 1 KEY 30 1.0 u U ú Ú 1 KEY 55 1.0 v V v V 1 @@ -104,7 +108,8 @@ KEY 59 1.0 , < ç Ç 2 KEY 60 1.0 . > ˙ ˇ 0 KEY 61 1.0 / ? ¿ ̉ 0 -KEY 62 2.5 Shift Shift Shift Shift 0 +KEY 62 2.5 SHIFT SHIFT SHIFT SHIFT 0 +# __↑__ __↑__ __↑__ __↑__ 0 diff --git a/osk/qwerty.h_layout b/osk/qwerty.h_layout index cfe0f6df7..93025fa2d 100644 --- a/osk/qwerty.h_layout +++ b/osk/qwerty.h_layout @@ -38,7 +38,7 @@ KEY 18 1.0 9 ( ‘ ˘ 0 KEY 19 1.0 0 ) ’ ° 0 KEY 20 1.0 - _ ¥ ̣ 0 KEY 21 1.0 = + × ÷ 0 -KEY 22 2.0 Back Back Back Back 0 +KEY 22 2.0 DELETE DELETE DELETE DELETE 0 NEWLINE @@ -46,7 +46,7 @@ NEWLINE # Tab -KEY 23 1.5 |<->| |<->| |<->| |<->| 0 +KEY 23 1.5 TAB TAB TAB TAB 0 @@ -69,7 +69,7 @@ KEY 51 1.5 \ | ¬ ¦ 0 NEWLINE # CAPSLOCK -KEY 66 2.0 Caps Caps Caps Caps 0 +KEY 66 2.0 CAPSLOCK CAPSLOCK CAPSLOCK CAPSLOCK 0 KEY 38 1.0 a A á Á 1 KEY 39 1.0 s S ß § 1 @@ -86,14 +86,14 @@ KEY 47 1.0 ; : ¶ ° 0 KEY 48 1.0 ´ ¨ ' " 0 # Return -KEY 36 2.0 Enter Enter Enter Enter 0 +KEY 36 2.0 ENTER ENTER ENTER ENTER 0 NEWLINE -KEY 50 2.5 Shift Shift Shift Shift 0 +KEY 50 2.5 SHIFT SHIFT SHIFT SHIFT 0 KEY 52 1.0 z Z æ Æ 1 KEY 53 1.0 x X x X 1 @@ -106,7 +106,7 @@ KEY 58 1.0 m M µ µ 1 KEY 59 1.0 , < ç Ç 2 KEY 60 1.0 . > ˙ ˇ 0 KEY 61 1.0 / ? ¿ ̉ 0 -KEY 62 2.5 Shift Shift Shift Shift 0 +KEY 62 2.5 SHIFT SHIFT SHIFT SHIFT 0 diff --git a/src/onscreen_keyboard.c b/src/onscreen_keyboard.c index de155a525..eec59e821 100644 --- a/src/onscreen_keyboard.c +++ b/src/onscreen_keyboard.c @@ -66,7 +66,7 @@ static void mtw(wchar_t * wtok, char * tok) #define mbstowcs(wtok, tok, size) mtw(wtok, tok) #endif -struct osk_keyboard *osk_create(char *layout_name, SDL_Surface *canvas, SDL_Surface *button_up, SDL_Surface *button_down, SDL_Surface *button_off, SDL_Surface *button_nav, SDL_Surface *button_hold, int disable_change) +struct osk_keyboard *osk_create(char *layout_name, SDL_Surface *canvas, SDL_Surface *button_up, SDL_Surface *button_down, SDL_Surface *button_off, SDL_Surface *button_nav, SDL_Surface *button_hold, SDL_Surface *oskdel, SDL_Surface *osktab, SDL_Surface *oskenter, SDL_Surface *oskcapslock, SDL_Surface *oskshift, int disable_change) { SDL_Surface *surface; osk_layout *layout; @@ -116,6 +116,11 @@ struct osk_keyboard *osk_create(char *layout_name, SDL_Surface *canvas, SDL_Surf keyboard->button_off = button_off; keyboard->button_nav = button_nav; keyboard->button_hold = button_hold; + keyboard->oskdel = oskdel; + keyboard->osktab = osktab; + keyboard->oskenter = oskenter; + keyboard->oskcapslock = oskcapslock; + keyboard->oskshift = oskshift; keyboard->composing = layout->composemap; keyboard->composed = NULL; keyboard->last_key_pressed = NULL; @@ -1281,7 +1286,32 @@ static void label_key(osk_key key, on_screen_keyboard *keyboard) text = strdup(key.top_label); } - if( strncmp("SPACE", text, 5) != 0 && strncmp("NULL", text, 4) != 0) + if( strncmp("DELETE", text, 6) == 0) + { + apply_surface(key.x, key.y, keyboard->oskdel, keyboard->surface, NULL); + } + + else if( strncmp("TAB", text, 3) == 0) + { + apply_surface(key.x, key.y, keyboard->osktab, keyboard->surface, NULL); + } + + else if( strncmp("ENTER", text, 5) == 0) + { + apply_surface(key.x, key.y, keyboard->oskenter, keyboard->surface, NULL); + } + + else if( strncmp("CAPSLOCK", text, 8) == 0) + { + apply_surface(key.x, key.y, keyboard->oskcapslock, keyboard->surface, NULL); + } + + else if( strncmp("SHIFT", text, 5) == 0) + { + apply_surface(key.x, key.y, keyboard->oskshift, keyboard->surface, NULL); + } + + else if( strncmp("SPACE", text, 5) != 0 && strncmp("NULL", text, 4) != 0) { messager = TTF_RenderUTF8_Blended(osk_fonty, text, keyboard->layout->fgcolor); @@ -1643,7 +1673,7 @@ struct osk_keyboard * osk_clicked(on_screen_keyboard *keyboard, int x, int y) } - new_keyboard = osk_create(name, keyboard->surface, keyboard->button_up, keyboard->button_down, keyboard->button_off, keyboard->button_nav, keyboard->button_hold, keyboard->disable_change); + new_keyboard = osk_create(name, keyboard->surface, keyboard->button_up, keyboard->button_down, keyboard->button_off, keyboard->button_nav, keyboard->button_hold, keyboard->oskdel, keyboard->osktab, keyboard->oskenter, keyboard->oskcapslock, keyboard->oskshift, keyboard->disable_change); free(aux_list_ptr); diff --git a/src/onscreen_keyboard.h b/src/onscreen_keyboard.h index 03af0843e..a04b1809e 100644 --- a/src/onscreen_keyboard.h +++ b/src/onscreen_keyboard.h @@ -110,6 +110,11 @@ typedef struct osk_keyboard SDL_Surface *button_off; SDL_Surface *button_nav; SDL_Surface *button_hold; + SDL_Surface *oskdel; /* The surfaces containing some symbols for the buttons, delete arrow */ + SDL_Surface *osktab; /* Tab arrows */ + SDL_Surface *oskenter; /* Return hook/arrow */ + SDL_Surface *oskcapslock; /* CapsLock */ + SDL_Surface *oskshift; /* Shift */ int changed; /* If the surface has been modified (painted) */ SDL_Rect rect; /* The rectangle that has changed */ int recreated; /* If the surface has been deleted and newly created */ @@ -127,7 +132,7 @@ typedef struct osk_keyboard osk_key * last_key_pressed; /* The last key pressed */ } on_screen_keyboard; -struct osk_keyboard *osk_create(char *layout_name, SDL_Surface *canvas, SDL_Surface *button_up, SDL_Surface *button_down, SDL_Surface *button_off, SDL_Surface *button_nav, SDL_Surface *button_hold, int disable_change); +struct osk_keyboard *osk_create(char *layout_name, SDL_Surface *canvas, SDL_Surface *button_up, SDL_Surface *button_down, SDL_Surface *button_off, SDL_Surface *button_nav, SDL_Surface *button_hold, SDL_Surface *oskdel, SDL_Surface *osktab, SDL_Surface *oskenter, SDL_Surface *oskcapslock, SDL_Surface *oskshift, int disable_change); struct osk_layout *osk_load_layout(char *layout_name); diff --git a/src/tuxpaint.c b/src/tuxpaint.c index 6d6605b64..0118a40da 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -1358,6 +1358,7 @@ static SDL_Surface *img_title_on, *img_title_off, static SDL_Surface *img_title_names[NUM_TITLES]; static SDL_Surface *img_tools[NUM_TOOLS], *img_tool_names[NUM_TOOLS]; +static SDL_Surface *img_oskdel, *img_osktab, *img_oskenter, *img_oskcapslock, *img_oskshift; static SDL_Surface *thumbnail(SDL_Surface * src, int max_x, int max_y, int keep_aspect); static SDL_Surface *thumbnail2(SDL_Surface * src, int max_x, int max_y, @@ -3033,9 +3034,9 @@ static void mainloop(void) if (kbd == NULL) { if (onscreen_keyboard_layout) - kbd = osk_create(onscreen_keyboard_layout, screen, img_btnsm_up, img_btnsm_down, img_btnsm_off, img_btnsm_nav, img_btnsm_hold, onscreen_keyboard_disable_change); + kbd = osk_create(onscreen_keyboard_layout, screen, img_btnsm_up, img_btnsm_down, img_btnsm_off, img_btnsm_nav, img_btnsm_hold, img_oskdel, img_osktab, img_oskenter, img_oskcapslock, img_oskshift, onscreen_keyboard_disable_change); else - kbd = osk_create(strdup("default.layout"), screen, img_btnsm_up, img_btnsm_down, img_btnsm_off, img_btnsm_nav, img_btnsm_hold, onscreen_keyboard_disable_change); + kbd = osk_create(strdup("default.layout"), screen, img_btnsm_up, img_btnsm_down, img_btnsm_off, img_btnsm_nav, img_btnsm_hold, img_oskdel, img_osktab, img_oskenter, img_oskcapslock, img_oskshift, onscreen_keyboard_disable_change); } if (kbd == NULL) printf("kbd = NULL\n"); @@ -12199,6 +12200,15 @@ static void cleanup(void) free(img_color_btns); #endif + if (onscreen_keyboard) + { + free_surface(&img_oskdel); + free_surface(&img_osktab); + free_surface(&img_oskenter); + free_surface(&img_oskcapslock); + free_surface(&img_oskshift); + } + free_surface(&screen); free_surface(&img_starter); free_surface(&img_starter_bkgd); @@ -23143,6 +23153,15 @@ static void setup(void) img_paintcan = loadimage(DATA_PREFIX "images/ui/paintcan.png"); #endif + if (onscreen_keyboard) + { + img_oskdel = loadimage(DATA_PREFIX "images/ui/osk_delete.png"); + img_osktab = loadimage(DATA_PREFIX "images/ui/osk_tab.png"); + img_oskenter = loadimage(DATA_PREFIX "images/ui/osk_enter.png"); + img_oskcapslock = loadimage(DATA_PREFIX "images/ui/osk_capslock.png"); + img_oskshift = loadimage(DATA_PREFIX "images/ui/osk_shift.png"); + + } show_progress_bar(screen);