Dialog now themeable
This commit is contained in:
+4
-3
@@ -19,13 +19,14 @@
|
||||
|
||||
#include "dialog.h"
|
||||
#include "mainwindow.h"
|
||||
#include "theme.h"
|
||||
|
||||
Dialog::Dialog(std::string title, const rect_t & rect):
|
||||
ModalWindow(),
|
||||
content(this, rect),
|
||||
form(&content, {0, 0, rect.w, rect.h}, FORM_NO_BORDER)
|
||||
content(createDialogWindow(this, rect)),
|
||||
form(content, {0, POPUP_HEADER_HEIGHT, rect.w, coord_t(rect.h - POPUP_HEADER_HEIGHT)}, FORM_NO_BORDER)
|
||||
{
|
||||
bringToTop();
|
||||
content.setTitle(title);
|
||||
content->setTitle(title);
|
||||
form.setFocus();
|
||||
}
|
||||
|
||||
+8
-2
@@ -30,11 +30,17 @@ class Dialog: public ModalWindow {
|
||||
~Dialog() override
|
||||
{
|
||||
form.detach();
|
||||
content.detach();
|
||||
}
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() override
|
||||
{
|
||||
return "Dialog";
|
||||
}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
ModalWindowContent content;
|
||||
ModalWindowContent * content;
|
||||
FormGroup form;
|
||||
};
|
||||
|
||||
|
||||
+3
-3
@@ -102,8 +102,8 @@ void MenuWindowContent::paint(BitmapBuffer * dc)
|
||||
|
||||
// the title
|
||||
if (!title.empty()) {
|
||||
dc->drawText(MENUS_WIDTH / 2, (MENUS_HEADER_HEIGHT - getFontHeight(MENU_HEADER_FONT)) / 2, title.c_str(), CENTERED | MENU_HEADER_FONT);
|
||||
dc->drawSolidHorizontalLine(0, MENUS_HEADER_HEIGHT - 1, MENUS_WIDTH, MENU_LINE_COLOR);
|
||||
dc->drawText(MENUS_WIDTH / 2, (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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ void Menu::updatePosition()
|
||||
{
|
||||
if (!toolbar) {
|
||||
// there is no navigation bar at the left, we may center the window on screen
|
||||
auto headerHeight = content->title.empty() ? 0 : MENUS_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);
|
||||
content->setTop((LCD_H - headerHeight - bodyHeight) / 2 + MENUS_OFFSET_TOP);
|
||||
content->setHeight(headerHeight + bodyHeight);
|
||||
|
||||
+1
-1
@@ -181,4 +181,4 @@ class Menu: public ModalWindow {
|
||||
void updatePosition();
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // _MENU_H_
|
||||
|
||||
+5
-5
@@ -37,9 +37,9 @@ void ModalWindow::paint(BitmapBuffer * dc)
|
||||
|
||||
void ModalWindowContent::paint(BitmapBuffer * dc)
|
||||
{
|
||||
dc->drawSolidFilledRect(0, 0, width(), PAGE_LINE_HEIGHT, FOCUS_BGCOLOR);
|
||||
dc->drawText(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, title.c_str(), FOCUS_COLOR);
|
||||
dc->drawSolidFilledRect(0, PAGE_LINE_HEIGHT, width(), height() - PAGE_LINE_HEIGHT, DEFAULT_BGCOLOR);
|
||||
dc->drawSolidFilledRect(0, 0, width(), POPUP_HEADER_HEIGHT, FOCUS_BGCOLOR);
|
||||
dc->drawText(FIELD_PADDING_LEFT, (POPUP_HEADER_HEIGHT - getFontHeight(FONT(STD))) / 2, title.c_str(), FOCUS_COLOR);
|
||||
dc->drawSolidFilledRect(0, POPUP_HEADER_HEIGHT, width(), height() - POPUP_HEADER_HEIGHT, DEFAULT_BGCOLOR);
|
||||
|
||||
/*
|
||||
// the background
|
||||
@@ -47,7 +47,7 @@ void ModalWindowContent::paint(BitmapBuffer * dc)
|
||||
|
||||
// the title
|
||||
if (!title.empty()) {
|
||||
dc->drawText(MENUS_WIDTH / 2, (MENUS_HEADER_HEIGHT - getFontHeight(MENU_HEADER_FONT)) / 2, title.c_str(), CENTERED | MENU_HEADER_FONT);
|
||||
dc->drawSolidHorizontalLine(0, MENUS_HEADER_HEIGHT - 1, MENUS_WIDTH, MENU_LINE_COLOR);
|
||||
dc->drawText(MENUS_WIDTH / 2, (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);
|
||||
}*/
|
||||
}
|
||||
|
||||
+3
@@ -25,6 +25,8 @@
|
||||
|
||||
class Menu;
|
||||
class MenuWindowContent;
|
||||
class Dialog;
|
||||
class ModalWindowContent;
|
||||
class ChoiceBase;
|
||||
|
||||
enum IconState {
|
||||
@@ -53,5 +55,6 @@ class Theme {
|
||||
extern Theme * theme;
|
||||
|
||||
MenuWindowContent * createMenuWindow(Menu * menu);
|
||||
ModalWindowContent * createDialogWindow(Dialog * dialog, const rect_t & rect);
|
||||
|
||||
#endif // _THEME_H_
|
||||
|
||||
Reference in New Issue
Block a user