diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-04-09 16:55:24 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-04-10 06:29:31 +0300 |
commit | 04c1a56fde3edc94fbc04c09ca7877598fa02fd6 (patch) | |
tree | 03910cbab0d596621fc5bc16a28bb16a16b26054 | |
parent | 830f8671ca7913b28a35a48748f1d613bac74104 (diff) |
DocumentWidget: Pinch zoom vs. hover
Don't update hover while zooming.
-rw-r--r-- | src/ui/documentwidget.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 9df88068..65d9f164 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -580,7 +580,8 @@ static void updateHover_DocumentWidget_(iDocumentWidget *d, iInt2 mouse) { | |||
580 | iConstForEach(PtrArray, i, &d->visibleLinks) { | 580 | iConstForEach(PtrArray, i, &d->visibleLinks) { |
581 | const iGmRun *run = i.ptr; | 581 | const iGmRun *run = i.ptr; |
582 | /* Click targets are slightly expanded so there are no gaps between links. */ | 582 | /* Click targets are slightly expanded so there are no gaps between links. */ |
583 | if (contains_Rect(expanded_Rect(run->bounds, init1_I2(gap_Text / 2)), hoverPos)) { | 583 | if (~d->flags & pinchZoom_DocumentWidgetFlag && |
584 | contains_Rect(expanded_Rect(run->bounds, init1_I2(gap_Text / 2)), hoverPos)) { | ||
584 | d->hoverLink = run; | 585 | d->hoverLink = run; |
585 | break; | 586 | break; |
586 | } | 587 | } |
@@ -596,7 +597,7 @@ static void updateHover_DocumentWidget_(iDocumentWidget *d, iInt2 mouse) { | |||
596 | refresh_Widget(w); | 597 | refresh_Widget(w); |
597 | } | 598 | } |
598 | /* Hovering over preformatted blocks. */ | 599 | /* Hovering over preformatted blocks. */ |
599 | if (isHover_Widget(w)) { | 600 | if (isHover_Widget(w) && ~d->flags & pinchZoom_DocumentWidgetFlag) { |
600 | iConstForEach(PtrArray, j, &d->visiblePre) { | 601 | iConstForEach(PtrArray, j, &d->visiblePre) { |
601 | const iGmRun *run = j.ptr; | 602 | const iGmRun *run = j.ptr; |
602 | if (contains_Rect(run->bounds, hoverPos)) { | 603 | if (contains_Rect(run->bounds, hoverPos)) { |
@@ -1674,7 +1675,7 @@ static iBool handlePinch_DocumentWidget_(iDocumentWidget *d, const char *cmd) { | |||
1674 | } | 1675 | } |
1675 | else if (equal_Command(cmd, "pinch.moved")) { | 1676 | else if (equal_Command(cmd, "pinch.moved")) { |
1676 | const float rel = argf_Command(cmd); | 1677 | const float rel = argf_Command(cmd); |
1677 | int zoom = iClamp(iRound(d->pinchZoomInitial * rel / 5.0f) * 5, 50, 200); | 1678 | int zoom = iRound(d->pinchZoomInitial * rel / 5.0f) * 5; |
1678 | /* Snap to 100%. */ | 1679 | /* Snap to 100%. */ |
1679 | if (zoom > 90 && zoom < 110) { | 1680 | if (zoom > 90 && zoom < 110) { |
1680 | zoom = 100; | 1681 | zoom = 100; |
@@ -1685,6 +1686,7 @@ static iBool handlePinch_DocumentWidget_(iDocumentWidget *d, const char *cmd) { | |||
1685 | else { | 1686 | else { |
1686 | zoom = iMin(100, zoom + 10); | 1687 | zoom = iMin(100, zoom + 10); |
1687 | } | 1688 | } |
1689 | zoom = iClamp(zoom, 50, 200); | ||
1688 | if (d->pinchZoomPosted != zoom) { | 1690 | if (d->pinchZoomPosted != zoom) { |
1689 | d->pinchZoomPosted = zoom; | 1691 | d->pinchZoomPosted = zoom; |
1690 | postCommandf_App("zoom.set arg:%d", zoom); | 1692 | postCommandf_App("zoom.set arg:%d", zoom); |