From 6ee5d36084a645ec93b8c41fe1716de0fcb63cda Mon Sep 17 00:00:00 2001 From: yellows8 Date: Fri, 3 Jan 2020 17:49:08 -0500 Subject: [PATCH] Removed hbmenuLogoImage from theme_t and just determine which AssetId to use for logo during rendering, imageSize from the asset is now used instead of from the layoutobj. Removed drawImageFromLayout since it's no longer used, and removed imageSize from the layout objects which don't need it anymore. --- common/menu.c | 23 +++++++++++------------ common/theme.c | 7 ------- common/theme.h | 1 - 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/common/menu.c b/common/menu.c index 34a95b2..bd931bc 100644 --- a/common/menu.c +++ b/common/menu.c @@ -180,12 +180,6 @@ static void drawImage(int x, int y, int width, int height, const uint8_t *image, } } -static void drawImageFromLayout(ThemeLayoutId id, const uint8_t *image, ImageMode mode) { - ThemeLayoutObject *obj = &themeCurrent.layoutObjects[id]; - if (!obj->visible) return; - drawImage(obj->posStart[0], obj->posStart[1], obj->imageSize[0], obj->imageSize[1], image, mode); -} - //Draws an RGBA8888 image masked by the passed color. static void drawIcon(int x, int y, int width, int height, const uint8_t *image, color_t color) { int tmpx, tmpy; @@ -674,12 +668,17 @@ void menuLoop(void) { if (layoutobj->visible) drawWave(2, menuTimer, themeCurrent.frontWaveColor, layoutobj->size[1], 4.0, -2.5); menuTimer += 0.05; - if (!themeCurrent.logoColor_set) - drawImageFromLayout(ThemeLayoutId_Logo, themeCurrent.hbmenuLogoImage, IMAGE_MODE_RGBA32); - else { - layoutobj = &themeCurrent.layoutObjects[ThemeLayoutId_Logo]; - assetsGetData(AssetId_hbmenu_logo_light, &data); - if (layoutobj->visible) drawIcon(layoutobj->posStart[0], layoutobj->posStart[1], data->imageSize[0], data->imageSize[1], data->buffer, themeCurrent.logoColor); + layoutobj = &themeCurrent.layoutObjects[ThemeLayoutId_Logo]; + if(themeGlobalPreset == THEME_PRESET_DARK) + assetsGetData(AssetId_hbmenu_logo_dark, &data); + else assetsGetData(AssetId_hbmenu_logo_light, &data); + + if (layoutobj->visible) { + if (!themeCurrent.logoColor_set) + drawImage(layoutobj->posStart[0], layoutobj->posStart[1], data->imageSize[0], data->imageSize[1], data->buffer, data->imageMode); + else { + drawIcon(layoutobj->posStart[0], layoutobj->posStart[1], data->imageSize[0], data->imageSize[1], data->buffer, themeCurrent.logoColor); + } } DrawTextFromLayout(ThemeLayoutId_HbmenuVersion, themeCurrent.textColor, VERSION); diff --git a/common/theme.c b/common/theme.c index 6c10a6b..5fdc25d 100644 --- a/common/theme.c +++ b/common/theme.c @@ -111,7 +111,6 @@ void themeStartup(ThemePreset preset) { .buttonMText = "\uE0F0", .labelStarOnText = "\u2605", .labelStarOffText = "\u2606", - .hbmenuLogoImage = assetsGetDataBuffer(AssetId_hbmenu_logo_light), }; theme_t themeDark = (theme_t) { @@ -136,7 +135,6 @@ void themeStartup(ThemePreset preset) { .buttonMText = "\uE0B4", .labelStarOnText = "\u2605", .labelStarOffText = "\u2606", - .hbmenuLogoImage = assetsGetDataBuffer(AssetId_hbmenu_logo_dark), }; theme_t themeCommon = { @@ -145,7 +143,6 @@ void themeStartup(ThemePreset preset) { .visible = true, .posType = false, .posStart = {40, 20}, - .imageSize = {140, 60}, }, [ThemeLayoutId_HbmenuVersion] = { @@ -312,7 +309,6 @@ void themeStartup(ThemePreset preset) { .visible = true, .posType = true, .posStart = {0, 0 + 47 + 10 + 3}, - .imageSize = {24, 24}, }, [ThemeLayoutId_BatteryCharge] = { @@ -326,14 +322,12 @@ void themeStartup(ThemePreset preset) { .visible = true, .posType = false, .posStart = {1180 - 8 - 24 - 8, 0 + 47 + 10 + 6}, - .imageSize = {24, 24}, }, [ThemeLayoutId_ChargingIcon] = { .visible = true, .posType = false, .posStart = {1180 - 20, 0 + 47 + 10 + 6}, - .imageSize = {24, 24}, }, [ThemeLayoutId_Status] = { @@ -521,7 +515,6 @@ void themeStartup(ThemePreset preset) { .progressBarColor = progressBarColor, .logoColor_set = logoColor_set, .enableWaveBlending = waveBlending, - .hbmenuLogoImage = themeDefault->hbmenuLogoImage }; strncpy(themeCurrent.buttonAText, AText, sizeof(themeCurrent.buttonAText)); themeCurrent.buttonAText[sizeof(themeCurrent.buttonAText)-1] = 0; diff --git a/common/theme.h b/common/theme.h index 589d066..0eec46d 100644 --- a/common/theme.h +++ b/common/theme.h @@ -48,7 +48,6 @@ typedef struct char buttonMText[32]; char labelStarOnText[32]; char labelStarOffText[32]; - const uint8_t *hbmenuLogoImage; ThemeLayoutObject layoutObjects[ThemeLayoutId_Total]; } theme_t;