#include <PianoView.h>
|
| static int | getKeyFromKeyEvent (QKeyEvent *_ke) |
| | Map a keyboard key being pressed to a note in our keyboard view.
|
◆ PianoView()
| lmms::gui::PianoView::PianoView |
( |
QWidget * | parent | ) |
|
Create a new keyboard display view.
- Parameters
-
| _parent | the parent instrument plugin window |
- Todo
- are the descriptions of the m_startkey and m_lastkey properties correct?
< Our parent
< Our view Model
< Our piano Model
< The first key displayed?
< The last key displayed?
< Key marker which is being moved
◆ ~PianoView()
| lmms::gui::PianoView::~PianoView |
( |
| ) |
|
|
overridedefault |
◆ baseNoteChanged
| void lmms::gui::PianoView::baseNoteChanged |
( |
| ) |
|
|
signal |
◆ contextMenuEvent()
| void lmms::gui::PianoView::contextMenuEvent |
( |
QContextMenuEvent * | me | ) |
|
|
overrideprotected |
Handle a context menu selection on the piano display view.
- Parameters
-
| me | the ContextMenuEvent to handle. |
- Todo
- Is this right, or does this create the context menu?
◆ focusInEvent()
| void lmms::gui::PianoView::focusInEvent |
( |
QFocusEvent * | fe | ) |
|
|
overrideprotected |
◆ focusOutEvent()
| void lmms::gui::PianoView::focusOutEvent |
( |
QFocusEvent * | _fe | ) |
|
|
overrideprotected |
Handle the focus leaving the piano display view.
Turn off all notes if we lose focus.
- Todo
- Is there supposed to be a parameter given here?
◆ getKeyFromKeyEvent()
| int lmms::gui::PianoView::getKeyFromKeyEvent |
( |
QKeyEvent * | _ke | ) |
|
|
static |
Map a keyboard key being pressed to a note in our keyboard view.
◆ getKeyFromMouse()
| int lmms::gui::PianoView::getKeyFromMouse |
( |
const QPoint & | p | ) |
const |
|
private |
Get the key from the mouse position in the piano display.
- Parameters
-
| p | The point that the mouse was pressed. |
◆ getKeyHeight()
| int lmms::gui::PianoView::getKeyHeight |
( |
int | key_num | ) |
const |
|
private |
Return the height of a given key.
◆ getKeyWidth()
| int lmms::gui::PianoView::getKeyWidth |
( |
int | key_num | ) |
const |
|
private |
Return the width of a given key.
◆ getKeyX()
| int lmms::gui::PianoView::getKeyX |
( |
int | _key_num | ) |
const |
|
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.
- Parameters
-
| _key_num | the keyboard key to translate |
- Todo
is this description of what the method does correct?
replace the final subtract with initialising x to width/2.
◆ getNearestMarker()
Return model and title of the marker closest to the given key.
◆ keyPressed
| void lmms::gui::PianoView::keyPressed |
( |
int | | ) |
|
|
signal |
◆ keyPressEvent()
| void lmms::gui::PianoView::keyPressEvent |
( |
QKeyEvent * | _ke | ) |
|
|
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.
- Parameters
-
| _ke | the KeyEvent to handle. |
◆ keyReleaseEvent()
| void lmms::gui::PianoView::keyReleaseEvent |
( |
QKeyEvent * | _ke | ) |
|
|
override |
Handle a key release event on the piano display view.
The same logic as the keyPressEvent() method.
- Parameters
-
| _ke | the KeyEvent to handle. |
◆ modelChanged()
| void lmms::gui::PianoView::modelChanged |
( |
| ) |
|
|
overrideprotectedvirtual |
◆ mouseMoveEvent()
| void lmms::gui::PianoView::mouseMoveEvent |
( |
QMouseEvent * | _me | ) |
|
|
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).
- Parameters
-
| _me | the ContextMenuEvent to handle. |
- Todo
- Paul Wayper thinks that this code should be refactored to reduce or remove the duplication between this, the mousePressEvent() and mouseReleaseEvent() methods.
◆ mousePressEvent()
| void lmms::gui::PianoView::mousePressEvent |
( |
QMouseEvent * | me | ) |
|
|
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
- Parameters
-
| me | the mouse click to handle. |
◆ mouseReleaseEvent()
| void lmms::gui::PianoView::mouseReleaseEvent |
( |
QMouseEvent * | me | ) |
|
|
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.
- Parameters
-
| _me | the mousePressEvent to handle. |
◆ paintEvent()
| void lmms::gui::PianoView::paintEvent |
( |
QPaintEvent * | | ) |
|
|
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.
- Todo
- Is there supposed to be a parameter given here?
◆ pianoScrolled
| void lmms::gui::PianoView::pianoScrolled |
( |
int | newPos | ) |
|
|
privateslot |
Handle the scrolling on the piano display view.
We need to update our start key position based on the new position.
- Parameters
-
| newPos | the new key position, counting only white keys. |
◆ resizeEvent()
| void lmms::gui::PianoView::resizeEvent |
( |
QResizeEvent * | event | ) |
|
|
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.
- Parameters
-
| Event | resize-event object (unused) |
◆ m_blackKeyDisabledPm
◆ m_blackKeyPm
◆ m_blackKeyPressedPm
◆ m_lastKey
| int lmms::gui::PianoView::m_lastKey |
|
private |
◆ m_movedNoteModel
| IntModel* lmms::gui::PianoView::m_movedNoteModel |
|
private |
note marker which is being moved
◆ m_piano
| Piano* lmms::gui::PianoView::m_piano |
|
private |
◆ m_pianoScroll
| QScrollBar* lmms::gui::PianoView::m_pianoScroll |
|
private |
◆ m_startKey
| int lmms::gui::PianoView::m_startKey |
|
private |
◆ m_whiteKeyDisabledPm
◆ m_whiteKeyPm
◆ m_whiteKeyPressedPm
The documentation for this class was generated from the following files:
- /home/runner/work/lmms-fork/lmms-fork/include/PianoView.h
- /home/runner/work/lmms-fork/lmms-fork/src/gui/instrument/PianoView.cpp