From bb09db3b0176b01d10b5c5ed339ee67e2e753f42 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Fri, 23 Jul 2021 09:14:44 +0300 Subject: UploadWidget: Expand to input field size --- src/ui/uploadwidget.c | 14 ++++++++++++++ src/ui/util.c | 3 ++- src/ui/widget.h | 1 - 3 files changed, 16 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui/uploadwidget.c b/src/ui/uploadwidget.c index 4fd35732..67075040 100644 --- a/src/ui/uploadwidget.c +++ b/src/ui/uploadwidget.c @@ -76,6 +76,13 @@ void init_UploadWidget(iUploadWidget *d) { d->info = addChildFlags_Widget(w, iClob(new_LabelWidget("", NULL)), frameless_WidgetFlag); /* Tabs for input data. */ iWidget *tabs = makeTabs_Widget(w); + /* Make the tabs support vertical expansion based on content. */ { + setFlags_Widget(tabs, resizeHeightOfChildren_WidgetFlag, iFalse); + setFlags_Widget(tabs, arrangeHeight_WidgetFlag, iTrue); + iWidget *tabPages = findChild_Widget(tabs, "tabs.pages"); + setFlags_Widget(tabPages, resizeHeightOfChildren_WidgetFlag, iFalse); + setFlags_Widget(tabPages, arrangeHeight_WidgetFlag, iTrue); + } iWidget *headings, *values; setBackgroundColor_Widget(findChild_Widget(tabs, "tabs.buttons"), uiBackgroundSidebar_ColorId); setId_Widget(tabs, "upload.tabs"); @@ -235,6 +242,13 @@ static iBool processEvent_UploadWidget_(iUploadWidget *d, const SDL_Event *ev) { destroy_Widget(w); return iTrue; } + else if (isCommand_Widget(w, ev, "input.resized")) { + + resizeToLargestPage_Widget(findChild_Widget(w, "upload.tabs")); + arrange_Widget(w); + refresh_Widget(w); + return iTrue; + } if (ev->type == SDL_DROPFILE) { /* Switch to File tab. */ iWidget *tabs = findChild_Widget(w, "upload.tabs"); diff --git a/src/ui/util.c b/src/ui/util.c index 152df0bd..13a9237e 100644 --- a/src/ui/util.c +++ b/src/ui/util.c @@ -1043,7 +1043,8 @@ void resizeToLargestPage_Widget(iWidget *tabs) { iWidget *pages = findChild_Widget(tabs, "tabs.pages"); iForEach(ObjectList, i, children_Widget(pages)) { setMinSize_Widget(i.object, zero_I2()); -// resetSize_Widget(i.object); + iWidget *w = i.object; + w->rect.size = zero_I2(); } arrange_Widget(tabs); iInt2 largest = zero_I2(); diff --git a/src/ui/widget.h b/src/ui/widget.h index 41784b99..1a944c0a 100644 --- a/src/ui/widget.h +++ b/src/ui/widget.h @@ -268,7 +268,6 @@ iAny * removeChild_Widget (iWidget *, iAnyObject *child); /* returns a iAny * child_Widget (iWidget *, size_t index); /* O(n) */ size_t childIndex_Widget (const iWidget *, const iAnyObject *child); /* O(n) */ void arrange_Widget (iWidget *); -void resetSize_Widget (iWidget *); iBool scrollOverflow_Widget (iWidget *, int delta); /* moves the widget */ iBool dispatchEvent_Widget (iWidget *, const SDL_Event *); iBool processEvent_Widget (iWidget *, const SDL_Event *); -- cgit v1.2.3