~mc-return/nux/nux.merge-fix-deprecated-warnings

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
/*
 * Copyright 2010 Inalogic® Inc.
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License, as
 * published by the  Free Software Foundation; either version 2.1 or 3.0
 * of the License.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
 * PURPOSE.  See the applicable version of the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of both the GNU Lesser General Public
 * License along with this program. If not, see <http://www.gnu.org/licenses/>
 *
 * Authored by: Jay Taoko <jaytaoko@inalogic.com>
 *
 */


#ifndef COLOREDITOR_H
#define COLOREDITOR_H

#include "NuxGraphics/GpuDevice.h"
#include "NuxGraphics/GLDeviceObjects.h"
#include "NuxGraphics/GLSh_DrawFunction.h"
#include "DoubleValidator.h"
#include "TimerProc.h"

namespace nux
{

  class GLSh_ColorPicker;
  class HLayout;
  class VLayout;
  class EditTextBox;
  class CheckBox;
  class AbstractButton;
  class RadioButton;
  class RadioButtonGroup;
  class Button;

  class ColorEditor;
  class ColorPreview;

  class ColorDialogProxy
  {
  public:
    ColorDialogProxy(bool ModalWindow);
    ~ColorDialogProxy();

    void RecvDialogOk(ColorEditor *coloreditor);
    void RecvDialogCancel(ColorEditor *coloreditor);
    void RecvDialogChange(ColorEditor *coloreditor);

    void Start();
    bool IsActive();
    void StopThreadMonitoring();

    void SetColor(Color color);
    Color GetColor();
    void SetPreviousColor(Color color);
    Color GetPreviousColor();
    void SetColorModel(color::Model color_model);
    color::Model GetColorModel();
    void SetColorChannel(color::Channel color_model);
    color::Channel GetColorChannel();

  private:
    bool m_bDialogChange;
    bool m_bDialogRunning;
    unsigned int m_DialogThreadID;
    Color m_RGBColor;
    Color m_PreviousRGBColor;
    color::Model m_ColorModel;
    color::Channel color_channel_;
    bool m_ModalWindow;
    NThread *m_Thread;

    friend class ColorPreview;
  };

  class ColorEditor : public View
  {
  public:
    ColorEditor(NUX_FILE_LINE_PROTO);
    ~ColorEditor();

    void SetRed(double r);
    void SetGreen(double g);
    void SetBlue(double b);
    void SetHue(double h);
    void SetSaturation(double s);
    void SetValue(double v);

    void SetRGB(double r, double g, double b);
    void SetHSV(double h, double s, double v);
    void SetRGB(Color const& rgb);
    Color GetRGBColor() const;

    void SetColorModel(color::Model, color::Channel);
    color::Model GetColorModel() const;
    color::Channel GetColorChannel() const;

    void RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
    void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
    void RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);

    void RecvPickerMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
    void RecvPickerMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
    void RecvPickerMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);

    void RecvCheckColorModel(bool, color::Model, color::Channel);
    void RecvCheckColorModel0(AbstractButton *button, color::Model color_mode, color::Channel channel);

    sigc::signal< void, ColorEditor * > sigChange;

  protected:
    virtual void Draw(GraphicsEngine &graphics_engine, bool force_draw);
    virtual void DrawContent(GraphicsEngine &graphics_engine, bool force_draw);
    virtual void PreLayoutManagement();
    virtual bool AcceptKeyNavFocus();
  private:

    //! Override of Area::SetMinimumHeight and made private.
    /*!
        Prevent changing the minimum height of the ColorEditor view.
    */
    virtual void SetMinimumHeight(){};

    //! Override of Area::SetMaximumHeight and made private.
    /*!
        Prevent changing the maximum height of the ColorEditor view.
    */
    virtual void SetMaximumHeight(){};

    //! Override of Area::SetMinimumWidth and made private.
    /*!
        Prevent changing the minimum width of the ColorEditor view.
    */
    virtual void SetMinimumWidth(){};

    //! Override of Area::SetMaximumWidth and made private.
    /*!
        Prevent changing the maximum width of the ColorEditor view.
    */
    virtual void SetMaximumWidth(){};

    void DrawBaseChannelMarker(GraphicsEngine &graphics_engine);
    void DrawRGB(GraphicsEngine &graphics_engine, bool force_draw);
    void DrawHSV(GraphicsEngine &graphics_engine, bool force_draw);

    color::Channel   color_channel_;
    color::Model     m_ColorModel;
    InputArea       *picker_area_;
    InputArea       *channel_area_;
    InputArea       *selected_color_area_;
    HLayout        *m_hlayout;
    VLayout        *ctrllayout;

    GLSh_ColorPicker *m_RedShader;
    GLSh_ColorPicker *m_GreenShader;
    GLSh_ColorPicker *m_BlueShader;

    GLSh_ColorPicker *m_HueShader;
    GLSh_ColorPicker *m_SaturationShader;
    GLSh_ColorPicker *m_ValueShader;

    Point m_MarkerPosition;
    Point m_VertMarkerPosition;

    color::RedGreenBlue rgb_;
    color::HueSaturationValue hsv_;

    HLayout *redlayout;
    HLayout *greenlayout;
    HLayout *bluelayout;

    RadioButton *redcheck;
    EditTextBox *redtext;
    RadioButton *greencheck;
    EditTextBox *greentext;
    RadioButton *bluecheck;
    EditTextBox *bluetext;

    HLayout *huelayout;
    HLayout *saturationlayout;
    HLayout *valuelayout;

    RadioButton *huecheck;
    EditTextBox *hue_text_entry_;
    RadioButton *saturationcheck;
    EditTextBox *saturation_text_entry_;
    RadioButton *valuecheck;
    EditTextBox *value_text_entry_;

    Button *OkButton;
    Button *CancelButton;
    RadioButtonGroup *radiogroup;

    DoubleValidator m_Validator;

    static Size picker_area_size;
    static int channel_area_width;
  };


}

#endif // COLOREDITOR_H