mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-04 22:57:50 +03:00
refactor: Update popup dimensions and styles; add sleep entry message
This commit is contained in:
parent
93ce00aed9
commit
d418948a76
@ -55,6 +55,8 @@ class GfxRenderer {
|
||||
int getScreenWidth() const;
|
||||
int getScreenHeight() 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 clearScreen(uint8_t color = 0xFF) const;
|
||||
|
||||
|
||||
@ -27,7 +27,11 @@ build_flags =
|
||||
# https://libexpat.github.io/doc/api/latest/#XML_GE
|
||||
-DXML_GE=0
|
||||
-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
|
||||
-DUSE_UTF8_LONG_NAMES=1
|
||||
|
||||
|
||||
@ -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,
|
||||
const int minWidth, const int minHeight) {
|
||||
constexpr int margin = 15;
|
||||
const int textWidth = renderer.getTextWidth(UI_12_FONT_ID, message, EpdFontFamily::BOLD);
|
||||
constexpr int margin = 16;
|
||||
const int contentWidth = textWidth > minWidth ? textWidth : minWidth;
|
||||
const int x = (renderer.getScreenWidth() - contentWidth - margin * 2) / 2;
|
||||
const int w = contentWidth + margin * 2;
|
||||
const int contentWidth = std::max(textWidth, minWidth);
|
||||
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, false);
|
||||
|
||||
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();
|
||||
return {x, y, w, h};
|
||||
}
|
||||
|
||||
void ScreenComponents::fillPopupProgress(const GfxRenderer& renderer, const PopupLayout& layout, const int progress) {
|
||||
const int barWidth = POPUP_DEFAULT_MIN_WIDTH;
|
||||
const int barHeight = POPUP_DEFAULT_BAR_HEIGHT;
|
||||
constexpr int barWidth = POPUP_DEFAULT_MIN_WIDTH;
|
||||
constexpr int barHeight = POPUP_DEFAULT_BAR_HEIGHT;
|
||||
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;
|
||||
if (fillWidth < 0) {
|
||||
@ -73,9 +75,8 @@ void ScreenComponents::fillPopupProgress(const GfxRenderer& renderer, const Popu
|
||||
fillWidth = barWidth;
|
||||
}
|
||||
|
||||
if (fillWidth > 2) {
|
||||
renderer.fillRect(barX + 1, barY + 1, fillWidth - 2, barHeight - 2, true);
|
||||
}
|
||||
renderer.fillRect(barX, barY, fillWidth, barHeight, true);
|
||||
|
||||
renderer.displayBuffer(EInkDisplay::FAST_REFRESH);
|
||||
}
|
||||
|
||||
|
||||
@ -13,9 +13,9 @@ struct TabInfo {
|
||||
|
||||
class ScreenComponents {
|
||||
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_HEIGHT = 72;
|
||||
static constexpr int POPUP_DEFAULT_BAR_HEIGHT = 4;
|
||||
|
||||
struct PopupLayout {
|
||||
int x;
|
||||
@ -26,7 +26,7 @@ class ScreenComponents {
|
||||
|
||||
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);
|
||||
|
||||
static void fillPopupProgress(const GfxRenderer& renderer, const PopupLayout& layout, int progress);
|
||||
|
||||
@ -11,10 +11,13 @@
|
||||
#include "fontIds.h"
|
||||
#include "images/CrossLarge.h"
|
||||
#include "util/StringUtils.h"
|
||||
#include "ScreenComponents.h"
|
||||
|
||||
void SleepActivity::onEnter() {
|
||||
Activity::onEnter();
|
||||
|
||||
ScreenComponents::drawPopup(renderer, "Entering Sleep...");
|
||||
|
||||
if (SETTINGS.sleepScreen == CrossPointSettings::SLEEP_SCREEN_MODE::BLANK) {
|
||||
return renderBlankSleepScreen();
|
||||
}
|
||||
|
||||
@ -332,6 +332,9 @@ void setup() {
|
||||
|
||||
setupDisplayAndFonts();
|
||||
|
||||
exitActivity();
|
||||
enterNewActivity(new BootActivity(renderer, mappedInputManager));
|
||||
|
||||
APP_STATE.loadFromFile();
|
||||
RECENT_BOOKS.loadFromFile();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user