mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-05 05:20:31 +00:00
Implementation of sRGB image support. Overhauls the linearization setup to utilize the sRGB image types, as well as refactors the use of ColorF and ColorI to be properly internally consistent. ColorIs are used only for front-facing/editing/UI settings, and ColorFs, now renamed to LinearColorF to reduce confusion of purpose, are used for color info in the engine itself. This avoids confusing and expensive conversions back and forth between types and avoids botches with linearity. Majority work done by @rextimmy
This commit is contained in:
parent
8780f83262
commit
25686ed4be
294 changed files with 3894 additions and 2813 deletions
|
|
@ -32,11 +32,11 @@
|
|||
|
||||
/// @name Common colors we use
|
||||
/// @{
|
||||
ColorF colorWhite(1.,1.,1.);
|
||||
ColorF colorWhiteBlend(1.,1.,1.,.75);
|
||||
ColorF colorBlack(.0,.0,.0);
|
||||
ColorF colorAlpha(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
ColorF colorAlphaW(1.0f, 1.0f, 1.0f, 0.0f);
|
||||
LinearColorF colorWhite(1.,1.,1.);
|
||||
LinearColorF colorWhiteBlend(1.,1.,1.,.75);
|
||||
LinearColorF colorBlack(.0,.0,.0);
|
||||
LinearColorF colorAlpha(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
LinearColorF colorAlphaW(1.0f, 1.0f, 1.0f, 0.0f);
|
||||
|
||||
ColorI GuiColorPickerCtrl::mColorRange[7] = {
|
||||
ColorI(255,0,0), // Red
|
||||
|
|
@ -52,7 +52,7 @@ ColorI GuiColorPickerCtrl::mColorRange[7] = {
|
|||
IMPLEMENT_CONOBJECT(GuiColorPickerCtrl);
|
||||
|
||||
ConsoleDocClass( GuiColorPickerCtrl,
|
||||
"@brief Editor GUI used for picking a ColorF from a palette.\n\n"
|
||||
"@brief Editor GUI used for picking a LinearColorF from a palette.\n\n"
|
||||
"@note Editor use only.\n\n"
|
||||
"@internal"
|
||||
);
|
||||
|
|
@ -61,8 +61,8 @@ GuiColorPickerCtrl::GuiColorPickerCtrl()
|
|||
{
|
||||
setExtent(140, 30);
|
||||
mDisplayMode = pPallet;
|
||||
mBaseColor = ColorF(1.,.0,1.);
|
||||
mPickColor = ColorF(.0,.0,.0);
|
||||
mBaseColor = LinearColorF(1.,.0,1.);
|
||||
mPickColor = LinearColorF(.0,.0,.0);
|
||||
mSelectorPos = Point2I(0,0);
|
||||
mMouseDown = mMouseOver = false;
|
||||
mActive = true;
|
||||
|
|
@ -73,7 +73,6 @@ GuiColorPickerCtrl::GuiColorPickerCtrl()
|
|||
mSelectColor = false;
|
||||
mSetColor = mSetColor.BLACK;
|
||||
mBitmap = NULL;
|
||||
mUseSRGB = false;
|
||||
}
|
||||
|
||||
GuiColorPickerCtrl::~GuiColorPickerCtrl()
|
||||
|
|
@ -105,7 +104,6 @@ void GuiColorPickerCtrl::initPersistFields()
|
|||
addGroup("ColorPicker");
|
||||
addField("baseColor", TypeColorF, Offset(mBaseColor, GuiColorPickerCtrl));
|
||||
addField("pickColor", TypeColorF, Offset(mPickColor, GuiColorPickerCtrl));
|
||||
addField("useSRGB", TypeBool, Offset(mUseSRGB, GuiColorPickerCtrl), "Render using sRGB scale");
|
||||
addField("selectorGap", TypeS32, Offset(mSelectorGap, GuiColorPickerCtrl));
|
||||
addField("displayMode", TYPEID< PickMode >(), Offset(mDisplayMode, GuiColorPickerCtrl) );
|
||||
addField("actionOnMove", TypeBool,Offset(mActionOnMove, GuiColorPickerCtrl));
|
||||
|
|
@ -116,25 +114,19 @@ void GuiColorPickerCtrl::initPersistFields()
|
|||
}
|
||||
|
||||
// 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, LinearColorF &c1, LinearColorF &c2, LinearColorF &c3, LinearColorF &c4)
|
||||
{
|
||||
GFX->setStateBlock(mStateBlock);
|
||||
|
||||
S32 l = bounds.point.x, r = bounds.point.x + bounds.extent.x;
|
||||
S32 t = bounds.point.y, b = bounds.point.y + bounds.extent.y;
|
||||
|
||||
ColorF col[4];
|
||||
LinearColorF col[4];
|
||||
col[0] = c1;
|
||||
col[1] = c2;
|
||||
col[2] = c3;
|
||||
col[3] = c4;
|
||||
if (!mUseSRGB)
|
||||
{
|
||||
for (U32 i = 0; i < 4; i++)
|
||||
col[i] = col[i].toGamma();
|
||||
}
|
||||
|
||||
//A couple of checks to determine if color blend
|
||||
//A couple of checks to determine if color blend
|
||||
if (c1 == colorWhite && c3 == colorAlpha && c4 == colorBlack)
|
||||
{
|
||||
|
|
@ -224,17 +216,8 @@ void GuiColorPickerCtrl::drawBlendRangeBox(RectI &bounds, bool vertical, U8 numC
|
|||
|
||||
ColorI *col = new ColorI[numColors];
|
||||
dMemcpy(col, colors, numColors * sizeof(ColorI));
|
||||
if (mUseSRGB)
|
||||
{
|
||||
for (U16 i = 0; i < numColors - 1; i++)
|
||||
for (U16 i = 0; i < numColors - 1; i++)
|
||||
col[i] = colors[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
for (U16 i = 0; i < numColors - 1; i++)
|
||||
col[i] = colors[i].toGamma();
|
||||
}
|
||||
|
||||
|
||||
for (U16 i = 0; i < numColors - 1; i++)
|
||||
{
|
||||
|
|
@ -273,6 +256,8 @@ void GuiColorPickerCtrl::drawBlendRangeBox(RectI &bounds, bool vertical, U8 numC
|
|||
}
|
||||
PrimBuild::end();
|
||||
}
|
||||
|
||||
SAFE_DELETE_ARRAY(col);
|
||||
}
|
||||
|
||||
void GuiColorPickerCtrl::drawSelector(RectI &bounds, Point2I &selectorPos, SelectorMode mode)
|
||||
|
|
@ -281,23 +266,24 @@ void GuiColorPickerCtrl::drawSelector(RectI &bounds, Point2I &selectorPos, Selec
|
|||
return;
|
||||
|
||||
U16 sMax = mSelectorGap*2;
|
||||
const ColorI color = colorWhiteBlend.toColorI();
|
||||
switch (mode)
|
||||
{
|
||||
case sVertical:
|
||||
// Now draw the vertical selector Up -> Pos
|
||||
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, color);
|
||||
// Down -> Pos
|
||||
if (selectorPos.y != bounds.point.y+bounds.extent.y)
|
||||
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, color);
|
||||
break;
|
||||
case sHorizontal:
|
||||
// Now draw the horizontal selector Left -> Pos
|
||||
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, color);
|
||||
// Right -> Pos
|
||||
if (selectorPos.x != bounds.point.x)
|
||||
GFX->getDrawUtil()->drawLine(bounds.point.x+mSelectorPos.x+sMax, selectorPos.y-1, bounds.point.x + bounds.extent.x, selectorPos.y-1, colorWhiteBlend);
|
||||
GFX->getDrawUtil()->drawLine(bounds.point.x+mSelectorPos.x+sMax, selectorPos.y-1, bounds.point.x + bounds.extent.x, selectorPos.y-1, color);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -339,7 +325,7 @@ void GuiColorPickerCtrl::renderColorBox(RectI &bounds)
|
|||
drawBlendBox( blendRect, colorAlpha, colorAlpha, colorBlack, colorBlack );
|
||||
blendRect.point.y += blendRect.extent.y - 1;
|
||||
blendRect.extent.y = 2;
|
||||
GFX->getDrawUtil()->drawRect( blendRect, colorBlack);
|
||||
GFX->getDrawUtil()->drawRect( blendRect, colorBlack.toColorI());
|
||||
drawSelector( pickerBounds, selectorPos, sHorizontal );
|
||||
drawSelector( pickerBounds, selectorPos, sVertical );
|
||||
break;
|
||||
|
|
@ -366,7 +352,7 @@ void GuiColorPickerCtrl::renderColorBox(RectI &bounds)
|
|||
break;
|
||||
case pPallet:
|
||||
default:
|
||||
GFX->getDrawUtil()->drawRectFill( pickerBounds, mBaseColor );
|
||||
GFX->getDrawUtil()->drawRectFill( pickerBounds, mBaseColor.toColorI());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -404,7 +390,7 @@ void GuiColorPickerCtrl::onRender(Point2I offset, const RectI& updateRect)
|
|||
U32 buf_x = offset.x + mSelectorPos.x + 1;
|
||||
U32 buf_y = resolution.y - (extent.y - (offset.y + mSelectorPos.y + 1));
|
||||
|
||||
GFXTexHandle bb( resolution.x, resolution.y, GFXFormatR8G8B8A8, &GFXDefaultRenderTargetProfile, avar("%s() - bb (line %d)", __FUNCTION__, __LINE__) );
|
||||
GFXTexHandle bb(resolution.x, resolution.y, GFXFormatR8G8B8A8_SRGB, &GFXRenderTargetSRGBProfile, avar("%s() - bb (line %d)", __FUNCTION__, __LINE__));
|
||||
|
||||
Point2I tmpPt(buf_x, buf_y);
|
||||
|
||||
|
|
@ -417,7 +403,7 @@ void GuiColorPickerCtrl::onRender(Point2I offset, const RectI& updateRect)
|
|||
mBitmap = NULL;
|
||||
}
|
||||
|
||||
mBitmap = new GBitmap(bb.getWidth(), bb.getHeight());
|
||||
mBitmap = new GBitmap(bb.getWidth(), bb.getHeight(),false,GFXFormatR8G8B8A8);
|
||||
|
||||
bb.copyToBmp(mBitmap);
|
||||
|
||||
|
|
@ -435,7 +421,7 @@ void GuiColorPickerCtrl::onRender(Point2I offset, const RectI& updateRect)
|
|||
ColorI tmp;
|
||||
mBitmap->getColor(buf_x, buf_y, tmp);
|
||||
|
||||
mPickColor = (ColorF)tmp;
|
||||
mPickColor = (LinearColorF)tmp;
|
||||
|
||||
// Now do onAction() if we are allowed
|
||||
if (mActionOnMove)
|
||||
|
|
@ -449,7 +435,7 @@ void GuiColorPickerCtrl::onRender(Point2I offset, const RectI& updateRect)
|
|||
renderChildControls(offset, updateRect);
|
||||
}
|
||||
|
||||
void GuiColorPickerCtrl::setSelectorPos(const ColorF & color)
|
||||
void GuiColorPickerCtrl::setSelectorPos(const LinearColorF & color)
|
||||
{
|
||||
if (mBitmap && !mPositionChanged)
|
||||
{
|
||||
|
|
@ -469,7 +455,7 @@ void GuiColorPickerCtrl::setSelectorPos(const ColorF & color)
|
|||
}
|
||||
}
|
||||
|
||||
Point2I GuiColorPickerCtrl::findColor(const ColorF & color, const Point2I& offset, const Point2I& resolution, GBitmap& bmp)
|
||||
Point2I GuiColorPickerCtrl::findColor(const LinearColorF & color, const Point2I& offset, const Point2I& resolution, GBitmap& bmp)
|
||||
{
|
||||
RectI rect;
|
||||
Point2I ext = getExtent();
|
||||
|
|
@ -506,7 +492,7 @@ Point2I GuiColorPickerCtrl::findColor(const ColorF & color, const Point2I& offse
|
|||
ColorI tmp;
|
||||
U32 buf_x;
|
||||
U32 buf_y;
|
||||
ColorF curColor;
|
||||
LinearColorF curColor;
|
||||
F32 val(10000.0f);
|
||||
F32 closestVal(10000.0f);
|
||||
bool closestSet = false;
|
||||
|
|
@ -521,7 +507,7 @@ Point2I GuiColorPickerCtrl::findColor(const ColorF & color, const Point2I& offse
|
|||
|
||||
//Get the color at that position
|
||||
bmp.getColor(buf_x, buf_y, tmp);
|
||||
curColor = (ColorF)tmp;
|
||||
curColor = (LinearColorF)tmp;
|
||||
|
||||
//Evaluate how close the color is to our desired color
|
||||
val = mFabs(color.red - curColor.red) + mFabs(color.green - curColor.green) + mFabs(color.blue - curColor.blue);
|
||||
|
|
@ -660,14 +646,14 @@ void GuiColorPickerCtrl::onMouseUp(const GuiEvent &)
|
|||
const char *GuiColorPickerCtrl::getScriptValue()
|
||||
{
|
||||
static char temp[256];
|
||||
ColorF color = getValue();
|
||||
LinearColorF color = getValue();
|
||||
dSprintf( temp, 256, "%f %f %f %f", color.red, color.green, color.blue, color.alpha );
|
||||
return temp;
|
||||
}
|
||||
|
||||
void GuiColorPickerCtrl::setScriptValue(const char *value)
|
||||
{
|
||||
ColorF newValue;
|
||||
LinearColorF newValue;
|
||||
dSscanf(value, "%f %f %f %f", &newValue.red, &newValue.green, &newValue.blue, &newValue.alpha);
|
||||
setValue(newValue);
|
||||
}
|
||||
|
|
@ -687,7 +673,7 @@ DefineConsoleMethod(GuiColorPickerCtrl, updateColor, void, (), , "Forces update
|
|||
object->updateColor();
|
||||
}
|
||||
|
||||
DefineEngineMethod(GuiColorPickerCtrl, setSelectorColor, void, (ColorF color), ,
|
||||
DefineEngineMethod(GuiColorPickerCtrl, setSelectorColor, void, (LinearColorF color), ,
|
||||
"Sets the current position of the selector based on a color.n"
|
||||
"@param color Color to look for.n")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -81,16 +81,15 @@ class GuiColorPickerCtrl : public GuiControl
|
|||
/// @{
|
||||
void renderColorBox(RectI &bounds); ///< Function that draws the actual color box
|
||||
void drawSelector(RectI &bounds, Point2I &selectorPos, SelectorMode mode); /// < Function that draws the selection indicator
|
||||
void drawBlendBox(RectI &bounds, ColorF &c1, ColorF &c2, ColorF &c3, ColorF &c4);
|
||||
void drawBlendBox(RectI &bounds, LinearColorF &c1, LinearColorF &c2, LinearColorF &c3, LinearColorF &c4);
|
||||
void drawBlendRangeBox(RectI &bounds, bool vertical, U8 numColors, ColorI *colors);
|
||||
/// @}
|
||||
|
||||
/// @name Core Variables
|
||||
/// @{
|
||||
ColorF mPickColor; ///< Color that has been picked from control
|
||||
ColorF mBaseColor; ///< Colour we display (in case of pallet and blend mode)
|
||||
LinearColorF mPickColor; ///< Color that has been picked from control
|
||||
LinearColorF mBaseColor; ///< Colour we display (in case of pallet and blend mode)
|
||||
PickMode mDisplayMode; ///< Current color display mode of the selector
|
||||
bool mUseSRGB; ///< use sRGB color scale
|
||||
|
||||
Point2I mSelectorPos; ///< Current position of the selector
|
||||
bool mPositionChanged; ///< Current position has changed since last render?
|
||||
|
|
@ -99,10 +98,10 @@ class GuiColorPickerCtrl : public GuiControl
|
|||
bool mActionOnMove; ///< Perform onAction() when position has changed?
|
||||
|
||||
bool mSelectColor;
|
||||
ColorF mSetColor;
|
||||
LinearColorF mSetColor;
|
||||
GBitmap* mBitmap;
|
||||
|
||||
Point2I findColor(const ColorF & color, const Point2I& offset, const Point2I& resolution, GBitmap& bmp);
|
||||
Point2I findColor(const LinearColorF & color, const Point2I& offset, const Point2I& resolution, GBitmap& bmp);
|
||||
|
||||
S32 mSelectorGap; ///< The half-way "gap" between the selector pos and where the selector is allowed to draw.
|
||||
|
||||
|
|
@ -125,9 +124,9 @@ class GuiColorPickerCtrl : public GuiControl
|
|||
/// @name Color Value Functions
|
||||
/// @{
|
||||
/// NOTE: setValue only sets baseColor, since setting pickColor wouldn't be useful
|
||||
void setValue(ColorF &value) {mBaseColor = value;}
|
||||
void setValue(LinearColorF &value) {mBaseColor = value;}
|
||||
/// NOTE: getValue() returns baseColor if pallet (since pallet controls can't "pick" colours themselves)
|
||||
ColorF getValue() { return mDisplayMode == pPallet ? mBaseColor : mPickColor; }
|
||||
LinearColorF getValue() { return mDisplayMode == pPallet ? mBaseColor : mPickColor; }
|
||||
const char *getScriptValue();
|
||||
void setScriptValue(const char *value);
|
||||
void updateColor() {mPositionChanged = true;}
|
||||
|
|
@ -136,7 +135,7 @@ class GuiColorPickerCtrl : public GuiControl
|
|||
/// @name Selector Functions
|
||||
/// @{
|
||||
void setSelectorPos(const Point2I &pos); ///< Set new pos (in local coords)
|
||||
void setSelectorPos(const ColorF & color);
|
||||
void setSelectorPos(const LinearColorF & color);
|
||||
Point2I getSelectorPos() {return mSelectorPos;}
|
||||
/// @}
|
||||
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ void GuiGradientSwatchCtrl::onRender( Point2I offset, const RectI &updateRect )
|
|||
drawer->drawBitmapStretch( mGrid, renderRect );
|
||||
|
||||
// Draw swatch color as fill...
|
||||
drawer->drawRectFill( renderRect, mSwatchColor );
|
||||
drawer->drawRectFill( renderRect, mSwatchColor.toColorI());
|
||||
|
||||
// Draw any borders...
|
||||
drawer->drawRect( renderRect, borderColor );
|
||||
|
|
@ -218,14 +218,14 @@ GuiGradientCtrl::GuiGradientCtrl()
|
|||
setExtent(140, 30);
|
||||
mDisplayMode = pHorizColorRange;
|
||||
mSaveDisplayMode = pHorizColorRange;
|
||||
mBaseColor = ColorF(1.,.0,1.);
|
||||
mPickColor = ColorF(.0,.0,.0);
|
||||
mBaseColor = LinearColorF(1.,.0,1.);
|
||||
mPickColor = LinearColorF(.0,.0,.0);
|
||||
mMouseDown = mMouseOver = false;
|
||||
mActive = true;
|
||||
mPositionChanged = false;
|
||||
mActionOnMove = false;
|
||||
mShowReticle = true;
|
||||
colorWhiteBlend = ColorF(1.,1.,1.,.75);
|
||||
colorWhiteBlend = LinearColorF(1.,1.,1.,.75);
|
||||
mSwatchFactor = 7;
|
||||
}
|
||||
|
||||
|
|
@ -410,7 +410,7 @@ void GuiGradientCtrl::onMouseDown(const GuiEvent &event)
|
|||
Point2I resolution = getRoot()->getExtent();
|
||||
GFXTexHandle bb( resolution.x,
|
||||
resolution.y,
|
||||
GFXFormatR8G8B8A8, &GFXDefaultRenderTargetProfile, avar("%s() - bb (line %d)", __FUNCTION__, __LINE__) );
|
||||
GFXFormatR8G8B8A8, &GFXRenderTargetSRGBProfile, avar("%s() - bb (line %d)", __FUNCTION__, __LINE__) );
|
||||
|
||||
Point2I tmpPt( event.mousePoint.x, event.mousePoint.y );
|
||||
GFXTarget *targ = GFX->getActiveRenderTarget();
|
||||
|
|
@ -420,7 +420,7 @@ void GuiGradientCtrl::onMouseDown(const GuiEvent &event)
|
|||
ColorI tmp;
|
||||
bmp.getColor( event.mousePoint.x, event.mousePoint.y, tmp );
|
||||
|
||||
addColorRange( globalToLocalCoord(event.mousePoint), ColorF(tmp) );
|
||||
addColorRange( globalToLocalCoord(event.mousePoint), LinearColorF(tmp) );
|
||||
|
||||
mMouseDown = true;
|
||||
}
|
||||
|
|
@ -506,7 +506,7 @@ void GuiGradientCtrl::reInitSwatches( GuiGradientCtrl::PickMode )
|
|||
mColorRange[i].swatch->registerObject();
|
||||
addObject(mColorRange[i].swatch);
|
||||
mColorRange[i].swatch->setPosition( Point2I( mColorRange[i].pos, b ) );// needs to be adjusted
|
||||
mColorRange[i].swatch->setColor(ColorF(mColorRange[i].color));
|
||||
mColorRange[i].swatch->setColor(LinearColorF(mColorRange[i].color));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -518,12 +518,12 @@ void GuiGradientCtrl::reInitSwatches( GuiGradientCtrl::PickMode )
|
|||
mAlphaRange[i].swatch->registerObject();
|
||||
addObject(mAlphaRange[i].swatch);
|
||||
mAlphaRange[i].swatch->setPosition( Point2I( mAlphaRange[i].pos, b ) );// needs to be adjusted
|
||||
mAlphaRange[i].swatch->setColor(ColorF(mAlphaRange[i].color));
|
||||
mAlphaRange[i].swatch->setColor(LinearColorF(mAlphaRange[i].color));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GuiGradientCtrl::addColorRange(Point2I pos, const ColorF& color)
|
||||
void GuiGradientCtrl::addColorRange(Point2I pos, const LinearColorF& color)
|
||||
{
|
||||
if( pos.x + mSwatchFactor < mBlendRangeBox.point.x &&
|
||||
pos.x + mSwatchFactor > mBlendRangeBox.extent.x )
|
||||
|
|
@ -611,7 +611,7 @@ DefineConsoleMethod(GuiGradientCtrl, getColorCount, S32, (), , "Get color count"
|
|||
return 0;
|
||||
}
|
||||
|
||||
DefineConsoleMethod(GuiGradientCtrl, getColor, ColorF, (S32 idx), , "Get color value")
|
||||
DefineConsoleMethod(GuiGradientCtrl, getColor, LinearColorF, (S32 idx), , "Get color value")
|
||||
{
|
||||
|
||||
if( object->getDisplayMode() == GuiGradientCtrl::pHorizColorRange )
|
||||
|
|
@ -631,5 +631,5 @@ DefineConsoleMethod(GuiGradientCtrl, getColor, ColorF, (S32 idx), , "Get color v
|
|||
}
|
||||
}
|
||||
|
||||
return ColorF::ONE;
|
||||
return LinearColorF::ONE;
|
||||
}
|
||||
|
|
@ -74,7 +74,7 @@ public:
|
|||
{
|
||||
GuiGradientSwatchCtrl* swatch;
|
||||
S32 pos;
|
||||
ColorF color;
|
||||
LinearColorF color;
|
||||
};
|
||||
|
||||
Vector<ColorRange> mColorRange;
|
||||
|
|
@ -93,8 +93,8 @@ private:
|
|||
|
||||
/// @name Core Variables
|
||||
/// @{
|
||||
ColorF mPickColor; ///< Color that has been picked from control
|
||||
ColorF mBaseColor; ///< Colour we display (in case of pallet and blend mode)
|
||||
LinearColorF mPickColor; ///< Color that has been picked from control
|
||||
LinearColorF mBaseColor; ///< Colour we display (in case of pallet and blend mode)
|
||||
PickMode mDisplayMode; ///< Current color display mode of the selector
|
||||
PickMode mSaveDisplayMode;
|
||||
|
||||
|
|
@ -105,11 +105,11 @@ private:
|
|||
|
||||
GFXStateBlockRef mStateBlock;
|
||||
|
||||
ColorF colorWhite;
|
||||
ColorF colorWhiteBlend;
|
||||
ColorF colorBlack;
|
||||
ColorF colorAlpha;
|
||||
ColorF colorAlphaW;
|
||||
LinearColorF colorWhite;
|
||||
LinearColorF colorWhiteBlend;
|
||||
LinearColorF colorBlack;
|
||||
LinearColorF colorAlpha;
|
||||
LinearColorF colorAlphaW;
|
||||
/// @}
|
||||
String mColorFunction;
|
||||
|
||||
|
|
@ -126,9 +126,9 @@ public:
|
|||
/// @name Color Value Functions
|
||||
/// @{
|
||||
/// NOTE: setValue only sets baseColor, since setting pickColor wouldn't be useful
|
||||
void setValue(ColorF &value) {mBaseColor = value;}
|
||||
void setValue(LinearColorF &value) {mBaseColor = value;}
|
||||
/// NOTE: getValue() returns baseColor if pallet (since pallet controls can't "pick" colours themselves)
|
||||
ColorF getValue() {return mPickColor;}
|
||||
LinearColorF getValue() {return mPickColor;}
|
||||
void updateColor() {mPositionChanged = true;}
|
||||
/// @}
|
||||
|
||||
|
|
@ -148,7 +148,7 @@ public:
|
|||
void inspectPreApply();
|
||||
void inspectPostApply();
|
||||
void reInitSwatches( GuiGradientCtrl::PickMode );
|
||||
void addColorRange(Point2I pos, const ColorF& color);
|
||||
void addColorRange(Point2I pos, const LinearColorF& color);
|
||||
void removeColorRange( GuiGradientSwatchCtrl* swatch );
|
||||
void sortColorRange();
|
||||
|
||||
|
|
|
|||
|
|
@ -626,7 +626,7 @@ DefineEngineMethod( GuiListBoxCtrl, addItem, S32, (const char* newItem, const ch
|
|||
green = dAtof(GuiListBoxCtrl::getStringElement( color, 1 ));
|
||||
blue = dAtof(GuiListBoxCtrl::getStringElement( color, 2 ));
|
||||
|
||||
return object->addItemWithColor( newItem, ColorF(red, green, blue) );
|
||||
return object->addItemWithColor( newItem, LinearColorF(red, green, blue) );
|
||||
}
|
||||
else if(elementCount == 1)
|
||||
{
|
||||
|
|
@ -654,13 +654,13 @@ S32 GuiListBoxCtrl::addItem( StringTableEntry text, void *itemData )
|
|||
return insertItem( mItems.size(), text, itemData );
|
||||
}
|
||||
|
||||
S32 GuiListBoxCtrl::addItemWithColor( StringTableEntry text, ColorF color, void *itemData )
|
||||
S32 GuiListBoxCtrl::addItemWithColor( StringTableEntry text, LinearColorF color, void *itemData )
|
||||
{
|
||||
// This just calls insert item at the end of the list
|
||||
return insertItemWithColor( mItems.size(), text, color, itemData );
|
||||
}
|
||||
|
||||
DefineEngineMethod( GuiListBoxCtrl, setItemColor, void, (S32 index, ColorF color),,
|
||||
DefineEngineMethod( GuiListBoxCtrl, setItemColor, void, (S32 index, LinearColorF color),,
|
||||
"@brief Sets the color of a single list entry at the specified index id.\n\n"
|
||||
"@param index Index id to modify the color of in the list.\n"
|
||||
"@param color Color value to set the list entry to.\n"
|
||||
|
|
@ -677,7 +677,7 @@ DefineEngineMethod( GuiListBoxCtrl, setItemColor, void, (S32 index, ColorF color
|
|||
object->setItemColor( index, color );
|
||||
}
|
||||
|
||||
void GuiListBoxCtrl::setItemColor(S32 index, const ColorF& color)
|
||||
void GuiListBoxCtrl::setItemColor(S32 index, const LinearColorF& color)
|
||||
{
|
||||
if ((index >= mItems.size()) || index < 0)
|
||||
{
|
||||
|
|
@ -767,7 +767,7 @@ S32 GuiListBoxCtrl::insertItem( S32 index, StringTableEntry text, void *itemData
|
|||
|
||||
}
|
||||
|
||||
S32 GuiListBoxCtrl::insertItemWithColor( S32 index, StringTableEntry text, ColorF color, void *itemData )
|
||||
S32 GuiListBoxCtrl::insertItemWithColor( S32 index, StringTableEntry text, LinearColorF color, void *itemData )
|
||||
{
|
||||
// If the index is greater than our list size, insert it at the end
|
||||
if( index >= mItems.size() )
|
||||
|
|
@ -780,7 +780,7 @@ S32 GuiListBoxCtrl::insertItemWithColor( S32 index, StringTableEntry text, Color
|
|||
return -1;
|
||||
}
|
||||
|
||||
if( color == ColorF(-1, -1, -1) )
|
||||
if( color == LinearColorF(-1, -1, -1) )
|
||||
{
|
||||
Con::warnf("GuiListBoxCtrl::insertItem - cannot add NULL color" );
|
||||
return -1;
|
||||
|
|
@ -1065,7 +1065,7 @@ void GuiListBoxCtrl::onRender( Point2I offset, const RectI &updateRect )
|
|||
{
|
||||
// Set the size of the color box to be drawn next to the item text
|
||||
colorBoxSize = 3;
|
||||
boxColor = ColorI(mItems[i]->color);
|
||||
boxColor = ColorI(mItems[i]->color.toColorI());
|
||||
// Draw the box first
|
||||
ColorI black = ColorI(0, 0, 0);
|
||||
drawBox( Point2I(offset.x + mProfile->mTextOffset.x + colorBoxSize, offset.y + ( i * mItemSize.y ) + 8), colorBoxSize, black, boxColor );
|
||||
|
|
@ -1085,7 +1085,7 @@ void GuiListBoxCtrl::onRenderItem(const RectI& itemRect, LBItem *item)
|
|||
if( item->isSelected )
|
||||
GFX->getDrawUtil()->drawRectFill( itemRect, mProfile->mFillColorSEL );
|
||||
|
||||
GFX->getDrawUtil()->setBitmapModulation( item->hasColor ? (ColorI)item->color : mProfile->mFontColor);
|
||||
GFX->getDrawUtil()->setBitmapModulation( item->hasColor ? item->color.toColorI() : mProfile->mFontColor);
|
||||
renderJustifiedText(itemRect.point + Point2I( 2, 0 ), itemRect.extent, item->itemText);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ public:
|
|||
String itemTooltip;
|
||||
bool isSelected;
|
||||
void* itemData;
|
||||
ColorF color;
|
||||
LinearColorF color;
|
||||
bool hasColor;
|
||||
};
|
||||
|
||||
|
|
@ -102,12 +102,12 @@ public:
|
|||
void setItemText( S32 index, StringTableEntry text );
|
||||
|
||||
S32 addItem( StringTableEntry text, void *itemData = NULL );
|
||||
S32 addItemWithColor( StringTableEntry text, ColorF color = ColorF(-1, -1, -1), void *itemData = NULL);
|
||||
S32 addItemWithColor( StringTableEntry text, LinearColorF color = LinearColorF(-1, -1, -1), void *itemData = NULL);
|
||||
S32 insertItem( S32 index, StringTableEntry text, void *itemData = NULL );
|
||||
S32 insertItemWithColor( S32 index, StringTableEntry text, ColorF color = ColorF(-1, -1, -1), void *itemData = NULL);
|
||||
S32 insertItemWithColor( S32 index, StringTableEntry text, LinearColorF color = LinearColorF(-1, -1, -1), void *itemData = NULL);
|
||||
S32 findItemText( StringTableEntry text, bool caseSensitive = false );
|
||||
|
||||
void setItemColor(S32 index, const ColorF& color);
|
||||
void setItemColor(S32 index, const LinearColorF& color);
|
||||
void clearItemColor(S32 index);
|
||||
|
||||
void deleteItem( S32 index );
|
||||
|
|
|
|||
|
|
@ -1871,7 +1871,7 @@ bool GuiTreeViewCtrl::buildIconTable(const char * icons)
|
|||
dStrncpy( buf, start, getMin( sizeof( buf ) / sizeof( buf[ 0 ] ) - 1, len ) );
|
||||
buf[ len ] = '\0';
|
||||
|
||||
mIconTable[ numIcons ] = GFXTexHandle( buf, &GFXDefaultPersistentProfile, avar( "%s() - mIconTable[%d] (line %d)", __FUNCTION__, numIcons, __LINE__ ) );
|
||||
mIconTable[ numIcons ] = GFXTexHandle( buf, &GFXTexturePersistentProfile, avar( "%s() - mIconTable[%d] (line %d)", __FUNCTION__, numIcons, __LINE__ ) );
|
||||
}
|
||||
else
|
||||
mIconTable[ numIcons ] = GFXTexHandle();
|
||||
|
|
@ -3942,7 +3942,7 @@ void GuiTreeViewCtrl::onRender(Point2I offset, const RectI &updateRect)
|
|||
if (mDragMidPoint == NomDragMidPoint || !mSupportMouseDragging )
|
||||
return;
|
||||
|
||||
ColorF greyLine(0.5,0.5,0.5,1);
|
||||
ColorI greyLine(128,128,128);
|
||||
Point2F squarePt;
|
||||
|
||||
// CodeReview: LineWidth is not supported in Direct3D. This is lame. [5/10/2007 Pat]
|
||||
|
|
@ -4257,7 +4257,6 @@ bool GuiTreeViewCtrl::renderTooltip( const Point2I &hoverPos, const Point2I& cur
|
|||
{
|
||||
Item* item;
|
||||
BitSet32 flags = 0;
|
||||
char buf[ 2048 ];
|
||||
if( _hitTest( cursorPos, item, flags ) && (!item->mTooltip.isEmpty() || mUseInspectorTooltips) )
|
||||
{
|
||||
bool render = true;
|
||||
|
|
@ -4302,6 +4301,7 @@ bool GuiTreeViewCtrl::renderTooltip( const Point2I &hoverPos, const Point2I& cur
|
|||
{
|
||||
if( mUseInspectorTooltips )
|
||||
{
|
||||
char buf[2048];
|
||||
item->getTooltipText( sizeof( buf ), buf );
|
||||
tipText = buf;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue