Sun, 07 Sep 2014 04:11:55 +0300
- fixed: due to a shared pointer called via reference called dismiss() in LDDocument::closeInitialFile, this could cause LDDocuments to delete themselves in setImplicit(true) as no shared pointers were left inside closeInitialFile to keep the refcount up.
- fixed: bad QMap iteration after erase in the gl compiler
how diabolic can bugs get? *shudder*
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
844
11587d419d2f
- changed copyright lines to use my legal name instead of my nickname
Teemu Piippo <crimsondusk64@gmail.com>
parents:
840
diff
changeset
|
3 | * Copyright (C) 2013, 2014 Teemu Piippo |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | * ===================================================================== |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | * colorSelectDialog.cxx: Color selector box. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | */ |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | #include <QGraphicsScene> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | #include <QGraphicsItem> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | #include <QMouseEvent> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | #include <QScrollBar> |
795
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
26 | #include <QColorDialog> |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | #include "main.h" |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | #include "mainWindow.h" |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | #include "colorSelector.h" |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | #include "colors.h" |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | #include "configuration.h" |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | #include "miscallenous.h" |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | #include "ui_colorsel.h" |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | static const int g_numColumns = 16; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | |
852
cbd89b33f70d
- down with all these unnecessary semicolons!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
850
diff
changeset
|
37 | EXTERN_CFGENTRY (String, MainColor) |
cbd89b33f70d
- down with all these unnecessary semicolons!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
850
diff
changeset
|
38 | EXTERN_CFGENTRY (Float, MainColorAlpha) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
39 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
40 | // ============================================================================= |
795
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
41 | // |
878
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
42 | ColorSelector::ColorSelector (LDColor defaultvalue, QWidget* parent) : |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
43 | QDialog (parent) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
45 | m_firstResize = true; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
46 | ui = new Ui_ColorSelUI; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
47 | ui->setupUi (this); |
878
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
48 | setSelection (defaultvalue); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
49 | |
878
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
50 | QGridLayout* layout = new QGridLayout (this); |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
51 | |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
52 | // Spawn color selector buttons |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
53 | for (int i = 0; i < CountLDConfigColors(); ++i) |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
54 | { |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
55 | LDColor ldcolor = LDColor::fromIndex (i); |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
56 | QPushButton* button = new QPushButton (this); |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
57 | button->setMinimumSize (QSize (32, 32)); |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
58 | button->setMaximumSize (button->minimumSize()); |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
59 | |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
60 | if (ldcolor != null) |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
61 | { |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
62 | QString colorname; |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
63 | QColor color (ldcolor.faceColor()); |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
64 | |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
65 | if (i == MainColorIndex) |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
66 | { |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
67 | color = QColor (cfg::MainColor); |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
68 | color.setAlphaF (cfg::MainColorAlpha); |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
69 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
70 | |
878
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
71 | QString color2name (Luma (color) < 80 ? "white" : "black"); |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
72 | button->setAutoFillBackground (true); |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
73 | button->setStyleSheet (format ("background-color: rgba(%1, %2, %3, %4); color: %5", |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
74 | color.red(), color.green(), color.blue(), color.alpha(), color2name)); |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
75 | button->setCheckable (true); |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
76 | button->setText (QString::number (ldcolor.index())); |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
77 | button->setToolTip (format ("%1: %2", ldcolor.index(), ldcolor.name())); |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
78 | m_buttons[i] = button; |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
79 | m_buttonsReversed[button] = i; |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
80 | connect (button, SIGNAL (clicked(bool)), this, SLOT (colorButtonClicked())); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
81 | |
878
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
82 | if (ldcolor == selection()) |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
83 | button->setChecked (true); |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
84 | } |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
85 | else |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
86 | { |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
87 | button->setEnabled (false); |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
88 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
89 | |
878
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
90 | layout->addWidget (button, i / g_numColumns, i % g_numColumns); |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
91 | } |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
92 | |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
93 | QWidget* widget = new QWidget(); |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
94 | widget->setLayout (layout); |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
95 | ui->definedColors->setWidget (widget); |
795
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
96 | connect (ui->directColor, SIGNAL (clicked (bool)), this, SLOT (chooseDirectColor())); |
801
f6abc9eb4217
- made transparent direct colors a compile-time opt-in since it appears to be non-standard
Santeri Piippo <crimsondusk64@gmail.com>
parents:
796
diff
changeset
|
97 | |
878
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
98 | ui->definedColors->setMinimumWidth (ui->definedColors->widget()->width() + 16); |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
99 | |
801
f6abc9eb4217
- made transparent direct colors a compile-time opt-in since it appears to be non-standard
Santeri Piippo <crimsondusk64@gmail.com>
parents:
796
diff
changeset
|
100 | #ifdef TRANSPARENT_DIRECT_COLORS |
795
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
101 | connect (ui->transparentDirectColor, SIGNAL (clicked (bool)), this, SLOT (transparentCheckboxClicked())); |
801
f6abc9eb4217
- made transparent direct colors a compile-time opt-in since it appears to be non-standard
Santeri Piippo <crimsondusk64@gmail.com>
parents:
796
diff
changeset
|
102 | #else |
f6abc9eb4217
- made transparent direct colors a compile-time opt-in since it appears to be non-standard
Santeri Piippo <crimsondusk64@gmail.com>
parents:
796
diff
changeset
|
103 | ui->transparentDirectColor->hide(); |
f6abc9eb4217
- made transparent direct colors a compile-time opt-in since it appears to be non-standard
Santeri Piippo <crimsondusk64@gmail.com>
parents:
796
diff
changeset
|
104 | #endif |
795
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
105 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
106 | drawColorInfo(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
107 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
108 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
109 | // ============================================================================= |
795
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
110 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
111 | ColorSelector::~ColorSelector() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
112 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
113 | delete ui; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
114 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
115 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
116 | // ============================================================================= |
795
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
117 | // |
878
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
118 | void ColorSelector::colorButtonClicked() |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
119 | { |
878
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
120 | QPushButton* button = qobject_cast<QPushButton*> (sender()); |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
121 | auto it = m_buttonsReversed.find (button); |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
122 | LDColor color; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
123 | |
878
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
124 | if (Q_UNLIKELY (button == null or it == m_buttonsReversed.end() |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
125 | or (color = LDColor::fromIndex (*it)) == null)) |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
126 | { |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
127 | print ("colorButtonClicked() called with invalid sender"); |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
128 | return; |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
129 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
130 | |
878
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
131 | if (selection() != null) |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
132 | { |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
133 | auto it2 = m_buttons.find (selection().index()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
134 | |
878
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
135 | if (it2 != m_buttons.end()) |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
136 | (*it2)->setChecked (false); |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
137 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
138 | |
878
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
139 | setSelection (color); |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
140 | button->setChecked (true); |
945e44575b3e
- changed the unorthodox color selection grid into a push button grid
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
141 | drawColorInfo(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
142 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
143 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
144 | // ============================================================================= |
795
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
145 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
146 | void ColorSelector::drawColorInfo() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
147 | { |
795
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
148 | if (selection() == null) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
149 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
150 | ui->colorLabel->setText ("---"); |
855
e16f1587ef44
- fixed compilation on windows systems
Santeri Piippo <crimsondusk64@gmail.com>
parents:
852
diff
changeset
|
151 | ui->iconLabel->setPixmap (QPixmap()); |
795
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
152 | ui->transparentDirectColor->setChecked (false); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
153 | return; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
154 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
155 | |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
801
diff
changeset
|
156 | ui->colorLabel->setText (format ("%1 - %2", selection().indexString(), |
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
801
diff
changeset
|
157 | (selection().isDirect() ? "<direct color>" : selection().name()))); |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
158 | ui->iconLabel->setPixmap (MakeColorIcon (selection(), 16).pixmap (16, 16)); |
801
f6abc9eb4217
- made transparent direct colors a compile-time opt-in since it appears to be non-standard
Santeri Piippo <crimsondusk64@gmail.com>
parents:
796
diff
changeset
|
159 | |
f6abc9eb4217
- made transparent direct colors a compile-time opt-in since it appears to be non-standard
Santeri Piippo <crimsondusk64@gmail.com>
parents:
796
diff
changeset
|
160 | #ifdef TRANSPARENT_DIRECT_COLORS |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
801
diff
changeset
|
161 | ui->transparentDirectColor->setEnabled (selection().isDirect()); |
840
d077dd19bf9a
- changed `&&` and `||` operators to their named variants `and` and `or`
Teemu Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
162 | ui->transparentDirectColor->setChecked (selection().isDirect() and selection().faceColor().alphaF() < 1.0); |
801
f6abc9eb4217
- made transparent direct colors a compile-time opt-in since it appears to be non-standard
Santeri Piippo <crimsondusk64@gmail.com>
parents:
796
diff
changeset
|
163 | #else |
f6abc9eb4217
- made transparent direct colors a compile-time opt-in since it appears to be non-standard
Santeri Piippo <crimsondusk64@gmail.com>
parents:
796
diff
changeset
|
164 | ui->transparentDirectColor->setChecked (false); |
f6abc9eb4217
- made transparent direct colors a compile-time opt-in since it appears to be non-standard
Santeri Piippo <crimsondusk64@gmail.com>
parents:
796
diff
changeset
|
165 | ui->transparentDirectColor->setEnabled (false); |
f6abc9eb4217
- made transparent direct colors a compile-time opt-in since it appears to be non-standard
Santeri Piippo <crimsondusk64@gmail.com>
parents:
796
diff
changeset
|
166 | #endif |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
167 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
168 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
169 | // ============================================================================= |
795
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
170 | // |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
171 | void ColorSelector::selectDirectColor (QColor col) |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
172 | { |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
173 | int32 idx = (ui->transparentDirectColor->isChecked() ? 0x03000000 : 0x02000000); |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
174 | idx |= (col.red() << 16) | (col.green() << 8) | (col.blue()); |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
175 | setSelection (LDColor::fromIndex (idx)); |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
176 | drawColorInfo(); |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
177 | } |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
178 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
179 | // ============================================================================= |
795
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
180 | // |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
181 | void ColorSelector::chooseDirectColor() |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
182 | { |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
801
diff
changeset
|
183 | QColor defcolor = selection() != null ? selection().faceColor() : Qt::white; |
795
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
184 | QColor newcolor = QColorDialog::getColor (defcolor); |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
185 | |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
186 | if (not newcolor.isValid()) |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
187 | return; // canceled |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
188 | |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
189 | selectDirectColor (newcolor); |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
190 | } |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
191 | |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
192 | // ============================================================================= |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
193 | // |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
194 | void ColorSelector::transparentCheckboxClicked() |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
195 | { |
840
d077dd19bf9a
- changed `&&` and `||` operators to their named variants `and` and `or`
Teemu Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
196 | if (selection() == null or not selection().isDirect()) |
795
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
197 | return; |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
198 | |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
801
diff
changeset
|
199 | selectDirectColor (selection().faceColor()); |
795
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
200 | } |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
201 | |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
202 | // ============================================================================= |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
203 | // |
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
204 | bool ColorSelector::selectColor (LDColor& val, LDColor defval, QWidget* parent) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
205 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
206 | ColorSelector dlg (defval, parent); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
207 | |
840
d077dd19bf9a
- changed `&&` and `||` operators to their named variants `and` and `or`
Teemu Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
208 | if (dlg.exec() and dlg.selection() != null) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
209 | { |
795
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
210 | val = dlg.selection(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
211 | return true; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
212 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
213 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
214 | return false; |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
215 | } |