ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
qtcolorpicker.cpp
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #include "qtcolorpicker.h"
9 
10 #include <math.h>
11 
12 #include <QApplication>
13 #include <QColorDialog>
14 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
15 #include <QDesktopWidget>
16 #endif
17 #include <QFocusEvent>
18 #include <QGridLayout>
19 #include <QHideEvent>
20 #include <QKeyEvent>
21 #include <QLabel>
22 #include <QLayout>
23 #include <QMap>
24 #include <QMouseEvent>
25 #include <QPaintEvent>
26 #include <QPainter>
27 #include <QPixmap>
28 #include <QPushButton>
29 #include <QScreen>
30 #include <QShowEvent>
31 #include <QStyle>
32 #include <QToolTip>
33 
101 /*
102  A class that acts very much like a QPushButton. It's not styled,
103  so we can expect the exact same look, feel and geometry
104  everywhere. Also, this button always emits clicked on
105  mouseRelease, even if the mouse button was not pressed inside the
106  widget.
107 */
108 
109 namespace Widgets {
110 
111 class ColorPickerButton : public QFrame {
112  Q_OBJECT
113 
114 public:
115  ColorPickerButton(QWidget *parent);
116 
117 signals:
118  void clicked();
119 
120 protected:
121  void mousePressEvent(QMouseEvent *e);
122  void mouseMoveEvent(QMouseEvent *e);
123  void mouseReleaseEvent(QMouseEvent *e);
124  void keyPressEvent(QKeyEvent *e);
125  void keyReleaseEvent(QKeyEvent *e);
126  void paintEvent(QPaintEvent *e);
127  void focusInEvent(QFocusEvent *e);
128  void focusOutEvent(QFocusEvent *e);
129 };
130 
131 /*
132  This class represents each "color" or item in the color grid.
133 */
134 class ColorPickerItem : public QFrame {
135  Q_OBJECT
136 
137 public:
138  ColorPickerItem(const QColor &color = Qt::white,
139  const QString &text = QString(),
140  QWidget *parent = 0);
142 
143  QColor color() const;
144  QString text() const;
145 
146  void setSelected(bool);
147  bool isSelected() const;
148 signals:
149  void clicked();
150  void selected();
151  void clicked(const QColor &clr);
152 
153 public slots:
154  void setColor(const QColor &color, const QString &text = QString());
155 
156 protected:
157  void mousePressEvent(QMouseEvent *e);
158  void mouseReleaseEvent(QMouseEvent *e);
159  void mouseMoveEvent(QMouseEvent *e);
160  void paintEvent(QPaintEvent *e);
161 
162 private:
163  QColor c;
164  QString t;
165  bool sel;
166 };
167 
168 /*
169 
170 */
171 class ColorPickerPopup : public QFrame {
172  Q_OBJECT
173 
174 public:
175  ColorPickerPopup(int width, bool withColorDialog, QWidget *parent = 0);
177 
178  void insertColor(const QColor &col, const QString &text, int index);
179  void exec();
180 
181  void setExecFlag();
182 
183  QColor lastSelected() const;
184 
185  ColorPickerItem *find(const QColor &col) const;
186  QColor color(int index) const;
187 
188 signals:
189  void selected(const QColor &);
190  void hid();
191 
192 public slots:
193  void getColorFromDialog();
194 
195 protected slots:
196  void updateSelected();
197 
198 protected:
199  void keyPressEvent(QKeyEvent *e);
200  void showEvent(QShowEvent *e);
201  void hideEvent(QHideEvent *e);
202  void mouseReleaseEvent(QMouseEvent *e);
203 
204  void regenerateGrid();
205 
206 private:
207  QMap<int, QMap<int, QWidget *>> widgetAt;
208  QList<ColorPickerItem *> items;
209  QGridLayout *grid;
210  ColorPickerButton *moreButton;
211  QEventLoop *eventLoop;
212 
213  int lastPos;
214  int cols;
215  QColor lastSel;
216 };
217 
235 QtColorPicker::QtColorPicker(QWidget *parent, int cols, bool enableColorDialog)
236  : QPushButton(parent), popup(0), withColorDialog(enableColorDialog) {
237  setFocusPolicy(Qt::StrongFocus);
238  setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
239  setAutoDefault(false);
240  setAutoFillBackground(true);
241  setCheckable(true);
242 
243  // Set text
244  setText(tr("Black"));
245  firstInserted = false;
246 
247  // Create and set icon
248  col = Qt::black;
249  dirty = true;
250 
251  // Create color grid popup and connect to it.
252  popup = new ColorPickerPopup(cols, withColorDialog, this);
253  connect(popup, SIGNAL(selected(const QColor &)),
254  SLOT(setCurrentColor(const QColor &)));
255  connect(popup, SIGNAL(hid()), SLOT(popupClosed()));
256 
257  // Connect this push button's pressed() signal.
258  connect(this, SIGNAL(toggled(bool)), SLOT(buttonPressed(bool)));
259 }
260 
265 
271 void QtColorPicker::buttonPressed(bool toggled) {
272  if (!toggled) return;
273 
274  const QRect desktop = QGuiApplication::primaryScreen()->geometry();
275  // Make sure the popup is inside the desktop.
276  QPoint pos = mapToGlobal(rect().bottomLeft());
277  if (pos.x() < desktop.left()) pos.setX(desktop.left());
278  if (pos.y() < desktop.top()) pos.setY(desktop.top());
279 
280  if ((pos.x() + popup->sizeHint().width()) > desktop.width())
281  pos.setX(desktop.width() - popup->sizeHint().width());
282  if ((pos.y() + popup->sizeHint().height()) > desktop.bottom())
283  pos.setY(desktop.bottom() - popup->sizeHint().height());
284  popup->move(pos);
285 
286  if (ColorPickerItem *item = popup->find(col)) item->setSelected(true);
287 
288  // Remove focus from this widget, preventing the focus rect
289  // from showing when the popup is shown. Order an update to
290  // make sure the focus rect is cleared.
291  clearFocus();
292  update();
293 
294  // Allow keyboard navigation as soon as the popup shows.
295  popup->setFocus();
296 
297  // Execute the popup. The popup will enter the event loop.
298  popup->show();
299 }
300 
304 void QtColorPicker::paintEvent(QPaintEvent *e) {
305  if (dirty) {
306  int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize);
307  QPixmap pix(iconSize, iconSize);
308  pix.fill(palette().button().color());
309 
310  QPainter p(&pix);
311 
312  int w = pix.width(); // width of cell in pixels
313  int h = pix.height(); // height of cell in pixels
314  p.setPen(QPen(Qt::gray));
315  p.setBrush(col);
316  p.drawRect(2, 2, w - 5, h - 5);
317  setIcon(QIcon(pix));
318 
319  dirty = false;
320  }
321  QPushButton::paintEvent(e);
322 }
323 
328 void QtColorPicker::popupClosed() {
329  setChecked(false);
330  setFocus();
331 }
332 
338 QColor QtColorPicker::currentColor() const { return col; }
339 
343 QColor QtColorPicker::color(int index) const { return popup->color(index); }
344 
354  insertColor(Qt::black, tr("Black"));
355  insertColor(Qt::white, tr("White"));
356  insertColor(Qt::red, tr("Red"));
357  insertColor(Qt::darkRed, tr("Dark red"));
358  insertColor(Qt::green, tr("Green"));
359  insertColor(Qt::darkGreen, tr("Dark green"));
360  insertColor(Qt::blue, tr("Blue"));
361  insertColor(Qt::darkBlue, tr("Dark blue"));
362  insertColor(Qt::cyan, tr("Cyan"));
363  insertColor(Qt::darkCyan, tr("Dark cyan"));
364  insertColor(Qt::magenta, tr("Magenta"));
365  insertColor(Qt::darkMagenta, tr("Dark magenta"));
366  insertColor(Qt::yellow, tr("Yellow"));
367  insertColor(Qt::darkYellow, tr("Dark yellow"));
368  insertColor(Qt::gray, tr("Gray"));
369  insertColor(Qt::darkGray, tr("Dark gray"));
370  insertColor(Qt::lightGray, tr("Light gray"));
371 }
372 
381  if (col == color || !color.isValid()) return;
382 
383  ColorPickerItem *item = popup->find(color);
384  if (!item) {
385  insertColor(color, tr("Custom"));
386  item = popup->find(color);
387  }
388 
389  col = color;
390  setText(item->text());
391 
392  dirty = true;
393 
394  popup->hide();
395  repaint();
396 
397  item->setSelected(true);
398  emit colorChanged(color);
399 }
400 
408  const QString &text,
409  int index) {
410  popup->insertColor(color, text, index);
411  if (!firstInserted) {
412  col = color;
413  setText(text);
414  firstInserted = true;
415  }
416 }
417 
427  withColorDialog = enabled;
428 }
429 bool QtColorPicker::colorDialogEnabled() const { return withColorDialog; }
430 
448 QColor QtColorPicker::GetColor(const QPoint &point, bool allowCustomColors) {
449  ColorPickerPopup popup(-1, allowCustomColors);
450 
451  popup.insertColor(Qt::black, tr("Black"), 0);
452  popup.insertColor(Qt::white, tr("White"), 1);
453  popup.insertColor(Qt::red, tr("Red"), 2);
454  popup.insertColor(Qt::darkRed, tr("Dark red"), 3);
455  popup.insertColor(Qt::green, tr("Green"), 4);
456  popup.insertColor(Qt::darkGreen, tr("Dark green"), 5);
457  popup.insertColor(Qt::blue, tr("Blue"), 6);
458  popup.insertColor(Qt::darkBlue, tr("Dark blue"), 7);
459  popup.insertColor(Qt::cyan, tr("Cyan"), 8);
460  popup.insertColor(Qt::darkCyan, tr("Dark cyan"), 9);
461  popup.insertColor(Qt::magenta, tr("Magenta"), 10);
462  popup.insertColor(Qt::darkMagenta, tr("Dark magenta"), 11);
463  popup.insertColor(Qt::yellow, tr("Yellow"), 12);
464  popup.insertColor(Qt::darkYellow, tr("Dark yellow"), 13);
465  popup.insertColor(Qt::gray, tr("Gray"), 14);
466  popup.insertColor(Qt::darkGray, tr("Dark gray"), 15);
467  popup.insertColor(Qt::lightGray, tr("Light gray"), 16);
468 
469  popup.move(point);
470  popup.exec();
471  return popup.lastSelected();
472 }
473 
479  bool withColorDialog,
480  QWidget *parent)
481  : QFrame(parent, Qt::Popup) {
482  setFrameStyle(QFrame::StyledPanel);
484 
485  setFocusPolicy(Qt::StrongFocus);
486  setMouseTracking(true);
487  cols = width;
488 
489  if (withColorDialog) {
490  moreButton = new ColorPickerButton(this);
491  moreButton->setFixedWidth(24);
492  moreButton->setFixedHeight(21);
493  moreButton->setFrameRect(QRect(2, 2, 20, 17));
494  connect(moreButton, SIGNAL(clicked()), SLOT(getColorFromDialog()));
495  } else {
496  moreButton = 0;
497  }
498 
499  eventLoop = 0;
500  grid = 0;
501  regenerateGrid();
502 }
503 
509  if (eventLoop) eventLoop->exit();
510 }
511 
517 ColorPickerItem *ColorPickerPopup::find(const QColor &col) const {
518  for (int i = 0; i < items.size(); ++i) {
519  if (items.at(i) && items.at(i)->color() == col) return items.at(i);
520  }
521 
522  return 0;
523 }
524 
530 void ColorPickerPopup::insertColor(const QColor &col,
531  const QString &text,
532  int index) {
533  // Don't add colors that we have already.
534  ColorPickerItem *existingItem = find(col);
535  ColorPickerItem *lastSelectedItem = find(lastSelected());
536 
537  if (existingItem) {
538  if (lastSelectedItem && existingItem != lastSelectedItem)
539  lastSelectedItem->setSelected(false);
540  existingItem->setFocus();
541  existingItem->setSelected(true);
542  return;
543  }
544 
545  ColorPickerItem *item = new ColorPickerItem(col, text, this);
546 
547  if (lastSelectedItem) {
548  lastSelectedItem->setSelected(false);
549  } else {
550  item->setSelected(true);
551  lastSel = col;
552  }
553  item->setFocus();
554 
555  connect(item, SIGNAL(selected()), SLOT(updateSelected()));
556  connect(item, SIGNAL(clicked(QColor)), this, SIGNAL(selected(QColor)));
557 
558  if (index == -1) index = items.count();
559 
560  items.insert((unsigned int)index, item);
561  regenerateGrid();
562 
563  update();
564 }
565 
569 QColor ColorPickerPopup::color(int index) const {
570  if (index < 0 || index > (int)items.count() - 1) return QColor();
571 
572  ColorPickerPopup *that = (ColorPickerPopup *)this;
573  return that->items.at(index)->color();
574 }
575 
580  show();
581 
582  QEventLoop e;
583  eventLoop = &e;
584  (void)e.exec();
585  eventLoop = 0;
586 }
587 
592  QLayoutItem *layoutItem;
593  int i = 0;
594  while ((layoutItem = grid->itemAt(i)) != 0) {
595  QWidget *w = layoutItem->widget();
596  if (w && w->inherits("ColorPickerItem")) {
597  ColorPickerItem *litem =
598  reinterpret_cast<ColorPickerItem *>(layoutItem->widget());
599  if (litem != sender()) litem->setSelected(false);
600  }
601  ++i;
602  }
603 
604  if (sender() && sender()->inherits("ColorPickerItem")) {
605  ColorPickerItem *item = (ColorPickerItem *)sender();
606  lastSel = item->color();
607  emit selected(item->color());
608  }
609 
610  hide();
611 }
612 
617  if (!rect().contains(e->pos())) hide();
618 }
619 
625  int curRow = 0;
626  int curCol = 0;
627 
628  bool foundFocus = false;
629  for (int j = 0; !foundFocus && j < grid->rowCount(); ++j) {
630  for (int i = 0; !foundFocus && i < grid->columnCount(); ++i) {
631  if (widgetAt[j][i] && widgetAt[j][i]->hasFocus()) {
632  curRow = j;
633  curCol = i;
634  foundFocus = true;
635  break;
636  }
637  }
638  }
639 
640  switch (e->key()) {
641  case Qt::Key_Left:
642  if (curCol > 0)
643  --curCol;
644  else if (curRow > 0) {
645  --curRow;
646  curCol = grid->columnCount() - 1;
647  }
648  break;
649  case Qt::Key_Right:
650  if (curCol < grid->columnCount() - 1 &&
651  widgetAt[curRow][curCol + 1])
652  ++curCol;
653  else if (curRow < grid->rowCount() - 1) {
654  ++curRow;
655  curCol = 0;
656  }
657  break;
658  case Qt::Key_Up:
659  if (curRow > 0)
660  --curRow;
661  else
662  curCol = 0;
663  break;
664  case Qt::Key_Down:
665  if (curRow < grid->rowCount() - 1) {
666  QWidget *w = widgetAt[curRow + 1][curCol];
667  if (w) {
668  ++curRow;
669  } else
670  for (int i = 1; i < grid->columnCount(); ++i) {
671  if (!widgetAt[curRow + 1][i]) {
672  curCol = i - 1;
673  ++curRow;
674  break;
675  }
676  }
677  }
678  break;
679  case Qt::Key_Space:
680  case Qt::Key_Return:
681  case Qt::Key_Enter: {
682  QWidget *w = widgetAt[curRow][curCol];
683  if (w && w->inherits("ColorPickerItem")) {
684  ColorPickerItem *wi = reinterpret_cast<ColorPickerItem *>(w);
685  wi->setSelected(true);
686 
687  QLayoutItem *layoutItem;
688  int i = 0;
689  while ((layoutItem = grid->itemAt(i)) != 0) {
690  QWidget *w = layoutItem->widget();
691  if (w && w->inherits("ColorPickerItem")) {
692  ColorPickerItem *litem =
693  reinterpret_cast<ColorPickerItem *>(
694  layoutItem->widget());
695  if (litem != wi) litem->setSelected(false);
696  }
697  ++i;
698  }
699 
700  lastSel = wi->color();
701  emit selected(wi->color());
702  hide();
703  } else if (w && w->inherits("QPushButton")) {
704  ColorPickerItem *wi = reinterpret_cast<ColorPickerItem *>(w);
705  wi->setSelected(true);
706 
707  QLayoutItem *layoutItem;
708  int i = 0;
709  while ((layoutItem = grid->itemAt(i)) != 0) {
710  QWidget *w = layoutItem->widget();
711  if (w && w->inherits("ColorPickerItem")) {
712  ColorPickerItem *litem =
713  reinterpret_cast<ColorPickerItem *>(
714  layoutItem->widget());
715  if (litem != wi) litem->setSelected(false);
716  }
717  ++i;
718  }
719 
720  lastSel = wi->color();
721  emit selected(wi->color());
722  hide();
723  }
724  } break;
725  case Qt::Key_Escape:
726  hide();
727  break;
728  default:
729  e->ignore();
730  break;
731  }
732 
733  widgetAt[curRow][curCol]->setFocus();
734 }
735 
739 void ColorPickerPopup::hideEvent(QHideEvent *e) {
740  if (eventLoop) {
741  eventLoop->exit();
742  }
743 
744  setFocus();
745 
746  emit hid();
747  QFrame::hideEvent(e);
748 }
749 
753 QColor ColorPickerPopup::lastSelected() const { return lastSel; }
754 
760 void ColorPickerPopup::showEvent(QShowEvent *) {
761  bool foundSelected = false;
762  for (int i = 0; i < grid->columnCount(); ++i) {
763  for (int j = 0; j < grid->rowCount(); ++j) {
764  QWidget *w = widgetAt[j][i];
765  if (w && w->inherits("ColorPickerItem")) {
766  if (((ColorPickerItem *)w)->isSelected()) {
767  w->setFocus();
768  foundSelected = true;
769  break;
770  }
771  }
772  }
773  }
774 
775  if (!foundSelected) {
776  if (items.count() == 0)
777  setFocus();
778  else
779  widgetAt[0][0]->setFocus();
780  }
781 }
782 
787  widgetAt.clear();
788 
789  int columns = cols;
790  if (columns == -1) columns = (int)ceil(sqrt((float)items.count()));
791 
792  // When the number of columns grows, the number of rows will
793  // fall. There's no way to shrink a grid, so we create a new
794  // one.
795  if (grid) delete grid;
796  grid = new QGridLayout(this);
797 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
798  grid->setMargin(1);
799 #endif
800  grid->setContentsMargins(1, 1, 1, 1);
801  grid->setSpacing(0);
802 
803  int ccol = 0, crow = 0;
804  for (int i = 0; i < items.size(); ++i) {
805  if (items.at(i)) {
806  widgetAt[crow][ccol] = items.at(i);
807  grid->addWidget(items.at(i), crow, ccol++);
808  if (ccol == columns) {
809  ++crow;
810  ccol = 0;
811  }
812  }
813  }
814 
815  if (moreButton) {
816  grid->addWidget(moreButton, crow, ccol);
817  widgetAt[crow][ccol] = moreButton;
818  }
819  updateGeometry();
820 }
821 
828  bool ok = true;
829  // QRgb rgb = QColorDialog::getRgba(lastSel.rgba(), &ok, parentWidget());
830  QRgb rgb = QColorDialog::getColor(lastSel, parentWidget()).rgb();
831  if (!ok) return;
832 
833  QColor col = QColor::fromRgba(rgb);
834  insertColor(col, tr("Custom"), -1);
835  lastSel = col;
836  emit selected(col);
837 }
838 
844  const QString &text,
845  QWidget *parent)
846  : QFrame(parent), c(color), t(text), sel(false) {
847  setToolTip(t);
848  setFixedWidth(24);
849  setFixedHeight(21);
850 }
851 
856 
862 QColor ColorPickerItem::color() const { return c; }
863 
869 QString ColorPickerItem::text() const { return t; }
870 
874 bool ColorPickerItem::isSelected() const { return sel; }
875 
879 void ColorPickerItem::setSelected(bool selected) {
880  sel = selected;
881  update();
882 }
883 
887 void ColorPickerItem::setColor(const QColor &color, const QString &text) {
888  c = color;
889  t = text;
890  setToolTip(t);
891  update();
892 }
893 
897 void ColorPickerItem::mouseMoveEvent(QMouseEvent *) {
898  setFocus();
899  update();
900 }
901 
906  sel = true;
907  emit selected();
908 }
909 
913 void ColorPickerItem::mousePressEvent(QMouseEvent *) {
914  setFocus();
915  update();
916  emit clicked(c);
917 }
918 
922 void ColorPickerItem::paintEvent(QPaintEvent *) {
923  QPainter p(this);
924  int w = width(); // width of cell in pixels
925  int h = height(); // height of cell in pixels
926 
927  p.setPen(QPen(Qt::gray, 0, Qt::SolidLine));
928 
929  if (sel) p.drawRect(1, 1, w - 3, h - 3);
930 
931  p.setPen(QPen(Qt::black, 0, Qt::SolidLine));
932  p.drawRect(3, 3, w - 7, h - 7);
933  p.fillRect(QRect(4, 4, w - 8, h - 8), QBrush(c));
934 
935  if (hasFocus()) p.drawRect(0, 0, w - 1, h - 1);
936 }
937 
941 ColorPickerButton::ColorPickerButton(QWidget *parent) : QFrame(parent) {
942  setFrameStyle(StyledPanel);
943 }
944 
949  setFrameShadow(Sunken);
950  update();
951 }
952 
957  setFocus();
958  update();
959 }
960 
965  setFrameShadow(Raised);
966  repaint();
967  emit clicked();
968 }
969 
974  if (e->key() == Qt::Key_Up || e->key() == Qt::Key_Down ||
975  e->key() == Qt::Key_Left || e->key() == Qt::Key_Right) {
976  qApp->sendEvent(parent(), e);
977  } else if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Space ||
978  e->key() == Qt::Key_Return) {
979  setFrameShadow(Sunken);
980  update();
981  } else {
982  QFrame::keyPressEvent(e);
983  }
984 }
985 
990  if (e->key() == Qt::Key_Up || e->key() == Qt::Key_Down ||
991  e->key() == Qt::Key_Left || e->key() == Qt::Key_Right) {
992  qApp->sendEvent(parent(), e);
993  } else if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Space ||
994  e->key() == Qt::Key_Return) {
995  setFrameShadow(Raised);
996  repaint();
997  emit clicked();
998  } else {
999  QFrame::keyReleaseEvent(e);
1000  }
1001 }
1002 
1007  setFrameShadow(Raised);
1008  update();
1009  QFrame::focusOutEvent(e);
1010 }
1011 
1016  setFrameShadow(Raised);
1017  update();
1018  QFrame::focusOutEvent(e);
1019 }
1020 
1024 void ColorPickerButton::paintEvent(QPaintEvent *e) {
1025  QFrame::paintEvent(e);
1026 
1027  QPainter p(this);
1028  p.fillRect(contentsRect(), palette().button());
1029 
1030  QRect r = rect();
1031 
1032  int offset = frameShadow() == Sunken ? 1 : 0;
1033 
1034  QPen pen(palette().buttonText(), 1);
1035  p.setPen(pen);
1036 
1037  p.drawRect(r.center().x() + offset - 4, r.center().y() + offset, 1, 1);
1038  p.drawRect(r.center().x() + offset, r.center().y() + offset, 1, 1);
1039  p.drawRect(r.center().x() + offset + 4, r.center().y() + offset, 1, 1);
1040  if (hasFocus()) {
1041  p.setPen(QPen(Qt::black, 0, Qt::SolidLine));
1042  p.drawRect(0, 0, width() - 1, height() - 1);
1043  }
1044 
1045  p.end();
1046 }
1047 
1048 } // namespace Widgets
1049 #include "qtcolorpicker.moc"
int width
int height
int offset
math::float4 color
#define slots
#define signals
static int columnCount(int count)
ColorPickerButton(QWidget *parent)
void mouseMoveEvent(QMouseEvent *e)
void keyReleaseEvent(QKeyEvent *e)
void keyPressEvent(QKeyEvent *e)
void mousePressEvent(QMouseEvent *e)
void focusInEvent(QFocusEvent *e)
void mouseReleaseEvent(QMouseEvent *e)
void paintEvent(QPaintEvent *e)
void focusOutEvent(QFocusEvent *e)
void paintEvent(QPaintEvent *e)
void setColor(const QColor &color, const QString &text=QString())
void mousePressEvent(QMouseEvent *e)
void clicked(const QColor &clr)
void mouseMoveEvent(QMouseEvent *e)
ColorPickerItem(const QColor &color=Qt::white, const QString &text=QString(), QWidget *parent=0)
void mouseReleaseEvent(QMouseEvent *e)
ColorPickerPopup(int width, bool withColorDialog, QWidget *parent=0)
void mouseReleaseEvent(QMouseEvent *e)
void showEvent(QShowEvent *e)
ColorPickerItem * find(const QColor &col) const
void selected(const QColor &)
void hideEvent(QHideEvent *e)
void keyPressEvent(QKeyEvent *e)
QColor color(int index) const
void insertColor(const QColor &col, const QString &text, int index)
void setColorDialogEnabled(bool enabled)
void paintEvent(QPaintEvent *e)
QtColorPicker(QWidget *parent=0, int columns=-1, bool enableColorDialog=true)
static QColor GetColor(const QPoint &pos, bool allowCustomColors=true)
QColor color(int index) const
void colorChanged(const QColor &)
void insertColor(const QColor &color, const QString &text=QString(), int index=-1)
QColor currentColor() const
void setCurrentColor(const QColor &col)
bool colorDialogEnabled() const
const double * e
normal_z rgb
Tensor Minimum(const Tensor &input, const Tensor &other)
Computes the element-wise minimum of input and other. The tensors must have same data type and device...
MiniVec< float, N > ceil(const MiniVec< float, N > &a)
Definition: MiniVec.h:89
constexpr Rgb cyan(0, MAX, MAX)
constexpr Rgb black(0, 0, 0)
constexpr Rgb magenta(MAX, 0, MAX)
constexpr Rgb darkBlue(0, 0, MAX/2)
constexpr Rgb white(MAX, MAX, MAX)
constexpr Rgb red(MAX, 0, 0)
constexpr Rgb blue(0, 0, MAX)
constexpr Rgb green(0, MAX, 0)
constexpr Rgb yellow(MAX, MAX, 0)