forked from Miroirs/x49gp
(WIP) cairo'fied annunciators
This commit is contained in:
parent
6148325b13
commit
0d884c930e
3 changed files with 237 additions and 301 deletions
|
@ -292,46 +292,41 @@ void x49gp_draw_rectangle( GdkPixmap* target, int x, int y, int w, int h, GdkCol
|
|||
cairo_destroy( cr );
|
||||
}
|
||||
|
||||
void x49gp_draw_surface( GdkPixmap* target, cairo_surface_t* surface, int x, int y, int w, int h, GdkColor* color )
|
||||
{
|
||||
cairo_t* cr = gdk_cairo_create( target );
|
||||
|
||||
cairo_set_source_rgb( cr, color->red / 65535.0, color->green / 65535.0, color->blue / 65535.0 );
|
||||
cairo_mask_surface( cr, surface, x, y );
|
||||
|
||||
cairo_destroy( cr );
|
||||
}
|
||||
|
||||
void x49gp_lcd_update( x49gp_t* x49gp )
|
||||
{
|
||||
x49gp_ui_t* ui = x49gp->ui;
|
||||
s3c2410_lcd_t* lcd = x49gp->s3c2410_lcd;
|
||||
// cairo_t* cr;
|
||||
|
||||
gdk_draw_drawable( ui->lcd_pixmap, gtk_widget_get_style( ui->window )->bg_gc[ 0 ], ui->bg_pixmap, ui->lcd_x_offset, ui->lcd_y_offset, 0,
|
||||
0, ui->lcd_width, ui->lcd_height );
|
||||
|
||||
if ( lcd->lcdcon1 & 1 ) {
|
||||
int color;
|
||||
GdkColor color;
|
||||
|
||||
color = x49gp_get_pixel_color( lcd, 131, 1 );
|
||||
gdk_gc_set_rgb_fg_color( ui->ann_left_gc, &( ui->colors[ UI_COLOR_GRAYSCALE_0 + color ] ) );
|
||||
gdk_draw_rectangle( ui->lcd_pixmap, ui->ann_left_gc, true, 11, 0, 15, 12 );
|
||||
color = ui->colors[ UI_COLOR_GRAYSCALE_0 + x49gp_get_pixel_color( lcd, 131, 1 ) ];
|
||||
x49gp_draw_surface( ui->lcd_pixmap, ui->ann_left_surface, 11, 0, 15, 12, &color );
|
||||
|
||||
/* cr = gdk_cairo_create( ui->ann_left ); */
|
||||
/* gdk_cairo_set_source_pixbuf( cr, ui->lcd_pixmap, 11, 0 ); */
|
||||
/* cairo_paint( cr ); */
|
||||
/* cairo_destroy( cr ); */
|
||||
color = ui->colors[ UI_COLOR_GRAYSCALE_0 + x49gp_get_pixel_color( lcd, 131, 2 ) ];
|
||||
x49gp_draw_surface( ui->lcd_pixmap, ui->ann_right_surface, 56, 0, 15, 12, &color );
|
||||
|
||||
color = x49gp_get_pixel_color( lcd, 131, 2 );
|
||||
gdk_gc_set_rgb_fg_color( ui->ann_right_gc, &( ui->colors[ UI_COLOR_GRAYSCALE_0 + color ] ) );
|
||||
gdk_draw_rectangle( ui->lcd_pixmap, ui->ann_right_gc, true, 56, 0, 15, 12 );
|
||||
color = ui->colors[ UI_COLOR_GRAYSCALE_0 + x49gp_get_pixel_color( lcd, 131, 3 ) ];
|
||||
x49gp_draw_surface( ui->lcd_pixmap, ui->ann_alpha_surface, 101, 0, 15, 12, &color );
|
||||
|
||||
color = x49gp_get_pixel_color( lcd, 131, 3 );
|
||||
gdk_gc_set_rgb_fg_color( ui->ann_alpha_gc, &( ui->colors[ UI_COLOR_GRAYSCALE_0 + color ] ) );
|
||||
gdk_draw_rectangle( ui->lcd_pixmap, ui->ann_alpha_gc, true, 101, 0, 15, 12 );
|
||||
color = ui->colors[ UI_COLOR_GRAYSCALE_0 + x49gp_get_pixel_color( lcd, 131, 4 ) ];
|
||||
x49gp_draw_surface( ui->lcd_pixmap, ui->ann_battery_surface, 146, 0, 15, 12, &color );
|
||||
|
||||
color = x49gp_get_pixel_color( lcd, 131, 4 );
|
||||
gdk_gc_set_rgb_fg_color( ui->ann_battery_gc, &( ui->colors[ UI_COLOR_GRAYSCALE_0 + color ] ) );
|
||||
gdk_draw_rectangle( ui->lcd_pixmap, ui->ann_battery_gc, true, 146, 0, 15, 12 );
|
||||
color = ui->colors[ UI_COLOR_GRAYSCALE_0 + x49gp_get_pixel_color( lcd, 131, 5 ) ];
|
||||
x49gp_draw_surface( ui->lcd_pixmap, ui->ann_busy_surface, 191, 0, 15, 12, &color );
|
||||
|
||||
color = x49gp_get_pixel_color( lcd, 131, 5 );
|
||||
gdk_gc_set_rgb_fg_color( ui->ann_busy_gc, &( ui->colors[ UI_COLOR_GRAYSCALE_0 + color ] ) );
|
||||
gdk_draw_rectangle( ui->lcd_pixmap, ui->ann_busy_gc, true, 191, 0, 15, 12 );
|
||||
|
||||
color = x49gp_get_pixel_color( lcd, 131, 0 );
|
||||
gdk_gc_set_rgb_fg_color( ui->ann_io_gc, &( ui->colors[ UI_COLOR_GRAYSCALE_0 + color ] ) );
|
||||
gdk_draw_rectangle( ui->lcd_pixmap, ui->ann_io_gc, true, 236, 0, 15, 12 );
|
||||
color = ui->colors[ UI_COLOR_GRAYSCALE_0 + x49gp_get_pixel_color( lcd, 131, 0 ) ];
|
||||
x49gp_draw_surface( ui->lcd_pixmap, ui->ann_io_surface, 236, 0, 15, 12, &color );
|
||||
|
||||
for ( int y = 0; y < ( ( ui->lcd_height - ui->lcd_annunciators_height ) / LCD_PIXEL_SCALE ); y++ )
|
||||
for ( int x = 0; x < ( ui->lcd_width / LCD_PIXEL_SCALE ); x++ )
|
||||
|
|
|
@ -5666,9 +5666,6 @@ static void x49gp_button_realize( GtkWidget* widget, gpointer user_data )
|
|||
|
||||
button->pixmap = gdk_pixmap_new( gtk_widget_get_style( widget )->bg_pixmap[ 0 ], w, h, -1 );
|
||||
|
||||
gdk_draw_drawable( button->pixmap, gtk_widget_get_style( widget )->black_gc, gtk_widget_get_style( widget )->bg_pixmap[ 0 ], xoffset,
|
||||
yoffset, 0, 0, button->key->width, button->key->height );
|
||||
|
||||
xoffset += 2;
|
||||
yoffset += 2;
|
||||
w -= 4;
|
||||
|
@ -5689,7 +5686,8 @@ static void x49gp_button_realize( GtkWidget* widget, gpointer user_data )
|
|||
cairo_stroke( cr );
|
||||
#endif
|
||||
|
||||
cairo_set_source_rgb( cr, ui->colors[key->bg_color].red / 65535.0, ui->colors[key->bg_color].green / 65535.0, ui->colors[key->bg_color].blue / 65535.0 );
|
||||
cairo_set_source_rgb( cr, ui->colors[ key->bg_color ].red / 65535.0, ui->colors[ key->bg_color ].green / 65535.0,
|
||||
ui->colors[ key->bg_color ].blue / 65535.0 );
|
||||
cairo_set_line_width( cr, 1.0 );
|
||||
cairo_move_to( cr, xoffset, yoffset );
|
||||
cairo_line_to( cr, xoffset + w - 1, yoffset );
|
||||
|
@ -5762,71 +5760,21 @@ static int x49gp_lcd_configure_event( GtkWidget* widget, GdkEventConfigure* even
|
|||
if ( NULL != ui->lcd_pixmap )
|
||||
return false;
|
||||
|
||||
ui->ann_left =
|
||||
gdk_bitmap_create_from_data( gtk_widget_get_window( ui->lcd_canvas ), ( char* )ann_left_bits, ann_left_width, ann_left_height );
|
||||
ui->ann_right =
|
||||
gdk_bitmap_create_from_data( gtk_widget_get_window( ui->lcd_canvas ), ( char* )ann_right_bits, ann_right_width, ann_right_height );
|
||||
ui->ann_alpha =
|
||||
gdk_bitmap_create_from_data( gtk_widget_get_window( ui->lcd_canvas ), ( char* )ann_alpha_bits, ann_alpha_width, ann_alpha_height );
|
||||
ui->ann_battery = gdk_bitmap_create_from_data( gtk_widget_get_window( ui->lcd_canvas ), ( char* )ann_battery_bits, ann_battery_width,
|
||||
ann_battery_height );
|
||||
ui->ann_busy =
|
||||
gdk_bitmap_create_from_data( gtk_widget_get_window( ui->lcd_canvas ), ( char* )ann_busy_bits, ann_busy_width, ann_busy_height );
|
||||
ui->ann_io = gdk_bitmap_create_from_data( gtk_widget_get_window( ui->lcd_canvas ), ( char* )ann_io_bits, ann_io_width, ann_io_height );
|
||||
|
||||
ui->ann_left_gc = gdk_gc_new( gtk_widget_get_window( ui->lcd_canvas ) );
|
||||
gdk_gc_copy( ui->ann_left_gc, gtk_widget_get_style( widget )->black_gc );
|
||||
gdk_gc_set_ts_origin( ui->ann_left_gc, 11, 0 );
|
||||
gdk_gc_set_stipple( ui->ann_left_gc, ui->ann_left );
|
||||
gdk_gc_set_fill( ui->ann_left_gc, GDK_STIPPLED );
|
||||
|
||||
ui->ann_right_gc = gdk_gc_new( gtk_widget_get_window( ui->lcd_canvas ) );
|
||||
gdk_gc_copy( ui->ann_right_gc, gtk_widget_get_style( widget )->black_gc );
|
||||
gdk_gc_set_ts_origin( ui->ann_right_gc, 56, 0 );
|
||||
gdk_gc_set_stipple( ui->ann_right_gc, ui->ann_right );
|
||||
gdk_gc_set_fill( ui->ann_right_gc, GDK_STIPPLED );
|
||||
|
||||
ui->ann_alpha_gc = gdk_gc_new( gtk_widget_get_window( ui->lcd_canvas ) );
|
||||
gdk_gc_copy( ui->ann_alpha_gc, gtk_widget_get_style( widget )->black_gc );
|
||||
gdk_gc_set_ts_origin( ui->ann_alpha_gc, 101, 0 );
|
||||
gdk_gc_set_stipple( ui->ann_alpha_gc, ui->ann_alpha );
|
||||
gdk_gc_set_fill( ui->ann_alpha_gc, GDK_STIPPLED );
|
||||
|
||||
ui->ann_battery_gc = gdk_gc_new( gtk_widget_get_window( ui->lcd_canvas ) );
|
||||
gdk_gc_copy( ui->ann_battery_gc, gtk_widget_get_style( widget )->black_gc );
|
||||
gdk_gc_set_ts_origin( ui->ann_battery_gc, 146, 0 );
|
||||
gdk_gc_set_stipple( ui->ann_battery_gc, ui->ann_battery );
|
||||
gdk_gc_set_fill( ui->ann_battery_gc, GDK_STIPPLED );
|
||||
|
||||
ui->ann_busy_gc = gdk_gc_new( gtk_widget_get_window( ui->lcd_canvas ) );
|
||||
gdk_gc_copy( ui->ann_busy_gc, gtk_widget_get_style( widget )->black_gc );
|
||||
gdk_gc_set_ts_origin( ui->ann_busy_gc, 191, 0 );
|
||||
gdk_gc_set_stipple( ui->ann_busy_gc, ui->ann_busy );
|
||||
gdk_gc_set_fill( ui->ann_busy_gc, GDK_STIPPLED );
|
||||
|
||||
ui->ann_io_gc = gdk_gc_new( gtk_widget_get_window( ui->lcd_canvas ) );
|
||||
gdk_gc_copy( ui->ann_io_gc, gtk_widget_get_style( widget )->black_gc );
|
||||
gdk_gc_set_ts_origin( ui->ann_io_gc, 236, 0 );
|
||||
gdk_gc_set_stipple( ui->ann_io_gc, ui->ann_io );
|
||||
gdk_gc_set_fill( ui->ann_io_gc, GDK_STIPPLED );
|
||||
ui->ann_left_surface = cairo_image_surface_create_for_data( ann_left_bits, CAIRO_FORMAT_A1, ann_left_width, ann_left_height,
|
||||
cairo_format_stride_for_width( CAIRO_FORMAT_A1, ann_left_width ) );
|
||||
ui->ann_right_surface = cairo_image_surface_create_for_data( ann_right_bits, CAIRO_FORMAT_A1, ann_right_width, ann_right_height,
|
||||
cairo_format_stride_for_width( CAIRO_FORMAT_A1, ann_right_width ) );
|
||||
ui->ann_alpha_surface = cairo_image_surface_create_for_data( ann_alpha_bits, CAIRO_FORMAT_A1, ann_alpha_width, ann_alpha_height,
|
||||
cairo_format_stride_for_width( CAIRO_FORMAT_A1, ann_alpha_width ) );
|
||||
ui->ann_battery_surface = cairo_image_surface_create_for_data( ann_battery_bits, CAIRO_FORMAT_A1, ann_battery_width, ann_battery_height,
|
||||
cairo_format_stride_for_width( CAIRO_FORMAT_A1, ann_battery_width ) );
|
||||
ui->ann_busy_surface = cairo_image_surface_create_for_data( ann_busy_bits, CAIRO_FORMAT_A1, ann_busy_width, ann_busy_height,
|
||||
cairo_format_stride_for_width( CAIRO_FORMAT_A1, ann_busy_width ) );
|
||||
ui->ann_io_surface = cairo_image_surface_create_for_data( ann_io_bits, CAIRO_FORMAT_A1, ann_io_width, ann_io_height,
|
||||
cairo_format_stride_for_width( CAIRO_FORMAT_A1, ann_io_width ) );
|
||||
|
||||
ui->lcd_pixmap = gdk_pixmap_new( gtk_widget_get_window( ui->lcd_canvas ), ui->lcd_width, ui->lcd_height, -1 );
|
||||
|
||||
#if DEBUG_LAYOUT /* Debug Symbols on LCD screen ;) */
|
||||
{
|
||||
cairo_t* cr;
|
||||
|
||||
cr = gdk_cairo_create( ui->bg_pixmap );
|
||||
cairo_set_line_cap( cr, CAIRO_LINE_CAP_BUTT );
|
||||
cairo_set_line_join( cr, CAIRO_LINE_JOIN_MITER );
|
||||
|
||||
x49gp_ui_draw_text( cr, >k_widget_get_style( widget )->black, opt.font, 100.0, 1.0, ui->lcd_x_offset + 10, ui->lcd_y_offset + 160,
|
||||
1, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD, "\\arrowleftdblfull" );
|
||||
|
||||
cairo_destroy( cr );
|
||||
}
|
||||
#endif
|
||||
|
||||
gdk_draw_drawable( ui->lcd_pixmap, gtk_widget_get_style( widget )->black_gc, ui->bg_pixmap, ui->lcd_x_offset, ui->lcd_y_offset, 0, 0,
|
||||
ui->lcd_width, ui->lcd_height );
|
||||
|
||||
|
@ -6087,21 +6035,21 @@ static int gui_load( x49gp_module_t* module, GKeyFile* keyfile )
|
|||
break;
|
||||
}
|
||||
|
||||
/* Load faceplate base texture into faceplate_texture */
|
||||
/* Load faceplate base texture */
|
||||
GError* gerror = NULL;
|
||||
char* faceplate_texture;
|
||||
char* faceplate_texture_data;
|
||||
int fd = x49gp_module_open_rodata( module,
|
||||
ui->calculator == UI_CALCULATOR_HP49GP || ui->calculator == UI_CALCULATOR_HP49GP_NEWRPL
|
||||
? "hp49g+-cropped.png"
|
||||
: /* "blank.png" */ "hp50g-cropped.png",
|
||||
&faceplate_texture );
|
||||
&faceplate_texture_data );
|
||||
if ( fd < 0 )
|
||||
return fd;
|
||||
|
||||
ui->bg_pixbuf = gdk_pixbuf_new_from_file( faceplate_texture, &gerror );
|
||||
ui->bg_pixbuf = gdk_pixbuf_new_from_file( faceplate_texture_data, &gerror );
|
||||
|
||||
/* set ui->width and ui->height based on faceplate_texture dimensions */
|
||||
gdk_pixbuf_get_file_info( faceplate_texture, &ui->width, &ui->height );
|
||||
/* set ui->width and ui->height based on faceplate_texture_data dimensions */
|
||||
gdk_pixbuf_get_file_info( faceplate_texture_data, &ui->width, &ui->height );
|
||||
close( fd );
|
||||
|
||||
/* set coordinates of LCD and keyboard */
|
||||
|
|
|
@ -118,19 +118,12 @@ struct __x49gp_ui_s__ {
|
|||
GtkWidget* lcd_canvas;
|
||||
GdkPixmap* lcd_pixmap;
|
||||
|
||||
GdkGC* ann_left_gc;
|
||||
GdkGC* ann_right_gc;
|
||||
GdkGC* ann_alpha_gc;
|
||||
GdkGC* ann_battery_gc;
|
||||
GdkGC* ann_busy_gc;
|
||||
GdkGC* ann_io_gc;
|
||||
|
||||
GdkBitmap* ann_left;
|
||||
GdkBitmap* ann_right;
|
||||
GdkBitmap* ann_alpha;
|
||||
GdkBitmap* ann_battery;
|
||||
GdkBitmap* ann_busy;
|
||||
GdkBitmap* ann_io;
|
||||
cairo_surface_t* ann_left_surface;
|
||||
cairo_surface_t* ann_right_surface;
|
||||
cairo_surface_t* ann_alpha_surface;
|
||||
cairo_surface_t* ann_battery_surface;
|
||||
cairo_surface_t* ann_busy_surface;
|
||||
cairo_surface_t* ann_io_surface;
|
||||
|
||||
gint width;
|
||||
gint height;
|
||||
|
|
Loading…
Reference in a new issue