Continuously scroll map with two fingers
This commit is contained in:
@@ -41,6 +41,7 @@ bool _left_button_down; ///< Is left mouse button pressed?
|
||||
bool _left_button_clicked; ///< Is left mouse button clicked?
|
||||
bool _right_button_down; ///< Is right mouse button pressed?
|
||||
bool _right_button_clicked; ///< Is right mouse button clicked?
|
||||
Point _right_button_down_pos; ///< Pos of right mouse button click, for drag and drop
|
||||
|
||||
DrawPixelInfo _screen;
|
||||
bool _screen_disable_anim = false; ///< Disable palette animation (important for 32bpp-anim blitter during giant screenshot)
|
||||
|
||||
@@ -65,6 +65,7 @@ extern bool _left_button_down;
|
||||
extern bool _left_button_clicked;
|
||||
extern bool _right_button_down;
|
||||
extern bool _right_button_clicked;
|
||||
extern Point _right_button_down_pos;
|
||||
|
||||
extern DrawPixelInfo _screen;
|
||||
extern bool _screen_disable_anim; ///< Disable palette animation (important for 32bpp-anim blitter during giant screenshot)
|
||||
|
||||
@@ -598,6 +598,8 @@ int VideoDriver_SDL::PollEvent()
|
||||
case SDL_BUTTON_RIGHT:
|
||||
_right_button_down = true;
|
||||
_right_button_clicked = true;
|
||||
_right_button_down_pos.x = ev.motion.x;
|
||||
_right_button_down_pos.y = ev.motion.y;
|
||||
break;
|
||||
|
||||
case SDL_BUTTON_WHEELUP: _cursor.wheel--; break;
|
||||
|
||||
@@ -2777,6 +2777,24 @@ static void HandleAutoscroll()
|
||||
#undef scrollspeed
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform small continuous scrolling with right button press and drag.
|
||||
*/
|
||||
static void HandleContinuousScroll()
|
||||
{
|
||||
#define scrollspeed 0.05f
|
||||
if (_scrolling_viewport && _right_button_down) {
|
||||
Window *w = FindWindowFromPt(_right_button_down_pos.x, _right_button_down_pos.y);
|
||||
if (w == NULL || w->flags & WF_DISABLE_VP_SCROLL) return;
|
||||
ViewPort *vp = IsPtInWindowViewport(w, _right_button_down_pos.x, _right_button_down_pos.y);
|
||||
if (vp == NULL) return;
|
||||
|
||||
w->viewport->dest_scrollpos_x += ScaleByZoom(scrollspeed * (_right_button_down_pos.x - _cursor.pos.x), vp->zoom);
|
||||
w->viewport->dest_scrollpos_y += ScaleByZoom(scrollspeed * (_right_button_down_pos.y - _cursor.pos.y), vp->zoom);
|
||||
}
|
||||
#undef scrollspeed
|
||||
}
|
||||
|
||||
enum MouseClick {
|
||||
MC_NONE = 0,
|
||||
MC_LEFT,
|
||||
@@ -3096,6 +3114,7 @@ void InputLoop()
|
||||
/* HandleMouseEvents was already called for this tick */
|
||||
HandleMouseEvents();
|
||||
HandleAutoscroll();
|
||||
HandleContinuousScroll();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user