From 4b7d2f8978881b8a01f4b37ce33486dfa6484d1c Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Tue, 18 May 2021 16:54:15 +0300 Subject: Mobile: No view split on phone; layout fixes --- src/ui/documentwidget.c | 3 +++ src/ui/mobile.c | 18 ++++++++++++------ src/ui/widget.c | 6 ++++-- src/ui/window.c | 5 +++++ 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 9b8340fb..e227bcef 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c @@ -3053,6 +3053,9 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e 0, format_CStr("!open newtab:5 url:%s", cstr_String(linkUrl)) } }, 4); + if (deviceType_App() == phone_AppDeviceType) { + removeN_Array(&items, size_Array(&items) - 2, iInvalidSize); + } } else if (!willUseProxy_App(scheme)) { pushBack_Array( diff --git a/src/ui/mobile.c b/src/ui/mobile.c index 1f5e9758..6c3a0b32 100644 --- a/src/ui/mobile.c +++ b/src/ui/mobile.c @@ -253,7 +253,9 @@ static iAnyObject *addPanelChild_(iWidget *panel, iAnyObject *child, int64_t fla } } if ((elementType == toggle_PrefsElement && precedingElementType != toggle_PrefsElement) || - (elementType == textInput_PrefsElement && precedingElementType != textInput_PrefsElement)) { + (elementType == textInput_PrefsElement && precedingElementType != textInput_PrefsElement) || + (elementType == dropdown_PrefsElement && precedingElementType != dropdown_PrefsElement) || + (elementType == radioButton_PrefsElement && precedingElementType == heading_PrefsElement)) { flags |= borderTop_WidgetFlag; } return addChildFlags_Widget(panel, child, flags); @@ -305,6 +307,7 @@ static iWidget *makeValuePadding_(iWidget *value) { } static iWidget *makeValuePaddingWithHeading_(iLabelWidget *heading, iWidget *value) { + const iBool isInput = isInstance_Object(value, &Class_InputWidget); iWidget *div = new_Widget(); setFlags_Widget(div, borderBottom_WidgetFlag | arrangeHeight_WidgetFlag | @@ -313,10 +316,11 @@ static iWidget *makeValuePaddingWithHeading_(iLabelWidget *heading, iWidget *val setBackgroundColor_Widget(div, uiBackgroundSidebar_ColorId); setPadding_Widget(div, gap_UI, gap_UI, 4 * gap_UI, gap_UI); addChildFlags_Widget(div, iClob(heading), 0); + setPadding1_Widget(as_Widget(heading), 0); //setFixedSize_Widget(as_Widget(heading), init_I2(-1, height_Widget(value))); setFont_LabelWidget(heading, labelFont_()); setTextColor_LabelWidget(heading, uiTextStrong_ColorId); - if (isInstance_Object(value, &Class_InputWidget)) { + if (isInput) { addChildFlags_Widget(div, iClob(value), expand_WidgetFlag); } else if (isInstance_Object(value, &Class_LabelWidget) && @@ -332,6 +336,7 @@ static iWidget *makeValuePaddingWithHeading_(iLabelWidget *heading, iWidget *val addChildFlags_Widget(div, iClob(new_Widget()), expand_WidgetFlag); addChild_Widget(div, iClob(value)); } + printTree_Widget(div); return div; } @@ -374,7 +379,9 @@ void finalizeSheet_Mobile(iWidget *sheet) { postRefresh_App(); return; } - /* Landscape Layout    Portrait Layout + /* TODO: In portrait, top panel and detail stack are all stacked together. + + Landscape Layout    Portrait Layout    ┌─────────┬──────Detail─Stack─────┐    ┌─────────┬ ─ ─ ─ ─ ┐ │ │┌───────────────────┐ │    │ │Detail @@ -616,10 +623,9 @@ void finalizeSheet_Mobile(iWidget *sheet) { addChild_Widget(topPanel, iClob(makePadding_Widget(lineHeight_Text(labelFont_())))); iLabelWidget *aboutButton = addChildFlags_Widget(topPanel, iClob(makePanelButton_(planet_Icon " ${menu.about}", "panel.open")), - chevron_WidgetFlag); + chevron_WidgetFlag | borderTop_WidgetFlag); addChildFlags_Widget(topPanel, - iClob(makePanelButton_(info_Icon " ${menu.help}", "!open url:about:help")), - borderTop_WidgetFlag); + iClob(makePanelButton_(info_Icon " ${menu.help}", "!open url:about:help")), 0); /* The About panel. */ { iWidget *panel = addChildPanel_(detailStack, aboutButton, NULL); iString *msg = collectNew_String(); diff --git a/src/ui/widget.c b/src/ui/widget.c index 3439fb1b..3ff2e713 100644 --- a/src/ui/widget.c +++ b/src/ui/widget.c @@ -726,13 +726,15 @@ static void resetArrangement_Widget_(iWidget *d) { if (d->flags & arrangeHorizontal_WidgetFlag) { child->rect.pos.x = 0; } - if (d->flags & resizeWidthOfChildren_WidgetFlag && child->flags & expand_WidgetFlag) { + if (d->flags & resizeWidthOfChildren_WidgetFlag && child->flags & expand_WidgetFlag && + ~child->flags & fixedWidth_WidgetFlag) { child->rect.size.x = 0; } if (d->flags & arrangeVertical_WidgetFlag) { child->rect.pos.y = 0; } - if (d->flags & resizeHeightOfChildren_WidgetFlag && child->flags & expand_WidgetFlag) { + if (d->flags & resizeHeightOfChildren_WidgetFlag && child->flags & expand_WidgetFlag && + ~child->flags & fixedHeight_WidgetFlag) { child->rect.size.y = 0; } } diff --git a/src/ui/window.c b/src/ui/window.c index 252b3bdb..87db2f3e 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -1199,6 +1199,11 @@ void swapRoots_Window(iWindow *d) { void setSplitMode_Window(iWindow *d, int splitFlags) { const int splitMode = splitFlags & mode_WindowSplit; + if (deviceType_App() == phone_AppDeviceType) { + /* There isn't enough room on the phone. */ + /* TODO: Maybe in landscape only? */ + return; + } iAssert(current_Root() == NULL); if (d->splitMode != splitMode) { int oldCount = numRoots_Window(d); -- cgit v1.2.3