Resizable mixer channels/strips (#7293)

## 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.
This commit is contained in:
Michael Gregorius
2024-05-31 13:11:45 +02:00
committed by GitHub
parent 94b1a382dd
commit 37795ae20a
2 changed files with 9 additions and 12 deletions

View File

@@ -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();
@@ -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);
}

View File

@@ -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
@@ -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();
@@ -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
@@ -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);