summaryrefslogtreecommitdiff
path: root/src/ui/color.h
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-08-05 10:44:52 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-08-05 10:44:52 +0300
commitddb3dd5c4278f4ecfbd76351cb1651581dd9ec49 (patch)
tree316839d72f77e7e0e50b8ff2cb7ddfb3070a9c76 /src/ui/color.h
parent84909b4deba7ed90eed591cefe457be482628ecf (diff)
Color: Added HSL conversions
Removed the extra 15/88 grays from the UI palette.
Diffstat (limited to 'src/ui/color.h')
-rw-r--r--src/ui/color.h79
1 files changed, 61 insertions, 18 deletions
diff --git a/src/ui/color.h b/src/ui/color.h
index 01e49c9c..11feb63e 100644
--- a/src/ui/color.h
+++ b/src/ui/color.h
@@ -1,15 +1,14 @@
1#pragma once 1#pragma once
2 2
3#include <the_Foundation/range.h> 3#include <the_Foundation/range.h>
4#include <the_Foundation/math.h>
4 5
5enum iColorId { 6enum iColorId {
6 none_ColorId = -1, 7 none_ColorId = -1,
7 black_ColorId, 8 black_ColorId,
8 gray15_ColorId,
9 gray25_ColorId, 9 gray25_ColorId,
10 gray50_ColorId, 10 gray50_ColorId,
11 gray75_ColorId, 11 gray75_ColorId,
12 gray88_ColorId,
13 white_ColorId, 12 white_ColorId,
14 brown_ColorId, 13 brown_ColorId,
15 orange_ColorId, 14 orange_ColorId,
@@ -20,35 +19,79 @@ enum iColorId {
20 magenta_ColorId, 19 magenta_ColorId,
21 blue_ColorId, 20 blue_ColorId,
22 green_ColorId, 21 green_ColorId,
22 /* content theme colors */
23 tmFirst_ColorId,
24 tmBackground_ColorId = tmFirst_ColorId,
25 tmParagraph_ColorId,
26 tmFirstParagraph_ColorId,
27 tmQuote_ColorId,
28 tmPreformatted_ColorId,
29 tmHeader1_ColorId,
30 tmHeader2_ColorId,
31 tmHeader3_ColorId,
32
33 tmLinkIcon_ColorId,
34 tmLinkIconVisited_ColorId,
35 tmLinkText_ColorId,
36 tmLinkTextHover_ColorId,
37 tmLinkDomain_ColorId,
38 tmLinkLastVisitDate_ColorId,
39
40 tmHypertextLinkIcon_ColorId,
41 tmHypertextLinkIconVisited_ColorId,
42 tmHypertextLinkText_ColorId,
43 tmHypertextLinkTextHover_ColorId,
44 tmHypertextLinkDomain_ColorId,
45 tmHypertextLinkLastVisitDate_ColorId,
46
47 tmGopherLinkIcon_ColorId,
48 tmGopherLinkIconVisited_ColorId,
49 tmGopherLinkText_ColorId,
50 tmGopherLinkTextHover_ColorId,
51 tmGopherLinkDomain_ColorId,
52 tmGopherLinkLastVisitDate_ColorId,
53
54 tmInlineContentMetadata_ColorId,
55 tmBannerBackground_ColorId,
56 tmBannerTitle_ColorId,
57 tmBannerIcon_ColorId,
23 max_ColorId 58 max_ColorId
24}; 59};
25 60
26#define mask_ColorId 0x0f 61#define mask_ColorId 0x3f
27#define permanent_ColorId 0x80 /* cannot be changed via escapes */ 62#define permanent_ColorId 0x80 /* cannot be changed via escapes */
28 63
29#define black_ColorEscape "\r0" 64#define black_ColorEscape "\r0"
30#define gray15_ColorEscape "\r1" 65#define gray25_ColorEscape "\r1"
31#define gray25_ColorEscape "\r2" 66#define gray50_ColorEscape "\r2"
32#define gray50_ColorEscape "\r3" 67#define gray75_ColorEscape "\r3"
33#define gray75_ColorEscape "\r4" 68#define white_ColorEscape "\r4"
34#define gray88_ColorEscape "\r5" 69#define brown_ColorEscape "\r5"
35#define white_ColorEscape "\r6" 70#define orange_ColorEscape "\r6"
36#define brown_ColorEscape "\r7" 71#define teal_ColorEscape "\r7"
37#define orange_ColorEscape "\r8" 72#define cyan_ColorEscape "\r8"
38#define teal_ColorEscape "\r9" 73#define yellow_ColorEscape "\r9"
39#define cyan_ColorEscape "\r:" 74#define red_ColorEscape "\r:"
40#define yellow_ColorEscape "\r;" 75#define magenta_ColorEscape "\r;"
41#define red_ColorEscape "\r<" 76#define blue_ColorEscape "\r<"
42#define magenta_ColorEscape "\r=" 77#define green_ColorEscape "\r="
43#define blue_ColorEscape "\r>"
44#define green_ColorEscape "\r?"
45 78
46iDeclareType(Color) 79iDeclareType(Color)
80iDeclareType(HSLColor)
47 81
48struct Impl_Color { 82struct Impl_Color {
49 uint8_t r, g, b, a; 83 uint8_t r, g, b, a;
50}; 84};
51 85
86struct Impl_HSLColor {
87 float hue, sat, lum, a;
88};
89
52iColor get_Color (int color); 90iColor get_Color (int color);
91void set_Color (int color, iColor rgba);
92
93iHSLColor hsl_Color (iColor rgba);
94iColor fromHsl_Color (iHSLColor hsl);
95
53iColor ansi_Color (iRangecc escapeSequence, int fallback); 96iColor ansi_Color (iRangecc escapeSequence, int fallback);
54const char * escape_Color (int color); 97const char * escape_Color (int color);