ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
qtcolorpicker.h
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 #pragma once
9 #include <QColor>
10 #include <QEvent>
11 #include <QFocusEvent>
12 #include <QLabel>
13 #include <QPushButton>
14 #include <QString>
15 
16 #include "../qPCL.h"
17 
18 namespace Widgets {
19 
20 class ColorPickerPopup;
21 
22 class QPCL_ENGINE_LIB_API QtColorPicker : public QPushButton {
23  Q_OBJECT
24 
25  Q_PROPERTY(bool colorDialog READ colorDialogEnabled WRITE
26  setColorDialogEnabled)
27 
28 public:
29  QtColorPicker(QWidget *parent = 0,
30  int columns = -1,
31  bool enableColorDialog = true);
32 
33  ~QtColorPicker();
34 
35  void insertColor(const QColor &color,
36  const QString &text = QString(),
37  int index = -1);
38 
39  QColor currentColor() const;
40 
41  QColor color(int index) const;
42 
43  void setColorDialogEnabled(bool enabled);
44  bool colorDialogEnabled() const;
45 
46  void setStandardColors();
47 
48  static QColor GetColor(const QPoint &pos, bool allowCustomColors = true);
49 
50 public Q_SLOTS:
51  void setCurrentColor(const QColor &col);
52 
53 Q_SIGNALS:
54  void colorChanged(const QColor &);
55 
56 protected:
57  void paintEvent(QPaintEvent *e);
58 
59 private Q_SLOTS:
60  void buttonPressed(bool toggled);
61  void popupClosed();
62 
63 private:
64  ColorPickerPopup *popup;
65  QColor col;
66  bool withColorDialog;
67  bool dirty;
68  bool firstInserted;
69 };
70 
71 } // namespace Widgets
math::float4 color
void colorChanged(const QColor &)
static QColor GetColor(double value, double r1, double g1, double b1)
const double * e
#define QPCL_ENGINE_LIB_API
Definition: qPCL.h:15