コード例 #1
0
/** Implements widget::render for scrollbox widgets. */
void gg_scrollbox_render(gg_widget_t *widget, int x, int y, int focus)
{
    gg_widget_t *child = gg_bin_get_child(GG_BIN(widget));
    gg_scrollbox_t *scrollbox = GG_SCROLLBOX(widget);
    gg_widget_t *view_child = gg_bin_get_child(GG_BIN(child));
    gg_rect_t source, dest;
    int sliderpos=1;
    int slidersize=16;
    float yscroll=GG_VIEWPORT(child)->yscroll;
    gg_widget_t *parent=widget;
    gg_dialog_style_t *style;

    source.x=source.y=0;
    source.width=source.height=16;

    /* Draw Top Left Corner */
    dest.x = x+widget->width-16.0f; dest.y = y;
    dest.width = 16; dest.height = 16;
    gg_system_draw_image(gg_dialog_get_current_style()->widget_images[1], source, dest, 
        GG_MODE_TILE, GG_MODE_SCALE, &col_white, FALSE);

    dest.x = x+widget->width-16.0f; dest.y = y+16;
    dest.width = 16; dest.height = widget->height-(32);
    gg_system_draw_image(gg_dialog_get_current_style()->widget_images[4], source, dest, 
        GG_MODE_TILE, GG_MODE_SCALE, &col_white, FALSE);

    dest.x = x+widget->width-16.0f; dest.y = y+widget->height-16;
    dest.width = 16; dest.height = 16;
    gg_system_draw_image(gg_dialog_get_current_style()->widget_images[0], source, dest, 
        GG_MODE_TILE, GG_MODE_SCALE, &col_white, FALSE);

    /* Draw the slider! */
    slidersize=((float)child->height/(float)view_child->height)*(widget->height-32);
    sliderpos=((widget->height-(32)+1-slidersize)*yscroll)-1;

    dest.x = x+widget->width-16.0f; dest.y = y+16+sliderpos;
    dest.width = 16; dest.height = slidersize;
    gg_system_draw_image(gg_dialog_get_current_style()->widget_images[7], source, dest, 
        GG_MODE_TILE, GG_MODE_SCALE, &col_white, FALSE);

    child->render(child, x, y, GG_FOCUS_NONE);
}
コード例 #2
0
ファイル: system.c プロジェクト: BackupTheBerlios/banana-svn
void gg_system_draw_string(char *s, int x, int y, gg_colour_t *colour, int bounce, int effect, float align)
{
    int i;
    unsigned int ticks = gg_system_get_ticks();
    gg_rect_t rect_d;
    rect_d.x = x;

    if (align != 0.0f)
    {
        int width;

        gg_system_get_string_size(s, &width, NULL);

        rect_d.x -= width * align;
    }

    for (i = 0; i < strlen((char *) s); i++)
    {
        int y_off = 0;
        void *image = driver->get_char_image(s[i]);
        gg_rect_t rect_s = {0, 0};

        if (bounce)
        {
            float phase = ((ticks % (1000 / GG_BOUNCE_SPEED)) / (float) (1000 / GG_BOUNCE_SPEED));

            if (phase < 0.5)
                y_off = phase * 2 * (GG_BOUNCE_AMP + 1);
            else
                y_off = ((1.0 - phase) * 2) * (GG_BOUNCE_AMP + 1);
        }

        gg_system_get_image_size(image, &rect_s.width, &rect_s.height);
        //printf( "Char i:%c=%i,%i\n", s[i], rect_s.width, rect_s.height );
        rect_d.width = rect_s.width;
        rect_d.height = rect_s.height;
        rect_d.y = y + y_off;
        gg_system_draw_image(image, rect_s, rect_d, GG_MODE_SCALE, GG_MODE_SCALE, colour, effect);
        rect_d.x += rect_s.width+1.0f;

        ticks += 1000 / GG_BOUNCE_SPEED / GG_BOUNCE_LEN;
    }
}
コード例 #3
0
ファイル: dialog.c プロジェクト: konker/dreamchess
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);
}