summaryrefslogtreecommitdiff
path: root/src/ui/documentwidget.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/documentwidget.c')
-rw-r--r--src/ui/documentwidget.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 40d83cec..cb075c49 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -1701,6 +1701,8 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)
1701 iWidget *sizer = new_Widget(); 1701 iWidget *sizer = new_Widget();
1702 setSize_Widget(sizer, init_I2(gap_UI * 90, 1)); 1702 setSize_Widget(sizer, init_I2(gap_UI * 90, 1));
1703 addChildFlags_Widget(dlg, iClob(sizer), frameless_WidgetFlag); 1703 addChildFlags_Widget(dlg, iClob(sizer), frameless_WidgetFlag);
1704 setFlags_Widget(dlg, centerHorizontal_WidgetFlag, iFalse);
1705 setPos_Widget(dlg, bottomLeft_Rect(bounds_Widget(findWidget_App("navbar.lock"))));
1704 arrange_Widget(dlg); 1706 arrange_Widget(dlg);
1705 addAction_Widget(dlg, SDLK_ESCAPE, 0, "message.ok"); 1707 addAction_Widget(dlg, SDLK_ESCAPE, 0, "message.ok");
1706 addAction_Widget(dlg, SDLK_SPACE, 0, "message.ok"); 1708 addAction_Widget(dlg, SDLK_SPACE, 0, "message.ok");
@@ -2350,16 +2352,20 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
2350 } 2352 }
2351 } 2353 }
2352 else if (ev->type == SDL_MOUSEWHEEL && isHover_Widget(w)) { 2354 else if (ev->type == SDL_MOUSEWHEEL && isHover_Widget(w)) {
2355 /* TODO: Maybe clean this up a bit? Wheel events are used for scrolling
2356 but they are calculated differently based on device/mouse/trackpad. */
2353 const iInt2 mouseCoord = mouseCoord_Window(get_Window()); 2357 const iInt2 mouseCoord = mouseCoord_Window(get_Window());
2354#if defined (iPlatformApple) 2358#if defined (iPlatformApple)
2355 /* On macOS, we handle both trackpad and mouse events. We expect SDL to identify 2359 /* On macOS, we handle both trackpad and mouse events. We expect SDL to identify
2356 which device is sending the event. */ 2360 which device is sending the event. */
2357 if (ev->wheel.which == 0) { /* Trackpad with precise scrolling w/inertia. */ 2361 if (ev->wheel.which == 0) { /* Trackpad with precise scrolling w/inertia. */
2358 stop_Anim(&d->scrollY); 2362 stop_Anim(&d->scrollY);
2359 iInt2 wheel = mulf_I2(init_I2(ev->wheel.x, ev->wheel.y), get_Window()->pixelRatio); 2363 iInt2 wheel = init_I2(ev->wheel.x, ev->wheel.y);
2360#if defined (iPlatformAppleMobile) 2364# if defined (iPlatformAppleMobile)
2361 wheel.x = -wheel.x; 2365 wheel.x = -wheel.x;
2362#else 2366# else
2367 /* Wheel mounts are in points. */
2368 mulfv_I2(&wheel, get_Window()->pixelRatio);
2363 /* Only scroll on one axis at a time. */ 2369 /* Only scroll on one axis at a time. */
2364 if (iAbs(wheel.x) > iAbs(wheel.y)) { 2370 if (iAbs(wheel.x) > iAbs(wheel.y)) {
2365 wheel.y = 0; 2371 wheel.y = 0;
@@ -2367,7 +2373,7 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
2367 else { 2373 else {
2368 wheel.x = 0; 2374 wheel.x = 0;
2369 } 2375 }
2370#endif 2376# endif
2371 scroll_DocumentWidget_(d, -wheel.y); 2377 scroll_DocumentWidget_(d, -wheel.y);
2372 scrollWideBlock_DocumentWidget_(d, mouseCoord, wheel.x, 0); 2378 scrollWideBlock_DocumentWidget_(d, mouseCoord, wheel.x, 0);
2373 } 2379 }