From ca442991158d525f3a8e2f5c31492921059f4797 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Sat, 25 Dec 2021 15:37:18 +0200 Subject: Mobile: Same indication for hover links and open URLs --- src/ui/documentwidget.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 81aa382f..1b5b9af2 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c @@ -1243,9 +1243,9 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) { const iGmDocument *doc = d->view->doc; const int linkFlags = linkFlags_GmDocument(doc, run->linkId); /* Hover state of a link. */ - iBool isHover = - (run->linkId && d->view->hoverLink && run->linkId == d->view->hoverLink->linkId && - ~run->flags & decoration_GmRunFlag); + const iBool isPartOfHover = (run->linkId && d->view->hoverLink && + run->linkId == d->view->hoverLink->linkId); + iBool isHover = (isPartOfHover && ~run->flags & decoration_GmRunFlag); /* Visible (scrolled) position of the run. */ const iInt2 visPos = addX_I2(add_I2(run->visBounds.pos, origin), /* Preformatted runs can be scrolled. */ @@ -1260,18 +1260,23 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) { isInlineImageCaption = iFalse; } #endif + iBool isMobileHover = deviceType_App() != desktop_AppDeviceType && + (isPartOfHover || contains_PtrSet(d->view->invalidRuns, run)); /* While this is consistent, it's a bit excessive to indicate that an inlined image is open: the image itself is the indication. */ const iBool isInlineImageCaption = iFalse; - if (run->linkId && (linkFlags & isOpen_GmLinkFlag || isInlineImageCaption)) { + if (run->linkId && (linkFlags & isOpen_GmLinkFlag || isInlineImageCaption || isMobileHover)) { /* Open links get a highlighted background. */ int bg = tmBackgroundOpenLink_ColorId; + if (isMobileHover && !isPartOfHover) { + bg = tmBackground_ColorId; /* hover ended and was invalidated */ + } const int frame = tmFrameOpenLink_ColorId; const int pad = gap_Text; iRect wideRect = { init_I2(origin.x - pad, visPos.y), init_I2(d->docBounds.size.x + 2 * pad, height_Rect(run->visBounds)) }; - adjustEdges_Rect(&wideRect, + adjustEdges_Rect(&wideRect, run->flags & startOfLine_GmRunFlag ? -pad * 3 / 4 : 0, 0, run->flags & endOfLine_GmRunFlag ? pad * 3 / 4 : 0, 0); /* The first line is composed of two runs that may be drawn in either order, so -- cgit v1.2.3