mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-16 00:54:54 +00:00
Merge branch 'ColorPickerAdvanced' of https://github.com/Azaezel/Torque3D into ColorPickerAdvanced
This commit is contained in:
commit
bc433e7c30
6 changed files with 257 additions and 276 deletions
|
|
@ -875,8 +875,10 @@ DefineConsoleFunction(ColorHEXToRGB, ColorI, (const char* hex), ,
|
||||||
"@endtsexample\n"
|
"@endtsexample\n"
|
||||||
"@ingroup Strings")
|
"@ingroup Strings")
|
||||||
{
|
{
|
||||||
|
S32 rgb = dAtoui(hex, 16);
|
||||||
|
|
||||||
ColorI color;
|
ColorI color;
|
||||||
color.set(hex);
|
color.set(rgb & 0x000000FF, (rgb & 0x0000FF00) >> 8, (rgb & 0x00FF0000) >> 16);
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,6 @@ ConsoleDocClass( GuiColorPickerCtrl,
|
||||||
"@internal"
|
"@internal"
|
||||||
);
|
);
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
GuiColorPickerCtrl::GuiColorPickerCtrl()
|
GuiColorPickerCtrl::GuiColorPickerCtrl()
|
||||||
{
|
{
|
||||||
setExtent(140, 30);
|
setExtent(140, 30);
|
||||||
|
|
@ -85,8 +84,6 @@ GuiColorPickerCtrl::~GuiColorPickerCtrl()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ImplementEnumType( GuiColorPickMode,
|
ImplementEnumType( GuiColorPickMode,
|
||||||
"\n\n"
|
"\n\n"
|
||||||
"@ingroup GuiUtil"
|
"@ingroup GuiUtil"
|
||||||
|
|
@ -102,24 +99,20 @@ ImplementEnumType( GuiColorPickMode,
|
||||||
{ GuiColorPickerCtrl::pDropperBackground, "Dropper" },
|
{ GuiColorPickerCtrl::pDropperBackground, "Dropper" },
|
||||||
EndImplementEnumType;
|
EndImplementEnumType;
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
void GuiColorPickerCtrl::initPersistFields()
|
void GuiColorPickerCtrl::initPersistFields()
|
||||||
{
|
{
|
||||||
addGroup("ColorPicker");
|
addGroup("ColorPicker");
|
||||||
|
|
||||||
addField("baseColor", TypeColorF, Offset(mBaseColor, GuiColorPickerCtrl));
|
addField("baseColor", TypeColorF, Offset(mBaseColor, GuiColorPickerCtrl));
|
||||||
addField("pickColor", TypeColorF, Offset(mPickColor, GuiColorPickerCtrl));
|
addField("pickColor", TypeColorF, Offset(mPickColor, GuiColorPickerCtrl));
|
||||||
addField("selectorGap", TypeS32, Offset(mSelectorGap, GuiColorPickerCtrl));
|
addField("selectorGap", TypeS32, Offset(mSelectorGap, GuiColorPickerCtrl));
|
||||||
addField("displayMode", TYPEID< PickMode >(), Offset(mDisplayMode, GuiColorPickerCtrl) );
|
addField("displayMode", TYPEID< PickMode >(), Offset(mDisplayMode, GuiColorPickerCtrl) );
|
||||||
addField("actionOnMove", TypeBool,Offset(mActionOnMove, GuiColorPickerCtrl));
|
addField("actionOnMove", TypeBool,Offset(mActionOnMove, GuiColorPickerCtrl));
|
||||||
addField("showReticle", TypeBool, Offset(mShowReticle, GuiColorPickerCtrl));
|
addField("showReticle", TypeBool, Offset(mShowReticle, GuiColorPickerCtrl));
|
||||||
|
|
||||||
endGroup("ColorPicker");
|
endGroup("ColorPicker");
|
||||||
|
|
||||||
Parent::initPersistFields();
|
Parent::initPersistFields();
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
// Function to draw a box which can have 4 different colors in each corner blended together
|
// Function to draw a box which can have 4 different colors in each corner blended together
|
||||||
void GuiColorPickerCtrl::drawBlendBox(RectI &bounds, ColorF &c1, ColorF &c2, ColorF &c3, ColorF &c4)
|
void GuiColorPickerCtrl::drawBlendBox(RectI &bounds, ColorF &c1, ColorF &c2, ColorF &c3, ColorF &c4)
|
||||||
{
|
{
|
||||||
|
|
@ -252,8 +245,7 @@ void GuiColorPickerCtrl::drawSelector(RectI &bounds, Point2I &selectorPos, Selec
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case sVertical:
|
case sVertical:
|
||||||
// Now draw the vertical selector
|
// Now draw the vertical selector Up -> Pos
|
||||||
// Up -> Pos
|
|
||||||
if (selectorPos.y != bounds.point.y+1)
|
if (selectorPos.y != bounds.point.y+1)
|
||||||
GFX->getDrawUtil()->drawLine(selectorPos.x, bounds.point.y, selectorPos.x, selectorPos.y-sMax-1, colorWhiteBlend);
|
GFX->getDrawUtil()->drawLine(selectorPos.x, bounds.point.y, selectorPos.x, selectorPos.y-sMax-1, colorWhiteBlend);
|
||||||
// Down -> Pos
|
// Down -> Pos
|
||||||
|
|
@ -261,8 +253,7 @@ void GuiColorPickerCtrl::drawSelector(RectI &bounds, Point2I &selectorPos, Selec
|
||||||
GFX->getDrawUtil()->drawLine(selectorPos.x, selectorPos.y + sMax, selectorPos.x, bounds.point.y + bounds.extent.y, colorWhiteBlend);
|
GFX->getDrawUtil()->drawLine(selectorPos.x, selectorPos.y + sMax, selectorPos.x, bounds.point.y + bounds.extent.y, colorWhiteBlend);
|
||||||
break;
|
break;
|
||||||
case sHorizontal:
|
case sHorizontal:
|
||||||
// Now draw the horizontal selector
|
// Now draw the horizontal selector Left -> Pos
|
||||||
// Left -> Pos
|
|
||||||
if (selectorPos.x != bounds.point.x)
|
if (selectorPos.x != bounds.point.x)
|
||||||
GFX->getDrawUtil()->drawLine(bounds.point.x, selectorPos.y-1, selectorPos.x-sMax, selectorPos.y-1, colorWhiteBlend);
|
GFX->getDrawUtil()->drawLine(bounds.point.x, selectorPos.y-1, selectorPos.x-sMax, selectorPos.y-1, colorWhiteBlend);
|
||||||
// Right -> Pos
|
// Right -> Pos
|
||||||
|
|
@ -365,6 +356,7 @@ void GuiColorPickerCtrl::onRender(Point2I offset, const RectI& updateRect)
|
||||||
|
|
||||||
mPositionChanged = false;
|
mPositionChanged = false;
|
||||||
Point2I extent = getRoot()->getExtent();
|
Point2I extent = getRoot()->getExtent();
|
||||||
|
|
||||||
// If we are anything but a pallete, change the pick color
|
// If we are anything but a pallete, change the pick color
|
||||||
if (mDisplayMode != pPallet)
|
if (mDisplayMode != pPallet)
|
||||||
{
|
{
|
||||||
|
|
@ -373,9 +365,7 @@ void GuiColorPickerCtrl::onRender(Point2I offset, const RectI& updateRect)
|
||||||
U32 buf_x = offset.x + mSelectorPos.x + 1;
|
U32 buf_x = offset.x + mSelectorPos.x + 1;
|
||||||
U32 buf_y = resolution.y - (extent.y - (offset.y + mSelectorPos.y + 1));
|
U32 buf_y = resolution.y - (extent.y - (offset.y + mSelectorPos.y + 1));
|
||||||
|
|
||||||
GFXTexHandle bb(resolution.x,
|
GFXTexHandle bb( resolution.x, resolution.y, GFXFormatR8G8B8A8, &GFXDefaultRenderTargetProfile, avar("%s() - bb (line %d)", __FUNCTION__, __LINE__) );
|
||||||
resolution.y,
|
|
||||||
GFXFormatR8G8B8A8, &GFXDefaultRenderTargetProfile, avar("%s() - bb (line %d)", __FUNCTION__, __LINE__));
|
|
||||||
|
|
||||||
Point2I tmpPt(buf_x, buf_y);
|
Point2I tmpPt(buf_x, buf_y);
|
||||||
|
|
||||||
|
|
@ -392,8 +382,6 @@ void GuiColorPickerCtrl::onRender(Point2I offset, const RectI& updateRect)
|
||||||
|
|
||||||
bb.copyToBmp(mBitmap);
|
bb.copyToBmp(mBitmap);
|
||||||
|
|
||||||
//bmp.writePNGDebug( "foo.png" );
|
|
||||||
|
|
||||||
if (!nullBitmap)
|
if (!nullBitmap)
|
||||||
{
|
{
|
||||||
if (mSelectColor)
|
if (mSelectColor)
|
||||||
|
|
@ -401,7 +389,6 @@ void GuiColorPickerCtrl::onRender(Point2I offset, const RectI& updateRect)
|
||||||
Point2I pos = findColor(mSetColor, offset, resolution, *mBitmap);
|
Point2I pos = findColor(mSetColor, offset, resolution, *mBitmap);
|
||||||
mSetColor = mSetColor.BLACK;
|
mSetColor = mSetColor.BLACK;
|
||||||
mSelectColor = false;
|
mSelectColor = false;
|
||||||
|
|
||||||
setSelectorPos(pos);
|
setSelectorPos(pos);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -417,7 +404,6 @@ void GuiColorPickerCtrl::onRender(Point2I offset, const RectI& updateRect)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//render the children
|
//render the children
|
||||||
|
|
@ -492,7 +478,6 @@ Point2I GuiColorPickerCtrl::findColor(const ColorF & color, const Point2I& offse
|
||||||
{
|
{
|
||||||
buf_x = offset.x + x + 1;
|
buf_x = offset.x + x + 1;
|
||||||
buf_y = (resolution.y - (offset.y + y + 1));
|
buf_y = (resolution.y - (offset.y + y + 1));
|
||||||
if (GFX->getAdapterType() != OpenGL)
|
|
||||||
buf_y = resolution.y - buf_y;
|
buf_y = resolution.y - buf_y;
|
||||||
|
|
||||||
//Get the color at that position
|
//Get the color at that position
|
||||||
|
|
@ -519,7 +504,6 @@ Point2I GuiColorPickerCtrl::findColor(const ColorF & color, const Point2I& offse
|
||||||
return closestPos;
|
return closestPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
void GuiColorPickerCtrl::setSelectorPos(const Point2I &pos)
|
void GuiColorPickerCtrl::setSelectorPos(const Point2I &pos)
|
||||||
{
|
{
|
||||||
Point2I extent = getExtent();
|
Point2I extent = getExtent();
|
||||||
|
|
@ -564,7 +548,6 @@ void GuiColorPickerCtrl::setSelectorPos(const Point2I &pos)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
void GuiColorPickerCtrl::onMouseDown(const GuiEvent &event)
|
void GuiColorPickerCtrl::onMouseDown(const GuiEvent &event)
|
||||||
{
|
{
|
||||||
if (!mActive)
|
if (!mActive)
|
||||||
|
|
@ -600,10 +583,8 @@ void GuiColorPickerCtrl::onMouseDragged(const GuiEvent &event)
|
||||||
|
|
||||||
if( !mActionOnMove )
|
if( !mActionOnMove )
|
||||||
execAltConsoleCallback();
|
execAltConsoleCallback();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
void GuiColorPickerCtrl::onMouseMove(const GuiEvent &event)
|
void GuiColorPickerCtrl::onMouseMove(const GuiEvent &event)
|
||||||
{
|
{
|
||||||
// Only for dropper mode
|
// Only for dropper mode
|
||||||
|
|
@ -611,20 +592,17 @@ void GuiColorPickerCtrl::onMouseMove(const GuiEvent &event)
|
||||||
setSelectorPos(globalToLocalCoord(event.mousePoint));
|
setSelectorPos(globalToLocalCoord(event.mousePoint));
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
void GuiColorPickerCtrl::onMouseEnter(const GuiEvent &event)
|
void GuiColorPickerCtrl::onMouseEnter(const GuiEvent &event)
|
||||||
{
|
{
|
||||||
mMouseOver = true;
|
mMouseOver = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
void GuiColorPickerCtrl::onMouseLeave(const GuiEvent &)
|
void GuiColorPickerCtrl::onMouseLeave(const GuiEvent &)
|
||||||
{
|
{
|
||||||
// Reset state
|
// Reset state
|
||||||
mMouseOver = false;
|
mMouseOver = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
void GuiColorPickerCtrl::onMouseUp(const GuiEvent &)
|
void GuiColorPickerCtrl::onMouseUp(const GuiEvent &)
|
||||||
{
|
{
|
||||||
//if we released the mouse within this control, perform the action
|
//if we released the mouse within this control, perform the action
|
||||||
|
|
@ -640,7 +618,6 @@ void GuiColorPickerCtrl::onMouseUp(const GuiEvent &)
|
||||||
mouseUnlock();
|
mouseUnlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
const char *GuiColorPickerCtrl::getScriptValue()
|
const char *GuiColorPickerCtrl::getScriptValue()
|
||||||
{
|
{
|
||||||
static char temp[256];
|
static char temp[256];
|
||||||
|
|
@ -649,7 +626,6 @@ const char *GuiColorPickerCtrl::getScriptValue()
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
void GuiColorPickerCtrl::setScriptValue(const char *value)
|
void GuiColorPickerCtrl::setScriptValue(const char *value)
|
||||||
{
|
{
|
||||||
ColorF newValue;
|
ColorF newValue;
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,6 @@ class GuiColorPickerCtrl : public GuiControl
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/// @name Core Rendering functions
|
/// @name Core Rendering functions
|
||||||
/// @{
|
/// @{
|
||||||
void renderColorBox(RectI &bounds); ///< Function that draws the actual color box
|
void renderColorBox(RectI &bounds); ///< Function that draws the actual color box
|
||||||
|
|
|
||||||
|
|
@ -1262,7 +1262,7 @@ void GuiTextEditCtrl::onRender(Point2I offset, const RectI &updateRect)
|
||||||
if ( mProfile->mOpaque )
|
if ( mProfile->mOpaque )
|
||||||
{
|
{
|
||||||
if (!mTextValid)
|
if (!mTextValid)
|
||||||
GFX->getDrawUtil()->drawRectFill(ctrlRect, mProfile->mFillColorNA);
|
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
|
||||||
|
|
@ -1274,7 +1274,7 @@ void GuiTextEditCtrl::onRender(Point2I offset, const RectI &updateRect)
|
||||||
{
|
{
|
||||||
renderBorder(ctrlRect, mProfile);
|
renderBorder(ctrlRect, mProfile);
|
||||||
if (!mTextValid)
|
if (!mTextValid)
|
||||||
GFX->getDrawUtil()->drawRectFill(ctrlRect, mProfile->mFillColorNA);
|
GFX->getDrawUtil()->drawRectFill(ctrlRect, mProfile->mFillColorERR);
|
||||||
}
|
}
|
||||||
|
|
||||||
drawText( ctrlRect, isFirstResponder() );
|
drawText( ctrlRect, isFirstResponder() );
|
||||||
|
|
|
||||||
|
|
@ -269,6 +269,7 @@ GuiControlProfile::GuiControlProfile(void) :
|
||||||
mFillColor(255,0,255,255),
|
mFillColor(255,0,255,255),
|
||||||
mFillColorHL(255,0,255,255),
|
mFillColorHL(255,0,255,255),
|
||||||
mFillColorNA(255,0,255,255),
|
mFillColorNA(255,0,255,255),
|
||||||
|
mFillColorERR(255,0,0,255),
|
||||||
mFillColorSEL(255,0,255,255),
|
mFillColorSEL(255,0,255,255),
|
||||||
mBorderColor(255,0,255,255),
|
mBorderColor(255,0,255,255),
|
||||||
mBorderColorHL(255,0,255,255),
|
mBorderColorHL(255,0,255,255),
|
||||||
|
|
@ -334,6 +335,7 @@ GuiControlProfile::GuiControlProfile(void) :
|
||||||
mFillColor = def->mFillColor;
|
mFillColor = def->mFillColor;
|
||||||
mFillColorHL = def->mFillColorHL;
|
mFillColorHL = def->mFillColorHL;
|
||||||
mFillColorNA = def->mFillColorNA;
|
mFillColorNA = def->mFillColorNA;
|
||||||
|
mFillColorERR = def->mFillColorERR;
|
||||||
mFillColorSEL = def->mFillColorSEL;
|
mFillColorSEL = def->mFillColorSEL;
|
||||||
|
|
||||||
mBorder = def->mBorder;
|
mBorder = def->mBorder;
|
||||||
|
|
@ -398,6 +400,7 @@ void GuiControlProfile::initPersistFields()
|
||||||
addField("fillColor", TypeColorI, Offset(mFillColor, GuiControlProfile));
|
addField("fillColor", TypeColorI, Offset(mFillColor, GuiControlProfile));
|
||||||
addField("fillColorHL", TypeColorI, Offset(mFillColorHL, GuiControlProfile));
|
addField("fillColorHL", TypeColorI, Offset(mFillColorHL, GuiControlProfile));
|
||||||
addField("fillColorNA", TypeColorI, Offset(mFillColorNA, GuiControlProfile));
|
addField("fillColorNA", TypeColorI, Offset(mFillColorNA, GuiControlProfile));
|
||||||
|
addField("fillColorERR", TypeColorI, Offset(mFillColorERR, GuiControlProfile));
|
||||||
addField("fillColorSEL", TypeColorI, Offset(mFillColorSEL, GuiControlProfile));
|
addField("fillColorSEL", TypeColorI, Offset(mFillColorSEL, GuiControlProfile));
|
||||||
addField("border", TypeS32, Offset(mBorder, GuiControlProfile),
|
addField("border", TypeS32, Offset(mBorder, GuiControlProfile),
|
||||||
"Border type (0=no border)." );
|
"Border type (0=no border)." );
|
||||||
|
|
|
||||||
|
|
@ -385,6 +385,7 @@ public:
|
||||||
ColorI mFillColor; ///< Fill color, this is used to fill the bounds of the control if it is opaque
|
ColorI mFillColor; ///< Fill color, this is used to fill the bounds of the control if it is opaque
|
||||||
ColorI mFillColorHL; ///< This is used instead of mFillColor if the object is highlighted
|
ColorI mFillColorHL; ///< This is used instead of mFillColor if the object is highlighted
|
||||||
ColorI mFillColorNA; ///< This is used instead of mFillColor if the object is not active or disabled
|
ColorI mFillColorNA; ///< This is used instead of mFillColor if the object is not active or disabled
|
||||||
|
ColorI mFillColorERR; ///< This is used instead of mFillColor if the object has an error or is invalid
|
||||||
ColorI mFillColorSEL; ///< This is used instead of mFillColor if the object is selected
|
ColorI mFillColorSEL; ///< This is used instead of mFillColor if the object is selected
|
||||||
|
|
||||||
S32 mBorder; ///< For most controls, if mBorder is > 0 a border will be drawn, some controls use this to draw different types of borders however @see guiDefaultControlRender.cc
|
S32 mBorder; ///< For most controls, if mBorder is > 0 a border will be drawn, some controls use this to draw different types of borders however @see guiDefaultControlRender.cc
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue