From 78092e44e6ba554c6ed31df5bfa3d7c38d2341d2 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Tue, 23 Feb 2021 11:48:06 +0200 Subject: Show a search indicator in the URL bar Indicate to user when entered text will be user for a search engine query. IssueID #157 --- src/ui/inputwidget.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/ui/inputwidget.c') diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c index 25c3e145..58a47610 100644 --- a/src/ui/inputwidget.c +++ b/src/ui/inputwidget.c @@ -81,6 +81,8 @@ struct Impl_InputWidget { iArray text; /* iChar[] */ iArray oldText; /* iChar[] */ iString hint; + int leftPadding; + int rightPadding; size_t cursor; size_t lastCursor; iRanges mark; @@ -114,6 +116,8 @@ void init_InputWidget(iInputWidget *d, size_t maxLen) { init_String(&d->hint); init_Array(&d->undoStack, sizeof(iInputUndo)); d->font = uiInput_FontId | alwaysVariableFlag_FontId; + d->leftPadding = 0; + d->rightPadding = 0; d->cursor = 0; d->lastCursor = 0; d->inFlags = eatEscape_InputWidgetFlag; @@ -196,6 +200,12 @@ void setHint_InputWidget(iInputWidget *d, const char *hintText) { setCStr_String(&d->hint, hintText); } +void setContentPadding_InputWidget(iInputWidget *d, int left, int right) { + d->leftPadding = left; + d->rightPadding = right; + refresh_Widget(d); +} + static const iChar sensitiveChar_ = 0x25cf; /* black circle */ static iString *visText_InputWidget_(const iInputWidget *d) { @@ -488,7 +498,9 @@ iLocalDef iInt2 padding_(void) { static iInt2 textOrigin_InputWidget_(const iInputWidget *d, const char *visText) { const iWidget *w = constAs_Widget(d); - iRect bounds = adjusted_Rect(bounds_Widget(w), padding_(), neg_I2(padding_())); + iRect bounds = adjusted_Rect(bounds_Widget(w), + addX_I2(padding_(), d->leftPadding), + neg_I2(addX_I2(padding_(), d->rightPadding))); const iInt2 emSize = advance_Text(d->font, "M"); const int textWidth = advance_Text(d->font, visText).x; const int cursorX = advanceN_Text(d->font, visText, d->cursor).x; -- cgit v1.2.3