Fix track operations button alignment, size, and style (#7779)

Make the track ops button consistently sized and style it and the solo & mute buttons using CSS instead of SVG assets
This commit is contained in:
Fawn
2025-03-25 19:02:08 -06:00
committed by GitHub
parent 1d5f2c0050
commit 8afe95aeaf
20 changed files with 297 additions and 262 deletions

View File

@@ -107,18 +107,16 @@ MixerChannelView::MixerChannelView(QWidget* parent, MixerView* mixerView, int ch
renameLineEditProxy->setRotation(-90);
m_renameLineEditView->setFixedSize(m_renameLineEdit->height() + 5, m_renameLineEdit->width() + 5);
m_muteButton = new PixmapButton(this, tr("Mute"));
m_muteButton = new AutomatableButton(this, tr("Mute"));
m_muteButton->setModel(&mixerChannel->m_muteModel);
m_muteButton->setActiveGraphic(embed::getIconPixmap("mute_active"));
m_muteButton->setInactiveGraphic(embed::getIconPixmap("mute_inactive"));
m_muteButton->setCheckable(true);
m_muteButton->setObjectName("btn-mute");
m_muteButton->setToolTip(tr("Mute this channel"));
m_soloButton = new PixmapButton(this, tr("Solo"));
m_soloButton = new AutomatableButton(this, tr("Solo"));
m_soloButton->setModel(&mixerChannel->m_soloModel);
m_soloButton->setActiveGraphic(embed::getIconPixmap("solo_active"));
m_soloButton->setInactiveGraphic(embed::getIconPixmap("solo_inactive"));
m_soloButton->setCheckable(true);
m_soloButton->setObjectName("btn-solo");
m_soloButton->setToolTip(tr("Solo this channel"));
auto soloMuteLayout = new QVBoxLayout();

View File

@@ -32,7 +32,6 @@
#include <QVBoxLayout>
#include "EffectRackView.h"
#include "PixmapButton.h"
#include "embed.h"
#include "GuiApplication.h"
#include "Knob.h"
@@ -101,18 +100,16 @@ SampleTrackWindow::SampleTrackWindow(SampleTrackView * tv) :
soloMuteLayout->setContentsMargins(0, 0, 2, 0);
soloMuteLayout->setSpacing(2);
m_muteBtn = new PixmapButton(this, tr("Mute"));
m_muteBtn = new AutomatableButton(this, tr("Mute"));
m_muteBtn->setModel(&m_track->m_mutedModel);
m_muteBtn->setActiveGraphic(embed::getIconPixmap("mute_active"));
m_muteBtn->setInactiveGraphic(embed::getIconPixmap("mute_inactive"));
m_muteBtn->setObjectName("btn-mute");
m_muteBtn->setCheckable(true);
m_muteBtn->setToolTip(tr("Mute this sample track"));
soloMuteLayout->addWidget(m_muteBtn, 0, widgetAlignment);
m_soloBtn = new PixmapButton(this, tr("Solo"));
m_soloBtn = new AutomatableButton(this, tr("Solo"));
m_soloBtn->setModel(&m_track->m_soloModel);
m_soloBtn->setActiveGraphic(embed::getIconPixmap("solo_active"));
m_soloBtn->setInactiveGraphic(embed::getIconPixmap("solo_inactive"));
m_soloBtn->setObjectName("btn-solo");
m_soloBtn->setCheckable(true);
m_soloBtn->setToolTip(tr("Solo this sample track"));
soloMuteLayout->addWidget(m_soloBtn, 0, widgetAlignment);

View File

@@ -144,19 +144,17 @@ InstrumentTrackWindow::InstrumentTrackWindow( InstrumentTrackView * _itv ) :
soloMuteLayout->setContentsMargins(0, 0, 2, 0);
soloMuteLayout->setSpacing(2);
m_muteBtn = new PixmapButton(this, tr("Mute"));
m_muteBtn = new AutomatableButton(this, tr("Mute"));
m_muteBtn->setModel(&m_track->m_mutedModel);
m_muteBtn->setActiveGraphic(embed::getIconPixmap("mute_active"));
m_muteBtn->setInactiveGraphic(embed::getIconPixmap("mute_inactive"));
m_muteBtn->setCheckable(true);
m_muteBtn->setObjectName("btn-mute");
m_muteBtn->setToolTip(tr("Mute this instrument"));
soloMuteLayout->addWidget(m_muteBtn, 0, widgetAlignment);
m_soloBtn = new PixmapButton(this, tr("Solo"));
m_soloBtn = new AutomatableButton(this, tr("Solo"));
m_soloBtn->setModel(&m_track->m_soloModel);
m_soloBtn->setActiveGraphic(embed::getIconPixmap("solo_active"));
m_soloBtn->setInactiveGraphic(embed::getIconPixmap("solo_inactive"));
m_soloBtn->setCheckable(true);
m_soloBtn->setObjectName("btn-solo");
m_soloBtn->setToolTip(tr("Solo this instrument"));
soloMuteLayout->addWidget(m_soloBtn, 0, widgetAlignment);

View File

@@ -83,7 +83,7 @@ TrackOperationsWidget::TrackOperationsWidget( TrackView * parent ) :
// buttons in a layout.
auto operationsWidget = new QWidget(this);
auto operationsLayout = new QHBoxLayout(operationsWidget);
operationsLayout->setContentsMargins(0, 3, 0, 0);
operationsLayout->setContentsMargins(2, 6, 0, 6);
operationsLayout->setSpacing(2);
m_trackOps = new QPushButton(operationsWidget);
@@ -91,44 +91,18 @@ TrackOperationsWidget::TrackOperationsWidget( TrackView * parent ) :
m_trackOps->setMenu( toMenu );
m_trackOps->setToolTip(tr("Actions"));
// This helper lambda wraps a PixmapButton in a QWidget. This is necessary due to some strange effect where the
// PixmapButtons are resized to a size that's larger than their minimum/fixed size when the method "show" is called
// in "TrackContainerView::realignTracks". Specifically, with the default theme the buttons are resized from
// (16, 14) to (26, 26). This then makes them behave not as expected in layouts.
// The resizing is not done for QWidgets. Therefore we wrap the PixmapButton in a QWidget which is set to a
// fixed size that will be able to show the active and inactive pixmap. We can then use the QWidget in layouts
// without any disturbances.
//
// The resizing only seems to affect the track view hierarchy and is triggered by Qt's internal mechanisms.
// For example the buttons in the mixer view do not seem to be affected.
// If you want to debug this simply override "PixmapButton::resizeEvent" and trigger a break point in there.
auto buildPixmapButtonWrappedInWidget = [](QWidget* parent, const QString& toolTip,
std::string_view activeGraphic, std::string_view inactiveGraphic, PixmapButton*& pixmapButton)
{
const auto activePixmap = embed::getIconPixmap(activeGraphic);
const auto inactivePixmap = embed::getIconPixmap(inactiveGraphic);
auto wrapperWidget = new QWidget(parent);
auto button = new PixmapButton(wrapperWidget, toolTip);
button->setCheckable(true);
button->setActiveGraphic(activePixmap);
button->setInactiveGraphic(inactivePixmap);
button->setToolTip(toolTip);
wrapperWidget->setFixedSize(button->minimumSizeHint());
pixmapButton = button;
return wrapperWidget;
};
auto muteWidget = buildPixmapButtonWrappedInWidget(operationsWidget, tr("Mute"), "mute_active", "mute_inactive", m_muteBtn);
auto soloWidget = buildPixmapButtonWrappedInWidget(operationsWidget, tr("Solo"), "solo_active", "solo_inactive", m_soloBtn);
m_muteBtn = new AutomatableButton(operationsWidget, tr("Mute"));
m_muteBtn->setCheckable(true);
m_muteBtn->setToolTip(tr("Mute"));
m_muteBtn->setObjectName("btn-mute");
m_soloBtn = new AutomatableButton(operationsWidget, tr("Solo"));
m_soloBtn->setCheckable(true);
m_soloBtn->setToolTip(tr("Solo"));
m_soloBtn->setObjectName("btn-solo");
operationsLayout->addWidget(m_trackOps);
operationsLayout->addWidget(muteWidget);
operationsLayout->addWidget(soloWidget);
operationsLayout->addWidget(m_muteBtn);
operationsLayout->addWidget(m_soloBtn);
layout->addWidget(operationsWidget, 0, Qt::AlignTop | Qt::AlignLeading);