summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-12-08 15:54:05 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-12-08 17:09:29 +0200
commit776d917183f179545dbed6888788a8e3c0e5a7a7 (patch)
tree3b12aa2b6eb8d63c0ad8718f78f6271229ff53fc /src/ui
parentddd7f1a32ca00533ef33583efdf457a572c1ea03 (diff)
iOS: Fixed text field position was shifting
The field was not tall enough, so it was scrolling slightly. Some of the changes in InputWidget may have been unnecessary.
Diffstat (limited to 'src/ui')
-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 1935826b..3bee3d21 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -722,18 +722,19 @@ static void updateAllLinesAndResizeHeight_InputWidget_(iInputWidget *d) {
722#endif 722#endif
723 723
724static int contentHeight_InputWidget_(const iInputWidget *d) { 724static int contentHeight_InputWidget_(const iInputWidget *d) {
725 const int lineHeight = lineHeight_Text(d->font);
725#if LAGRANGE_USE_SYSTEM_TEXT_INPUT 726#if LAGRANGE_USE_SYSTEM_TEXT_INPUT
726 const int minHeight = d->minWrapLines * lineHeight_Text(d->font); 727 const int minHeight = d->minWrapLines * lineHeight;
727 const int maxHeight = d->maxWrapLines * lineHeight_Text(d->font); 728 const int maxHeight = d->maxWrapLines * lineHeight;
728 if (d->sysCtrl) { 729 if (d->sysCtrl) {
729 const int preferred = preferredHeight_SystemTextInput(d->sysCtrl); 730 const int preferred = (preferredHeight_SystemTextInput(d->sysCtrl) + gap_UI) / lineHeight;
730 return iClamp(preferred, minHeight, maxHeight); 731 return iClamp(preferred * lineHeight, minHeight, maxHeight);
731 } 732 }
732 if (d->buffered && ~d->inFlags & needUpdateBuffer_InputWidgetFlag) { 733 if (d->buffered && ~d->inFlags & needUpdateBuffer_InputWidgetFlag) {
733 return iClamp(d->buffered->size.y, minHeight, maxHeight); 734 return iClamp(d->buffered->size.y, minHeight, maxHeight);
734 } 735 }
735#endif 736#endif
736 return size_Range(&d->visWrapLines) * lineHeight_Text(d->font); 737 return (int) size_Range(&d->visWrapLines) * lineHeight;
737} 738}
738 739
739static void updateTextInputRect_InputWidget_(const iInputWidget *d) { 740static void updateTextInputRect_InputWidget_(const iInputWidget *d) {
@@ -1178,6 +1179,7 @@ void begin_InputWidget(iInputWidget *d) {
1178 setText_SystemTextInput(d->sysCtrl, &d->oldText); 1179 setText_SystemTextInput(d->sysCtrl, &d->oldText);
1179 setTextChangedFunc_SystemTextInput(d->sysCtrl, systemInputChanged_InputWidget_, d); 1180 setTextChangedFunc_SystemTextInput(d->sysCtrl, systemInputChanged_InputWidget_, d);
1180 iConnect(Root, w->root, visualOffsetsChanged, d, updateAfterVisualOffsetChange_InputWidget_); 1181 iConnect(Root, w->root, visualOffsetsChanged, d, updateAfterVisualOffsetChange_InputWidget_);
1182 updateTextInputRect_InputWidget_(d);
1181 updateMetrics_InputWidget_(d); 1183 updateMetrics_InputWidget_(d);
1182#else 1184#else
1183 mergeLines_(&d->lines, &d->oldText); 1185 mergeLines_(&d->lines, &d->oldText);