aboutsummaryrefslogtreecommitdiff
path: root/src/Theme.cpp
blob: 18581ff47ffcf8b5d4ec877c6ee47042ae5c02a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include "../include/Theme.hpp"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <assert.h>

namespace QuickMedia {
    enum {
        THEME_DARK, // Default theme
        THEME_NORD,

        __NUM_THEMES__ // This should always be the last item
    };

    static bool themes_initialized = false;
    static int current_theme = THEME_DARK;
    static Theme themes[__NUM_THEMES__];

    static void init_theme_dark() {
        themes[THEME_DARK].background_color = sf::Color(18, 21, 26);
        themes[THEME_DARK].text_color = sf::Color(255, 255, 255);
        themes[THEME_DARK].faded_text_color = sf::Color(255, 255, 255, 179);
        themes[THEME_DARK].shade_color = sf::Color(28, 32, 39);
        themes[THEME_DARK].selected_color = sf::Color(55, 60, 68);
        themes[THEME_DARK].card_item_background_color = sf::Color(28, 32, 39);
        themes[THEME_DARK].replies_text_color = sf::Color(129, 162, 190);
        themes[THEME_DARK].placeholder_text_color = sf::Color(255, 255, 255, 100);
        themes[THEME_DARK].image_loading_background_color = sf::Color(52, 58, 70);
        themes[THEME_DARK].attention_alert_text_color = sf::Color(255, 100, 100);
        themes[THEME_DARK].cancel_button_background_color = sf::Color(41, 45, 50);
        themes[THEME_DARK].confirm_button_background_color = sf::Color(31, 117, 255);
        themes[THEME_DARK].loading_bar_color = sf::Color(31, 117, 255);
        themes[THEME_DARK].embedded_item_border_color = sf::Color(255, 255, 255);
        themes[THEME_DARK].provisional_message_color = sf::Color(255, 255, 255, 150);
        themes[THEME_DARK].failed_text_color = sf::Color(255, 0, 0);
        themes[THEME_DARK].timestamp_text_color = sf::Color(185, 190, 198, 100);
        themes[THEME_DARK].new_items_alert_color = sf::Color(128, 50, 50);
        themes[THEME_DARK].arrow_color = sf::Color(255, 255, 255, 175);
        themes[THEME_DARK].url_text_color = sf::Color(35, 140, 245);
        themes[THEME_DARK].loading_page_color = sf::Color(175, 180, 188);
        themes[THEME_DARK].more_items_color = sf::Color(150, 175, 255, 100);
        themes[THEME_DARK].blur_enabled = false;
    }

    static void init_theme_nord() {
        themes[THEME_NORD].background_color = sf::Color(46, 52, 64);
        themes[THEME_NORD].text_color = sf::Color(236, 239, 244);
        themes[THEME_NORD].faded_text_color = sf::Color(229, 233, 240);
        themes[THEME_NORD].shade_color = sf::Color(67, 76, 94);
        themes[THEME_NORD].selected_color = sf::Color(59, 66, 82);
        themes[THEME_NORD].card_item_background_color = sf::Color(76, 86, 106);
        themes[THEME_NORD].replies_text_color = sf::Color(136, 192, 208);
        themes[THEME_NORD].placeholder_text_color = sf::Color(236, 239, 244);
        themes[THEME_NORD].image_loading_background_color = sf::Color(216, 222, 233);
        themes[THEME_NORD].attention_alert_text_color = sf::Color(191, 97, 106);
        themes[THEME_NORD].cancel_button_background_color = sf::Color(229, 233, 240);
        themes[THEME_NORD].confirm_button_background_color = sf::Color(229, 233, 240);
        themes[THEME_NORD].loading_bar_color = sf::Color(136, 192, 208);
        themes[THEME_NORD].embedded_item_border_color = sf::Color(216, 222, 233);
        themes[THEME_NORD].provisional_message_color = sf::Color(236, 239, 244);
        themes[THEME_NORD].failed_text_color = sf::Color(191, 97, 106);
        themes[THEME_NORD].timestamp_text_color = sf::Color(76, 86, 106);
        themes[THEME_NORD].new_items_alert_color = sf::Color(235, 203, 139);
        themes[THEME_NORD].arrow_color = sf::Color(236, 239, 244);
        themes[THEME_NORD].url_text_color = sf::Color(136, 192, 208);
        themes[THEME_NORD].loading_page_color = sf::Color(229, 233, 240);
        themes[THEME_NORD].more_items_color = sf::Color(150, 175, 255, 100);
        themes[THEME_NORD].blur_enabled = false;
    }

    void init_themes() {
        if(themes_initialized)
            return;

        themes_initialized = true;
        init_theme_dark();
        init_theme_nord();

        char *theme = getenv("QM_THEME");
        if(!theme)
            return;

        if(strcmp(theme, "default") == 0)
            current_theme = THEME_DARK;
        else if(strcmp(theme, "nord") == 0)
            current_theme = THEME_NORD;
        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];
    }
}