Added hex input for color picker. FIRE-4805

ziree 2012-06-01 00:09:02 +02:00
parent ef15bd7555
commit be01514855
3 changed files with 74 additions and 0 deletions

View File

@ -238,6 +238,7 @@ BOOL LLFloaterColorPicker::postBuild()
childSetCommitCallback("rspin_lsl", onTextCommit, (void*)this );
childSetCommitCallback("gspin_lsl", onTextCommit, (void*)this );
childSetCommitCallback("bspin_lsl", onTextCommit, (void*)this );
childSetCommitCallback("hex_value", onTextCommit, (void*)this );
// </FS:Zi>
LLToolPipette::getInstance()->setToolSelectCallback(boost::bind(&LLFloaterColorPicker::onColorSelect, this, _1));
@ -716,6 +717,8 @@ void LLFloaterColorPicker::updateTextEntry ()
getChild<LLUICtrl>("rspin_lsl")->setValue(( getCurR () ) );
getChild<LLUICtrl>("gspin_lsl")->setValue(( getCurG () ) );
getChild<LLUICtrl>("bspin_lsl")->setValue(( getCurB () ) );
getChild<LLUICtrl>("hex_value")->setValue(llformat("%02x%02x%02x",(S32) (getCurR()*255.0),(S32) (getCurG()*255.0),(S32) (getCurB()*255.0)));
// </FS:Zi>
}
@ -780,6 +783,34 @@ void LLFloaterColorPicker::onTextEntryChanged ( LLUICtrl* ctrl )
updateTextEntry ();
}
else if ( name == "hex_value" )
{
// get current RGB
S32 r, g, b;
F32 rVal, gVal, bVal;
getCurRgb ( rVal, gVal, bVal );
std::string hex_string=ctrl->getValue().asString();
if(hex_string.length()!=6)
return;
LLStringUtil::toLower(hex_string);
if(hex_string.find_first_not_of("0123456789abcdef")!=std::string::npos)
return;
sscanf(hex_string.c_str(),"%02x%02x%02x", &r,&g,&b);
rVal=(F32) r/255.0;
gVal=(F32) g/255.0;
bVal=(F32) b/255.0;
// update current RGB (and implicitly HSL)
setCurRgb ( rVal, gVal, bVal );
updateTextEntry ();
}
// </FS:Zi>
else
// value in HSL boxes changed

View File

@ -196,6 +196,7 @@ class LLFloaterColorPicker
private:
LLButton* mCopyLSLBtn;
LLLineEditor* mHexValue;
// </FS:Zi>
};

View File

@ -14,6 +14,8 @@
layout="topleft"
left="4"
top="24"
label_pad_left="6"
tab_width="35"
width="130"
height="93">
<panel
@ -174,6 +176,46 @@
top_delta="0"
width="50" />
</panel>
<panel
label="Hex"
follows="left|top"
layout="topleft">
<text
type="string"
length="1"
follows="left|top"
height="20"
layout="topleft"
left="5"
top="16"
name="hex_text"
width="120">
Hex Code (#rrggbb):
</text>
<text
type="string"
length="1"
follows="left|top"
font="Monospace"
font.size="Large"
height="20"
layout="topleft"
top_pad="0"
left="12"
name="hex_hash_prefix"
width="10">
#
</text>
<line_editor
layout="topleft"
follows="left|top"
font="Monospace"
name="hex_value"
max_length_bytes="6"
left_pad="0"
height="20"
width="80" />
</panel>
</tab_container>
<text