Immensely tidied Screen3's handling of fixed/thermo mode by adding _printInverted to CScreen
This commit is contained in:
parent
abc8f63590
commit
a784943349
|
@ -56,33 +56,15 @@ CScreen3::show(const CProtocol& CtlFrame, const CProtocol& HtrFrame)
|
||||||
// show next/prev screen navigation line
|
// show next/prev screen navigation line
|
||||||
_drawMenuTextCentreJustified(_display.xCentre(), Row[0], _rowSel == 0, Label0);
|
_drawMenuTextCentreJustified(_display.xCentre(), Row[0], _rowSel == 0, Label0);
|
||||||
|
|
||||||
// thermostat / fixed mode selection menu
|
|
||||||
// highlight active state - depends if line is active whetehr this is an open box, or inverse text
|
|
||||||
int col = getThermostatMode() ? 0 : 1; // follow actual heater settings
|
int col = getThermostatMode() ? 0 : 1; // follow actual heater settings
|
||||||
_display.getTextExtents(Label1[col], extents);
|
|
||||||
extents.xPos = (col == 0) ? border : _display.width() - extents.width - border;
|
|
||||||
extents.yPos = Row[1];
|
|
||||||
if(_rowSel == 1) {
|
if(_rowSel == 1) {
|
||||||
// draw selection box
|
_drawMenuText(border, Row[1], col == 0, Label1[0]);
|
||||||
_drawSelectionBox(extents.xPos, extents.yPos, Label1[col]);
|
_drawMenuTextRightJustified(_display.width()-border, Row[1], col == 1, Label1[1]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// draw white background, expanded about usual text size
|
_printInverted(border, Row[1], col == 0, Label1[0]);
|
||||||
extents.Expand(1);
|
_printInverted(_display.width()-border, Row[1], col == 1, Label1[1], eRightJustify);
|
||||||
_display.fillRect(extents.xPos, extents.yPos, extents.width, extents.height, WHITE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(col == 0 && _rowSel != 1)
|
|
||||||
_display.setTextColor(BLACK);
|
|
||||||
_display.setCursor(border, Row[1]);
|
|
||||||
_display.print(Label1[0]);
|
|
||||||
_display.setTextColor(WHITE);
|
|
||||||
|
|
||||||
if(col == 1 && _rowSel != 1)
|
|
||||||
_display.setTextColor(BLACK);
|
|
||||||
_display.setCursor(_display.width() - border, Row[1]);
|
|
||||||
_display.printRightJustified(Label1[1]);
|
|
||||||
_display.setTextColor(WHITE);
|
|
||||||
|
|
||||||
// fuel pump priming menu
|
// fuel pump priming menu
|
||||||
_drawMenuText(Col[0], Row[2], "Prime pump");
|
_drawMenuText(Col[0], Row[2], "Prime pump");
|
||||||
|
|
|
@ -377,6 +377,14 @@ CScreen::_drawMenuText(int x, int y, bool selected, const char* str, int border,
|
||||||
_drawSelectionBox(x, y, str, border, radius);
|
_drawSelectionBox(x, y, str, border, radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*void
|
||||||
|
CScreen::_drawMenuText(int x, int y, bool selected, const char* str, eJUSTIFY justify, int border, int radius)
|
||||||
|
{
|
||||||
|
_drawMenuText(x, y, str);
|
||||||
|
if(selected)
|
||||||
|
_drawSelectionBox(x, y, str, border, radius);
|
||||||
|
}*/
|
||||||
|
|
||||||
void
|
void
|
||||||
CScreen::_drawMenuTextCentreJustified(int x, int y, const char* str)
|
CScreen::_drawMenuTextCentreJustified(int x, int y, const char* str)
|
||||||
{
|
{
|
||||||
|
@ -408,29 +416,29 @@ CScreen::_drawMenuTextRightJustified(int x, int y, bool selected, const char* st
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CScreen::_printInverted(int x, int y, const char* str)
|
CScreen::_printInverted(int x, int y, const char* str, eJUSTIFY justify)
|
||||||
{
|
{
|
||||||
_display.setCursor(x, y);
|
_printInverted( x, y, true, str, justify);
|
||||||
_display.setTextColor(BLACK);
|
|
||||||
_display.print(str);
|
|
||||||
_display.setTextColor(WHITE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CScreen::_printInvertedConditional(int x, int y, bool selected, const char* str)
|
CScreen::_printInverted(int x, int y, bool selected, const char* str, eJUSTIFY justify)
|
||||||
{
|
{
|
||||||
|
// position output, according to justification
|
||||||
|
CRect extents;
|
||||||
|
extents.xPos = x;
|
||||||
|
extents.yPos = y;
|
||||||
|
_adjustExtents(extents, justify, str);
|
||||||
|
|
||||||
if(selected) {
|
if(selected) {
|
||||||
_display.setTextColor(BLACK);
|
_display.setTextColor(BLACK, WHITE);
|
||||||
CRect extents;
|
|
||||||
_display.getTextExtents(str, extents);
|
|
||||||
extents.xPos = x;
|
|
||||||
extents.yPos = y;
|
|
||||||
extents.Expand(1);
|
extents.Expand(1);
|
||||||
_display.fillRect(extents.xPos, extents.yPos, extents.width, extents.height, WHITE);
|
_display.fillRect(extents.xPos, extents.yPos, extents.width, extents.height, WHITE);
|
||||||
|
extents.Expand(-1);
|
||||||
}
|
}
|
||||||
_display.setCursor(x, y);
|
_display.setCursor(extents.xPos, extents.yPos);
|
||||||
_display.print(str);
|
_display.print(str);
|
||||||
_display.setTextColor(WHITE);
|
_display.setTextColor(WHITE, BLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
CAutoFont::CAutoFont(C128x64_OLED& disp, const FONT_INFO* pFont) :
|
CAutoFont::CAutoFont(C128x64_OLED& disp, const FONT_INFO* pFont) :
|
||||||
|
@ -444,3 +452,17 @@ CAutoFont::~CAutoFont()
|
||||||
{
|
{
|
||||||
_display.setFontInfo(NULL);
|
_display.setFontInfo(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CScreen::_adjustExtents(CRect& extents, eJUSTIFY justify, const char* str)
|
||||||
|
{
|
||||||
|
_display.getTextExtents(str, extents);
|
||||||
|
switch(justify) {
|
||||||
|
case eCentreJustify:
|
||||||
|
extents.xPos -= extents.width/2;
|
||||||
|
break;
|
||||||
|
case eRightJustify:
|
||||||
|
extents.xPos -= extents.width;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -24,11 +24,17 @@
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "FontTypes.h"
|
#include "FontTypes.h"
|
||||||
|
#include "UtilClasses.h"
|
||||||
|
|
||||||
|
|
||||||
class CProtocol;
|
class CProtocol;
|
||||||
class C128x64_OLED;
|
class C128x64_OLED;
|
||||||
class CScreen;
|
class CScreen;
|
||||||
|
struct CRect;
|
||||||
|
|
||||||
|
enum eJUSTIFY {
|
||||||
|
eLeftJustify, eCentreJustify, eRightJustify
|
||||||
|
};
|
||||||
|
|
||||||
class CScreenManager {
|
class CScreenManager {
|
||||||
static const int _maxScreens = 5;
|
static const int _maxScreens = 5;
|
||||||
|
@ -66,8 +72,9 @@ protected:
|
||||||
void _drawMenuTextCentreJustified(int x, int y, bool selected, const char* str, int border = 3, int radius = 4);
|
void _drawMenuTextCentreJustified(int x, int y, bool selected, const char* str, int border = 3, int radius = 4);
|
||||||
void _drawMenuTextRightJustified(int x, int y, const char* str);
|
void _drawMenuTextRightJustified(int x, int y, const char* str);
|
||||||
void _drawMenuTextRightJustified(int x, int y, bool selected, const char* str, int border = 3, int radius = 4);
|
void _drawMenuTextRightJustified(int x, int y, bool selected, const char* str, int border = 3, int radius = 4);
|
||||||
void _printInverted(int x, int y, const char* str);
|
void _printInverted(int x, int y, const char* str, eJUSTIFY justify = eLeftJustify);
|
||||||
void _printInvertedConditional(int x, int y, bool selected, const char* str);
|
void _printInverted(int x, int y, bool selected, const char* str, eJUSTIFY justify = eLeftJustify);
|
||||||
|
void _adjustExtents(CRect& rect, eJUSTIFY justify, const char* str);
|
||||||
public:
|
public:
|
||||||
CScreen(C128x64_OLED& disp, CScreenManager& mgr);
|
CScreen(C128x64_OLED& disp, CScreenManager& mgr);
|
||||||
virtual ~CScreen();
|
virtual ~CScreen();
|
||||||
|
|
Loading…
Reference in a new issue