Use our own font for text labels of buttons (0b01 needs C23 for now)
This commit is contained in:
parent
dc74c49351
commit
eb2a8bc3a0
4 changed files with 371 additions and 24 deletions
2
Makefile
2
Makefile
|
@ -59,7 +59,7 @@ EXTRA_WARNING_FLAGS := -Wunused-function \
|
||||||
$(call cc-option,-Wunused-variable)
|
$(call cc-option,-Wunused-variable)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
override CFLAGS := -std=c11 \
|
override CFLAGS := -std=c23 \
|
||||||
-Wall -Wextra -Wpedantic \
|
-Wall -Wextra -Wpedantic \
|
||||||
-Wformat=2 -Wshadow \
|
-Wformat=2 -Wshadow \
|
||||||
-Wwrite-strings -Wstrict-prototypes -Wold-style-definition \
|
-Wwrite-strings -Wstrict-prototypes -Wold-style-definition \
|
||||||
|
|
147
src/ui.c
147
src/ui.c
|
@ -141,6 +141,137 @@ letter_t small_font[ 128 ] = {
|
||||||
{0, 0, 0 }
|
{0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
letter_t big_font[ 128 ] = {
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 }, /* # 16 */
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 }, /* # 32 */
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{big_font_dot_width, big_font_dot_height, big_font_dot_bitmap}, /* # 46 */
|
||||||
|
{0, 0, 0 },
|
||||||
|
{big_font_0_width, big_font_0_height, big_font_0_bitmap }, /* # 48 */
|
||||||
|
{big_font_1_width, big_font_1_height, big_font_1_bitmap },
|
||||||
|
{big_font_2_width, big_font_2_height, big_font_2_bitmap },
|
||||||
|
{big_font_3_width, big_font_3_height, big_font_3_bitmap },
|
||||||
|
{big_font_4_width, big_font_4_height, big_font_4_bitmap },
|
||||||
|
{big_font_5_width, big_font_5_height, big_font_5_bitmap },
|
||||||
|
{big_font_6_width, big_font_6_height, big_font_6_bitmap },
|
||||||
|
{big_font_7_width, big_font_7_height, big_font_7_bitmap },
|
||||||
|
{big_font_8_width, big_font_8_height, big_font_8_bitmap },
|
||||||
|
{big_font_9_width, big_font_9_height, big_font_9_bitmap },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 }, /* # 64 */
|
||||||
|
{big_font_A_width, big_font_A_height, big_font_A_bitmap },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{big_font_C_width, big_font_C_height, big_font_C_bitmap },
|
||||||
|
{big_font_D_width, big_font_D_height, big_font_D_bitmap },
|
||||||
|
{big_font_E_width, big_font_E_height, big_font_E_bitmap },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{big_font_G_width, big_font_G_height, big_font_G_bitmap },
|
||||||
|
{big_font_H_width, big_font_H_height, big_font_H_bitmap },
|
||||||
|
{big_font_I_width, big_font_I_height, big_font_I_bitmap },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{big_font_L_width, big_font_L_height, big_font_L_bitmap },
|
||||||
|
{big_font_M_width, big_font_M_height, big_font_M_bitmap },
|
||||||
|
{big_font_N_width, big_font_N_height, big_font_N_bitmap },
|
||||||
|
{big_font_O_width, big_font_O_height, big_font_O_bitmap },
|
||||||
|
{big_font_P_width, big_font_P_height, big_font_P_bitmap }, /* # 80 */
|
||||||
|
{0, 0, 0 },
|
||||||
|
{big_font_R_width, big_font_R_height, big_font_R_bitmap },
|
||||||
|
{big_font_S_width, big_font_S_height, big_font_S_bitmap },
|
||||||
|
{big_font_T_width, big_font_T_height, big_font_T_bitmap },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{big_font_V_width, big_font_V_height, big_font_V_bitmap },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{big_font_X_width, big_font_X_height, big_font_X_bitmap },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 }, /* # 96 */
|
||||||
|
{0, 0, 0 }, /* a == left arrow */
|
||||||
|
{0, 0, 0 }, /* b == differential */
|
||||||
|
{0, 0, 0 }, /* c == integral */
|
||||||
|
{0, 0, 0 }, /* d == sigma */
|
||||||
|
{0, 0, 0 }, /* e == sqr */
|
||||||
|
{0, 0, 0 }, /* f == root */
|
||||||
|
{0, 0, 0 }, /* g == pow10 */
|
||||||
|
{0, 0, 0 }, /* h == exp */
|
||||||
|
{0, 0, 0 }, /* i == << >> */
|
||||||
|
{0, 0, 0 }, /* j == " " */
|
||||||
|
{0, 0, 0 }, /* k == New Line */
|
||||||
|
{0, 0, 0 }, /* l == pi */
|
||||||
|
{0, 0, 0 }, /* m == angle */
|
||||||
|
{0, 0, 0 }, /* n == sqr gx */
|
||||||
|
{0, 0, 0 }, /* o == root gx */
|
||||||
|
{0, 0, 0 }, /* p == pow10 gx */
|
||||||
|
{0, 0, 0 }, /* q == exp gx */
|
||||||
|
{0, 0, 0 }, /* r == ( ) gx */
|
||||||
|
{0, 0, 0 }, /* s == # gx */
|
||||||
|
{0, 0, 0 }, /* t == [] gx */
|
||||||
|
{0, 0, 0 }, /* u == _ gx */
|
||||||
|
{0, 0, 0 }, /* v == << >> gx */
|
||||||
|
{0, 0, 0 }, /* w == " " gx */
|
||||||
|
{0, 0, 0 }, /* x == {} gx */
|
||||||
|
{0, 0, 0 }, /* y == :: gx */
|
||||||
|
{0, 0, 0 }, /* z == angle gx */
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 },
|
||||||
|
{0, 0, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
color_t colors_sx[ NB_COLORS ] = {
|
color_t colors_sx[ NB_COLORS ] = {
|
||||||
{
|
{
|
||||||
/* #ffffff */
|
/* #ffffff */
|
||||||
|
@ -2172,6 +2303,22 @@ int SmallTextWidth( const char* string, unsigned int length )
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int BigTextWidth( const char* string, unsigned int length )
|
||||||
|
{
|
||||||
|
int w = 0;
|
||||||
|
for ( unsigned int i = 0; i < length; i++ ) {
|
||||||
|
if ( big_font[ ( int )string[ i ] ].h != 0 )
|
||||||
|
w += big_font[ ( int )string[ i ] ].w;
|
||||||
|
else {
|
||||||
|
if ( config.verbose )
|
||||||
|
fprintf( stderr, "Unknown small letter 0x00%x\n", ( int )string[ i ] );
|
||||||
|
w += 7;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
|
||||||
void start_UI( int argc, char** argv )
|
void start_UI( int argc, char** argv )
|
||||||
{
|
{
|
||||||
ui_init_LCD();
|
ui_init_LCD();
|
||||||
|
|
184
src/ui_inner.h
184
src/ui_inner.h
|
@ -77,6 +77,7 @@ typedef struct ann_struct_t {
|
||||||
/* variables */
|
/* variables */
|
||||||
/*************/
|
/*************/
|
||||||
extern letter_t small_font[ 128 ];
|
extern letter_t small_font[ 128 ];
|
||||||
|
extern letter_t big_font[ 128 ];
|
||||||
|
|
||||||
extern color_t colors_sx[ NB_COLORS ];
|
extern color_t colors_sx[ NB_COLORS ];
|
||||||
extern color_t colors_gx[ NB_COLORS ];
|
extern color_t colors_gx[ NB_COLORS ];
|
||||||
|
@ -625,10 +626,193 @@ static unsigned char arrow_gx_bitmap[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0
|
||||||
#define equal_gx_height 12
|
#define equal_gx_height 12
|
||||||
static unsigned char equal_gx_bitmap[] = { 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00 };
|
static unsigned char equal_gx_bitmap[] = { 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00 };
|
||||||
|
|
||||||
|
/************/
|
||||||
|
/* Big font */
|
||||||
|
/************/
|
||||||
|
#define big_font_dot_width 8
|
||||||
|
#define big_font_dot_height 13
|
||||||
|
static unsigned char big_font_dot_bitmap[] = {
|
||||||
|
0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000,
|
||||||
|
0b00011000, 0b00011000, 0b00000000, 0b00000000, 0b00000000, 0b00000000,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define big_font_0_width 8
|
||||||
|
#define big_font_0_height 13
|
||||||
|
static unsigned char big_font_0_bitmap[] = {
|
||||||
|
0b00011000, 0b00111100, 0b01100110, 0b01100110, 0b11000011, 0b11000011, 0b11000011,
|
||||||
|
0b11000011, 0b11000011, 0b01100110, 0b01100110, 0b00111100, 0b00011000,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define big_font_1_width 8
|
||||||
|
#define big_font_1_height 13
|
||||||
|
static unsigned char big_font_1_bitmap[] = {
|
||||||
|
0b00011000, 0b00011100, 0b00011110, 0b00011011, 0b00011000, 0b00011000, 0b00011000,
|
||||||
|
0b00011000, 0b00011000, 0b00011000, 0b00011000, 0b00011000, 0b11111111,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define big_font_2_width 8
|
||||||
|
#define big_font_2_height 13
|
||||||
|
static unsigned char big_font_2_bitmap[] = {
|
||||||
|
0b00111100, 0b01100110, 0b11000011, 0b11000011, 0b11000000, 0b11000000, 0b01100000,
|
||||||
|
0b00111000, 0b00001100, 0b00000110, 0b00000011, 0b00000011, 0b11111111,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define big_font_3_width 8
|
||||||
|
#define big_font_3_height 13
|
||||||
|
static unsigned char big_font_3_bitmap[] = {
|
||||||
|
0b00111100, 0b01100110, 0b11000011, 0b11000011, 0b11000000, 0b01100000, 0b00111000,
|
||||||
|
0b01100000, 0b11000000, 0b11000011, 0b11000011, 0b01100110, 0b00111100,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define big_font_4_width 8
|
||||||
|
#define big_font_4_height 13
|
||||||
|
static unsigned char big_font_4_bitmap[] = {
|
||||||
|
0b01100000, 0b01110000, 0b01111000, 0b01101100, 0b01100110, 0b01100011, 0b01100011,
|
||||||
|
0b11111111, 0b01100000, 0b01100000, 0b01100000, 0b01100000, 0b01100000,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define big_font_5_width 8
|
||||||
|
#define big_font_5_height 13
|
||||||
|
static unsigned char big_font_5_bitmap[] = {
|
||||||
|
0b11111111, 0b00000011, 0b00000011, 0b00000011, 0b00000011, 0b00111011, 0b01100111,
|
||||||
|
0b11000000, 0b11000000, 0b11000000, 0b11000011, 0b01100110, 0b00111100,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define big_font_6_width 8
|
||||||
|
#define big_font_6_height 13
|
||||||
|
static unsigned char big_font_6_bitmap[] = {
|
||||||
|
0b00111100, 0b01100110, 0b01000011, 0b00000011, 0b00000011, 0b00111011, 0b01100111,
|
||||||
|
0b11000011, 0b11000011, 0b11000011, 0b11000011, 0b01100110, 0b00111100,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define big_font_7_width 8
|
||||||
|
#define big_font_7_height 13
|
||||||
|
static unsigned char big_font_7_bitmap[] = {
|
||||||
|
0b11111111, 0b11000000, 0b11000000, 0b01100000, 0b01100000, 0b00110000, 0b00110000,
|
||||||
|
0b00011000, 0b00011000, 0b00001100, 0b00001100, 0b00000110, 0b00000110,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define big_font_8_width 8
|
||||||
|
#define big_font_8_height 13
|
||||||
|
static unsigned char big_font_8_bitmap[] = {
|
||||||
|
0b00111100, 0b01100110, 0b11000011, 0b11000011, 0b11000011, 0b01100110, 0b00111100,
|
||||||
|
0b01100110, 0b11000011, 0b11000011, 0b11000011, 0b01100110, 0b00111100,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define big_font_9_width 8
|
||||||
|
#define big_font_9_height 13
|
||||||
|
static unsigned char big_font_9_bitmap[] = {
|
||||||
|
0b00111110, 0b11000011, 0b11000011, 0b11000011, 0b11000011, 0b11000011, 0b11100110,
|
||||||
|
0b11011100, 0b11000000, 0b11000000, 0b11000010, 0b01100110, 0b00111100,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define big_font_A_width 8
|
||||||
|
#define big_font_A_height 10
|
||||||
|
static unsigned char big_font_A_bitmap[] = {
|
||||||
|
0b00011110, 0b00110011, 0b00110011, 0b00110011, 0b00110011, 0b00110011, 0b00111111, 0b00110011, 0b00110011, 0b00110011,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define big_font_C_width 8
|
||||||
|
#define big_font_C_height 10
|
||||||
|
static unsigned char big_font_C_bitmap[] = {
|
||||||
|
0b00011110, 0b00110011, 0b00110011, 0b00000011, 0b00000011, 0b00000011, 0b00000011, 0b00110011, 0b00110011, 0b00011110,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define big_font_D_width 8
|
||||||
|
#define big_font_D_height 10
|
||||||
|
static unsigned char big_font_D_bitmap[] = {
|
||||||
|
0b00001111, 0b00011011, 0b00110011, 0b00110011, 0b00110011, 0b00110011, 0b00110011, 0b00110011, 0b00011011, 0b00001111,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define big_font_E_width 8
|
||||||
|
#define big_font_E_height 10
|
||||||
|
static unsigned char big_font_E_bitmap[] = {
|
||||||
|
0b00111111, 0b00000011, 0b00000011, 0b00000011, 0b00011111, 0b00000011, 0b00000011, 0b00000011, 0b00000011, 0b00111111,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define big_font_G_width 8
|
||||||
|
#define big_font_G_height 10
|
||||||
|
static unsigned char big_font_G_bitmap[] = {
|
||||||
|
0b00011110, 0b00110011, 0b00110011, 0b00000011, 0b00000011, 0b00111011, 0b00110011, 0b00110011, 0b00110011, 0b00011110,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define big_font_H_width 8
|
||||||
|
#define big_font_H_height 10
|
||||||
|
static unsigned char big_font_H_bitmap[] = {
|
||||||
|
0b00110011, 0b00110011, 0b00110011, 0b00110011, 0b00111111, 0b00110011, 0b00110011, 0b00110011, 0b00110011, 0b00110011,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define big_font_I_width 8
|
||||||
|
#define big_font_I_height 10
|
||||||
|
static unsigned char big_font_I_bitmap[] = {
|
||||||
|
0b00111111, 0b00001100, 0b00001100, 0b00001100, 0b00001100, 0b00001100, 0b00001100, 0b00001100, 0b00001100, 0b00111111,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define big_font_L_width 8
|
||||||
|
#define big_font_L_height 10
|
||||||
|
static unsigned char big_font_L_bitmap[] = {
|
||||||
|
0b00000011, 0b00000011, 0b00000011, 0b00000011, 0b00000011, 0b00000011, 0b00000011, 0b00000011, 0b00000011, 0b00111111,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define big_font_M_width 8
|
||||||
|
#define big_font_M_height 10
|
||||||
|
static unsigned char big_font_M_bitmap[] = {
|
||||||
|
0b00100001, 0b00110011, 0b00110011, 0b00111111, 0b00111111, 0b00110011, 0b00110011, 0b00110011, 0b00110011, 0b00110011,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define big_font_N_width 8
|
||||||
|
#define big_font_N_height 10
|
||||||
|
static unsigned char big_font_N_bitmap[] = {
|
||||||
|
0b00110011, 0b00110011, 0b00110111, 0b00110111, 0b00110111, 0b00111011, 0b00111011, 0b00111011, 0b00110011, 0b00110011,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define big_font_O_width 8
|
||||||
|
#define big_font_O_height 10
|
||||||
|
static unsigned char big_font_O_bitmap[] = {
|
||||||
|
0b00011110, 0b00110011, 0b00110011, 0b00110011, 0b00110011, 0b00110011, 0b00110011, 0b00110011, 0b00110011, 0b00011110,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define big_font_P_width 8
|
||||||
|
#define big_font_P_height 10
|
||||||
|
static unsigned char big_font_P_bitmap[] = {
|
||||||
|
0b00011111, 0b00110011, 0b00110011, 0b00110011, 0b00110011, 0b00011111, 0b00000011, 0b00000011, 0b00000011, 0b00000011,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define big_font_R_width 8
|
||||||
|
#define big_font_R_height 10
|
||||||
|
static unsigned char big_font_R_bitmap[] = {
|
||||||
|
0b00011111, 0b00110011, 0b00110011, 0b00110011, 0b00011111, 0b00011011, 0b00110011, 0b00110011, 0b00110011, 0b00110011,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define big_font_S_width 8
|
||||||
|
#define big_font_S_height 10
|
||||||
|
static unsigned char big_font_S_bitmap[] = {
|
||||||
|
0b00011110, 0b00110011, 0b00110011, 0b00000110, 0b00001100, 0b00001100, 0b00011000, 0b00110011, 0b00110011, 0b00011110,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define big_font_T_width 8
|
||||||
|
#define big_font_T_height 10
|
||||||
|
static unsigned char big_font_T_bitmap[] = {
|
||||||
|
0b00111111, 0b00001100, 0b00001100, 0b00001100, 0b00001100, 0b00001100, 0b00001100, 0b00001100, 0b00001100, 0b00001100,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define big_font_V_width 8
|
||||||
|
#define big_font_V_height 10
|
||||||
|
static unsigned char big_font_V_bitmap[] = {
|
||||||
|
0b00110011, 0b00110011, 0b00110011, 0b00110011, 0b00110011, 0b00110011, 0b00110011, 0b00011110, 0b00011110, 0b00001100,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define big_font_X_width 8
|
||||||
|
#define big_font_X_height 10
|
||||||
|
static unsigned char big_font_X_bitmap[] = {
|
||||||
|
0b00110011, 0b00110011, 0b00011110, 0b00011110, 0b00001100, 0b00001100, 0b00011110, 0b00011110, 0b00110011, 0b00110011,
|
||||||
|
};
|
||||||
|
|
||||||
/*************/
|
/*************/
|
||||||
/* functions */
|
/* functions */
|
||||||
/*************/
|
/*************/
|
||||||
extern int SmallTextWidth( const char* string, unsigned int length );
|
extern int SmallTextWidth( const char* string, unsigned int length );
|
||||||
|
extern int BigTextWidth( const char* string, unsigned int length );
|
||||||
extern void ui_init_LCD( void );
|
extern void ui_init_LCD( void );
|
||||||
|
|
||||||
#endif /* _UI_INNER_H */
|
#endif /* _UI_INNER_H */
|
||||||
|
|
|
@ -142,15 +142,30 @@ static void __draw_bitmap( int x, int y, unsigned int w, unsigned int h, unsigne
|
||||||
|
|
||||||
static void write_with_small_font( int x, int y, const char* string, int color_fg, int color_bg )
|
static void write_with_small_font( int x, int y, const char* string, int color_fg, int color_bg )
|
||||||
{
|
{
|
||||||
|
int c;
|
||||||
for ( unsigned int i = 0; i < strlen( string ); i++ ) {
|
for ( unsigned int i = 0; i < strlen( string ); i++ ) {
|
||||||
if ( small_font[ ( int )string[ i ] ].h != 0 )
|
c = ( int )string[ i ];
|
||||||
__draw_bitmap( x, ( int )( y - small_font[ ( int )string[ i ] ].h ), small_font[ ( int )string[ i ] ].w,
|
if ( small_font[ c ].h != 0 )
|
||||||
small_font[ ( int )string[ i ] ].h, small_font[ ( int )string[ i ] ].bits, color_fg, color_bg );
|
__draw_bitmap( x - 1, ( int )( y - small_font[ c ].h ), small_font[ c ].w, small_font[ c ].h, small_font[ c ].bits, color_fg,
|
||||||
|
color_bg );
|
||||||
|
|
||||||
x += SmallTextWidth( &string[ i ], 1 );
|
x += SmallTextWidth( &string[ i ], 1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void write_with_big_font( int x, int y, const char* string, int color_fg, int color_bg )
|
||||||
|
{
|
||||||
|
int c;
|
||||||
|
for ( unsigned int i = 0; i < strlen( string ); i++ ) {
|
||||||
|
c = ( int )string[ i ];
|
||||||
|
if ( big_font[ c ].h != 0 )
|
||||||
|
__draw_bitmap( x, y + ( big_font[ c ].h > 10 ? 0 : 2 ), big_font[ c ].w, big_font[ c ].h, big_font[ c ].bits, color_fg,
|
||||||
|
color_bg );
|
||||||
|
|
||||||
|
x += BigTextWidth( &string[ i ], 1 ) - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void colors_setup( void )
|
static void colors_setup( void )
|
||||||
{
|
{
|
||||||
// Adjust the LCD color according to the contrast
|
// Adjust the LCD color according to the contrast
|
||||||
|
@ -538,6 +553,27 @@ static SDL_Texture* create_button_texture( int hpkey, bool is_up )
|
||||||
// Fill the button and outline
|
// Fill the button and outline
|
||||||
__draw_rect( 0, 0, BUTTONS[ hpkey ].w, BUTTONS[ hpkey ].h, BUTTON );
|
__draw_rect( 0, 0, BUTTONS[ hpkey ].w, BUTTONS[ hpkey ].h, BUTTON );
|
||||||
|
|
||||||
|
if ( BUTTONS[ hpkey ].label != ( char* )0 ) {
|
||||||
|
/* Button has a text label */
|
||||||
|
x = strlen( BUTTONS[ hpkey ].label ) - 1;
|
||||||
|
x += ( ( BUTTONS[ hpkey ].w - BigTextWidth( BUTTONS[ hpkey ].label, strlen( BUTTONS[ hpkey ].label ) ) ) / 2 );
|
||||||
|
if ( is_up )
|
||||||
|
y = ( BUTTONS[ hpkey ].h + 1 ) / 2 - 6;
|
||||||
|
else
|
||||||
|
y = ( BUTTONS[ hpkey ].h + 1 ) / 2 - 7; /* down change */
|
||||||
|
|
||||||
|
write_with_big_font( x, y, BUTTONS[ hpkey ].label, WHITE, BUTTON );
|
||||||
|
} else if ( BUTTONS[ hpkey ].lw != 0 ) {
|
||||||
|
/* Button has a texture */
|
||||||
|
x = ( 1 + BUTTONS[ hpkey ].w - BUTTONS[ hpkey ].lw ) / 2;
|
||||||
|
if ( is_up )
|
||||||
|
y = ( 1 + BUTTONS[ hpkey ].h - BUTTONS[ hpkey ].lh ) / 2 + 1;
|
||||||
|
else
|
||||||
|
y = ( 1 + BUTTONS[ hpkey ].h - BUTTONS[ hpkey ].lh ) / 2;
|
||||||
|
|
||||||
|
__draw_bitmap( x, y, BUTTONS[ hpkey ].lw, BUTTONS[ hpkey ].lh, BUTTONS[ hpkey ].lb, BUTTONS[ hpkey ].lc, BUTTON );
|
||||||
|
}
|
||||||
|
|
||||||
// fix outer-corners color
|
// fix outer-corners color
|
||||||
int outer_color = PAD;
|
int outer_color = PAD;
|
||||||
if ( BUTTONS[ hpkey ].is_menu )
|
if ( BUTTONS[ hpkey ].is_menu )
|
||||||
|
@ -623,26 +659,6 @@ static SDL_Texture* create_button_texture( int hpkey, bool is_up )
|
||||||
// bottom-right
|
// bottom-right
|
||||||
__draw_pixel( BUTTONS[ hpkey ].w - 2, BUTTONS[ hpkey ].h - 2, FRAME );
|
__draw_pixel( BUTTONS[ hpkey ].w - 2, BUTTONS[ hpkey ].h - 2, FRAME );
|
||||||
|
|
||||||
if ( BUTTONS[ hpkey ].label != ( char* )0 ) {
|
|
||||||
/* Button has a text label */
|
|
||||||
x = ( BUTTONS[ hpkey ].w - strlen( BUTTONS[ hpkey ].label ) * 8 ) / 2;
|
|
||||||
if ( is_up )
|
|
||||||
y = ( BUTTONS[ hpkey ].h + 1 ) / 2 - 4;
|
|
||||||
else
|
|
||||||
y = ( BUTTONS[ hpkey ].h + 1 ) / 2 - 5; /* down change */
|
|
||||||
|
|
||||||
stringRGBA( renderer, x, y, BUTTONS[ hpkey ].label, 255, 255, 255, 255 );
|
|
||||||
} else if ( BUTTONS[ hpkey ].lw != 0 ) {
|
|
||||||
/* Button has a texture */
|
|
||||||
x = ( 1 + BUTTONS[ hpkey ].w - BUTTONS[ hpkey ].lw ) / 2;
|
|
||||||
if ( is_up )
|
|
||||||
y = ( 1 + BUTTONS[ hpkey ].h - BUTTONS[ hpkey ].lh ) / 2 + 1;
|
|
||||||
else
|
|
||||||
y = ( 1 + BUTTONS[ hpkey ].h - BUTTONS[ hpkey ].lh ) / 2;
|
|
||||||
|
|
||||||
__draw_bitmap( x, y, BUTTONS[ hpkey ].lw, BUTTONS[ hpkey ].lh, BUTTONS[ hpkey ].lb, BUTTONS[ hpkey ].lc, BUTTON );
|
|
||||||
}
|
|
||||||
|
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue