#pragma once #include #include #include "key_event.h" #include "key_help.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; } // The keys that work right now, for the help panel (Fn+h): the App's own, in the state it's // in. Back, Home and the arrows are added for it. No screen names keys any other way. virtual void help(std::vector& out) const { (void)out; } // What the panel is titled with, when the App's name isn't enough ("Notes: editor"). virtual const char* helpTitle() const { return nullptr; } // 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