LMMS
Loading...
Searching...
No Matches
ColorChooser.h
Go to the documentation of this file.
1/* ColorChooser.h - declaration and definition of ColorChooser class.
2 *
3 * Copyright (c) 2019 CYBERDEViLNL <cyberdevilnl/at/protonmail/dot/ch>
4 *
5 * This file is part of LMMS - https://lmms.io
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public
18 * License along with this program (see COPYING); if not, write to the
19 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301 USA.
21 *
22 */
23
24#ifndef LMMS_GUI_COLOR_CHOOSER_H
25#define LMMS_GUI_COLOR_CHOOSER_H
26
27#include <QApplication>
28#include <QColor>
29#include <QColorDialog>
30#include <QKeyEvent>
31#include <QVector>
32
33namespace lmms::gui
34{
35
36
37class ColorChooser : public QColorDialog
38{
39public:
40 ColorChooser(const QColor &initial, QWidget *parent): QColorDialog(initial, parent) {};
41 ColorChooser(QWidget *parent): QColorDialog(parent) {};
43 ColorChooser() = default;
44 enum class Palette {Default, Track, Mixer};
46 void setPalette (QVector<QColor>);
48 void setPalette (Palette);
52 static QVector<QColor> getPalette (Palette);
53
54protected:
56 void keyReleaseEvent(QKeyEvent *event) override
57 {
58 QApplication::sendEvent(parentWidget(), event);
59 }
60private:
62 static QVector<QColor> defaultPalette();
64 static QVector<QColor> nicePalette (int);
65};
66
67
68} // namespace lmms::gui
69
70#endif // LMMS_GUI_COLOR_CHOOSER_H
Definition Mixer.h:139
Base-class for all tracks.
Definition Track.h:68
Definition ColorChooser.h:38
void setPalette(QVector< QColor >)
Set global palette via array, checking bounds.
Definition ColorChooser.cpp:32
static QVector< QColor > nicePalette(int)
Generate a nice palette, with adjustable value.
Definition ColorChooser.cpp:84
static QVector< QColor > getPalette(Palette)
Return a certain palette.
Definition ColorChooser.cpp:58
ColorChooser * withPalette(Palette)
Set palette via enum, return self pointer for chaining.
Definition ColorChooser.cpp:50
ColorChooser(const QColor &initial, QWidget *parent)
Definition ColorChooser.h:40
void keyReleaseEvent(QKeyEvent *event) override
Forward key events to the parent to prevent stuck notes when the dialog gets focus.
Definition ColorChooser.h:56
static QVector< QColor > defaultPalette()
Copy the current QColorDialog palette into an array.
Definition ColorChooser.cpp:72
ColorChooser(QWidget *parent)
Definition ColorChooser.h:41
ColorChooser()=default
For getting a color without having to initialise a color dialog.
Palette
Definition ColorChooser.h:44
@ Default
Definition ColorChooser.h:44
static uintptr_t parent
Definition pugl.h:1644
Definition AudioPortAudio.cpp:223