Added a light theme

This commit is contained in:
Adubbz 2018-02-22 21:22:41 +11:00 committed by plutoo
parent 70a3995081
commit 4653c32646
7 changed files with 75 additions and 16 deletions

View File

@ -10,7 +10,7 @@ endef
test : pc_main/main.cpp pc_main/pc_launch.c \ test : pc_main/main.cpp pc_main/pc_launch.c \
common/menu.c common/font.c common/language.c common/launch.c \ common/menu.c common/font.c common/language.c common/launch.c \
common/menu-entry.c common/menu-list.c common/text.c \ common/menu-entry.c common/menu-list.c common/text.c \
common/nanojpeg.c common/ui.c common/math.c \ common/nanojpeg.c common/ui.c common/math.c common/theme.c \
build_pc/tahoma24.o build_pc/tahoma12.o build_pc/switchicon_questionmark.bin.o build_pc/folder_icon.bin.o build_pc/tahoma24.o build_pc/tahoma12.o build_pc/switchicon_questionmark.bin.o build_pc/folder_icon.bin.o
gcc -Wall -O2 -g0 $^ -lsfml-graphics -lsfml-window -lsfml-system -lstdc++ -I. -Ibuild_pc -o $@ gcc -Wall -O2 -g0 $^ -lsfml-graphics -lsfml-window -lsfml-system -lstdc++ -I. -Ibuild_pc -o $@

View File

@ -38,6 +38,7 @@ typedef union {
#include "nro.h" #include "nro.h"
#include "nanojpeg.h" #include "nanojpeg.h"
#include "math.h" #include "math.h"
#include "theme.h"
void menuStartup(); void menuStartup();
void menuLoop(); void menuLoop();

View File

@ -43,7 +43,7 @@ static void drawEntry(menuEntry_s* me, int off_x, int is_active) {
color_t border_color = MakeColor(255, 255, 255, 255); color_t border_color = MakeColor(255, 255, 255, 255);
if (is_active) { if (is_active) {
border_color = MakeColor(73, 103, 169, 255); border_color = themeCurrent.highlightColor;
} }
//{ //{
@ -132,15 +132,15 @@ static void drawEntry(menuEntry_s* me, int off_x, int is_active) {
start_x = 220; start_x = 220;
start_y = 135; start_y = 135;
DrawText(tahoma24, start_x + 256 + 64, start_y, MakeColor(255, 255, 255, 255), me->name); DrawText(tahoma24, start_x + 256 + 64, start_y, themeCurrent.textColor, me->name);
if (me->type != ENTRY_TYPE_FOLDER) { if (me->type != ENTRY_TYPE_FOLDER) {
memset(tmpstr, 0, sizeof(tmpstr)); memset(tmpstr, 0, sizeof(tmpstr));
snprintf(tmpstr, sizeof(tmpstr)-1, "Author: %s", me->author); snprintf(tmpstr, sizeof(tmpstr)-1, "Author: %s", me->author);
DrawText(tahoma12, start_x + 256 + 64, start_y + 28 + 30, MakeColor(255, 255, 255, 255), tmpstr); DrawText(tahoma12, start_x + 256 + 64, start_y + 28 + 30, themeCurrent.textColor, tmpstr);
memset(tmpstr, 0, sizeof(tmpstr)); memset(tmpstr, 0, sizeof(tmpstr));
snprintf(tmpstr, sizeof(tmpstr)-1, "Version: %s", me->version); snprintf(tmpstr, sizeof(tmpstr)-1, "Version: %s", me->version);
DrawText(tahoma12, start_x + 256 + 64, start_y + 28 + 30 + 18 + 6, MakeColor(255, 255, 255, 255), tmpstr); DrawText(tahoma12, start_x + 256 + 64, start_y + 28 + 30 + 18 + 6, themeCurrent.textColor, tmpstr);
} }
} }
} }
@ -164,7 +164,6 @@ color_t waveBlendAdd(color_t a, color_t b, float alpha) {
return MakeColor(a.r+(b.r*alpha), a.g+b.g*alpha, a.b + b.b*alpha, 255); return MakeColor(a.r+(b.r*alpha), a.g+b.g*alpha, a.b + b.b*alpha, 255);
} }
const int ENABLE_WAVE_BLENDING = 0;
double timer; double timer;
void drawWave(float timer, color_t color, float height, float phase, float speed) { void drawWave(float timer, color_t color, float height, float phase, float speed) {
@ -182,10 +181,14 @@ void drawWave(float timer, color_t color, float height, float phase, float speed
alpha = y-wave_top_y; alpha = y-wave_top_y;
existing_color = FetchPixelColor(x, y); existing_color = FetchPixelColor(x, y);
if (ENABLE_WAVE_BLENDING || alpha < 1.0) { if (themeCurrent.enableWaveBlending) {
new_color = waveBlendAdd(existing_color, color, clamp(alpha, 0.0, 1.0) * 0.3); new_color = waveBlendAdd(existing_color, color, clamp(alpha, 0.0, 1.0) * 0.3);
} }
else { else if (alpha < 0.3) { // anti-aliasing
alpha = fabs(alpha);
new_color = MakeColor(color.r * (1.0 - alpha) + existing_color.r * alpha, color.g * (1.0 - alpha) + existing_color.g * alpha, color.b * (1.0 - alpha) + existing_color.b * alpha, 255);
}
else { // darken closer to bottom of the waves
dark_mult = clamp((alpha - 50) / height, 0.0, 1.0); dark_mult = clamp((alpha - 50) / height, 0.0, 1.0);
new_color = MakeColor(color.r - dark_sub * dark_mult, color.g - dark_sub * dark_mult, color.b - dark_sub * dark_mult, 255); new_color = MakeColor(color.r - dark_sub * dark_mult, color.g - dark_sub * dark_mult, color.b - dark_sub * dark_mult, 255);
} }
@ -221,24 +224,24 @@ void menuLoop() {
for (x=0; x<1280; x++) { for (x=0; x<1280; x++) {
for (y=0; y<720; y++) { for (y=0; y<720; y++) {
DrawPixelRaw(x, y, MakeColor(45, 55, 66, 255)); DrawPixelRaw(x, y, themeCurrent.backgroundColor);
} }
} }
drawWave(timer, MakeColor(73, 103, 169, 255), 320.0, 0.0, 3.0); drawWave(timer, themeCurrent.backWaveColor, 320.0, 0.0, 3.0);
drawWave(timer, MakeColor(66, 154, 159, 255), 300.0, 2.0, 3.5); drawWave(timer, themeCurrent.middleWaveColor, 300.0, 2.0, 3.5);
drawWave(timer, MakeColor(96, 204, 204, 255), 280.0, 4.0, -2.5); drawWave(timer, themeCurrent.frontWaveColor, 280.0, 4.0, -2.5);
timer += 0.05; timer += 0.05;
DrawText(tahoma24, 40, 30, MakeColor(255, 255, 255, 255), "hbmenu"); DrawText(tahoma24, 40, 30, themeCurrent.textColor, "hbmenu");
DrawText(tahoma12, 40 + 120, 30 + 16, MakeColor(255, 255, 255, 255), "v2.0.0"); DrawText(tahoma12, 40 + 120, 30 + 16, themeCurrent.textColor, "v2.0.0");
DrawText(tahoma12, 40, 720 - 32 - 16, MakeColor(255, 255, 255, 255), menu->dirname); DrawText(tahoma12, 40, 720 - 32 - 16, themeCurrent.textColor, menu->dirname);
//drawTime(); //drawTime();
if (menu->nEntries==0) if (menu->nEntries==0)
{ {
DrawText(tahoma12, 64, 96 + 32, MakeColor(255, 255, 255, 255), textGetString(StrId_NoAppsFound_Msg)); DrawText(tahoma12, 64, 96 + 32, themeCurrent.textColor, textGetString(StrId_NoAppsFound_Msg));
} }
else else
{ {

29
common/theme.c Normal file
View File

@ -0,0 +1,29 @@
#include "theme.h"
void themeStartup(ThemePreset preset) {
switch (preset) {
case THEME_PRESET_DARK:
themeCurrent = (theme_t) {
textColor: MakeColor(255, 255, 255, 255),
frontWaveColor: MakeColor(96, 204, 204, 255),
middleWaveColor: MakeColor(66, 154, 159, 255),
backWaveColor: MakeColor(73, 103, 169, 255),
backgroundColor: MakeColor(45, 55, 66, 255),
highlightColor: MakeColor(73, 103, 169, 255),
enableWaveBlending: 0
};
break;
case THEME_PRESET_LIGHT:
themeCurrent = (theme_t) {
textColor: MakeColor(0, 0, 0, 255),
frontWaveColor: MakeColor(100, 212, 250, 255),
middleWaveColor: MakeColor(100, 153, 255, 255),
backWaveColor: MakeColor(154, 171, 255, 255),
backgroundColor: MakeColor(233, 236, 241, 255),
highlightColor: MakeColor(129, 137, 236, 255),
enableWaveBlending: 0
};
break;
}
}

24
common/theme.h Normal file
View File

@ -0,0 +1,24 @@
#pragma once
#include "common.h"
typedef struct
{
color_t textColor;
color_t frontWaveColor;
color_t middleWaveColor;
color_t backWaveColor;
color_t backgroundColor;
color_t highlightColor;
bool enableWaveBlending;
} theme_t;
typedef enum
{
THEME_PRESET_DARK,
THEME_PRESET_LIGHT,
} ThemePreset;
void themeStartup(ThemePreset preset);
theme_t themeCurrent;

View File

@ -13,6 +13,7 @@ int main(int argc, char **argv)
appletSetScreenShotPermission(1); appletSetScreenShotPermission(1);
//themeStartup();
menuStartup(); menuStartup();
launchInit(); launchInit();

View File

@ -15,6 +15,7 @@ int main()
sf::RenderWindow window(sf::VideoMode(1280, 720), "Test"); sf::RenderWindow window(sf::VideoMode(1280, 720), "Test");
window.setFramerateLimit(60); window.setFramerateLimit(60);
themeStartup(THEME_PRESET_LIGHT);
menuStartup(); menuStartup();
while (window.isOpen()) while (window.isOpen())