summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-04-09 17:08:18 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-04-10 06:29:31 +0300
commitbc0387f8dc45adcfe02344f0e58a1d9148a6ddcc (patch)
tree78bcd502dd12ec091fbeb6f9f219c05efab0b737 /src
parent04c1a56fde3edc94fbc04c09ca7877598fa02fd6 (diff)
DocumentWidget: Pinch zoom tuning
The snap didn't quite work. It would be easier to do with relative pinch motion events, but hardly essential.
Diffstat (limited to 'src')
-rw-r--r--src/ui/documentwidget.c12
1 files changed, 1 insertions, 11 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 65d9f164..15134e5f 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -1676,16 +1676,6 @@ static iBool handlePinch_DocumentWidget_(iDocumentWidget *d, const char *cmd) {
1676 else if (equal_Command(cmd, "pinch.moved")) { 1676 else if (equal_Command(cmd, "pinch.moved")) {
1677 const float rel = argf_Command(cmd); 1677 const float rel = argf_Command(cmd);
1678 int zoom = iRound(d->pinchZoomInitial * rel / 5.0f) * 5; 1678 int zoom = iRound(d->pinchZoomInitial * rel / 5.0f) * 5;
1679 /* Snap to 100%. */
1680 if (zoom > 90 && zoom < 110) {
1681 zoom = 100;
1682 }
1683 else if (zoom > 100) {
1684 zoom = iMax(100, zoom - 10);
1685 }
1686 else {
1687 zoom = iMin(100, zoom + 10);
1688 }
1689 zoom = iClamp(zoom, 50, 200); 1679 zoom = iClamp(zoom, 50, 200);
1690 if (d->pinchZoomPosted != zoom) { 1680 if (d->pinchZoomPosted != zoom) {
1691 d->pinchZoomPosted = zoom; 1681 d->pinchZoomPosted = zoom;
@@ -3638,7 +3628,7 @@ static void draw_DocumentWidget_(const iDocumentWidget *d) {
3638 const int height = lineHeight_Text(font) * 2; 3628 const int height = lineHeight_Text(font) * 2;
3639 const iInt2 size = init_I2(height * 2, height); 3629 const iInt2 size = init_I2(height * 2, height);
3640 const iRect rect = { sub_I2(mid_Rect(bounds), divi_I2(size, 2)), size }; 3630 const iRect rect = { sub_I2(mid_Rect(bounds), divi_I2(size, 2)), size };
3641 fillRect_Paint(&ctx.paint, rect, uiTextAction_ColorId); 3631 fillRect_Paint(&ctx.paint, rect, d->pinchZoomPosted == 100 ? uiTextCaution_ColorId : uiTextAction_ColorId);
3642 drawCentered_Text(font, bounds, iFalse, uiBackground_ColorId, "%d %%", 3632 drawCentered_Text(font, bounds, iFalse, uiBackground_ColorId, "%d %%",
3643 d->pinchZoomPosted); 3633 d->pinchZoomPosted);
3644 } 3634 }