Public Access
Add widget kit, input layer with Compose Key, Launcher and demo apps
Steps 5 and 6 of M0. - lib/ui (host-tested): ListModel, LineEditor (UTF-8, byte-limited), wrapText, ToastQueue, DialogModel - lib/input (host-tested): KeyMapper turns keyboard state into logical keys (Fn arrows, ` Back, Fn+` Home) and composes accents with opt - src/ui: off-screen 16-bit frame pushed in one transfer (fixes the flicker), Status Bar, list, text, line editor, dialog, Toast widgets, Notifier (Toast + beep + LED), vendored public-domain Latin-1 fonts - Apps: minimal Launcher, Widget demo, Diagnostics (SD erase now behind a confirmation dialog) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
#include "toast_queue.h"
|
||||
|
||||
namespace roro {
|
||||
|
||||
void ToastQueue::push(const std::string& text, NotificationLevel level, uint32_t nowMs) {
|
||||
current(nowMs); // retire an expired Toast first, so the new one gets its full time
|
||||
if (queue_.size() == capacity_) {
|
||||
// Keep the visible one; drop the oldest waiting.
|
||||
queue_.erase(queue_.begin() + (showing_ && queue_.size() > 1 ? 1 : 0));
|
||||
if (!showing_) changed_ = true;
|
||||
}
|
||||
queue_.push_back({text, level});
|
||||
if (!showing_) {
|
||||
showing_ = true;
|
||||
shownAtMs_ = nowMs;
|
||||
changed_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
const Toast* ToastQueue::current(uint32_t nowMs) {
|
||||
if (!showing_) return nullptr;
|
||||
if (nowMs - shownAtMs_ >= durationMs_) dismiss(shownAtMs_ + durationMs_);
|
||||
return showing_ ? &queue_.front() : nullptr;
|
||||
}
|
||||
|
||||
void ToastQueue::dismiss(uint32_t nowMs) {
|
||||
if (!showing_) return;
|
||||
queue_.pop_front();
|
||||
changed_ = true;
|
||||
showing_ = !queue_.empty();
|
||||
shownAtMs_ = nowMs;
|
||||
}
|
||||
|
||||
bool ToastQueue::takeChanged() {
|
||||
bool c = changed_;
|
||||
changed_ = false;
|
||||
return c;
|
||||
}
|
||||
|
||||
} // namespace roro
|
||||
Reference in New Issue
Block a user