summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ui/inputwidget.c17
-rw-r--r--src/ui/inputwidget.h2
-rw-r--r--src/ui/uploadwidget.c19
3 files changed, 34 insertions, 4 deletions
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index 2ca9bd55..6246078e 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -709,10 +709,19 @@ void setMaxLen_InputWidget(iInputWidget *d, size_t maxLen) {
709} 709}
710 710
711void setLineLimits_InputWidget(iInputWidget *d, int minLines, int maxLines) { 711void setLineLimits_InputWidget(iInputWidget *d, int minLines, int maxLines) {
712 d->minWrapLines = minLines; 712 if (d->minWrapLines != minLines || d->maxWrapLines != maxLines) {
713 d->maxWrapLines = maxLines; 713 d->minWrapLines = minLines;
714 updateVisible_InputWidget_(d); 714 d->maxWrapLines = maxLines;
715 updateMetrics_InputWidget_(d); 715 updateVisible_InputWidget_(d);
716 updateMetrics_InputWidget_(d);
717 }
718}
719
720int minLines_InputWidget(const iInputWidget *d) {
721 return d->minWrapLines;
722}
723int maxLines_InputWidget(const iInputWidget *d) {
724 return d->maxWrapLines;
716} 725}
717 726
718void setValidator_InputWidget(iInputWidget *d, iInputWidgetValidatorFunc validator, void *context) { 727void setValidator_InputWidget(iInputWidget *d, iInputWidgetValidatorFunc validator, void *context) {
diff --git a/src/ui/inputwidget.h b/src/ui/inputwidget.h
index 959eb334..a94291ed 100644
--- a/src/ui/inputwidget.h
+++ b/src/ui/inputwidget.h
@@ -63,6 +63,8 @@ void setUrlContent_InputWidget (iInputWidget *, iBool isUrl);
63void setNotifyEdits_InputWidget (iInputWidget *, iBool notifyEdits); 63void setNotifyEdits_InputWidget (iInputWidget *, iBool notifyEdits);
64void setEatEscape_InputWidget (iInputWidget *, iBool eatEscape); 64void setEatEscape_InputWidget (iInputWidget *, iBool eatEscape);
65 65
66int minLines_InputWidget (const iInputWidget *);
67int maxLines_InputWidget (const iInputWidget *);
66iInputWidgetContentPadding contentPadding_InputWidget (const iInputWidget *); 68iInputWidgetContentPadding contentPadding_InputWidget (const iInputWidget *);
67const iString * text_InputWidget (const iInputWidget *); 69const iString * text_InputWidget (const iInputWidget *);
68 70
diff --git a/src/ui/uploadwidget.c b/src/ui/uploadwidget.c
index 7dd26e93..7f2a68bf 100644
--- a/src/ui/uploadwidget.c
+++ b/src/ui/uploadwidget.c
@@ -24,6 +24,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
24#include "labelwidget.h" 24#include "labelwidget.h"
25#include "inputwidget.h" 25#include "inputwidget.h"
26#include "documentwidget.h" 26#include "documentwidget.h"
27#include "root.h"
27#include "color.h" 28#include "color.h"
28#include "command.h" 29#include "command.h"
29#include "gmrequest.h" 30#include "gmrequest.h"
@@ -62,6 +63,20 @@ static void updateProgress_UploadWidget_(iGmRequest *request, size_t current, si
62 total); 63 total);
63} 64}
64 65
66static void updateInputMaxHeight_UploadWidget_(iUploadWidget *d) {
67 iWidget *w = as_Widget(d);
68 /* Calculate how many lines fits vertically in the view. */
69 const iInt2 inputPos = topLeft_Rect(bounds_Widget(as_Widget(d->input)));
70 const int footerHeight = height_Widget(d->token) +
71 height_Widget(findChild_Widget(w, "dialogbuttons")) +
72 6 * gap_UI;
73 const int avail = bottom_Rect(safeRect_Root(w->root)) - footerHeight;
74 setLineLimits_InputWidget(d->input,
75 minLines_InputWidget(d->input),
76 iMaxi(minLines_InputWidget(d->input),
77 (avail - inputPos.y) / lineHeight_Text(monospace_FontId)));
78}
79
65void init_UploadWidget(iUploadWidget *d) { 80void init_UploadWidget(iUploadWidget *d) {
66 iWidget *w = as_Widget(d); 81 iWidget *w = as_Widget(d);
67 init_Widget(w); 82 init_Widget(w);
@@ -152,6 +167,7 @@ void init_UploadWidget(iUploadWidget *d) {
152 setFlags_Widget(as_Widget(d->token), expand_WidgetFlag, iTrue); 167 setFlags_Widget(as_Widget(d->token), expand_WidgetFlag, iTrue);
153 setFocus_Widget(as_Widget(d->input)); 168 setFocus_Widget(as_Widget(d->input));
154 setBackupFileName_InputWidget(d->input, "uploadbackup.txt"); 169 setBackupFileName_InputWidget(d->input, "uploadbackup.txt");
170 updateInputMaxHeight_UploadWidget_(d);
155} 171}
156 172
157void deinit_UploadWidget(iUploadWidget *d) { 173void deinit_UploadWidget(iUploadWidget *d) {
@@ -214,6 +230,9 @@ static void requestFinished_UploadWidget_(iUploadWidget *d, iGmRequest *req) {
214static iBool processEvent_UploadWidget_(iUploadWidget *d, const SDL_Event *ev) { 230static iBool processEvent_UploadWidget_(iUploadWidget *d, const SDL_Event *ev) {
215 iWidget *w = as_Widget(d); 231 iWidget *w = as_Widget(d);
216 const char *cmd = command_UserEvent(ev); 232 const char *cmd = command_UserEvent(ev);
233 if (isResize_UserEvent(ev)) {
234 updateInputMaxHeight_UploadWidget_(d);
235 }
217 if (isCommand_Widget(w, ev, "upload.cancel")) { 236 if (isCommand_Widget(w, ev, "upload.cancel")) {
218 setupSheetTransition_Mobile(w, iFalse); 237 setupSheetTransition_Mobile(w, iFalse);
219 destroy_Widget(w); 238 destroy_Widget(w);