From 9658d1372d36220c2ff94242109bdfb7531fefa6 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Mon, 21 Jan 2019 18:23:22 -1000 Subject: [PATCH] Additional methods for SScrollDelta --- include/boo/IWindow.hpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/include/boo/IWindow.hpp b/include/boo/IWindow.hpp index 3a00b4a..03feb8f 100644 --- a/include/boo/IWindow.hpp +++ b/include/boo/IWindow.hpp @@ -64,11 +64,11 @@ struct STouchCoord { }; struct SScrollDelta { - double delta[2]; - bool isFine; /* Use system-scale fine-scroll (for scrollable-trackpads) */ + double delta[2] = {}; + bool isFine = false; /* Use system-scale fine-scroll (for scrollable-trackpads) */ bool isAccelerated = false; /* System performs acceleration computation */ - SScrollDelta operator+(const SScrollDelta& other) { + SScrollDelta operator+(const SScrollDelta& other) const { SScrollDelta ret; ret.delta[0] = delta[0] + other.delta[0]; ret.delta[1] = delta[1] + other.delta[1]; @@ -76,6 +76,14 @@ struct SScrollDelta { ret.isAccelerated = isAccelerated || other.isAccelerated; return ret; } + SScrollDelta operator-(const SScrollDelta& other) const { + SScrollDelta ret; + ret.delta[0] = delta[0] - other.delta[0]; + ret.delta[1] = delta[1] - other.delta[1]; + ret.isFine = isFine || other.isFine; + ret.isAccelerated = isAccelerated || other.isAccelerated; + return ret; + } SScrollDelta& operator+=(const SScrollDelta& other) { delta[0] += other.delta[0]; delta[1] += other.delta[1]; @@ -87,6 +95,7 @@ struct SScrollDelta { delta[0] = 0.0; delta[1] = 0.0; } + bool isZero() const { return delta[0] == 0.0 && delta[1] == 0.0; } }; enum class ESpecialKey {