[Horus] UI continued

This commit is contained in:
Bertrand Songis
2016-02-16 20:45:25 +01:00
parent e72a049683
commit 33910c8721
35 changed files with 301 additions and 75 deletions
+3 -3
View File
@@ -259,11 +259,11 @@ const uint8_t LBM_STAR1[] __DMA = {
*/
const uint8_t LBM_HORUS[] __DMA = {
#include "bmp_horus.lbm"
#include "alpha_horus.lbm"
};
const uint8_t LBM_STICK_BACKGROUND[] __DMA = {
#include "bmp_stick_background.lbm"
#include "alpha_stick_background.lbm"
};
const uint8_t LBM_STICK_POINTER[] __DMA = {
@@ -299,7 +299,7 @@ const uint8_t LBM_SHUTDOWN[] __DMA = {
};
const uint8_t LBM_SLEEP[] __DMA = {
#include "bmp_sleep.lbm"
#include "alpha_sleep.lbm"
};
const uint8_t LBM_SHUTDOWN_CIRCLE[] __DMA = {
+14
View File
@@ -75,3 +75,17 @@ Layout * loadLayout(const char * name, Layout::PersistentData * persistentData)
}
return NULL;
}
void loadCustomScreens()
{
for (unsigned int i=0; i<MAX_CUSTOM_SCREENS; i++) {
char name[sizeof(g_model.screenData[i].layoutName)+1];
memset(name, 0, sizeof(name));
strncpy(name, g_model.screenData[i].layoutName, sizeof(g_model.screenData[i].layoutName));
customScreens[i] = loadLayout(name, &g_model.screenData[i].layoutData);
}
if (customScreens[0] == NULL) {
customScreens[0] = registeredLayouts[0]->create(&g_model.screenData[0].layoutData);
}
}
+1
View File
@@ -161,5 +161,6 @@ class BaseLayoutFactory: public LayoutFactory
extern unsigned int countRegisteredLayouts;
extern const LayoutFactory * registeredLayouts[MAX_REGISTERED_LAYOUTS];
Layout * loadLayout(const char * name, Layout::PersistentData * persistentData);
void loadCustomScreens();
#endif // _LAYOUT_H_
+1 -1
View File
@@ -182,7 +182,7 @@ bool menuCommonCalib(evt_t event)
break;
}
lcdDrawBitmap((LCD_W-206)/2, LCD_H-220, LBM_HORUS);
lcdDrawAlphaBitmap((LCD_W-206)/2, LCD_H-220, LBM_HORUS);
drawSticks();
drawPots();
+42 -10
View File
@@ -301,10 +301,9 @@ bool menuScreensTheme(evt_t event)
lcdDrawText(MENUS_MARGIN_LEFT, y + FH / 2, "Theme");
const Theme * new_theme = editThemeChoice<const Theme>(SCREENS_SETUP_2ND_COLUMN, y, registeredThemes, countRegisteredThemes, theme, needsOffsetCheck, attr, event);
if (new_theme) {
theme = new_theme;
theme->load();
// strncpy(g_model.screenData[T].layoutName, factory->getName(), sizeof(g_model.screenData[T].layoutName));
storageDirty(EE_MODEL);
loadTheme(new_theme);
strncpy(g_eeGeneral.themeName, new_theme->getName(), sizeof(g_eeGeneral.themeName));
storageDirty(EE_GENERAL);
}
break;
}
@@ -317,12 +316,8 @@ bool menuScreensTheme(evt_t event)
return true;
}
bool menuScreenAdd(evt_t event)
{
menuPageCount = updateMainviewsMenu();
MENU_WITH_OPTIONS("Add main view", LBM_MAINVIEWS_ICONS, menuTabMainviews, menuPageCount, menuPageCount-1, 0, { uint8_t(NAVIGATION_LINE_BY_LINE|uint8_t(countRegisteredLayouts-1)), ORPHAN_ROW, 0, 0, 0, 0 });
return true;
}
bool menuScreenAdd(evt_t event);
void onScreenSetupMenu(const char * result);
template <int T>
bool menuScreenSetup(evt_t event)
@@ -342,6 +337,8 @@ bool menuScreenSetup(evt_t event)
menuPageCount = updateMainviewsMenu();
MENU_WITH_OPTIONS(title, LBM_MAINVIEWS_ICONS, menuTabMainviews, menuPageCount, T+1, linesCount, { uint8_t(NAVIGATION_LINE_BY_LINE|uint8_t(countRegisteredLayouts-1)), ORPHAN_ROW, 0, 0, 0, 0 });
for (int i=0; i<NUM_BODY_LINES; i++) {
coord_t y = MENU_CONTENT_TOP + i * FH;
int k = i + menuVerticalOffset;
@@ -384,6 +381,13 @@ bool menuScreenSetup(evt_t event)
}
}
if (menuVerticalPosition == -1 && T > 0 && event == EVT_KEY_LONG(KEY_ENTER)) {
killEvents(KEY_ENTER);
menuHorizontalPosition = T;
POPUP_MENU_ADD_ITEM(STR_REMOVE_SCREEN);
popupMenuHandler = onScreenSetupMenu;
}
return true;
}
@@ -419,3 +423,31 @@ int updateMainviewsMenu()
}
return 1+MAX_CUSTOM_SCREENS;
}
bool menuScreenAdd(evt_t event)
{
menuPageCount = updateMainviewsMenu();
if (event == EVT_KEY_BREAK(KEY_ENTER)) {
customScreens[menuPageCount-2] = registeredLayouts[0]->create(&g_model.screenData[menuPageCount-2].layoutData);
chainMenu(menuMainviews[menuPageCount-2]);
return false;
}
MENU_WITH_OPTIONS("Add main view", LBM_MAINVIEWS_ICONS, menuTabMainviews, menuPageCount, menuPageCount-1, 0, { uint8_t(NAVIGATION_LINE_BY_LINE|uint8_t(countRegisteredLayouts-1)), ORPHAN_ROW, 0, 0, 0, 0 });
return true;
}
void onScreenSetupMenu(const char * result)
{
if (result == STR_REMOVE_SCREEN) {
if (menuHorizontalPosition != MAX_CUSTOM_SCREENS-1) {
memmove(&g_model.screenData[menuHorizontalPosition], &g_model.screenData[menuHorizontalPosition + 1], sizeof(CustomScreenData) * (MAX_CUSTOM_SCREENS - menuHorizontalPosition - 1));
memmove(&customScreens[menuHorizontalPosition], &customScreens[menuHorizontalPosition + 1], sizeof(Layout *) * (MAX_CUSTOM_SCREENS - menuHorizontalPosition - 1));
}
memset(&g_model.screenData[MAX_CUSTOM_SCREENS-1], 0, sizeof(CustomScreenData));
customScreens[MAX_CUSTOM_SCREENS-1] = NULL;
chainMenu(menuMainviews[menuHorizontalPosition > 0 ? menuHorizontalPosition-1 : 0]);
}
}
+14
View File
@@ -40,3 +40,17 @@ const Theme * getTheme(const char * name)
return NULL;
}
void loadTheme(const Theme * new_theme)
{
theme = new_theme;
theme->load();
}
void loadTheme()
{
char name[sizeof(g_eeGeneral.themeName)+1];
memset(name, 0, sizeof(name));
strncpy(name, g_eeGeneral.themeName, sizeof(g_eeGeneral.themeName));
const Theme * new_theme = getTheme(name);
loadTheme(new_theme ? new_theme : theme);
}
+5
View File
@@ -61,6 +61,11 @@ extern const Theme * theme;
#define MAX_REGISTERED_THEMES 10
extern unsigned int countRegisteredThemes;
void registerTheme(const Theme * theme);
extern const Theme * registeredThemes[MAX_REGISTERED_THEMES]; // TODO dynamic
const Theme * getTheme(const char * name);
void loadTheme(const Theme * theme);
void loadTheme();
#endif // _THEME_H_
+2 -2
View File
@@ -50,7 +50,7 @@ void drawTopbarDatetime()
#define STICK_PANEL_WIDTH 68
void drawStick(coord_t x, coord_t y, int16_t xval, int16_t yval)
{
lcdDrawBitmap(x, y, LBM_STICK_BACKGROUND);
lcdDrawAlphaBitmap(x, y, LBM_STICK_BACKGROUND);
lcdDrawAlphaBitmap(x + 2 + STICK_PANEL_WIDTH/2 + STICK_PANEL_WIDTH/2 * xval/RESX, y + 2 + STICK_PANEL_WIDTH/2 - STICK_PANEL_WIDTH/2 * yval/RESX, LBM_STICK_POINTER);
}
@@ -426,7 +426,7 @@ int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min, int
void drawSleepBitmap()
{
lcdClear();
lcdDrawBitmap((LCD_W-SLEEP_BITMAP_WIDTH)/2, (LCD_H-SLEEP_BITMAP_HEIGHT)/2, LBM_SLEEP);
lcdDrawAlphaBitmap((LCD_W-SLEEP_BITMAP_WIDTH)/2, (LCD_H-SLEEP_BITMAP_HEIGHT)/2, LBM_SLEEP);
lcdRefresh();
}
+2 -2
View File
@@ -498,9 +498,9 @@ void lcdDrawLine(coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t pat, Lc
}
}
void lcdDrawSolidVerticalLine(coord_t x, scoord_t y, scoord_t h)
void lcdDrawSolidVerticalLine(coord_t x, scoord_t y, scoord_t h, LcdFlags att)
{
lcdDrawVerticalLine(x, y, h, SOLID);
lcdDrawVerticalLine(x, y, h, SOLID, att);
}
#endif
+1 -1
View File
@@ -179,7 +179,7 @@ void lcdDrawPoint(coord_t x, coord_t y, LcdFlags att=0);
void lcdMaskPoint(uint8_t *p, uint8_t mask, LcdFlags att=0);
void lcdDrawSolidHorizontalLine(coord_t x, coord_t y, coord_t w, LcdFlags att=0);
void lcdDrawHorizontalLine(coord_t x, coord_t y, coord_t w, uint8_t pat, LcdFlags att=0);
void lcdDrawSolidVerticalLine(coord_t x, scoord_t y, scoord_t h);
void lcdDrawSolidVerticalLine(coord_t x, scoord_t y, scoord_t h, LcdFlags att=0);
void lcdDrawVerticalLine(coord_t x, scoord_t y, scoord_t h, uint8_t pat, LcdFlags att=0);
void lcdDrawLine(coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t pat=SOLID, LcdFlags att=0);
void lcdDrawFilledRect(coord_t x, scoord_t y, coord_t w, coord_t h, uint8_t pat=SOLID, LcdFlags att=0);