/** Implements widget::render for text widgets. */ void gg_label_render(gg_widget_t *widget, int x, int y, int focus) { gg_label_t *label = GG_LABEL(widget); if (label->bgcolour.a != 0.0f) gg_system_draw_filled_rect(x, y, label->width_a, label->height_a, &label->bgcolour); x += label->xalign * (label->width_a - label->width); y += (1.0f - label->yalign) * (label->height_a - label->height); /* TODO Fix temporary hack */ if (!widget->enabled) gg_system_draw_string(label->label, x, y, &col_grey, 0, 0); else if (focus != GG_FOCUS_NONE) gg_system_draw_string(label->label, x, y, &col_texthighlight, label->bouncy, 0); else gg_system_draw_string(label->label, x, y, &label->colour, 0, 0); }
void draw_border(void *image[9], char *title, int active, gg_rect_t area, int size) { gg_rect_t source, dest; int image_size; int titlebar_height = 0; gg_system_get_image_size(image[0], &image_size, NULL); source.x = 0; source.y = 0; source.width = image_size; source.height = image_size; if (title) { int text_height; gg_system_get_string_size(title, NULL, &text_height); titlebar_height = text_height * GG_DIALOG_TITLE_FACT; titlebar_height += GG_DIALOG_TITLE_SEP_HEIGHT; dest.x = area.x; dest.y = area.y + area.height - titlebar_height; dest.width = area.width; dest.height = GG_DIALOG_TITLE_SEP_HEIGHT; gg_system_draw_filled_rect(dest.x, dest.y, dest.width, GG_DIALOG_TITLE_SEP_HEIGHT, &col_black); dest.y += GG_DIALOG_TITLE_SEP_HEIGHT; dest.height = titlebar_height - GG_DIALOG_TITLE_SEP_HEIGHT; if (active ) gg_system_draw_gradient_rect(dest.x, dest.y, dest.width, dest.height, &col_blue2, &col_blue, &col_blue2, &col_blue); else gg_system_draw_gradient_rect(dest.x, dest.y, dest.width, dest.height, &col_grey2, &col_grey, &col_grey2, &col_grey); gg_clipping_adjust(&dest); dest.y += text_height * (GG_DIALOG_TITLE_FACT - 1) / 2; gg_system_draw_string(title, dest.x + dest.width / 2, dest.y, &col_white, 0, 0.5); gg_clipping_undo(); } area.x -= size; area.y -= size; area.width += 2 * size; area.height += 2 * size; dest.x = area.x; dest.y = area.y; dest.width = size; dest.height = size; /* Draw four corners.. */ gg_system_draw_image(image[6], source, dest, GG_MODE_SCALE, GG_MODE_SCALE, &col_white); dest.y += area.height - size; gg_system_draw_image(image[0], source, dest, GG_MODE_SCALE, GG_MODE_SCALE, &col_white); dest.x += area.width - size; gg_system_draw_image(image[2], source, dest, GG_MODE_SCALE, GG_MODE_SCALE, &col_white); dest.y -= area.height - size; gg_system_draw_image(image[8], source, dest, GG_MODE_SCALE, GG_MODE_SCALE, &col_white); /* Draw bottom */ dest.x = area.x + size; dest.y = area.y; dest.width = area.width - (2 * size); dest.height = size; gg_system_draw_image(image[7], source, dest, GG_MODE_TILE, GG_MODE_SCALE, &col_white); /* Draw top */ dest.y += area.height - size; gg_system_draw_image(image[1], source, dest, GG_MODE_TILE, GG_MODE_SCALE, &col_white); /* Draw left */ dest.x = area.x; dest.y = area.y + size; dest.width = size; dest.height = area.height - (2 * size); gg_system_draw_image(image[3], source, dest, GG_MODE_SCALE, GG_MODE_TILE, &col_white); /* Draw right */ dest.x += area.width - size; gg_system_draw_image(image[5], source, dest, GG_MODE_SCALE, GG_MODE_TILE, &col_white); /* Draw middle */ dest.x = area.x + size; dest.width = area.width - 2 * size; dest.height -= titlebar_height; gg_system_draw_image(image[4], source, dest, GG_MODE_TILE, GG_MODE_TILE, &col_white); }