Example #1
0
/**
 *
 *  rct2: 0x006EAF26
 */
void widget_scroll_update_thumbs(rct_window *w, rct_widgetindex widget_index)
{
    rct_widget *widget = &w->widgets[widget_index];
    rct_scroll* scroll = &w->scrolls[window_get_scroll_data_index(w, widget_index)];

    if (scroll->flags & HSCROLLBAR_VISIBLE) {
        sint32 view_size = widget->right - widget->left - 21;
        if (scroll->flags & VSCROLLBAR_VISIBLE)
            view_size -= 11;
        sint32 x = scroll->h_left * view_size;
        if (scroll->h_right != 0)
            x /= scroll->h_right;
        scroll->h_thumb_left = x + 11;

        x = widget->right - widget->left - 2;
        if (scroll->flags & VSCROLLBAR_VISIBLE)
            x -= 11;
        x += scroll->h_left;
        if (scroll->h_right != 0)
            x = (x * view_size) / scroll->h_right;
        x += 11;
        view_size += 10;
        scroll->h_thumb_right = min(x, view_size);

        if(scroll->h_thumb_right - scroll->h_thumb_left < 20) {
            double barPosition = (scroll->h_thumb_right * 1.0) / view_size;

            scroll->h_thumb_left = (uint16) lround(scroll->h_thumb_left - (20 * barPosition));
            scroll->h_thumb_right = (uint16) lround(scroll->h_thumb_right + (20 * (1 - barPosition)));
        }
    }

    if (scroll->flags & VSCROLLBAR_VISIBLE) {
        sint32 view_size = widget->bottom - widget->top - 21;
        if (scroll->flags & HSCROLLBAR_VISIBLE)
            view_size -= 11;
        sint32 y = scroll->v_top * view_size;
        if (scroll->v_bottom != 0)
            y /= scroll->v_bottom;
        scroll->v_thumb_top = y + 11;

        y = widget->bottom - widget->top - 2;
        if (scroll->flags & HSCROLLBAR_VISIBLE)
            y -= 11;
        y += scroll->v_top;
        if (scroll->v_bottom != 0)
            y = (y * view_size) / scroll->v_bottom;
        y += 11;
        view_size += 10;
        scroll->v_thumb_bottom = min(y, view_size);

        if(scroll->v_thumb_bottom - scroll->v_thumb_top < 20) {
            double barPosition = (scroll->v_thumb_bottom * 1.0) / view_size;

            scroll->v_thumb_top = (uint16) lround(scroll->v_thumb_top - (20 * barPosition));
            scroll->v_thumb_bottom = (uint16) lround(scroll->v_thumb_bottom + (20 * (1 - barPosition)));
        }
    }

}
Example #2
0
/**
 *
 *  rct2: 0x006E957F
 */
static void input_scroll_drag_begin(sint32 x, sint32 y, rct_window* w, rct_widget* widget, rct_widgetindex widgetIndex)
{
	_inputState = INPUT_STATE_SCROLL_RIGHT;
	gInputDragLastX = x;
	gInputDragLastY = y;
	_dragWidget.window_classification = w->classification;
	_dragWidget.window_number = w->number;
	_dragWidget.widget_index = widgetIndex;
	_ticksSinceDragStart = 0;

	_dragScrollIndex = window_get_scroll_data_index(w, widgetIndex);
	platform_hide_cursor();
}
Example #3
0
/**
 * 
 *  rct2: 0x006EAF26
 */
void widget_scroll_update_thumbs(rct_window *w, int widget_index)
{
	rct_widget* widget;
	rct_scroll* scroll;
	int x, y, view_size;

	widget = &w->widgets[widget_index];
	scroll = &w->scrolls[window_get_scroll_data_index(w, widget_index)];

	if (scroll->flags & HSCROLLBAR_VISIBLE) {
		view_size = widget->right - widget->left - 21;
		if (scroll->flags & VSCROLLBAR_VISIBLE)
			view_size -= 11;
		x = scroll->h_left * view_size;
		if (scroll->h_right != 0)
			x /= scroll->h_right;
		scroll->h_thumb_left = x + 11;

		x = widget->right - widget->left - 2;
		if (scroll->flags & VSCROLLBAR_VISIBLE)
			x -= 11;
		x += scroll->h_left;
		if (scroll->h_right != 0)
			x = (x * view_size) / scroll->h_right;
		x += 11;
		view_size += 10;
		scroll->h_thumb_right = min(x, view_size);
	}

	if (scroll->flags & VSCROLLBAR_VISIBLE) {
		view_size = widget->bottom - widget->top - 21;
		if (scroll->flags & HSCROLLBAR_VISIBLE)
			view_size -= 11;
		y = scroll->v_top * view_size;
		if (scroll->v_bottom != 0)
			y /= scroll->v_bottom;
		scroll->v_thumb_top = y + 11;

		y = widget->bottom - widget->top - 2;
		if (scroll->flags & HSCROLLBAR_VISIBLE)
			y -= 11;
		y += scroll->v_top;
		if (scroll->v_bottom != 0)
			y = (y * view_size) / scroll->v_bottom;
		y += 11;
		view_size += 10;
		scroll->v_thumb_bottom = min(y, view_size);
	}
}
Example #4
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);
}
Example #5
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);
}