#pragma once #include #include "key_event.h" namespace roro { class Canvas; // provided by the widget kit // A foreground, user-facing program (see CONTEXT.md). Exactly one App is on screen at a time. class App { public: virtual ~App() = default; virtual void onEnter() {} virtual void onExit() {} // Return true if the key was consumed. An unconsumed Back leaves the App. virtual bool onKey(const KeyEvent& event) { (void)event; return false; } // True while the App is editing text: the arrow keys then type ; . , / and need Fn to move. virtual bool textEntryActive() const { return false; } // Called every main-loop pass while in the foreground (e.g. to refresh live values). virtual void update(uint32_t nowMs) { (void)nowMs; } virtual void draw(Canvas& canvas) = 0; void requestRedraw() { redraw_ = true; } bool consumeRedraw() { bool r = redraw_; redraw_ = false; return r; } private: bool redraw_ = false; }; } // namespace roro