From 54882a015e4ea880fb817f013609a3f8411db725 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Tue, 18 May 2021 14:58:58 +0300 Subject: App: Fixed init of UI palette on first run IssueID #275 --- src/ui/window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/window.c') diff --git a/src/ui/window.c b/src/ui/window.c index abdc363d..5bf2aa53 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -59,7 +59,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ static iWindow *theWindow_ = NULL; -#if defined (iPlatformApple) || defined (iPlatformLinux) +#if defined (iPlatformApple) || defined (iPlatformLinux) || defined (iPlatformOther) static float initialUiScale_ = 1.0f; #else static float initialUiScale_ = 1.1f; -- cgit v1.2.3 From 58b4bbc5e92d4eb64da507d44fe5bbc9f535eee5 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Tue, 18 May 2021 12:33:10 +0300 Subject: App: Attempt to fix app restore issue Cached content like font glyphs are (were?) not being restored when returning to foreground. --- src/app.c | 3 +++ src/ui/window.c | 14 +++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src/ui/window.c') diff --git a/src/app.c b/src/app.c index 6c559f33..d259f541 100644 --- a/src/app.c +++ b/src/app.c @@ -1008,6 +1008,9 @@ void processEvents_App(enum iAppEventMode eventMode) { case SDL_APP_LOWMEMORY: clearCache_App_(); break; + case SDL_APP_WILLENTERFOREGROUND: + invalidate_Window(d->window); + break; case SDL_APP_DIDENTERFOREGROUND: gotEvents = iTrue; d->warmupFrames = 5; diff --git a/src/ui/window.c b/src/ui/window.c index 5bf2aa53..252b3bdb 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -566,14 +566,18 @@ iRoot *otherRoot_Window(const iWindow *d, iRoot *root) { return root == d->roots[0] && d->roots[1] ? d->roots[1] : d->roots[0]; } -void invalidate_Window(iWindow *d) { - if (d && !d->isInvalidated) { +static void invalidate_Window_(iWindow *d, iBool forced) { + if (d && (!d->isInvalidated || forced)) { d->isInvalidated = iTrue; resetFonts_Text(); postCommand_App("theme.changed auto:1"); /* forces UI invalidation */ } } +void invalidate_Window(iWindow *d) { + invalidate_Window_(d, iFalse); +} + static iBool isNormalPlacement_Window_(const iWindow *d) { if (d->isDrawFrozen) return iFalse; #if defined (iPlatformApple) @@ -741,14 +745,14 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) { return iTrue; case SDL_WINDOWEVENT_RESTORED: updateSize_Window_(d, iTrue); - invalidate_Window(d); + invalidate_Window_(d, iTrue); d->isMinimized = iFalse; postRefresh_App(); return iTrue; case SDL_WINDOWEVENT_MINIMIZED: d->isMinimized = iTrue; return iTrue; -#endif +#endif /* defined (iPlatformDesktop) */ case SDL_WINDOWEVENT_LEAVE: unhover_Widget(); d->isMouseInside = iFalse; @@ -772,7 +776,7 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) { d->isExposed = iTrue; #if defined (iPlatformMobile) /* Returned to foreground, may have lost buffered content. */ - invalidate_Window(d); + invalidate_Window_(d, iTrue); postCommand_App("window.unfreeze"); #endif return iFalse; -- cgit v1.2.3 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(-) (limited to 'src/ui/window.c') 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