Skip to content

Commit

Permalink
Fix a display bug
Browse files Browse the repository at this point in the history
  • Loading branch information
messmerd committed Aug 17, 2024
1 parent 8445f2c commit ecc6318
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 37 deletions.
2 changes: 0 additions & 2 deletions include/PluginPinConnector.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,7 @@ class LMMS_EXPORT PluginPinConnector
static constexpr std::size_t MaxTrackChannels = 256; // TODO: Move somewhere else

public slots:

void updateTrackChannels(int count);
void updateConnectionLabels();

private:
static void saveSettings(const Matrix& matrix, QDomDocument& doc, QDomElement& elem);
Expand Down
17 changes: 0 additions & 17 deletions src/core/PluginPinConnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,6 @@
*
*/

/*
TODO:
- Methods to set custom plugin channel names
- Remember to emit dataChanged signal
- Give BoolModels a name for automation
- New icons?
- Testing! (esp. loading/saving)
*/


#include "PluginPinConnector.h"

#include <QDomDocument>
Expand Down Expand Up @@ -305,8 +295,6 @@ void PluginPinConnector::saveSettings(QDomDocument& doc, QDomElement& elem)
auto pins = doc.createElement(nodeName());
elem.appendChild(pins);

pins.setAttribute("v", 0); // version

if (m_trackChannelsUsed != s_totalTrackChannels)
{
pins.setAttribute("tc_used", m_trackChannelsUsed);
Expand Down Expand Up @@ -556,9 +544,4 @@ void PluginPinConnector::updateTrackChannels(int count)
emit propertiesChanged();
}

void PluginPinConnector::updateConnectionLabels()
{

}

} // namespace lmms
46 changes: 28 additions & 18 deletions src/gui/PluginPinConnectorView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ namespace
{

constexpr auto CenterMargin = QSize{48, 0};
constexpr auto WindowMarginTop = QSize{0, 144};
constexpr auto WindowMarginBottom = QSize{0, 48};
constexpr auto WindowMarginSide = QSize{64, 0};
constexpr auto WindowMarginTop = QSize{0, 96};
constexpr auto WindowMarginBottom = QSize{0, 32};
constexpr auto WindowMarginSide = QSize{48, 0};
constexpr auto WindowMarginTotal = WindowMarginTop + WindowMarginBottom + WindowMarginSide + WindowMarginSide;
constexpr auto DefaultWindowSize = QSize{400, 256};
constexpr auto DefaultMaxWindowSize = QSize{400, 256};

} // namespace

Expand Down Expand Up @@ -100,7 +100,8 @@ PluginPinConnectorView::PluginPinConnectorView(PluginPinConnector* model, QWidge
m_subWindow->setWindowFlags(flags);

auto hLayout = new QHBoxLayout{};
hLayout->addWidget(m_inView, 1, Qt::AlignmentFlag::AlignRight);
hLayout->addSpacing(WindowMarginSide.width());
hLayout->addWidget(m_inView, 0, Qt::AlignmentFlag::AlignRight);

auto getSpacerWidth = [&]() {
const bool singleMatrix = model->trackChannelsUsed() == 0
Expand All @@ -116,7 +117,8 @@ PluginPinConnectorView::PluginPinConnectorView(PluginPinConnector* model, QWidge
});
hLayout->addSpacerItem(spacer);

hLayout->addWidget(m_outView, 1, Qt::AlignmentFlag::AlignLeft);
hLayout->addWidget(m_outView, 0, Qt::AlignmentFlag::AlignLeft);
hLayout->addSpacing(WindowMarginSide.width());


auto vLayout = new QVBoxLayout{this};
Expand Down Expand Up @@ -148,8 +150,8 @@ auto PluginPinConnectorView::minimumSizeHint() const -> QSize
{
const auto minSize = sizeHint();
return QSize {
std::min(minSize.width(), DefaultWindowSize.width()),
std::min(minSize.height(), DefaultWindowSize.height())
std::min(minSize.width(), DefaultMaxWindowSize.width()),
std::min(minSize.height(), DefaultMaxWindowSize.height())
};
}

Expand Down Expand Up @@ -196,31 +198,38 @@ void PluginPinConnectorView::paintEvent(QPaintEvent*)
auto outMatrixRect = m_outView->rect();
outMatrixRect.moveTo(m_outView->pos());

// Draw track channel text
const auto xwIn = std::pair{0, inMatrixRect.left() - 4};
const auto xwOut = std::pair{outMatrixRect.right() + 4, width() - outMatrixRect.right() - 4};
int yPos = inMatrixRect.y();
for (unsigned idx = 0; idx < model->trackChannelsUsed(); ++idx)
// Draw track channel text (in)
if (model->in().channelCount != 0)
{
if (model->in().channelCount != 0)
const auto xwIn = std::pair{0, inMatrixRect.left() - 4};
int yPos = inMatrixRect.y();
for (unsigned idx = 0; idx < model->trackChannelsUsed(); ++idx)
{
p.drawText(xwIn.first, yPos, xwIn.second, textSize.height(), Qt::AlignRight,
QString::fromUtf16(u"%1 \U0001F82E").arg(idx + 1));

yPos += cellSize.height();
}
}

if (model->out().channelCount != 0)
// Draw track channel text (out)
if (model->out().channelCount != 0)
{
const auto xwOut = std::pair{outMatrixRect.right() + 4, width() - outMatrixRect.right() - 4};
int yPos = outMatrixRect.y();
for (unsigned idx = 0; idx < model->trackChannelsUsed(); ++idx)
{
p.drawText(xwOut.first, yPos, xwOut.second, textSize.height(), Qt::AlignLeft,
QString::fromUtf16(u"\U0001F82E %1").arg(idx + 1));
}

yPos += cellSize.height();
yPos += cellSize.height();
}
}

p.save();

// Draw plugin channel text (in)
yPos = inMatrixRect.top() - 4;
int yPos = inMatrixRect.top() - 4;
int xPos = inMatrixRect.x() + 2;
for (int idx = 0; idx < model->in().channelCount; ++idx)
{
Expand All @@ -234,6 +243,7 @@ void PluginPinConnectorView::paintEvent(QPaintEvent*)
}

// Draw plugin channel text (out)
yPos = outMatrixRect.top() - 4;
xPos = outMatrixRect.x() + 2;
for (int idx = 0; idx < model->out().channelCount; ++idx)
{
Expand Down

0 comments on commit ecc6318

Please sign in to comment.