refactor: Update popup dimensions and styles; add sleep entry message

This commit is contained in:
Arthur Tazhitdinov 2026-01-22 18:35:28 +05:00
parent 93ce00aed9
commit d418948a76
6 changed files with 29 additions and 16 deletions

View File

@ -55,6 +55,8 @@ class GfxRenderer {
int getScreenWidth() const; int getScreenWidth() const;
int getScreenHeight() const; int getScreenHeight() const;
void displayBuffer(EInkDisplay::RefreshMode refreshMode = EInkDisplay::FAST_REFRESH) const; void displayBuffer(EInkDisplay::RefreshMode refreshMode = EInkDisplay::FAST_REFRESH) const;
// EXPERIMENTAL: Windowed update - display only a rectangular region -- not implemented
// void displayWindow(int x, int y, int width, int height) const;
void invertScreen() const; void invertScreen() const;
void clearScreen(uint8_t color = 0xFF) const; void clearScreen(uint8_t color = 0xFF) const;

View File

@ -27,7 +27,11 @@ build_flags =
# https://libexpat.github.io/doc/api/latest/#XML_GE # https://libexpat.github.io/doc/api/latest/#XML_GE
-DXML_GE=0 -DXML_GE=0
-DXML_CONTEXT_BYTES=1024 -DXML_CONTEXT_BYTES=1024
-std=c++2a ; -std=c++2a
-std=gnu++2a
build_unflags = -std=gnu++11
# Enable UTF-8 long file names in SdFat # Enable UTF-8 long file names in SdFat
-DUSE_UTF8_LONG_NAMES=1 -DUSE_UTF8_LONG_NAMES=1

View File

@ -44,27 +44,29 @@ void ScreenComponents::drawBattery(const GfxRenderer& renderer, const int left,
ScreenComponents::PopupLayout ScreenComponents::drawPopup(const GfxRenderer& renderer, const char* message, const int y, ScreenComponents::PopupLayout ScreenComponents::drawPopup(const GfxRenderer& renderer, const char* message, const int y,
const int minWidth, const int minHeight) { const int minWidth, const int minHeight) {
constexpr int margin = 15;
const int textWidth = renderer.getTextWidth(UI_12_FONT_ID, message, EpdFontFamily::BOLD); const int textWidth = renderer.getTextWidth(UI_12_FONT_ID, message, EpdFontFamily::BOLD);
constexpr int margin = 16; const int contentWidth = std::max(textWidth, minWidth);
const int contentWidth = textWidth > minWidth ? textWidth : minWidth;
const int x = (renderer.getScreenWidth() - contentWidth - margin * 2) / 2;
const int w = contentWidth + margin * 2;
const int contentHeight = renderer.getLineHeight(UI_12_FONT_ID) + margin * 2; const int contentHeight = renderer.getLineHeight(UI_12_FONT_ID) + margin * 2;
const int h = contentHeight >= minHeight ? contentHeight : minHeight; const int w = contentWidth + margin * 2 + 50;
// const int x = (renderer.getScreenWidth() - w) / 2;
const int x = renderer.getScreenWidth() - w - margin;
const int h = std::max(contentHeight, minHeight);
renderer.fillRect(x - 2, y - 2, w + 4, h + 4, true); renderer.fillRect(x - 2, y - 2, w + 4, h + 4, true);
renderer.fillRect(x + 2, y + 2, w - 4, h - 4, false); renderer.fillRect(x + 2, y + 2, w - 4, h - 4, false);
const int textX = x + margin + (contentWidth - textWidth) / 2; const int textX = x + margin + (contentWidth - textWidth) / 2;
renderer.drawText(UI_12_FONT_ID, textX, y + margin, message, true, EpdFontFamily::BOLD); // renderer.drawText(UI_12_FONT_ID, textX, y + margin + 4, message, true, EpdFontFamily::BOLD);
renderer.drawText(NOTOSANS_18_FONT_ID, textX, y + margin + 4, message, true, EpdFontFamily::BOLD);
renderer.displayBuffer(); renderer.displayBuffer();
return {x, y, w, h}; return {x, y, w, h};
} }
void ScreenComponents::fillPopupProgress(const GfxRenderer& renderer, const PopupLayout& layout, const int progress) { void ScreenComponents::fillPopupProgress(const GfxRenderer& renderer, const PopupLayout& layout, const int progress) {
const int barWidth = POPUP_DEFAULT_MIN_WIDTH; constexpr int barWidth = POPUP_DEFAULT_MIN_WIDTH;
const int barHeight = POPUP_DEFAULT_BAR_HEIGHT; constexpr int barHeight = POPUP_DEFAULT_BAR_HEIGHT;
const int barX = layout.x + (layout.width - barWidth) / 2; const int barX = layout.x + (layout.width - barWidth) / 2;
const int barY = layout.y + layout.height - 16; // 16 pixels above bottom of popup const int barY = layout.y + layout.height - 15;
int fillWidth = barWidth * progress / 100; int fillWidth = barWidth * progress / 100;
if (fillWidth < 0) { if (fillWidth < 0) {
@ -73,9 +75,8 @@ void ScreenComponents::fillPopupProgress(const GfxRenderer& renderer, const Popu
fillWidth = barWidth; fillWidth = barWidth;
} }
if (fillWidth > 2) { renderer.fillRect(barX, barY, fillWidth, barHeight, true);
renderer.fillRect(barX + 1, barY + 1, fillWidth - 2, barHeight - 2, true);
}
renderer.displayBuffer(EInkDisplay::FAST_REFRESH); renderer.displayBuffer(EInkDisplay::FAST_REFRESH);
} }

View File

@ -13,9 +13,9 @@ struct TabInfo {
class ScreenComponents { class ScreenComponents {
public: public:
static constexpr int POPUP_DEFAULT_MIN_HEIGHT = 72;
static constexpr int POPUP_DEFAULT_BAR_HEIGHT = 6;
static constexpr int POPUP_DEFAULT_MIN_WIDTH = 200; static constexpr int POPUP_DEFAULT_MIN_WIDTH = 200;
static constexpr int POPUP_DEFAULT_MIN_HEIGHT = 72;
static constexpr int POPUP_DEFAULT_BAR_HEIGHT = 4;
struct PopupLayout { struct PopupLayout {
int x; int x;
@ -26,7 +26,7 @@ class ScreenComponents {
static void drawBattery(const GfxRenderer& renderer, int left, int top, bool showPercentage = true); static void drawBattery(const GfxRenderer& renderer, int left, int top, bool showPercentage = true);
static PopupLayout drawPopup(const GfxRenderer& renderer, const char* message, int y = 117, static PopupLayout drawPopup(const GfxRenderer& renderer, const char* message, int y = 125,
int minWidth = POPUP_DEFAULT_MIN_WIDTH, int minHeight = POPUP_DEFAULT_MIN_HEIGHT); int minWidth = POPUP_DEFAULT_MIN_WIDTH, int minHeight = POPUP_DEFAULT_MIN_HEIGHT);
static void fillPopupProgress(const GfxRenderer& renderer, const PopupLayout& layout, int progress); static void fillPopupProgress(const GfxRenderer& renderer, const PopupLayout& layout, int progress);

View File

@ -11,10 +11,13 @@
#include "fontIds.h" #include "fontIds.h"
#include "images/CrossLarge.h" #include "images/CrossLarge.h"
#include "util/StringUtils.h" #include "util/StringUtils.h"
#include "ScreenComponents.h"
void SleepActivity::onEnter() { void SleepActivity::onEnter() {
Activity::onEnter(); Activity::onEnter();
ScreenComponents::drawPopup(renderer, "Entering Sleep...");
if (SETTINGS.sleepScreen == CrossPointSettings::SLEEP_SCREEN_MODE::BLANK) { if (SETTINGS.sleepScreen == CrossPointSettings::SLEEP_SCREEN_MODE::BLANK) {
return renderBlankSleepScreen(); return renderBlankSleepScreen();
} }

View File

@ -332,6 +332,9 @@ void setup() {
setupDisplayAndFonts(); setupDisplayAndFonts();
exitActivity();
enterNewActivity(new BootActivity(renderer, mappedInputManager));
APP_STATE.loadFromFile(); APP_STATE.loadFromFile();
RECENT_BOOKS.loadFromFile(); RECENT_BOOKS.loadFromFile();