summaryrefslogtreecommitdiff
path: root/src/ui/inputwidget.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-08-02 17:56:02 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-08-02 17:56:02 +0300
commitf3d083d3f150c1e940c4086f39165fb55935344a (patch)
treed5d65702d4b80112095859e61635a95801c2d5c0 /src/ui/inputwidget.c
parenta346dd6450b9c6636110d1c882d28ca4dc82573d (diff)
Flag for tight label padding; aligning labels visually
Diffstat (limited to 'src/ui/inputwidget.c')
-rw-r--r--src/ui/inputwidget.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index de633e3c..bfb71913 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -291,12 +291,13 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) {
291static const iChar sensitiveChar_ = 0x25cf; /* black circle */ 291static const iChar sensitiveChar_ = 0x25cf; /* black circle */
292 292
293static void draw_InputWidget_(const iInputWidget *d) { 293static void draw_InputWidget_(const iInputWidget *d) {
294 const iWidget *w = constAs_Widget(d);
294 const uint32_t time = frameTime_Window(get_Window()); 295 const uint32_t time = frameTime_Window(get_Window());
295 const iInt2 padding = init_I2(gap_UI / 2, gap_UI / 2); 296 const iInt2 padding = init_I2(gap_UI / 2, gap_UI / 2);
296 iRect bounds = adjusted_Rect(bounds_Widget(constAs_Widget(d)), padding, neg_I2(padding)); 297 iRect bounds = adjusted_Rect(bounds_Widget(w), padding, neg_I2(padding));
297 const iBool isFocused = isFocused_Widget(constAs_Widget(d)); 298 const iBool isFocused = isFocused_Widget(w);
298 const iBool isHover = isHover_Widget(constAs_Widget(d)) && 299 const iBool isHover = isHover_Widget(w) &&
299 contains_Widget(constAs_Widget(d), mouseCoord_Window(get_Window())); 300 contains_Widget(w, mouseCoord_Window(get_Window()));
300 iPaint p; 301 iPaint p;
301 init_Paint(&p); 302 init_Paint(&p);
302 iString text; 303 iString text;
@@ -314,7 +315,7 @@ static void draw_InputWidget_(const iInputWidget *d) {
314 adjusted_Rect(bounds, neg_I2(one_I2()), zero_I2()), 315 adjusted_Rect(bounds, neg_I2(one_I2()), zero_I2()),
315 isFocused ? orange_ColorId : isHover ? cyan_ColorId : gray50_ColorId); 316 isFocused ? orange_ColorId : isHover ? cyan_ColorId : gray50_ColorId);
316 setClip_Paint(&p, bounds); 317 setClip_Paint(&p, bounds);
317 shrink_Rect(&bounds, init_I2(gap_UI * 2, 0)); 318 shrink_Rect(&bounds, init_I2(gap_UI * (flags_Widget(w) & tight_WidgetFlag ? 1 : 2), 0));
318 const iInt2 emSize = advance_Text(d->font, "M"); 319 const iInt2 emSize = advance_Text(d->font, "M");
319 const int textWidth = advance_Text(d->font, cstr_String(&text)).x; 320 const int textWidth = advance_Text(d->font, cstr_String(&text)).x;
320 const int cursorX = advanceN_Text(d->font, cstr_String(&text), d->cursor).x; 321 const int cursorX = advanceN_Text(d->font, cstr_String(&text), d->cursor).x;