Exemple #1
0
static void
execute(XSurface *surf, struct gui_command_buffer *buffer)
{
    const struct gui_command *cmd;
    gui_foreach_command(cmd, buffer) {
        switch (cmd->type) {
        case GUI_COMMAND_NOP: break;
        case GUI_COMMAND_SCISSOR: {
            const struct gui_command_scissor *s = gui_command(scissor, cmd);
            surface_scissor(surf, s->x, s->y, s->w, s->h);
        } break;
        case GUI_COMMAND_LINE: {
            const struct gui_command_line *l = gui_command(line, cmd);
            surface_draw_line(surf, l->begin[0], l->begin[1], l->end[0],
                l->end[1], l->color.r, l->color.g, l->color.b);
        } break;
        case GUI_COMMAND_RECT: {
            const struct gui_command_rect *r = gui_command(rect, cmd);
	    if (!r->r) {
		surface_draw_rect(surf, r->x, r->y, r->w, r->h,
		    r->color.r, r->color.g, r->color.b);
	    } else {
		surface_draw_rounded_rect(surf, r->x, r->y, r->w, r->h, r->r,
		    r->color.r, r->color.g, r->color.b);
	    }
        } break;
        case GUI_COMMAND_CIRCLE: {
            const struct gui_command_circle *c = gui_command(circle, cmd);
            surface_draw_circle(surf, c->x, c->y, c->w, c->h,
                c->color.r, c->color.g, c->color.b);
        } break;
        case GUI_COMMAND_TRIANGLE: {
            const struct gui_command_triangle *t = gui_command(triangle, cmd);
            surface_draw_triangle(surf, t->a[0], t->a[1], t->b[0], t->b[1],
                t->c[0], t->c[1], t->color.r, t->color.g, t->color.b);
        } break;
        case GUI_COMMAND_TEXT: {
            const struct gui_command_text *t = gui_command(text, cmd);
            XWindow *win = t->font.ptr;
            surface_draw_text(surf, win->font, t->x, t->y, t->w, t->h, (const char*)t->string,
                    t->length, t->bg.r, t->bg.g, t->bg.b, t->fg.r, t->fg.g, t->fg.b);
        } break;
        case GUI_COMMAND_IMAGE:
        default: break;
        }
    }
}
Exemple #2
0
static void
draw(XSurface *surf, struct zr_command_queue *queue)
{
    const struct zr_command *cmd;
    zr_foreach_command(cmd, queue) {
        switch (cmd->type) {
        case ZR_COMMAND_NOP: break;
        case ZR_COMMAND_SCISSOR: {
            const struct zr_command_scissor *s = zr_command(scissor, cmd);
            surface_scissor(surf, s->x, s->y, s->w, s->h);
        } break;
        case ZR_COMMAND_LINE: {
            const struct zr_command_line *l = zr_command(line, cmd);
            surface_draw_line(surf, l->begin.x, l->begin.y, l->end.x,
                l->end.y, l->color.r, l->color.g, l->color.b);
        } break;
        case ZR_COMMAND_RECT: {
            const struct zr_command_rect *r = zr_command(rect, cmd);
            surface_draw_rect(surf, r->x, r->y, r->w, r->h,
                r->color.r, r->color.g, r->color.b);
        } break;
        case ZR_COMMAND_CIRCLE: {
            const struct zr_command_circle *c = zr_command(circle, cmd);
            surface_draw_circle(surf, c->x, c->y, c->w, c->h,
                c->color.r, c->color.g, c->color.b);
        } break;
        case ZR_COMMAND_TRIANGLE: {
            const struct zr_command_triangle *t = zr_command(triangle, cmd);
            surface_draw_triangle(surf, t->a.x, t->a.y, t->b.x, t->b.y,
                t->c.x, t->c.y, t->color.r, t->color.g, t->color.b);
        } break;
        case ZR_COMMAND_TEXT: {
            const struct zr_command_text *t = zr_command(text, cmd);
            XWindow *win = t->font->userdata.ptr;
            surface_draw_text(surf, win->font, t->x, t->y, t->w, t->h, (const char*)t->string,
                    (unsigned int)t->length, t->background.r, t->background.g, t->background.b,
                    t->foreground.r, t->foreground.g, t->foreground.b);
        } break;
        case ZR_COMMAND_IMAGE:
        case ZR_COMMAND_CURVE:
        case ZR_COMMAND_ARC:
        default: break;
        }
    }
    zr_command_queue_clear(queue);
}