File indexing completed on 2024-05-12 16:34:16

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2007 Marijn Kruisselbrink <mkruisselbrink@kde.org>
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Library General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2 of the License, or (at your option) any later version.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012  * Library General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Library General Public License
0015  * along with this library; see the file COPYING.LIB.  If not, write to
0016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018  */
0019 #ifndef MUSIC_STYLE_H
0020 #define MUSIC_STYLE_H
0021 
0022 #include "core/Global.h"
0023 #include "core/Clef.h"
0024 
0025 #include <QPen>
0026 #include <QPainter>
0027 
0028 /**
0029  * This class contains various methods that define how music is rendered. Currently all hardcoded
0030  * implementations, but in the future this class would become pure virtual, with various implementations.
0031  */
0032 class MusicStyle {
0033 public:
0034     MusicStyle();
0035     virtual ~MusicStyle();
0036     virtual QPen staffLinePen(const QColor& color = Qt::black);
0037     virtual QPen stemPen(const QColor& color = Qt::black);
0038     virtual QPen noteDotPen(const QColor& color = Qt::black);
0039     virtual qreal beamLineWidth();
0040     virtual void renderNoteHead(QPainter& painter, qreal x, qreal y, MusicCore::Duration duration, const QColor& color = Qt::black);
0041     virtual void renderRest(QPainter& painter, qreal x, qreal y, MusicCore::Duration duration, const QColor& color = Qt::black);
0042     virtual void renderClef(QPainter& painter, qreal x, qreal y, MusicCore::Clef::ClefShape shape, const QColor& color = Qt::black);
0043     virtual void renderAccidental(QPainter& painter, qreal x, qreal y, int accidental, const QColor& color = Qt::black);
0044     virtual void renderTimeSignatureNumber(QPainter& painter, qreal x, qreal y, qreal w, int number, const QColor& color = Qt::black);
0045     virtual void renderNoteFlags(QPainter& painter, qreal x, qreal y, MusicCore::Duration duration, bool stemsUp, const QColor& color = Qt::black);
0046     /**
0047      * Render text either as text or as path, as specified by the textAsPath value
0048      */
0049     virtual void renderText(QPainter& painter, qreal x, qreal y, const QString& text);
0050     /**
0051      * Whether to render text as paths. Default value is false (render text as text)
0052      */
0053     virtual void setTextAsPath(bool drawTextAsPath);
0054     /**
0055      * Whether to render text as paths
0056      */
0057     virtual bool textAsPath() const;
0058 private:
0059     QPen m_staffLinePen, m_stemPen, m_noteDotPen;
0060     QFont m_font;
0061     bool m_textAsPath;
0062 };
0063 
0064 #endif // MUSIC_STYLE_H