summaryrefslogtreecommitdiff
path: root/src/ui/inputwidget.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/inputwidget.c
parentb10087331ff28acbc368361ba14dba3a70b7dc90 (diff)
Palette has UI colors; defined Light theme colors
Diffstat (limited to 'src/ui/inputwidget.c')
-rw-r--r--src/ui/inputwidget.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index 305b8c9b..66e2af0a 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -1,6 +1,7 @@
1#include "inputwidget.h" 1#include "inputwidget.h"
2#include "paint.h" 2#include "paint.h"
3#include "util.h" 3#include "util.h"
4#include "app.h"
4 5
5#include <the_Foundation/array.h> 6#include <the_Foundation/array.h>
6#include <SDL_clipboard.h> 7#include <SDL_clipboard.h>
@@ -291,13 +292,13 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) {
291static const iChar sensitiveChar_ = 0x25cf; /* black circle */ 292static const iChar sensitiveChar_ = 0x25cf; /* black circle */
292 293
293static void draw_InputWidget_(const iInputWidget *d) { 294static void draw_InputWidget_(const iInputWidget *d) {
294 const iWidget *w = constAs_Widget(d); 295 const iWidget *w = constAs_Widget(d);
295 const uint32_t time = frameTime_Window(get_Window()); 296 const uint32_t time = frameTime_Window(get_Window());
296 const iInt2 padding = init_I2(gap_UI / 2, gap_UI / 2); 297 const iInt2 padding = init_I2(gap_UI / 2, gap_UI / 2);
297 iRect bounds = adjusted_Rect(bounds_Widget(w), padding, neg_I2(padding)); 298 iRect bounds = adjusted_Rect(bounds_Widget(w), padding, neg_I2(padding));
298 const iBool isFocused = isFocused_Widget(w); 299 const iBool isFocused = isFocused_Widget(w);
299 const iBool isHover = isHover_Widget(w) && 300 const iBool isHover = isHover_Widget(w) &&
300 contains_Widget(w, mouseCoord_Window(get_Window())); 301 contains_Widget(w, mouseCoord_Window(get_Window()));
301 iPaint p; 302 iPaint p;
302 init_Paint(&p); 303 init_Paint(&p);
303 iString text; 304 iString text;
@@ -310,10 +311,13 @@ static void draw_InputWidget_(const iInputWidget *d) {
310 appendChar_String(&text, sensitiveChar_); 311 appendChar_String(&text, sensitiveChar_);
311 } 312 }
312 } 313 }
313 fillRect_Paint(&p, bounds, black_ColorId); 314 fillRect_Paint(
314 drawRect_Paint(&p, 315 &p, bounds, isFocused ? uiInputBackgroundFocused_ColorId : uiInputBackground_ColorId);
315 adjusted_Rect(bounds, neg_I2(one_I2()), zero_I2()), 316 drawRectThickness_Paint(&p,
316 isFocused ? orange_ColorId : isHover ? cyan_ColorId : gray50_ColorId); 317 adjusted_Rect(bounds, neg_I2(one_I2()), zero_I2()),
318 isFocused ? gap_UI / 4 : 1,
319 isFocused ? uiInputFrameFocused_ColorId
320 : isHover ? uiInputFrameHover_ColorId : uiInputFrame_ColorId);
317 setClip_Paint(&p, bounds); 321 setClip_Paint(&p, bounds);
318 shrink_Rect(&bounds, init_I2(gap_UI * (flags_Widget(w) & tight_WidgetFlag ? 1 : 2), 0)); 322 shrink_Rect(&bounds, init_I2(gap_UI * (flags_Widget(w) & tight_WidgetFlag ? 1 : 2), 0));
319 const iInt2 emSize = advance_Text(d->font, "M"); 323 const iInt2 emSize = advance_Text(d->font, "M");
@@ -332,7 +336,7 @@ static void draw_InputWidget_(const iInputWidget *d) {
332 const int yOff = (height_Rect(bounds) - lineHeight_Text(d->font)) / 2; 336 const int yOff = (height_Rect(bounds) - lineHeight_Text(d->font)) / 2;
333 draw_Text(d->font, 337 draw_Text(d->font,
334 add_I2(topLeft_Rect(bounds), init_I2(xOff, yOff)), 338 add_I2(topLeft_Rect(bounds), init_I2(xOff, yOff)),
335 white_ColorId, 339 isFocused ? uiInputTextFocused_ColorId : uiInputText_ColorId,
336 "%s", 340 "%s",
337 cstr_String(&text)); 341 cstr_String(&text));
338 unsetClip_Paint(&p); 342 unsetClip_Paint(&p);
@@ -354,8 +358,8 @@ static void draw_InputWidget_(const iInputWidget *d) {
354 else { 358 else {
355 initCStr_String(&cur, " "); 359 initCStr_String(&cur, " ");
356 } 360 }
357 fillRect_Paint(&p, curRect, orange_ColorId); 361 fillRect_Paint(&p, curRect, uiInputCursor_ColorId);
358 draw_Text(d->font, curPos, black_ColorId, cstr_String(&cur)); 362 draw_Text(d->font, curPos, uiInputCursorText_ColorId, cstr_String(&cur));
359 deinit_String(&cur); 363 deinit_String(&cur);
360 } 364 }
361 deinit_String(&text); 365 deinit_String(&text);