diff options
| author | Niall Cooling <niallcooling@gmail.com> | 2021-03-22 17:23:49 +0000 |
|---|---|---|
| committer | Niall Cooling <niallcooling@gmail.com> | 2021-03-22 17:23:49 +0000 |
| commit | e5e3fc02b8a2adf9ea100c162d1290cecdf617ef (patch) | |
| tree | 78d4da0239ff8bf7a8694c28f804f81d2496979f /src/displayapp/screens/Screen.h | |
| parent | 14bd790701f4e2f6d75ef8a1f52b9f38023c2dd9 (diff) | |
| parent | 9f9d0eb5df8ff86b9cd1e095afa3159094dde53c (diff) | |
Updated to include WatchFaceAnalog and fixed clashes
Diffstat (limited to 'src/displayapp/screens/Screen.h')
| -rw-r--r-- | src/displayapp/screens/Screen.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/displayapp/screens/Screen.h b/src/displayapp/screens/Screen.h index 6b1d0eec..638dac99 100644 --- a/src/displayapp/screens/Screen.h +++ b/src/displayapp/screens/Screen.h @@ -7,6 +7,26 @@ namespace Pinetime { namespace Applications { class DisplayApp; namespace Screens { + + template <class T> + class DirtyValue { + public: + DirtyValue() = default; // Use NSDMI + explicit DirtyValue(T const& v):value{v}{} // Use MIL and const-lvalue-ref + bool IsUpdated() const { return isUpdated; } + T const& Get() { this->isUpdated = false; return value; } // never expose a non-const lvalue-ref + DirtyValue& operator=(const T& other) { + if (this->value != other) { + this->value = other; + this->isUpdated = true; + } + return *this; + } + private: + T value{}; // NSDMI - default initialise type + bool isUpdated{true}; // NSDMI - use brace initilisation + }; + class Screen { public: explicit Screen(DisplayApp* app) : app{app} {} |
