From be015148557c5ba9cc40d12820aeda1c1706676b Mon Sep 17 00:00:00 2001 From: ziree Date: Fri, 1 Jun 2012 00:09:02 +0200 Subject: [PATCH] Added hex input for color picker. FIRE-4805 --- indra/newview/llfloatercolorpicker.cpp | 31 ++++++++++++++ indra/newview/llfloatercolorpicker.h | 1 + .../default/xui/en/floater_color_picker.xml | 42 +++++++++++++++++++ 3 files changed, 74 insertions(+) diff --git a/indra/newview/llfloatercolorpicker.cpp b/indra/newview/llfloatercolorpicker.cpp index c0c2cd7f94..3c453a5660 100644 --- a/indra/newview/llfloatercolorpicker.cpp +++ b/indra/newview/llfloatercolorpicker.cpp @@ -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 ); // LLToolPipette::getInstance()->setToolSelectCallback(boost::bind(&LLFloaterColorPicker::onColorSelect, this, _1)); @@ -716,6 +717,8 @@ void LLFloaterColorPicker::updateTextEntry () getChild("rspin_lsl")->setValue(( getCurR () ) ); getChild("gspin_lsl")->setValue(( getCurG () ) ); getChild("bspin_lsl")->setValue(( getCurB () ) ); + + getChild("hex_value")->setValue(llformat("%02x%02x%02x",(S32) (getCurR()*255.0),(S32) (getCurG()*255.0),(S32) (getCurB()*255.0))); // } @@ -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 (); + } // else // value in HSL boxes changed diff --git a/indra/newview/llfloatercolorpicker.h b/indra/newview/llfloatercolorpicker.h index 619f07bcb1..5004a0bef0 100644 --- a/indra/newview/llfloatercolorpicker.h +++ b/indra/newview/llfloatercolorpicker.h @@ -196,6 +196,7 @@ class LLFloaterColorPicker private: LLButton* mCopyLSLBtn; + LLLineEditor* mHexValue; // }; diff --git a/indra/newview/skins/default/xui/en/floater_color_picker.xml b/indra/newview/skins/default/xui/en/floater_color_picker.xml index 7a916f5bed..74a06d6d7c 100644 --- a/indra/newview/skins/default/xui/en/floater_color_picker.xml +++ b/indra/newview/skins/default/xui/en/floater_color_picker.xml @@ -14,6 +14,8 @@ layout="topleft" left="4" top="24" + label_pad_left="6" + tab_width="35" width="130" height="93"> + + + Hex Code (#rrggbb): + + + # + + +