forked from Miroirs/x49gp
Compare commits
2 commits
e58bd6b9ca
...
2a586e0449
Author | SHA1 | Date | |
---|---|---|---|
|
2a586e0449 | ||
|
1f118799db |
1 changed files with 89 additions and 85 deletions
174
src/x49gpng/ui.c
174
src/x49gpng/ui.c
|
@ -818,79 +818,79 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
char* css_global_49gp = ".main-window {"
|
char* css_global_49gp = ".main-window {"
|
||||||
" font-weight: bold;"
|
" font-weight: bold;"
|
||||||
"}"
|
"}"
|
||||||
"window {"
|
"window {"
|
||||||
" background-color: #f0e68c;"
|
" background-color: #f0e68c;"
|
||||||
"}"
|
"}"
|
||||||
".annunciator {"
|
".annunciator {"
|
||||||
" padding: 0px;"
|
" padding: 0px;"
|
||||||
" font-size: 12px;"
|
" font-size: 12px;"
|
||||||
" color: #080808;"
|
" color: #080808;"
|
||||||
"}"
|
"}"
|
||||||
".annunciators-container {"
|
".annunciators-container {"
|
||||||
" background-color: #abd2b4;"
|
" background-color: #abd2b4;"
|
||||||
"}"
|
"}"
|
||||||
"button {"
|
"button {"
|
||||||
" background-image: none;"
|
" background-image: none;"
|
||||||
" padding: 0px;"
|
" padding: 0px;"
|
||||||
"}"
|
"}"
|
||||||
"button:hover {"
|
"button:hover {"
|
||||||
" border: 1px solid yellow;"
|
" border: 1px solid yellow;"
|
||||||
"}"
|
"}"
|
||||||
".button-menu {"
|
".button-menu {"
|
||||||
" background-color: #a9a9a9;"
|
" background-color: #a9a9a9;"
|
||||||
"}"
|
"}"
|
||||||
".button-function {"
|
".button-function {"
|
||||||
" background-color: #696969;"
|
" background-color: #696969;"
|
||||||
"}"
|
"}"
|
||||||
".button-arrow {"
|
".button-arrow {"
|
||||||
" background-color: #e0e0e0;"
|
" background-color: #e0e0e0;"
|
||||||
"}"
|
"}"
|
||||||
".button-alpha {"
|
".button-alpha {"
|
||||||
" background-color: #fae82c;"
|
" background-color: #fae82c;"
|
||||||
"}"
|
"}"
|
||||||
".button-arrow .label, .button-alpha .label {"
|
".button-arrow .label, .button-alpha .label {"
|
||||||
" color: #080808;"
|
" color: #080808;"
|
||||||
"}"
|
"}"
|
||||||
".button-arrow .label {"
|
".button-arrow .label {"
|
||||||
" font-size: 24px;"
|
" font-size: 24px;"
|
||||||
"}"
|
"}"
|
||||||
".button-shift-left {"
|
".button-shift-left {"
|
||||||
" background-color: #4060a4;"
|
" background-color: #4060a4;"
|
||||||
"}"
|
"}"
|
||||||
".button-shift-right {"
|
".button-shift-right {"
|
||||||
" background-color: #8e2518;"
|
" background-color: #8e2518;"
|
||||||
"}"
|
"}"
|
||||||
".button-shift-left .label, .button-shift-right .label {"
|
".button-shift-left .label, .button-shift-right .label {"
|
||||||
" font-size: 28px;"
|
" font-size: 28px;"
|
||||||
" color: #f5f5f5;"
|
" color: #f5f5f5;"
|
||||||
"}"
|
"}"
|
||||||
".button-core, .button-core-number {"
|
".button-core, .button-core-number {"
|
||||||
" background-color: #080808;"
|
" background-color: #080808;"
|
||||||
"}"
|
"}"
|
||||||
".button-core-number .label {"
|
".button-core-number .label {"
|
||||||
" font-size: 20px;"
|
" font-size: 20px;"
|
||||||
"}"
|
"}"
|
||||||
".label {"
|
".label {"
|
||||||
" font-size: 12px;"
|
" font-size: 12px;"
|
||||||
" color: #ffffff;"
|
" color: #ffffff;"
|
||||||
"}"
|
"}"
|
||||||
".label-left {"
|
".label-left {"
|
||||||
" font-size: 8px;"
|
" font-size: 8px;"
|
||||||
" color: #4060a4;"
|
" color: #4060a4;"
|
||||||
"}"
|
"}"
|
||||||
".label-right {"
|
".label-right {"
|
||||||
" font-size: 8px;"
|
" font-size: 8px;"
|
||||||
" color: #c06e60;"
|
" color: #c06e60;"
|
||||||
"}"
|
"}"
|
||||||
".label-below {"
|
".label-below {"
|
||||||
" font-size: 8px;"
|
" font-size: 8px;"
|
||||||
" color: #4060a4;"
|
" color: #4060a4;"
|
||||||
"}"
|
"}"
|
||||||
".label-letter {"
|
".label-letter {"
|
||||||
" font-size: 8px;"
|
" font-size: 8px;"
|
||||||
" color: #fae82c;"
|
" color: #fae82c;"
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
char* css_global_50g = "* {"
|
char* css_global_50g = "* {"
|
||||||
|
@ -983,6 +983,14 @@ static inline int _tiny_text_width( const char* text )
|
||||||
|
|
||||||
static int _tiny_text_height = 10;
|
static int _tiny_text_height = 10;
|
||||||
|
|
||||||
|
static void key_to_button( GtkWidget* button, bool is_press )
|
||||||
|
{
|
||||||
|
GdkEventButton event = { .type = GDK_BUTTON_PRESS, .state = 0 };
|
||||||
|
static gboolean unused_but_needed_return_value;
|
||||||
|
g_signal_emit_by_name( GTK_BUTTON( button ), is_press ? "button-press-event" : "button-release-event", &event,
|
||||||
|
&unused_but_needed_return_value );
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean react_to_button_press( GtkWidget* widget, GdkEventButton* event, gpointer user_data )
|
static gboolean react_to_button_press( GtkWidget* widget, GdkEventButton* event, gpointer user_data )
|
||||||
{
|
{
|
||||||
x49gp_ui_button_t* button = user_data;
|
x49gp_ui_button_t* button = user_data;
|
||||||
|
@ -1008,7 +1016,7 @@ static gboolean react_to_button_press( GtkWidget* widget, GdkEventButton* event,
|
||||||
button->hold = true;
|
button->hold = true;
|
||||||
if ( button->down )
|
if ( button->down )
|
||||||
return false;
|
return false;
|
||||||
gtk_button_pressed( GTK_BUTTON( button->button ) );
|
key_to_button( button->button, true );
|
||||||
button->down = true;
|
button->down = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -1032,7 +1040,7 @@ static void ui_release_button( x49gp_ui_button_t* button, x49gp_ui_button_t* cau
|
||||||
{
|
{
|
||||||
x49gp_t* x49gp = button->x49gp;
|
x49gp_t* x49gp = button->x49gp;
|
||||||
const x49gp_ui_key_t* key = button->key;
|
const x49gp_ui_key_t* key = button->key;
|
||||||
GtkButton* gtkbutton = GTK_BUTTON( button->button );
|
/* GtkButton* gtkbutton = GTK_BUTTON( button->button ); */
|
||||||
|
|
||||||
/* #ifdef DEBUG_X49GP_UI */
|
/* #ifdef DEBUG_X49GP_UI */
|
||||||
/* printf( "%s: button %u: col %u, row %u, eint %u\n", __FUNCTION__, event->button, button->key->column, button->key->row, */
|
/* printf( "%s: button %u: col %u, row %u, eint %u\n", __FUNCTION__, event->button, button->key->column, button->key->row, */
|
||||||
|
@ -1044,7 +1052,7 @@ static void ui_release_button( x49gp_ui_button_t* button, x49gp_ui_button_t* cau
|
||||||
|
|
||||||
/* if ( button != cause ) */
|
/* if ( button != cause ) */
|
||||||
/* gtkbutton->in_button = false; */
|
/* gtkbutton->in_button = false; */
|
||||||
gtk_button_released( gtkbutton );
|
key_to_button( button->button, false );
|
||||||
|
|
||||||
if ( key->rowbit )
|
if ( key->rowbit )
|
||||||
s3c2410_io_port_g_update( x49gp, key->column, key->row, key->columnbit, key->rowbit, 0 );
|
s3c2410_io_port_g_update( x49gp, key->column, key->row, key->columnbit, key->rowbit, 0 );
|
||||||
|
@ -1140,11 +1148,9 @@ static gboolean react_to_focus_lost( GtkWidget* widget, GdkEventFocus* event, gp
|
||||||
|
|
||||||
static void ui_open_file_dialog( x49gp_t* x49gp, const char* prompt, GtkFileChooserAction action, char** filename )
|
static void ui_open_file_dialog( x49gp_t* x49gp, const char* prompt, GtkFileChooserAction action, char** filename )
|
||||||
{
|
{
|
||||||
GtkWidget* dialog;
|
|
||||||
x49gp_ui_t* ui = x49gp->ui;
|
x49gp_ui_t* ui = x49gp->ui;
|
||||||
|
GtkWidget* dialog = gtk_file_chooser_dialog_new( prompt, GTK_WINDOW( ui->window ), action, "_Cancel", GTK_RESPONSE_CANCEL, "_Open",
|
||||||
dialog = gtk_file_chooser_dialog_new( prompt, GTK_WINDOW( ui->window ), action, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN,
|
GTK_RESPONSE_ACCEPT, NULL );
|
||||||
GTK_RESPONSE_ACCEPT, NULL );
|
|
||||||
|
|
||||||
gtk_file_chooser_set_local_only( GTK_FILE_CHOOSER( dialog ), true );
|
gtk_file_chooser_set_local_only( GTK_FILE_CHOOSER( dialog ), true );
|
||||||
gtk_file_chooser_set_select_multiple( GTK_FILE_CHOOSER( dialog ), false );
|
gtk_file_chooser_set_select_multiple( GTK_FILE_CHOOSER( dialog ), false );
|
||||||
|
@ -1485,13 +1491,13 @@ static gboolean react_to_key_event( GtkWidget* widget, GdkEventKey* event, gpoin
|
||||||
bev.type = GDK_BUTTON_PRESS;
|
bev.type = GDK_BUTTON_PRESS;
|
||||||
react_to_button_press( button->button, &bev, button );
|
react_to_button_press( button->button, &bev, button );
|
||||||
/* GTK_BUTTON( button->button )->in_button = true; */
|
/* GTK_BUTTON( button->button )->in_button = true; */
|
||||||
gtk_button_pressed( GTK_BUTTON( button->button ) );
|
key_to_button( button->button, true );
|
||||||
/* GTK_BUTTON( button->button )->in_button = save_in; */
|
/* GTK_BUTTON( button->button )->in_button = save_in; */
|
||||||
break;
|
break;
|
||||||
case GDK_KEY_RELEASE:
|
case GDK_KEY_RELEASE:
|
||||||
bev.type = GDK_BUTTON_RELEASE;
|
bev.type = GDK_BUTTON_RELEASE;
|
||||||
/* GTK_BUTTON( button->button )->in_button = true; */
|
/* GTK_BUTTON( button->button )->in_button = true; */
|
||||||
gtk_button_released( GTK_BUTTON( button->button ) );
|
key_to_button( button->button, false );
|
||||||
/* GTK_BUTTON( button->button )->in_button = save_in; */
|
/* GTK_BUTTON( button->button )->in_button = save_in; */
|
||||||
react_to_button_release( button->button, &bev, button );
|
react_to_button_release( button->button, &bev, button );
|
||||||
break;
|
break;
|
||||||
|
@ -1502,15 +1508,13 @@ static gboolean react_to_key_event( GtkWidget* widget, GdkEventKey* event, gpoin
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int redraw_lcd( GtkWidget* widget, GdkEventExpose* event, gpointer user_data )
|
static int redraw_lcd( GtkWidget* widget, cairo_t* cr, gpointer user_data )
|
||||||
{
|
{
|
||||||
x49gp_t* x49gp = user_data;
|
x49gp_t* x49gp = user_data;
|
||||||
x49gp_ui_t* ui = x49gp->ui;
|
x49gp_ui_t* ui = x49gp->ui;
|
||||||
|
|
||||||
cairo_t* cr = gdk_cairo_create( gtk_widget_get_window( widget ) );
|
|
||||||
cairo_set_source_surface( cr, ui->lcd_surface, 0, 0 );
|
cairo_set_source_surface( cr, ui->lcd_surface, 0, 0 );
|
||||||
cairo_paint( cr );
|
cairo_paint( cr );
|
||||||
cairo_destroy( cr );
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue