char buf[100];
if (ms < 0) {
- xcounter_simple_update(state->timer, "\n");
+ xcounter_update(state->timer, "\n");
return;
}
- xcounter_simple_update(state->timer, timer_text(ms, buf));
+ xcounter_update(state->timer, timer_text(ms, buf));
}
static void configure_mainwin(struct app_state *state, Widget form)
{
Widget gamearea = XtNameToWidget(form, &tree_strtab[gameArea]);
Widget goalarea = XtNameToWidget(form, &tree_strtab[goalArea]);
+ Widget timer = XtNameToWidget(form, &tree_strtab[timeDisplay]);
XtActionsRec resize_rec;
char xc_template[100];
- assert(gamearea && goalarea);
+ assert(gamearea && goalarea && timer);
XtVaSetValues(form, XmNfractionBase, SPLIT_DENOMINATOR, (char *)NULL);
state->game = XtNameToWidget(gamearea, &tree_strtab[gameCanvas]);
XmNtopWidget, gamearea,
(char *)NULL);
- state->timer = XtNameToWidget(form, &tree_strtab[timeDisplay]);
- XtVaSetValues(state->timer, XmNleftAttachment, XmATTACH_WIDGET,
- XmNleftWidget, gamearea,
- XmNtopAttachment, XmATTACH_WIDGET,
- XmNtopWidget, goalarea,
- XmNrightAttachment, XmATTACH_FORM,
- (char *)NULL);
-
- xcounter_simple_setup(state->timer, timer_text(20000, xc_template));
+ XtVaSetValues(timer, XmNleftAttachment, XmATTACH_WIDGET,
+ XmNleftWidget, gamearea,
+ XmNtopAttachment, XmATTACH_WIDGET,
+ XmNtopWidget, goalarea,
+ XmNrightAttachment, XmATTACH_FORM,
+ (char *)NULL);
+ state->timer = xcounter_simple_init(timer, timer_text(0, xc_template));
ui_timer_update(state, -1);
resize_rec.string = "ResizeGameArea";
(e->y+e->height-1)/tile_h );
}
-static void game_resize(Widget w, void *data, void *cb_data)
+static void resize(Widget w, void *data, void *cb_data)
{
- x11_queue_render(data, -1, 0);
-}
+ struct app_state *state = data;
-static void goal_resize(Widget w, void *data, void *cb_data)
-{
- x11_queue_render(data, 0, -1);
+ x11_queue_render(data, -1, 1 << (w == state->game));
}
static void expose(Widget w, void *data, void *cb_data)
XExposeEvent *e = &cbs->event->xexpose;
struct app_state *state = data;
Dimension tile_w, tile_h;
+ uint_fast32_t mask;
XtVaGetValues(w, XmNwidth, &tile_w, XmNheight, &tile_h, (char *)NULL);
if (w == state->game) {
uint_least32_t *gp = state->board.game;
- uint_fast32_t mask;
if (!(tile_w /= 5) || !(tile_h /= 5))
return;
* spaces don't need to be drawn again.
*/
mask = gp[0] | gp[1] | gp[2];
- mask &= x11_expose_mask(e, tile_w, tile_h);
-
- x11_queue_render(state, mask, 0);
} else {
if (!(tile_w /= 3) || !(tile_h /= 3))
return;
- x11_queue_render(state, 0, x11_expose_mask(e, tile_w, tile_h));
+ /* Goal area never has empty tiles. */
+ mask = -1;
}
+
+ mask &= x11_expose_mask(e, tile_w, tile_h);
+ x11_queue_render(state, mask, 1<<(w == state->game));
}
void ui_initialize(struct app_state *state, Widget shell)
XtVaGetValues(state->game, XmNwidth, &state->game_sz[0],
XmNheight, &state->game_sz[1],
(char *)NULL);
- XtAddCallback(state->game, XmNresizeCallback, game_resize, state);
+ XtAddCallback(state->game, XmNresizeCallback, resize, state);
XtAddCallback(state->game, XmNexposeCallback, expose, state);
XtVaGetValues(state->game, XmNwidth, &state->goal_sz[0],
XmNheight, &state->goal_sz[1],
(char *)NULL);
- XtAddCallback(state->goal, XmNresizeCallback, goal_resize, state);
+ XtAddCallback(state->goal, XmNresizeCallback, resize, state);
XtAddCallback(state->goal, XmNexposeCallback, expose, state);
}