summaryrefslogtreecommitdiff
path: root/src/ui/labelwidget.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-08-16 16:15:30 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-08-16 16:15:30 +0300
commit027d8185b10632092508bfda62467d24c9f8655b (patch)
tree03b0bf1edb9f2f284afde1679e24ac390b2f201d /src/ui/labelwidget.c
parentb10087331ff28acbc368361ba14dba3a70b7dc90 (diff)
Palette has UI colors; defined Light theme colors
Diffstat (limited to 'src/ui/labelwidget.c')
-rw-r--r--src/ui/labelwidget.c99
1 files changed, 59 insertions, 40 deletions
diff --git a/src/ui/labelwidget.c b/src/ui/labelwidget.c
index 0c9269d1..62eb9853 100644
--- a/src/ui/labelwidget.c
+++ b/src/ui/labelwidget.c
@@ -122,60 +122,79 @@ static void keyStr_LabelWidget_(const iLabelWidget *d, iString *str) {
122 } 122 }
123} 123}
124 124
125static void draw_LabelWidget_(const iLabelWidget *d) { 125static void getColors_LabelWidget_(const iLabelWidget *d, int *bg, int *fg, int *frame1, int *frame2) {
126 const iWidget *w = constAs_Widget(d); 126 const iWidget *w = constAs_Widget(d);
127 draw_Widget(w); 127 const iBool isPress = (flags_Widget(w) & pressed_WidgetFlag) != 0;
128 const iBool isButton = d->click.button != 0; 128 const iBool isSel = (flags_Widget(w) & selected_WidgetFlag) != 0;
129 const int flags = flags_Widget(w); 129 const iBool isFrameless = (flags_Widget(w) & frameless_WidgetFlag) != 0;
130 const iRect bounds = bounds_Widget(w); 130 const iBool isButton = d->click.button != 0;
131 iRect rect = bounds; 131 /* Default color state. */
132 if (isButton) { 132 *bg = isButton ? uiBackground_ColorId : none_ColorId;
133 shrink_Rect(&rect, divi_I2(gap2_UI, 4)); 133 *fg = uiText_ColorId;
134 adjustEdges_Rect(&rect, gap_UI / 8, 0, -gap_UI / 8, 0); 134 *frame1 = isButton ? uiEmboss1_ColorId : uiFrame_ColorId;
135 } 135 *frame2 = isButton ? uiEmboss2_ColorId : *frame1;
136 iPaint p; 136 if (isSel) {
137 init_Paint(&p); 137 *bg = uiBackgroundSelected_ColorId;
138 int bg = 0; 138 *fg = uiTextSelected_ColorId;
139 int fg = gray75_ColorId; 139 if (isButton) {
140 int frame = isButton ? gray50_ColorId : gray25_ColorId; 140 *frame1 = uiEmbossSelected1_ColorId;
141 int frame2 = isButton ? black_ColorId : frame; 141 *frame2 = uiEmbossSelected2_ColorId;
142 if (flags & selected_WidgetFlag) { 142 }
143 bg = teal_ColorId;
144 fg = white_ColorId;
145 frame = isButton ? cyan_ColorId : frame;
146 } 143 }
147 if (isHover_Widget(w)) { 144 if (isHover_Widget(w)) {
148 if (flags & frameless_WidgetFlag) { 145 if (isFrameless) {
149 bg = teal_ColorId; 146 *bg = uiBackgroundFramelessHover_ColorId;
150 fg = white_ColorId; 147 *fg = uiTextFramelessHover_ColorId;
151 if (isButton && flags & selected_WidgetFlag) frame = white_ColorId;
152 } 148 }
153 else { 149 else {
154 if (frame != cyan_ColorId) { 150 /* Frames matching color escaped text. */
155 if (startsWith_String(&d->label, orange_ColorEscape)) { 151 if (startsWith_String(&d->label, "\r")) {
156 frame = orange_ColorId; 152 if (colorTheme_App() == dark_ColorTheme) {
157 frame2 = brown_ColorId; 153 *frame1 = cstr_String(&d->label)[1] - '0';
154 *frame2 = darker_Color(*frame1);
158 } 155 }
159 else { 156 else {
160 frame = cyan_ColorId; 157 *bg = *frame1 = *frame2 = cstr_String(&d->label)[1] - '0';
161 frame2 = teal_ColorId; 158 *fg = uiBackground_ColorId | permanent_ColorId;
162 } 159 }
163 } 160 }
161 else if (isSel) {
162 *frame1 = uiEmbossSelectedHover1_ColorId;
163 *frame2 = uiEmbossSelectedHover2_ColorId;
164 }
164 else { 165 else {
165 frame = white_ColorId; 166 if (isButton) *bg = uiBackgroundHover_ColorId;
166 frame2 = cyan_ColorId; 167 *frame1 = uiEmbossHover1_ColorId;
168 *frame2 = uiEmbossHover2_ColorId;
167 } 169 }
168 } 170 }
169 } 171 }
170 if (flags & pressed_WidgetFlag) { 172 if (isPress) {
171 bg = orange_ColorId | permanent_ColorId; 173 *bg = uiBackgroundPressed_ColorId | permanent_ColorId;
172 if (isButton) { 174 if (isButton) {
173 frame = brown_ColorId; 175 *frame1 = uiEmbossPressed1_ColorId;
174 frame2 = white_ColorId; 176 *frame2 = uiEmbossPressed2_ColorId;
175 } 177 }
176 fg = black_ColorId | permanent_ColorId; 178 *fg = uiTextPressed_ColorId | permanent_ColorId;
177 } 179 }
178 if (bg) { 180}
181
182static void draw_LabelWidget_(const iLabelWidget *d) {
183 const iWidget *w = constAs_Widget(d);
184 draw_Widget(w);
185 const iBool isButton = d->click.button != 0;
186 const int flags = flags_Widget(w);
187 const iRect bounds = bounds_Widget(w);
188 iRect rect = bounds;
189 if (isButton) {
190 shrink_Rect(&rect, divi_I2(gap2_UI, 4));
191 adjustEdges_Rect(&rect, gap_UI / 8, 0, -gap_UI / 8, 0);
192 }
193 iPaint p;
194 init_Paint(&p);
195 int bg, fg, frame, frame2;
196 getColors_LabelWidget_(d, &bg, &fg, &frame, &frame2);
197 if (bg >= 0) {
179 fillRect_Paint(&p, rect, bg); 198 fillRect_Paint(&p, rect, bg);
180 } 199 }
181 if (~flags & frameless_WidgetFlag) { 200 if (~flags & frameless_WidgetFlag) {
@@ -201,7 +220,7 @@ static void draw_LabelWidget_(const iLabelWidget *d) {
201 keyStr_LabelWidget_(d, &str); 220 keyStr_LabelWidget_(d, &str);
202 drawAlign_Text(uiShortcuts_FontId, 221 drawAlign_Text(uiShortcuts_FontId,
203 add_I2(topRight_Rect(bounds), negX_I2(padding_(flags))), 222 add_I2(topRight_Rect(bounds), negX_I2(padding_(flags))),
204 flags & pressed_WidgetFlag ? fg : cyan_ColorId, 223 flags & pressed_WidgetFlag ? fg : uiTextShortcut_ColorId,
205 right_Alignment, 224 right_Alignment,
206 cstr_String(&str)); 225 cstr_String(&str));
207 deinit_String(&str); 226 deinit_String(&str);