Default Theme facelift
This commit is contained in:
+8
-9
@@ -77,22 +77,20 @@ void TextButton::paint(BitmapBuffer * dc)
|
|||||||
if (checked()) {
|
if (checked()) {
|
||||||
if (hasFocus()) {
|
if (hasFocus()) {
|
||||||
dc->drawSolidRect(0, 0, rect.w, rect.h, 2, FOCUS_BGCOLOR);
|
dc->drawSolidRect(0, 0, rect.w, rect.h, 2, FOCUS_BGCOLOR);
|
||||||
dc->drawSolidFilledRect(3, 3, rect.w - 6, rect.h - 6, FOCUS_BGCOLOR);
|
dc->drawSolidFilledRect(3, 3, rect.w - 6, rect.h - 6, EDIT_MARKER_COLOR);
|
||||||
}
|
} else {
|
||||||
else {
|
dc->drawSolidFilledRect(0, 0, rect.w, rect.h, EDIT_MARKER_COLOR);
|
||||||
dc->drawSolidRect(0, 0, rect.w, rect.h, 1, DISABLE_COLOR);
|
|
||||||
dc->drawSolidFilledRect(2, 2, rect.w - 4, rect.h - 4, FOCUS_BGCOLOR);
|
|
||||||
}
|
}
|
||||||
textColor = FOCUS_COLOR;
|
textColor = FOCUS_COLOR;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (windowFlags & BUTTON_BACKGROUND) {
|
if (windowFlags & BUTTON_BACKGROUND) {
|
||||||
if (hasFocus()) {
|
if (hasFocus()) {
|
||||||
dc->drawSolidRect(0, 0, rect.w, rect.h, 2, FOCUS_BGCOLOR);
|
dc->drawSolidFilledRect(0, 0, rect.w, rect.h, FOCUS_BGCOLOR);
|
||||||
dc->drawSolidFilledRect(2, 2, rect.w - 4, rect.h - 4, DISABLE_COLOR);
|
textColor = FOCUS_COLOR;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
dc->drawSolidFilledRect(0, 0, rect.w, rect.h, DISABLE_COLOR);
|
dc->drawSolidFilledRect(0, 0, rect.w, rect.h, FIELD_FRAME_COLOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -105,7 +103,8 @@ void TextButton::paint(BitmapBuffer * dc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dc->drawText(rect.w / 2, 1 + (rect.h - getFontHeight(textFlags)) / 2, text.c_str(), CENTERED | textFlags | textColor);
|
dc->drawText(rect.w / 2, 1 + (rect.h - getFontHeight(textFlags)) / 2,
|
||||||
|
text.c_str(), CENTERED | textFlags | textColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IconButton::paint(BitmapBuffer * dc)
|
void IconButton::paint(BitmapBuffer * dc)
|
||||||
|
|||||||
+21
-18
@@ -89,31 +89,34 @@ class Button: public FormField
|
|||||||
class TextButton: public Button
|
class TextButton: public Button
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TextButton(FormGroup * parent, const rect_t & rect, std::string text, std::function<uint8_t(void)> pressHandler = nullptr, WindowFlags windowFlags = BUTTON_BACKGROUND | OPAQUE, LcdFlags textFlags = 0):
|
TextButton(FormGroup* parent, const rect_t& rect, std::string text,
|
||||||
Button(parent, rect, std::move(pressHandler), windowFlags, textFlags),
|
std::function<uint8_t(void)> pressHandler = nullptr,
|
||||||
text(std::move(text))
|
WindowFlags windowFlags = BUTTON_BACKGROUND | OPAQUE,
|
||||||
{
|
LcdFlags textFlags = 0) :
|
||||||
}
|
Button(parent, rect, std::move(pressHandler), windowFlags, textFlags),
|
||||||
|
text(std::move(text))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(DEBUG_WINDOWS)
|
#if defined(DEBUG_WINDOWS)
|
||||||
std::string getName() const override
|
std::string getName() const override
|
||||||
{
|
{
|
||||||
return "TextButton \"" + text + "\"";
|
return "TextButton \"" + text + "\"";
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void setText(std::string value)
|
void setText(std::string value)
|
||||||
{
|
{
|
||||||
if (value != text) {
|
if (value != text) {
|
||||||
text = std::move(value);
|
text = std::move(value);
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void paint(BitmapBuffer * dc) override;
|
void paint(BitmapBuffer* dc) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string text;
|
std::string text;
|
||||||
};
|
};
|
||||||
|
|
||||||
class IconButton: public Button
|
class IconButton: public Button
|
||||||
|
|||||||
+11
-7
@@ -87,14 +87,18 @@ void FormField::setFocus(uint8_t flag, Window * from)
|
|||||||
void FormField::paint(BitmapBuffer * dc)
|
void FormField::paint(BitmapBuffer * dc)
|
||||||
{
|
{
|
||||||
if (editMode) {
|
if (editMode) {
|
||||||
dc->drawSolidFilledRect(0, 0, rect.w, rect.h, FOCUS_BGCOLOR);
|
dc->drawSolidFilledRect(0, 0, rect.w, rect.h, EDIT_MARKER_COLOR);
|
||||||
}
|
}
|
||||||
else if (!(windowFlags & FORM_NO_BORDER)) {
|
else {
|
||||||
if (hasFocus()) {
|
|
||||||
dc->drawSolidRect(0, 0, rect.w, rect.h, 2, FOCUS_BGCOLOR);
|
if (!(windowFlags & FORM_NO_BORDER)) {
|
||||||
}
|
|
||||||
else if (!(windowFlags & FORM_BORDER_FOCUS_ONLY)) {
|
if (hasFocus()) {
|
||||||
dc->drawSolidRect(0, 0, rect.w, rect.h, 1, DISABLE_COLOR);
|
dc->drawSolidFilledRect(0, 0, rect.w, rect.h, FOCUS_BGCOLOR);
|
||||||
|
} else if (!(windowFlags & FORM_BORDER_FOCUS_ONLY)) {
|
||||||
|
dc->drawSolidFilledRect(0, 0, rect.w, rect.h, FIELD_BGCOLOR);
|
||||||
|
dc->drawSolidRect(0, 0, rect.w, rect.h, 1, FIELD_FRAME_COLOR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+31
-17
@@ -107,36 +107,43 @@ void MenuBody::paint(BitmapBuffer * dc)
|
|||||||
dc->clear(MENU_BGCOLOR);
|
dc->clear(MENU_BGCOLOR);
|
||||||
|
|
||||||
for (unsigned i = 0; i < lines.size(); i++) {
|
for (unsigned i = 0; i < lines.size(); i++) {
|
||||||
auto & line = lines[i];
|
auto& line = lines[i];
|
||||||
LcdFlags flags = MENU_COLOR | MENU_FONT;
|
LcdFlags flags = MENU_COLOR | MENU_FONT;
|
||||||
if (selectedIndex == (int)i) {
|
if (selectedIndex == (int)i) {
|
||||||
flags = MENU_HIGHLIGHT_COLOR | MENU_FONT;
|
flags = MENU_HIGHLIGHT_COLOR | MENU_FONT;
|
||||||
if (MENU_HIGHLIGHT_BGCOLOR != MENU_BGCOLOR) {
|
if (MENU_HIGHLIGHT_BGCOLOR != MENU_BGCOLOR) {
|
||||||
dc->drawSolidFilledRect(0, i * MENUS_LINE_HEIGHT, width(), MENUS_LINE_HEIGHT, MENU_HIGHLIGHT_BGCOLOR);
|
dc->drawSolidFilledRect(0, i * MENUS_LINE_HEIGHT, width(),
|
||||||
|
MENUS_LINE_HEIGHT, MENU_HIGHLIGHT_BGCOLOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (line.drawLine) {
|
if (line.drawLine) {
|
||||||
line.drawLine(dc, 0, i * MENUS_LINE_HEIGHT, flags);
|
line.drawLine(dc, 0, i * MENUS_LINE_HEIGHT, flags);
|
||||||
}
|
} else {
|
||||||
else {
|
const char* text = line.text.data();
|
||||||
const char * text = line.text.data();
|
dc->drawText(10,
|
||||||
dc->drawText(10, i * MENUS_LINE_HEIGHT + (MENUS_LINE_HEIGHT - getFontHeight(MENU_FONT)) / 2, text[0] == '\0' ? "---" : text, flags);
|
i * MENUS_LINE_HEIGHT +
|
||||||
|
(MENUS_LINE_HEIGHT - getFontHeight(MENU_FONT)) / 2,
|
||||||
|
text[0] == '\0' ? "---" : text, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu * menu = getParentMenu();
|
Menu* menu = getParentMenu();
|
||||||
if (menu->multiple && line.isChecked) {
|
if (menu->multiple && line.isChecked) {
|
||||||
theme->drawCheckBox(dc, line.isChecked(), width() - 35, i * MENUS_LINE_HEIGHT + (MENUS_LINE_HEIGHT - 20) / 2, 0);
|
theme->drawCheckBox(dc, line.isChecked(), width() - 35,
|
||||||
|
i * MENUS_LINE_HEIGHT + (MENUS_LINE_HEIGHT - 20) / 2,
|
||||||
|
0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
dc->drawSolidHorizontalLine(0, i * MENUS_LINE_HEIGHT - 1, MENUS_WIDTH, MENU_LINE_COLOR);
|
dc->drawSolidHorizontalLine(0, i * MENUS_LINE_HEIGHT, MENUS_WIDTH,
|
||||||
|
MENU_LINE_COLOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuWindowContent::MenuWindowContent(Menu * parent):
|
MenuWindowContent::MenuWindowContent(Menu* parent) :
|
||||||
ModalWindowContent(parent, {(LCD_W - MENUS_WIDTH) / 2, (LCD_H - MENUS_WIDTH) / 2, MENUS_WIDTH, 0}),
|
ModalWindowContent(parent, {(LCD_W - MENUS_WIDTH) / 2,
|
||||||
body(this, {0, 0, width(), height()})
|
(LCD_H - MENUS_WIDTH) / 2, MENUS_WIDTH, 0}),
|
||||||
|
body(this, {1, 1, width() - 2, height() - 2})
|
||||||
{
|
{
|
||||||
body.setFocus(SET_FOCUS_DEFAULT);
|
body.setFocus(SET_FOCUS_DEFAULT);
|
||||||
}
|
}
|
||||||
@@ -148,9 +155,14 @@ void MenuWindowContent::paint(BitmapBuffer * dc)
|
|||||||
|
|
||||||
// the title
|
// the title
|
||||||
if (!title.empty()) {
|
if (!title.empty()) {
|
||||||
dc->drawText(MENUS_WIDTH / 2, (POPUP_HEADER_HEIGHT - getFontHeight(MENU_HEADER_FONT)) / 2, title.c_str(), CENTERED | MENU_HEADER_FONT);
|
dc->drawText(MENUS_WIDTH / 2,
|
||||||
dc->drawSolidHorizontalLine(0, POPUP_HEADER_HEIGHT - 1, MENUS_WIDTH, MENU_LINE_COLOR);
|
(POPUP_HEADER_HEIGHT - getFontHeight(MENU_HEADER_FONT)) / 2,
|
||||||
|
title.c_str(), CENTERED | MENU_HEADER_FONT);
|
||||||
|
dc->drawSolidHorizontalLine(0, POPUP_HEADER_HEIGHT - 1, MENUS_WIDTH,
|
||||||
|
MENU_LINE_COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dc->drawSolidRect(0, 0, MENUS_WIDTH, height(), 1, MENU_LINE_COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu::Menu(Window * parent, bool multiple):
|
Menu::Menu(Window * parent, bool multiple):
|
||||||
@@ -165,10 +177,12 @@ void Menu::updatePosition()
|
|||||||
if (!toolbar) {
|
if (!toolbar) {
|
||||||
// there is no navigation bar at the left, we may center the window on screen
|
// there is no navigation bar at the left, we may center the window on screen
|
||||||
auto headerHeight = content->title.empty() ? 0 : POPUP_HEADER_HEIGHT;
|
auto headerHeight = content->title.empty() ? 0 : POPUP_HEADER_HEIGHT;
|
||||||
auto bodyHeight = limit<coord_t>(MENUS_MIN_HEIGHT, content->body.lines.size() * MENUS_LINE_HEIGHT - 1, MENUS_MAX_HEIGHT);
|
auto bodyHeight = limit<coord_t>(
|
||||||
|
MENUS_MIN_HEIGHT, content->body.lines.size() * MENUS_LINE_HEIGHT - 1,
|
||||||
|
MENUS_MAX_HEIGHT);
|
||||||
content->setTop((LCD_H - headerHeight - bodyHeight) / 2 + MENUS_OFFSET_TOP);
|
content->setTop((LCD_H - headerHeight - bodyHeight) / 2 + MENUS_OFFSET_TOP);
|
||||||
content->setHeight(headerHeight + bodyHeight);
|
content->setHeight(headerHeight + bodyHeight + 2);
|
||||||
content->body.setTop(headerHeight);
|
content->body.setTop(headerHeight + 1);
|
||||||
content->body.setHeight(bodyHeight);
|
content->body.setHeight(bodyHeight);
|
||||||
}
|
}
|
||||||
content->body.setInnerHeight(content->body.lines.size() * MENUS_LINE_HEIGHT - 1);
|
content->body.setInnerHeight(content->body.lines.size() * MENUS_LINE_HEIGHT - 1);
|
||||||
|
|||||||
+16
-13
@@ -38,27 +38,30 @@ void NumberEdit::paint(BitmapBuffer * dc)
|
|||||||
if (editMode)
|
if (editMode)
|
||||||
textColor = FOCUS_COLOR;
|
textColor = FOCUS_COLOR;
|
||||||
else if (hasFocus())
|
else if (hasFocus())
|
||||||
textColor = FOCUS_BGCOLOR;
|
textColor = FOCUS_COLOR;
|
||||||
else if (enabled && (value != 0 || zeroText.empty()))
|
// else if (enabled && (value != 0 || zeroText.empty()))
|
||||||
textColor = DEFAULT_COLOR;
|
// textColor = DEFAULT_COLOR;
|
||||||
else
|
else
|
||||||
textColor = DISABLE_COLOR;
|
textColor = DEFAULT_COLOR;
|
||||||
|
|
||||||
if (displayFunction) {
|
if (displayFunction) {
|
||||||
displayFunction(dc, textColor, value);
|
displayFunction(dc, textColor, value);
|
||||||
}
|
} else if (value == 0 && !zeroText.empty()) {
|
||||||
else if (value == 0 && !zeroText.empty()) {
|
dc->drawText(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, zeroText.c_str(),
|
||||||
dc->drawText(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, zeroText.c_str(), textColor | textFlags);
|
textColor | textFlags);
|
||||||
if (textFlags & RIGHT)
|
if (textFlags & RIGHT)
|
||||||
dc->drawText(rect.w - FIELD_PADDING_LEFT, FIELD_PADDING_TOP, zeroText.c_str(), textColor | textFlags);
|
dc->drawText(rect.w - FIELD_PADDING_LEFT, FIELD_PADDING_TOP,
|
||||||
|
zeroText.c_str(), textColor | textFlags);
|
||||||
else
|
else
|
||||||
dc->drawText(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, zeroText.c_str(), textColor | textFlags);
|
dc->drawText(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, zeroText.c_str(),
|
||||||
}
|
textColor | textFlags);
|
||||||
else {
|
} else {
|
||||||
if (textFlags & RIGHT)
|
if (textFlags & RIGHT)
|
||||||
dc->drawNumber(rect.w - FIELD_PADDING_LEFT, FIELD_PADDING_TOP, value, textColor | textFlags, 0, prefix.c_str(), suffix.c_str());
|
dc->drawNumber(rect.w - FIELD_PADDING_LEFT, FIELD_PADDING_TOP, value,
|
||||||
|
textColor | textFlags, 0, prefix.c_str(), suffix.c_str());
|
||||||
else
|
else
|
||||||
dc->drawNumber(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, value, textColor | textFlags, 0, prefix.c_str(), suffix.c_str());
|
dc->drawNumber(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, value,
|
||||||
|
textColor | textFlags, 0, prefix.c_str(), suffix.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -30,7 +30,7 @@ class StaticText: public Window
|
|||||||
text(std::move(text))
|
text(std::move(text))
|
||||||
{
|
{
|
||||||
if (windowFlags & BUTTON_BACKGROUND) {
|
if (windowFlags & BUTTON_BACKGROUND) {
|
||||||
setBackgroundColor(DISABLE_COLOR);
|
setBackgroundColor(FIELD_FRAME_COLOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+11
-8
@@ -47,24 +47,27 @@ void TextEdit::paint(BitmapBuffer * dc)
|
|||||||
FormField::paint(dc);
|
FormField::paint(dc);
|
||||||
|
|
||||||
if (editMode) {
|
if (editMode) {
|
||||||
dc->drawSizedText(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, value, length, FOCUS_COLOR);
|
dc->drawSizedText(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, value, length,
|
||||||
|
FOCUS_COLOR);
|
||||||
coord_t left = (cursorPos == 0 ? 0 : getTextWidth(value, cursorPos));
|
coord_t left = (cursorPos == 0 ? 0 : getTextWidth(value, cursorPos));
|
||||||
#if defined(SOFTWARE_KEYBOARD)
|
#if defined(SOFTWARE_KEYBOARD)
|
||||||
dc->drawSolidFilledRect(left + 2, 2, 2, height() - 4, FOCUS_COLOR);
|
dc->drawSolidFilledRect(left + 2, 2, 2, height() - 4, FOCUS_COLOR);
|
||||||
#else
|
#else
|
||||||
char s[] = { value[cursorPos], '\0' };
|
char s[] = {value[cursorPos], '\0'};
|
||||||
dc->drawSolidFilledRect(FIELD_PADDING_LEFT + left - 1, FIELD_PADDING_TOP - 1, getTextWidth(s, 1) + 1, height() - 2, FOCUS_COLOR);
|
dc->drawSolidFilledRect(FIELD_PADDING_LEFT + left - 1,
|
||||||
dc->drawText(FIELD_PADDING_LEFT + left, FIELD_PADDING_TOP, s, DEFAULT_COLOR);
|
FIELD_PADDING_TOP - 1, getTextWidth(s, 1) + 1,
|
||||||
|
height() - 2, FOCUS_COLOR);
|
||||||
|
dc->drawText(FIELD_PADDING_LEFT + left, FIELD_PADDING_TOP, s,
|
||||||
|
DEFAULT_COLOR);
|
||||||
#endif
|
#endif
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
const char * displayedValue = value;
|
const char * displayedValue = value;
|
||||||
LcdFlags textColor;
|
LcdFlags textColor = FOCUS_COLOR;
|
||||||
if (hasFocus()) {
|
if (hasFocus()) {
|
||||||
if (strlen(value) == 0) {
|
if (strlen(value) == 0) {
|
||||||
displayedValue = "---";
|
displayedValue = "---";
|
||||||
}
|
}
|
||||||
textColor = FOCUS_BGCOLOR;
|
textColor = FOCUS_COLOR;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (strlen(value) == 0) {
|
if (strlen(value) == 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user