1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-23 16:25:16 +03:00

[Horus] Alert Box new design by Martin

This commit is contained in:
Bertrand Songis 2016-02-16 22:07:10 +01:00
parent 33910c8721
commit f9f7ddd639
11 changed files with 64 additions and 44 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

View file

@ -275,7 +275,7 @@ const uint8_t LBM_STICK_POINTER[] __DMA = {
*/ */
const uint8_t LBM_ASTERISK[] __DMA = { const uint8_t LBM_ASTERISK[] __DMA = {
#include "bmp_asterisk.lbm" #include "alpha_asterisk.lbm"
}; };
const uint8_t LBM_POINT[] __DMA = { const uint8_t LBM_POINT[] __DMA = {

View file

@ -37,14 +37,6 @@ uint16_t popupMenuOffset = 0;
uint8_t popupMenuOffsetType = MENU_OFFSET_INTERNAL; uint8_t popupMenuOffsetType = MENU_OFFSET_INTERNAL;
void (*popupMenuHandler)(const char * result); 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() void displayWarningBox()
{ {
lcdDrawSolidFilledRect(POPUP_X, POPUP_Y, POPUP_W, POPUP_H, TEXT_BGCOLOR); 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); // 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(); theme->drawAlertBox(title, text, action);
#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);
}
} }
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(); lcdRefresh();
lcdSetContrast(); lcdSetContrast();
clearKeyEvents(); clearKeyEvents();

View file

@ -20,6 +20,34 @@
#include "opentx.h" #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 const Theme * registeredThemes[MAX_REGISTERED_THEMES]; // TODO dynamic
unsigned int countRegisteredThemes = 0; unsigned int countRegisteredThemes = 0;
void registerTheme(const Theme * theme) void registerTheme(const Theme * theme)

View file

@ -48,10 +48,12 @@ class Theme
virtual void load() const = 0; 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 drawTopbarBackground(const uint8_t * icon) const = 0;
virtual void drawAlertBox(const char * title, const char * text, const char * action) const;
protected: protected:
const char * name; const char * name;
const uint8_t * bitmap; const uint8_t * bitmap;

View file

@ -61,11 +61,6 @@ class DarkblueTheme: public Theme
lcdColorTable[OVERLAY_COLOR_INDEX] = BLACK; 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 void drawTopbarBackground(const uint8_t * icon) const
{ {
lcdDrawSolidFilledRect(0, 0, LCD_W, MENU_HEADER_HEIGHT, HEADER_BGCOLOR); lcdDrawSolidFilledRect(0, 0, LCD_W, MENU_HEADER_HEIGHT, HEADER_BGCOLOR);

View file

@ -55,7 +55,7 @@ const pm_uchar asterisk_lbm[] PROGMEM = {
#include "asterisk.lbm" #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(); lcdClear();
lcdDrawBitmap(0, 0, asterisk_lbm); lcdDrawBitmap(0, 0, asterisk_lbm);
@ -71,18 +71,22 @@ void drawMessageBox(const pm_char * title, const pm_char * t, const char * last,
#endif #endif
lcdDrawFilledRect(MESSAGE_LCD_OFFSET, 0, LCD_W-MESSAGE_LCD_OFFSET, 32); lcdDrawFilledRect(MESSAGE_LCD_OFFSET, 0, LCD_W-MESSAGE_LCD_OFFSET, 32);
if (t) lcdDrawText(MESSAGE_LCD_OFFSET, 5*FH, t);
if (last) { if (text) {
lcdDrawText(MESSAGE_LCD_OFFSET, 7*FH, last); lcdDrawText(MESSAGE_LCD_OFFSET, 5*FH, text);
AUDIO_ERROR_MESSAGE(sound); }
if (action) {
lcdDrawText(MESSAGE_LCD_OFFSET, 7*FH, action);
} }
#undef MESSAGE_LCD_OFFSET #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(); lcdRefresh();
lcdSetContrast(); lcdSetContrast();
clearKeyEvents(); clearKeyEvents();

View file

@ -814,7 +814,8 @@ class LuaTheme: public Theme
Theme(name, bitmap), Theme(name, bitmap),
loadFunction(0), loadFunction(0),
drawBackgroundFunction(0), drawBackgroundFunction(0),
drawTopbarBackgroundFunction(0) drawTopbarBackgroundFunction(0),
drawAlertBoxFunction(0)
{ {
} }
@ -845,10 +846,18 @@ class LuaTheme: public Theme
exec(drawTopbarBackgroundFunction); exec(drawTopbarBackgroundFunction);
} }
#if 0
virtual void drawAlertBox(const char * title, const char * text, const char * action) const
{
exec(drawAlertBoxFunction);
}
#endif
protected: protected:
int loadFunction; int loadFunction;
int drawBackgroundFunction; int drawBackgroundFunction;
int drawTopbarBackgroundFunction; int drawTopbarBackgroundFunction;
int drawAlertBoxFunction;
}; };
int luaLoadTheme(const char * filename) int luaLoadTheme(const char * filename)

View file

@ -674,9 +674,9 @@ uint16_t evalChkSum();
// TODO these functions in gui directories // TODO these functions in gui directories
#if defined(COLORLCD) || defined(PCBTARANIS) #if defined(COLORLCD) || defined(PCBTARANIS)
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);
#endif #endif
void message(const pm_char * title, const pm_char * s, const char * last MESSAGE_SOUND_ARG); void message(const pm_char * title, const pm_char * text, const char * action MESSAGE_SOUND_ARG);
void alert(const pm_char * t, const pm_char * s MESSAGE_SOUND_ARG); void alert(const pm_char * t, const pm_char * s MESSAGE_SOUND_ARG);
enum PerOutMode { enum PerOutMode {

View file

@ -831,7 +831,10 @@ void checkSwitches()
// first - display warning // first - display warning
#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) #if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS)
if ((last_bad_switches != switches_states) || (last_bad_pots != bad_pots)) { if ((last_bad_switches != switches_states) || (last_bad_pots != bad_pots)) {
drawMessageBox(STR_SWITCHWARN, NULL, STR_PRESSANYKEYTOSKIP, ((last_bad_switches == 0xff) || (last_bad_pots == 0xff)) ? AU_SWITCH_ALERT : AU_NONE); drawAlertBox(STR_SWITCHWARN, NULL, STR_PRESSANYKEYTOSKIP);
if (last_bad_switches == 0xff || last_bad_pots == 0xff) {
AUDIO_ERROR_MESSAGE(AU_SWITCH_ALERT);
}
int x = SWITCH_WARNING_LIST_X, y = SWITCH_WARNING_LIST_Y; int x = SWITCH_WARNING_LIST_X, y = SWITCH_WARNING_LIST_Y;
int numWarnings = 0; int numWarnings = 0;
for (int i=0; i<NUM_SWITCHES; ++i) { for (int i=0; i<NUM_SWITCHES; ++i) {