From 480fe2f859b191584113de6e483121d3893eaf3e Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Thu, 18 Mar 2021 13:37:23 +0200 Subject: Mobile improvements Seeing if a few forced redraws will take care of the squished view issue. On the phone, showing and hiding the sidebar is not supposed to resize any documents. --- src/ui/documentwidget.c | 10 +++++++--- src/ui/scrollwidget.c | 2 +- src/ui/sidebarwidget.c | 5 +++-- 3 files changed, 11 insertions(+), 6 deletions(-) (limited to 'src/ui') diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 72867133..341da6f8 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c @@ -1493,8 +1493,12 @@ static const int homeRowKeys_[] = { 't', 'y', }; -static void updateDocumentWidthRetainingScrollPosition_DocumentWidget_(iDocumentWidget *d, - iBool keepCenter) { +static iBool updateDocumentWidthRetainingScrollPosition_DocumentWidget_(iDocumentWidget *d, + iBool keepCenter) { + const int newWidth = documentWidth_DocumentWidget_(d); + if (newWidth == size_GmDocument(d->doc).x) { + return iFalse; /* hasn't changed */ + } /* Font changes (i.e., zooming) will keep the view centered, otherwise keep the top of the visible area fixed. */ const iGmRun *run = keepCenter ? middleRun_DocumentWidget_(d) : d->firstVisibleRun; @@ -1505,7 +1509,7 @@ static void updateDocumentWidthRetainingScrollPosition_DocumentWidget_(iDocument /* TODO: First *fully* visible run? */ voffset = visibleRange_DocumentWidget_(d).start - top_Rect(run->visBounds); } - setWidth_GmDocument(d->doc, documentWidth_DocumentWidget_(d)); + setWidth_GmDocument(d->doc, newWidth); documentRunsInvalidated_DocumentWidget_(d); if (runLoc && !keepCenter) { run = findRunAtLoc_GmDocument(d->doc, runLoc); diff --git a/src/ui/scrollwidget.c b/src/ui/scrollwidget.c index a08b58d7..050681f4 100644 --- a/src/ui/scrollwidget.c +++ b/src/ui/scrollwidget.c @@ -116,7 +116,7 @@ static void unfade_ScrollWidget_(iScrollWidget *d, float opacity) { } static void checkVisible_ScrollWidget_(iScrollWidget *d) { - const iBool wasHidden = isVisible_Widget(d); + const iBool wasHidden = !isVisible_Widget(d); const iBool isHidden = d->thumbSize != 0 ? height_Rect(thumbRect_ScrollWidget_(d)) == 0 : iTrue; setFlags_Widget(as_Widget(d), hidden_WidgetFlag, isHidden); if (wasHidden && !isHidden) { diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c index ac119575..8c1bb60d 100644 --- a/src/ui/sidebarwidget.c +++ b/src/ui/sidebarwidget.c @@ -699,8 +699,9 @@ static void checkModeButtonLayout_SidebarWidget_(iSidebarWidget *d) { } void setWidth_SidebarWidget(iSidebarWidget *d, int width) { + const iBool isFixedWidth = deviceType_App() == phone_AppDeviceType; iWidget *w = as_Widget(d); - if (deviceType_App() != phone_AppDeviceType) { /* phone doesn't allow resizing */ + if (!isFixedWidth) { /* Even less space if the other sidebar is visible, too. */ const int otherWidth = width_Widget(findWidget_App(d->side == left_SideBarSide ? "sidebar2" : "sidebar")); @@ -713,7 +714,7 @@ void setWidth_SidebarWidget(iSidebarWidget *d, int width) { arrange_Widget(findWidget_App("stack")); checkModeButtonLayout_SidebarWidget_(d); updateItemHeight_SidebarWidget_(d); - if (!isRefreshPending_App()) { + if (!isFixedWidth && !isRefreshPending_App()) { updateSize_DocumentWidget(document_App()); invalidate_ListWidget(d->list); } -- cgit v1.2.3