summaryrefslogtreecommitdiff
path: root/src/ui/uploadwidget.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-09-14 13:45:35 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-09-14 13:45:35 +0300
commitabbd44dbc29bed6044830b946f7d8ccc7d0dbfa5 (patch)
treeb9359304e76abe3311b20dc05fd673f77a9eebc7 /src/ui/uploadwidget.c
parent8fcd270e6e74d3b8099c2f7f86d803def9070eb9 (diff)
UploadWidget: Mobile fixes
Diffstat (limited to 'src/ui/uploadwidget.c')
-rw-r--r--src/ui/uploadwidget.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/ui/uploadwidget.c b/src/ui/uploadwidget.c
index 78a1196a..c3f71ab9 100644
--- a/src/ui/uploadwidget.c
+++ b/src/ui/uploadwidget.c
@@ -29,6 +29,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29#include "command.h" 29#include "command.h"
30#include "gmrequest.h" 30#include "gmrequest.h"
31#include "sitespec.h" 31#include "sitespec.h"
32#include "window.h"
32#include "app.h" 33#include "app.h"
33 34
34#include <the_Foundation/file.h> 35#include <the_Foundation/file.h>
@@ -67,14 +68,16 @@ static void updateInputMaxHeight_UploadWidget_(iUploadWidget *d) {
67 iWidget *w = as_Widget(d); 68 iWidget *w = as_Widget(d);
68 /* Calculate how many lines fits vertically in the view. */ 69 /* Calculate how many lines fits vertically in the view. */
69 const iInt2 inputPos = topLeft_Rect(bounds_Widget(as_Widget(d->input))); 70 const iInt2 inputPos = topLeft_Rect(bounds_Widget(as_Widget(d->input)));
70 const int footerHeight = height_Widget(d->token) + 71 const int footerHeight = isUsingPanelLayout_Mobile() ? 0 :
71 height_Widget(findChild_Widget(w, "dialogbuttons")) + 72 (height_Widget(d->token) +
72 6 * gap_UI; 73 height_Widget(findChild_Widget(w, "dialogbuttons")) +
73 const int avail = bottom_Rect(safeRect_Root(w->root)) - footerHeight; 74 6 * gap_UI);
75 const int avail = bottom_Rect(safeRect_Root(w->root)) - footerHeight -
76 get_Window()->keyboardHeight;
74 setLineLimits_InputWidget(d->input, 77 setLineLimits_InputWidget(d->input,
75 minLines_InputWidget(d->input), 78 minLines_InputWidget(d->input),
76 iMaxi(minLines_InputWidget(d->input), 79 iMaxi(minLines_InputWidget(d->input),
77 (avail - inputPos.y) / lineHeight_Text(monospace_FontId))); 80 (avail - inputPos.y) / lineHeight_Text(font_InputWidget(d->input))));
78} 81}
79 82
80void init_UploadWidget(iUploadWidget *d) { 83void init_UploadWidget(iUploadWidget *d) {
@@ -103,9 +106,9 @@ void init_UploadWidget(iUploadWidget *d) {
103 { "title id:heading.upload.file" }, 106 { "title id:heading.upload.file" },
104 { "button text:" uiTextAction_ColorEscape "${dlg.upload.pickfile}", 0, 0, "upload.pickfile" }, 107 { "button text:" uiTextAction_ColorEscape "${dlg.upload.pickfile}", 0, 0, "upload.pickfile" },
105 { "heading id:upload.file.name" }, 108 { "heading id:upload.file.name" },
106 { "label id:upload.filepathlabel" }, 109 { "label id:upload.filepathlabel text:\u2014" },
107 { "heading id:upload.file.size" }, 110 { "heading id:upload.file.size" },
108 { "label id:upload.filesizelabel" }, 111 { "label id:upload.filesizelabel text:\u2014" },
109 { "padding" }, 112 { "padding" },
110 { "input id:upload.mime" }, 113 { "input id:upload.mime" },
111 { "label id:upload.counter text:" }, 114 { "label id:upload.counter text:" },
@@ -131,6 +134,7 @@ void init_UploadWidget(iUploadWidget *d) {
131 } 134 }
132 else { 135 else {
133 useSheetStyle_Widget(w); 136 useSheetStyle_Widget(w);
137 setFlags_Widget(w, overflowScrollable_WidgetFlag, iFalse);
134 addChildFlags_Widget(w, 138 addChildFlags_Widget(w,
135 iClob(new_LabelWidget(uiHeading_ColorEscape "${heading.upload}", NULL)), 139 iClob(new_LabelWidget(uiHeading_ColorEscape "${heading.upload}", NULL)),
136 frameless_WidgetFlag); 140 frameless_WidgetFlag);
@@ -193,7 +197,7 @@ void init_UploadWidget(iUploadWidget *d) {
193 setFlags_Widget(as_Widget(d->token), expand_WidgetFlag, iTrue); 197 setFlags_Widget(as_Widget(d->token), expand_WidgetFlag, iTrue);
194 setFocus_Widget(as_Widget(d->input)); 198 setFocus_Widget(as_Widget(d->input));
195 } 199 }
196 setFont_InputWidget(d->input, monospace_FontId); 200 setFont_InputWidget(d->input, iosevka_FontId);
197 setUseReturnKeyBehavior_InputWidget(d->input, iFalse); /* traditional text editor */ 201 setUseReturnKeyBehavior_InputWidget(d->input, iFalse); /* traditional text editor */
198 setLineLimits_InputWidget(d->input, 7, 20); 202 setLineLimits_InputWidget(d->input, 7, 20);
199 setHint_InputWidget(d->input, "${hint.upload.text}"); 203 setHint_InputWidget(d->input, "${hint.upload.text}");
@@ -262,7 +266,7 @@ static void requestFinished_UploadWidget_(iUploadWidget *d, iGmRequest *req) {
262static iBool processEvent_UploadWidget_(iUploadWidget *d, const SDL_Event *ev) { 266static iBool processEvent_UploadWidget_(iUploadWidget *d, const SDL_Event *ev) {
263 iWidget *w = as_Widget(d); 267 iWidget *w = as_Widget(d);
264 const char *cmd = command_UserEvent(ev); 268 const char *cmd = command_UserEvent(ev);
265 if (isResize_UserEvent(ev)) { 269 if (isResize_UserEvent(ev) || equal_Command(cmd, "keyboard.changed")) {
266 updateInputMaxHeight_UploadWidget_(d); 270 updateInputMaxHeight_UploadWidget_(d);
267 } 271 }
268 if (equal_Command(cmd, "upload.cancel")) { 272 if (equal_Command(cmd, "upload.cancel")) {