Enable mixer color-coding (#5589)

* Enable mixer color-coding

* Cleanup

* Fix warnings

* Improvements

* Improvements

* Use ColorChooser instead of QColorDialog

* Fix default palette being out of range

* Remove a redundant function

* Rename and make stuff efficient

* Comment on the code

* Make things more efficient

* Fix breaking builds

* Improvements

* Improvements pt. 2

* Improvements pt. 3

* Improvements pt. 4

* Improvements pt. 5

* Apply suggestions from code review

Co-authored-by: Hyunjin Song <tteu.ingog@gmail.com>

Co-authored-by: Hyunjin Song <tteu.ingog@gmail.com>
This commit is contained in:
Kumar
2020-08-11 14:31:58 +05:30
committed by GitHub
parent f2887bda68
commit 1bb8d12e99
7 changed files with 186 additions and 7 deletions

View File

@@ -21,21 +21,39 @@
*
*/
#include <QColorDialog>
#include <QApplication>
#include <QColor>
#include <QColorDialog>
#include <QKeyEvent>
#include <QVector>
class ColorChooser: public QColorDialog
{
public:
ColorChooser(const QColor &initial, QWidget *parent): QColorDialog(initial, parent) {};
ColorChooser(QWidget *parent): QColorDialog(parent) {};
//! For getting a color without having to initialise a color dialog
ColorChooser() {};
enum class Palette {Default, Track, Mixer};
//! Set global palette via array, checking bounds
void setPalette (QVector<QColor>);
//! Set global paletter via enum
void setPalette (Palette);
//! Set palette via enum, return self pointer for chaining
ColorChooser* withPalette (Palette);
//! Return a certain palette
static QVector<QColor> getPalette (Palette);
protected:
// Forward key events to the parent to prevent stuck notes when the dialog gets focus
//! Forward key events to the parent to prevent stuck notes when the dialog gets focus
void keyReleaseEvent(QKeyEvent *event) override
{
QKeyEvent ke(*event);
QApplication::sendEvent(parentWidget(), &ke);
}
private:
//! Copy the current QColorDialog palette into an array
static QVector<QColor> defaultPalette();
//! Generate a nice palette, with adjustable value
static QVector<QColor> nicePalette (int);
};

View File

@@ -26,10 +26,12 @@
#ifndef FX_LINE_H
#define FX_LINE_H
#include <QColorDialog>
#include <QGraphicsView>
#include <QLineEdit>
#include <QWidget>
#include "ColorChooser.h"
#include "Knob.h"
#include "LcdWidget.h"
#include "SendButtonIndicator.h"
@@ -101,6 +103,9 @@ private:
public slots:
void renameChannel();
void resetColor();
void changeColor();
void randomColor();
private slots:
void renameFinished();

View File

@@ -32,6 +32,8 @@
#include <atomic>
#include <QColor>
class FxRoute;
typedef QVector<FxRoute *> FxRouteVector;
@@ -70,6 +72,11 @@ class FxChannel : public ThreadableJob
bool requiresProcessing() const override { return true; }
void unmuteForSolo();
// TODO C++17 and above: use std::optional insteads
QColor m_color;
bool m_hasColor;
std::atomic_int m_dependenciesMet;
void incrementDeps();