Merge branch 'ColorPickerAdvanced' of https://github.com/Azaezel/Torque3D into ColorPickerAdvanced

This commit is contained in:
Azaezel 2016-02-21 16:07:51 -06:00
commit 7a60056365
4 changed files with 74 additions and 74 deletions

View file

@ -829,51 +829,51 @@ DefineConsoleFunction(ColorFloatToInt, ColorI, (ColorF color), ,
} }
DefineConsoleFunction(ColorIntToFloat, ColorF, (ColorI color), , DefineConsoleFunction(ColorIntToFloat, ColorF, (ColorI color), ,
"Convert from a integer color to an float color (0 to 255 to 0.0 - 1.0).\n" "Convert from a integer color to an float color (0 to 255 to 0.0 - 1.0).\n"
"@param color Integer color value to be converted in the form \"R G B A\", where R is red, G is green, B is blue, and A is alpha.\n" "@param color Integer color value to be converted in the form \"R G B A\", where R is red, G is green, B is blue, and A is alpha.\n"
"@return Converted color value (0.0 - 1.0)\n\n" "@return Converted color value (0.0 - 1.0)\n\n"
"@tsexample\n" "@tsexample\n"
"ColorIntToFloat( \"0 0 255 128\" ) // Returns \"0 0 1 0.5\".\n" "ColorIntToFloat( \"0 0 255 128\" ) // Returns \"0 0 1 0.5\".\n"
"@endtsexample\n" "@endtsexample\n"
"@ingroup Strings") "@ingroup Strings")
{ {
return (ColorF)color; return (ColorF)color;
} }
DefineConsoleFunction(ColorRGBToHEX, const char*, (ColorI color), , DefineConsoleFunction(ColorRGBToHEX, const char*, (ColorI color), ,
"Convert from a integer RGB (red, green, blue) color to hex color value (0 to 255 to 00 - FF).\n" "Convert from a integer RGB (red, green, blue) color to hex color value (0 to 255 to 00 - FF).\n"
"@param color Integer color value to be converted in the form \"R G B A\", where R is red, G is green, B is blue, and A is alpha. It excepts an alpha, but keep in mind this will not be converted.\n" "@param color Integer color value to be converted in the form \"R G B A\", where R is red, G is green, B is blue, and A is alpha. It excepts an alpha, but keep in mind this will not be converted.\n"
"@return Hex color value (#000000 - #FFFFFF), alpha isn't handled/converted so it is only the RGB value\n\n" "@return Hex color value (#000000 - #FFFFFF), alpha isn't handled/converted so it is only the RGB value\n\n"
"@tsexample\n" "@tsexample\n"
"ColorRBGToHEX( \"0 0 255 128\" ) // Returns \"#0000FF\".\n" "ColorRBGToHEX( \"0 0 255 128\" ) // Returns \"#0000FF\".\n"
"@endtsexample\n" "@endtsexample\n"
"@ingroup Strings") "@ingroup Strings")
{ {
return Con::getReturnBuffer(color.getHex()); return Con::getReturnBuffer(color.getHex());
} }
DefineConsoleFunction(ColorRGBToHSB, const char*, (ColorI color), , DefineConsoleFunction(ColorRGBToHSB, const char*, (ColorI color), ,
"Convert from a integer RGB (red, green, blue) color to HSB (hue, saturation, brightness). HSB is also know as HSL or HSV as well, with the last letter standing for lightness or value.\n" "Convert from a integer RGB (red, green, blue) color to HSB (hue, saturation, brightness). HSB is also know as HSL or HSV as well, with the last letter standing for lightness or value.\n"
"@param color Integer color value to be converted in the form \"R G B A\", where R is red, G is green, B is blue, and A is alpha. It excepts an alpha, but keep in mind this will not be converted.\n" "@param color Integer color value to be converted in the form \"R G B A\", where R is red, G is green, B is blue, and A is alpha. It excepts an alpha, but keep in mind this will not be converted.\n"
"@return HSB color value, alpha isn't handled/converted so it is only the RGB value\n\n" "@return HSB color value, alpha isn't handled/converted so it is only the RGB value\n\n"
"@tsexample\n" "@tsexample\n"
"ColorRBGToHSB( \"0 0 255 128\" ) // Returns \"240 100 100\".\n" "ColorRBGToHSB( \"0 0 255 128\" ) // Returns \"240 100 100\".\n"
"@endtsexample\n" "@endtsexample\n"
"@ingroup Strings") "@ingroup Strings")
{ {
ColorI::Hsb hsb(color.getHSB()); ColorI::Hsb hsb(color.getHSB());
String s(String::ToString(hsb.hue) + " " + String::ToString(hsb.sat) + " " + String::ToString(hsb.brightness)); String s(String::ToString(hsb.hue) + " " + String::ToString(hsb.sat) + " " + String::ToString(hsb.brightness));
return Con::getReturnBuffer(s); return Con::getReturnBuffer(s);
} }
DefineConsoleFunction(ColorHEXToRGB, ColorI, (const char* hex), , DefineConsoleFunction(ColorHEXToRGB, ColorI, (const char* hex), ,
"Convert from a hex color value to an integer RGB (red, green, blue) color (00 - FF to 0 to 255).\n" "Convert from a hex color value to an integer RGB (red, green, blue) color (00 - FF to 0 to 255).\n"
"@param hex Hex color value (#000000 - #FFFFFF) to be converted to an RGB (red, green, blue) value.\n" "@param hex Hex color value (#000000 - #FFFFFF) to be converted to an RGB (red, green, blue) value.\n"
"@return Integer color value to be converted in the form \"R G B A\", where R is red, G is green, B is blue, and A is alpha. Alpha isn't handled/converted so only pay attention to the RGB value\n\n" "@return Integer color value to be converted in the form \"R G B A\", where R is red, G is green, B is blue, and A is alpha. Alpha isn't handled/converted so only pay attention to the RGB value\n\n"
"@tsexample\n" "@tsexample\n"
"ColorHEXToRGB( \"#0000FF\" ) // Returns \"0 0 255 0\".\n" "ColorHEXToRGB( \"#0000FF\" ) // Returns \"0 0 255 0\".\n"
"@endtsexample\n" "@endtsexample\n"
"@ingroup Strings") "@ingroup Strings")
{ {
S32 rgb = dAtoui(hex, 16); S32 rgb = dAtoui(hex, 16);
@ -883,17 +883,17 @@ DefineConsoleFunction(ColorHEXToRGB, ColorI, (const char* hex), ,
} }
DefineConsoleFunction(ColorHSBToRGB, ColorI, (Point3I hsb), , DefineConsoleFunction(ColorHSBToRGB, ColorI, (Point3I hsb), ,
"Convert from a HSB (hue, saturation, brightness) to an integer RGB (red, green, blue) color. HSB is also know as HSL or HSV as well, with the last letter standing for lightness or value.\n" "Convert from a HSB (hue, saturation, brightness) to an integer RGB (red, green, blue) color. HSB is also know as HSL or HSV as well, with the last letter standing for lightness or value.\n"
"@param hsb HSB (hue, saturation, brightness) value to be converted.\n" "@param hsb HSB (hue, saturation, brightness) value to be converted.\n"
"@return Integer color value to be converted in the form \"R G B A\", where R is red, G is green, B is blue, and A is alpha. Alpha isn't handled/converted so only pay attention to the RGB value\n\n" "@return Integer color value to be converted in the form \"R G B A\", where R is red, G is green, B is blue, and A is alpha. Alpha isn't handled/converted so only pay attention to the RGB value\n\n"
"@tsexample\n" "@tsexample\n"
"ColorHSBToRGB( \"240 100 100\" ) // Returns \"0 0 255 0\".\n" "ColorHSBToRGB( \"240 100 100\" ) // Returns \"0 0 255 0\".\n"
"@endtsexample\n" "@endtsexample\n"
"@ingroup Strings") "@ingroup Strings")
{ {
ColorI color; ColorI color;
color.set(ColorI::Hsb(hsb.x, hsb.y, hsb.z)); color.set(ColorI::Hsb(hsb.x, hsb.y, hsb.z));
return color; return color;
} }
//============================================================================= //=============================================================================

View file

@ -127,12 +127,12 @@ class ColorI
struct Hsb struct Hsb
{ {
Hsb() :hue(0), sat(0), brightness(0){}; Hsb() :hue(0), sat(0), brightness(0){};
Hsb(U32 h, U32 s, U32 b) :hue(h), sat(s), brightness(b){}; Hsb(U32 h, U32 s, U32 b) :hue(h), sat(s), brightness(b){};
U32 hue; ///Hue U32 hue; ///Hue
U32 sat; ///Saturation U32 sat; ///Saturation
U32 brightness; //Brightness/Value/Lightness U32 brightness; //Brightness/Value/Lightness
}; };
public: public:

View file

@ -1254,27 +1254,27 @@ void GuiTextEditCtrl::onLoseFirstResponder()
Parent::onLoseFirstResponder(); Parent::onLoseFirstResponder();
} }
void GuiTextEditCtrl::onRender(Point2I offset, const RectI &updateRect) void GuiTextEditCtrl::onRender( Point2I offset, const RectI &updateRect )
{ {
RectI ctrlRect( offset, getExtent() ); RectI ctrlRect( offset, getExtent() );
//if opaque, fill the update rect with the fill color //if opaque, fill the update rect with the fill color
if ( mProfile->mOpaque ) if ( mProfile->mOpaque )
{ {
if (!mTextValid) if ( !mTextValid )
GFX->getDrawUtil()->drawRectFill(ctrlRect, mProfile->mFillColorERR); GFX->getDrawUtil()->drawRectFill( ctrlRect, mProfile->mFillColorERR );
else if (isFirstResponder()) else if ( isFirstResponder() )
GFX->getDrawUtil()->drawRectFill(ctrlRect, mProfile->mFillColorHL); GFX->getDrawUtil()->drawRectFill( ctrlRect, mProfile->mFillColorHL );
else else
GFX->getDrawUtil()->drawRectFill(ctrlRect, mProfile->mFillColor); GFX->getDrawUtil()->drawRectFill( ctrlRect, mProfile->mFillColor );
} }
//if there's a border, draw the border //if there's a border, draw the border
if (mProfile->mBorder) if ( mProfile->mBorder )
{ {
renderBorder(ctrlRect, mProfile); renderBorder( ctrlRect, mProfile );
if (!mTextValid) if ( !mTextValid )
GFX->getDrawUtil()->drawRectFill(ctrlRect, mProfile->mFillColorERR); GFX->getDrawUtil()->drawRectFill( ctrlRect, mProfile->mFillColorERR );
} }
drawText( ctrlRect, isFirstResponder() ); drawText( ctrlRect, isFirstResponder() );
@ -1498,25 +1498,25 @@ void GuiTextEditCtrl::drawText( const RectI &drawRect, bool isFocused )
bool GuiTextEditCtrl::hasText() bool GuiTextEditCtrl::hasText()
{ {
return (mTextBuffer.length()); return ( mTextBuffer.length() );
} }
void GuiTextEditCtrl::invalidText(bool playSound) void GuiTextEditCtrl::invalidText(bool playSound)
{ {
mTextValid = false; mTextValid = false;
if (playSound) if ( playSound )
playDeniedSound(); playDeniedSound();
} }
void GuiTextEditCtrl::validText() void GuiTextEditCtrl::validText()
{ {
mTextValid = true; mTextValid = true;
} }
bool GuiTextEditCtrl::isValidText() bool GuiTextEditCtrl::isValidText()
{ {
return mTextValid; return mTextValid;
} }
void GuiTextEditCtrl::playDeniedSound() void GuiTextEditCtrl::playDeniedSound()

View file

@ -104,16 +104,16 @@ DefineConsoleFunction( mRound, S32, ( F32 v ),,
} }
DefineConsoleFunction( mRoundColour, F32, ( F32 v, S32 n ), (0), DefineConsoleFunction( mRoundColour, F32, ( F32 v, S32 n ), (0),
"Round v to the nth decimal place or the nearest whole number by default." "Round v to the nth decimal place or the nearest whole number by default."
"@param v Value to roundn" "@param v Value to roundn"
"@param n Number of decimal places to round to, 0 by defaultn" "@param n Number of decimal places to round to, 0 by defaultn"
"@return The rounded value as a S32." "@return The rounded value as a S32."
"@ingroup Math") "@ingroup Math")
{ {
if (n <= 0) if (n <= 0)
return mRound(v); return mRound(v);
else else
return mRound(v, n); return mRound(v, n);
} }
DefineConsoleFunction( mCeil, S32, ( F32 v ),, DefineConsoleFunction( mCeil, S32, ( F32 v ),,