forked from LMMS/lmms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable mixer color-coding (LMMS#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>
- Loading branch information
Showing
7 changed files
with
186 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* ColorChooser.cpp - definition of ColorChooser class. | ||
* | ||
* Copyright (c) 2020 russiankumar <adityakumar4644/at/gmail/dot/com> | ||
* | ||
* This file is part of LMMS - https://lmms.io | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public | ||
* License along with this program (see COPYING); if not, write to the | ||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
* Boston, MA 02110-1301 USA. | ||
* | ||
*/ | ||
|
||
#include <ColorChooser.h> | ||
|
||
|
||
|
||
|
||
//! Set global palette via array, checking bounds | ||
void ColorChooser::setPalette (QVector<QColor> colors) | ||
{ | ||
const int max = qMin (colors.size(), 48); | ||
for (int i = 0; i < max; i++) | ||
{ | ||
ColorChooser::setStandardColor (i, colors[i]); | ||
} | ||
} | ||
|
||
|
||
//! Set global paletter via enum | ||
void ColorChooser::setPalette (Palette palette) | ||
{ | ||
setPalette (getPalette (palette)); | ||
} | ||
|
||
|
||
//! Set palette via enum, return self pointer for chaining | ||
ColorChooser* ColorChooser::withPalette (Palette palette) | ||
{ | ||
setPalette (palette); | ||
return this; | ||
} | ||
|
||
|
||
//! Return a certain palette | ||
QVector<QColor> ColorChooser::getPalette (Palette palette) | ||
{ | ||
switch (palette) | ||
{ | ||
case Palette::Mixer: return nicePalette(140); | ||
case Palette::Track: return nicePalette(150); | ||
default: return defaultPalette(); | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
//! Copy the current QColorDialog palette into an array | ||
QVector<QColor> ColorChooser::defaultPalette() | ||
{ | ||
QVector <QColor> result (48); | ||
for (int i = 0; i < 48; i++) | ||
{ | ||
result[i] = (QColorDialog::standardColor(i)); | ||
} | ||
return result; | ||
} | ||
|
||
|
||
//! Generate a nice palette, with adjustable value | ||
QVector<QColor> ColorChooser::nicePalette (int base) | ||
{ | ||
QVector <QColor> result (48); | ||
for (int x = 0; x < 8; x++) | ||
{ | ||
for (int y = 0; y < 6; y++) | ||
{ | ||
result[6 * x + y].setHsl (qMax(0, 44 * x - 1), 150 - 20 * y, base - 10 * y); | ||
} | ||
} | ||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters