mirror of https://github.com/AxioDL/amuse.git
ADSREditor: Use std::array for m_percentTexts
Same behavior, but allows for stronger typing and dehardcoding of sizes.
This commit is contained in:
parent
9b482ba013
commit
344dbea31a
|
@ -55,8 +55,8 @@ void ADSRView::paintEvent(QPaintEvent* ev) {
|
||||||
painter.setPen(QPen(QColor(127, 127, 127), penWidth));
|
painter.setPen(QPen(QColor(127, 127, 127), penWidth));
|
||||||
painter.setFont(m_gridFont);
|
painter.setFont(m_gridFont);
|
||||||
const qreal yIncrement = (height() - 16.0) / 10.0;
|
const qreal yIncrement = (height() - 16.0) / 10.0;
|
||||||
for (int i = 0; i < 11; ++i) {
|
for (size_t i = 0; i < m_percentTexts.size(); ++i) {
|
||||||
const qreal thisY = i * yIncrement;
|
const qreal thisY = qreal(i) * yIncrement;
|
||||||
const qreal textY = thisY - (i == 0 ? 2.0 : (i == 10 ? 16.0 : 8.0));
|
const qreal textY = thisY - (i == 0 ? 2.0 : (i == 10 ? 16.0 : 8.0));
|
||||||
painter.drawStaticText(QPointF(0.0, textY), m_percentTexts[i]);
|
painter.drawStaticText(QPointF(0.0, textY), m_percentTexts[i]);
|
||||||
painter.drawLine(QPointF(30.0, thisY), QPointF(width(), thisY));
|
painter.drawLine(QPointF(30.0, thisY), QPointF(width(), thisY));
|
||||||
|
@ -212,7 +212,7 @@ void ADSRView::mouseMoveEvent(QMouseEvent* ev) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ADSRView::ADSRView(QWidget* parent) : QWidget(parent) {
|
ADSRView::ADSRView(QWidget* parent) : QWidget(parent) {
|
||||||
for (int i = 0; i < 11; ++i) {
|
for (size_t i = 0; i < m_percentTexts.size(); ++i) {
|
||||||
m_percentTexts[i].setText(QStringLiteral("%1%").arg(100 - i * 10));
|
m_percentTexts[i].setText(QStringLiteral("%1%").arg(100 - i * 10));
|
||||||
m_percentTexts[i].setTextOption(QTextOption(Qt::AlignVCenter | Qt::AlignRight));
|
m_percentTexts[i].setTextOption(QTextOption(Qt::AlignVCenter | Qt::AlignRight));
|
||||||
m_percentTexts[i].setTextWidth(28.0);
|
m_percentTexts[i].setTextWidth(28.0);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -22,7 +23,7 @@ class ADSRView : public QWidget {
|
||||||
friend class ADSRControls;
|
friend class ADSRControls;
|
||||||
amuse::ObjToken<ProjectModel::ADSRNode> m_node;
|
amuse::ObjToken<ProjectModel::ADSRNode> m_node;
|
||||||
QFont m_gridFont;
|
QFont m_gridFont;
|
||||||
QStaticText m_percentTexts[11];
|
std::array<QStaticText, 11> m_percentTexts;
|
||||||
std::vector<QStaticText> m_timeTexts;
|
std::vector<QStaticText> m_timeTexts;
|
||||||
int m_dragPoint = -1;
|
int m_dragPoint = -1;
|
||||||
uint64_t m_cycleIdx = 0;
|
uint64_t m_cycleIdx = 0;
|
||||||
|
|
Loading…
Reference in New Issue