on_screen_keyboard: Mejorada la calidad del cursor

on_screen_keyboard: Compatibilidad con fuentes de texto de tamaño variable
This commit is contained in:
2023-05-28 19:35:49 +02:00
parent 120c3791cf
commit d2e94ce74b
5 changed files with 74 additions and 67 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

BIN
data/nokia.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -3,57 +3,57 @@
# box height # box height
8 8
# 32 espacio ( ) # 32 espacio ( )
2 4
# 33 ! # 33 !
2 2
# 34 " # 34 "
5 3
# 35 # # 35 #
6 5
# 36 $ # 36 $
6 5
# 37 % # 37 %
6 6
# 38 & # 38 &
6 6
# 39 ' # 39 '
2 1
# 40 ( # 40 (
3 3
# 41 ) # 41 )
3 3
# 42 * # 42 *
4 5
# 43 + # 43 +
3 5
# 44 , # 44 ,
2 2
# 45 - # 45 -
3 4
# 46 . # 46 .
2 2
# 47 / # 47 /
4 3
# 48 0 # 48 0
6 5
# 49 1 # 49 1
6 3
# 50 2 # 50 2
6 5
# 51 3 # 51 3
6 5
# 52 4 # 52 4
6 5
# 53 5 # 53 5
6 5
# 54 6 # 54 6
6 5
# 55 7 # 55 7
6 5
# 56 8 # 56 8
6 5
# 57 9 # 57 9
6 5
# 58 : # 58 :
2 2
# 59 ; # 59 ;
@@ -61,73 +61,73 @@
# 60 < # 60 <
4 4
# 61 = # 61 =
3 4
# 62 > # 62 >
4 4
# 63 ? # 63 ?
6 5
# 64 @ # 64 @
8 6
# 65 A # 65 A
6 5
# 66 B # 66 B
6 5
# 67 C # 67 C
6 5
# 68 D # 68 D
6 5
# 69 E # 69 E
6 5
# 70 F # 70 F
6 5
# 71 G # 71 G
6 5
# 72 H # 72 H
6 5
# 73 I # 73 I
6 2
# 74 J # 74 J
6 4
# 75 K # 75 K
6 6
# 76 L # 76 L
6 4
# 77 M # 77 M
6 7
# 78 N # 78 N
6 6
# 79 O # 79 O
6 6
# 80 P # 80 P
6 5
# 81 Q # 81 Q
6 6
# 82 R # 82 R
6 5
# 83 S # 83 S
6 4
# 84 T # 84 T
6 6
# 85 U # 85 U
6
# 86 V
5 5
# 87 W # 86 V
6 6
# 87 W
7
# 88 X # 88 X
6 6
# 89 Y # 89 Y
6 6
# 90 Z # 90 Z
6
# 91 [
3
# 92 \
5 5
# 93 ] # 91 [
2
# 92 \
3 3
# 93 ]
2
# 94 ^ # 94 ^
4 3
# 95 _ # 95 _
6 6
# 96 ` # 96 `
@@ -137,27 +137,27 @@
# 98 b # 98 b
5 5
# 99 c # 99 c
5 4
# 100 d # 100 d
5 5
# 101 e # 101 e
5 5
# 102 f # 102 f
5 3
# 103 g # 103 g
5 5
# 104 h # 104 h
5 5
# 105 i # 105 i
4 2
# 106 j # 106 j
5 3
# 107 k # 107 k
5 5
# 108 l # 108 l
5 2
# 109 m # 109 m
6 8
# 110 n # 110 n
5 5
# 111 o # 111 o
@@ -167,28 +167,28 @@
# 113 q # 113 q
5 5
# 114 r # 114 r
5
# 115 s
5
# 116 t
4 4
# 115 s
4
# 116 t
3
# 117 u # 117 u
5 5
# 118 v # 118 v
5 5
# 119 w # 119 w
6 7
# 120 x # 120 x
4 5
# 121 y # 121 y
4 5
# 122 z # 122 z
5 5
# 123 { # 123 { -> ñ
3 5
# 124 | # 124 | -> ç
2 5
# 125 } # 125 }
3 0
# 126 ~ # 126 ~
3 0

View File

@@ -165,6 +165,8 @@ void initAsset(char *argv[])
asset->add("/data/smb2.png", t_bitmap); asset->add("/data/smb2.png", t_bitmap);
asset->add("/data/debug.txt", t_font); asset->add("/data/debug.txt", t_font);
asset->add("/data/debug.png", t_bitmap); asset->add("/data/debug.png", t_bitmap);
asset->add("/data/nokia.txt", t_font);
asset->add("/data/nokia.png", t_bitmap);
asset->add("/data/z80.png", t_bitmap); asset->add("/data/z80.png", t_bitmap);
asset->add("/data/notify.png", t_bitmap); asset->add("/data/notify.png", t_bitmap);
asset->add("/data/notify.wav", t_sound); asset->add("/data/notify.wav", t_sound);
@@ -243,7 +245,7 @@ void initText()
// Inicializa el teclado en pantalla // Inicializa el teclado en pantalla
void initOnScreenKeyboard() void initOnScreenKeyboard()
{ {
osk = new OnScreenKeyboard(renderer, input, asset->get("smb2.png"), asset->get("smb2.txt"), options, options->screen.nativeWidth - 30, options->screen.nativeHeight - 80, "JailDesigner"); osk = new OnScreenKeyboard(renderer, input, asset->get("nokia.png"), asset->get("nokia.txt"), options, options->screen.nativeWidth - 30, options->screen.nativeHeight - 80, "JailDesigner");
osk->setBgColor({123, 99, 63}); osk->setBgColor({123, 99, 63});
osk->setCaption("JAILER_ID"); osk->setCaption("JAILER_ID");
osk->setChars(USE_UPPER | USE_LOWER | USE_NUMBER); osk->setChars(USE_UPPER | USE_LOWER | USE_NUMBER);

View File

@@ -105,7 +105,8 @@ void OnScreenKeyboard::fillTexture()
// SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 255); // SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 255);
// SDL_Rect rect = {offset_x + (layout.at(pos).col * dist), offset_y + (layout.at(pos).row * dist), dist, dist}; // SDL_Rect rect = {offset_x + (layout.at(pos).col * dist), offset_y + (layout.at(pos).row * dist), dist, dist};
// SDL_RenderFillRect(renderer, &rect); // SDL_RenderFillRect(renderer, &rect);
text->write(offset_x + (layout.at(pos).col * dist) + 4, offset_y + (layout.at(pos).row * dist) + 4, layout.at(pos).caption); // text->write(offset_x + (layout.at(pos).col * dist) + (dist / 2), offset_y + (layout.at(pos).row * dist) + (dist / 2), layout.at(pos).caption);
text->writeCentered(offset_x + (layout.at(pos).col * dist) + (dist / 2), offset_y + (layout.at(pos).row * dist) + (dist / 4), layout.at(pos).caption);
} }
} }
@@ -261,6 +262,10 @@ void OnScreenKeyboard::render()
{ {
SDL_RenderCopy(renderer, texture, nullptr, &dest); SDL_RenderCopy(renderer, texture, nullptr, &dest);
SDL_RenderCopy(renderer, textureCursor, nullptr, &cursor.dest); SDL_RenderCopy(renderer, textureCursor, nullptr, &cursor.dest);
const int pos = cursor.col + cursor.row * columns;
const string key = pos < layout.size() ? layout.at(pos).caption : "";
text->writeDX(TXT_CENTER | TXT_COLOR, cursor.dest.x + cursor.dest.w / 2, cursor.dest.y + cursor.dest.w / 4, key, 1, {0, 255, 0});
text->write(dest.x + outputDest.x, dest.y + outputDest.y, output); text->write(dest.x + outputDest.x, dest.y + outputDest.y, output);
} }