small improvements
This commit is contained in:
+3
-5
@@ -23,11 +23,9 @@ UIElement::UIElement(Arduino_GFX *d, UIDimensions dims, UIDecorations decor,
|
||||
|
||||
UIElement::~UIElement() {
|
||||
// Destruction involves redrawing over the "old" area
|
||||
|
||||
// TODO: should we have a separate place to do all the drawing?
|
||||
this->display->fillRect(this->dims.x, this->dims.y,
|
||||
this->dims.width, this->dims.height,
|
||||
this->decor.bgColor);
|
||||
|
||||
fillRect(this->dims.x, this->dims.y, this->dims.width, this->dims.height,
|
||||
this->decor.bgColor, this->display);
|
||||
}
|
||||
|
||||
int16_t UIElement::getContentAreaX0() {
|
||||
|
||||
+8
-4
@@ -2,13 +2,17 @@
|
||||
#define __UI_DECORATIONS
|
||||
|
||||
#include "UIDrawing.h"
|
||||
#include <cstdint>
|
||||
#include <stdint.h>
|
||||
|
||||
struct UIDecorations {
|
||||
bool hasBorder = true;
|
||||
uint16_t bgColor = MAIN_BG_COLOR, fgColor = MAIN_FG_COLOR;
|
||||
uint16_t titleColor = MAIN_FG_COLOR, borderColor = RED;
|
||||
uint8_t titleSize = 2, textSize = 4;
|
||||
uint16_t bgColor = MAIN_BG_COLOR;
|
||||
uint16_t fgColor = MAIN_FG_COLOR;
|
||||
uint16_t titleColor = MAIN_FG_COLOR;
|
||||
uint16_t borderColor = RED;
|
||||
uint8_t titleSize = 2;
|
||||
uint8_t textSize = 4;
|
||||
uint8_t hasBorder = true;
|
||||
|
||||
UIDecorations();
|
||||
UIDecorations(uint16_t bg, uint16_t fg, uint16_t title, uint16_t border,
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "UIDimensions.h"
|
||||
|
||||
UIDimensions::UIDimensions() : x(0), y(0), width(0), height(0) {}
|
||||
|
||||
UIDimensions::UIDimensions(uint16_t x, uint16_t y, uint16_t w, uint16_t h)
|
||||
: x(x), y(y), width(w), height(h) {}
|
||||
|
||||
|
||||
+6
-2
@@ -1,12 +1,16 @@
|
||||
#ifndef __UI_DIMENSIONS__
|
||||
#define __UI_DIMENSIONS__
|
||||
|
||||
#include <cstdint>
|
||||
#include <stdint.h>
|
||||
|
||||
struct UIDimensions {
|
||||
uint16_t x = 0, y = 0;
|
||||
uint16_t width = 0, height = 0;
|
||||
uint16_t x = 0;
|
||||
uint16_t y = 0;
|
||||
uint16_t width = 0;
|
||||
uint16_t height = 0;
|
||||
|
||||
UIDimensions();
|
||||
UIDimensions(uint16_t x, uint16_t y, uint16_t w, uint16_t h);
|
||||
UIDimensions& operator=(const UIDimensions& other);
|
||||
};
|
||||
|
||||
@@ -106,3 +106,9 @@ void UIElement::drawBox() {
|
||||
this->dims.height, PURPLE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
|
||||
uint16_t colour, Arduino_GFX *display) {
|
||||
// TODO: should we have a separate place to do all the drawing?
|
||||
display->fillRect(x, y, w, h, colour);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define __CURSES_UI_VISUALS
|
||||
|
||||
#include <Arduino_GFX.h>
|
||||
#include <cstdint>
|
||||
|
||||
#define RIGHT 0
|
||||
#define INVERTED 1
|
||||
@@ -21,5 +22,7 @@
|
||||
|
||||
uint16_t calculateHeight(int16_t titleSize, int16_t textSize, int16_t nLines);
|
||||
uint16_t calculateWidth(int16_t textSize, int16_t nChars);
|
||||
void fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
|
||||
uint16_t colour, Arduino_GFX *display);
|
||||
|
||||
#endif
|
||||
|
||||
+2
-3
@@ -4,6 +4,7 @@
|
||||
#include "UIString.h"
|
||||
#include "UITable.h"
|
||||
#include "values.h"
|
||||
#include "logger.h"
|
||||
|
||||
namespace WindowPool {
|
||||
WindowEntry pool[MAX_WINDOWS];
|
||||
@@ -90,9 +91,7 @@ namespace WindowPool {
|
||||
void PrintInUse() {
|
||||
for (int k = 0; k < MAX_WINDOWS; k++) {
|
||||
if (inUse[k]) {
|
||||
Serial2.print(k);
|
||||
Serial2.print(" : ");
|
||||
Serial2.println(inUse[k]);
|
||||
LOG_TRACE(F("Window in use: %d : %d\n"), k, inUse[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user