diff --git a/src/UIComponent.cpp b/src/UIComponent.cpp index 01284a2..54a62cf 100644 --- a/src/UIComponent.cpp +++ b/src/UIComponent.cpp @@ -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() { diff --git a/src/UIDecorations.h b/src/UIDecorations.h index 9633a2c..2477b5e 100644 --- a/src/UIDecorations.h +++ b/src/UIDecorations.h @@ -2,13 +2,17 @@ #define __UI_DECORATIONS #include "UIDrawing.h" +#include #include 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, diff --git a/src/UIDimensions.cpp b/src/UIDimensions.cpp index cca7b66..c3b20f1 100644 --- a/src/UIDimensions.cpp +++ b/src/UIDimensions.cpp @@ -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) {} diff --git a/src/UIDimensions.h b/src/UIDimensions.h index 844f669..54576e7 100644 --- a/src/UIDimensions.h +++ b/src/UIDimensions.h @@ -1,12 +1,16 @@ #ifndef __UI_DIMENSIONS__ #define __UI_DIMENSIONS__ +#include #include 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); }; diff --git a/src/UIDrawing.cpp b/src/UIDrawing.cpp index 4a3edb8..47d78ae 100644 --- a/src/UIDrawing.cpp +++ b/src/UIDrawing.cpp @@ -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); +} diff --git a/src/UIDrawing.h b/src/UIDrawing.h index 0650435..fe9ac63 100644 --- a/src/UIDrawing.h +++ b/src/UIDrawing.h @@ -2,6 +2,7 @@ #define __CURSES_UI_VISUALS #include +#include #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 diff --git a/src/windowPool.cpp b/src/windowPool.cpp index 10a820c..32140e1 100644 --- a/src/windowPool.cpp +++ b/src/windowPool.cpp @@ -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]); } } }