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
|
/**
* @file llfloatercolorpicker.h
* @brief Generic system color picker
*
* Copyright (c) 2004-$CurrentYear$, Linden Research, Inc.
* $License$
*/
#ifndef LL_LLFLOATERCOLORPICKER_H
#define LL_LLFLOATERCOLORPICKER_H
#include <vector>
#include "llfloater.h"
#include "llmemory.h"
#include "llcolorswatch.h"
#include "llspinctrl.h"
#include "lltextureentry.h"
class LLButton;
class LLLineEditor;
class LLCheckBoxCtrl;
//////////////////////////////////////////////////////////////////////////////
// floater class
class LLFloaterColorPicker
: public LLFloater
{
public:
LLFloaterColorPicker (LLColorSwatchCtrl* swatch, BOOL show_apply_immediate = FALSE);
virtual ~LLFloaterColorPicker ();
// overrides
virtual BOOL postBuild ();
virtual void draw ();
virtual BOOL handleMouseDown ( S32 x, S32 y, MASK mask );
virtual BOOL handleMouseUp ( S32 x, S32 y, MASK mask );
virtual BOOL handleHover ( S32 x, S32 y, MASK mask );
virtual void onClose(bool app_quitting);
// implicit methods
void createUI ();
void initUI ( F32 rValIn, F32 gValIn, F32 bValIn );
void showUI ();
void destroyUI ();
void cancelSelection ();
LLColorSwatchCtrl* getSwatch () { return mSwatch; };
// mutator / accessor for original RGB value
void setOrigRgb ( F32 origRIn, F32 origGIn, F32 origBIn );
void getOrigRgb ( F32& origROut, F32& origGOut, F32& origBOut );
F32 getOrigR () { return origR; };
F32 getOrigG () { return origG; };
F32 getOrigB () { return origB; };
// mutator / accessors for currernt RGB value
void setCurRgb ( F32 curRIn, F32 curGIn, F32 curBIn );
void getCurRgb ( F32& curROut, F32& curGOut, F32& curBOut );
F32 getCurR () { return curR; };
F32 getCurG () { return curG; };
F32 getCurB () { return curB; };
// mutator / accessors for currernt HSL value
void setCurHsl ( F32 curHIn, F32 curSIn, F32 curLIn );
void getCurHsl ( F32& curHOut, F32& curSOut, F32& curLOut );
F32 getCurH () { return curH; };
F32 getCurS () { return curS; };
F32 getCurL () { return curL; };
// updates current RGB/HSL values based on point in picker
BOOL updateRgbHslFromPoint ( S32 xPosIn, S32 yPosIn );
// updates text entry fields with current RGB/HSL
void updateTextEntry ();
void stopUsingPipette();
// mutator / accessor for mouse button pressed in region
void setMouseDownInHueRegion ( BOOL mouse_down_in_region );
BOOL getMouseDownInHueRegion () { return mMouseDownInHueRegion; };
void setMouseDownInLumRegion ( BOOL mouse_down_in_region );
BOOL getMouseDownInLumRegion () { return mMouseDownInLumRegion; };
void setMouseDownInSwatch (BOOL mouse_down_in_swatch);
BOOL getMouseDownInSwatch () { return mMouseDownInSwatch; }
// called when text entries (RGB/HSL etc.) are changed by user
void onTextEntryChanged ( LLUICtrl* ctrl );
// convert RGB to HSL and vice-versa
void hslToRgb ( F32 hValIn, F32 sValIn, F32 lValIn, F32& rValOut, F32& gValOut, F32& bValOut );
void rgbToHsl ( F32 rValIn, F32 gValIn, F32 bValIn, F32& hValOut, F32& sValOut, F32& lValOut );
F32 hueToRgb ( F32 val1In, F32 val2In, F32 valHUeIn );
void setActive(BOOL active);
static void onMouseCaptureLost(LLMouseHandler* old_captor);
protected:
// callbacks
static void onClickCancel ( void* data );
static void onClickSelect ( void* data );
static void onClickPipette ( void* data );
static void onTextCommit ( LLUICtrl* ctrl, void* data );
static void onImmediateCheck ( LLUICtrl* ctrl, void* data );
static void onColorSelect( const LLTextureEntry& te, void *data );
private:
// turns on or off text entry commit call backs
void enableTextCallbacks ( BOOL stateIn );
// draws color selection palette
void drawPalette ();
// find a complimentary color to the one passed in that can be used to highlight
LLColor4& getComplimentaryColor ( LLColor4& backgroundColor );
// original RGB values
F32 origR, origG, origB;
// current RGB/HSL values
F32 curR, curG, curB;
F32 curH, curS, curL;
const S32 mComponents;
BOOL mMouseDownInLumRegion;
BOOL mMouseDownInHueRegion;
BOOL mMouseDownInSwatch;
const S32 mRGBViewerImageLeft;
const S32 mRGBViewerImageTop;
const S32 mRGBViewerImageWidth;
const S32 mRGBViewerImageHeight;
const S32 mLumRegionLeft;
const S32 mLumRegionTop;
const S32 mLumRegionWidth;
const S32 mLumRegionHeight;
const S32 mLumMarkerSize;
// Preview of the current color.
const S32 mSwatchRegionLeft;
const S32 mSwatchRegionTop;
const S32 mSwatchRegionWidth;
const S32 mSwatchRegionHeight;
LLView* mSwatchView;
const S32 numPaletteColumns;
const S32 numPaletteRows;
std::vector < LLColor4* > mPalette;
S32 highlightEntry;
const S32 mPaletteRegionLeft;
const S32 mPaletteRegionTop;
const S32 mPaletteRegionWidth;
const S32 mPaletteRegionHeight;
// image used to compose color grid
LLPointer<LLImageGL> mRGBImage;
// current swatch in use
LLColorSwatchCtrl* mSwatch;
// are we actively tied to some output?
BOOL mActive;
// enable/disable immediate updates
LLCheckBoxCtrl* mApplyImmediateCheck;
BOOL mCanApplyImmediately;
LLButton* mSelectBtn;
LLButton* mCancelBtn;
LLButton* mPipetteBtn;
F32 mContextConeOpacity;
};
#endif // LL_LLFLOATERCOLORPICKER_H
|