summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-12-25 15:37:18 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-12-25 15:37:18 +0200
commitca442991158d525f3a8e2f5c31492921059f4797 (patch)
treecf580be69736d8641e3e1f3ff2b52a7c3c2efb73 /src
parent2007dc961480151721e646aac468a0ae5639b18f (diff)
Mobile: Same indication for hover links and open URLs
Diffstat (limited to 'src')
-rw-r--r--src/ui/documentwidget.c15
1 files 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) {
1243 const iGmDocument *doc = d->view->doc; 1243 const iGmDocument *doc = d->view->doc;
1244 const int linkFlags = linkFlags_GmDocument(doc, run->linkId); 1244 const int linkFlags = linkFlags_GmDocument(doc, run->linkId);
1245 /* Hover state of a link. */ 1245 /* Hover state of a link. */
1246 iBool isHover = 1246 const iBool isPartOfHover = (run->linkId && d->view->hoverLink &&
1247 (run->linkId && d->view->hoverLink && run->linkId == d->view->hoverLink->linkId && 1247 run->linkId == d->view->hoverLink->linkId);
1248 ~run->flags & decoration_GmRunFlag); 1248 iBool isHover = (isPartOfHover && ~run->flags & decoration_GmRunFlag);
1249 /* Visible (scrolled) position of the run. */ 1249 /* Visible (scrolled) position of the run. */
1250 const iInt2 visPos = addX_I2(add_I2(run->visBounds.pos, origin), 1250 const iInt2 visPos = addX_I2(add_I2(run->visBounds.pos, origin),
1251 /* Preformatted runs can be scrolled. */ 1251 /* Preformatted runs can be scrolled. */
@@ -1260,18 +1260,23 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) {
1260 isInlineImageCaption = iFalse; 1260 isInlineImageCaption = iFalse;
1261 } 1261 }
1262#endif 1262#endif
1263 iBool isMobileHover = deviceType_App() != desktop_AppDeviceType &&
1264 (isPartOfHover || contains_PtrSet(d->view->invalidRuns, run));
1263 /* While this is consistent, it's a bit excessive to indicate that an inlined image 1265 /* While this is consistent, it's a bit excessive to indicate that an inlined image
1264 is open: the image itself is the indication. */ 1266 is open: the image itself is the indication. */
1265 const iBool isInlineImageCaption = iFalse; 1267 const iBool isInlineImageCaption = iFalse;
1266 if (run->linkId && (linkFlags & isOpen_GmLinkFlag || isInlineImageCaption)) { 1268 if (run->linkId && (linkFlags & isOpen_GmLinkFlag || isInlineImageCaption || isMobileHover)) {
1267 /* Open links get a highlighted background. */ 1269 /* Open links get a highlighted background. */
1268 int bg = tmBackgroundOpenLink_ColorId; 1270 int bg = tmBackgroundOpenLink_ColorId;
1271 if (isMobileHover && !isPartOfHover) {
1272 bg = tmBackground_ColorId; /* hover ended and was invalidated */
1273 }
1269 const int frame = tmFrameOpenLink_ColorId; 1274 const int frame = tmFrameOpenLink_ColorId;
1270 const int pad = gap_Text; 1275 const int pad = gap_Text;
1271 iRect wideRect = { init_I2(origin.x - pad, visPos.y), 1276 iRect wideRect = { init_I2(origin.x - pad, visPos.y),
1272 init_I2(d->docBounds.size.x + 2 * pad, 1277 init_I2(d->docBounds.size.x + 2 * pad,
1273 height_Rect(run->visBounds)) }; 1278 height_Rect(run->visBounds)) };
1274 adjustEdges_Rect(&wideRect, 1279 adjustEdges_Rect(&wideRect,
1275 run->flags & startOfLine_GmRunFlag ? -pad * 3 / 4 : 0, 0, 1280 run->flags & startOfLine_GmRunFlag ? -pad * 3 / 4 : 0, 0,
1276 run->flags & endOfLine_GmRunFlag ? pad * 3 / 4 : 0, 0); 1281 run->flags & endOfLine_GmRunFlag ? pad * 3 / 4 : 0, 0);
1277 /* The first line is composed of two runs that may be drawn in either order, so 1282 /* The first line is composed of two runs that may be drawn in either order, so