Ejemplo n.º 1
0
/**
 * 
 *  rct2: 0x006EBD96
 */
static void widget_scroll_draw(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex)
{
	rct_widget* widget;
	rct_scroll* scroll;
	int scrollIndex;
	int l, t, r, b;
	int cl, ct, cr, cb;
	uint8 colour;
	rct_drawpixelinfo scroll_dpi;

	// Get the widget
	scrollIndex = window_get_scroll_data_index(w, widgetIndex);
	widget = &w->widgets[widgetIndex];
	scroll = &w->scrolls[scrollIndex];

	// Resolve the absolute ltrb
	l = w->x + widget->left;
	t = w->y + widget->top;
	r = w->x + widget->right;
	b = w->y + widget->bottom;

	// Get the colour
	colour = w->colours[widget->colour];

	// Draw the border
	gfx_fill_rect_inset(dpi, l, t, r, b, colour, 0x60);

	// Inflate by -1
	l++;
	t++;
	r--;
	b--;

	// Horizontal scrollbar
	if (scroll->flags & HSCROLLBAR_VISIBLE)
		widget_hscrollbar_draw(dpi, scroll, l, b - 10, (scroll->flags & VSCROLLBAR_VISIBLE ? r - 10 : r), b, colour);

	// Vertical scrollbar
	if (scroll->flags & VSCROLLBAR_VISIBLE)
		widget_vscrollbar_draw(dpi, scroll, r - 10, t, r, (scroll->flags & HSCROLLBAR_VISIBLE ? b - 10 : b), colour);

	// Contents
	if (scroll->flags & HSCROLLBAR_VISIBLE)
		b -= 11;
	if (scroll->flags & VSCROLLBAR_VISIBLE)
		r -= 11;

	// Create a new inner scroll dpi
	scroll_dpi = *dpi;

	// Clip the scroll dpi against the outer dpi
	cl = max(dpi->x, l);
	ct = max(dpi->y, t);
	cr = min(dpi->x + dpi->width, r);
	cb = min(dpi->y + dpi->height, b);

	// Set the respective dpi attributes
	scroll_dpi.x = cl - l + scroll->h_left;
	scroll_dpi.y = ct - t + scroll->v_top;
	scroll_dpi.width = cr - cl;
	scroll_dpi.height = cb - ct;
	scroll_dpi.bits += cl - dpi->x;
	scroll_dpi.bits += (ct - dpi->y) * (dpi->width + dpi->pitch);
	scroll_dpi.pitch = (dpi->width + dpi->pitch) - scroll_dpi.width;

	// Draw the scroll contents
	if (scroll_dpi.width > 0 && scroll_dpi.height > 0)
		RCT2_CALLPROC_X(w->event_handlers[WE_SCROLL_PAINT], 0, 0, 0, 0, (int)w, (int)&scroll_dpi, 0);
}
Ejemplo n.º 2
0
/**
 *
 *  rct2: 0x006EBD96
 */
static void widget_scroll_draw(rct_drawpixelinfo *dpi, rct_window *w, rct_widgetindex widgetIndex)
{
    // Get the widget
    sint32 scrollIndex = window_get_scroll_data_index(w, widgetIndex);
    rct_widget *widget = &w->widgets[widgetIndex];
    rct_scroll* scroll = &w->scrolls[scrollIndex];

    // Resolve the absolute ltrb
    sint32 l = w->x + widget->left;
    sint32 t = w->y + widget->top;
    sint32 r = w->x + widget->right;
    sint32 b = w->y + widget->bottom;

    // Get the colour
    uint8 colour = w->colours[widget->colour];

    // Draw the border
    gfx_fill_rect_inset(dpi, l, t, r, b, colour, INSET_RECT_F_60);

    // Inflate by -1
    l++;
    t++;
    r--;
    b--;

    gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;

    // Horizontal scrollbar
    if (scroll->flags & HSCROLLBAR_VISIBLE)
        widget_hscrollbar_draw(dpi, scroll, l, b - 10, ((scroll->flags & VSCROLLBAR_VISIBLE) ? r - 11 : r), b, colour);

    // Vertical scrollbar
    if (scroll->flags & VSCROLLBAR_VISIBLE)
        widget_vscrollbar_draw(dpi, scroll, r - 10, t, r, ((scroll->flags & HSCROLLBAR_VISIBLE) ? b - 11 : b), colour);

    // Contents
    if (scroll->flags & HSCROLLBAR_VISIBLE)
        b -= 11;
    if (scroll->flags & VSCROLLBAR_VISIBLE)
        r -= 11;

    b++;
    r++;

    // Create a new inner scroll dpi
    rct_drawpixelinfo scroll_dpi = *dpi;

    // Clip the scroll dpi against the outer dpi
    sint32 cl = max(dpi->x, l);
    sint32 ct = max(dpi->y, t);
    sint32 cr = min(dpi->x + dpi->width, r);
    sint32 cb = min(dpi->y + dpi->height, b);

    // Set the respective dpi attributes
    scroll_dpi.x = cl - l + scroll->h_left;
    scroll_dpi.y = ct - t + scroll->v_top;
    scroll_dpi.width = cr - cl;
    scroll_dpi.height = cb - ct;
    scroll_dpi.bits += cl - dpi->x;
    scroll_dpi.bits += (ct - dpi->y) * (dpi->width + dpi->pitch);
    scroll_dpi.pitch = (dpi->width + dpi->pitch) - scroll_dpi.width;

    // Draw the scroll contents
    if (scroll_dpi.width > 0 && scroll_dpi.height > 0)
        window_event_scroll_paint_call(w, &scroll_dpi, scrollIndex);
}