From c8f9ce5c2ca9e0cbd792d01ff5d12f7b3c9205a8 Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine Date: Sun, 10 Nov 2024 12:45:06 +0100 Subject: [PATCH] --text-scale and --display-scale to scale then independently --- src/x49gpng/options.c | 14 ++- src/x49gpng/options.h | 3 +- src/x49gpng/ui.c | 194 +++++++++++++++++++++--------------------- 3 files changed, 109 insertions(+), 102 deletions(-) diff --git a/src/x49gpng/options.c b/src/x49gpng/options.c index eb0b239..20ccd31 100644 --- a/src/x49gpng/options.c +++ b/src/x49gpng/options.c @@ -28,7 +28,8 @@ void config_init( char* progname, int argc, char* argv[] ) opt.firmware = NULL; opt.model = MODEL_50G; opt.name = NULL; - opt.scale = 1.0; + opt.text_scale = 1; + opt.display_scale = 1; #if defined( __linux__ ) opt.font = "urw gothic l"; @@ -53,7 +54,8 @@ void config_init( char* progname, int argc, char* argv[] ) {"49gp", no_argument, NULL, 496}, {"49gp-newrpl", no_argument, NULL, 497}, {"name", required_argument, NULL, 'n'}, - {"scale", required_argument, NULL, 's'}, + {"text-scale", required_argument, NULL, 's'}, + {"display-scale", required_argument, NULL, 'S'}, {"font", required_argument, NULL, 't'}, @@ -77,7 +79,8 @@ void config_init( char* progname, int argc, char* argv[] ) " --49gp-newrpl show HP 49g+ faceplate with newRPL labels\n" " -n --name[=] set alternate UI name\n" " -t --font[=] set alternate UI font\n" - " -s --scale[=] scale GUI by X.x\n" + " -s --text-scale[=] scale text by X\n" + " -S --display-scale[=] scale LCD by X\n" " -D --enable-debug[=] enable the debugger interface\n" " (default port: %u)\n" " -d --debug use along -D to also start the debugger immediately\n" @@ -130,7 +133,10 @@ void config_init( char* progname, int argc, char* argv[] ) opt.name = strdup( optarg ); break; case 's': - opt.scale = atof( optarg ); + opt.text_scale = atoi( optarg ); + break; + case 'S': + opt.display_scale = atoi( optarg ); break; case 't': opt.font = strdup( optarg ); diff --git a/src/x49gpng/options.h b/src/x49gpng/options.h index 2737cfd..92b349a 100644 --- a/src/x49gpng/options.h +++ b/src/x49gpng/options.h @@ -26,7 +26,8 @@ struct options { char* name; char* font; - double scale; + int display_scale; + int text_scale; }; extern struct options opt; diff --git a/src/x49gpng/ui.c b/src/x49gpng/ui.c index 7e2aab6..aaa0f12 100644 --- a/src/x49gpng/ui.c +++ b/src/x49gpng/ui.c @@ -24,10 +24,10 @@ #define NB_KEYS 51 -#define FONT_SIZE_SYMBOL ( ( int )( 28 * opt.scale ) ) -#define FONT_SIZE_NUMBER ( ( int )( 20 * opt.scale ) ) -#define FONT_SIZE_KEY ( ( int )( 12 * opt.scale ) ) -#define FONT_SIZE_TINY ( ( int )( 10 * opt.scale ) ) +#define FONT_SIZE_SYMBOL ( ( int )( 28 * opt.text_scale ) ) +#define FONT_SIZE_NUMBER ( ( int )( 20 * opt.text_scale ) ) +#define FONT_SIZE_KEY ( ( int )( 12 * opt.text_scale ) ) +#define FONT_SIZE_TINY ( ( int )( 10 * opt.text_scale ) ) #define TINY_TEXT_HEIGHT ( FONT_SIZE_TINY + 2 ) #define TINY_TEXT_WIDTH ( TINY_TEXT_HEIGHT / 2 ) @@ -52,7 +52,7 @@ #define ANNUNCIATOR_HEIGHT 16 #define ANNUNCIATORS_HEIGHT ANNUNCIATOR_HEIGHT -#define LCD_PIXEL_SCALE ( ( int )( 2 * opt.scale ) ) +#define LCD_PIXEL_SCALE ( ( int )( 2 * opt.display_scale ) ) #define LCD_WIDTH ( 131 * LCD_PIXEL_SCALE ) #define LCD_HEIGHT ( 80 * LCD_PIXEL_SCALE ) @@ -68,7 +68,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .letter = "A", .left = "Y=", .right = NULL, - .below = NULL, + .below = "", .column = 5, .row = 1, .columnbit = ( 1 << 5 ), @@ -79,7 +79,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .letter = "B", .left = "WIN", .right = NULL, - .below = NULL, + .below = "", .column = 5, .row = 2, .columnbit = ( 1 << 5 ), @@ -90,7 +90,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .letter = "C", .left = "GRAPH", .right = NULL, - .below = NULL, + .below = "", .column = 5, .row = 3, .columnbit = ( 1 << 5 ), @@ -101,7 +101,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .letter = "D", .left = "2D/3D", .right = NULL, - .below = NULL, + .below = "", .column = 5, .row = 4, .columnbit = ( 1 << 5 ), @@ -112,7 +112,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .letter = "E", .left = "TBLSET", .right = NULL, - .below = NULL, + .below = "", .column = 5, .row = 5, .columnbit = ( 1 << 5 ), @@ -123,7 +123,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .letter = "F", .left = "TABLE", .right = NULL, - .below = NULL, + .below = "", .column = 5, .row = 6, .columnbit = ( 1 << 5 ), @@ -135,7 +135,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .letter = "G", .left = "FILES", .right = "BEGIN", - .below = NULL, + .below = "", .column = 5, .row = 7, .columnbit = ( 1 << 5 ), @@ -146,7 +146,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .letter = "H", .left = "CUSTOM", .right = "END", - .below = NULL, + .below = "", .column = 6, .row = 5, .columnbit = ( 1 << 6 ), @@ -157,7 +157,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .letter = "I", .left = "i", .right = "I", - .below = NULL, + .below = "", .column = 6, .row = 6, .columnbit = ( 1 << 6 ), @@ -165,10 +165,10 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .eint = 6}, {.css_class = "arrow", .label = "⬆", - .letter = NULL, - .left = NULL, + .letter = "", + .left = "", .right = NULL, - .below = NULL, + .below = "", .column = 6, .row = 1, .columnbit = ( 1 << 6 ), @@ -179,7 +179,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .letter = "J", .left = "UPDIR", .right = "COPY", - .below = NULL, + .below = "", .column = 6, .row = 7, .columnbit = ( 1 << 6 ), @@ -190,7 +190,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .letter = "K", .left = "RCL", .right = "CUT", - .below = NULL, + .below = "", .column = 7, .row = 1, .columnbit = ( 1 << 7 ), @@ -201,7 +201,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .letter = "L", .left = "PREV", .right = "PASTE", - .below = NULL, + .below = "", .column = 7, .row = 2, .columnbit = ( 1 << 7 ), @@ -210,10 +210,10 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { {.css_class = "arrow", .label = "⬅", - .letter = NULL, - .left = NULL, + .letter = "", + .left = "", .right = NULL, - .below = NULL, + .below = "", .column = 6, .row = 2, .columnbit = ( 1 << 6 ), @@ -221,10 +221,10 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .eint = 2}, {.css_class = "arrow", .label = "⬇", - .letter = NULL, - .left = NULL, + .letter = "", + .left = "", .right = NULL, - .below = NULL, + .below = "", .column = 6, .row = 3, .columnbit = ( 1 << 6 ), @@ -232,10 +232,10 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .eint = 3}, {.css_class = "arrow", .label = "⮕", - .letter = NULL, - .left = NULL, + .letter = "", + .left = "", .right = NULL, - .below = NULL, + .below = "", .column = 6, .row = 4, .columnbit = ( 1 << 6 ), @@ -247,7 +247,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .letter = "M", .left = "CMD", .right = "UNDO", - .below = NULL, + .below = "", .column = 4, .row = 1, .columnbit = ( 1 << 4 ), @@ -258,7 +258,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .letter = "N", .left = "PRG", .right = "CHARS", - .below = NULL, + .below = "", .column = 3, .row = 1, .columnbit = ( 1 << 3 ), @@ -269,7 +269,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .letter = "O", .left = "MTRW", .right = "EQW", - .below = NULL, + .below = "", .column = 2, .row = 1, .columnbit = ( 1 << 2 ), @@ -280,7 +280,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .letter = "P", .left = "MTH", .right = "CAT", - .below = NULL, + .below = "", .column = 1, .row = 1, .columnbit = ( 1 << 1 ), @@ -288,10 +288,10 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .eint = 1}, {.css_class = "function", .label = "⬅", - .letter = NULL, + .letter = "", .left = "DEL", .right = "CLEAR", - .below = NULL, + .below = "", .column = 0, .row = 1, .columnbit = ( 1 << 0 ), @@ -303,7 +303,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .letter = "Q", .left = "𝑒x", .right = "LN", - .below = NULL, + .below = "", .column = 4, .row = 2, .columnbit = ( 1 << 4 ), @@ -314,7 +314,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .letter = "R", .left = "𝓍2", .right = "x√𝓎", - .below = NULL, + .below = "", .column = 3, .row = 2, .columnbit = ( 1 << 3 ), @@ -325,7 +325,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .letter = "S", .left = "ASIN", .right = "∑", - .below = NULL, + .below = "", .column = 2, .row = 2, .columnbit = ( 1 << 2 ), @@ -336,7 +336,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .letter = "T", .left = "ACOS", .right = "∂", - .below = NULL, + .below = "", .column = 1, .row = 2, .columnbit = ( 1 << 1 ), @@ -347,7 +347,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .letter = "U", .left = "ATAN", .right = "∫", - .below = NULL, + .below = "", .column = 0, .row = 2, .columnbit = ( 1 << 0 ), @@ -359,7 +359,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .letter = "V", .left = "10𝓍", .right = "LOG", - .below = NULL, + .below = "", .column = 4, .row = 3, .columnbit = ( 1 << 4 ), @@ -370,7 +370,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .letter = "W", .left = "≠", .right = "=", - .below = NULL, + .below = "", .column = 3, .row = 3, .columnbit = ( 1 << 3 ), @@ -381,7 +381,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .letter = "X", .left = "≤", .right = ">", - .below = NULL, + .below = "", .column = 2, .row = 3, .columnbit = ( 1 << 2 ), @@ -392,7 +392,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .letter = "Y", .left = "≥", .right = ">", - .below = NULL, + .below = "", .column = 1, .row = 3, .columnbit = ( 1 << 1 ), @@ -403,7 +403,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .letter = "Z", .left = "ABS", .right = "ARG", - .below = NULL, + .below = "", .column = 0, .row = 3, .columnbit = ( 1 << 0 ), @@ -412,10 +412,10 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { {.css_class = "alpha", .label = "ALPHA", - .letter = NULL, + .letter = "", .left = "USER", .right = "ENTRY", - .below = NULL, + .below = "", .column = 0, .row = 0, .columnbit = 0, @@ -423,10 +423,10 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .eint = 4}, {.css_class = "core-number", .label = "7", - .letter = NULL, + .letter = "", .left = "S.SLV", .right = "NUM.SLV", - .below = NULL, + .below = "", .column = 3, .row = 4, .columnbit = ( 1 << 3 ), @@ -434,10 +434,10 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .eint = 4}, {.css_class = "core-number", .label = "8", - .letter = NULL, + .letter = "", .left = "EXP&LN", .right = "TRIG", - .below = NULL, + .below = "", .column = 2, .row = 4, .columnbit = ( 1 << 2 ), @@ -445,10 +445,10 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .eint = 4}, {.css_class = "core-number", .label = "9", - .letter = NULL, + .letter = "", .left = "FINANCE", .right = "TIME", - .below = NULL, + .below = "", .column = 1, .row = 4, .columnbit = ( 1 << 1 ), @@ -456,10 +456,10 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .eint = 4}, {.css_class = "core-number", .label = "×", - .letter = NULL, + .letter = "", .left = "[ ]", .right = "\" \"", - .below = NULL, + .below = "", .column = 0, .row = 4, .columnbit = ( 1 << 0 ), @@ -468,10 +468,10 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { {.css_class = "shift-left", .label = "⮢", - .letter = NULL, - .left = NULL, + .letter = "", + .left = "", .right = NULL, - .below = NULL, + .below = "", .column = 0, .row = 0, .columnbit = 0, @@ -479,10 +479,10 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .eint = 5}, {.css_class = "core-number", .label = "4", - .letter = NULL, + .letter = "", .left = "CALC", .right = "ALG", - .below = NULL, + .below = "", .column = 3, .row = 5, .columnbit = ( 1 << 3 ), @@ -490,10 +490,10 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .eint = 5}, {.css_class = "core-number", .label = "5", - .letter = NULL, + .letter = "", .left = "MATRICES", .right = "STAT", - .below = NULL, + .below = "", .column = 2, .row = 5, .columnbit = ( 1 << 2 ), @@ -501,10 +501,10 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .eint = 5}, {.css_class = "core-number", .label = "6", - .letter = NULL, + .letter = "", .left = "CONVERT", .right = "UNITS", - .below = NULL, + .below = "", .column = 1, .row = 5, .columnbit = ( 1 << 1 ), @@ -512,10 +512,10 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .eint = 5}, {.css_class = "core-number", .label = "-", - .letter = NULL, + .letter = "", .left = "( )", .right = "_", - .below = NULL, + .below = "", .column = 0, .row = 5, .columnbit = ( 1 << 0 ), @@ -524,10 +524,10 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { {.css_class = "shift-right", .label = "⮣", - .letter = NULL, - .left = NULL, + .letter = "", + .left = "", .right = NULL, - .below = NULL, + .below = "", .column = 0, .row = 0, .columnbit = 0, @@ -535,10 +535,10 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .eint = 6}, {.css_class = "core-number", .label = "1", - .letter = NULL, + .letter = "", .left = "ARITH", .right = "CMPLX", - .below = NULL, + .below = "", .column = 3, .row = 6, .columnbit = ( 1 << 3 ), @@ -546,10 +546,10 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .eint = 6}, {.css_class = "core-number", .label = "2", - .letter = NULL, + .letter = "", .left = "DEF", .right = "LIB", - .below = NULL, + .below = "", .column = 2, .row = 6, .columnbit = ( 1 << 2 ), @@ -557,10 +557,10 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .eint = 6}, {.css_class = "core-number", .label = "3", - .letter = NULL, + .letter = "", .left = "#", .right = "BASE", - .below = NULL, + .below = "", .column = 1, .row = 6, .columnbit = ( 1 << 1 ), @@ -568,10 +568,10 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .eint = 6}, {.css_class = "core-number", .label = "+", - .letter = NULL, + .letter = "", .left = "{ }", .right = "« »", - .below = NULL, + .below = "", .column = 0, .row = 6, .columnbit = ( 1 << 0 ), @@ -580,7 +580,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { {.css_class = "core", .label = "ON", - .letter = NULL, + .letter = "", .left = "CONT", .right = "OFF", .below = "CANCEL", @@ -591,10 +591,10 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .eint = 0}, {.css_class = "core-number", .label = "0", - .letter = NULL, + .letter = "", .left = "∞", .right = "→", - .below = NULL, + .below = "", .column = 3, .row = 7, .columnbit = ( 1 << 3 ), @@ -602,10 +602,10 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .eint = 7}, {.css_class = "core", .label = ".", - .letter = NULL, + .letter = "", .left = ": :", .right = "↲", - .below = NULL, + .below = "", .column = 2, .row = 7, .columnbit = ( 1 << 2 ), @@ -613,10 +613,10 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .eint = 7}, {.css_class = "core", .label = "SPC", - .letter = NULL, + .letter = "", .left = "𝚷", .right = ",", - .below = NULL, + .below = "", .column = 1, .row = 7, .columnbit = ( 1 << 1 ), @@ -624,10 +624,10 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = { .eint = 7}, {.css_class = "core", .label = "ENTER", - .letter = NULL, + .letter = "", .left = "ANS", .right = "→NUM", - .below = NULL, + .below = "", .column = 0, .row = 7, .columnbit = ( 1 << 0 ), @@ -1334,17 +1334,17 @@ static inline void _ui_load__newrplify_ui_keys() { // modify keys' labeling for newRPL for ( int i = 0; i < 6; i++ ) - ui_keys[ i ].left = NULL; + ui_keys[ i ].left = ""; for ( int i = 6; i < 9; i++ ) { ui_keys[ i ].label = ""; - ui_keys[ i ].left = NULL; + ui_keys[ i ].left = ""; ui_keys[ i ].right = NULL; } for ( int i = 10; i < 13; i++ ) { ui_keys[ i ].label = ""; - ui_keys[ i ].left = NULL; + ui_keys[ i ].left = ""; ui_keys[ i ].right = NULL; } @@ -1363,33 +1363,33 @@ static inline void _ui_load__newrplify_ui_keys() ui_keys[ 16 ].right = "PREV.M"; for ( int i = 17; i < 20; i++ ) { - ui_keys[ i ].left = NULL; + ui_keys[ i ].left = ""; ui_keys[ i ].right = NULL; } ui_keys[ 19 ].label = "MENU"; - ui_keys[ 20 ].left = NULL; + ui_keys[ 20 ].left = ""; for ( int i = 23; i < 26; i++ ) ui_keys[ i ].right = NULL; for ( int i = 31; i < 35; i++ ) - ui_keys[ i ].left = NULL; + ui_keys[ i ].left = ""; ui_keys[ 33 ].right = NULL; for ( int i = 37; i < 39; i++ ) { - ui_keys[ i ].left = NULL; + ui_keys[ i ].left = ""; ui_keys[ i ].right = NULL; } - ui_keys[ 43 ].left = NULL; + ui_keys[ 43 ].left = ""; - ui_keys[ 46 ].left = NULL; - ui_keys[ 46 ].below = NULL; + ui_keys[ 46 ].left = ""; + ui_keys[ 46 ].below = ""; - ui_keys[ 50 ].left = NULL; + ui_keys[ 50 ].left = ""; } static GtkWidget* _ui_load__create_annunciator_widget( x49gp_ui_t* ui, const char* label )