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

View File

@@ -165,6 +165,8 @@ void initAsset(char *argv[])
asset->add("/data/smb2.png", t_bitmap);
asset->add("/data/debug.txt", t_font);
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/notify.png", t_bitmap);
asset->add("/data/notify.wav", t_sound);
@@ -243,7 +245,7 @@ void initText()
// Inicializa el teclado en pantalla
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->setCaption("JAILER_ID");
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_Rect rect = {offset_x + (layout.at(pos).col * dist), offset_y + (layout.at(pos).row * dist), dist, dist};
// 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, 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);
}