mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-11 08:48:06 +01:00
Fix tray hanging below main window; draw pending tiles white-on-black as on other platforms.
This commit is contained in:
parent
e0f5fcf280
commit
880254c17f
2 changed files with 25 additions and 27 deletions
|
@ -147,17 +147,17 @@ compForHt( gconstpointer a,
|
||||||
static PangoLayout*
|
static PangoLayout*
|
||||||
layout_for_ht( GtkDrawCtx* dctx, XP_U16 ht )
|
layout_for_ht( GtkDrawCtx* dctx, XP_U16 ht )
|
||||||
{
|
{
|
||||||
PangoLayout* result = NULL;
|
PangoLayout* layout = NULL;
|
||||||
|
|
||||||
/* Try to find a cached layout. Otherwise create a new one. */
|
/* Try to find a cached layout. Otherwise create a new one. */
|
||||||
FontPerSize fps = { .ht = ht };
|
FontPerSize fps = { .ht = ht };
|
||||||
GList* gl = g_list_find_custom( dctx->fontsPerSize, &fps,
|
GList* gl = g_list_find_custom( dctx->fontsPerSize, &fps,
|
||||||
compForHt );
|
compForHt );
|
||||||
if ( NULL != gl ) {
|
if ( NULL != gl ) {
|
||||||
result = ((FontPerSize*)gl->data)->layout;
|
layout = ((FontPerSize*)gl->data)->layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( NULL == result ) {
|
if ( NULL == layout ) {
|
||||||
FontPerSize* fps = g_malloc( sizeof(*fps) );
|
FontPerSize* fps = g_malloc( sizeof(*fps) );
|
||||||
dctx->fontsPerSize = g_list_insert( dctx->fontsPerSize,
|
dctx->fontsPerSize = g_list_insert( dctx->fontsPerSize,
|
||||||
fps, 0 );
|
fps, 0 );
|
||||||
|
@ -165,20 +165,18 @@ layout_for_ht( GtkDrawCtx* dctx, XP_U16 ht )
|
||||||
char font[32];
|
char font[32];
|
||||||
snprintf( font, sizeof(font), "helvetica normal %d", ht );
|
snprintf( font, sizeof(font), "helvetica normal %d", ht );
|
||||||
|
|
||||||
fps->layout = pango_layout_new( dctx->pangoContext );
|
layout = pango_layout_new( dctx->pangoContext );
|
||||||
fps->fontdesc = pango_font_description_from_string( font );
|
fps->fontdesc = pango_font_description_from_string( font );
|
||||||
pango_layout_set_font_description( fps->layout, fps->fontdesc );
|
pango_layout_set_font_description( layout, fps->fontdesc );
|
||||||
|
fps->layout = layout;
|
||||||
|
|
||||||
/* This only happens first time??? */
|
/* This only happens first time??? */
|
||||||
pango_layout_set_alignment( fps->layout, PANGO_ALIGN_CENTER );
|
pango_layout_set_alignment( layout, PANGO_ALIGN_CENTER );
|
||||||
fps->ht = ht;
|
fps->ht = ht;
|
||||||
result = fps->layout;
|
|
||||||
XP_LOGF( "There are %d fonts now", g_list_length( dctx->fontsPerSize ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FontPerSize* fps = g_list_nth_data( dctx->fontsPerSize, 0 ); */
|
return layout;
|
||||||
return result;
|
} /* layout_for_ht */
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
draw_string_at( GtkDrawCtx* dctx, const char* str, XP_U16 fontHt,
|
draw_string_at( GtkDrawCtx* dctx, const char* str, XP_U16 fontHt,
|
||||||
|
@ -417,6 +415,7 @@ gtk_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* letter,
|
||||||
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
|
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
|
||||||
XP_Rect rectInset = *rect;
|
XP_Rect rectInset = *rect;
|
||||||
XP_Bool showGrid = dctx->globals->gridOn;
|
XP_Bool showGrid = dctx->globals->gridOn;
|
||||||
|
XP_Bool highlight = (flags & CELL_HIGHLIGHT) != 0;
|
||||||
|
|
||||||
eraseRect( dctx, rect );
|
eraseRect( dctx, rect );
|
||||||
|
|
||||||
|
@ -447,19 +446,17 @@ gtk_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* letter,
|
||||||
} else if ( *letter != LETTER_NONE ) {
|
} else if ( *letter != LETTER_NONE ) {
|
||||||
GdkColor* foreground;
|
GdkColor* foreground;
|
||||||
|
|
||||||
|
if ( !highlight ) {
|
||||||
gdk_gc_set_foreground( dctx->drawGC, &dctx->tileBack );
|
gdk_gc_set_foreground( dctx->drawGC, &dctx->tileBack );
|
||||||
|
}
|
||||||
gdk_draw_rectangle( DRAW_WHAT(dctx),
|
gdk_draw_rectangle( DRAW_WHAT(dctx),
|
||||||
dctx->drawGC,
|
dctx->drawGC,
|
||||||
TRUE,
|
TRUE,
|
||||||
rectInset.left, rectInset.top,
|
rectInset.left, rectInset.top,
|
||||||
rectInset.width+1, rectInset.height+1 );
|
rectInset.width+1, rectInset.height+1 );
|
||||||
if ( (flags & CELL_HIGHLIGHT) != 0 ) {
|
|
||||||
foreground = &dctx->red;
|
|
||||||
} else {
|
|
||||||
foreground = &dctx->playerColors[owner];
|
|
||||||
}
|
|
||||||
|
|
||||||
draw_string_at( dctx, letter, rectInset.height,
|
foreground = highlight? &dctx->white : &dctx->playerColors[owner];
|
||||||
|
draw_string_at( dctx, letter, rectInset.height-2,
|
||||||
&rectInset, XP_GTK_JUST_CENTER,
|
&rectInset, XP_GTK_JUST_CENTER,
|
||||||
foreground, NULL );
|
foreground, NULL );
|
||||||
|
|
||||||
|
@ -690,7 +687,8 @@ gtk_draw_drawBoardArrow( DrawCtx* p_dctx, const XP_Rect* rectP,
|
||||||
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
|
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
|
||||||
const char* curs = vertical? "|":"-";
|
const char* curs = vertical? "|":"-";
|
||||||
|
|
||||||
draw_string_at( dctx, curs, rectP->height,
|
/* font needs to be small enough that "|" doesn't overwrite cell below */
|
||||||
|
draw_string_at( dctx, curs, (rectP->height*2)/3,
|
||||||
rectP, XP_GTK_JUST_CENTER,
|
rectP, XP_GTK_JUST_CENTER,
|
||||||
&dctx->black, NULL );
|
&dctx->black, NULL );
|
||||||
drawHintBorders( dctx, rectP, hintAtts );
|
drawHintBorders( dctx, rectP, hintAtts );
|
||||||
|
|
|
@ -388,7 +388,7 @@ static gboolean
|
||||||
configure_event( GtkWidget* widget, GdkEventConfigure* XP_UNUSED(event),
|
configure_event( GtkWidget* widget, GdkEventConfigure* XP_UNUSED(event),
|
||||||
GtkAppGlobals* globals )
|
GtkAppGlobals* globals )
|
||||||
{
|
{
|
||||||
short width, height, leftMargin, topMargin;
|
short bdWidth, bdHeight, leftMargin, topMargin;
|
||||||
short timerLeft, timerTop;
|
short timerLeft, timerTop;
|
||||||
gint hscale, vscale;
|
gint hscale, vscale;
|
||||||
gint trayTop;
|
gint trayTop;
|
||||||
|
@ -398,18 +398,18 @@ configure_event( GtkWidget* widget, GdkEventConfigure* XP_UNUSED(event),
|
||||||
createOrLoadObjects( globals );
|
createOrLoadObjects( globals );
|
||||||
}
|
}
|
||||||
|
|
||||||
width = widget->allocation.width - (RIGHT_MARGIN + BOARD_LEFT_MARGIN);
|
bdWidth = widget->allocation.width - (RIGHT_MARGIN + BOARD_LEFT_MARGIN);
|
||||||
if ( globals->cGlobals.params->verticalScore ) {
|
if ( globals->cGlobals.params->verticalScore ) {
|
||||||
width -= VERT_SCORE_WIDTH;
|
bdWidth -= VERT_SCORE_WIDTH;
|
||||||
}
|
}
|
||||||
height = widget->allocation.height - (TOP_MARGIN + BOTTOM_MARGIN)
|
bdHeight = widget->allocation.height - (TOP_MARGIN + BOTTOM_MARGIN)
|
||||||
- MIN_TRAY_SCALEV - BOTTOM_MARGIN;
|
- MIN_TRAY_SCALEV - BOTTOM_MARGIN;
|
||||||
|
|
||||||
hscale = width / NUM_COLS;
|
hscale = bdWidth / NUM_COLS;
|
||||||
vscale = (height / (NUM_ROWS + 2)); /* makd tray height 2x cell height */
|
vscale = (bdHeight / (NUM_ROWS + TRAY_HT_ROWS)); /* makd tray height 3x cell height */
|
||||||
|
|
||||||
leftMargin = (width - (hscale*NUM_COLS)) / 2;
|
leftMargin = (bdWidth - (hscale*NUM_COLS)) / 2;
|
||||||
topMargin = (height - (vscale*(NUM_ROWS*2))) / 2;
|
topMargin = (bdHeight - (vscale*(NUM_ROWS*2))) / 2;
|
||||||
|
|
||||||
if ( !globals->cGlobals.params->verticalScore ) {
|
if ( !globals->cGlobals.params->verticalScore ) {
|
||||||
boardTop += HOR_SCORE_HEIGHT;
|
boardTop += HOR_SCORE_HEIGHT;
|
||||||
|
|
Loading…
Add table
Reference in a new issue