forked from Miroirs/x49gp
--font-size is more clear than text-scale
This commit is contained in:
parent
ed48563f14
commit
5df16bb28f
3 changed files with 80 additions and 40 deletions
|
@ -22,7 +22,8 @@ struct options opt = {
|
|||
.model = MODEL_50G,
|
||||
.newrpl = false,
|
||||
.name = NULL,
|
||||
.text_scale = 2,
|
||||
.verbose = false,
|
||||
.font_size = 12,
|
||||
.display_scale = 2,
|
||||
#if defined( __linux__ )
|
||||
.font = "urw gothic l",
|
||||
|
@ -95,6 +96,7 @@ static void print_config( void )
|
|||
fprintf( stdout, "-- Configuration file for x49gpng\n" );
|
||||
fprintf( stdout, "-- This is a comment\n" );
|
||||
|
||||
fprintf( stdout, "verbose = %s\n\n", opt.verbose ? "true" : "false" );
|
||||
fprintf( stdout, "name = \"%s\"", opt.name );
|
||||
fprintf( stdout, " -- this customize the title of the window\n" );
|
||||
|
||||
|
@ -112,7 +114,7 @@ static void print_config( void )
|
|||
fprintf( stdout, "newrpl_keyboard = %s", opt.newrpl ? "true" : "false" );
|
||||
fprintf( stdout, " -- when true this makes the keyboard labels more suited to newRPL use\n" );
|
||||
fprintf( stdout, "font = \"%s\"\n", opt.font );
|
||||
fprintf( stdout, "text_scale = %i\n", opt.text_scale );
|
||||
fprintf( stdout, "font_size = %i\n", opt.font_size );
|
||||
fprintf( stdout, "display_scale = %i\n", opt.display_scale );
|
||||
|
||||
fprintf( stdout, "--- End of saturnng configuration ----------------------------------------------\n" );
|
||||
|
@ -130,40 +132,43 @@ void config_init( char* progname, int argc, char* argv[] )
|
|||
bool do_reflash = false;
|
||||
bool do_reflash_full = false;
|
||||
|
||||
int clopt_verbose = -1;
|
||||
|
||||
char* clopt_name = NULL;
|
||||
char* clopt_font = NULL;
|
||||
int clopt_model = -1;
|
||||
int clopt_newrpl = -1;
|
||||
int clopt_text_scale = -1;
|
||||
int clopt_font_size = -1;
|
||||
int clopt_display_scale = -1;
|
||||
|
||||
int print_config_and_exit = false;
|
||||
|
||||
const char* optstring = "hrc:D:df:Fn:t:";
|
||||
struct option long_options[] = {
|
||||
{"help", no_argument, NULL, 'h' },
|
||||
{"print-config", no_argument, &print_config_and_exit, true},
|
||||
{"help", no_argument, NULL, 'h' },
|
||||
{"print-config", no_argument, &print_config_and_exit, true},
|
||||
{"verbose", no_argument, &clopt_verbose, true},
|
||||
|
||||
{"config", required_argument, NULL, 'c' },
|
||||
{"config", required_argument, NULL, 'c' },
|
||||
|
||||
{"state", required_argument, NULL, 1 },
|
||||
{"state", required_argument, NULL, 1 },
|
||||
|
||||
{"enable-debug", required_argument, NULL, 'D' },
|
||||
{"debug", no_argument, NULL, 'd' },
|
||||
{"reflash", required_argument, NULL, 'f' },
|
||||
{"reflash-full", no_argument, NULL, 'F' },
|
||||
{"reboot", no_argument, NULL, 'r' },
|
||||
{"enable-debug", required_argument, NULL, 'D' },
|
||||
{"debug", no_argument, NULL, 'd' },
|
||||
{"reflash", required_argument, NULL, 'f' },
|
||||
{"reflash-full", no_argument, NULL, 'F' },
|
||||
{"reboot", no_argument, NULL, 'r' },
|
||||
|
||||
{"50g", no_argument, NULL, 506 },
|
||||
{"49gp", no_argument, NULL, 496 },
|
||||
{"newrpl-keyboard", no_argument, &clopt_newrpl, true},
|
||||
{"name", required_argument, NULL, 'n' },
|
||||
{"text-scale", required_argument, NULL, 's' },
|
||||
{"display-scale", required_argument, NULL, 'S' },
|
||||
{"50g", no_argument, NULL, 506 },
|
||||
{"49gp", no_argument, NULL, 496 },
|
||||
{"newrpl-keyboard", no_argument, &clopt_newrpl, true},
|
||||
{"name", required_argument, NULL, 'n' },
|
||||
{"font-size", required_argument, NULL, 's' },
|
||||
{"display-scale", required_argument, NULL, 'S' },
|
||||
|
||||
{"font", required_argument, NULL, 't' },
|
||||
{"font", required_argument, NULL, 't' },
|
||||
|
||||
{0, 0, 0, 0 }
|
||||
{0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
while ( c != EOF ) {
|
||||
|
@ -182,7 +187,7 @@ void config_init( char* progname, int argc, char* argv[] )
|
|||
" --newrpl-keyboard label keyboard for newRPL\n"
|
||||
" -n --name[=<name>] set alternate UI name\n"
|
||||
" -t --font[=<fontname>] set alternate UI font\n"
|
||||
" -s --text-scale[=<X>] scale text by X (default: 2)\n"
|
||||
" -s --font-size[=<X>] scale text by X (default: 3)\n"
|
||||
" -S --display-scale[=<X>] scale LCD by X (default: 2)\n"
|
||||
" -D --enable-debug[=<port>] enable the debugger interface\n"
|
||||
" (default port: %u)\n"
|
||||
|
@ -235,7 +240,7 @@ void config_init( char* progname, int argc, char* argv[] )
|
|||
clopt_name = strdup( optarg );
|
||||
break;
|
||||
case 's':
|
||||
clopt_text_scale = atoi( optarg );
|
||||
clopt_font_size = atoi( optarg );
|
||||
break;
|
||||
case 'S':
|
||||
clopt_display_scale = atoi( optarg );
|
||||
|
@ -287,16 +292,18 @@ void config_init( char* progname, int argc, char* argv[] )
|
|||
lua_getglobal( config_lua_values, "font" );
|
||||
opt.font = strdup( luaL_optstring( config_lua_values, -1, opt.font ) );
|
||||
|
||||
lua_getglobal( config_lua_values, "text_scale" );
|
||||
opt.text_scale = luaL_optinteger( config_lua_values, -1, 1 );
|
||||
lua_getglobal( config_lua_values, "font_size" );
|
||||
opt.font_size = luaL_optinteger( config_lua_values, -1, opt.font_size );
|
||||
|
||||
lua_getglobal( config_lua_values, "display_scale" );
|
||||
opt.display_scale = luaL_optinteger( config_lua_values, -1, 2 );
|
||||
opt.display_scale = luaL_optinteger( config_lua_values, -1, opt.display_scale );
|
||||
}
|
||||
|
||||
/****************************************************/
|
||||
/* 2. treat command-line params which have priority */
|
||||
/****************************************************/
|
||||
if ( clopt_verbose != -1 )
|
||||
opt.verbose = clopt_verbose;
|
||||
if ( clopt_name != NULL )
|
||||
opt.name = strdup( clopt_name );
|
||||
if ( clopt_font != NULL )
|
||||
|
@ -305,15 +312,17 @@ void config_init( char* progname, int argc, char* argv[] )
|
|||
opt.model = clopt_model;
|
||||
if ( clopt_newrpl != -1 )
|
||||
opt.newrpl = clopt_newrpl;
|
||||
if ( clopt_text_scale != -1 )
|
||||
opt.text_scale = clopt_text_scale;
|
||||
if ( clopt_display_scale != -1 )
|
||||
if ( clopt_font_size > 0 )
|
||||
opt.font_size = clopt_font_size;
|
||||
if ( clopt_display_scale > 0 )
|
||||
opt.display_scale = clopt_display_scale;
|
||||
|
||||
if ( print_config_and_exit ) {
|
||||
print_config();
|
||||
exit( EXIT_SUCCESS );
|
||||
}
|
||||
if ( opt.verbose )
|
||||
print_config();
|
||||
|
||||
if ( !haz_config_file ) {
|
||||
fprintf( stderr, "\nConfiguration file %s doesn't seem to exist or is invalid!\n", opt.config_lua_filename );
|
||||
|
|
|
@ -28,8 +28,9 @@ struct options {
|
|||
|
||||
char* font;
|
||||
int display_scale;
|
||||
int text_scale;
|
||||
int font_size;
|
||||
char* config_lua_filename;
|
||||
bool verbose;
|
||||
};
|
||||
|
||||
extern struct options opt;
|
||||
|
|
|
@ -24,10 +24,10 @@
|
|||
|
||||
#define NB_KEYS 51
|
||||
|
||||
#define FONT_SIZE_SYMBOL ( 14 * opt.text_scale )
|
||||
#define FONT_SIZE_NUMBER ( 10 * opt.text_scale )
|
||||
#define FONT_SIZE_KEY ( 7 * opt.text_scale )
|
||||
#define FONT_SIZE_TINY ( 6 * opt.text_scale )
|
||||
#define FONT_SIZE_KEY opt.font_size
|
||||
#define FONT_SIZE_SYMBOL ( 2 * opt.font_size )
|
||||
#define FONT_SIZE_NUMBER ( ( int )( 1.5 * opt.font_size ) )
|
||||
#define FONT_SIZE_TINY ( ( int )( 0.75 * opt.font_size ) )
|
||||
|
||||
#define TINY_TEXT_HEIGHT ( FONT_SIZE_TINY + 2 )
|
||||
#define TINY_TEXT_WIDTH ( TINY_TEXT_HEIGHT / 2 )
|
||||
|
@ -36,14 +36,13 @@
|
|||
#define KB_NB_COLS_MENU 6
|
||||
#define KB_NB_COLS 5
|
||||
|
||||
#define KB_WIDTH_6_KEYS ( 36 * opt.text_scale )
|
||||
#define KB_WIDTH_5_KEYS ( 46 * opt.text_scale )
|
||||
#define KB_WIDTH_6_KEYS ( 3 * opt.font_size )
|
||||
#define KB_WIDTH_5_KEYS ( 4 * opt.font_size )
|
||||
|
||||
#define KB_HEIGHT_MENU_KEYS ( 11 * opt.text_scale )
|
||||
#define KB_HEIGHT_SMALL_KEYS ( 14 * opt.text_scale )
|
||||
#define KB_HEIGHT_BIG_KEYS ( 16 * opt.text_scale )
|
||||
#define KB_HEIGHT_MENU_KEYS ( 2 * opt.font_size )
|
||||
#define KB_HEIGHT_SMALL_KEYS ( ( int )( 1.5 * opt.font_size ) )
|
||||
#define KB_HEIGHT_BIG_KEYS ( 3 * opt.font_size )
|
||||
|
||||
#define KB_LINE_HEIGHT ( KB_HEIGHT_BIG_KEYS + ( 1.5 * ( TINY_TEXT_HEIGHT + 2 ) ) )
|
||||
#define KB_SPACING_KEYS TINY_TEXT_WIDTH
|
||||
#define KB_COLUMN_WIDTH_6_KEYS ( KB_WIDTH_6_KEYS + KB_SPACING_KEYS )
|
||||
#define KB_COLUMN_WIDTH_5_KEYS ( KB_WIDTH_5_KEYS + KB_SPACING_KEYS )
|
||||
|
@ -58,7 +57,7 @@
|
|||
|
||||
#define KEYBOARD_PADDING ( TINY_TEXT_HEIGHT + 2 )
|
||||
|
||||
#define WINDOW_WIDTH ( 300 )
|
||||
#define WINDOW_WIDTH ( 384 )
|
||||
|
||||
#define LCD_PADDING ( ( WINDOW_WIDTH - LCD_WIDTH ) / 2 )
|
||||
|
||||
|
@ -1713,6 +1712,37 @@ int gui_init( x49gp_t* x49gp )
|
|||
{
|
||||
x49gp_module_t* module;
|
||||
|
||||
if ( opt.verbose ) {
|
||||
fprintf( stderr,
|
||||
" FONT_SIZE_KEY = %i\n"
|
||||
" FONT_SIZE_SYMBOL = %i\n"
|
||||
" FONT_SIZE_NUMBER = %i\n"
|
||||
" FONT_SIZE_TINY = %i\n"
|
||||
" TINY_TEXT_HEIGHT = %i\n"
|
||||
" TINY_TEXT_WIDTH = %i\n"
|
||||
" KB_WIDTH_6_KEYS = %i\n"
|
||||
" KB_WIDTH_5_KEYS = %i\n"
|
||||
" KB_HEIGHT_MENU_KEYS = %i\n"
|
||||
" KB_HEIGHT_SMALL_KEYS = %i\n"
|
||||
" KB_HEIGHT_BIG_KEYS = %i\n"
|
||||
" KB_SPACING_KEYS = %i\n"
|
||||
" KB_COLUMN_WIDTH_6_KEYS = %i\n"
|
||||
" KB_COLUMN_WIDTH_5_KEYS = %i\n"
|
||||
" ANNUNCIATOR_WIDTH = %i\n"
|
||||
" ANNUNCIATOR_HEIGHT = %i\n"
|
||||
" ANNUNCIATORS_HEIGHT = %i\n"
|
||||
" LCD_PIXEL_SCALE = %i\n"
|
||||
" LCD_WIDTH = %i\n"
|
||||
" LCD_HEIGHT = %i\n"
|
||||
" KEYBOARD_PADDING = %i\n"
|
||||
" WINDOW_WIDTH = %i\n"
|
||||
" LCD_PADDING = %i\n",
|
||||
FONT_SIZE_KEY, FONT_SIZE_SYMBOL, FONT_SIZE_NUMBER, FONT_SIZE_TINY, TINY_TEXT_HEIGHT, TINY_TEXT_WIDTH, KB_WIDTH_6_KEYS,
|
||||
KB_WIDTH_5_KEYS, KB_HEIGHT_MENU_KEYS, KB_HEIGHT_SMALL_KEYS, KB_HEIGHT_BIG_KEYS, KB_SPACING_KEYS, KB_COLUMN_WIDTH_6_KEYS,
|
||||
KB_COLUMN_WIDTH_5_KEYS, ANNUNCIATOR_WIDTH, ANNUNCIATOR_HEIGHT, ANNUNCIATORS_HEIGHT, LCD_PIXEL_SCALE, LCD_WIDTH, LCD_HEIGHT,
|
||||
KEYBOARD_PADDING, WINDOW_WIDTH, LCD_PADDING );
|
||||
}
|
||||
|
||||
if ( x49gp_module_init( x49gp, "gui", ui_init, ui_exit, ui_reset, ui_load, ui_save, NULL, &module ) )
|
||||
return -1;
|
||||
|
||||
|
|
Loading…
Reference in a new issue