diff --git a/lib/cursesAtHome/src/UITable.cpp b/lib/cursesAtHome/src/UITable.cpp index a853789..ebe8656 100644 --- a/lib/cursesAtHome/src/UITable.cpp +++ b/lib/cursesAtHome/src/UITable.cpp @@ -2,6 +2,7 @@ #include "HardwareSerial.h" #include "UIDecorations.h" #include "UIDrawing.h" +#include #define DEBUG @@ -12,6 +13,8 @@ UITable::UITable(Arduino_GFX *gfx, UIDimensions dims, UIDecorations *decor, // Default decoration for every cell UIDecorations *cellDecor = new UIDecorations(); + cellDecor->textSize = 2; + this->decor->textSize = 2; for (int k = 0; k < ROWS * COLUMNS; k++) { this->tableData[k].decor = cellDecor; @@ -21,6 +24,15 @@ UITable::UITable(Arduino_GFX *gfx, UIDimensions dims, UIDecorations *decor, this->tableData[k].dims.height = 0; this->tableData[k].display = this->display; } + + int cellH = CHR_HEIGHT(this->decor->textSize) + CELL_MARGIN; + + // Initialize the table dimensions + this->dims.height = ROWS * cellH + this->getTitleAreaHeight() + + DEFAULT_MARGIN + DEFAULT_BORDER_THICKNESS; + this->dims.width = + (DEFAULT_BORDER_THICKNESS + DEFAULT_MARGIN) * 2 + + (CHR_WIDTH(this->decor->textSize) + CELL_MARGIN) * (3 + 24 + 5); } uint16_t UITable::getContentAreaHeight() { @@ -35,9 +47,9 @@ uint16_t UITable::getContentAreaHeight() { */ void UITable::setup() { // Define the cell dimensions - int tableCellW[] = {3 * (CHR_WIDTH(this->decor->textSize) + 2), - 24 * (CHR_WIDTH(this->decor->textSize) + 2), - 5 * (CHR_WIDTH(this->decor->textSize) + 2)}; + int tableCellW[] = {3 * (CHR_WIDTH(this->decor->textSize) + CELL_MARGIN), + 24 * (CHR_WIDTH(this->decor->textSize) + CELL_MARGIN), + 5 * (CHR_WIDTH(this->decor->textSize) + CELL_MARGIN)}; int cellH = CHR_HEIGHT(this->decor->textSize) + CELL_MARGIN; // Initialize the cells @@ -60,15 +72,4 @@ void UITable::setup() { #endif } } - - // Initialize the table dimensions - this->dims.height = ROWS * cellH + this->getTitleAreaHeight(); - this->dims.width = - (3 + 24 + 5 + CELL_MARGIN) * CHR_WIDTH(this->decor->textSize); -} - -void UITable::initDimensions() { - // Calculate the height - - // Calculate the width } diff --git a/lib/cursesAtHome/src/UITable.h b/lib/cursesAtHome/src/UITable.h index 5b1ac25..b43b631 100644 --- a/lib/cursesAtHome/src/UITable.h +++ b/lib/cursesAtHome/src/UITable.h @@ -20,7 +20,6 @@ struct UITable : UIElement { UITable(Arduino_GFX *gfx, UIDimensions dims, UIDecorations *decor, char *t); // void Update(StandingLine standings[5]); - void initDimensions(); void setup(); // Getters diff --git a/src/main.cpp b/src/main.cpp index 3374165..1cead81 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -77,6 +77,10 @@ void setup() { // Setup the relative relativeDecor->textSize = 2; + relative.dims.x = gfx->width() - relative.dims.width; + relative.dims.y = gfx->height() - relative.dims.height; + // relative.dims.x = 250; + // relative.dims.y = 250; relative.setup(); relative.drawBox();