Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/SongEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ private slots:

bool m_scrollBack;
bool m_smoothScroll;
int m_widgetWidthTotal;

EditMode m_mode;
EditMode m_ctrlMode; // mode they were in before they hit ctrl
Expand Down
11 changes: 11 additions & 0 deletions src/gui/editors/AutomationEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1634,6 +1634,17 @@ void AutomationEditor::wheelEvent(QWheelEvent * we )
x--;
}
x = qBound( 0, x, m_zoomingXModel.size() - 1 );

int mouseX = (we->x() - VALUES_WIDTH)* MidiTime::ticksPerTact();
// ticks based on the mouse x-position where the scroll wheel was used
int ticks = mouseX / m_ppt;
// what would be the ticks in the new zoom level on the very same mouse x
int newTicks = mouseX / (DEFAULT_PPT * m_zoomXLevels[x]);

// scroll so the tick "selected" by the mouse x doesn't move on the screen
m_leftRightScroll->setValue(m_leftRightScroll->value() + ticks - newTicks);


m_zoomingXModel.setValue( x );
}
else if( we->modifiers() & Qt::ShiftModifier
Expand Down
8 changes: 8 additions & 0 deletions src/gui/editors/PianoRoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3289,6 +3289,14 @@ void PianoRoll::wheelEvent(QWheelEvent * we )
z--;
}
z = qBound( 0, z, m_zoomingModel.size() - 1 );

int x = (we->x() - WHITE_KEY_WIDTH)* MidiTime::ticksPerTact();
// ticks based on the mouse x-position where the scroll wheel was used
int ticks = x / m_ppt;
// what would be the ticks in the new zoom level on the very same mouse x
int newTicks = x / (DEFAULT_PR_PPT * m_zoomLevels[z]);
// scroll so the tick "selected" by the mouse x doesn't move on the screen
m_leftRightScroll->setValue(m_leftRightScroll->value() + ticks - newTicks);
// update combobox with zooming-factor
m_zoomingModel.setValue( z );
}
Expand Down
14 changes: 12 additions & 2 deletions src/gui/editors/SongEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ SongEditor::SongEditor( Song * song ) :
{
m_zoomingModel->setParent(this);
// create time-line
int widgetTotal = ConfigManager::inst()->value( "ui",
m_widgetWidthTotal = ConfigManager::inst()->value( "ui",
"compacttrackbuttons" ).toInt()==1 ?
DEFAULT_SETTINGS_WIDGET_WIDTH_COMPACT + TRACK_OP_WIDTH_COMPACT :
DEFAULT_SETTINGS_WIDGET_WIDTH + TRACK_OP_WIDTH;
m_timeLine = new TimeLineWidget( widgetTotal, 32,
m_timeLine = new TimeLineWidget( m_widgetWidthTotal, 32,
pixelsPerTact(),
m_song->m_playPos[Song::Mode_PlaySong],
m_currentPosition, this );
Expand Down Expand Up @@ -384,6 +384,16 @@ void SongEditor::wheelEvent( QWheelEvent * we )
z--;
}
z = qBound( 0, z, m_zoomingModel->size() - 1 );


int x = (we->x() - m_widgetWidthTotal);
// tact based on the mouse x-position where the scroll wheel was used
int tact= x / pixelsPerTact();
// what would be the tact in the new zoom level on the very same mouse x
int newTact = x / DEFAULT_PIXELS_PER_TACT / m_zoomLevels[z];
// scroll so the tact "selected" by the mouse x doesn't move on the screen
m_leftRightScroll->setValue(m_leftRightScroll->value() + tact - newTact);

// update combobox with zooming-factor
m_zoomingModel->setValue( z );

Expand Down