KiCad PCB EDA Suite
color4Dpickerdlg.h
Go to the documentation of this file.
1 
5 #ifndef COLOR4DPICKERDLG_H
6 #define COLOR4DPICKERDLG_H
7 
8 
9 #include <gal/color4d.h>
10 #include "color4Dpickerdlg_base.h"
11 
13 {
21 };
22 
24 {
25 public:
33  COLOR4D_PICKER_DLG( wxWindow* aParent, KIGFX::COLOR4D& aCurrentColor, bool aAllowOpacityControl );
35 
37 
38  static int m_ActivePage;
39 
40 private:
41  /* When the dialog is created, the mouse cursor can be on the RGB or HSV palette selector
42  * Because this dialog is created by clicking double clicking on a widget, the left mouse
43  * button is down, thus creating a not wanted mouse event inside this dialog
44  * m_allowMouseEvents is first set to false, and then set to true on the first left mouse
45  * clicking inside this dialog to prevent not wanted mouse drag event
46  */
53 
59 
60  double m_hue;
61  double m_sat;
62  double m_val;
63 
64  wxBitmap* m_bitmapRGB;
65  wxBitmap* m_bitmapHSV;
66 
67  std::vector<wxBitmapButton*> m_buttonsColor;
68 
69  void SetEditVals( CHANGED_COLOR aChanged );
70  void drawAll();
71 
72  void createHSVBitmap();
73  void drawHSVPalette();
74  void createRGBBitmap();
75  void drawRGBPalette();
76  void drawRGBCursors();
77 
79  void setIconColor( wxStaticBitmap* aStaticBitmap, KIGFX::COLOR4D& aColor4D );
80 
82  void OnChangeBrightness( wxScrollEvent& event ) override;
83 
85  void OnChangeAlpha( wxScrollEvent& event ) override;
86 
88  void OnChangeEditRed( wxSpinEvent& event ) override;
89  void OnChangeEditGreen( wxSpinEvent& event ) override;
90  void OnChangeEditBlue( wxSpinEvent& event ) override;
91  void OnChangeEditHue( wxSpinEvent& event ) override;
92  void OnChangeEditSat( wxSpinEvent& event ) override;
93 
95  void onRGBMouseClick( wxMouseEvent& event ) override;
96  void onRGBMouseDrag( wxMouseEvent& event ) override;
97  void onHSVMouseClick( wxMouseEvent& event ) override;
98  void onHSVMouseDrag( wxMouseEvent& event ) override;
99 
107  bool setHSvaluesFromCursor( wxPoint aMouseCursor );
108 
110  void buttColorClick( wxCommandEvent& event );
111 
113  bool TransferDataToWindow() override;
114 
116  void initDefinedColors();
117 
118  // convert double value 0 ... 1 to int 0 ... aValMax
119  int normalizeToInt( double aValue, int aValMax = 255 )
120  {
121  return ( aValue * aValMax ) + 0.5;
122  }
123 
124 };
125 
126 #endif // #define COLOR4DPICKERDLG_H
void initDefinedColors()
creates the bitmap buttons for each defined colors
void OnChangeBrightness(wxScrollEvent &event) override
Event handler from wxSlider: alpha (transparency) control.
void OnChangeEditSat(wxSpinEvent &event) override
void createRGBBitmap()
generate the bitmap that shows the RVB color space
void SetEditVals(CHANGED_COLOR aChanged)
KIGFX::COLOR4D GetColor()
int normalizeToInt(double aValue, int aValMax=255)
double m_hue
the current hue, in degrees (0 ... 360)
wxPoint m_cursorBitmapBlue
the blue cursor on the RGB bitmap palette.
double m_sat
the current saturation (0 ... 1.0)
wxPoint m_cursorBitmapHSV
the cursor on the HSV bitmap palette.
wxPoint * m_selectedCursor
the ref cursor to the selected curor, if any, or null.
std::vector< wxBitmapButton * > m_buttonsColor
list of defined colors buttons
wxPoint m_cursorBitmapGreen
the green cursor on the RGB bitmap palette.
void onRGBMouseClick(wxMouseEvent &event) override
mouse handlers, when clicking on a palette bitmap
void OnChangeEditGreen(wxSpinEvent &event) override
Class COLOR4D_PICKER_DLG_BASE.
wxPoint m_cursorBitmapRed
the red cursor on the RGB bitmap palette.
void createHSVBitmap()
generate the bitmap that shows the HSV color circle
wxBitmap * m_bitmapRGB
the basic RGB palette
void drawHSVPalette()
draws the HSV color circle
CHANGED_COLOR
void setIconColor(wxStaticBitmap *aStaticBitmap, KIGFX::COLOR4D &aColor4D)
repaint a static bitmap with the aColor4D color
KIGFX::COLOR4D m_previousColor4D
the inital color4d
void onHSVMouseClick(wxMouseEvent &event) override
void OnChangeEditBlue(wxSpinEvent &event) override
COLOR4D_PICKER_DLG(wxWindow *aParent, KIGFX::COLOR4D &aCurrentColor, bool aAllowOpacityControl)
Dialog constructor.
void drawRGBPalette()
draws the RVB color space
void OnChangeEditRed(wxSpinEvent &event) override
void OnChangeAlpha(wxScrollEvent &event) override
Event handlers from wxSpinControl.
bool m_allowOpacityCtrl
true to show the widget, false to keep alpha channel = 1.0
KIGFX::COLOR4D m_newColor4D
the current color4d
void OnChangeEditHue(wxSpinEvent &event) override
static int m_ActivePage
the active notebook page, stored during a session
double m_val
the current value (0 ... 1.0)
void buttColorClick(wxCommandEvent &event)
Event handler for defined color buttons
wxBitmap * m_bitmapHSV
the basic HUV palette
bool TransferDataToWindow() override
called when creating the dialog
bool setHSvaluesFromCursor(wxPoint aMouseCursor)
manage the Hue and Saturation settings when the mouse cursor is at aMouseCursor.
void onHSVMouseDrag(wxMouseEvent &event) override
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
void onRGBMouseDrag(wxMouseEvent &event) override