1 /**************************************************************************/
2 /* Copyright 2009 Tim Day */
3 /* */
4 /* This file is part of Fracplanet */
5 /* */
6 /* Fracplanet is free software: you can redistribute it and/or modify */
7 /* it under the terms of the GNU General Public License as published by */
8 /* the Free Software Foundation, either version 3 of the License, or */
9 /* (at your option) any later version. */
10 /* */
11 /* Fracplanet is distributed in the hope that it will be useful, */
12 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
13 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
14 /* GNU General Public License for more details. */
15 /* */
16 /* You should have received a copy of the GNU General Public License */
17 /* along with Fracplanet. If not, see <http://www.gnu.org/licenses/>. */
18 /**************************************************************************/
19
20 #include "control.h"
21
Control()22 Control::Control()
23 :QWidget()
24 {
25 setLayout(new QVBoxLayout());
26 }
27
~Control()28 Control::~Control()
29 {}
30
pickColour(QPushButton * button,FloatRGBA & colour)31 void Control::pickColour(QPushButton* button,FloatRGBA& colour)
32 {
33 const ByteRGBA col_old(colour);
34 QColor qcol_old(col_old.r,col_old.g,col_old.b);
35 QColor qcol_new=QColorDialog::getColor(qcol_old,this);
36 if (qcol_new.isValid())
37 {
38 colour=FloatRGBA(ByteRGBA(qcol_new.red(),qcol_new.green(),qcol_new.blue(),255));
39
40 QPixmap pmap(16,16);
41 pmap.fill(qcol_new);
42 button->setIcon(QIcon(pmap));
43 }
44 }
45
46 /*! Used when initialising colour-chooser buttons.
47 */
build_icon_of_colour(const FloatRGBA & col)48 QIcon Control::build_icon_of_colour(const FloatRGBA& col)
49 {
50 QPixmap pmap(16,16);
51
52 const ByteRGBA bcol(col);
53 pmap.fill(QColor(bcol.r,bcol.g,bcol.b));
54 return QIcon(pmap);
55 }
56
57