Public Access
; . , / are arrows on their own unless the foreground App is editing text (App::textEntryActive); Fn + those keys are arrows everywhere. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
46 lines
1.0 KiB
C++
46 lines
1.0 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
|
|
#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
|