nux-1.16.0
|
00001 /* 00002 * Copyright 2010 Inalogic® Inc. 00003 * 00004 * This program is free software: you can redistribute it and/or modify it 00005 * under the terms of the GNU Lesser General Public License, as 00006 * published by the Free Software Foundation; either version 2.1 or 3.0 00007 * of the License. 00008 * 00009 * This program is distributed in the hope that it will be useful, but 00010 * WITHOUT ANY WARRANTY; without even the implied warranties of 00011 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR 00012 * PURPOSE. See the applicable version of the GNU Lesser General Public 00013 * License for more details. 00014 * 00015 * You should have received a copy of both the GNU Lesser General Public 00016 * License along with this program. If not, see <http://www.gnu.org/licenses/> 00017 * 00018 * Authored by: Jay Taoko <jaytaoko@inalogic.com> 00019 * 00020 */ 00021 00022 00023 #ifndef COLOREDITOR_H 00024 #define COLOREDITOR_H 00025 00026 #include "NuxGraphics/GpuDevice.h" 00027 #include "NuxGraphics/GLDeviceObjects.h" 00028 #include "NuxGraphics/GLSh_DrawFunction.h" 00029 #include "DoubleValidator.h" 00030 #include "TimerProc.h" 00031 00032 namespace nux 00033 { 00034 00035 class GLSh_ColorPicker; 00036 class HLayout; 00037 class VLayout; 00038 class EditTextBox; 00039 class CheckBox; 00040 class ToggleButton; 00041 class Button; 00042 00043 class ColorEditor; 00044 class ColorPreview; 00045 00046 class ColorDialogProxy 00047 { 00048 public: 00049 ColorDialogProxy (bool ModalWindow); 00050 ~ColorDialogProxy(); 00051 00052 void RecvDialogOk (ColorEditor *coloreditor); 00053 void RecvDialogCancel (ColorEditor *coloreditor); 00054 void RecvDialogChange (ColorEditor *coloreditor); 00055 00056 void Start(); 00057 bool IsActive(); 00058 void StopThreadMonitoring(); 00059 00060 void SetColor (Color color); 00061 Color GetColor(); 00062 void SetPreviousColor (Color color); 00063 Color GetPreviousColor(); 00064 void SetColorModel (color::Model color_model); 00065 color::Model GetColorModel(); 00066 void SetColorChannel (color::Channel color_model); 00067 color::Channel GetColorChannel(); 00068 00069 private: 00070 bool m_bDialogChange; 00071 bool m_bDialogRunning; 00072 unsigned int m_DialogThreadID; 00073 Color m_RGBColor; 00074 Color m_PreviousRGBColor; 00075 color::Model m_ColorModel; 00076 color::Channel m_ColorChannel; 00077 bool m_ModalWindow; 00078 NThread *m_Thread; 00079 00080 friend class ColorPreview; 00081 }; 00082 00083 class ColorEditor : public View 00084 { 00085 public: 00086 ColorEditor (NUX_FILE_LINE_PROTO); 00087 ~ColorEditor(); 00088 virtual long ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo); 00089 virtual void Draw (GraphicsEngine &GfxContext, bool force_draw); 00090 virtual void DrawContent (GraphicsEngine &GfxContext, bool force_draw); 00091 virtual void PostDraw (GraphicsEngine &GfxContext, bool force_draw); 00092 00093 void SetRed (double r); 00094 void SetGreen (double g); 00095 void SetBlue (double b); 00096 void SetHue (double h); 00097 void SetSaturation (double s); 00098 void SetValue (double v); 00099 00100 void SetRGB (double r, double g, double b); 00101 void SetHSV (double h, double s, double v); 00102 void SetRGB(Color const& rgb); 00103 Color GetRGBColor() const; 00104 00105 void SetColorModel (color::Model, color::Channel); 00106 color::Model GetColorModel() const; 00107 color::Channel GetColorChannel() const; 00108 00109 void RecvMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags); 00110 void RecvMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags); 00111 void RecvMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); 00112 00113 void RecvPickerMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags); 00114 void RecvPickerMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags); 00115 void RecvPickerMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); 00116 00117 void RecvCheckColorModel (bool, color::Model, color::Channel); 00118 00119 sigc::signal< void, ColorEditor * > sigChange; 00120 00121 protected: 00122 virtual bool AcceptKeyNavFocus(); 00123 private: 00124 void DrawBaseChannelMarker (GraphicsEngine &GfxContext); 00125 void DrawRGB (GraphicsEngine &GfxContext, bool force_draw); 00126 void DrawHSV (GraphicsEngine &GfxContext, bool force_draw); 00127 00128 color::Channel m_ColorChannel; 00129 color::Model m_ColorModel; 00130 InputArea *m_PickerArea; 00131 InputArea *m_BaseChannelArea; 00132 InputArea *m_ColorSquare; 00133 HLayout *m_hlayout; 00134 VLayout *ctrllayout; 00135 00136 GLSh_ColorPicker *m_RedShader; 00137 GLSh_ColorPicker *m_GreenShader; 00138 GLSh_ColorPicker *m_BlueShader; 00139 00140 GLSh_ColorPicker *m_HueShader; 00141 GLSh_ColorPicker *m_SaturationShader; 00142 GLSh_ColorPicker *m_ValueShader; 00143 00144 Point m_MarkerPosition; 00145 Point m_VertMarkerPosition; 00146 00147 color::RedGreenBlue rgb_; 00148 color::HueSaturationValue hsv_; 00149 00150 HLayout *redlayout; 00151 HLayout *greenlayout; 00152 HLayout *bluelayout; 00153 00154 Button *redcheck; 00155 EditTextBox *redtext; 00156 Button *greencheck; 00157 EditTextBox *greentext; 00158 Button *bluecheck; 00159 EditTextBox *bluetext; 00160 00161 HLayout *huelayout; 00162 HLayout *saturationlayout; 00163 HLayout *valuelayout; 00164 00165 Button *huecheck; 00166 EditTextBox *huetext; 00167 Button *saturationcheck; 00168 EditTextBox *saturationtext; 00169 Button *valuecheck; 00170 EditTextBox *valuetext; 00171 00172 ToggleButton *OkButton; 00173 ToggleButton *CancelButton; 00174 //RadioButtonGroup *radiogroup; 00175 00176 DoubleValidator m_Validator; 00177 00178 }; 00179 00180 00181 } 00182 00183 #endif // COLOREDITOR_H 00184