static void icon_paint(paint_event_t* event) { icon_t* i = widget_get_instance_data(event->widget); rect_t rect = widget_get_rect(event->widget); point_t center = rect_center(rect); if (!widget_is_enabled(event->widget)) { gfx_set_bg_color(DARK_GRAY); gfx_clear_rect(rect); } /* draw icon */ if (i->image != NULL) { gfx_set_fg_color(i->icon_color); gfx_draw_bitmap( center.x - (i->image->width / 2), center.y - (i->image->height / 2), i->image); } }
static void widget_paint_predicate(widget_t* w, widget_traversal_event_t event, void* data) { (void)data; if (event == WIDGET_TRAVERSAL_BEFORE_CHILDREN) { gfx_ctx_push(); if (w->bg_color != TRANSPARENT) gfx_set_bg_color(w->bg_color); if (w->needs_paint && widget_is_visible(w)) { paint_event_t event = { .id = EVT_PAINT, .widget = w, }; gfx_clear_rect(w->rect); CALL_WC(w, on_paint)(&event); w->needs_paint = false; }
void gfx_clear_screen() { gfx_clear_rect(display_rect); }