forked from mia/Aegisub
Set the horizontal zoom option consistently
Always store the actual zoom level, rather than sometimes the zoom level and sometimes the slider position. Updates #1597.
This commit is contained in:
parent
8f65d43b6c
commit
48c44440f7
2 changed files with 12 additions and 11 deletions
|
@ -149,8 +149,7 @@ void AudioBox::OnMouseWheel(wxMouseEvent &evt) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool zoom = evt.CmdDown() != OPT_GET("Audio/Wheel Default to Zoom")->GetBool();
|
bool zoom = evt.CmdDown() != OPT_GET("Audio/Wheel Default to Zoom")->GetBool();
|
||||||
if (!zoom)
|
if (!zoom) {
|
||||||
{
|
|
||||||
int amount = -evt.GetWheelRotation() * GetClientSize().GetWidth() / (evt.GetWheelDelta() * 3);
|
int amount = -evt.GetWheelRotation() * GetClientSize().GetWidth() / (evt.GetWheelDelta() * 3);
|
||||||
|
|
||||||
// If the user did a horizontal scroll the amount should be inverted
|
// If the user did a horizontal scroll the amount should be inverted
|
||||||
|
@ -165,15 +164,11 @@ void AudioBox::OnMouseWheel(wxMouseEvent &evt) {
|
||||||
|
|
||||||
audioDisplay->ScrollBy(amount);
|
audioDisplay->ScrollBy(amount);
|
||||||
}
|
}
|
||||||
else if (evt.GetWheelAxis() == 0)
|
else if (evt.GetWheelAxis() == 0) {
|
||||||
{
|
|
||||||
mouse_zoom_accum += evt.GetWheelRotation();
|
mouse_zoom_accum += evt.GetWheelRotation();
|
||||||
int zoom_delta = mouse_zoom_accum / evt.GetWheelDelta();
|
int zoom_delta = mouse_zoom_accum / evt.GetWheelDelta();
|
||||||
mouse_zoom_accum %= evt.GetWheelDelta();
|
mouse_zoom_accum %= evt.GetWheelDelta();
|
||||||
int new_zoom = audioDisplay->GetZoomLevel() + zoom_delta;
|
SetHorizontalZoom(audioDisplay->GetZoomLevel() + zoom_delta);
|
||||||
audioDisplay->SetZoomLevel(new_zoom);
|
|
||||||
HorizontalZoom->SetValue(-new_zoom);
|
|
||||||
OPT_SET("Audio/Zoom/Horizontal")->SetInt(new_zoom);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,10 +190,15 @@ void AudioBox::OnSashDrag(wxSashEvent &event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioBox::OnHorizontalZoom(wxScrollEvent &event) {
|
void AudioBox::OnHorizontalZoom(wxScrollEvent &event) {
|
||||||
// Negate the value, we want zoom out to be on bottom and zoom in on top,
|
// Negate the value since we want zoom out to be on bottom and zoom in on top,
|
||||||
// but the control doesn't want negative on bottom and positive on top.
|
// but the control doesn't want negative on bottom and positive on top.
|
||||||
audioDisplay->SetZoomLevel(-event.GetPosition());
|
SetHorizontalZoom(-event.GetPosition());
|
||||||
OPT_SET("Audio/Zoom/Horizontal")->SetInt(event.GetPosition());
|
}
|
||||||
|
|
||||||
|
void AudioBox::SetHorizontalZoom(int new_zoom) {
|
||||||
|
audioDisplay->SetZoomLevel(new_zoom);
|
||||||
|
HorizontalZoom->SetValue(-new_zoom);
|
||||||
|
OPT_SET("Audio/Zoom/Horizontal")->SetInt(new_zoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioBox::OnVerticalZoom(wxScrollEvent &event) {
|
void AudioBox::OnVerticalZoom(wxScrollEvent &event) {
|
||||||
|
|
|
@ -76,6 +76,7 @@ class AudioBox : public wxSashWindow {
|
||||||
// Mouse wheel zoom accumulator
|
// Mouse wheel zoom accumulator
|
||||||
int mouse_zoom_accum;
|
int mouse_zoom_accum;
|
||||||
|
|
||||||
|
void SetHorizontalZoom(int new_zoom);
|
||||||
void OnAudioOpen();
|
void OnAudioOpen();
|
||||||
void OnHorizontalZoom(wxScrollEvent &event);
|
void OnHorizontalZoom(wxScrollEvent &event);
|
||||||
void OnMouseWheel(wxMouseEvent &evt);
|
void OnMouseWheel(wxMouseEvent &evt);
|
||||||
|
|
Loading…
Reference in a new issue