Make the send button and receive arrow occupy the same space in mixer channels (#7503)
This commit is contained in:
@@ -58,12 +58,33 @@ namespace lmms::gui
|
||||
widget->setSizePolicy(sizePolicy);
|
||||
};
|
||||
|
||||
auto receiveArrowContainer = new QWidget{};
|
||||
auto receiveArrowLayout = new QVBoxLayout{receiveArrowContainer};
|
||||
m_receiveArrow = new QLabel{};
|
||||
m_receiveArrow->setPixmap(embed::getIconPixmap("receive_bg_arrow"));
|
||||
receiveArrowLayout->setContentsMargins(0, 0, 0, 0);
|
||||
receiveArrowLayout->setSpacing(0);
|
||||
receiveArrowLayout->addWidget(m_receiveArrow, 0, Qt::AlignHCenter);
|
||||
|
||||
auto sendButtonContainer = new QWidget{};
|
||||
auto sendButtonLayout = new QVBoxLayout{sendButtonContainer};
|
||||
m_sendButton = new SendButtonIndicator{this, this, mixerView};
|
||||
retainSizeWhenHidden(m_sendButton);
|
||||
sendButtonLayout->setContentsMargins(0, 0, 0, 0);
|
||||
sendButtonLayout->setSpacing(0);
|
||||
sendButtonLayout->addWidget(m_sendButton, 0, Qt::AlignHCenter);
|
||||
|
||||
m_receiveArrowOrSendButton = new QStackedWidget{this};
|
||||
m_receiveArrowStackedIndex = m_receiveArrowOrSendButton->addWidget(receiveArrowContainer);
|
||||
m_sendButtonStackedIndex = m_receiveArrowOrSendButton->addWidget(sendButtonContainer);
|
||||
retainSizeWhenHidden(m_receiveArrowOrSendButton);
|
||||
|
||||
m_sendKnob = new Knob{KnobType::Bright26, this, tr("Channel send amount")};
|
||||
retainSizeWhenHidden(m_sendKnob);
|
||||
|
||||
m_sendArrow = new QLabel{};
|
||||
m_sendArrow->setPixmap(embed::getIconPixmap("send_bg_arrow"));
|
||||
retainSizeWhenHidden(m_sendArrow);
|
||||
|
||||
m_channelNumberLcd = new LcdWidget{2, this};
|
||||
m_channelNumberLcd->setValue(channelIndex);
|
||||
retainSizeWhenHidden(m_channelNumberLcd);
|
||||
@@ -89,16 +110,6 @@ namespace lmms::gui
|
||||
renameLineEditProxy->setRotation(-90);
|
||||
m_renameLineEditView->setFixedSize(m_renameLineEdit->height() + 5, m_renameLineEdit->width() + 5);
|
||||
|
||||
m_sendArrow = new QLabel{};
|
||||
m_sendArrow->setPixmap(embed::getIconPixmap("send_bg_arrow"));
|
||||
retainSizeWhenHidden(m_sendArrow);
|
||||
m_sendArrow->setVisible(m_sendReceiveState == SendReceiveState::SendToThis);
|
||||
|
||||
m_receiveArrow = new QLabel{};
|
||||
m_receiveArrow->setPixmap(embed::getIconPixmap("receive_bg_arrow"));
|
||||
retainSizeWhenHidden(m_receiveArrow);
|
||||
m_receiveArrow->setVisible(m_sendReceiveState == SendReceiveState::ReceiveFromThis);
|
||||
|
||||
m_muteButton = new PixmapButton(this, tr("Mute"));
|
||||
m_muteButton->setModel(&mixerChannel->m_muteModel);
|
||||
m_muteButton->setActiveGraphic(embed::getIconPixmap("led_off"));
|
||||
@@ -131,8 +142,7 @@ namespace lmms::gui
|
||||
mainLayout->setContentsMargins(4, 4, 4, 4);
|
||||
mainLayout->setSpacing(2);
|
||||
|
||||
mainLayout->addWidget(m_receiveArrow, 0, Qt::AlignHCenter);
|
||||
mainLayout->addWidget(m_sendButton, 0, Qt::AlignHCenter);
|
||||
mainLayout->addWidget(m_receiveArrowOrSendButton, 0, Qt::AlignHCenter);
|
||||
mainLayout->addWidget(m_sendKnob, 0, Qt::AlignHCenter);
|
||||
mainLayout->addWidget(m_sendArrow, 0, Qt::AlignHCenter);
|
||||
mainLayout->addWidget(m_channelNumberLcd, 0, Qt::AlignHCenter);
|
||||
@@ -179,13 +189,11 @@ namespace lmms::gui
|
||||
|
||||
void MixerChannelView::paintEvent(QPaintEvent* event)
|
||||
{
|
||||
auto * mixer = Engine::mixer();
|
||||
const auto channel = mixerChannel();
|
||||
const bool muted = channel->m_muteModel.value();
|
||||
const auto name = channel->m_name;
|
||||
const auto elidedName = elideName(name);
|
||||
const auto * mixerChannelView = m_mixerView->currentMixerChannel();
|
||||
const auto isActive = mixerChannelView == this;
|
||||
const auto isActive = m_mixerView->currentMixerChannel() == this;
|
||||
|
||||
if (!m_inRename && m_renameLineEdit->text() != elidedName)
|
||||
{
|
||||
@@ -213,26 +221,6 @@ namespace lmms::gui
|
||||
painter.setPen(isActive ? strokeOuterActive() : strokeOuterInactive());
|
||||
painter.drawRect(0, 0, width - MIXER_CHANNEL_OUTER_BORDER_SIZE, height - MIXER_CHANNEL_OUTER_BORDER_SIZE);
|
||||
|
||||
const auto & currentMixerChannelIndex = mixerChannelView->m_channelIndex;
|
||||
const auto sendToThis = mixer->channelSendModel(currentMixerChannelIndex, m_channelIndex) != nullptr;
|
||||
const auto receiveFromThis = mixer->channelSendModel(m_channelIndex, currentMixerChannelIndex) != nullptr;
|
||||
const auto sendReceiveStateNone = !sendToThis && !receiveFromThis;
|
||||
|
||||
// Only one or none of them can be on
|
||||
assert(sendToThis ^ receiveFromThis || sendReceiveStateNone);
|
||||
|
||||
m_sendArrow->setVisible(sendToThis);
|
||||
m_receiveArrow->setVisible(receiveFromThis);
|
||||
|
||||
if (sendReceiveStateNone)
|
||||
{
|
||||
setSendReceiveState(SendReceiveState::None);
|
||||
}
|
||||
else
|
||||
{
|
||||
setSendReceiveState(sendToThis ? SendReceiveState::SendToThis : SendReceiveState::ReceiveFromThis);
|
||||
}
|
||||
|
||||
QWidget::paintEvent(event);
|
||||
}
|
||||
|
||||
@@ -284,18 +272,6 @@ namespace lmms::gui
|
||||
m_channelIndex = index;
|
||||
}
|
||||
|
||||
MixerChannelView::SendReceiveState MixerChannelView::sendReceiveState() const
|
||||
{
|
||||
return m_sendReceiveState;
|
||||
}
|
||||
|
||||
void MixerChannelView::setSendReceiveState(const SendReceiveState& state)
|
||||
{
|
||||
m_sendReceiveState = state;
|
||||
m_sendArrow->setVisible(state == SendReceiveState::SendToThis);
|
||||
m_receiveArrow->setVisible(state == SendReceiveState::ReceiveFromThis);
|
||||
}
|
||||
|
||||
QBrush MixerChannelView::backgroundActive() const
|
||||
{
|
||||
return m_backgroundActive;
|
||||
|
||||
@@ -343,28 +343,37 @@ void MixerView::setCurrentMixerChannel(MixerChannelView* channel)
|
||||
|
||||
void MixerView::updateMixerChannel(int index)
|
||||
{
|
||||
Mixer * mix = getMixer();
|
||||
const auto mixer = getMixer();
|
||||
|
||||
// does current channel send to this channel?
|
||||
int selIndex = m_currentMixerChannel->channelIndex();
|
||||
auto thisLine = m_mixerChannelViews[index];
|
||||
const auto currentIndex = m_currentMixerChannel->channelIndex();
|
||||
const auto thisLine = m_mixerChannelViews[index];
|
||||
thisLine->setToolTip(getMixer()->mixerChannel(index)->m_name);
|
||||
|
||||
FloatModel * sendModel = mix->channelSendModel(selIndex, index);
|
||||
if (sendModel == nullptr)
|
||||
const auto sendModelCurrentToThis = mixer->channelSendModel(currentIndex, index);
|
||||
if (sendModelCurrentToThis == nullptr)
|
||||
{
|
||||
// does not send, hide send knob
|
||||
thisLine->m_sendKnob->setVisible(false);
|
||||
thisLine->m_sendArrow->setVisible(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// it does send, show knob and connect
|
||||
thisLine->m_sendKnob->setVisible(true);
|
||||
thisLine->m_sendKnob->setModel(sendModel);
|
||||
thisLine->m_sendKnob->setModel(sendModelCurrentToThis);
|
||||
thisLine->m_sendArrow->setVisible(true);
|
||||
}
|
||||
|
||||
const auto sendModelThisToCurrent = mixer->channelSendModel(index, currentIndex);
|
||||
if (sendModelThisToCurrent)
|
||||
{
|
||||
thisLine->m_receiveArrowOrSendButton->setVisible(true);
|
||||
thisLine->m_receiveArrowOrSendButton->setCurrentIndex(thisLine->m_receiveArrowStackedIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
thisLine->m_receiveArrowOrSendButton->setVisible(!mixer->isInfiniteLoop(currentIndex, index));
|
||||
thisLine->m_receiveArrowOrSendButton->setCurrentIndex(thisLine->m_sendButtonStackedIndex);
|
||||
}
|
||||
|
||||
// disable the send button if it would cause an infinite loop
|
||||
thisLine->m_sendButton->setVisible(!mix->isInfiniteLoop(selIndex, index));
|
||||
thisLine->m_sendButton->updateLightStatus();
|
||||
thisLine->update();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user