factorize annunciators among all UIs
This commit is contained in:
parent
8c4d5c5a9d
commit
d3e4b33953
4 changed files with 41 additions and 50 deletions
9
src/ui.c
9
src/ui.c
|
@ -2057,6 +2057,15 @@ button_t buttons_gx[ NB_KEYS ] = {
|
|||
.sub = 0 },
|
||||
};
|
||||
|
||||
ann_struct_t ann_tbl[ NB_ANNUNCIATORS ] = {
|
||||
{.x = 16, .y = 4, .width = ann_left_width, .height = ann_left_height, .bits = ann_left_bitmap },
|
||||
{.x = 61, .y = 4, .width = ann_right_width, .height = ann_right_height, .bits = ann_right_bitmap },
|
||||
{.x = 106, .y = 4, .width = ann_alpha_width, .height = ann_alpha_height, .bits = ann_alpha_bitmap },
|
||||
{.x = 151, .y = 4, .width = ann_battery_width, .height = ann_battery_height, .bits = ann_battery_bitmap},
|
||||
{.x = 196, .y = 4, .width = ann_busy_width, .height = ann_busy_height, .bits = ann_busy_bitmap },
|
||||
{.x = 241, .y = 4, .width = ann_io_width, .height = ann_io_height, .bits = ann_io_bitmap },
|
||||
};
|
||||
|
||||
void ( *ui_disp_draw_nibble )( word_20 addr, word_4 val );
|
||||
void ( *ui_menu_draw_nibble )( word_20 addr, word_4 val );
|
||||
void ( *ui_get_event )( void );
|
||||
|
|
|
@ -64,6 +64,14 @@ typedef struct button_t {
|
|||
const char* sub;
|
||||
} button_t;
|
||||
|
||||
typedef struct ann_struct_t {
|
||||
int x;
|
||||
int y;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned char* bits;
|
||||
} ann_struct_t;
|
||||
|
||||
/*************/
|
||||
/* variables */
|
||||
/*************/
|
||||
|
@ -75,6 +83,8 @@ extern color_t colors_gx[ NB_COLORS ];
|
|||
extern button_t buttons_sx[ NB_KEYS ];
|
||||
extern button_t buttons_gx[ NB_KEYS ];
|
||||
|
||||
extern ann_struct_t ann_tbl[ NB_ANNUNCIATORS ];
|
||||
|
||||
/***********/
|
||||
/* bitmaps */
|
||||
/***********/
|
||||
|
|
48
src/ui_sdl.c
48
src/ui_sdl.c
|
@ -44,15 +44,7 @@ typedef struct sdl_button_t {
|
|||
SDL_Surface* surfacedown;
|
||||
} sdl_button_t;
|
||||
|
||||
// This mimicks the structure formerly lcd.c, except with SDL surfaces instead
|
||||
// of Pixmaps.
|
||||
typedef struct sdl_ann_struct_t {
|
||||
int x;
|
||||
int y;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned char* bits;
|
||||
|
||||
SDL_Surface* surfaceon;
|
||||
SDL_Surface* surfaceoff;
|
||||
} sdl_ann_struct_t;
|
||||
|
@ -127,19 +119,13 @@ static sdl_button_t sdl_buttons[ NB_KEYS ] = {
|
|||
{.surfaceup = 0, .surfacedown = 0},
|
||||
};
|
||||
|
||||
static sdl_ann_struct_t ann_tbl[] = {
|
||||
{.x = 16, .y = 4, .width = ann_left_width, .height = ann_left_height, .bits = ann_left_bitmap, .surfaceon = 0, .surfaceoff = 0},
|
||||
{.x = 61, .y = 4, .width = ann_right_width, .height = ann_right_height, .bits = ann_right_bitmap, .surfaceon = 0, .surfaceoff = 0},
|
||||
{.x = 106, .y = 4, .width = ann_alpha_width, .height = ann_alpha_height, .bits = ann_alpha_bitmap, .surfaceon = 0, .surfaceoff = 0},
|
||||
{.x = 151,
|
||||
.y = 4,
|
||||
.width = ann_battery_width,
|
||||
.height = ann_battery_height,
|
||||
.bits = ann_battery_bitmap,
|
||||
.surfaceon = 0,
|
||||
.surfaceoff = 0 },
|
||||
{.x = 196, .y = 4, .width = ann_busy_width, .height = ann_busy_height, .bits = ann_busy_bitmap, .surfaceon = 0, .surfaceoff = 0},
|
||||
{.x = 241, .y = 4, .width = ann_io_width, .height = ann_io_height, .bits = ann_io_bitmap, .surfaceon = 0, .surfaceoff = 0},
|
||||
static sdl_ann_struct_t sdl_ann_tbl[] = {
|
||||
{.surfaceon = 0, .surfaceoff = 0},
|
||||
{.surfaceon = 0, .surfaceoff = 0},
|
||||
{.surfaceon = 0, .surfaceoff = 0},
|
||||
{.surfaceon = 0, .surfaceoff = 0},
|
||||
{.surfaceon = 0, .surfaceoff = 0},
|
||||
{.surfaceon = 0, .surfaceoff = 0},
|
||||
};
|
||||
|
||||
// State to displayed zoomed last pressed key
|
||||
|
@ -264,20 +250,20 @@ static void create_annunc( void )
|
|||
{
|
||||
for ( int i = 0; i < NB_ANNUNCIATORS; i++ ) {
|
||||
// If the SDL surface does not exist yet, we create it on the fly
|
||||
if ( ann_tbl[ i ].surfaceon ) {
|
||||
SDL_FreeSurface( ann_tbl[ i ].surfaceon );
|
||||
ann_tbl[ i ].surfaceon = 0;
|
||||
if ( sdl_ann_tbl[ i ].surfaceon ) {
|
||||
SDL_FreeSurface( sdl_ann_tbl[ i ].surfaceon );
|
||||
sdl_ann_tbl[ i ].surfaceon = 0;
|
||||
}
|
||||
|
||||
ann_tbl[ i ].surfaceon =
|
||||
sdl_ann_tbl[ i ].surfaceon =
|
||||
bitmap_to_surface( ann_tbl[ i ].width, ann_tbl[ i ].height, ann_tbl[ i ].bits, ARGBColors[ PIXEL ], ARGBColors[ LCD ] );
|
||||
|
||||
if ( ann_tbl[ i ].surfaceoff ) {
|
||||
SDL_FreeSurface( ann_tbl[ i ].surfaceoff );
|
||||
ann_tbl[ i ].surfaceoff = 0;
|
||||
if ( sdl_ann_tbl[ i ].surfaceoff ) {
|
||||
SDL_FreeSurface( sdl_ann_tbl[ i ].surfaceoff );
|
||||
sdl_ann_tbl[ i ].surfaceoff = 0;
|
||||
}
|
||||
|
||||
ann_tbl[ i ].surfaceoff =
|
||||
sdl_ann_tbl[ i ].surfaceoff =
|
||||
bitmap_to_surface( ann_tbl[ i ].width, ann_tbl[ i ].height, ann_tbl[ i ].bits, ARGBColors[ LCD ], ARGBColors[ LCD ] );
|
||||
}
|
||||
}
|
||||
|
@ -1237,9 +1223,9 @@ static void draw_annunciators( char* annunc )
|
|||
drect.w = ann_tbl[ i ].width;
|
||||
drect.h = ann_tbl[ i ].height;
|
||||
if ( annunc[ i ] )
|
||||
SDL_BlitSurface( ann_tbl[ i ].surfaceon, &srect, sdlwindow, &drect );
|
||||
SDL_BlitSurface( sdl_ann_tbl[ i ].surfaceon, &srect, sdlwindow, &drect );
|
||||
else
|
||||
SDL_BlitSurface( ann_tbl[ i ].surfaceoff, &srect, sdlwindow, &drect );
|
||||
SDL_BlitSurface( sdl_ann_tbl[ i ].surfaceoff, &srect, sdlwindow, &drect );
|
||||
}
|
||||
|
||||
// Always immediately update annunciators
|
||||
|
|
24
src/ui_x11.c
24
src/ui_x11.c
|
@ -198,16 +198,6 @@ typedef struct x11_button_t {
|
|||
Window xwin;
|
||||
} x11_button_t;
|
||||
|
||||
typedef struct x11_ann_struct_t {
|
||||
int x;
|
||||
int y;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned char* bits;
|
||||
|
||||
Pixmap pixmap;
|
||||
} x11_ann_struct_t;
|
||||
|
||||
typedef struct x11_lcd_t {
|
||||
Window win;
|
||||
GC gc;
|
||||
|
@ -229,6 +219,7 @@ typedef struct icon_map_t {
|
|||
static bool mapped;
|
||||
|
||||
static x11_keypad_t keypad;
|
||||
|
||||
static XColor x11_colors[ NB_COLORS ] = {
|
||||
{0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0},
|
||||
{0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0},
|
||||
|
@ -388,13 +379,8 @@ static unsigned char nibbles[ 16 ][ 2 ] = {
|
|||
|
||||
static unsigned char nibble_bitmap[ 16 ];
|
||||
|
||||
static x11_ann_struct_t ann_tbl[] = {
|
||||
{.x = 16, .y = 4, .width = ann_left_width, .height = ann_left_height, .bits = ann_left_bitmap, .pixmap = 0},
|
||||
{.x = 61, .y = 4, .width = ann_right_width, .height = ann_right_height, .bits = ann_right_bitmap, .pixmap = 0},
|
||||
{.x = 106, .y = 4, .width = ann_alpha_width, .height = ann_alpha_height, .bits = ann_alpha_bitmap, .pixmap = 0},
|
||||
{.x = 151, .y = 4, .width = ann_battery_width, .height = ann_battery_height, .bits = ann_battery_bitmap, .pixmap = 0},
|
||||
{.x = 196, .y = 4, .width = ann_busy_width, .height = ann_busy_height, .bits = ann_busy_bitmap, .pixmap = 0},
|
||||
{.x = 241, .y = 4, .width = ann_io_width, .height = ann_io_height, .bits = ann_io_bitmap, .pixmap = 0},
|
||||
static Pixmap x11_ann_pixmaps[ NB_ANNUNCIATORS ] = {
|
||||
0, 0, 0, 0, 0, 0,
|
||||
};
|
||||
|
||||
static icon_map_t icon_maps_sx[] = {
|
||||
|
@ -3283,7 +3269,7 @@ void x11_draw_annunc( void )
|
|||
|
||||
for ( int i = 0; i < NB_ANNUNCIATORS; i++ )
|
||||
if ( ( annunciators_bits[ i ] & val ) == annunciators_bits[ i ] )
|
||||
XCopyPlane( dpy, ann_tbl[ i ].pixmap, lcd.win, lcd.gc, 0, 0, ann_tbl[ i ].width, ann_tbl[ i ].height, ann_tbl[ i ].x,
|
||||
XCopyPlane( dpy, x11_ann_pixmaps[ i ], lcd.win, lcd.gc, 0, 0, ann_tbl[ i ].width, ann_tbl[ i ].height, ann_tbl[ i ].x,
|
||||
ann_tbl[ i ].y, 1 );
|
||||
else
|
||||
XClearArea( dpy, lcd.win, ann_tbl[ i ].x, ann_tbl[ i ].y, ann_tbl[ i ].width, ann_tbl[ i ].height, False );
|
||||
|
@ -3363,7 +3349,7 @@ void init_x11_ui( int argc, char** argv )
|
|||
}
|
||||
|
||||
for ( int i = 0; i < NB_ANNUNCIATORS; i++ )
|
||||
ann_tbl[ i ].pixmap = XCreateBitmapFromData( dpy, lcd.win, ( char* )ann_tbl[ i ].bits, ann_tbl[ i ].width, ann_tbl[ i ].height );
|
||||
x11_ann_pixmaps[ i ] = XCreateBitmapFromData( dpy, lcd.win, ( char* )ann_tbl[ i ].bits, ann_tbl[ i ].width, ann_tbl[ i ].height );
|
||||
|
||||
/* init nibble_maps */
|
||||
for ( int i = 0; i < 16; i++ )
|
||||
|
|
Loading…
Reference in a new issue