Skip to content

Commit

Permalink
initial work on theme v2
Browse files Browse the repository at this point in the history
see #78
  • Loading branch information
ITotalJustice committed Jan 9, 2025
1 parent 9915307 commit f05230e
Show file tree
Hide file tree
Showing 26 changed files with 452 additions and 532 deletions.
15 changes: 8 additions & 7 deletions assets/romfs/themes/abyss_theme.ini
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
[meta]
name=Abyss
author=TotalJustice
version=1.0.0
version=1.1.0
inherit=romfs:/themes/base_black_theme.ini

[theme]
background=0x0f111aff
grid=0x0f115c30
selected=0x0f115cff
selected_overlay=0x529cffff
text=0xffbc41ff
text_selected=0x529cffff
background = 0x0f111a
grid = 0x0f115c30
popup = 0x0f115c
text = 0xffbc41
text_info = 0xffbc41
text_selected = 0x529cff
selected_background = 0x0f115c
46 changes: 32 additions & 14 deletions assets/romfs/themes/base_black_theme.ini
Original file line number Diff line number Diff line change
@@ -1,15 +1,33 @@
[theme]
background=0x2d2d2dff
grid=0x46464630
selected=0x464646ff
selected_overlay=0x00ffc8ff
text=0xfbfbfbff
text_selected=0x00ffc8ff

icon_audio=romfs:/theme/icon_audio.png
icon_video=romfs:/theme/icon_video.png
icon_image=romfs:/theme/icon_image.png
icon_file=romfs:/theme/icon_file.png
icon_folder=romfs:/theme/icon_folder.png
icon_zip=romfs:/theme/icon_zip.png
icon_nro=romfs:/theme/icon_nro.png
background = 0x2d2d2d
grid = 0x46464630
popup = 0x464646
error = 0xfa5a3a

line = 0xfbfbfb
line_seperator = 0xd1d1d1

text = 0xfbfbfb
text_info = 0xd1d1d1
text_selected = 0x00ffc8
selected_background = 0x464646

sidebar = 0x000000dc

scrollbar = 0x00ffc8
scrollbar_background = ; hide the background
; scrollbar_background = 0x464646

progressbar = 0x00ffc8
progressbar_background = 0x464646

highlight_1 = 0x1989c6
highlight_2 = 0x89f0f2

icon_audio = romfs:/theme/icon_audio.png
icon_video = romfs:/theme/icon_video.png
icon_image = romfs:/theme/icon_image.png
icon_file = romfs:/theme/icon_file.png
icon_folder = romfs:/theme/icon_folder.png
icon_zip = romfs:/theme/icon_zip.png
icon_nro = romfs:/theme/icon_nro.png
34 changes: 34 additions & 0 deletions assets/romfs/themes/base_white_theme.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[theme]
background = 0xececec
grid = 0xf1f1f1
popup = 0xf1f1f1
error = 0xfa5a3a

line = 0x373737
line_seperator = 0x373737

text = 0x373737
text_info = 0x808080
text_selected = 0x3250f0
selected_background = 0xfdfdfd

sidebar = 0xe2e2e2f5

scrollbar = 0x3250f0
scrollbar_background = ; hide the background
; scrollbar_background = 0xababab

progressbar = 0x3250f0
progressbar_background = 0x808080

highlight_1 = 0x1989c6
highlight_2 = 0x89f0f2

icon_colour = 0x6f7779
icon_audio = romfs:/theme/icon_audio.png
icon_video = romfs:/theme/icon_video.png
icon_image = romfs:/theme/icon_image.png
icon_file = romfs:/theme/icon_file.png
icon_folder = romfs:/theme/icon_folder.png
icon_zip = romfs:/theme/icon_zip.png
icon_nro = romfs:/theme/icon_nro.png
2 changes: 1 addition & 1 deletion assets/romfs/themes/black_theme.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[meta]
name=Black
author=TotalJustice
version=1.0.0
version=1.1.0
inherit=romfs:/themes/base_black_theme.ini
16 changes: 8 additions & 8 deletions assets/romfs/themes/oled_black_theme.ini
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[meta]
name=OLED Black
author=iTotalJustice/Sanras
version=1.0.0
author=TotalJustice/Sanras
version=1.1.0
inherit=romfs:/themes/base_black_theme.ini

