Skip to content

Commit

Permalink
[ui_x11.c] draw keypad in one loop
Browse files Browse the repository at this point in the history
  • Loading branch information
gwenhael-le-moine committed May 16, 2024
1 parent 45f37f9 commit 976ec1f
Showing 1 changed file with 14 additions and 25 deletions.
39 changes: 14 additions & 25 deletions src/ui_x11.c
Original file line number Diff line number Diff line change
Expand Up @@ -1208,10 +1208,7 @@ void CreateKeypad( unsigned int offset_y, unsigned int offset_x, x11_keypad_t* k
for ( i = FIRST_HPKEY; i <= LAST_HPKEY; i++ ) {
CreateButton( i, offset_x, offset_y, f_small, f_med, f_big );

if ( i < HPKEY_MTH )
pixel = COLOR( DISP_PAD );
else
pixel = COLOR( PAD );
pixel = ( i < HPKEY_MTH ) ? COLOR( DISP_PAD ) : COLOR( PAD );

if ( buttons[ i ].letter != ( char* )0 ) {
XSetBackground( dpy, gc, pixel );
Expand All @@ -1227,16 +1224,10 @@ void CreateKeypad( unsigned int offset_y, unsigned int offset_x, x11_keypad_t* k

DrawSmallString( dpy, keypad->pixmap, gc, x, y, buttons[ i ].letter, 1 );
}
}

XFreeFont( dpy, f_big );
XFreeFont( dpy, f_med );
XFreeFont( dpy, f_small );

/*
* draw the bottom labels
*/
for ( i = FIRST_HPKEY; i <= LAST_HPKEY; i++ ) {
/*
* draw the bottom labels
*/
if ( buttons[ i ].sub != ( char* )0 ) {
XSetBackground( dpy, gc, pixel );
XSetForeground( dpy, gc, COLOR( WHITE ) );
Expand All @@ -1246,12 +1237,10 @@ void CreateKeypad( unsigned int offset_y, unsigned int offset_x, x11_keypad_t* k

DrawSmallString( dpy, keypad->pixmap, gc, x, y, buttons[ i ].sub, strlen( buttons[ i ].sub ) );
}
}

/*
* draw the left labels
*/
for ( i = FIRST_HPKEY; i <= LAST_HPKEY; i++ ) {
/*
* draw the left labels
*/
if ( buttons[ i ].left != ( char* )0 ) {
if ( buttons[ i ].is_menu ) {
/*
Expand Down Expand Up @@ -1319,14 +1308,10 @@ void CreateKeypad( unsigned int offset_y, unsigned int offset_x, x11_keypad_t* k
DrawSmallString( dpy, keypad->pixmap, gc, x, y, buttons[ i ].left, strlen( buttons[ i ].left ) );
}
}
}

/*
* draw the right labels
*/
for ( i = FIRST_HPKEY; i <= LAST_HPKEY; i++ ) {
pixel = ( i < HPKEY_MTH ) ? COLOR( DISP_PAD ) : COLOR( PAD );

/*
* draw the right labels
*/
if ( buttons[ i ].right != ( char* )0 ) {
if ( buttons[ i ].is_menu ) {
/*
Expand Down Expand Up @@ -1396,6 +1381,10 @@ void CreateKeypad( unsigned int offset_y, unsigned int offset_x, x11_keypad_t* k
}
}

XFreeFont( dpy, f_big );
XFreeFont( dpy, f_med );
XFreeFont( dpy, f_small );

/*
* at last draw the v--- LAST ---v thing
*/
Expand Down

0 comments on commit 976ec1f

Please sign in to comment.