|
lmms
Cross-platform music production software
|
#include <PianoView.h>
Signals | |
| void | keyPressed (int) |
| void | baseNoteChanged () |
Public Member Functions | |
| PianoView (QWidget *parent) | |
| Create a new keyboard display view. | |
| ~PianoView () override=default | |
| void | keyPressEvent (QKeyEvent *ke) override |
| Handle a key press event on the piano display view. | |
| void | keyReleaseEvent (QKeyEvent *ke) override |
| Handle a key release event on the piano display view. | |
| Public Member Functions inherited from lmms::gui::ModelView | |
| ModelView (Model *model, QWidget *widget) | |
| virtual | ~ModelView () |
| virtual void | setModel (Model *model, bool isOldModelValid=true) |
| virtual void | unsetModel () |
| Model * | model () |
| const Model * | model () const |
| template<class T> | |
| T * | castModel () |
| template<class T> | |
| const T * | castModel () const |
Static Public Member Functions | |
| static int | getKeyFromKeyEvent (QKeyEvent *_ke) |
| Map a keyboard key being pressed to a note in our keyboard view. | |
Protected Member Functions | |
| void | modelChanged () override |
| Register a change to this piano display view. | |
| void | contextMenuEvent (QContextMenuEvent *me) override |
| Handle a context menu selection on the piano display view. | |
| void | paintEvent (QPaintEvent *) override |
| Paint the piano display view in response to an event. | |
| void | mousePressEvent (QMouseEvent *me) override |
| Handle a mouse click on this piano display view. | |
| void | mouseReleaseEvent (QMouseEvent *me) override |
| Handle a mouse release event on the piano display view. | |
| void | mouseMoveEvent (QMouseEvent *me) override |
| Handle a mouse move event on the piano display view. | |
| void | focusOutEvent (QFocusEvent *) override |
| Handle the focus leaving the piano display view. | |
| void | focusInEvent (QFocusEvent *fe) override |
| void | resizeEvent (QResizeEvent *) override |
| update scrollbar range after resize | |
| Protected Member Functions inherited from lmms::gui::ModelView | |
| QWidget * | widget () |
| virtual void | doConnections () |
Private Slots | |
| void | pianoScrolled (int newPos) |
| Handle the scrolling on the piano display view. | |
Private Member Functions | |
| int | getKeyFromMouse (const QPoint &p) const |
| Get the key from the mouse position in the piano display. | |
| int | getKeyX (int key_num) const |
| Convert a key number to an X coordinate in the piano display view. | |
| int | getKeyWidth (int key_num) const |
| Return the width of a given key. | |
| int | getKeyHeight (int key_num) const |
| Return the height of a given key. | |
| IntModel * | getNearestMarker (int key, QString *title=nullptr) |
| Return model and title of the marker closest to the given key. | |
Private Attributes | |
| QPixmap | m_whiteKeyPm = embed::getIconPixmap("white_key") |
| QPixmap | m_blackKeyPm = embed::getIconPixmap("black_key") |
| QPixmap | m_whiteKeyPressedPm = embed::getIconPixmap("white_key_pressed") |
| QPixmap | m_blackKeyPressedPm = embed::getIconPixmap("black_key_pressed") |
| QPixmap | m_whiteKeyDisabledPm = embed::getIconPixmap("white_key_disabled") |
| QPixmap | m_blackKeyDisabledPm = embed::getIconPixmap("black_key_disabled") |
| Piano * | m_piano = nullptr |
| QScrollBar * | m_pianoScroll |
| int | m_startKey |
| first key when drawing | |
| int | m_lastKey = -1 |
| previously pressed key | |
| IntModel * | m_movedNoteModel = nullptr |
| note marker which is being moved | |
| lmms::gui::PianoView::PianoView | ( | QWidget * | parent | ) |
Create a new keyboard display view.
| parent | the parent instrument plugin window |
|
overridedefault |
|
signal |
|
overrideprotected |
Handle a context menu selection on the piano display view.
| me | The ContextMenuEvent to handle. |
|
overrideprotected |
|
overrideprotected |
Handle the focus leaving the piano display view.
Turn off all notes if we lose focus.
|
static |
Map a keyboard key being pressed to a note in our keyboard view.
|
private |
Get the key from the mouse position in the piano display.
| p | The point that the mouse was pressed. |
|
private |
Return the height of a given key.
|
private |
Return the width of a given key.
|
private |
Convert a key number to an X coordinate in the piano display view.
We can immediately discard the trivial case of when the key number is less than our starting key. We then iterate through the keys from the start key to this key, adding the width of each key as we go. For black keys, and the first white key if there is no black key between two white keys, we add half a white key width; for that second white key, we add a whole width. That takes us to the boundary of a white key - subtract half a width to get to the middle.
| key_num | the keyboard key to translate |
|
private |
Return model and title of the marker closest to the given key.
|
signal |
|
override |
Handle a key press event on the piano display view.
We determine our key number from the getKeyFromKeyEvent() method, and pass the event on to the piano's handleKeyPress() method if auto-repeat is off.
| ke | the KeyEvent to handle. |
|
override |
Handle a key release event on the piano display view.
The same logic as the keyPressEvent() method.
| ke | the KeyEvent to handle. |
|
overrideprotectedvirtual |
Register a change to this piano display view.
Reimplemented from lmms::gui::ModelView.
|
overrideprotected |
Handle a mouse move event on the piano display view.
This handles the user dragging the mouse across the keys. It uses code from mousePressEvent() and mouseReleaseEvent(), also correcting for if the mouse movement has stayed within one key and if the mouse has moved outside the vertical area of the keyboard (which is still allowed but won't make the volume go up to 11).
| me | the ContextMenuEvent to handle. |
|
overrideprotected |
Handle a mouse click on this piano display view.
We first determine the key number using the getKeyFromMouse() method.
If we're below the 'root key selection' area, we set the volume of the note to be proportional to the vertical position on the keyboard - lower down the key is louder, within the boundaries of the (white or black) key pressed. We then tell the instrument to play that note, scaling for MIDI max loudness = 127.
If we're in the 'root key selection' area, of course, we set the root key to be that key.
We finally update ourselves to show the key press
| me | the mouse click to handle. |
|
overrideprotected |
Handle a mouse release event on the piano display view.
If a key was pressed by the in the mousePressEvent() function, we turn the note off.
| me | the mousePressEvent to handle. |
|
overrideprotected |
Paint the piano display view in response to an event.
This method draws the piano and the 'root note' base. It draws the base first, then all the white keys, then all the black keys.
|
privateslot |
Handle the scrolling on the piano display view.
We need to update our start key position based on the new position.
| newPos | the new key position, counting only white keys. |
|
overrideprotected |
update scrollbar range after resize
After resizing we need to adjust range of scrollbar for not allowing to scroll too far to the right.
|
private |
|
private |
|
private |
|
private |
previously pressed key
|
private |
note marker which is being moved
|
private |
|
private |
|
private |
first key when drawing
|
private |
|
private |
|
private |