Description:
Only scroll after a slight delay. Wait about 1/3 of a second before beginning to scroll. Otherwise it becomes too easy to trigger by mistake when mousing over to the toolbar.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r697:4370c4f6e8f8 -

@@ -46,6 +46,9
46 private int height;
46 private int height;
47 private int width;
47 private int width;
48
48
49 private double timeInRange;
50 private const double SCROLL_THRESHOLD = 0.333f;
51
49 public InputEngine(int menuBarHeight, Camera camera,
52 public InputEngine(int menuBarHeight, Camera camera,
50 GraphicsDeviceManager gdm, int height, int width) {
53 GraphicsDeviceManager gdm, int height, int width) {
51 //initialize to blank for now
54 //initialize to blank for now
@@ -56,6 +59,8
56 this.graphicsDevice = gdm.GraphicsDevice;
59 this.graphicsDevice = gdm.GraphicsDevice;
57 this.height = height;
60 this.height = height;
58 this.width = width;
61 this.width = width;
62
63 this.timeInRange = 0.0f;
59 }
64 }
60
65
61
66
@@ -245,20 +250,33
245 #endregion misc_keys
250 #endregion misc_keys
246 #region mouse_movement
251 #region mouse_movement
247
252
253 var within_top_range = MathUtils.BetweenExclusive(mouseCur.Y, menuBarHeight, 50 + menuBarHeight);
254 var within_bottom_range = MathUtils.BetweenExclusive(mouseCur.Y, (viewHeight - 50 -menuBarHeight), viewHeight-menuBarHeight);
255 var within_left_range = MathUtils.BetweenExclusive(mouseCur.X, 0, 50);
256 var within_right_range = MathUtils.BetweenExclusive(mouseCur.X, (viewWidth - 50), viewWidth);
248
257
249 if (MathUtils.BetweenExclusive(mouseCur.Y, menuBarHeight, 50 + menuBarHeight))
258 if (within_top_range || within_bottom_range || within_right_range || within_left_range)
259 {
260 this.timeInRange += dt;
261 }
262 else
263 {
264 this.timeInRange = 0;
265 }
266
267 if (within_top_range && this.timeInRange > SCROLL_THRESHOLD)
250 {
268 {
251 SendMessage(new MoveCameraMessage {Movement = new Vector2(0, -4)});
269 SendMessage(new MoveCameraMessage {Movement = new Vector2(0, -4)});
252 }
270 }
253 else if (MathUtils.BetweenExclusive(mouseCur.Y, (viewHeight - 50 -menuBarHeight), viewHeight-menuBarHeight))
271 else if (within_bottom_range && this.timeInRange > SCROLL_THRESHOLD)
254 {
272 {
255 SendMessage(new MoveCameraMessage {Movement = new Vector2(0, 4)});
273 SendMessage(new MoveCameraMessage {Movement = new Vector2(0, 4)});
256 }
274 }
257 if (MathUtils.BetweenExclusive(mouseCur.X, 0, 50))
275 if (within_left_range && this.timeInRange > SCROLL_THRESHOLD)
258 {
276 {
259 SendMessage(new MoveCameraMessage {Movement = new Vector2(-4, 0)});
277 SendMessage(new MoveCameraMessage {Movement = new Vector2(-4, 0)});
260 }
278 }
261 else if (MathUtils.BetweenExclusive(mouseCur.X, (viewWidth - 50), viewWidth))
279 else if (within_right_range && this.timeInRange > SCROLL_THRESHOLD)
262 {
280 {
263 SendMessage(new MoveCameraMessage {Movement = new Vector2(4, 0)});
281 SendMessage(new MoveCameraMessage {Movement = new Vector2(4, 0)});
264 }
282 }
You need to be logged in to leave comments. Login now