Skip to content

Commit

Permalink
Add helper method for incrementing scoll position
Browse files Browse the repository at this point in the history
  • Loading branch information
regulus79 committed Oct 6, 2024
1 parent ffd3967 commit 2f71e41
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 13 deletions.
2 changes: 2 additions & 0 deletions include/AutomationEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ protected slots:
QScrollBar * m_leftRightScroll;
QScrollBar * m_topBottomScroll;

void incrementLeftRightScoll(int value);

TimePos m_currentPosition;

Action m_action;
Expand Down
2 changes: 2 additions & 0 deletions include/PianoRoll.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,8 @@ protected slots:
QScrollBar * m_leftRightScroll;
QScrollBar * m_topBottomScroll;

void incrementLeftRightScoll(int value);

TimePos m_currentPosition;
bool m_recording;
bool m_doAutoQuantization{false};
Expand Down
2 changes: 2 additions & 0 deletions include/SongEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ private slots:

QScrollBar * m_leftRightScroll;

void incrementLeftRightScoll(int value);

LcdSpinBox * m_tempoSpinBox;

TimeLineWidget * m_timeLine;
Expand Down
12 changes: 7 additions & 5 deletions src/gui/editors/AutomationEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1560,7 +1560,11 @@ void AutomationEditor::resizeEvent(QResizeEvent * re)
update();
}


void AutomationEditor::incrementLeftRightScoll(int value)
{
m_leftRightScroll->setValue(m_leftRightScroll->value() -
value * 0.3f / m_zoomXLevels[m_zoomingXModel.value()]);
}


// TODO: Move this method up so it's closer to the other mouse events
Expand Down Expand Up @@ -1625,13 +1629,11 @@ void AutomationEditor::wheelEvent(QWheelEvent * we )
// FIXME: Reconsider if determining orientation is necessary in Qt6.
else if(abs(we->angleDelta().x()) > abs(we->angleDelta().y())) // scrolling is horizontal
{
m_leftRightScroll->setValue(m_leftRightScroll->value() -
we->angleDelta().x() * 2 / 6 / m_zoomXLevels[m_zoomingXModel.value()]);
incrementLeftRightScoll(we->angleDelta().x());
}
else if(we->modifiers() & Qt::ShiftModifier)
{
m_leftRightScroll->setValue(m_leftRightScroll->value() -
we->angleDelta().y() * 2 / 6 / m_zoomXLevels[m_zoomingXModel.value()]);
incrementLeftRightScoll(we->angleDelta().y());
}
else
{
Expand Down
12 changes: 8 additions & 4 deletions src/gui/editors/PianoRoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3743,6 +3743,12 @@ void PianoRoll::resizeEvent(QResizeEvent* re)
}


void PianoRoll::incrementLeftRightScoll(int value)
{
m_leftRightScroll->setValue(m_leftRightScroll->value() -
value * 0.3f / m_zoomXLevels[m_zoomingXModel.value()]);
}



void PianoRoll::wheelEvent(QWheelEvent * we )
Expand Down Expand Up @@ -3875,13 +3881,11 @@ void PianoRoll::wheelEvent(QWheelEvent * we )
// FIXME: Reconsider if determining orientation is necessary in Qt6.
else if(abs(we->angleDelta().x()) > abs(we->angleDelta().y())) // scrolling is horizontal
{
m_leftRightScroll->setValue(m_leftRightScroll->value() -
we->angleDelta().x() * 2 / 6 / m_zoomLevels[m_zoomingModel.value()]);
incrementLeftRightScoll(we->angleDelta().x());
}
else if(we->modifiers() & Qt::ShiftModifier)
{
m_leftRightScroll->setValue(m_leftRightScroll->value() -
we->angleDelta().y() * 2 / 6 / m_zoomLevels[m_zoomingModel.value()]);
incrementLeftRightScoll(we->angleDelta().y());
}
else
{
Expand Down
12 changes: 8 additions & 4 deletions src/gui/editors/SongEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,12 @@ void SongEditor::keyPressEvent( QKeyEvent * ke )



void SongEditor::incrementLeftRightScoll(int value)
{
m_leftRightScroll->setValue(m_leftRightScroll->value()
- value * DEFAULT_PIXELS_PER_BAR / pixelsPerBar());
}


void SongEditor::wheelEvent( QWheelEvent * we )
{
Expand Down Expand Up @@ -544,13 +550,11 @@ void SongEditor::wheelEvent( QWheelEvent * we )
// FIXME: Reconsider if determining orientation is necessary in Qt6.
else if (std::abs(we->angleDelta().x()) > std::abs(we->angleDelta().y())) // scrolling is horizontal
{
m_leftRightScroll->setValue(m_leftRightScroll->value()
- we->angleDelta().x() * DEFAULT_PIXELS_PER_BAR / pixelsPerBar());
incrementLeftRightScoll(we->angleDelta().x());
}
else if (we->modifiers() & Qt::ShiftModifier)
{
m_leftRightScroll->setValue(m_leftRightScroll->value()
- we->angleDelta().y() * DEFAULT_PIXELS_PER_BAR / pixelsPerBar());
incrementLeftRightScoll(we->angleDelta().y());
}
else
{
Expand Down

0 comments on commit 2f71e41

Please sign in to comment.