-
Notifications
You must be signed in to change notification settings - Fork 635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DYN-4305: After panning, sometimes zooming doesn't zoom into the mouse position #13095
Changes from 6 commits
9f18d83
0996149
54ad9db
176647f
73a9e87
862c451
264c0af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,29 +100,34 @@ public Point GetTranslateTransformOrigin() | |
|
||
public void SetTranslateTransformOrigin(Point2D p) | ||
{ | ||
var tt = GetTranslateTransform(child); | ||
tt.X = p.X; | ||
tt.Y = p.Y; | ||
var tt = GetChildTranslateTransform(); | ||
if (tt.X != p.X || tt.Y != p.Y) | ||
{ | ||
tt.X = p.X; | ||
tt.Y = p.Y; | ||
|
||
var st = GetScaleTransform(child); | ||
NotifyViewSettingsChanged(tt.X, tt.Y, st.ScaleX); | ||
var st = GetChildScaleTransform(); | ||
NotifyViewSettingsChanged(tt.X, tt.Y, st.ScaleX); | ||
} | ||
} | ||
|
||
public void SetZoom(double zoom) | ||
{ | ||
var st = GetScaleTransform(child); | ||
st.ScaleX = zoom; | ||
st.ScaleY = zoom; | ||
|
||
var tt = GetTranslateTransform(child); | ||
NotifyViewSettingsChanged(tt.X, tt.Y, zoom); | ||
var st = GetChildScaleTransform(); | ||
if (st.ScaleX != zoom || st.ScaleY != zoom) | ||
{ | ||
st.ScaleX = zoom; | ||
st.ScaleY = zoom; | ||
var tt = GetTranslateTransform(child); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GetChildTranslateTransform() ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, could be used here. I may do a pass and use the child version of these methods. |
||
NotifyViewSettingsChanged(tt.X, tt.Y, zoom); | ||
} | ||
} | ||
|
||
#region Child Events | ||
|
||
private void child_MouseWheel(object sender, MouseWheelEventArgs e) | ||
{ | ||
if (child != null) | ||
if (child != null && !child.IsMouseCaptured) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do not allow zoom if middle button is down. This caused zoom to jump. |
||
{ | ||
//double zoom = e.Delta > 0 ? .1 : -.1; | ||
double zoom = e.Delta > 0 ? 1 : -1; | ||
|
@@ -173,6 +178,12 @@ private void child_MouseMove(object sender, MouseEventArgs e) | |
|
||
// Change ZoomBorder's child translation | ||
Vector v = start - e.GetPosition(this); | ||
|
||
if (v.Length == 0.0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe use a tolerance ? I guess it does not matter that much... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking of it but the values I have seen here have been 0,1,2 etc and 0 has been 0 in those cases. So I think this is good enough. |
||
{ | ||
return; | ||
} | ||
|
||
SetTranslateTransformOrigin(new Point2D | ||
{ | ||
X = origin.X - v.X, | ||
|
@@ -202,7 +213,6 @@ private void NotifyViewSettingsChanged(double x, double y, double zoom) | |
handler(new ViewSettingsChangedEventArgs(x, y, zoom)); | ||
} | ||
} | ||
|
||
#endregion | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1310,7 +1310,7 @@ private void SetCurrentOffset(object parameter) | |
|
||
//set the current offset without triggering | ||
//any property change notices. | ||
if (Model.X != p.X && Model.Y != p.Y) | ||
if (Model.X != p.X || Model.Y != p.Y) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was the second bug. Zoom jumped if only X or Y changed during pan. |
||
{ | ||
Model.X = p.X; | ||
Model.Y = p.Y; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keeping code that stops propagation if nothing has changed.