|
From: Tapio V. <aa...@us...> - 2011-02-23 18:51:58
|
Author: Tapio Vierros <tap...@gm...>
Date: Wed Feb 23 20:50:41 2011 +0200
Remove a couple of duplicate "magic numbers".
---
editorapp.cc | 11 +++++++----
notegraphwidget.cc | 5 +++--
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/editorapp.cc b/editorapp.cc
index 2254125..5fa4043 100644
--- a/editorapp.cc
+++ b/editorapp.cc
@@ -954,7 +954,10 @@ void Piano::updatePixmap(NoteGraphWidget *ngw)
{
if (!ngw) return;
const int notes = 12 * 4; // Four octaves
+ const QColor borderColor = QColor("#c0c0c0");
+ const QColor selectionColor = QColor("#090");
int noteHeight = ngw->n2px(0) - ngw->n2px(1);
+
QImage image(50, notes * noteHeight, QImage::Format_ARGB32_Premultiplied);
image.fill(qRgba(0, 0, 0, 0));
setFixedSize(image.width(), image.height());
@@ -970,8 +973,8 @@ void Piano::updatePixmap(NoteGraphWidget *ngw)
int y2 = image.height() - i * noteHeight; // Note center y
y2 -= (scale.isSharp(i + 1) ? 1.0 : 0.5) * noteHeight; // Key top y
// Pick border color according to selection status
- if (selectionMatches(i, ngw)) pen.setColor(QColor("#090"));
- else pen.setColor(QColor("#c0c0c0"));
+ if (selectionMatches(i, ngw)) pen.setColor(selectionColor);
+ else pen.setColor(borderColor);
painter.setPen(pen);
// Skip the first key because y hasn't been calculated yet
if (i > -1) {
@@ -986,8 +989,8 @@ void Piano::updatePixmap(NoteGraphWidget *ngw)
if (!scale.isSharp(i)) continue;
y = image.height() - i*noteHeight - noteHeight / 2;
// Pick border color according to selection status
- if (selectionMatches(i, ngw)) pen.setColor(QColor("#090"));
- else pen.setColor(QColor("#c0c0c0"));
+ if (selectionMatches(i, ngw)) pen.setColor(selectionColor);
+ else pen.setColor(borderColor);
painter.setPen(pen);
painter.fillRect(0, y, w, noteHeight, QColor("#000000"));
painter.drawRect(0, y, w, noteHeight);
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index e51dc39..ecbc311 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -24,6 +24,7 @@ namespace {
}
static const double endMarginSeconds = 5.0;
+ static const int NoteGraphHeight = 768;
}
@@ -39,7 +40,7 @@ NoteGraphWidget::NoteGraphWidget(QWidget *parent)
// Initially expanding horizontally to fill the space
QSizePolicy sp(QSizePolicy::Expanding, QSizePolicy::Fixed);
setSizePolicy(sp);
- setFixedHeight(768);
+ setFixedHeight(NoteGraphHeight);
setFocusPolicy(Qt::StrongFocus);
setAcceptDrops(true);
@@ -696,7 +697,7 @@ QString NoteGraphWidget::dumpLyrics() const
SeekHandle::SeekHandle(QWidget *parent)
: QLabel(parent)
{
- QImage image(8, 768, QImage::Format_ARGB32_Premultiplied);
+ QImage image(8, NoteGraphHeight, QImage::Format_ARGB32_Premultiplied);
image.fill(qRgba(128, 128, 128, 128));
setPixmap(QPixmap::fromImage(image));
setMouseTracking(true);
|