forked from Miroirs/x49gp
Compare commits
4 commits
0f9dffe8ea
...
a2f5b119bf
Author | SHA1 | Date | |
---|---|---|---|
|
a2f5b119bf | ||
|
3b8474337d | ||
|
3c38e3e46e | ||
|
540f06d9fe |
2 changed files with 99 additions and 103 deletions
201
src/x49gpng/ui.c
201
src/x49gpng/ui.c
|
@ -1424,30 +1424,6 @@ static gboolean react_to_key_event( GtkWidget* widget, GdkEventKey* event, gpoin
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int redraw_lcd( GtkWidget* widget, cairo_t* cr, gpointer user_data )
|
|
||||||
{
|
|
||||||
x49gp_t* x49gp = user_data;
|
|
||||||
x49gp_ui_t* ui = x49gp->ui;
|
|
||||||
|
|
||||||
cairo_set_source_surface( cr, ui->lcd_surface, 0, 0 );
|
|
||||||
cairo_paint( cr );
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int draw_lcd( GtkWidget* widget, GdkEventConfigure* event, gpointer user_data )
|
|
||||||
{
|
|
||||||
x49gp_t* x49gp = user_data;
|
|
||||||
x49gp_ui_t* ui = x49gp->ui;
|
|
||||||
|
|
||||||
if ( NULL != ui->lcd_surface )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
ui->lcd_surface = cairo_image_surface_create( CAIRO_FORMAT_RGB24, LCD_WIDTH, LCD_HEIGHT );
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean react_to_window_click( GtkWidget* widget, GdkEventButton* event, gpointer user_data )
|
static gboolean react_to_window_click( GtkWidget* widget, GdkEventButton* event, gpointer user_data )
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_X49GP_UI
|
#ifdef DEBUG_X49GP_UI
|
||||||
|
@ -1486,6 +1462,30 @@ static gboolean react_to_window_click( GtkWidget* widget, GdkEventButton* event,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int redraw_lcd( GtkWidget* widget, cairo_t* cr, gpointer user_data )
|
||||||
|
{
|
||||||
|
x49gp_t* x49gp = user_data;
|
||||||
|
x49gp_ui_t* ui = x49gp->ui;
|
||||||
|
|
||||||
|
cairo_set_source_surface( cr, ui->lcd_surface, 0, 0 );
|
||||||
|
cairo_paint( cr );
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int draw_lcd( GtkWidget* widget, GdkEventConfigure* event, gpointer user_data )
|
||||||
|
{
|
||||||
|
x49gp_t* x49gp = user_data;
|
||||||
|
x49gp_ui_t* ui = x49gp->ui;
|
||||||
|
|
||||||
|
if ( NULL != ui->lcd_surface )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
ui->lcd_surface = cairo_image_surface_create( CAIRO_FORMAT_RGB24, LCD_WIDTH, LCD_HEIGHT );
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static void do_quit( gpointer user_data, GtkWidget* widget, GdkEvent* event )
|
static void do_quit( gpointer user_data, GtkWidget* widget, GdkEvent* event )
|
||||||
{
|
{
|
||||||
x49gp_t* x49gp = user_data;
|
x49gp_t* x49gp = user_data;
|
||||||
|
@ -1722,92 +1722,89 @@ static int ui_load( x49gp_module_t* module, GKeyFile* keyfile )
|
||||||
if ( ui->calculator == UI_CALCULATOR_HP49GP_NEWRPL || ui->calculator == UI_CALCULATOR_HP50G_NEWRPL )
|
if ( ui->calculator == UI_CALCULATOR_HP49GP_NEWRPL || ui->calculator == UI_CALCULATOR_HP50G_NEWRPL )
|
||||||
_ui_load__newrplify_ui_keys();
|
_ui_load__newrplify_ui_keys();
|
||||||
|
|
||||||
for ( int i = 0; i < NB_KEYS; i++ ) {
|
int key_index = 0;
|
||||||
button = &ui->buttons[ i ];
|
for ( int row = 0; row < 10; row++ ) {
|
||||||
|
for ( int column = 0; column < ( ( row == 0 ) ? 6 : 5 ); column++ ) {
|
||||||
|
button = &ui->buttons[ key_index ];
|
||||||
|
button->x49gp = x49gp;
|
||||||
|
button->key = &ui_keys[ key_index ];
|
||||||
|
|
||||||
button->x49gp = x49gp;
|
button->button = gtk_button_new();
|
||||||
button->key = &ui_keys[ i ];
|
gtk_style_context_add_class( gtk_widget_get_style_context( button->button ), button->key->css_class );
|
||||||
|
gtk_widget_set_size_request( button->button, button->key->width, button->key->height );
|
||||||
|
gtk_widget_set_can_focus( button->button, false );
|
||||||
|
gtk_widget_add_events( button->button, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_LEAVE_NOTIFY_MASK );
|
||||||
|
g_signal_connect( G_OBJECT( button->button ), "button-press-event", G_CALLBACK( react_to_button_press ), button );
|
||||||
|
g_signal_connect( G_OBJECT( button->button ), "button-release-event", G_CALLBACK( react_to_button_release ), button );
|
||||||
|
g_signal_connect( G_OBJECT( button->button ), "leave-notify-event", G_CALLBACK( react_to_button_leave ), button );
|
||||||
|
|
||||||
button->button = gtk_button_new();
|
gtk_fixed_put( GTK_FIXED( keyboard_container ), button->button, button->key->x, KEYBOARD_PADDING + button->key->y );
|
||||||
gtk_widget_set_size_request( button->button, button->key->width, button->key->height );
|
|
||||||
gtk_widget_set_can_focus( button->button, false );
|
|
||||||
gtk_style_context_add_class( gtk_widget_get_style_context( button->button ), button->key->css_class );
|
|
||||||
|
|
||||||
button->box = gtk_event_box_new();
|
if ( button->key->label ) {
|
||||||
gtk_event_box_set_visible_window( GTK_EVENT_BOX( button->box ), true );
|
ui_label = gtk_label_new( NULL );
|
||||||
gtk_event_box_set_above_child( GTK_EVENT_BOX( button->box ), false );
|
gtk_style_context_add_class( gtk_widget_get_style_context( ui_label ), "label-key" );
|
||||||
gtk_container_add( GTK_CONTAINER( button->box ), button->button );
|
|
||||||
|
|
||||||
g_signal_connect( G_OBJECT( button->button ), "button-press-event", G_CALLBACK( react_to_button_press ), button );
|
gtk_label_set_use_markup( GTK_LABEL( ui_label ), true );
|
||||||
g_signal_connect( G_OBJECT( button->button ), "button-release-event", G_CALLBACK( react_to_button_release ), button );
|
gtk_label_set_markup( GTK_LABEL( ui_label ), button->key->label );
|
||||||
g_signal_connect( G_OBJECT( button->button ), "leave-notify-event", G_CALLBACK( react_to_button_leave ), button );
|
|
||||||
|
|
||||||
gtk_widget_add_events( button->button, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_LEAVE_NOTIFY_MASK );
|
gtk_container_add( GTK_CONTAINER( button->button ), ui_label );
|
||||||
|
|
||||||
gtk_widget_set_size_request( button->box, button->key->width, button->key->height );
|
|
||||||
gtk_fixed_put( GTK_FIXED( keyboard_container ), button->box, button->key->x, KEYBOARD_PADDING + button->key->y );
|
|
||||||
|
|
||||||
if ( button->key->label ) {
|
|
||||||
ui_label = gtk_label_new( NULL );
|
|
||||||
gtk_style_context_add_class( gtk_widget_get_style_context( ui_label ), "label-key" );
|
|
||||||
|
|
||||||
gtk_label_set_use_markup( GTK_LABEL( ui_label ), true );
|
|
||||||
gtk_label_set_markup( GTK_LABEL( ui_label ), button->key->label );
|
|
||||||
|
|
||||||
gtk_container_add( GTK_CONTAINER( button->button ), ui_label );
|
|
||||||
}
|
|
||||||
if ( button->key->left ) {
|
|
||||||
ui_left = gtk_label_new( NULL );
|
|
||||||
gtk_style_context_add_class( gtk_widget_get_style_context( ui_left ), "label-left" );
|
|
||||||
gtk_label_set_use_markup( GTK_LABEL( ui_left ), true );
|
|
||||||
gtk_label_set_markup( GTK_LABEL( ui_left ), button->key->left );
|
|
||||||
|
|
||||||
if ( button->key->right ) {
|
|
||||||
ui_right = gtk_label_new( NULL );
|
|
||||||
gtk_style_context_add_class( gtk_widget_get_style_context( ui_right ), "label-right" );
|
|
||||||
gtk_label_set_use_markup( GTK_LABEL( ui_right ), true );
|
|
||||||
gtk_label_set_markup( GTK_LABEL( ui_right ), button->key->right );
|
|
||||||
}
|
}
|
||||||
y = y2 = button->key->y - ( TINY_TEXT_HEIGHT + 2 );
|
if ( button->key->left ) {
|
||||||
if ( button->key->right ) {
|
ui_left = gtk_label_new( NULL );
|
||||||
x = button->key->x;
|
gtk_style_context_add_class( gtk_widget_get_style_context( ui_left ), "label-left" );
|
||||||
|
gtk_label_set_use_markup( GTK_LABEL( ui_left ), true );
|
||||||
|
gtk_label_set_markup( GTK_LABEL( ui_left ), button->key->left );
|
||||||
|
|
||||||
x2 = button->key->x + button->key->width - _tiny_text_width( button->key->right );
|
if ( button->key->right ) {
|
||||||
|
ui_right = gtk_label_new( NULL );
|
||||||
if ( _tiny_text_width( button->key->right ) + _tiny_text_width( button->key->left ) > button->key->width ) {
|
gtk_style_context_add_class( gtk_widget_get_style_context( ui_right ), "label-right" );
|
||||||
x -= ( ( _tiny_text_width( button->key->right ) + _tiny_text_width( button->key->left ) ) - button->key->width ) / 2;
|
gtk_label_set_use_markup( GTK_LABEL( ui_right ), true );
|
||||||
x2 += ( ( _tiny_text_width( button->key->right ) + _tiny_text_width( button->key->left ) ) - button->key->width ) / 2;
|
gtk_label_set_markup( GTK_LABEL( ui_right ), button->key->right );
|
||||||
}
|
}
|
||||||
|
y = y2 = button->key->y - ( TINY_TEXT_HEIGHT + 2 );
|
||||||
|
if ( button->key->right ) {
|
||||||
|
x = button->key->x;
|
||||||
|
|
||||||
gtk_fixed_put( GTK_FIXED( keyboard_container ), ui_left, x, KEYBOARD_PADDING + y );
|
x2 = button->key->x + button->key->width - _tiny_text_width( button->key->right );
|
||||||
gtk_fixed_put( GTK_FIXED( keyboard_container ), ui_right, x2, KEYBOARD_PADDING + y2 );
|
|
||||||
} else {
|
if ( _tiny_text_width( button->key->right ) + _tiny_text_width( button->key->left ) > button->key->width ) {
|
||||||
x = button->key->x + ( ( button->key->width - _tiny_text_width( button->key->left ) ) / 2 );
|
x -=
|
||||||
gtk_fixed_put( GTK_FIXED( keyboard_container ), ui_left, x, KEYBOARD_PADDING + y );
|
( ( _tiny_text_width( button->key->right ) + _tiny_text_width( button->key->left ) ) - button->key->width ) / 2;
|
||||||
|
x2 +=
|
||||||
|
( ( _tiny_text_width( button->key->right ) + _tiny_text_width( button->key->left ) ) - button->key->width ) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_fixed_put( GTK_FIXED( keyboard_container ), ui_left, x, KEYBOARD_PADDING + y );
|
||||||
|
gtk_fixed_put( GTK_FIXED( keyboard_container ), ui_right, x2, KEYBOARD_PADDING + y2 );
|
||||||
|
} else {
|
||||||
|
x = button->key->x + ( ( button->key->width - _tiny_text_width( button->key->left ) ) / 2 );
|
||||||
|
gtk_fixed_put( GTK_FIXED( keyboard_container ), ui_left, x, KEYBOARD_PADDING + y );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
if ( button->key->letter ) {
|
||||||
if ( button->key->letter ) {
|
ui_letter = gtk_label_new( NULL );
|
||||||
ui_letter = gtk_label_new( NULL );
|
gtk_style_context_add_class( gtk_widget_get_style_context( ui_letter ), "label-letter" );
|
||||||
gtk_style_context_add_class( gtk_widget_get_style_context( ui_letter ), "label-letter" );
|
gtk_label_set_use_markup( GTK_LABEL( ui_letter ), true );
|
||||||
gtk_label_set_use_markup( GTK_LABEL( ui_letter ), true );
|
gtk_label_set_markup( GTK_LABEL( ui_letter ), button->key->letter );
|
||||||
gtk_label_set_markup( GTK_LABEL( ui_letter ), button->key->letter );
|
|
||||||
|
|
||||||
x = button->key->x + button->key->width + ( TINY_TEXT_WIDTH / 2 );
|
x = button->key->x + button->key->width + ( TINY_TEXT_WIDTH / 2 );
|
||||||
y = button->key->y + button->key->height - ( TINY_TEXT_HEIGHT / 2 );
|
y = button->key->y + button->key->height - ( TINY_TEXT_HEIGHT / 2 );
|
||||||
gtk_fixed_put( GTK_FIXED( keyboard_container ), ui_letter, x, KEYBOARD_PADDING + y );
|
gtk_fixed_put( GTK_FIXED( keyboard_container ), ui_letter, x, KEYBOARD_PADDING + y );
|
||||||
}
|
}
|
||||||
if ( button->key->below ) {
|
if ( button->key->below ) {
|
||||||
ui_below = gtk_label_new( NULL );
|
ui_below = gtk_label_new( NULL );
|
||||||
gtk_style_context_add_class( gtk_widget_get_style_context( ui_below ), "label-below" );
|
gtk_style_context_add_class( gtk_widget_get_style_context( ui_below ), "label-below" );
|
||||||
gtk_label_set_use_markup( GTK_LABEL( ui_below ), true );
|
gtk_label_set_use_markup( GTK_LABEL( ui_below ), true );
|
||||||
gtk_label_set_markup( GTK_LABEL( ui_below ), button->key->below );
|
gtk_label_set_markup( GTK_LABEL( ui_below ), button->key->below );
|
||||||
|
|
||||||
x = button->key->x + ( ( button->key->width - _tiny_text_width( button->key->below ) ) / 2 );
|
x = button->key->x + ( ( button->key->width - _tiny_text_width( button->key->below ) ) / 2 );
|
||||||
y = button->key->y + button->key->height + 2;
|
y = button->key->y + button->key->height + 2;
|
||||||
gtk_fixed_put( GTK_FIXED( keyboard_container ), ui_below, x, KEYBOARD_PADDING + y );
|
gtk_fixed_put( GTK_FIXED( keyboard_container ), ui_below, x, KEYBOARD_PADDING + y );
|
||||||
|
}
|
||||||
|
|
||||||
|
key_index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Right-click menu
|
// Right-click menu
|
||||||
ui->menu = gtk_menu_new();
|
ui->menu = gtk_menu_new();
|
||||||
|
|
||||||
|
@ -1894,12 +1891,12 @@ void gui_update_lcd( x49gp_t* x49gp )
|
||||||
s3c2410_lcd_t* lcd = x49gp->s3c2410_lcd;
|
s3c2410_lcd_t* lcd = x49gp->s3c2410_lcd;
|
||||||
|
|
||||||
if ( lcd->lcdcon1 & 1 ) {
|
if ( lcd->lcdcon1 & 1 ) {
|
||||||
gtk_widget_set_opacity( ui->ui_ann_left, x49gp_get_pixel_color( lcd, 131, 1 ) > 0 ? 1 : 0 );
|
gtk_widget_set_opacity( ui->ui_ann_left, x49gp_get_pixel_color( lcd, 131, 1 ) );
|
||||||
gtk_widget_set_opacity( ui->ui_ann_right, x49gp_get_pixel_color( lcd, 131, 2 ) > 0 ? 1 : 0 );
|
gtk_widget_set_opacity( ui->ui_ann_right, x49gp_get_pixel_color( lcd, 131, 2 ) );
|
||||||
gtk_widget_set_opacity( ui->ui_ann_alpha, x49gp_get_pixel_color( lcd, 131, 3 ) > 0 ? 1 : 0 );
|
gtk_widget_set_opacity( ui->ui_ann_alpha, x49gp_get_pixel_color( lcd, 131, 3 ) );
|
||||||
gtk_widget_set_opacity( ui->ui_ann_battery, x49gp_get_pixel_color( lcd, 131, 4 ) > 0 ? 1 : 0 );
|
gtk_widget_set_opacity( ui->ui_ann_battery, x49gp_get_pixel_color( lcd, 131, 4 ) );
|
||||||
gtk_widget_set_opacity( ui->ui_ann_busy, x49gp_get_pixel_color( lcd, 131, 5 ) > 0 ? 1 : 0 );
|
gtk_widget_set_opacity( ui->ui_ann_busy, x49gp_get_pixel_color( lcd, 131, 5 ) );
|
||||||
gtk_widget_set_opacity( ui->ui_ann_io, x49gp_get_pixel_color( lcd, 131, 0 ) > 0 ? 1 : 0 );
|
gtk_widget_set_opacity( ui->ui_ann_io, x49gp_get_pixel_color( lcd, 131, 0 ) );
|
||||||
|
|
||||||
for ( int y = 0; y < ( LCD_HEIGHT / LCD_PIXEL_SCALE ); y++ )
|
for ( int y = 0; y < ( LCD_HEIGHT / LCD_PIXEL_SCALE ); y++ )
|
||||||
for ( int x = 0; x < ( LCD_WIDTH / LCD_PIXEL_SCALE ); x++ )
|
for ( int x = 0; x < ( LCD_WIDTH / LCD_PIXEL_SCALE ); x++ )
|
||||||
|
|
|
@ -58,7 +58,6 @@ typedef struct {
|
||||||
x49gp_t* x49gp;
|
x49gp_t* x49gp;
|
||||||
const x49gp_ui_key_t* key;
|
const x49gp_ui_key_t* key;
|
||||||
GtkWidget* button;
|
GtkWidget* button;
|
||||||
GtkWidget* box;
|
|
||||||
gboolean down;
|
gboolean down;
|
||||||
gboolean hold;
|
gboolean hold;
|
||||||
} x49gp_ui_button_t;
|
} x49gp_ui_button_t;
|
||||||
|
|
Loading…
Reference in a new issue