[theme]
background=0x000000ff
grid=0x46464640
selected=0x323232ff
selected_overlay=0x00ffc8ff
text=0xfbfbfbff
text_selected=0x00ffc8ff
background = 0x000000
grid = 0x46464640
popup = 0x323232
text = 0xfbfbfb
text_selected = 0x00ffc8
selected_background = 0x323232
5 changes: 5 additions & 0 deletions assets/romfs/themes/white_theme.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[meta]
name=White
author=TotalJustice/Yorunokyujitsu
version=1.0.0
inherit=romfs:/themes/base_white_theme.ini
2 changes: 1 addition & 1 deletion sphaira/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ FetchContent_Declare(yyjson

FetchContent_Declare(minIni
GIT_REPOSITORY https://github.com/ITotalJustice/minIni-nx.git
GIT_TAG 63ec295
GIT_TAG 11cac8b
)

set(MININI_LIB_NAME minIni)
Expand Down
7 changes: 5 additions & 2 deletions sphaira/include/app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ class App {
// void DrawElement(float x, float y, float w, float h, ui::ThemeEntryID id);
auto LoadElementImage(std::string_view value) -> ElementEntry;
auto LoadElementColour(std::string_view value) -> ElementEntry;
auto LoadElement(std::string_view data) -> ElementEntry;
auto LoadElement(std::string_view data, ElementType type) -> ElementEntry;

void LoadTheme(const ThemeMeta& meta);
void LoadTheme(ThemeMeta meta, int inherit_level = 0);
void CloseTheme();
void ScanThemes(const std::string& path);
void ScanThemeEntries();
Expand Down Expand Up @@ -165,6 +165,9 @@ class App {
PLSR_BFSAR m_qlaunch_bfsar{};
PLSR_PlayerSoundId m_sound_ids[SoundEffect_MAX]{};

private:
void CloseMusic();

private: // from nanovg decko3d example by adubbz
static constexpr unsigned NumFramebuffers = 2;
static constexpr unsigned StaticCmdSize = 0x1000;
Expand Down
76 changes: 13 additions & 63 deletions sphaira/include/ui/nvg_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,87 +5,37 @@

namespace sphaira::ui::gfx {

enum class Colour {
BLACK,
LIGHT_BLACK,
SILVER,
DARK_GREY,
GREY,
WHITE,
CYAN,
TEAL,
BLUE,
LIGHT_BLUE,
YELLOW,
RED,
};

void drawImage(NVGcontext*, float x, float y, float w, float h, int texture);
void drawImage(NVGcontext*, Vec4 v, int texture);
void drawImage(NVGcontext*, const Vec4& v, int texture);
void drawImageRounded(NVGcontext*, float x, float y, float w, float h, int texture);
void drawImageRounded(NVGcontext*, Vec4 v, int texture);

auto getColour(Colour c) -> NVGcolor;
void drawImageRounded(NVGcontext*, const Vec4& v, int texture);

void dimBackground(NVGcontext*);

void drawRect(NVGcontext*, float x, float y, float w, float h, Colour c, bool rounded = false);
void drawRect(NVGcontext*, Vec4 vec, Colour c, bool rounded = false);
void drawRect(NVGcontext*, float x, float y, float w, float h, const NVGcolor& c, bool rounded = false);
void drawRect(NVGcontext*, float x, float y, float w, float h, const NVGcolor&& c, bool rounded = false);
void drawRect(NVGcontext*, Vec4 vec, const NVGcolor& c, bool rounded = false);
void drawRect(NVGcontext*, Vec4 vec, const NVGcolor&& c, bool rounded = false);
void drawRect(NVGcontext*, const Vec4& v, const NVGcolor& c, bool rounded = false);
void drawRect(NVGcontext*, float x, float y, float w, float h, const NVGpaint& p, bool rounded = false);
void drawRect(NVGcontext*, float x, float y, float w, float h, const NVGpaint&& p, bool rounded = false);
void drawRect(NVGcontext*, Vec4 vec, const NVGpaint& p, bool rounded = false);
void drawRect(NVGcontext*, Vec4 vec, const NVGpaint&& p, bool rounded = false);

void drawRectOutline(NVGcontext*, float size, const NVGcolor& out_col, float x, float y, float w, float h, Colour c);
void drawRectOutline(NVGcontext*, float size, const NVGcolor& out_col, Vec4 vec, Colour c);
void drawRectOutline(NVGcontext*, float size, const NVGcolor& out_col, float x, float y, float w, float h, const NVGcolor& c);
void drawRectOutline(NVGcontext*, float size, const NVGcolor& out_col, float x, float y, float w, float h, const NVGcolor&& c);
void drawRectOutline(NVGcontext*, float size, const NVGcolor& out_col, Vec4 vec, const NVGcolor& c);
void drawRectOutline(NVGcontext*, float size, const NVGcolor& out_col, Vec4 vec, const NVGcolor&& c);
void drawRectOutline(NVGcontext*, float size, const NVGcolor& out_col, float x, float y, float w, float h, const NVGpaint& p);
void drawRectOutline(NVGcontext*, float size, const NVGcolor& out_col, float x, float y, float w, float h, const NVGpaint&& p);
void drawRectOutline(NVGcontext*, float size, const NVGcolor& out_col, Vec4 vec, const NVGpaint& p);
void drawRectOutline(NVGcontext*, float size, const NVGcolor& out_col, Vec4 vec, const NVGpaint&& p);
void drawRect(NVGcontext*, const Vec4& v, const NVGpaint& p, bool rounded = false);

void drawTriangle(NVGcontext*, float aX, float aY, float bX, float bY, float cX, float cY, Colour c);
void drawTriangle(NVGcontext*, float aX, float aY, float bX, float bY, float cX, float cY, const NVGcolor& c);
void drawTriangle(NVGcontext*, float aX, float aY, float bX, float bY, float cX, float cY, const NVGcolor&& c);
void drawTriangle(NVGcontext*, float aX, float aY, float bX, float bY, float cX, float cY, const NVGpaint& p);
void drawTriangle(NVGcontext*, float aX, float aY, float bX, float bY, float cX, float cY, const NVGpaint&& p);
void drawRectOutline(NVGcontext*, const Theme*, float size, float x, float y, float w, float h);
void drawRectOutline(NVGcontext*, const Theme*, float size, const Vec4& v);

void drawText(NVGcontext*, float x, float y, float size, const char* str, const char* end, int align, Colour c);
void drawText(NVGcontext*, float x, float y, float size, Colour c, const char* str, int align = NVG_ALIGN_LEFT | NVG_ALIGN_TOP, const char* end = nullptr);
void drawText(NVGcontext*, Vec2 vec, float size, const char* str, const char* end, int align, Colour c);
void drawText(NVGcontext*, Vec2 vec, float size, Colour c, const char* str, int align = NVG_ALIGN_LEFT | NVG_ALIGN_TOP, const char* end = nullptr);
void drawText(NVGcontext*, float x, float y, float size, const char* str, const char* end, int align, const NVGcolor& c);
void drawText(NVGcontext*, float x, float y, float size, const char* str, const char* end, int align, const NVGcolor&& c);
void drawText(NVGcontext*, float x, float y, float size, const NVGcolor& c, const char* str, int align = NVG_ALIGN_LEFT | NVG_ALIGN_TOP, const char* end = nullptr);
void drawText(NVGcontext*, float x, float y, float size, const NVGcolor&& c, const char* str, int align = NVG_ALIGN_LEFT | NVG_ALIGN_TOP, const char* end = nullptr);
void drawText(NVGcontext*, Vec2 vec, float size, const char* str, const char* end, int align, const NVGcolor& c);
void drawText(NVGcontext*, Vec2 vec, float size, const char* str, const char* end, int align, const NVGcolor&& c);
void drawText(NVGcontext*, Vec2 vec, float size, const NVGcolor& c, const char* str, int align = NVG_ALIGN_LEFT | NVG_ALIGN_TOP, const char* end = nullptr);
void drawText(NVGcontext*, Vec2 vec, float size, const NVGcolor&& c, const char* str, int align = NVG_ALIGN_LEFT | NVG_ALIGN_TOP, const char* end = nullptr);
void drawTextArgs(NVGcontext*, float x, float y, float size, int align, Colour c, const char* str, ...) __attribute__ ((format (printf, 7, 8)));
void drawText(NVGcontext*, const Vec2& v, float size, const char* str, const char* end, int align, const NVGcolor& c);
void drawText(NVGcontext*, const Vec2& v, float size, const NVGcolor& c, const char* str, int align = NVG_ALIGN_LEFT | NVG_ALIGN_TOP, const char* end = nullptr);
void drawTextArgs(NVGcontext*, float x, float y, float size, int align, const NVGcolor& c, const char* str, ...) __attribute__ ((format (printf, 7, 8)));

void drawTextBox(NVGcontext*, float x, float y, float size, float bound, NVGcolor& c, const char* str, int align = NVG_ALIGN_LEFT | NVG_ALIGN_TOP, const char* end = nullptr);
void drawTextBox(NVGcontext*, float x, float y, float size, float bound, NVGcolor&& c, const char* str, int align = NVG_ALIGN_LEFT | NVG_ALIGN_TOP, const char* end = nullptr);
void drawTextBox(NVGcontext*, float x, float y, float size, float bound, Colour c, const char* str, int align = NVG_ALIGN_LEFT | NVG_ALIGN_TOP, const char* end = nullptr);
void drawTextBox(NVGcontext*, float x, float y, float size, float bound, const NVGcolor& c, const char* str, int align = NVG_ALIGN_LEFT | NVG_ALIGN_TOP, const char* end = nullptr);

void textBounds(NVGcontext*, float x, float y, float *bounds, const char* str, ...) __attribute__ ((format (printf, 5, 6)));
// void textBounds(NVGcontext*, float *bounds, const char* str, ...) __attribute__ ((format (printf, 5, 6)));
// void textBounds(NVGcontext*, float *bounds, const char* str);

auto getButton(Button button) -> const char*;
void drawScrollbar(NVGcontext* vg, Theme* theme, u32 index_off, u32 count, u32 max_per_page);
void drawScrollbar(NVGcontext* vg, Theme* theme, float x, float y, float h, u32 index_off, u32 count, u32 max_per_page);
void drawScrollbar(NVGcontext*, const Theme*, u32 index_off, u32 count, u32 max_per_page);
void drawScrollbar(NVGcontext*, const Theme*, float x, float y, float h, u32 index_off, u32 count, u32 max_per_page);

void drawScrollbar2(NVGcontext* vg, Theme* theme, float x, float y, float h, s64 index_off, s64 count, s64 row, s64 page);
void drawScrollbar2(NVGcontext* vg, Theme* theme, s64 index_off, s64 count, s64 row, s64 page);
void drawScrollbar2(NVGcontext*, const Theme*, float x, float y, float h, s64 index_off, s64 count, s64 row, s64 page);
void drawScrollbar2(NVGcontext*, const Theme*, s64 index_off, s64 count, s64 row, s64 page);

void updateHighlightAnimation();
void getHighlightAnimation(float* gradientX, float* gradientY, float* color);
Expand Down
46 changes: 42 additions & 4 deletions sphaira/include/ui/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,21 +162,55 @@ struct ElementEntry {
};

enum ThemeEntryID {
// colour of the background, can be an image.
ThemeEntryID_BACKGROUND,

// colour of the grid background (homebrew, appstore), can be an image.
ThemeEntryID_GRID,
ThemeEntryID_SELECTED,
ThemeEntryID_SELECTED_OVERLAY,
// background colour of a popup.
ThemeEntryID_POPUP,
// colour of the error text / button.
ThemeEntryID_ERROR,

// colour of all text.
ThemeEntryID_TEXT,
// colour of text info and subheaders.
ThemeEntryID_TEXT_INFO,
// colour of selected item text.
ThemeEntryID_TEXT_SELECTED,
// background colour of a selected item, can be an image (not recommended).
ThemeEntryID_SELECTED_BACKGROUND,

// colour of line separators in a list.
ThemeEntryID_LINE,
ThemeEntryID_LINE_SEPERATOR,

// colour of the sidebar backrgound.
ThemeEntryID_SIDEBAR,

// colour of the scrollbar (full portion).
ThemeEntryID_SCROLLBAR,
// colour of the scrollbar background (empty portion).
ThemeEntryID_SCROLLBAR_BACKGROUND,

// colour of the progressbar (full portion).
ThemeEntryID_PROGRESSBAR,
// colour of the progressbar background (empty portion).
ThemeEntryID_PROGRESSBAR_BACKGROUND,

// the colours of the pulsing effect, from 1 -> 2.
ThemeEntryID_HIGHLIGHT_1,
ThemeEntryID_HIGHLIGHT_2,

// changes the colours of the internal icons used below.
ThemeEntryID_ICON_COLOUR,

// images used in the filebrowser.
ThemeEntryID_ICON_AUDIO,
ThemeEntryID_ICON_VIDEO,
ThemeEntryID_ICON_IMAGE,
ThemeEntryID_ICON_FILE,
ThemeEntryID_ICON_FOLDER,
ThemeEntryID_ICON_ZIP,
ThemeEntryID_ICON_GAME,
ThemeEntryID_ICON_NRO,

ThemeEntryID_MAX,
Expand All @@ -194,6 +228,10 @@ struct Theme {
ThemeMeta meta;
PLSR_BFSTM music;
ElementEntry elements[ThemeEntryID_MAX];

auto GetColour(ThemeEntryID id) const {
return elements[id].colour;
}
};

// enum class TouchGesture {
Expand Down
Loading

0 comments on commit f05230e

Please sign in to comment.