mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 03:33:48 +00:00
Color Picker
This commit is contained in:
parent
39f0e269d6
commit
03109c9d6d
9 changed files with 2424 additions and 642 deletions
|
|
@ -128,6 +128,8 @@ GuiTextEditCtrl::GuiTextEditCtrl()
|
|||
|
||||
mActive = true;
|
||||
|
||||
mTextValid = true;
|
||||
|
||||
mTextOffsetReset = true;
|
||||
|
||||
mHistoryDirty = false;
|
||||
|
|
@ -1257,15 +1259,21 @@ void GuiTextEditCtrl::onRender(Point2I offset, const RectI &updateRect)
|
|||
//if opaque, fill the update rect with the fill color
|
||||
if ( mProfile->mOpaque )
|
||||
{
|
||||
if(isFirstResponder())
|
||||
GFX->getDrawUtil()->drawRectFill( ctrlRect, mProfile->mFillColorHL );
|
||||
else
|
||||
GFX->getDrawUtil()->drawRectFill( ctrlRect, mProfile->mFillColor );
|
||||
if (!mTextValid)
|
||||
GFX->getDrawUtil()->drawRectFill(ctrlRect, mProfile->mFillColorNA);
|
||||
else if (isFirstResponder())
|
||||
GFX->getDrawUtil()->drawRectFill(ctrlRect, mProfile->mFillColorHL);
|
||||
else
|
||||
GFX->getDrawUtil()->drawRectFill(ctrlRect, mProfile->mFillColor);
|
||||
}
|
||||
|
||||
//if there's a border, draw the border
|
||||
if ( mProfile->mBorder )
|
||||
renderBorder( ctrlRect, mProfile );
|
||||
if (mProfile->mBorder)
|
||||
{
|
||||
renderBorder(ctrlRect, mProfile);
|
||||
if (!mTextValid)
|
||||
GFX->getDrawUtil()->drawRectFill(ctrlRect, mProfile->mFillColorNA);
|
||||
}
|
||||
|
||||
drawText( ctrlRect, isFirstResponder() );
|
||||
}
|
||||
|
|
@ -1491,6 +1499,24 @@ bool GuiTextEditCtrl::hasText()
|
|||
return (mTextBuffer.length());
|
||||
}
|
||||
|
||||
void GuiTextEditCtrl::invalidText(bool playSound)
|
||||
{
|
||||
mTextValid = false;
|
||||
|
||||
if (playSound)
|
||||
playDeniedSound();
|
||||
}
|
||||
|
||||
void GuiTextEditCtrl::validText()
|
||||
{
|
||||
mTextValid = true;
|
||||
}
|
||||
|
||||
bool GuiTextEditCtrl::isValidText()
|
||||
{
|
||||
return mTextValid;
|
||||
}
|
||||
|
||||
void GuiTextEditCtrl::playDeniedSound()
|
||||
{
|
||||
if ( mDeniedSound )
|
||||
|
|
@ -1518,27 +1544,29 @@ void GuiTextEditCtrl::handleCharInput( U16 ascii )
|
|||
//see if it's a number field
|
||||
if ( mProfile->mNumbersOnly )
|
||||
{
|
||||
if ( ascii == '-')
|
||||
{
|
||||
//a minus sign only exists at the beginning, and only a single minus sign
|
||||
if ( mCursorPos != 0 && !isAllTextSelected() )
|
||||
{
|
||||
playDeniedSound();
|
||||
return;
|
||||
}
|
||||
if (ascii == '-')
|
||||
{
|
||||
//a minus sign only exists at the beginning, and only a single minus sign
|
||||
if (mCursorPos != 0 && !isAllTextSelected())
|
||||
{
|
||||
invalidText();
|
||||
return;
|
||||
}
|
||||
|
||||
if ( mInsertOn && ( mTextBuffer.getChar(0) == '-' ) )
|
||||
{
|
||||
playDeniedSound();
|
||||
return;
|
||||
}
|
||||
}
|
||||
// BJTODO: This is probably not unicode safe.
|
||||
else if ( ascii != '.' && (ascii < '0' || ascii > '9') )
|
||||
{
|
||||
playDeniedSound();
|
||||
return;
|
||||
}
|
||||
if (mInsertOn && (mTextBuffer.getChar(0) == '-'))
|
||||
{
|
||||
invalidText();
|
||||
return;
|
||||
}
|
||||
}
|
||||
// BJTODO: This is probably not unicode safe.
|
||||
else if (ascii != '.' && (ascii < '0' || ascii > '9'))
|
||||
{
|
||||
invalidText();
|
||||
return;
|
||||
}
|
||||
else
|
||||
validText();
|
||||
}
|
||||
|
||||
//save the current state
|
||||
|
|
@ -1746,3 +1774,24 @@ DefineEngineMethod( GuiTextEditCtrl, forceValidateText, void, (),,
|
|||
{
|
||||
object->forceValidateText();
|
||||
}
|
||||
|
||||
DefineEngineMethod(GuiTextEditCtrl, invalidText, void, (bool playSound), (true),
|
||||
"@brief Trigger the invalid sound and make the box red.nn"
|
||||
"@param playSound Play the invalid text sound or not.n")
|
||||
{
|
||||
object->invalidText(playSound);
|
||||
}
|
||||
|
||||
|
||||
DefineEngineMethod(GuiTextEditCtrl, validText, void, (), ,
|
||||
"@brief Restores the box to normal color.nn")
|
||||
{
|
||||
object->validText();
|
||||
}
|
||||
|
||||
DefineEngineMethod(GuiTextEditCtrl, isValidText, bool, (), ,
|
||||
"@brief Returns if the text is set to valid or not.n"
|
||||
"@Return true if text is set to valid, false if not.nn")
|
||||
{
|
||||
return object->isValidText();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue