20 #ifndef KEYBOARDGRAPHICSVIEW_H
21 #define KEYBOARDGRAPHICSVIEW_H
23 #include <QGraphicsView>
24 #include <QGraphicsScene>
25 #include <QGraphicsRectItem>
26 #include <QGraphicsPixmapItem>
27 #include "../core/system/log.h"
28 #include "../core/piano/keyboard.h"
29 #include "../core/messages/messagelistener.h"
164 void selectKey(int8_t key0,
KeyState keyState,
bool notifyMessageListeners =
true);
169 virtual QSize
sizeHint() const override final {
return QSize(0, 200);}
176 void showEvent(QShowEvent *event)
override;
379 #endif // KEYBOARDGRAPHICSVIEW_H
void mouseMoveEvent(QMouseEvent *event) override
void redrawAllMarkers()
Force all markers to update its state.
std::shared_ptr< Message > MessagePtr
Global type of a shared message pointer.
const Key * getSelectedKey() const
KeyState mSelectedKeyState
The key state of the selected key.
void changeTotalNumberOfKeys(int keys, int keyA)
Function to change the total number of keys and the key number of A.
static const QColor KEY_SELECTED_UNRECORDED_COLOR
Color of the selected key if it is not recorded.
static const QColor KEY_SELECTED_RECORDED_COLOR
Color of the selected key if it is recorded.
int8_t getSelectedKeyIndex() const
Getter for mSelectedKey.
const Keyboard * getKeyboard() const
Getter for mKeyboard.
static const QColor KEY_PRELIMINARY_COLOR
Color of the preliminary key.
void setKeyColor(int8_t key)
Function to set the key color of key.
void handleMessage(MessagePtr m) override
Message handling.
Class describing the piano keyboard, holding a collection of keys.
int mKeyNumberOfA
The keynumber of A of the given mKeyboard.
const Keyboard * mKeyboard
Pointer to the keyboard that is displayed.
static const int NO_KEY
No key selection constant.
virtual QSize sizeHint() const overridefinal
static const qreal KEY_BLACK_TO_WHITE_RATIO
Size ratio of black and white keys.
const Key & at(size_t i) const
void mousePressEvent(QMouseEvent *event) override
The mouse press will select the klicked key.
virtual void scrollContentsBy(int dx, int dy) overridefinal
std::vector< QGraphicsRectItem * > mKeysGraphicsItems
List of all key items.
static const qreal KEY_WIDTH
Width of a single key.
static const qreal KEY_WHITE_KEY_SIZE
Size of a white key (a bit bigger than KEY_WIDTH)
static const qreal PEN_MEDIUM_LINE
Medium pen line width.
KeyboardGraphicsView(QWidget *parent)
Constructor.
void deselectKey(bool notifyListeners=true)
Slot to deselect a key.
Class describing a single piano key.
int getKeyAtPosition(const QPoint &pos)
Function to get the key index at the given position.
static const QColor KEY_PRELIMINARY_AND_SELECTED_COLOR
Color if the preliminary key equates the selected key.
QList< AutoScaledToKeyboardGraphicsView * > mAutoScaledGraphicsViews
List of other graphic views that are scaled along this keyboard view.
void selectKey(int8_t key0, KeyState keyState, bool notifyMessageListeners=true)
Function to select or deselect a key.
static const qreal KEY_FORCED_FACTOR
Color scaling if the key is forced.
void resizeEvent(QResizeEvent *event) override
Reimplemented to keep the complete scene rect in the view.
void selectionChanged(int8_t key)
Signal beeing emitted if the selected key changed.
void resetKey(int8_t key)
Function to reset the key and marker color to the unselected state.
std::vector< QGraphicsPixmapItem * > mMarkerPixmapItems
List of all marker items.
static const qreal PEN_THIN_LINE
Thin pen line width.
int8_t mSelectedKey
The selected key.
int8_t mPreliminaryKey
The preliminary key.
void setKeyboard(const Keyboard *kb)
Setter for mKeyboard.
KeyColor
The KeyColor enum.
void setSelection(int key, KeyState state, int preliminary)
Function to set the current selection.
int heightForWidth(int w) const override
Get the height for a given view width.
void centerOnKey(int8_t key)
This function will center the view on the given key.
int8_t mCenterOnKey
Index of the key to center on.
void addAutoScaledGraphicsView(AutoScaledToKeyboardGraphicsView *view)
Function to add a AutoScaledToKeyboardGraphicsView.
QRectF keyShape(int8_t key0)
Returns a QRectF as shape of the given key.
KeyState getSelectedKeyState() const
Getter for mSelectedKeyState.
static const qreal TOTAL_HEIGHT
Total height of the view.
void showEvent(QShowEvent *event) override
Reimplemented to keep the complete scene rect in the view.
void selectNext()
Slot that will select the next key.
static const qreal KEY_SPACING_TO_MARKERS
Space between keys and markers.
void keyPressEvent(QKeyEvent *event) override
Handler for key presses.
void updateColorMarker(int8_t key0)
Function to update a single color marker.
void selectPrevious()
Slot that will select the previous key.
const QGraphicsScene & getScene() const
Getter for mScene.
static const qreal KEY_MARKERS_MARGIN
Margin of a single marker.
void fitAllInView()
Fit the complete scene rect in the given view.
QGraphicsScene mScene
The QGraphicsScene in which the elements will be drawed.
void selectPreliminaryKey(int8_t key0)
Function to change the prelimary key stored in mPreliminaryKey.
An GraphicsViewAdaptorForQt keeping the same size as a KeyboardGraphicsView.
static const qreal GLOBAL_SCALING
A global scaling factor.
QPixmap getPixmapForKeyRecordingState(bool recorded)
Function to get the QPixmap for the given recording state.
QColor getKeyColor(piano::KeyColor color, bool selected, KeyState keyState, bool recorded)
Function to get the key color.
KeyState
The KeyState enum.
static const qreal KEY_HEIGHT
Height of a single key.
virtual QSize minimumSizeHint() const overridefinal
int8_t getPreliminaryKey() const
Getter for mPreliminaryKey.
QRectF getVisibleContentsRect() const