nux-0.9.48
|
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 RadioButton; 00041 class RadioButtonGroup; 00042 class PushButton; 00043 00044 class ColorEditor; 00045 class ColorPreview; 00046 00047 class ColorDialogProxy 00048 { 00049 public: 00050 ColorDialogProxy (bool ModalWindow); 00051 ~ColorDialogProxy(); 00052 00053 void RecvDialogOk (ColorEditor *coloreditor); 00054 void RecvDialogCancel (ColorEditor *coloreditor); 00055 void RecvDialogChange (ColorEditor *coloreditor); 00056 00057 void Start(); 00058 bool IsActive(); 00059 void StopThreadMonitoring(); 00060 00061 void SetColor (Color color); 00062 Color GetColor(); 00063 void SetPreviousColor (Color color); 00064 Color GetPreviousColor(); 00065 void SetColorModel (eColorModel color_model); 00066 eColorModel GetColorModel(); 00067 void SetColorChannel (eColorChannel color_model); 00068 eColorChannel GetColorChannel(); 00069 00070 private: 00071 bool m_bDialogChange; 00072 bool m_bDialogRunning; 00073 unsigned int m_DialogThreadID; 00074 Color m_RGBColor; 00075 Color m_PreviousRGBColor; 00076 eColorModel m_ColorModel; 00077 eColorChannel m_ColorChannel; 00078 bool m_ModalWindow; 00079 NThread *m_Thread; 00080 00081 friend class ColorPreview; 00082 }; 00083 00084 class ColorEditor : public View 00085 { 00086 public: 00087 ColorEditor (NUX_FILE_LINE_PROTO); 00088 ~ColorEditor(); 00089 virtual long ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo); 00090 virtual void Draw (GraphicsEngine &GfxContext, bool force_draw); 00091 virtual void DrawContent (GraphicsEngine &GfxContext, bool force_draw); 00092 virtual void PostDraw (GraphicsEngine &GfxContext, bool force_draw); 00093 00094 00095 void SetRed (double r); 00096 void SetGreen (double g); 00097 void SetBlue (double b); 00098 void SetHue (double h); 00099 void SetSaturation (double s); 00100 void SetValue (double v); 00101 00102 void SetRGB (double r, double g, double b); 00103 void SetHSV (double h, double s, double v); 00104 void SetRGB (Color rgb); 00105 void SetHSV (Color hsv); 00106 Color GetRGBColor() const; 00107 Color GetHSVColor() const; 00108 00109 void SetColorModel (eColorModel, eColorChannel); 00110 eColorModel GetColorModel() const; 00111 eColorChannel GetColorChannel() const; 00112 00113 void RecvMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags); 00114 void RecvMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags); 00115 void RecvMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); 00116 00117 void RecvPickerMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags); 00118 void RecvPickerMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags); 00119 void RecvPickerMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); 00120 00121 void RecvCheckColorModel (bool, eColorModel, eColorChannel); 00122 00123 sigc::signal< void, ColorEditor * > sigChange; 00124 private: 00125 void DrawBaseChannelMarker (GraphicsEngine &GfxContext); 00126 void DrawRGB (GraphicsEngine &GfxContext, bool force_draw); 00127 void DrawHSV (GraphicsEngine &GfxContext, bool force_draw); 00128 00129 eColorChannel m_ColorChannel; 00130 eColorModel m_ColorModel; 00131 InputArea *m_PickerArea; 00132 InputArea *m_BaseChannelArea; 00133 InputArea *m_ColorSquare; 00134 HLayout *m_hlayout; 00135 VLayout *ctrllayout; 00136 00137 GLSh_ColorPicker *m_RedShader; 00138 GLSh_ColorPicker *m_GreenShader; 00139 GLSh_ColorPicker *m_BlueShader; 00140 00141 GLSh_ColorPicker *m_HueShader; 00142 GLSh_ColorPicker *m_SaturationShader; 00143 GLSh_ColorPicker *m_ValueShader; 00144 00145 Point m_MarkerPosition; 00146 Point m_VertMarkerPosition; 00147 00148 float m_Red; 00149 float m_Green; 00150 float m_Blue; 00151 float m_Hue; 00152 float m_Saturation; 00153 float m_Value; 00154 00155 00156 HLayout *redlayout; 00157 HLayout *greenlayout; 00158 HLayout *bluelayout; 00159 00160 RadioButton *redcheck; 00161 EditTextBox *redtext; 00162 RadioButton *greencheck; 00163 EditTextBox *greentext; 00164 RadioButton *bluecheck; 00165 EditTextBox *bluetext; 00166 00167 HLayout *huelayout; 00168 HLayout *saturationlayout; 00169 HLayout *valuelayout; 00170 00171 RadioButton *huecheck; 00172 EditTextBox *huetext; 00173 RadioButton *saturationcheck; 00174 EditTextBox *saturationtext; 00175 RadioButton *valuecheck; 00176 EditTextBox *valuetext; 00177 00178 PushButton *OkButton; 00179 PushButton *CancelButton; 00180 RadioButtonGroup *radiogroup; 00181 00182 DoubleValidator m_Validator; 00183 00184 }; 00185 00186 00187 } 00188 00189 #endif // COLOREDITOR_H 00190