Skip to content
Open
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
3 changes: 3 additions & 0 deletions include/MixerView.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#ifndef LMMS_GUI_MIXER_VIEW_H
#define LMMS_GUI_MIXER_VIEW_H

#include <QScrollBar>
#include <QWidget>

#include "MixerChannelView.h"
Expand Down Expand Up @@ -54,6 +55,7 @@ class LMMS_EXPORT MixerView
public:
MixerView(Mixer* mixer);
void keyPressEvent(QKeyEvent* e) override;
void wheelEvent(QWheelEvent* e) override;

void saveSettings(QDomDocument& doc, QDomElement& domElement) override;
void loadSettings(const QDomElement& domElement) override;
Expand Down Expand Up @@ -119,6 +121,7 @@ private slots:
QScrollArea* channelArea;
QHBoxLayout* chLayout;
QWidget* m_channelAreaWidget;
QScrollBar* m_channelAreaScrollBar;
QStackedLayout* m_racksLayout;
QWidget* m_racksWidget;
Mixer* m_mixer;
Expand Down
30 changes: 30 additions & 0 deletions src/gui/MixerView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ MixerView::MixerView(Mixer* mixer) :
channelArea->setFrameStyle(QFrame::NoFrame);
channelArea->setMinimumWidth(mixerChannelSize.width() * 6);
channelArea->setWidgetResizable(true);
m_channelAreaScrollBar = channelArea->horizontalScrollBar();

int const scrollBarExtent = style()->pixelMetric(QStyle::PM_ScrollBarExtent);
channelArea->setMinimumHeight(mixerChannelSize.height() + scrollBarExtent);
Expand Down Expand Up @@ -478,6 +479,8 @@ void MixerView::keyPressEvent(QKeyEvent * e)
}
};

int overflow;

switch(e->key())
{
case Qt::Key_Delete:
Expand All @@ -493,6 +496,11 @@ void MixerView::keyPressEvent(QKeyEvent * e)
// select channel to the left
setCurrentMixerChannel(m_currentMixerChannel->channelIndex() - 1);
}
if ( ( overflow = m_channelAreaScrollBar->value() - m_currentMixerChannel->x() ) > 0 )
{
// scroll to the left if the current channel is going out of view
m_channelAreaScrollBar->setValue( m_channelAreaScrollBar->value() - overflow );
}
break;
case Qt::Key_Right:
if (e->modifiers() & Qt::AltModifier)
Expand All @@ -504,6 +512,11 @@ void MixerView::keyPressEvent(QKeyEvent * e)
// select channel to the right
setCurrentMixerChannel(m_currentMixerChannel->channelIndex() + 1);
}
if ( ( overflow = m_currentMixerChannel->x() + m_currentMixerChannel->width() - m_channelAreaScrollBar->value() - m_channelAreaScrollBar->pageStep() ) > 0 )
{
// scroll to the right if the current channel is going out of view
m_channelAreaScrollBar->setValue( m_channelAreaScrollBar->value() + overflow );
}
break;
case Qt::Key_Up:
case Qt::Key_Plus:
Expand Down Expand Up @@ -532,6 +545,23 @@ void MixerView::keyPressEvent(QKeyEvent * e)



void MixerView::wheelEvent(QWheelEvent* e)
{
if (e->modifiers() & Qt::ShiftModifier)
{
if ( e->angleDelta().y() > 0 )
{
m_channelAreaScrollBar->setValue( m_channelAreaScrollBar->value() - m_currentMixerChannel->width() );
}
else
{
m_channelAreaScrollBar->setValue( m_channelAreaScrollBar->value() + m_currentMixerChannel->width() );
}
}
}



void MixerView::setCurrentMixerChannel(int channel)
{
if (channel >= 0 && channel < m_mixerChannelViews.size())
Expand Down
Loading