Hex Values in color picker, as well as general cleanup of the color picker.
Signed-off-by: Beeks <HgDelirium@gmail.com>
This commit is contained in:
@@ -96,7 +96,7 @@ LLFloaterColorPicker (LLColorSwatchCtrl* swatch, BOOL show_apply_immediate )
|
|||||||
mLumMarkerSize ( 6 ),
|
mLumMarkerSize ( 6 ),
|
||||||
// *TODO: Specify this in XML
|
// *TODO: Specify this in XML
|
||||||
mSwatchRegionLeft ( 12 ),
|
mSwatchRegionLeft ( 12 ),
|
||||||
mSwatchRegionTop ( 190 ),
|
mSwatchRegionTop ( 170 ),
|
||||||
mSwatchRegionWidth ( 116 ),
|
mSwatchRegionWidth ( 116 ),
|
||||||
mSwatchRegionHeight ( 60 ),
|
mSwatchRegionHeight ( 60 ),
|
||||||
mSwatchView ( NULL ),
|
mSwatchView ( NULL ),
|
||||||
@@ -105,7 +105,7 @@ LLFloaterColorPicker (LLColorSwatchCtrl* swatch, BOOL show_apply_immediate )
|
|||||||
numPaletteRows ( 2 ),
|
numPaletteRows ( 2 ),
|
||||||
highlightEntry ( -1 ),
|
highlightEntry ( -1 ),
|
||||||
mPaletteRegionLeft ( 11 ),
|
mPaletteRegionLeft ( 11 ),
|
||||||
mPaletteRegionTop ( 100 - 8 ),
|
mPaletteRegionTop ( 92 ),
|
||||||
mPaletteRegionWidth ( mLumRegionLeft + mLumRegionWidth - 10 ),
|
mPaletteRegionWidth ( mLumRegionLeft + mLumRegionWidth - 10 ),
|
||||||
mPaletteRegionHeight ( 40 ),
|
mPaletteRegionHeight ( 40 ),
|
||||||
mSwatch ( swatch ),
|
mSwatch ( swatch ),
|
||||||
@@ -249,6 +249,7 @@ postBuild()
|
|||||||
childSetCommitCallback("hspin", onTextCommit, (void*)this );
|
childSetCommitCallback("hspin", onTextCommit, (void*)this );
|
||||||
childSetCommitCallback("sspin", onTextCommit, (void*)this );
|
childSetCommitCallback("sspin", onTextCommit, (void*)this );
|
||||||
childSetCommitCallback("lspin", onTextCommit, (void*)this );
|
childSetCommitCallback("lspin", onTextCommit, (void*)this );
|
||||||
|
childSetCommitCallback("hexval", onHexCommit, (void*)this );
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -615,8 +616,8 @@ void LLFloaterColorPicker::draw()
|
|||||||
|
|
||||||
// create rgb area outline
|
// create rgb area outline
|
||||||
gl_rect_2d ( mRGBViewerImageLeft,
|
gl_rect_2d ( mRGBViewerImageLeft,
|
||||||
mRGBViewerImageTop - mRGBViewerImageHeight,
|
mRGBViewerImageTop - mRGBViewerImageHeight + 1,
|
||||||
mRGBViewerImageLeft + mRGBViewerImageWidth,
|
mRGBViewerImageLeft + mRGBViewerImageWidth + 1,
|
||||||
mRGBViewerImageTop,
|
mRGBViewerImageTop,
|
||||||
LLColor4 ( 0.0f, 0.0f, 0.0f, 1.0f ),
|
LLColor4 ( 0.0f, 0.0f, 0.0f, 1.0f ),
|
||||||
FALSE );
|
FALSE );
|
||||||
@@ -635,7 +636,7 @@ void LLFloaterColorPicker::draw()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// draw luninance marker
|
// draw luminance marker
|
||||||
S32 startX = mLumRegionLeft + mLumRegionWidth;
|
S32 startX = mLumRegionLeft + mLumRegionWidth;
|
||||||
S32 startY = mLumRegionTop - mLumRegionHeight + ( S32 ) ( mLumRegionHeight * getCurL () );
|
S32 startY = mLumRegionTop - mLumRegionHeight + ( S32 ) ( mLumRegionHeight * getCurL () );
|
||||||
gl_triangle_2d ( startX, startY,
|
gl_triangle_2d ( startX, startY,
|
||||||
@@ -645,8 +646,8 @@ void LLFloaterColorPicker::draw()
|
|||||||
|
|
||||||
// draw luminance slider outline
|
// draw luminance slider outline
|
||||||
gl_rect_2d ( mLumRegionLeft,
|
gl_rect_2d ( mLumRegionLeft,
|
||||||
mLumRegionTop - mLumRegionHeight,
|
mLumRegionTop - mLumRegionHeight + 1,
|
||||||
mLumRegionLeft + mLumRegionWidth,
|
mLumRegionLeft + mLumRegionWidth + 1,
|
||||||
mLumRegionTop,
|
mLumRegionTop,
|
||||||
LLColor4 ( 0.0f, 0.0f, 0.0f, 1.0f ),
|
LLColor4 ( 0.0f, 0.0f, 0.0f, 1.0f ),
|
||||||
FALSE );
|
FALSE );
|
||||||
@@ -661,8 +662,8 @@ void LLFloaterColorPicker::draw()
|
|||||||
|
|
||||||
// draw selected color swatch outline
|
// draw selected color swatch outline
|
||||||
gl_rect_2d ( mSwatchRegionLeft,
|
gl_rect_2d ( mSwatchRegionLeft,
|
||||||
mSwatchRegionTop - mSwatchRegionHeight,
|
mSwatchRegionTop - mSwatchRegionHeight + 1,
|
||||||
mSwatchRegionLeft + mSwatchRegionWidth,
|
mSwatchRegionLeft + mSwatchRegionWidth + 1,
|
||||||
mSwatchRegionTop,
|
mSwatchRegionTop,
|
||||||
LLColor4 ( 0.0f, 0.0f, 0.0f, 1.0f ),
|
LLColor4 ( 0.0f, 0.0f, 0.0f, 1.0f ),
|
||||||
FALSE );
|
FALSE );
|
||||||
@@ -714,7 +715,7 @@ drawPalette ()
|
|||||||
// draw palette entry color
|
// draw palette entry color
|
||||||
if ( mPalette [ curEntry ] )
|
if ( mPalette [ curEntry ] )
|
||||||
{
|
{
|
||||||
gl_rect_2d ( x1 + 2, y1 - 2, x2 - 2, y2 + 2, *mPalette [ curEntry++ ], TRUE );
|
gl_rect_2d ( x1 + 1, y1 - 2, x2 - 2, y2 + 1, *mPalette [ curEntry++ ], TRUE );
|
||||||
gl_rect_2d ( x1 + 1, y1 - 1, x2 - 1, y2 + 1, LLColor4 ( 0.0f, 0.0f, 0.0f, 1.0f ), FALSE );
|
gl_rect_2d ( x1 + 1, y1 - 1, x2 - 1, y2 + 1, LLColor4 ( 0.0f, 0.0f, 0.0f, 1.0f ), FALSE );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -746,6 +747,50 @@ drawPalette ()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Convert to Hex.
|
||||||
|
std::string RGBToHex(int rNum, int gNum, int bNum)
|
||||||
|
{
|
||||||
|
std::string result;
|
||||||
|
char chr[255];
|
||||||
|
sprintf_s(chr, "%.2X", rNum);
|
||||||
|
result.append(chr);
|
||||||
|
sprintf_s(chr, "%.2X", gNum);
|
||||||
|
result.append(chr);
|
||||||
|
sprintf_s(chr, "%.2X", bNum);
|
||||||
|
result.append(chr);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Called when a hex value is entered into the Hex field - Convert and set values.
|
||||||
|
void
|
||||||
|
LLFloaterColorPicker::
|
||||||
|
onHexCommit ( LLUICtrl* ctrl, void* data )
|
||||||
|
{
|
||||||
|
if ( data )
|
||||||
|
{
|
||||||
|
LLFloaterColorPicker* self = ( LLFloaterColorPicker* )data;
|
||||||
|
if ( self )
|
||||||
|
{
|
||||||
|
char* pStop;
|
||||||
|
int num = strtol(ctrl->getValue().asString().c_str(), &pStop, 16);
|
||||||
|
int r = (num & 0xFF0000) >> 16;
|
||||||
|
int g = (num & 0xFF00) >> 8;
|
||||||
|
int b = num & 0xFF;
|
||||||
|
self->setCurRgb (r / 255.0f, g / 255.0f, b / 255.0f);
|
||||||
|
|
||||||
|
// HACK: turn off the call back wilst we update the text or we recurse ourselves into oblivion
|
||||||
|
self->enableTextCallbacks ( FALSE );
|
||||||
|
self->updateTextEntry ();
|
||||||
|
self->enableTextCallbacks ( TRUE );
|
||||||
|
if (self->mApplyImmediateCheck->get())
|
||||||
|
{
|
||||||
|
LLColorSwatchCtrl::onColorChanged ( self->getSwatch (), LLColorSwatchCtrl::COLOR_CHANGE );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
// update text entry values for RGB/HSL (can't be done in ::draw () since this overwrites input
|
// update text entry values for RGB/HSL (can't be done in ::draw () since this overwrites input
|
||||||
void
|
void
|
||||||
@@ -759,6 +804,7 @@ updateTextEntry ()
|
|||||||
childSetValue("hspin", ( getCurH () * 360.0f ) );
|
childSetValue("hspin", ( getCurH () * 360.0f ) );
|
||||||
childSetValue("sspin", ( getCurS () * 100.0f ) );
|
childSetValue("sspin", ( getCurS () * 100.0f ) );
|
||||||
childSetValue("lspin", ( getCurL () * 100.0f ) );
|
childSetValue("lspin", ( getCurL () * 100.0f ) );
|
||||||
|
childSetValue("hexval", RGBToHex(getCurR() * 255, getCurG() * 255, getCurB() * 255));
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -775,6 +821,7 @@ enableTextCallbacks ( BOOL stateIn )
|
|||||||
childSetCommitCallback("hspin", onTextCommit, (void*)this );
|
childSetCommitCallback("hspin", onTextCommit, (void*)this );
|
||||||
childSetCommitCallback("sspin", onTextCommit, (void*)this );
|
childSetCommitCallback("sspin", onTextCommit, (void*)this );
|
||||||
childSetCommitCallback("lspin", onTextCommit, (void*)this );
|
childSetCommitCallback("lspin", onTextCommit, (void*)this );
|
||||||
|
childSetCommitCallback("hexval", onHexCommit, (void*)this );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -784,6 +831,7 @@ enableTextCallbacks ( BOOL stateIn )
|
|||||||
childSetCommitCallback("hspin", 0, (void*)this );
|
childSetCommitCallback("hspin", 0, (void*)this );
|
||||||
childSetCommitCallback("sspin", 0, (void*)this );
|
childSetCommitCallback("sspin", 0, (void*)this );
|
||||||
childSetCommitCallback("lspin", 0, (void*)this );
|
childSetCommitCallback("lspin", 0, (void*)this );
|
||||||
|
childSetCommitCallback("hexval", 0, (void*)this );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ class LLFloaterColorPicker
|
|||||||
static void onClickSelect ( void* data );
|
static void onClickSelect ( void* data );
|
||||||
static void onClickPipette ( void* data );
|
static void onClickPipette ( void* data );
|
||||||
static void onTextCommit ( LLUICtrl* ctrl, void* data );
|
static void onTextCommit ( LLUICtrl* ctrl, void* data );
|
||||||
|
static void onHexCommit ( LLUICtrl* ctrl, void* data );
|
||||||
static void onImmediateCheck ( LLUICtrl* ctrl, void* data );
|
static void onImmediateCheck ( LLUICtrl* ctrl, void* data );
|
||||||
static void onColorSelect( const LLTextureEntry& te, void *data );
|
static void onColorSelect( const LLTextureEntry& te, void *data );
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -55,30 +55,40 @@
|
|||||||
Lum:
|
Lum:
|
||||||
</text>
|
</text>
|
||||||
<spinner bottom="-166" decimal_digits="0" follows="left" height="16" increment="1"
|
<spinner bottom="-166" decimal_digits="0" follows="left" height="16" increment="1"
|
||||||
initial_val="50" left="75" max_val="100" min_val="0" mouse_opaque="true"
|
initial_val="50" left="75" max_val="100" min_val="0" mouse_opaque="true"
|
||||||
name="lspin" width="50" />
|
name="lspin" width="50" />
|
||||||
<check_box bottom="-373" follows="left|bottom" font="SansSerifSmall" height="20"
|
<check_box bottom="-373" follows="left|bottom" font="SansSerifSmall" height="20"
|
||||||
initial_value="false" label="Apply Immediately" left="12"
|
initial_value="false" label="Apply Immediately" left="12"
|
||||||
mouse_opaque="true" name="apply_immediate" width="100" />
|
mouse_opaque="true" name="apply_immediate" width="100" />
|
||||||
<button bottom="-373" follows="left|top" font="SansSerif" halign="center" height="32"
|
<button bottom="-373" follows="left|top" font="SansSerif" halign="center" height="32"
|
||||||
label="" label_selected="" left_delta="130" mouse_opaque="true"
|
label="" label_selected="" left_delta="130" mouse_opaque="true"
|
||||||
name="color_pipette" width="32" />
|
name="color_pipette" width="32" />
|
||||||
<button bottom="-373" follows="right|bottom" font="SansSerif" halign="center"
|
<button bottom="-373" follows="right|bottom" font="SansSerif" halign="center"
|
||||||
height="20" label="Cancel" label_selected="Cancel" left_delta="75"
|
height="20" label="Cancel" label_selected="Cancel" left_delta="75"
|
||||||
mouse_opaque="true" name="cancel_btn" width="100" />
|
mouse_opaque="true" name="cancel_btn" width="100" />
|
||||||
<button bottom="-373" follows="right|bottom" font="SansSerif" halign="center"
|
<button bottom="-373" follows="right|bottom" font="SansSerif" halign="center"
|
||||||
height="20" label="Select" label_selected="Select" left_delta="104"
|
height="20" label="Select" label_selected="Select" left_delta="104"
|
||||||
mouse_opaque="true" name="select_btn" width="100" />
|
mouse_opaque="true" name="select_btn" width="100" />
|
||||||
<text bg_visible="false" border_drop_shadow_visible="false" border_visible="false"
|
<text bg_visible="false" border_drop_shadow_visible="false" border_visible="false"
|
||||||
bottom="-188" drop_shadow_visible="true" follows="left|top"
|
bottom="-190" drop_shadow_visible="true" follows="left|top"
|
||||||
font="SansSerifSmall" h_pad="0" halign="left" height="16" left="12"
|
font="SansSerifSmall" h_pad="0" halign="left" height="16" left="12"
|
||||||
mouse_opaque="true" name="Current color:" v_pad="0" width="110">
|
mouse_opaque="true" name="Hex Value:" v_pad="0" width="110">
|
||||||
|
Hex:
|
||||||
|
</text>
|
||||||
|
<line_editor bevel_style="in" border_style="line" border_thickness="1" bottom_delta="0" follows="left|top"
|
||||||
|
font="SansSerifSmall" height="18" left_delta="64" max_length="7" mouse_opaque="true"
|
||||||
|
tool_tip="" name="hexval" control_name="ColorHexValue"
|
||||||
|
width="49"/>
|
||||||
|
<text bg_visible="false" border_drop_shadow_visible="false" border_visible="false"
|
||||||
|
bottom="-210" drop_shadow_visible="true" follows="left|top"
|
||||||
|
font="SansSerifSmall" h_pad="0" halign="left" height="16" left="12"
|
||||||
|
mouse_opaque="true" name="Current color:" v_pad="0" width="110">
|
||||||
Current color:
|
Current color:
|
||||||
</text>
|
</text>
|
||||||
<text bg_visible="false" border_drop_shadow_visible="false" border_visible="false"
|
<text bg_visible="false" border_drop_shadow_visible="false" border_visible="false"
|
||||||
bottom="-270" drop_shadow_visible="true" follows="left|top"
|
bottom="-288" drop_shadow_visible="true" follows="left|top"
|
||||||
font="SansSerifSmall" h_pad="0" halign="left" height="16" left="12"
|
font="SansSerifSmall" h_pad="0" halign="left" height="16" left="12"
|
||||||
mouse_opaque="true" name="(Drag below to save.)" v_pad="0" width="110">
|
mouse_opaque="true" name="(Drag below to save.)" v_pad="0" width="110">
|
||||||
(Drag below to save.)
|
Drag below to save.
|
||||||
</text>
|
</text>
|
||||||
</floater>
|
</floater>
|
||||||
|
|||||||
Reference in New Issue
Block a user