libxputty  0.1
A damn tiny abstraction Layer to create X11 window/widgets with cairo surfaces
xcolor.h
Go to the documentation of this file.
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 {
44 } Color_state;
45 
46 /**
47  *
48  * @brief Color_set - select color set to use on draw
49  */
50 
51 typedef enum {
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 {
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 
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 
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 
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 
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 
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 
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 
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 
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 
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_
use_text_color_scheme
void use_text_color_scheme(Widget_t *w, Color_state st)
use_text_color_scheme - use text Colors to paint on Widget_t
Definition: xcolor.c:199
XColor_t::active
Colors active
Definition: xcolor.h:92
Xputty
Xputty - the main struct. It should be declared before any other call to a Xputty function....
Definition: xputty.h:177
FRAME_
@ FRAME_
Definition: xcolor.h:57
set_dark_theme
void set_dark_theme(Xputty *main)
set_dark_theme - init the XColor_t struct to the default dark theme
Definition: xcolor.c:24
SHADOW_
@ SHADOW_
Definition: xcolor.h:56
INSENSITIVE_
@ INSENSITIVE_
Definition: xcolor.h:43
BASE_
@ BASE_
Definition: xcolor.h:54
get_color_state
Color_state get_color_state(Widget_t *wid)
get_color_state - get the Color_state to use in relation to the Widget_t state
Definition: xcolor.c:155
FORGROUND_
@ FORGROUND_
Definition: xcolor.h:52
use_shadow_color_scheme
void use_shadow_color_scheme(Widget_t *w, Color_state st)
use_shadow_color_scheme - use shadow Colors to paint on Widget_t
Definition: xcolor.c:206
use_light_color_scheme
void use_light_color_scheme(Widget_t *w, Color_state st)
use_light_color_scheme - use light Colors to paint on Widget_t
Definition: xcolor.c:220
XColor_t::insensitive
Colors insensitive
Definition: xcolor.h:93
XColor_t
XColor_t - the Widget_t Color struct XColor_t could be used for theming you Widget_t set.
Definition: xcolor.h:88
use_fg_color_scheme
void use_fg_color_scheme(Widget_t *w, Color_state st)
use_fg_color_scheme - use forground Colors to paint on Widget_t
Definition: xcolor.c:178
xputty.h
use_bg_color_scheme
void use_bg_color_scheme(Widget_t *w, Color_state st)
use_bg_color_scheme - use background Colors to paint on Widget_t
Definition: xcolor.c:185
BACKGROUND_
@ BACKGROUND_
Definition: xcolor.h:53
TEXT_
@ TEXT_
Definition: xcolor.h:55
XColor_t::prelight
Colors prelight
Definition: xcolor.h:90
LIGHT_
@ LIGHT_
Definition: xcolor.h:58
set_light_theme
void set_light_theme(Xputty *main)
set_light_theme - init the XColor_t struct to the default light theme
Definition: xcolor.c:77
use_frame_color_scheme
void use_frame_color_scheme(Widget_t *w, Color_state st)
use_frame_color_scheme - use frame Colors to paint on Widget_t
Definition: xcolor.c:213
Colors
Color_t - struct used to set cairo color for Widget_t.
Definition: xcolor.h:73
ACTIVE_
@ ACTIVE_
Definition: xcolor.h:42
XColor_t::selected
Colors selected
Definition: xcolor.h:91
Widget_t
Widget_t - struct to hold the basic Widget_t info.
Definition: xwidget.h:298
NORMAL_
@ NORMAL_
Definition: xcolor.h:39
PRELIGHT_
@ PRELIGHT_
Definition: xcolor.h:40
set_pattern
void set_pattern(Widget_t *w, Colors *from, Colors *to, Color_mod mod)
set_pattern - set pattern for the selected Colors
Definition: xcolor.c:227
Color_mod
Color_mod
Color_set - select color set to use on draw.
Definition: xcolor.h:51
get_color_scheme
Colors * get_color_scheme(Xputty *main, Color_state st)
get_color_scheme - get pointer to the Colors struct to use in relation to the Color_state
Definition: xcolor.c:130
use_base_color_scheme
void use_base_color_scheme(Widget_t *w, Color_state st)
use_base_color_scheme - use base Colors to paint on Widget_t
Definition: xcolor.c:192
SELECTED_
@ SELECTED_
Definition: xcolor.h:41
Color_state
Color_state
Color_state - select color mode to use on Widget_t.
Definition: xcolor.h:38
XColor_t::normal
Colors normal
Definition: xcolor.h:89