00001
00032 #ifndef LL_LLFLOATERCOLORPICKER_H
00033 #define LL_LLFLOATERCOLORPICKER_H
00034
00035 #include <vector>
00036
00037 #include "llfloater.h"
00038 #include "llmemory.h"
00039 #include "llcolorswatch.h"
00040 #include "llspinctrl.h"
00041 #include "lltextureentry.h"
00042
00043 class LLButton;
00044 class LLLineEditor;
00045 class LLCheckBoxCtrl;
00046
00048
00049 class LLFloaterColorPicker
00050 : public LLFloater
00051 {
00052 public:
00053 LLFloaterColorPicker (LLColorSwatchCtrl* swatch, BOOL show_apply_immediate = FALSE);
00054 virtual ~LLFloaterColorPicker ();
00055
00056
00057 virtual BOOL postBuild ();
00058 virtual void draw ();
00059 virtual BOOL handleMouseDown ( S32 x, S32 y, MASK mask );
00060 virtual BOOL handleMouseUp ( S32 x, S32 y, MASK mask );
00061 virtual BOOL handleHover ( S32 x, S32 y, MASK mask );
00062 virtual void onMouseCaptureLost();
00063 virtual void onClose(bool app_quitting);
00064
00065
00066 void createUI ();
00067 void initUI ( F32 rValIn, F32 gValIn, F32 bValIn );
00068 void showUI ();
00069 void destroyUI ();
00070 void cancelSelection ();
00071 LLColorSwatchCtrl* getSwatch () { return mSwatch; };
00072
00073
00074 void setOrigRgb ( F32 origRIn, F32 origGIn, F32 origBIn );
00075 void getOrigRgb ( F32& origROut, F32& origGOut, F32& origBOut );
00076 F32 getOrigR () { return origR; };
00077 F32 getOrigG () { return origG; };
00078 F32 getOrigB () { return origB; };
00079
00080
00081 void setCurRgb ( F32 curRIn, F32 curGIn, F32 curBIn );
00082 void getCurRgb ( F32& curROut, F32& curGOut, F32& curBOut );
00083 F32 getCurR () { return curR; };
00084 F32 getCurG () { return curG; };
00085 F32 getCurB () { return curB; };
00086
00087
00088 void setCurHsl ( F32 curHIn, F32 curSIn, F32 curLIn );
00089 void getCurHsl ( F32& curHOut, F32& curSOut, F32& curLOut );
00090 F32 getCurH () { return curH; };
00091 F32 getCurS () { return curS; };
00092 F32 getCurL () { return curL; };
00093
00094
00095 BOOL updateRgbHslFromPoint ( S32 xPosIn, S32 yPosIn );
00096
00097
00098 void updateTextEntry ();
00099
00100 void stopUsingPipette();
00101
00102
00103 void setMouseDownInHueRegion ( BOOL mouse_down_in_region );
00104 BOOL getMouseDownInHueRegion () { return mMouseDownInHueRegion; };
00105
00106 void setMouseDownInLumRegion ( BOOL mouse_down_in_region );
00107 BOOL getMouseDownInLumRegion () { return mMouseDownInLumRegion; };
00108
00109 void setMouseDownInSwatch (BOOL mouse_down_in_swatch);
00110 BOOL getMouseDownInSwatch () { return mMouseDownInSwatch; }
00111
00112
00113 void onTextEntryChanged ( LLUICtrl* ctrl );
00114
00115
00116 void hslToRgb ( F32 hValIn, F32 sValIn, F32 lValIn, F32& rValOut, F32& gValOut, F32& bValOut );
00117 F32 hueToRgb ( F32 val1In, F32 val2In, F32 valHUeIn );
00118
00119 void setActive(BOOL active);
00120
00121 protected:
00122
00123 static void onClickCancel ( void* data );
00124 static void onClickSelect ( void* data );
00125 static void onClickPipette ( void* data );
00126 static void onTextCommit ( LLUICtrl* ctrl, void* data );
00127 static void onImmediateCheck ( LLUICtrl* ctrl, void* data );
00128 static void onColorSelect( const LLTextureEntry& te, void *data );
00129 private:
00130
00131 void enableTextCallbacks ( BOOL stateIn );
00132
00133
00134 void drawPalette ();
00135
00136
00137 LLColor4& getComplimentaryColor ( LLColor4& backgroundColor );
00138
00139
00140 F32 origR, origG, origB;
00141
00142
00143 F32 curR, curG, curB;
00144 F32 curH, curS, curL;
00145
00146 const S32 mComponents;
00147
00148 BOOL mMouseDownInLumRegion;
00149 BOOL mMouseDownInHueRegion;
00150 BOOL mMouseDownInSwatch;
00151
00152 const S32 mRGBViewerImageLeft;
00153 const S32 mRGBViewerImageTop;
00154 const S32 mRGBViewerImageWidth;
00155 const S32 mRGBViewerImageHeight;
00156
00157 const S32 mLumRegionLeft;
00158 const S32 mLumRegionTop;
00159 const S32 mLumRegionWidth;
00160 const S32 mLumRegionHeight;
00161 const S32 mLumMarkerSize;
00162
00163
00164 const S32 mSwatchRegionLeft;
00165 const S32 mSwatchRegionTop;
00166 const S32 mSwatchRegionWidth;
00167 const S32 mSwatchRegionHeight;
00168
00169 LLView* mSwatchView;
00170
00171 const S32 numPaletteColumns;
00172 const S32 numPaletteRows;
00173 std::vector < LLColor4* > mPalette;
00174 S32 highlightEntry;
00175 const S32 mPaletteRegionLeft;
00176 const S32 mPaletteRegionTop;
00177 const S32 mPaletteRegionWidth;
00178 const S32 mPaletteRegionHeight;
00179
00180
00181 LLPointer<LLImageGL> mRGBImage;
00182
00183
00184 LLColorSwatchCtrl* mSwatch;
00185
00186
00187 BOOL mActive;
00188
00189
00190 LLCheckBoxCtrl* mApplyImmediateCheck;
00191 BOOL mCanApplyImmediately;
00192
00193 LLButton* mSelectBtn;
00194 LLButton* mCancelBtn;
00195
00196 LLButton* mPipetteBtn;
00197
00198 F32 mContextConeOpacity;
00199 };
00200
00201 #endif // LL_LLFLOATERCOLORPICKER_H