Exemplo n.º 1
0
/**
 * Based on (heavily changed)
 *  rct2: 0x006E9E0E,  0x006E9ED0
 */
static void input_scroll_drag_continue(int x, int y, rct_window* w)
{
	rct_widgetindex widgetIndex = _dragWidget.widget_index;
	uint8 scrollIndex = _dragScrollIndex;

	rct_widget* widget = &w->widgets[widgetIndex];
	rct_scroll* scroll = &w->scrolls[scrollIndex];

	int dx, dy;
	dx = x - gInputDragLastX;
	dy = y - gInputDragLastY;

	if (scroll->flags & HSCROLLBAR_VISIBLE) {
		sint16 size = widget->right - widget->left - 1;
		if (scroll->flags & VSCROLLBAR_VISIBLE)
			size -= 11;
		size = max(0, scroll->h_right - size);
		scroll->h_left = min(max(0, scroll->h_left + dx), size);
	}

	if (scroll->flags & VSCROLLBAR_VISIBLE) {
		sint16 	size = widget->bottom - widget->top - 1;
		if (scroll->flags & HSCROLLBAR_VISIBLE)
			size -= 11;
		size = max(0, scroll->v_bottom - size);
		scroll->v_top = min(max(0, scroll->v_top + dy), size);
	}

	widget_scroll_update_thumbs(w, widgetIndex);
	window_invalidate_by_number(w->classification, w->number);
	platform_set_cursor_position(gInputDragLastX, gInputDragLastY);
}
Exemplo n.º 2
0
static void input_viewport_drag_continue()
{
	sint32 dx, dy, newDragX, newDragY;
	rct_window *w;
	rct_viewport *viewport;

	platform_get_cursor_position(&newDragX, &newDragY);

	dx = newDragX - gInputDragLastX;
	dy = newDragY - gInputDragLastY;
	w = window_find_by_number(_dragWidget.window_classification, _dragWidget.window_number);

	// #3294: Window can be closed during a drag session, so just finish
	//        the session if the window no longer exists
	if (w == NULL) {
		input_viewport_drag_end();
		return;
	}

	viewport = w->viewport;
	_ticksSinceDragStart += gTicksSinceLastUpdate;
	if (viewport == NULL) {
		platform_show_cursor();
		_inputState = INPUT_STATE_RESET;
	} else if (dx != 0 || dy != 0) {
		if (!(w->flags & WF_NO_SCROLLING)) {
			// User dragged a scrollable viewport

			// If the drag time is less than 500 the "drag" is usually interpreted as a right click.
			// As the user moved the mouse, don't interpret it as right click in any case.
			_ticksSinceDragStart = 1000;

			dx *= 1 << (viewport->zoom + 1);
			dy *= 1 << (viewport->zoom + 1);
			if (gConfigGeneral.invert_viewport_drag){
				w->saved_view_x -= dx;
				w->saved_view_y -= dy;
			} else {
				w->saved_view_x += dx;
				w->saved_view_y += dy;
			}
		}
	}

	platform_set_cursor_position(gInputDragLastX, gInputDragLastY);
}