Skip to content

Commit ed62f12

Browse files
committed
Control key modifier enables alternate zoom method.
NOTE: Currently only works with mouse wheel as key input is routed through GraphicsWindow::MenuView().
1 parent 5783d50 commit ed62f12

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

src/graphicswin.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -724,14 +724,14 @@ double GraphicsWindow::ZoomToFit(const Camera &camera,
724724
}
725725

726726

727-
void GraphicsWindow::ZoomToMouse(double zoomMultiplyer) {
727+
void GraphicsWindow::ZoomToMouse(double zoomMultiplyer, bool centered) {
728728
double offsetRight, offsetUp;
729729
double righti, upi;
730730

731731
// Mouse edit operations currently track the pointer relative to the
732-
// initial button press position, so zoomCenterNav is ignored during edits.
733-
bool trackPointer = (pending.operation != Pending::NONE) ||
734-
(! SS.zoomCenterNav);
732+
// initial button press position, so centered is currently ignored during
733+
// edits.
734+
bool trackPointer = (pending.operation != Pending::NONE) || (! centered);
735735

736736
if (trackPointer) {
737737
offsetRight = offset.Dot(projRight);
@@ -771,11 +771,11 @@ void GraphicsWindow::ZoomToMouse(double zoomMultiplyer) {
771771
void GraphicsWindow::MenuView(Command id) {
772772
switch(id) {
773773
case Command::ZOOM_IN:
774-
SS.GW.ZoomToMouse(1);
774+
SS.GW.ZoomToMouse(1, SS.zoomCenterNav);
775775
break;
776776

777777
case Command::ZOOM_OUT:
778-
SS.GW.ZoomToMouse(-1);
778+
SS.GW.ZoomToMouse(-1, SS.zoomCenterNav);
779779
break;
780780

781781
case Command::ZOOM_TO_FIT:

src/mouse.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,8 @@ bool GraphicsWindow::MouseEvent(Platform::MouseEvent event) {
915915
break;
916916

917917
case MouseEvent::Type::SCROLL_VERT:
918-
this->MouseScroll(event.shiftDown ? event.scrollDelta / 10 : event.scrollDelta);
918+
this->MouseScroll(event.shiftDown ? event.scrollDelta / 10 : event.scrollDelta,
919+
event.controlDown);
919920
break;
920921

921922
case MouseEvent::Type::LEAVE:
@@ -1480,7 +1481,7 @@ void GraphicsWindow::EditControlDone(const std::string &s) {
14801481
}
14811482
}
14821483

1483-
void GraphicsWindow::MouseScroll(double zoomMultiplyer) {
1484+
void GraphicsWindow::MouseScroll(double zoomMultiplyer, bool alt) {
14841485
// To support smooth scrolling where scroll wheel events come in increments
14851486
// smaller (or larger) than 1 we do:
14861487
// scale *= exp(ln(1.2) * zoomMultiplyer);
@@ -1491,7 +1492,7 @@ void GraphicsWindow::MouseScroll(double zoomMultiplyer) {
14911492
// while
14921493
// scale * a * b != scale * (a+b)
14931494
// So this constant is ln(1.2) = 0.1823216 to make the default zoom 1.2x
1494-
ZoomToMouse(zoomMultiplyer);
1495+
ZoomToMouse(zoomMultiplyer, alt ? ! SS.zoomCenterNav : SS.zoomCenterNav);
14951496
}
14961497

14971498
void GraphicsWindow::MouseLeave() {

src/ui.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ class GraphicsWindow {
629629
void HandlePointForZoomToFit(Vector p, Point2d *pmax, Point2d *pmin,
630630
double *wmin, bool usePerspective,
631631
const Camera &camera);
632-
void ZoomToMouse(double delta);
632+
void ZoomToMouse(double delta, bool centered);
633633
void LoopOverPoints(const std::vector<Entity *> &entities,
634634
const std::vector<Constraint *> &constraints,
635635
const std::vector<hEntity> &faces,
@@ -855,7 +855,7 @@ class GraphicsWindow {
855855
void MouseLeftDoubleClick(double x, double y);
856856
void MouseMiddleOrRightDown(double x, double y);
857857
void MouseRightUp(double x, double y);
858-
void MouseScroll(double delta);
858+
void MouseScroll(double delta, bool alt);
859859
void MouseLeave();
860860
bool KeyboardEvent(Platform::KeyboardEvent event);
861861
void EditControlDone(const std::string &s);

0 commit comments

Comments
 (0)