]> code.delx.au - virtualtones/blobdiff - pianoinstrument.cpp
README update
[virtualtones] / pianoinstrument.cpp
index 67ebc13a9f211d9de5d89bed50dcdfdbd0b88c4d..cc8bc6990a9a90d9d2d9b47451634338e1d09e0f 100644 (file)
@@ -1,25 +1,20 @@
 // pianoinstrument.cpp - A piano simulator
-// Written by James Bunton <james@delx.cjb.net>
+// Written by James Bunton <james@delx.net.au>
 // Licensed under the GPL, see COPYING.txt for more details
 
 
 #include "pianoinstrument.h"
 
-
+using namespace Qt;
 
 
 PianoInstrument::PianoInstrument(QWidget *parent)
 : Instrument(parent)
 {
-       // Set us up to look pretty
-       setPaletteBackgroundPixmap(QPixmap("piano.png"));
-       setFixedSize(184, 220);
-       parentWidget()->setFixedSize(184, 220);
+       background.load("piano.png");
 
-       for(int i = 0; i < 26; i++) {
-               oldNotes[i] = false;
-               notes[i] = false;
-       }
+       memset(oldNotes, 0, sizeof(oldNotes));
+       memset(notes, 0, sizeof(notes));
 
        noteStart = 48;
 
@@ -40,11 +35,12 @@ QString PianoInstrument::generateHelp()
 
 "Playing the keyboard:"
 "<ul>"
-"<li>You can change the octave using the &quot;Octave&quot; box above. Middle C is the third octave</li>"
+"<li>You can change the octave using the &quot;Base Octave&quot; box above. Middle C is the third octave</li>"
 "<li>The keys - qwertyui are the top row white keys</li>"
 "<li>The keys - 23 567 9 are the top row black keys</li>"
 "<li>The keys - zxcvbnm, are the bottom row white keys</li>"
 "<li>The keys - sd ghj l are the bottom row black keys</li>"
+"<li>When you push a key, the note it corresponds to is highlighted</li>"
 "</ul>"
 
 "</html>"
@@ -56,6 +52,9 @@ QString PianoInstrument::generateHelp()
 void PianoInstrument::paintEvent(QPaintEvent *)
 {
        QPainter paint(this);
+
+       paint.drawPixmap(0, 0, background);
+
        paint.setPen(Qt::red);
 
        const int topBlackY = 38;
@@ -384,4 +383,3 @@ void PianoInstrument::emitSounds()
 
        repaint();
 }
-