1 /* 2 * 0BSD 3 * 4 * BSD Zero Clause License 5 * 6 * Copyright (c) 2019 Hermann Meyer 7 * 8 * Permission to use, copy, modify, and/or distribute this software for any 9 * purpose with or without fee is hereby granted. 10 11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 12 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 13 * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 15 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 16 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17 * PERFORMANCE OF THIS SOFTWARE. 18 * 19 */ 20 21 #pragma once 22 23 #ifndef XCOLOR_H_ 24 #define XCOLOR_H_ 25 26 #include "xputty.h" 27 28 #ifdef __cplusplus 29 extern "C" { 30 #endif 31 32 33 /** 34 * 35 * @brief Color_state - select color mode to use on Widget_t 36 */ 37 38 typedef enum { 39 NORMAL_, 40 PRELIGHT_, 41 SELECTED_, 42 ACTIVE_, 43 INSENSITIVE_, 44 } Color_state; 45 46 /** 47 * 48 * @brief Color_set - select color set to use on draw 49 */ 50 51 typedef enum { 52 FORGROUND_, 53 BACKGROUND_, 54 BASE_, 55 TEXT_, 56 SHADOW_, 57 FRAME_, 58 LIGHT_, 59 } Color_mod; 60 61 /** 62 * 63 * @brief Color_t - struct used to set cairo color for Widget_t 64 * @param fg[4] - forground {red, green, blue, alpha} 65 * @param bg[4] - background {red, green, blue, alpha} 66 * @param base[4] - base {red, green, blue, alpha} 67 * @param text[4] - text {red, green, blue, alpha} 68 * @param shadow[4] - shadow {red, green, blue, alpha} 69 * @param frame[4] - frame {red, green, blue, alpha} 70 * @param light[4] - light {red, green, blue, alpha} 71 */ 72 73 typedef struct { 74 double fg[4]; 75 double bg[4]; 76 double base[4]; 77 double text[4]; 78 double shadow[4]; 79 double frame[4]; 80 double light[4]; 81 } Colors; 82 83 /** 84 * @brief XColor_t - the Widget_t Color struct 85 * \n XColor_t could be used for theming you Widget_t set 86 */ 87 88 struct XColor_t { 89 Colors normal; 90 Colors prelight; 91 Colors selected; 92 Colors active; 93 Colors insensitive; 94 }; 95 96 /** 97 * @brief set_dark_theme - init the XColor_t struct to the default 98 * dark theme 99 * @param *main - pointer to the main Xputty struct 100 * @return void 101 */ 102 103 void set_dark_theme(Xputty *main); 104 105 /** 106 * @brief set_light_theme - init the XColor_t struct to the default 107 * light theme 108 * @param *main - pointer to the main Xputty struct 109 * @return void 110 */ 111 112 void set_light_theme(Xputty *main); 113 114 /** 115 * @brief get_color_scheme - get pointer to the Colors struct to use 116 * in relation to the Color_state 117 * @param *st - the Color state to use 118 * @return void 119 */ 120 121 Colors *get_color_scheme(Xputty *main, Color_state st); 122 123 /** 124 * @brief get_color_state - get the Color_state to use in relation to the 125 * Widget_t state 126 * @param *wid - pointer to the Widget_t 127 * @return Color_state - the Color_state related to the Widget_t state 128 */ 129 130 Color_state get_color_state(Widget_t *wid); 131 132 /** 133 * @brief use_fg_color_scheme - use forground Colors to paint on Widget_t 134 * @param *w - the Widget_t to set the Colors 135 * @param st - the Color_state to use 136 * @return void 137 */ 138 139 void use_fg_color_scheme(Widget_t *w, Color_state st); 140 141 /** 142 * @brief use_bg_color_scheme - use background Colors to paint on Widget_t 143 * @param w - the Widget_t to set the Colors 144 * @param st - the Color_state to use 145 * @return void 146 */ 147 148 void use_bg_color_scheme(Widget_t *w, Color_state st); 149 150 /** 151 * @brief use_base_color_scheme - use base Colors to paint on Widget_t 152 * @param w - the Widget_t to set the Colors 153 * @param st - the Color_state to use 154 * @return void 155 */ 156 157 void use_base_color_scheme(Widget_t *w, Color_state st); 158 159 /** 160 * @brief use_text_color_scheme - use text Colors to paint on Widget_t 161 * @param w - the Widget_t to set the Colors 162 * @param st - the Color_state to use 163 * @return void 164 */ 165 166 void use_text_color_scheme(Widget_t *w, Color_state st); 167 168 /** 169 * @brief use_shadow_color_scheme - use shadow Colors to paint on Widget_t 170 * @param w - the Widget_t to set the Colors 171 * @param st - the Color_state to use 172 * @return void 173 */ 174 175 void use_shadow_color_scheme(Widget_t *w, Color_state st); 176 177 /** 178 * @brief use_frame_color_scheme - use frame Colors to paint on Widget_t 179 * @param w - the Widget_t to set the Colors 180 * @param st - the Color_state to use 181 * @return void 182 */ 183 184 void use_frame_color_scheme(Widget_t *w, Color_state st); 185 186 /** 187 * @brief use_light_color_scheme - use light Colors to paint on Widget_t 188 * @param w - the Widget_t to set the Colors 189 * @param st - the Color_state to use 190 * @return void 191 */ 192 193 void use_light_color_scheme(Widget_t *w, Color_state st); 194 195 /** 196 * @brief set_pattern - set pattern for the selected Colors 197 * @param *w_ - pointer to the Widget_t to set the pattern 198 * @param *from - the Colors set to pattern from (0) 199 * @param *to - the Colors set to pattern to (1) 200 * @param mod - the Color_mod to use 201 * @return void 202 */ 203 204 void set_pattern(Widget_t *w, Colors *from, Colors *to, Color_mod mod); 205 206 #ifdef __cplusplus 207 } 208 #endif 209 210 #endif //XCOLOR_H_ 211