Skip to content

Commit

Permalink
Resizable mixer channels/strips (LMMS#7293)
Browse files Browse the repository at this point in the history
## Make mixer channels resizable
Make the mixer channels resizable within the mixer view.

Remove the setting of the size policy from `MixerChannelView`. Add the
`Fader` widget with a stretch factor so that it is resized within the
layout of the mixer channel/strip. Remove the stretch that was added to
the layout because the fader now stretches.

In `MixerView` remove the top alignments when widgets are added to the
layout so that they can resize. Set the channel layout to align to the
left so that it behaves correctly when it is resized by the scroll area
it is contained in. Make the widget resizable in the scroll area so that
it always fills the space. Set the minimum height of the scroll area to
the minimum size of the widget plus the scrollbar height so that the
channel strips are never overlapped by the scrollbar.

Set the size policy of the "new channel" button so that it grows
vertically with the mixer view. Set a fixed size so that it is as wide as
a mixer strip.

## Enable maximization for mixer view

Enable the maximize button for the mixer view now that it is fully
resizable.
  • Loading branch information
michaelgregorius authored and Rossmaxx committed Jun 15, 2024
1 parent 1bd9709 commit ecc8a66
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
5 changes: 1 addition & 4 deletions src/gui/MixerChannelView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ namespace lmms::gui
m_mixerView(mixerView),
m_channelIndex(channelIndex)
{
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);

auto retainSizeWhenHidden = [](QWidget* widget)
{
auto sizePolicy = widget->sizePolicy();
Expand Down Expand Up @@ -133,10 +131,9 @@ namespace lmms::gui
mainLayout->addWidget(m_sendKnob, 0, Qt::AlignHCenter);
mainLayout->addWidget(m_sendArrow, 0, Qt::AlignHCenter);
mainLayout->addWidget(m_channelNumberLcd, 0, Qt::AlignHCenter);
mainLayout->addStretch();
mainLayout->addWidget(m_renameLineEditView, 0, Qt::AlignHCenter);
mainLayout->addLayout(soloMuteLayout, 0);
mainLayout->addWidget(m_fader, 0, Qt::AlignHCenter);
mainLayout->addWidget(m_fader, 1, Qt::AlignHCenter);

connect(m_renameLineEdit, &QLineEdit::editingFinished, this, &MixerChannelView::renameFinished);
}
Expand Down
16 changes: 8 additions & 8 deletions src/gui/MixerView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ MixerView::MixerView(Mixer* mixer) :
chLayout->setSizeConstraint(QLayout::SetMinimumSize);
chLayout->setSpacing(0);
chLayout->setContentsMargins(0, 0, 0, 0);
chLayout->setAlignment(Qt::AlignLeft);
m_channelAreaWidget->setLayout(chLayout);

// create rack layout before creating the first channel
Expand All @@ -105,7 +106,7 @@ MixerView::MixerView(Mixer* mixer) :

m_racksLayout->addWidget(m_mixerChannelViews[0]->m_effectRackView);

ml->addWidget(masterView, 0, Qt::AlignTop);
ml->addWidget(masterView, 0);

auto mixerChannelSize = masterView->sizeHint();

Expand Down Expand Up @@ -137,18 +138,20 @@ MixerView::MixerView(Mixer* mixer) :
channelArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
channelArea->setFrameStyle(QFrame::NoFrame);
channelArea->setMinimumWidth(mixerChannelSize.width() * 6);
channelArea->setWidgetResizable(true);

int const scrollBarExtent = style()->pixelMetric(QStyle::PM_ScrollBarExtent);
channelArea->setFixedHeight(mixerChannelSize.height() + scrollBarExtent);
channelArea->setMinimumHeight(mixerChannelSize.height() + scrollBarExtent);

ml->addWidget(channelArea, 1, Qt::AlignTop);
ml->addWidget(channelArea, 1);

// show the add new mixer channel button
auto newChannelBtn = new QPushButton(embed::getIconPixmap("new_channel"), QString(), this);
newChannelBtn->setObjectName("newChannelBtn");
newChannelBtn->setFixedSize(mixerChannelSize);
newChannelBtn->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding);
newChannelBtn->setFixedWidth(mixerChannelSize.width());
connect(newChannelBtn, SIGNAL(clicked()), this, SLOT(addNewChannel()));
ml->addWidget(newChannelBtn, 0, Qt::AlignTop);
ml->addWidget(newChannelBtn, 0);


// add the stacked layout for the effect racks of mixer channels
Expand All @@ -165,9 +168,6 @@ MixerView::MixerView(Mixer* mixer) :

// add ourself to workspace
QMdiSubWindow* subWin = mainWindow->addWindowedWidget(this);
Qt::WindowFlags flags = subWin->windowFlags();
flags &= ~Qt::WindowMaximizeButtonHint;
subWin->setWindowFlags(flags);
layout()->setSizeConstraint(QLayout::SetMinimumSize);
subWin->layout()->setSizeConstraint(QLayout::SetMinAndMaxSize);

Expand Down

0 comments on commit ecc8a66

Please sign in to comment.