diff --git a/data/images/ui/osk_capslock.png b/data/images/ui/osk_capslock.png new file mode 100644 index 000000000..c571dd2d7 Binary files /dev/null and b/data/images/ui/osk_capslock.png differ diff --git a/data/images/ui/osk_delete.png b/data/images/ui/osk_delete.png new file mode 100644 index 000000000..b9d754083 Binary files /dev/null and b/data/images/ui/osk_delete.png differ diff --git a/data/images/ui/osk_enter.png b/data/images/ui/osk_enter.png new file mode 100644 index 000000000..f15ede225 Binary files /dev/null and b/data/images/ui/osk_enter.png differ diff --git a/data/images/ui/osk_shift.png b/data/images/ui/osk_shift.png new file mode 100644 index 000000000..688824361 Binary files /dev/null and b/data/images/ui/osk_shift.png differ diff --git a/data/images/ui/osk_tab.png b/data/images/ui/osk_tab.png new file mode 100644 index 000000000..0f6a10fdc Binary files /dev/null and b/data/images/ui/osk_tab.png differ 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);