Piano: refactored class to be usable without friend classes

This commit is contained in:
Tobias Doerffel
2014-01-14 23:12:02 +01:00
parent 340789c191
commit c40b8350ef
5 changed files with 93 additions and 103 deletions

View File

@@ -1,7 +1,7 @@
/*
* Piano.h - declaration of class Piano
*
* Copyright (c) 2004-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -40,24 +40,40 @@ public:
BlackKey
} ;
Piano( InstrumentTrack * _it );
Piano( InstrumentTrack* track );
virtual ~Piano();
void setKeyState( int _key, bool _on = false );
void setKeyState( int key, bool state );
void handleKeyPress( int _key );
void handleKeyRelease( int _key );
bool isKeyPressed( int key ) const
{
return m_pressedKeys[key];
}
void handleKeyPress( int key );
void handleKeyRelease( int key );
InstrumentTrack* instrumentTrack() const
{
return m_instrumentTrack;
}
MidiEventProcessor* midiEventProcessor() const
{
return m_midiEvProc;
}
private:
InstrumentTrack * m_instrumentTrack;
MidiEventProcessor * m_midiEvProc;
static bool isValidKey( int key )
{
return key >= 0 && key < NumKeys;
}
InstrumentTrack* m_instrumentTrack;
MidiEventProcessor* m_midiEvProc;
bool m_pressedKeys[NumKeys];
friend class PianoView;
friend class pianoRoll;
} ;
#endif

View File

@@ -2,7 +2,7 @@
* piano_roll.h - declaration of class pianoRoll which is a window where you
* can set and edit notes in an easy way
*
* Copyright (c) 2004-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2008 Andrew Kelley <superjoe30/at/gmail/dot/com>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
@@ -50,7 +50,6 @@ class pattern;
class timeLine;
class toolButton;
class Piano;
class pianoRoll : public QWidget, public SerializingObject
{
Q_OBJECT
@@ -154,7 +153,6 @@ signals:
private:
Piano * m_piano;
enum editModes
{
ModeDraw,