summaryrefslogtreecommitdiff
path: root/src/ui/inputwidget.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/inputwidget.c')
-rw-r--r--src/ui/inputwidget.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index 784fabdd..05cd1cc3 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -148,6 +148,8 @@ iLocalDef iInt2 padding_(void) {
148 return init_I2(gap_UI / 2, gap_UI / 2); 148 return init_I2(gap_UI / 2, gap_UI / 2);
149} 149}
150 150
151#define extraPaddingHeight_ (1.25f * gap_UI)
152
151static iRect contentBounds_InputWidget_(const iInputWidget *d) { 153static iRect contentBounds_InputWidget_(const iInputWidget *d) {
152 const iWidget *w = constAs_Widget(d); 154 const iWidget *w = constAs_Widget(d);
153 // const iRect widgetBounds = bounds_Widget(w); 155 // const iRect widgetBounds = bounds_Widget(w);
@@ -157,7 +159,7 @@ static iRect contentBounds_InputWidget_(const iInputWidget *d) {
157 shrink_Rect(&bounds, init_I2(gap_UI * (flags_Widget(w) & tight_WidgetFlag ? 1 : 2), 0)); 159 shrink_Rect(&bounds, init_I2(gap_UI * (flags_Widget(w) & tight_WidgetFlag ? 1 : 2), 0));
158 bounds.pos.y += padding_().y / 2; 160 bounds.pos.y += padding_().y / 2;
159 if (flags_Widget(w) & extraPadding_WidgetFlag) { 161 if (flags_Widget(w) & extraPadding_WidgetFlag) {
160 bounds.pos.y += gap_UI; 162 bounds.pos.y += extraPaddingHeight_ / 2;
161 } 163 }
162 return bounds; 164 return bounds;
163} 165}
@@ -205,7 +207,7 @@ static void updateSizeForFixedLength_InputWidget_(iInputWidget *d) {
205 /* Set a fixed size based on maximum possible width of the text. */ 207 /* Set a fixed size based on maximum possible width of the text. */
206 iBlock *content = new_Block(d->maxLen); 208 iBlock *content = new_Block(d->maxLen);
207 fill_Block(content, 'M'); 209 fill_Block(content, 'M');
208 int extraHeight = (flags_Widget(as_Widget(d)) & extraPadding_WidgetFlag ? 2 * gap_UI : 0); 210 int extraHeight = (flags_Widget(as_Widget(d)) & extraPadding_WidgetFlag ? extraPaddingHeight_ : 0);
209 setFixedSize_Widget( 211 setFixedSize_Widget(
210 as_Widget(d), 212 as_Widget(d),
211 add_I2(measure_Text(d->font, cstr_Block(content)), 213 add_I2(measure_Text(d->font, cstr_Block(content)),
@@ -299,7 +301,7 @@ static int contentHeight_InputWidget_(const iInputWidget *d, iBool forLayout) {
299 if (forLayout) { 301 if (forLayout) {
300 numLines = iMin(numLines, d->maxLayoutLines); 302 numLines = iMin(numLines, d->maxLayoutLines);
301 } 303 }
302 return numLines * lineHeight_Text(d->font); 304 return (int) numLines * lineHeight_Text(d->font);
303} 305}
304 306
305static void updateMetrics_InputWidget_(iInputWidget *d) { 307static void updateMetrics_InputWidget_(iInputWidget *d) {
@@ -308,7 +310,7 @@ static void updateMetrics_InputWidget_(iInputWidget *d) {
308 /* Caller must arrange the width, but the height is fixed. */ 310 /* Caller must arrange the width, but the height is fixed. */
309 w->rect.size.y = contentHeight_InputWidget_(d, iTrue) + 3.0f * padding_().y; /* TODO: Why 3x? */ 311 w->rect.size.y = contentHeight_InputWidget_(d, iTrue) + 3.0f * padding_().y; /* TODO: Why 3x? */
310 if (flags_Widget(w) & extraPadding_WidgetFlag) { 312 if (flags_Widget(w) & extraPadding_WidgetFlag) {
311 w->rect.size.y += 2 * gap_UI; 313 w->rect.size.y += extraPaddingHeight_;
312 } 314 }
313 invalidateBuffered_InputWidget_(d); 315 invalidateBuffered_InputWidget_(d);
314 postCommand_Widget(d, "input.resized"); 316 postCommand_Widget(d, "input.resized");
@@ -960,7 +962,7 @@ static iRect bounds_InputWidget_(const iInputWidget *d) {
960 } 962 }
961 bounds.size.y = contentHeight_InputWidget_(d, iFalse) + 3 * padding_().y; 963 bounds.size.y = contentHeight_InputWidget_(d, iFalse) + 3 * padding_().y;
962 if (w->flags & extraPadding_WidgetFlag) { 964 if (w->flags & extraPadding_WidgetFlag) {
963 bounds.size.y += 2 * gap_UI; 965 bounds.size.y += extraPaddingHeight_;
964 } 966 }
965 return bounds; 967 return bounds;
966} 968}