src/dialogs/colorselector.h

changeset 1174
91696a2e022c
parent 1173
6cd85b28f43b
child 1195
fead30e6c557
equal deleted inserted replaced
1173:6cd85b28f43b 1174:91696a2e022c
20 #include <QDialog> 20 #include <QDialog>
21 #include "../main.h" 21 #include "../main.h"
22 #include "../colors.h" 22 #include "../colors.h"
23 #include "../hierarchyelement.h" 23 #include "../hierarchyelement.h"
24 24
25 /*
26 * Implements a dialog that asks the user to choose an LDraw color from a grid of available colors. Direct colors are also supported.
27 */
25 class ColorSelector : public QDialog, public HierarchyElement 28 class ColorSelector : public QDialog, public HierarchyElement
26 { 29 {
27 Q_OBJECT 30 Q_OBJECT
28 31
29 public: 32 public:
30 explicit ColorSelector (QWidget* parent, LDColor defaultvalue = LDColor::nullColor); 33 ColorSelector(QWidget* parent, LDColor defaultvalue = LDColor::nullColor);
31 virtual ~ColorSelector(); 34 ~ColorSelector();
32 static bool selectColor (QWidget* parent, LDColor& val, LDColor defval = LDColor::nullColor); 35
33 LDColor selection() const; 36 static bool selectColor(QWidget* parent, LDColor& color, LDColor defaultColor = LDColor::nullColor);
37 LDColor selectedColor() const;
38 Q_SLOT void setSelectedColor(LDColor color);
34 39
35 private: 40 private:
41 static const int columnCount = 16;
42
43 Q_SLOT void colorButtonClicked();
44 Q_SLOT void chooseDirectColor();
45 Q_SLOT void transparentCheckboxClicked();
46
36 class Ui_ColorSelUi& ui; 47 class Ui_ColorSelUi& ui;
37 QMap<LDColor, QPushButton*> m_buttons; 48 QMap<LDColor, QPushButton*> m_buttons;
38 QMap<QPushButton*, LDColor> m_buttonsReversed; 49 QMap<QPushButton*, LDColor> m_buttonsReversed;
39 bool m_firstResize; 50 LDColor m_selectedColor;
40 LDColor m_selection;
41
42 void drawColorInfo();
43 void selectDirectColor (QColor col);
44
45 private slots:
46 void colorButtonClicked();
47 void chooseDirectColor();
48 void transparentCheckboxClicked();
49 }; 51 };

mercurial