drumstick 2.10.0
C++ MIDI libraries using Qt objects, idioms, and style.
pianopalette.h
Go to the documentation of this file.
1/*
2 MIDI Virtual Piano Keyboard
3 Copyright (C) 2008-2024, Pedro Lopez-Cabanillas <plcl@users.sf.net>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with this program; If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#ifndef PIANOPALETTE_H
20#define PIANOPALETTE_H
21
22#include <QGuiApplication>
23#include <QString>
24#include <QColor>
25#include <QList>
26#include "macros.h"
27
32
33#if defined(DRUMSTICK_STATIC)
34#define DRUMSTICK_WIDGETS_EXPORT
35#else
36#if defined(drumstick_widgets_EXPORTS)
37#define DRUMSTICK_WIDGETS_EXPORT Q_DECL_EXPORT
38#else
39#define DRUMSTICK_WIDGETS_EXPORT Q_DECL_IMPORT
40#endif
41#endif
42
43namespace drumstick { namespace widgets {
44
64
70class DRUMSTICK_WIDGETS_EXPORT PianoPalette
71{
72 Q_GADGET
73 Q_DECLARE_TR_FUNCTIONS(PianoPalette)
74 Q_ENUM(PalettePolicy)
75
76public:
77 explicit PianoPalette(const int id);
78 virtual ~PianoPalette() = default;
79
80 void resetColors();
81 void retranslateStrings();
82
83 int paletteId() const;
84 int getNumColors() const;
85 bool isHighLight() const;
86 bool isBackground() const;
87 bool isForeground() const;
88
89 QString paletteName() const;
90 void setPaletteName(const QString& name);
91
92 QString paletteText() const;
93 void setPaletteText(const QString& text);
94
95 QColor getColor(const int i) const;
96 void setColor(const int n, const QString& s, const QColor& c);
97 void setColor(const int n, const QColor& c);
98
99 QString getColorName(const int i) const;
100 void setColorName(const int n, const QString& s);
101
102 void saveColors() const;
103 void loadColors();
104
105 bool operator==(const PianoPalette& other) const;
106 bool operator!=(const PianoPalette& other) const;
107
108 static const QString QSTR_PALETTEPREFIX;
109
110 friend QDataStream &operator<<(QDataStream& stream, const PianoPalette& palette);
111 friend QDataStream &operator>>(QDataStream& stream, PianoPalette& palette);
112
113protected:
114 void initialize();
115 void resetPaletteSingle();
116 void resetPaletteDouble();
118 void resetPaletteScale();
119 void resetPaletteKeys();
120 void resetPaletteFont();
127
128 int m_paletteId;
129 QList<QColor> m_colors;
130 QList<QString> m_names;
131 QString m_paletteName;
132 QString m_paletteText;
133};
134
136
137}} // namespace drumstick::widgets
138
139#endif // PIANOPALETTE_H
void resetPaletteChannels()
PianoPalette::resetPaletteChannels resets the colors to the standard values for the PAL_CHANNELS pale...
void resetPaletteKeys()
PianoPalette::resetPaletteKeys resets the colors to the standard values for the PAL_KEYS palette poli...
PianoPalette(const int id)
PianoPalette::PianoPalette Constructor.
void initialize()
PianoPalette::initialize reserves and initializes space to store colors according to the palette poli...
int getNumColors() const
PianoPalette::getNumColors palette policy colors size.
bool isBackground() const
PianoPalette::isBackground palette function.
void retranslatePaletteSingle()
PianoPalette::retranslatePaletteSingle retranslates the color names for the PAL_SINGLE palette policy...
QString paletteText() const
PianoPalette::paletteText gets the palette description.
friend QDataStream & operator>>(QDataStream &stream, PianoPalette &palette)
Deserialize a PianoPalette instance from a QDataStream.
void retranslatePaletteDouble()
PianoPalette::retranslatePaletteDouble retranslates the color names for the PAL_DOUBLE palette policy...
QString getColorName(const int i) const
PianoPalette::getColorName gets a palette color name.
void retranslatePaletteFont()
PianoPalette::retranslatePaletteFont retranslates the color names for the PAL_FONT palette policy.
void retranslateStrings()
PianoPalette::retranslateStrings retranslates the names and description texts according to the palett...
void retranslatePaletteScale()
PianoPalette::retranslatePaletteScale retranslates the color names for the PAL_SCALE palette policy.
static const QString QSTR_PALETTEPREFIX
PianoPalette::QSTR_PALETTEPREFIX is the string prefix for all the settings stored as persisting setti...
bool operator!=(const PianoPalette &other) const
PianoPalette::operator != compares two palettes.
void resetPaletteSingle()
PianoPalette::resetPaletteSingle resets the colors to the standard values for the PAL_SINGLE palette ...
bool isForeground() const
PianoPalette::isForeground palette function.
QString paletteName() const
PianoPalette::paletteName palette policy name.
bool isHighLight() const
PianoPalette::isHighLight palette function.
int paletteId() const
PianoPalette::paletteId palette policy.
void saveColors() const
PianoPalette::saveColors stores the set of colors as persistent settings.
void setColor(const int n, const QString &s, const QColor &c)
PianoPalette::setColor changes a palette color.
void resetColors()
PianoPalette::resetColors resets the colors to the standard values according to the palette policy id...
void setPaletteName(const QString &name)
PianoPalette::setPaletteName changes the palette name.
void resetPaletteDouble()
PianoPalette::resetPaletteDouble resets the colors to the standard values for the PAL_DOUBLE palette ...
void loadColors()
PianoPalette::loadColors loads the set of colors from persistent settings.
friend QDataStream & operator<<(QDataStream &stream, const PianoPalette &palette)
Serialize a PianoPalette instance into a QDataStream.
void retranslatePaletteChannels()
PianoPalette::retranslatePaletteChannels retranslates the color names for the PAL_CHANNELS palette po...
void resetPaletteScale()
PianoPalette::resetPaletteScale resets the colors to the standard values for the PAL_SCALE palette po...
void retranslatePaletteKeys()
PianoPalette::retranslatePaletteKeys retranslates the color names for the PAL_KEYS palette policy.
QColor getColor(const int i) const
PianoPalette::getColor gets a palette color.
void setPaletteText(const QString &text)
PianoPalette::setPaletteText changes the palette description.
void setColorName(const int n, const QString &s)
PianoPalette::setColorName changes a palette color name.
void resetPaletteFont()
PianoPalette::resetPaletteFont resets the colors to the standard values for the PAL_FONT palette poli...
bool operator==(const PianoPalette &other) const
PianoPalette::operator == compares two palettes.
PalettePolicy
The PalettePolicy enumeration.
@ PAL_SCALE
Background colors for each chromatic scale note.
@ PAL_SINGLE
Single highlihgting color for all keys.
@ PAL_HISCALE
Highlighting colors for each chromatic scale note.
@ PAL_CHANNELS
Different highlihgting colors for each channel.
@ PAL_KEYS
Two background colors (naturals/alterations)
@ PAL_DOUBLE
Two highlihgting colors (naturals/alterations)
@ PAL_FONT
Foreground font colors for names.
Drumstick Widgets library MIDI related widgets and functions.
Drumstick common.