[Horus] Alert Box new design by Martin

This commit is contained in:
Bertrand Songis
2016-02-16 22:07:33 +01:00
parent 33910c8721
commit f9f7ddd639
11 changed files with 64 additions and 44 deletions
+1 -1
View File
@@ -275,7 +275,7 @@ const uint8_t LBM_STICK_POINTER[] __DMA = {
*/
const uint8_t LBM_ASTERISK[] __DMA = {
#include "bmp_asterisk.lbm"
#include "alpha_asterisk.lbm"
};
const uint8_t LBM_POINT[] __DMA = {
+5 -26
View File
@@ -37,14 +37,6 @@ uint16_t popupMenuOffset = 0;
uint8_t popupMenuOffsetType = MENU_OFFSET_INTERNAL;
void (*popupMenuHandler)(const char * result);
void displayAlertBox()
{
lcdClear();
lcdDrawSolidFilledRect(POPUP_X, POPUP_Y, POPUP_W, POPUP_H, TEXT_BGCOLOR);
lcdDrawSolidRect(POPUP_X, POPUP_Y, POPUP_W, POPUP_H, 2, ALARM_COLOR);
lcdDrawBitmap(POPUP_X-80, POPUP_Y-30, LBM_ASTERISK);
}
void displayWarningBox()
{
lcdDrawSolidFilledRect(POPUP_X, POPUP_Y, POPUP_W, POPUP_H, TEXT_BGCOLOR);
@@ -59,28 +51,15 @@ void displayMessageBox()
// lcdDrawBitmap(POPUP_X+15, POPUP_Y+20, LBM_MESSAGE);
}
void drawMessageBox(const char * title, const char * t, const char * last, uint8_t sound)
void drawAlertBox(const char * title, const char * text, const char * action)
{
displayAlertBox();
#if defined(TRANSLATIONS_FR) || defined(TRANSLATIONS_IT) || defined(TRANSLATIONS_CZ)
lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y, STR_WARNING, ALARM_COLOR|DBLSIZE);
lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y+25, title, ALARM_COLOR|DBLSIZE);
#else
lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y, title, ALARM_COLOR|DBLSIZE);
lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y+25, STR_WARNING, ALARM_COLOR|DBLSIZE);
#endif
if (t) lcdDrawText(WARNING_LINE_X, WARNING_INFOLINE_Y, t);
if (last) {
lcdDrawText(WARNING_LINE_X, WARNING_INFOLINE_Y+16, last);
AUDIO_ERROR_MESSAGE(sound);
}
theme->drawAlertBox(title, text, action);
}
void message(const pm_char * title, const pm_char * t, const char * last, uint8_t sound)
void message(const pm_char * title, const pm_char * text, const char * action, uint8_t sound)
{
drawMessageBox(title, t, last, sound);
drawAlertBox(title, text, action);
AUDIO_ERROR_MESSAGE(sound);
lcdRefresh();
lcdSetContrast();
clearKeyEvents();
+28
View File
@@ -20,6 +20,34 @@
#include "opentx.h"
void Theme::drawBackground() const
{
lcdDrawSolidFilledRect(0, 0, LCD_W, LCD_H, TEXT_BGCOLOR);
}
void Theme::drawAlertBox(const char * title, const char * text, const char * action) const
{
drawBackground();
lcdDrawSolidFilledRect(0, POPUP_Y, LCD_W, POPUP_H, TEXT_INVERTED_COLOR | OPACITY(8));
lcdDrawAlphaBitmap(POPUP_X-80, POPUP_Y+12, LBM_ASTERISK);
#if defined(TRANSLATIONS_FR) || defined(TRANSLATIONS_IT) || defined(TRANSLATIONS_CZ)
lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y, STR_WARNING, ALARM_COLOR|DBLSIZE);
lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y+28, title, ALARM_COLOR|DBLSIZE);
#else
lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y, title, ALARM_COLOR|DBLSIZE);
lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y+28, STR_WARNING, ALARM_COLOR|DBLSIZE);
#endif
if (text) {
lcdDrawText(WARNING_LINE_X, WARNING_INFOLINE_Y, text);
}
if (action) {
lcdDrawText(WARNING_LINE_X, WARNING_INFOLINE_Y+16, action);
}
}
const Theme * registeredThemes[MAX_REGISTERED_THEMES]; // TODO dynamic
unsigned int countRegisteredThemes = 0;
void registerTheme(const Theme * theme)
+3 -1
View File
@@ -48,10 +48,12 @@ class Theme
virtual void load() const = 0;
virtual void drawBackground() const = 0;
virtual void drawBackground() const;
virtual void drawTopbarBackground(const uint8_t * icon) const = 0;
virtual void drawAlertBox(const char * title, const char * text, const char * action) const;
protected:
const char * name;
const uint8_t * bitmap;
-5
View File
@@ -61,11 +61,6 @@ class DarkblueTheme: public Theme
lcdColorTable[OVERLAY_COLOR_INDEX] = BLACK;
}
virtual void drawBackground() const
{
lcdDrawSolidFilledRect(0, 0, LCD_W, LCD_H, TEXT_BGCOLOR);
}
void drawTopbarBackground(const uint8_t * icon) const
{
lcdDrawSolidFilledRect(0, 0, LCD_W, MENU_HEADER_HEIGHT, HEADER_BGCOLOR);
+11 -7
View File
@@ -55,7 +55,7 @@ const pm_uchar asterisk_lbm[] PROGMEM = {
#include "asterisk.lbm"
};
void drawMessageBox(const pm_char * title, const pm_char * t, const char * last, uint8_t sound)
void drawAlertBox(const char * title, const char * text, const char * action)
{
lcdClear();
lcdDrawBitmap(0, 0, asterisk_lbm);
@@ -71,18 +71,22 @@ void drawMessageBox(const pm_char * title, const pm_char * t, const char * last,
#endif
lcdDrawFilledRect(MESSAGE_LCD_OFFSET, 0, LCD_W-MESSAGE_LCD_OFFSET, 32);
if (t) lcdDrawText(MESSAGE_LCD_OFFSET, 5*FH, t);
if (last) {
lcdDrawText(MESSAGE_LCD_OFFSET, 7*FH, last);
AUDIO_ERROR_MESSAGE(sound);
if (text) {
lcdDrawText(MESSAGE_LCD_OFFSET, 5*FH, text);
}
if (action) {
lcdDrawText(MESSAGE_LCD_OFFSET, 7*FH, action);
}
#undef MESSAGE_LCD_OFFSET
}
void message(const pm_char * title, const pm_char * t, const char * last, uint8_t sound)
void message(const pm_char * title, const pm_char * text, const char * action, uint8_t sound)
{
drawMessageBox(title, t, last, sound);
drawAlertBox(title, text, action);
AUDIO_ERROR_MESSAGE(sound);
lcdRefresh();
lcdSetContrast();
clearKeyEvents();