Additional methods for SScrollDelta

This commit is contained in:
Jack Andersen 2019-01-21 18:23:22 -10:00
parent 8333536a7c
commit 9658d1372d

View File

@ -64,11 +64,11 @@ struct STouchCoord {
}; };
struct SScrollDelta { struct SScrollDelta {
double delta[2]; double delta[2] = {};
bool isFine; /* Use system-scale fine-scroll (for scrollable-trackpads) */ bool isFine = false; /* Use system-scale fine-scroll (for scrollable-trackpads) */
bool isAccelerated = false; /* System performs acceleration computation */ bool isAccelerated = false; /* System performs acceleration computation */
SScrollDelta operator+(const SScrollDelta& other) { SScrollDelta operator+(const SScrollDelta& other) const {
SScrollDelta ret; SScrollDelta ret;
ret.delta[0] = delta[0] + other.delta[0]; ret.delta[0] = delta[0] + other.delta[0];
ret.delta[1] = delta[1] + other.delta[1]; ret.delta[1] = delta[1] + other.delta[1];
@ -76,6 +76,14 @@ struct SScrollDelta {
ret.isAccelerated = isAccelerated || other.isAccelerated; ret.isAccelerated = isAccelerated || other.isAccelerated;
return ret; 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) { SScrollDelta& operator+=(const SScrollDelta& other) {
delta[0] += other.delta[0]; delta[0] += other.delta[0];
delta[1] += other.delta[1]; delta[1] += other.delta[1];
@ -87,6 +95,7 @@ struct SScrollDelta {
delta[0] = 0.0; delta[0] = 0.0;
delta[1] = 0.0; delta[1] = 0.0;
} }
bool isZero() const { return delta[0] == 0.0 && delta[1] == 0.0; }
}; };
enum class ESpecialKey { enum class ESpecialKey {