30KeyLabel::KeyLabel(QGraphicsItem *parent) : QGraphicsTextItem(parent)
32 setAcceptedMouseButtons(Qt::NoButton);
35void KeyLabel::adjust()
39 PianoKey* key =
static_cast<PianoKey*
>(parentItem());
40 kr = key->boundingRect();
47 if (rotation() == 0) {
48 ax += (kr.width() - br.width()) / 2;
51 ax += (kr.width() - br.height()) / 2;
54 m_savedColor = defaultTextColor();
57void KeyLabel::setOrientation(LabelOrientation ori)
59 if (m_orientation != ori) {
61 switch(m_orientation) {
76void KeyLabel::restoreColor()
78 if (m_savedColor.isValid()) {
79 setDefaultTextColor(m_savedColor);
83void drumstick::widgets::KeyLabel::calculateRotation()
85 PianoKey* key =
static_cast<PianoKey*
>(parentItem());
87 kr = key->boundingRect();
89 if (br.width() > kr.width()) {
96void KeyLabel::setPlainText(
const QString &text)
98 QGraphicsTextItem::setPlainText(text);
100 if (m_orientation == AutomaticOrientation) {
105void KeyLabel::setHtml(
const QString &text)
107 QGraphicsTextItem::setHtml(text);
109 if (m_orientation == AutomaticOrientation) {
Declaration of the KeyLabel class.
Declaration of the PianoKey class.