diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-12-09 21:26:33 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-12-09 21:26:33 +0200 |
commit | 343e12429ec6b7e41edcaf9c9b05f2bb9ccb4e7d (patch) | |
tree | f7c893f3f39b2e78ef419d6ff9cf3b090cecea9a /src | |
parent | 812b770e2f63fa2864b88de6d7a0dbe37abf026a (diff) |
UploadWidget: Improved layout; path editing
Diffstat (limited to 'src')
-rw-r--r-- | src/ui/root.c | 5 | ||||
-rw-r--r-- | src/ui/uploadwidget.c | 43 |
2 files changed, 38 insertions, 10 deletions
diff --git a/src/ui/root.c b/src/ui/root.c index 08e0eafd..97879422 100644 --- a/src/ui/root.c +++ b/src/ui/root.c | |||
@@ -824,6 +824,11 @@ static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) { | |||
824 | return iFalse; | 824 | return iFalse; |
825 | } | 825 | } |
826 | else if (equal_Command(cmd, "navigate.focus")) { | 826 | else if (equal_Command(cmd, "navigate.focus")) { |
827 | /* The upload dialog has its own path field. */ | ||
828 | if (findWidget_App("upload")) { | ||
829 | postCommand_App("focus.set id:upload.path"); | ||
830 | return iTrue; | ||
831 | } | ||
827 | iWidget *url = findChild_Widget(navBar, "url"); | 832 | iWidget *url = findChild_Widget(navBar, "url"); |
828 | if (focus_Widget() != url) { | 833 | if (focus_Widget() != url) { |
829 | setFocus_Widget(findChild_Widget(navBar, "url")); | 834 | setFocus_Widget(findChild_Widget(navBar, "url")); |
diff --git a/src/ui/uploadwidget.c b/src/ui/uploadwidget.c index 9e86741e..fc5cc190 100644 --- a/src/ui/uploadwidget.c +++ b/src/ui/uploadwidget.c | |||
@@ -228,11 +228,18 @@ void init_UploadWidget(iUploadWidget *d) { | |||
228 | iClob(new_LabelWidget(uiHeading_ColorEscape "${heading.upload}", NULL)), | 228 | iClob(new_LabelWidget(uiHeading_ColorEscape "${heading.upload}", NULL)), |
229 | frameless_WidgetFlag), | 229 | frameless_WidgetFlag), |
230 | iTrue); | 230 | iTrue); |
231 | d->info = addChildFlags_Widget(w, | 231 | iWidget *headings, *values; |
232 | iClob(new_LabelWidget("", NULL)), | 232 | /* URL path. */ { |
233 | frameless_WidgetFlag | resizeToParentWidth_WidgetFlag | | 233 | iWidget *page = makeTwoColumns_Widget(&headings, &values); |
234 | fixedHeight_WidgetFlag); | 234 | d->path = new_InputWidget(0); |
235 | setWrap_LabelWidget(d->info, iTrue); | 235 | addTwoColumnDialogInputField_Widget( |
236 | headings, values, "", "upload.path", iClob(d->path)); | ||
237 | d->info = (iLabelWidget *) lastChild_Widget(headings); | ||
238 | setFont_LabelWidget(d->info, uiContent_FontId); | ||
239 | setTextColor_LabelWidget(d->info, uiInputTextFocused_ColorId); | ||
240 | addChild_Widget(w, iClob(page)); | ||
241 | addChild_Widget(w, iClob(makePadding_Widget(gap_UI))); | ||
242 | } | ||
236 | /* Tabs for input data. */ | 243 | /* Tabs for input data. */ |
237 | iWidget *tabs = makeTabs_Widget(w); | 244 | iWidget *tabs = makeTabs_Widget(w); |
238 | /* Make the tabs support vertical expansion based on content. */ { | 245 | /* Make the tabs support vertical expansion based on content. */ { |
@@ -242,7 +249,6 @@ void init_UploadWidget(iUploadWidget *d) { | |||
242 | setFlags_Widget(tabPages, resizeHeightOfChildren_WidgetFlag, iFalse); | 249 | setFlags_Widget(tabPages, resizeHeightOfChildren_WidgetFlag, iFalse); |
243 | setFlags_Widget(tabPages, arrangeHeight_WidgetFlag, iTrue); | 250 | setFlags_Widget(tabPages, arrangeHeight_WidgetFlag, iTrue); |
244 | } | 251 | } |
245 | iWidget *headings, *values; | ||
246 | setBackgroundColor_Widget(findChild_Widget(tabs, "tabs.buttons"), uiBackgroundSidebar_ColorId); | 252 | setBackgroundColor_Widget(findChild_Widget(tabs, "tabs.buttons"), uiBackgroundSidebar_ColorId); |
247 | setId_Widget(tabs, "upload.tabs"); | 253 | setId_Widget(tabs, "upload.tabs"); |
248 | /* Text input. */ { | 254 | /* Text input. */ { |
@@ -255,7 +261,8 @@ void init_UploadWidget(iUploadWidget *d) { | |||
255 | appendFramelessTabPage_Widget(tabs, iClob(page), "${heading.upload.text}", '1', 0); | 261 | appendFramelessTabPage_Widget(tabs, iClob(page), "${heading.upload.text}", '1', 0); |
256 | } | 262 | } |
257 | /* File content. */ { | 263 | /* File content. */ { |
258 | appendTwoColumnTabPage_Widget(tabs, "${heading.upload.file}", '2', &headings, &values); | 264 | iWidget *page = appendTwoColumnTabPage_Widget(tabs, "${heading.upload.file}", '2', &headings, &values); |
265 | setBackgroundColor_Widget(page, uiBackgroundSidebar_ColorId); | ||
259 | addChildFlags_Widget(headings, iClob(new_LabelWidget("${upload.file.name}", NULL)), frameless_WidgetFlag); | 266 | addChildFlags_Widget(headings, iClob(new_LabelWidget("${upload.file.name}", NULL)), frameless_WidgetFlag); |
260 | d->filePathLabel = addChildFlags_Widget(values, iClob(new_LabelWidget(uiTextAction_ColorEscape "${upload.file.drophere}", NULL)), frameless_WidgetFlag); | 267 | d->filePathLabel = addChildFlags_Widget(values, iClob(new_LabelWidget(uiTextAction_ColorEscape "${upload.file.drophere}", NULL)), frameless_WidgetFlag); |
261 | addChildFlags_Widget(headings, iClob(new_LabelWidget("${upload.file.size}", NULL)), frameless_WidgetFlag); | 268 | addChildFlags_Widget(headings, iClob(new_LabelWidget("${upload.file.size}", NULL)), frameless_WidgetFlag); |
@@ -295,6 +302,9 @@ void init_UploadWidget(iUploadWidget *d) { | |||
295 | } | 302 | } |
296 | resizeToLargestPage_Widget(tabs); | 303 | resizeToLargestPage_Widget(tabs); |
297 | arrange_Widget(w); | 304 | arrange_Widget(w); |
305 | setFixedSize_Widget(as_Widget(d->path), init_I2(width_Widget(tabs) - width_Widget(d->info), -1)); | ||
306 | setFixedSize_Widget(as_Widget(d->mime), init_I2(width_Widget(tabs) - 3 * gap_UI - | ||
307 | left_Rect(parent_Widget(d->mime)->rect), -1)); | ||
298 | setFixedSize_Widget(as_Widget(d->token), init_I2(width_Widget(tabs) - left_Rect(parent_Widget(d->token)->rect), -1)); | 308 | setFixedSize_Widget(as_Widget(d->token), init_I2(width_Widget(tabs) - left_Rect(parent_Widget(d->token)->rect), -1)); |
299 | setFixedSize_Widget(as_Widget(d->ident), init_I2(width_Widget(d->token), | 309 | setFixedSize_Widget(as_Widget(d->ident), init_I2(width_Widget(d->token), |
300 | lineHeight_Text(uiLabel_FontId) + 2 * gap_UI)); | 310 | lineHeight_Text(uiLabel_FontId) + 2 * gap_UI)); |
@@ -365,10 +375,23 @@ static void setUrlPort_UploadWidget_(iUploadWidget *d, const iString *url, uint1 | |||
365 | appendFormat_String(&d->url, ":%u", overridePort ? overridePort : titanPortForUrl_(url)); | 375 | appendFormat_String(&d->url, ":%u", overridePort ? overridePort : titanPortForUrl_(url)); |
366 | appendRange_String(&d->url, (iRangecc){ parts.path.start, constEnd_String(url) }); | 376 | appendRange_String(&d->url, (iRangecc){ parts.path.start, constEnd_String(url) }); |
367 | const iRangecc siteRoot = urlRoot_String(&d->url); | 377 | const iRangecc siteRoot = urlRoot_String(&d->url); |
368 | setTextCStr_LabelWidget(d->info, cstr_Rangecc((iRangecc){ constBegin_String(&d->url), siteRoot.end })); | 378 | setTextCStr_LabelWidget(d->info, cstr_Rangecc((iRangecc){ urlHost_String(&d->url).start, |
379 | siteRoot.end })); | ||
369 | /* From root onwards, the URL is editable. */ | 380 | /* From root onwards, the URL is editable. */ |
370 | setTextCStr_InputWidget(d->path, cstr_Rangecc((iRangecc){ siteRoot.end, constEnd_String(&d->url) })); | 381 | setTextCStr_InputWidget(d->path, |
371 | arrange_Widget(as_Widget(d)); | 382 | cstr_Rangecc((iRangecc){ siteRoot.end, constEnd_String(&d->url) })); |
383 | if (!cmp_String(text_InputWidget(d->path), "/")) { | ||
384 | setTextCStr_InputWidget(d->path, ""); /* might as well show the hint */ | ||
385 | } | ||
386 | if (isUsingPanelLayout_Mobile()) { | ||
387 | arrange_Widget(as_Widget(d)); /* a wrapped label */ | ||
388 | } | ||
389 | else { | ||
390 | setFixedSize_Widget(as_Widget(d->path), | ||
391 | init_I2(width_Widget(findChild_Widget(as_Widget(d), "upload.tabs")) - | ||
392 | width_Widget(d->info), | ||
393 | -1)); | ||
394 | } | ||
372 | } | 395 | } |
373 | 396 | ||
374 | void setUrl_UploadWidget(iUploadWidget *d, const iString *url) { | 397 | void setUrl_UploadWidget(iUploadWidget *d, const iString *url) { |