mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-18 22:26:30 +01:00
hook up draw signal
Whenver we get the draw signal, invalidate the whole board and draw it. This is resulting in a lot of wasted effort that might be mitigated if I figured out how to get the invalid region out of the cairo_t* that's passed in, but this is a test app and my machine's pleny fast. So go with it for now.
This commit is contained in:
parent
33f904fa1e
commit
66e26c1489
2 changed files with 17 additions and 61 deletions
|
@ -812,55 +812,6 @@ configure_event( GtkWidget* widget, GdkEventConfigure* XP_UNUSED(event),
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} /* configure_event */
|
} /* configure_event */
|
||||||
|
|
||||||
/* Redraw the screen from the backing pixmap */
|
|
||||||
static gint
|
|
||||||
expose_event( GtkWidget* XP_UNUSED(widget),
|
|
||||||
GdkEventExpose* XP_UNUSED(event),
|
|
||||||
GtkGameGlobals* globals )
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
gdk_draw_rectangle( widget->window,//((GtkDrawCtx*)globals->draw)->pixmap,
|
|
||||||
widget->style->white_gc,
|
|
||||||
TRUE,
|
|
||||||
0, 0,
|
|
||||||
widget->allocation.width,
|
|
||||||
widget->allocation.height+widget->allocation.y );
|
|
||||||
*/
|
|
||||||
/* I want to inval only the area that's exposed, but the rect is always
|
|
||||||
empty, even when clearly shouldn't be. Need to investigate. Until
|
|
||||||
fixed, use board_invalAll to ensure board is drawn.*/
|
|
||||||
/* board_invalRect( globals->cGlobals.game.board, (XP_Rect*)&event->area ); */
|
|
||||||
|
|
||||||
board_invalAll( globals->cGlobals.game.board );
|
|
||||||
board_draw( globals->cGlobals.game.board );
|
|
||||||
draw_gtk_status( globals->draw, globals->stateChar );
|
|
||||||
|
|
||||||
/* gdk_draw_pixmap( widget->window, */
|
|
||||||
/* widget->style->fg_gc[GTK_WIDGET_STATE (widget)], */
|
|
||||||
/* ((GtkDrawCtx*)globals->draw)->pixmap, */
|
|
||||||
/* event->area.x, event->area.y, */
|
|
||||||
/* event->area.x, event->area.y, */
|
|
||||||
/* event->area.width, event->area.height ); */
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
} /* expose_event */
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
static gint
|
|
||||||
handle_client_event( GtkWidget *widget, GdkEventClient *event,
|
|
||||||
GtkGameGlobals* globals )
|
|
||||||
{
|
|
||||||
XP_LOGF( "handle_client_event called: event->type = " );
|
|
||||||
if ( event->type == GDK_CLIENT_EVENT ) {
|
|
||||||
XP_LOGF( "GDK_CLIENT_EVENT" );
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
XP_LOGF( "%d", event->type );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
} /* handle_client_event */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void
|
void
|
||||||
destroy_board_window( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
destroy_board_window( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
||||||
{
|
{
|
||||||
|
@ -1260,8 +1211,6 @@ createAddItem( GtkWidget* parent, gchar* label,
|
||||||
{
|
{
|
||||||
GtkWidget* item = gtk_menu_item_new_with_label( label );
|
GtkWidget* item = gtk_menu_item_new_with_label( label );
|
||||||
|
|
||||||
/* g_print( "createAddItem called with label %s\n", label ); */
|
|
||||||
|
|
||||||
if ( handlerFunc != NULL ) {
|
if ( handlerFunc != NULL ) {
|
||||||
g_signal_connect( item, "activate", G_CALLBACK(handlerFunc),
|
g_signal_connect( item, "activate", G_CALLBACK(handlerFunc),
|
||||||
globals );
|
globals );
|
||||||
|
@ -2653,11 +2602,19 @@ initGlobalsNoDraw( GtkGameGlobals* globals, LaunchParams* params,
|
||||||
setupGtkUtilCallbacks( globals, globals->cGlobals.util );
|
setupGtkUtilCallbacks( globals, globals->cGlobals.util );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This gets called all the time, e.g. when the mouse moves across
|
||||||
|
drawing-area boundaries. So invalidating is crazy expensive. But this is a
|
||||||
|
test app....*/
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
on_draw_event( GtkWidget *widget, cairo_t* cr, gpointer user_data )
|
on_draw_event( GtkWidget *widget, cairo_t* cr, gpointer user_data )
|
||||||
{
|
{
|
||||||
LOG_FUNC();
|
// XP_LOGF( "%s(widget=%p)", __func__, widget );
|
||||||
XP_USE(user_data);
|
GtkGameGlobals* globals = (GtkGameGlobals*)user_data;
|
||||||
|
board_invalAll( globals->cGlobals.game.board );
|
||||||
|
board_draw( globals->cGlobals.game.board );
|
||||||
|
draw_gtk_status( globals->draw, globals->stateChar );
|
||||||
|
|
||||||
XP_USE(widget);
|
XP_USE(widget);
|
||||||
XP_USE(cr);
|
XP_USE(cr);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -2748,8 +2705,6 @@ initGlobals( GtkGameGlobals* globals, LaunchParams* params, CurGameInfo* gi )
|
||||||
|
|
||||||
gtk_box_pack_start( GTK_BOX(vbox), hbox/* drawing_area */, TRUE, TRUE, 0);
|
gtk_box_pack_start( GTK_BOX(vbox), hbox/* drawing_area */, TRUE, TRUE, 0);
|
||||||
|
|
||||||
g_signal_connect( drawing_area, "expose_event",
|
|
||||||
G_CALLBACK(expose_event), globals );
|
|
||||||
g_signal_connect( drawing_area,"configure_event",
|
g_signal_connect( drawing_area,"configure_event",
|
||||||
G_CALLBACK(configure_event), globals );
|
G_CALLBACK(configure_event), globals );
|
||||||
g_signal_connect( drawing_area, "button_press_event",
|
g_signal_connect( drawing_area, "button_press_event",
|
||||||
|
|
|
@ -85,10 +85,10 @@ gtkInsetRect( XP_Rect* r, short i )
|
||||||
static void
|
static void
|
||||||
initCairo( GtkDrawCtx* dctx )
|
initCairo( GtkDrawCtx* dctx )
|
||||||
{
|
{
|
||||||
XP_LOGF( "%s(dctx=%p)", __func__, dctx );
|
/* XP_LOGF( "%s(dctx=%p)", __func__, dctx ); */
|
||||||
XP_ASSERT( !dctx->_cairo );
|
XP_ASSERT( !dctx->_cairo );
|
||||||
dctx->_cairo = gdk_cairo_create( gtk_widget_get_window(dctx->drawing_area) );
|
dctx->_cairo = gdk_cairo_create( gtk_widget_get_window(dctx->drawing_area) );
|
||||||
XP_LOGF( "dctx->cairo=%p", dctx->_cairo );
|
/* XP_LOGF( "dctx->cairo=%p", dctx->_cairo ); */
|
||||||
cairo_set_line_width( dctx->_cairo, 1.0 );
|
cairo_set_line_width( dctx->_cairo, 1.0 );
|
||||||
cairo_set_line_cap( dctx->_cairo, CAIRO_LINE_CAP_SQUARE );
|
cairo_set_line_cap( dctx->_cairo, CAIRO_LINE_CAP_SQUARE );
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ initCairo( GtkDrawCtx* dctx )
|
||||||
static void
|
static void
|
||||||
destroyCairo( GtkDrawCtx* dctx )
|
destroyCairo( GtkDrawCtx* dctx )
|
||||||
{
|
{
|
||||||
XP_LOGF( "%s(dctx=%p)", __func__, dctx );
|
/* XP_LOGF( "%s(dctx=%p)", __func__, dctx ); */
|
||||||
XP_ASSERT( !!dctx->_cairo );
|
XP_ASSERT( !!dctx->_cairo );
|
||||||
cairo_destroy(dctx->_cairo);
|
cairo_destroy(dctx->_cairo);
|
||||||
dctx->_cairo = NULL;
|
dctx->_cairo = NULL;
|
||||||
|
@ -468,9 +468,7 @@ gtk_draw_boardBegin( DrawCtx* p_dctx, const XP_Rect* rect,
|
||||||
gdkrect = *(GdkRectangle*)rect;
|
gdkrect = *(GdkRectangle*)rect;
|
||||||
++gdkrect.width;
|
++gdkrect.width;
|
||||||
++gdkrect.height;
|
++gdkrect.height;
|
||||||
/* gdk_gc_set_clip_rectangle( dctx->drawGC, &gdkrect ); */
|
|
||||||
|
|
||||||
LOG_RETURN_VOID();
|
|
||||||
return XP_TRUE;
|
return XP_TRUE;
|
||||||
} /* gtk_draw_boardBegin */
|
} /* gtk_draw_boardBegin */
|
||||||
|
|
||||||
|
@ -947,7 +945,6 @@ gtkDrawDrawRemText( DrawCtx* p_dctx, const XP_Rect* rect, XP_S16 nTilesLeft,
|
||||||
}
|
}
|
||||||
*widthP = width;
|
*widthP = width;
|
||||||
*heightP = height;
|
*heightP = height;
|
||||||
XP_LOGF( "%s(): setting width: %d, height: %d", __func__, width, height );
|
|
||||||
} else {
|
} else {
|
||||||
const GdkRGBA* cursor = NULL;
|
const GdkRGBA* cursor = NULL;
|
||||||
if ( focussed ) {
|
if ( focussed ) {
|
||||||
|
@ -1485,6 +1482,8 @@ gtkDrawCtxtMake( GtkWidget* drawing_area, GtkGameGlobals* globals )
|
||||||
void
|
void
|
||||||
draw_gtk_status( GtkDrawCtx* dctx, char ch )
|
draw_gtk_status( GtkDrawCtx* dctx, char ch )
|
||||||
{
|
{
|
||||||
|
initCairo( dctx );
|
||||||
|
|
||||||
GtkGameGlobals* globals = dctx->globals;
|
GtkGameGlobals* globals = dctx->globals;
|
||||||
|
|
||||||
XP_Rect rect = {
|
XP_Rect rect = {
|
||||||
|
@ -1499,6 +1498,8 @@ draw_gtk_status( GtkDrawCtx* dctx, char ch )
|
||||||
draw_string_at( dctx, NULL, str, GTKMIN_W_HT,
|
draw_string_at( dctx, NULL, str, GTKMIN_W_HT,
|
||||||
&rect, XP_GTK_JUST_CENTER,
|
&rect, XP_GTK_JUST_CENTER,
|
||||||
&dctx->black, NULL );
|
&dctx->black, NULL );
|
||||||
|
|
||||||
|
destroyCairo( dctx );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in a new issue