6#include <QDoubleValidator>
7#include <QGraphicsSceneMouseEvent>
11#include <QResizeEvent>
13#include <QDialogButtonBox>
19#ifdef SEEXPR_USE_QDGUI
20#include <qdgui/QdColorPickerDialog.h>
28 setFrameStyle(QFrame::Box | QFrame::Plain);
29 QPalette pal = palette();
30 pal.setColor(backgroundRole(), pal.highlight().color());
32 setAutoFillBackground(
true);
46 p.fillRect(contentsRect(),
_color);
50 if (event->button() == Qt::RightButton)
54#ifdef SEEXPR_USE_QDGUI
55 QColor color = QdColorPickerDialog::chooseColorFromDialog(
_color,
this);
57 QColor color = QColorDialog::getColor(
_color);
60 if (color.isValid()) {
61 _value[0] = color.red() / 255.0;
62 _value[1] = color.green() / 255.0;
63 _value[2] = color.blue() / 255.0;
73 QMenu *menu =
new QMenu(
this);
74 QAction *deleteAction = menu->addAction(
"Delete Swatch");
75 menu->addAction(
"Cancel");
76 QAction *action = menu->exec(mapToGlobal(pos));
86 QVBoxLayout *vbox =
new QVBoxLayout();
87 vbox->setContentsMargins(0, 0, 0, 0);
92 std::stringstream indexSS;
94 QLabel *label =
new QLabel(indexSS.str().c_str());
95 vbox->addWidget(label);
106 : QWidget(parent), _columns(8), _indexLabel(indexLabel) {
107 QHBoxLayout *hboxLayout =
new QHBoxLayout();
108 hboxLayout->setContentsMargins(0, 0, 0, 0);
109 setLayout(hboxLayout);
111 QPushButton *addBtn =
new QPushButton(
"+");
112 addBtn->setFixedWidth(16);
113 addBtn->setFixedHeight(16);
114 QVBoxLayout *swatchControlLayout =
new QVBoxLayout();
115 swatchControlLayout->setContentsMargins(0, 0, 0, 0);
116 QHBoxLayout *addRemoveBtnLayout =
new QHBoxLayout();
117 addRemoveBtnLayout->setContentsMargins(0, 0, 0, 0);
118 addRemoveBtnLayout->setSpacing(0);
119 addRemoveBtnLayout->addWidget(addBtn);
120 swatchControlLayout->addLayout(addRemoveBtnLayout);
121 swatchControlLayout->addStretch();
123 QHBoxLayout *paletteLayout =
new QHBoxLayout();
124 paletteLayout->setContentsMargins(0, 0, 0, 0);
125 QWidget *colorGrid =
new QWidget();
126 colorGrid->setMinimumWidth(256);
131 paletteLayout->addStretch();
132 colorGrid->setLayout(paletteLayout);
134 hboxLayout->addWidget(colorGrid);
135 hboxLayout->addLayout(swatchControlLayout);
136 hboxLayout->addStretch();
139 connect(addBtn, SIGNAL(clicked()),
this, SLOT(
addNewColor()));
166 QWidget *parentWidget = widget->parentWidget();
169 if (
_gridLayout->itemAt(i)->widget() == parentWidget) {
171 parentWidget->deleteLater();
179 if (
index >= 0 && index < _gridLayout->count()) {
180 SeExpr2::Vec3d newColor(color.redF(), color.greenF(), color.blueF());
182 if (layoutItem && layoutItem->widget()) {
183 QWidget *widget = layoutItem->widget();
191 if (
index >= 0 && index < _gridLayout->count()) {
193 if (layoutItem && layoutItem->widget()) {
194 QWidget *widget = layoutItem->widget();
197 return QColor::fromRgbF(val[0], val[1], val[2], 1);
void selValChangedSignal(SeExpr2::Vec3d value)
void deleteSwatchMenu(const QPoint &pos)
ExprColorFrame(SeExpr2::Vec3d value, QWidget *parent=0)
void swatchChanged(QColor color)
virtual void mouseReleaseEvent(QMouseEvent *event)
virtual void paintEvent(QPaintEvent *event)
void setValue(const SeExpr2::Vec3d &value)
SeExpr2::Vec3d getValue() const
void deleteSwatch(ExprColorFrame *swatch)
The result is computed int int< br >< div style="margin-left: 40px;"> Picks values randomly between loRange and hiRange based on supplied index(which is automatically hashed).  
For any rgb or hsl value(except for negative s values)