diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-06-21 06:25:13 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-06-21 06:25:17 +0200 |
commit | 933ceeabb339cdf0583a8687528941593381a268 (patch) | |
tree | e3963cd74eb726a63f6e91f2f22f485fac65084a /src/Theme.cpp | |
parent | d137dcfa6dd248ffa94e58e7aef4487682bc12dc (diff) |
Add color themeing, (Theme.hpp/Theme.cpp) and the env var QM_THEME
Diffstat (limited to 'src/Theme.cpp')
-rw-r--r-- | src/Theme.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/Theme.cpp b/src/Theme.cpp new file mode 100644 index 0000000..1f4feca --- /dev/null +++ b/src/Theme.cpp @@ -0,0 +1,62 @@ +#include "../include/Theme.hpp" +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <assert.h> + +namespace QuickMedia { + static bool themes_initialized = false; + static int current_theme = Theme::THEME_DARK; + + static Theme themes[1]; + + static void init_theme_dark() { + themes[Theme::THEME_DARK].background_color = sf::Color(21, 25, 30); + themes[Theme::THEME_DARK].text_color = sf::Color(255, 255, 255); + themes[Theme::THEME_DARK].faded_text_color = sf::Color(255, 255, 255, 179); + themes[Theme::THEME_DARK].shade_color = sf::Color(33, 37, 44); + themes[Theme::THEME_DARK].selected_color = sf::Color(55, 60, 68); + themes[Theme::THEME_DARK].card_item_background_color = sf::Color(28, 32, 39); + themes[Theme::THEME_DARK].replies_text_color = sf::Color(129, 162, 190); + themes[Theme::THEME_DARK].placeholder_text_color = sf::Color(255, 255, 255, 100); + themes[Theme::THEME_DARK].image_loading_background_color = sf::Color(52, 58, 70); + themes[Theme::THEME_DARK].attention_alert_text_color = sf::Color(255, 100, 100); + themes[Theme::THEME_DARK].cancel_button_background_color = sf::Color(41, 45, 50); + themes[Theme::THEME_DARK].confirm_button_background_color = sf::Color(31, 117, 255); + themes[Theme::THEME_DARK].loading_bar_color = sf::Color(31, 117, 255); + themes[Theme::THEME_DARK].embedded_item_border_color = sf::Color(255, 255, 255); + themes[Theme::THEME_DARK].provisional_message_color = sf::Color(255, 255, 255, 150); + themes[Theme::THEME_DARK].failed_text_color = sf::Color(255, 0, 0); + themes[Theme::THEME_DARK].timestamp_text_color = sf::Color(185, 190, 198, 100); + themes[Theme::THEME_DARK].new_items_alert_color = sf::Color(128, 50, 50); + themes[Theme::THEME_DARK].arrow_color = sf::Color(255, 255, 255, 175); + themes[Theme::THEME_DARK].url_text_color = sf::Color(35, 140, 245); + themes[Theme::THEME_DARK].loading_page_color = sf::Color(175, 180, 188); + } + + void init_themes() { + if(themes_initialized) + return; + + init_theme_dark(); + themes_initialized = true; + + char *theme = getenv("QM_THEME"); + if(!theme) + return; + + if(strcmp(theme, "default") == 0) + set_current_theme(Theme::THEME_DARK); + else + fprintf(stderr, "Warning: Invalid theme %s, using the default theme...\n", theme); + } + + void set_current_theme(int theme) { + current_theme = theme; + } + + Theme& get_current_theme() { + assert(themes_initialized); + return themes[current_theme]; + } +}
\ No newline at end of file |