Merge branch 'development' into imageAsset_refactor_rev3

This commit is contained in:
marauder2k7 2025-03-24 20:07:06 +00:00 committed by GitHub
commit 0da0903599
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4189 changed files with 29881 additions and 635347 deletions

View file

@ -28,6 +28,7 @@
#include "console/engineAPI.h"
#include "gfx/gfxDevice.h"
#include "gfx/gfxDrawUtil.h"
#include "console/typeValidators.h"
@ -89,7 +90,7 @@ void guiAnimBitmapCtrl::initPersistFields()
addField("reverse", TypeBool, Offset(mReverse, guiAnimBitmapCtrl), "play reversed?");
addField("fps", TypeS32, Offset(mFramesPerSec, guiAnimBitmapCtrl), "Frame Rate");
addProtectedField("curFrame", TypeS32, Offset(mCurFrameIndex, guiAnimBitmapCtrl), &ptSetFrame, &defaultProtectedGetFn, "Index of currently Displaying Frame ");
addProtectedFieldV("curFrame", TypeRangedS32, Offset(mCurFrameIndex, guiAnimBitmapCtrl), &ptSetFrame, &defaultProtectedGetFn, &CommonValidators::S32Range, "Index of currently Displaying Frame ");
Parent::initPersistFields();
removeField("wrap");
@ -126,16 +127,21 @@ bool guiAnimBitmapCtrl::ptSetFrame(void *object, const char *index, const char *
S32 val = dAtoi(data);
if (val < 0)
if ((val < 0) || (val >pData->mNumFrames))
{
pData->mCurFrameIndex = pData->mNumFrames;
if (pData->mLoop)
{
int len = pData->mNumFrames;
val = (val >= 0 ? val % len : -val % len ? len - (-val % len) : 0);
}
else
{
if (val < 0) val = 0;
if (val >pData->mNumFrames) val = pData->mNumFrames;
}
pData->mCurFrameIndex = val;
return false;
}
else if (val > pData->mNumFrames)
{
pData->mCurFrameIndex = 0;
return false;
};
pData->mCurFrameIndex = val;
return true;

View file

@ -44,7 +44,7 @@ GuiBitmapBarCtrl::GuiBitmapBarCtrl(void)
void GuiBitmapBarCtrl::initPersistFields()
{
docsURL;
addField("percent", TypeF32, Offset(mPercent, GuiBitmapBarCtrl),
addFieldV("percent", TypeRangedF32, Offset(mPercent, GuiBitmapBarCtrl), &CommonValidators::NormalizedFloat,
"% shown");
addField("vertical", TypeBool, Offset(mVertical, GuiBitmapBarCtrl),
"If true, the bitmap is clipped vertically.");

View file

@ -73,12 +73,9 @@ void GuiBitmapCtrl::initPersistFields()
INITPERSISTFIELD_IMAGEASSET_REFACTOR(Bitmap, GuiBitmapCtrl, "The bitmap to render in this BitmapCtrl.")
addField("color", TypeColorI, Offset(mColor, GuiBitmapCtrl), "color mul");
addField("wrap", TypeBool, Offset(mWrap, GuiBitmapCtrl),
"If true, the bitmap is tiled inside the control rather than stretched to fit.");
addField("angle", TypeF32, Offset(mAngle, GuiBitmapCtrl), "rotation");
endGroup("Bitmap");
addField("wrap", TypeBool, Offset(mWrap, GuiBitmapCtrl), "If true, the bitmap is tiled inside the control rather than stretched to fit.");
addFieldV("angle", TypeRangedF32, Offset(mAngle, GuiBitmapCtrl), &CommonValidators::DegreeRange, "rotation");
endGroup( "Bitmap" );
Parent::initPersistFields();
}

View file

@ -29,6 +29,9 @@
#include "gui/controls/guiColorPicker.h"
#include "gfx/primBuilder.h"
#include "gfx/gfxDrawUtil.h"
#include "console/typeValidators.h"
#include "postFx/postEffectManager.h"
#include "gfx/screenshot.h"
IMPLEMENT_CONOBJECT(GuiColorPickerCtrl);
@ -47,15 +50,23 @@ GuiColorPickerCtrl::GuiColorPickerCtrl()
mActive = true;
mSelectorGap = 1;
mActionOnMove = false;
mDropperActive = false;
mShowReticle = true;
mSelectedHue = 0;
mSelectedAlpha = 255;
mSelectedSaturation = 100;
mSelectedBrightness = 100;
eyeDropperPos = Point2I::Zero;
eyeDropperCap = NULL;
}
GuiColorPickerCtrl::~GuiColorPickerCtrl()
{
if (eyeDropperCap != NULL)
{
delete eyeDropperCap;
eyeDropperCap = NULL;
}
}
ImplementEnumType( GuiColorPickMode,
@ -81,7 +92,7 @@ void GuiColorPickerCtrl::initPersistFields()
{
docsURL;
addGroup("ColorPicker");
addField("selectorGap", TypeS32, Offset(mSelectorGap, GuiColorPickerCtrl));
addFieldV("selectorGap", TypeRangedS32, Offset(mSelectorGap, GuiColorPickerCtrl),&CommonValidators::NaturalNumber);
addField("displayMode", TYPEID< PickMode >(), Offset(mDisplayMode, GuiColorPickerCtrl) );
addField("selectorMode", TYPEID< SelectorMode >(), Offset(mSelectorMode, GuiColorPickerCtrl) );
addField("actionOnMove", TypeBool,Offset(mActionOnMove, GuiColorPickerCtrl));
@ -94,7 +105,7 @@ void GuiColorPickerCtrl::initPersistFields()
void GuiColorPickerCtrl::renderBlendRange(RectI& bounds)
{
ColorI currentColor;
currentColor.set(ColorI::Hsb(mSelectedHue, 100, 100));
currentColor.set(Hsb(mSelectedHue, 100, 100));
GFX->getDrawUtil()->drawRectFill(bounds, currentColor, 0.0f, ColorI(0,0,0,0), true);
}
@ -114,7 +125,7 @@ void GuiColorPickerCtrl::renderBlendSelector(RectI& bounds)
selectorRect.set(Point2I(selectorPos.x - mSelectorGap, selectorPos.y - mSelectorGap), Point2I(mSelectorGap * 2, mSelectorGap * 2));
ColorI currentColor;
currentColor.set(ColorI::Hsb(mSelectedHue, mSelectedSaturation, mSelectedBrightness));
currentColor.set(Hsb(mSelectedHue, mSelectedSaturation, mSelectedBrightness));
GFX->getDrawUtil()->drawRectFill(selectorRect, currentColor, 2.0f, ColorI::WHITE);
}
@ -136,8 +147,8 @@ void GuiColorPickerCtrl::renderHueGradient(RectI& bounds, U32 numColours)
U32 nextHue = static_cast<U32>((F32(i + 1) / F32(numColours)) * 360.0f);
ColorI currentColor, nextColor;
currentColor.set(ColorI::Hsb(currentHue, 100, 100));
nextColor.set(ColorI::Hsb(nextHue, 100, 100));
currentColor.set(Hsb(currentHue, 100, 100));
nextColor.set(Hsb(nextHue, 100, 100));
switch (mSelectorMode)
{
@ -217,7 +228,7 @@ void GuiColorPickerCtrl::renderHueSelector(RectI& bounds)
}
ColorI currentColor;
currentColor.set(ColorI::Hsb(mSelectedHue, 100, 100));
currentColor.set(Hsb(mSelectedHue, 100, 100));
GFX->getDrawUtil()->drawRectFill(selectorRect, currentColor, 2.0f, ColorI::WHITE);
}
@ -232,7 +243,7 @@ void GuiColorPickerCtrl::renderAlphaGradient(RectI& bounds)
S32 b = bounds.point.y + bounds.extent.y;
ColorI currentColor;
currentColor.set(ColorI::Hsb(mSelectedHue, 100, 100));
currentColor.set(Hsb(mSelectedHue, 100, 100));
ColorI alphaCol = ColorI::BLACK;
alphaCol.alpha = 0;
@ -308,12 +319,38 @@ void GuiColorPickerCtrl::renderAlphaSelector(RectI& bounds)
}
ColorI currentColor;
currentColor.set(ColorI::Hsb(mSelectedHue, 100, 100));
currentColor.set(Hsb(mSelectedHue, 100, 100));
currentColor.alpha = mSelectedAlpha;
GFX->getDrawUtil()->drawRectFill(selectorRect, currentColor, 2.0f, ColorI::WHITE);
}
void GuiColorPickerCtrl::renderEyeDropper()
{
if (eyeDropperCap != NULL)
{
GFX->getDrawUtil()->drawBitmap(eyeHandle, getRoot()->getPosition());
Point2I resolution = getRoot()->getExtent();
Point2I magnifierSize(100, 100);
Point2I magnifierPosition = eyeDropperPos + Point2I(20, 20);
// Adjust position to ensure magnifier stays on screen
if (magnifierPosition.x + magnifierSize.x > resolution.x)
magnifierPosition.x = eyeDropperPos.x - magnifierSize.x - 20;
if (magnifierPosition.y + magnifierSize.y > resolution.y)
magnifierPosition.y = eyeDropperPos.y - magnifierSize.y - 20;
RectI magnifierBounds(magnifierPosition, magnifierSize);
ColorI currentColor;
currentColor.set(Hsb(mSelectedHue, mSelectedSaturation, mSelectedBrightness));
currentColor.alpha = mSelectedAlpha;
GFX->getDrawUtil()->drawRectFill(magnifierBounds, currentColor, 2.0f, ColorI::BLACK);
}
}
void GuiColorPickerCtrl::onRender(Point2I offset, const RectI& updateRect)
{
if (mStateBlock.isNull())
@ -333,7 +370,7 @@ void GuiColorPickerCtrl::onRender(Point2I offset, const RectI& updateRect)
case GuiColorPickerCtrl::pPalette:
{
ColorI currentColor;
currentColor.set(ColorI::Hsb(mSelectedHue, mSelectedSaturation, mSelectedBrightness));
currentColor.set(Hsb(mSelectedHue, mSelectedSaturation, mSelectedBrightness));
currentColor.alpha = mSelectedAlpha;
GFX->getDrawUtil()->drawRectFill(boundsRect, currentColor);
break;
@ -356,6 +393,15 @@ void GuiColorPickerCtrl::onRender(Point2I offset, const RectI& updateRect)
if (mShowReticle) renderAlphaSelector(boundsRect);
break;
}
case GuiColorPickerCtrl::pDropperBackground:
{
if (mDropperActive)
{
// Render the magnified view of our currently selected color.
renderEyeDropper();
}
break;
}
default:
break;
}
@ -364,72 +410,31 @@ void GuiColorPickerCtrl::onRender(Point2I offset, const RectI& updateRect)
renderChildControls(offset, updateRect);
}
Point2I GuiColorPickerCtrl::findColor(const LinearColorF & color, const Point2I& offset, const Point2I& resolution, GBitmap& bmp)
{
Point2I ext = getExtent();
Point2I closestPos(-1, -1);
/* Debugging
char filename[256];
dSprintf( filename, 256, "%s.%s", "colorPickerTest", "png" );
// Open up the file on disk.
FileStream fs;
if ( !fs.open( filename, Torque::FS::File::Write ) )
Con::errorf( "GuiObjectView::saveAsImage() - Failed to open output file '%s'!", filename );
else
{
// Write it and close.
bmp.writeBitmap( "png", fs );
fs.close();
}
*/
ColorI tmp;
U32 buf_x;
U32 buf_y;
LinearColorF curColor;
F32 val(10000.0f);
F32 closestVal(10000.0f);
bool closestSet = false;
for (S32 x = 0; x < ext.x; x++)
{
for (S32 y = 0; y < ext.y; y++)
{
buf_x = offset.x + x;
buf_y = (resolution.y - (offset.y + y));
buf_y = resolution.y - buf_y;
//Get the color at that position
bmp.getColor(buf_x, buf_y, 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);
if (!closestSet)
{
closestVal = val;
closestPos.set(x, y);
closestSet = true;
}
else if (val < closestVal)
{
closestVal = val;
closestPos.set(x, y);
}
}
}
return closestPos;
}
void GuiColorPickerCtrl::onMouseDown(const GuiEvent &event)
{
if (!mActive)
return;
// we need to do this first.
if (mDisplayMode == GuiColorPickerCtrl::pDropperBackground) {
if (mDropperActive)
{
mDropperActive = false;
//getRoot()->pushObjectToBack(this);
onAction();
mouseUnlock();
if (eyeDropperCap != NULL)
{
delete eyeDropperCap;
eyeDropperCap = NULL;
}
}
return;
}
mouseLock(this);
@ -510,14 +515,15 @@ void GuiColorPickerCtrl::onMouseDragged(const GuiEvent &event)
Point2I ext = getExtent();
Point2I mousePoint = globalToLocalCoord(event.mousePoint);
F32 relX = mClampF(F32(mousePoint.x) / F32(ext.x), 0.0, 1.0);
F32 relY = mClampF(F32(mousePoint.y) / F32(ext.y), 0.0, 1.0);
switch (mDisplayMode)
{
case GuiColorPickerCtrl::pPalette:
return;
case GuiColorPickerCtrl::pBlendRange:
{
F32 relX = F32(mousePoint.x) / F32(ext.x);
F32 relY = 1.0f - F32(mousePoint.y) / F32(ext.y);
relY = 1.0f - relY;
setSelectedSaturation(relX * 100.0);
setSelectedBrightness(relY * 100.0);
break;
@ -528,13 +534,11 @@ void GuiColorPickerCtrl::onMouseDragged(const GuiEvent &event)
{
case GuiColorPickerCtrl::sHorizontal:
{
F32 relX = F32(mousePoint.x) / F32(ext.x);
setSelectedHue(relX * 360.0);
break;
}
case GuiColorPickerCtrl::sVertical:
{
F32 relY = F32(mousePoint.y) / F32(ext.y);
setSelectedHue(relY * 360.0);
break;
}
@ -549,13 +553,11 @@ void GuiColorPickerCtrl::onMouseDragged(const GuiEvent &event)
{
case GuiColorPickerCtrl::sHorizontal:
{
F32 relX = F32(mousePoint.x) / F32(ext.x);
setSelectedAlpha(relX * 255.0);
break;
}
case GuiColorPickerCtrl::sVertical:
{
F32 relY = F32(mousePoint.y) / F32(ext.y);
setSelectedAlpha(relY * 255.0);
break;
}
@ -574,6 +576,29 @@ void GuiColorPickerCtrl::onMouseDragged(const GuiEvent &event)
void GuiColorPickerCtrl::onMouseMove(const GuiEvent &event)
{
if (mDisplayMode != pDropperBackground)
return;
if (!mDropperActive)
return;
// should not need globalToLocal as we are capturing the whole screen.
eyeDropperPos = globalToLocalCoord(event.mousePoint);
if (eyeDropperCap != NULL)
{
// Sample the pixel color at the mouse position. Mouse position should translate directly.
ColorI sampledColor;
eyeDropperCap->getColor(eyeDropperPos.x, eyeDropperPos.y, sampledColor);
// Convert the sampled color to HSB
Hsb hsb = sampledColor.getHSB();
mSelectedHue = hsb.hue;
mSelectedSaturation = hsb.sat;
mSelectedBrightness = hsb.brightness;
mSelectedAlpha = sampledColor.alpha;
}
}
void GuiColorPickerCtrl::onMouseEnter(const GuiEvent &event)
@ -587,7 +612,16 @@ void GuiColorPickerCtrl::onMouseLeave(const GuiEvent &)
mMouseOver = false;
}
void GuiColorPickerCtrl::setSelectedHue(const F64& hueValue)
void GuiColorPickerCtrl::onMouseUp(const GuiEvent&)
{
//if we released the mouse within this control, perform the action
if (mActive && mMouseDown)
mMouseDown = false;
mouseUnlock();
}
void GuiColorPickerCtrl::setSelectedHue(const U32& hueValue)
{
if (hueValue < 0)
{
@ -605,7 +639,7 @@ void GuiColorPickerCtrl::setSelectedHue(const F64& hueValue)
}
void GuiColorPickerCtrl::setSelectedBrightness(const F64& brightValue)
void GuiColorPickerCtrl::setSelectedBrightness(const U32& brightValue)
{
if (brightValue < 0)
{
@ -622,7 +656,7 @@ void GuiColorPickerCtrl::setSelectedBrightness(const F64& brightValue)
mSelectedBrightness = brightValue;
}
void GuiColorPickerCtrl::setSelectedSaturation(const F64& satValue)
void GuiColorPickerCtrl::setSelectedSaturation(const U32& satValue)
{
if (satValue < 0)
{
@ -639,7 +673,7 @@ void GuiColorPickerCtrl::setSelectedSaturation(const F64& satValue)
mSelectedSaturation = satValue;
}
void GuiColorPickerCtrl::setSelectedAlpha(const F64& alphaValue)
void GuiColorPickerCtrl::setSelectedAlpha(const U32& alphaValue)
{
if (alphaValue < 0)
{
@ -656,13 +690,27 @@ void GuiColorPickerCtrl::setSelectedAlpha(const F64& alphaValue)
mSelectedAlpha = alphaValue;
}
void GuiColorPickerCtrl::onMouseUp(const GuiEvent &)
void GuiColorPickerCtrl::activateEyeDropper()
{
//if we released the mouse within this control, perform the action
if (mActive && mMouseDown)
mMouseDown = false;
// Make sure we are a pDropperBackground
if (mDisplayMode == GuiColorPickerCtrl::pDropperBackground)
{
mouseLock(this); // take over!
mouseUnlock();
setFirstResponder(); // we need this to be first responder regardless.
//getRoot()->bringObjectToFront(this);
mDropperActive = true;
// Set up our resolution.
Point2I resolution = getRoot()->getExtent();
eyeDropperCap = gScreenShot->_captureBackBuffer();
// Texture handle to resolve the target to.
eyeHandle.set(eyeDropperCap, &GFXStaticTextureSRGBProfile, false, avar("%s() - bb (line %d)", __FUNCTION__, __LINE__));
}
}
/// <summary>
@ -673,49 +721,57 @@ DefineEngineMethod(GuiColorPickerCtrl, executeUpdate, void, (), , "Execute the o
object->onAction();
}
DefineEngineMethod(GuiColorPickerCtrl, setSelectedHue, void, (F64 hueValue), , "Sets the selected hue value should be 0-360.")
/// <summary>
/// This command should only be used with guiColorPicker in pDropperBackground mode.
/// </summary>
DefineEngineMethod(GuiColorPickerCtrl, activateEyeDropper, void, (), , "Activate the dropper mode.")
{
object->activateEyeDropper();
}
DefineEngineMethod(GuiColorPickerCtrl, setSelectedHue, void, (S32 hueValue), , "Sets the selected hue value should be 0-360.")
{
object->setSelectedHue(hueValue);
}
DefineEngineMethod(GuiColorPickerCtrl, getSelectedHue, F64, (), , "Gets the current selected hue value.")
DefineEngineMethod(GuiColorPickerCtrl, getSelectedHue, S32, (), , "Gets the current selected hue value.")
{
return object->getSelectedHue();
}
DefineEngineMethod(GuiColorPickerCtrl, setSelectedBrightness, void, (F64 brightness), , "Sets the selected brightness value should be 0-100.")
DefineEngineMethod(GuiColorPickerCtrl, setSelectedBrightness, void, (S32 brightness), , "Sets the selected brightness value should be 0-100.")
{
object->setSelectedBrightness(brightness);
}
DefineEngineMethod(GuiColorPickerCtrl, getSelectedBrightness, F64, (), , "Gets the current selected brightness.")
DefineEngineMethod(GuiColorPickerCtrl, getSelectedBrightness, S32, (), , "Gets the current selected brightness.")
{
return object->getSelectedBrightness();
}
DefineEngineMethod(GuiColorPickerCtrl, setSelectedSaturation, void, (F64 saturation), , "Sets the selected saturation value should be 0-100.")
DefineEngineMethod(GuiColorPickerCtrl, setSelectedSaturation, void, (S32 saturation), , "Sets the selected saturation value should be 0-100.")
{
object->setSelectedSaturation(saturation);
}
DefineEngineMethod(GuiColorPickerCtrl, getSelectedSaturation, F64, (), , "Gets the current selected saturation value.")
DefineEngineMethod(GuiColorPickerCtrl, getSelectedSaturation, S32, (), , "Gets the current selected saturation value.")
{
return object->getSelectedSaturation();
}
DefineEngineMethod(GuiColorPickerCtrl, setSelectedAlpha, void, (F64 alpha), , "Sets the selected alpha value should be 0-255.")
DefineEngineMethod(GuiColorPickerCtrl, setSelectedAlpha, void, (S32 alpha), , "Sets the selected alpha value should be 0-255.")
{
object->setSelectedAlpha(alpha);
}
DefineEngineMethod(GuiColorPickerCtrl, getSelectedAlpha, F64, (), , "Gets the current selected alpha value.")
DefineEngineMethod(GuiColorPickerCtrl, getSelectedAlpha, S32, (), , "Gets the current selected alpha value.")
{
return object->getSelectedAlpha();
}
DefineEngineMethod(GuiColorPickerCtrl, setSelectedColorI, void, (ColorI col), , "Sets the current selected hsb from a colorI value.")
{
ColorI::Hsb hsb(col.getHSB());
Hsb hsb(col.getHSB());
object->setSelectedHue(hsb.hue);
object->setSelectedSaturation(hsb.sat);
object->setSelectedBrightness(hsb.brightness);
@ -725,26 +781,25 @@ DefineEngineMethod(GuiColorPickerCtrl, setSelectedColorI, void, (ColorI col), ,
DefineEngineMethod(GuiColorPickerCtrl, getSelectedColorI, ColorI, (), , "Gets the current selected hsb as a colorI value.")
{
ColorI col;
col.set(ColorI::Hsb(object->getSelectedHue(), object->getSelectedSaturation(), object->getSelectedBrightness()));
col.set(Hsb(object->getSelectedHue(), object->getSelectedSaturation(), object->getSelectedBrightness()));
col.alpha = object->getSelectedAlpha();
return col;
}
DefineEngineMethod(GuiColorPickerCtrl, setSelectedLinearColor, void, (LinearColorF colF), , "Sets the current selected hsb froma a LinearColorF value.")
{
ColorI col = colF.toColorI();
ColorI::Hsb hsb(col.getHSB());
Hsb hsb = colF.getHSB();
object->setSelectedHue(hsb.hue);
object->setSelectedSaturation(hsb.sat);
object->setSelectedBrightness(hsb.brightness);
object->setSelectedAlpha(col.alpha);
object->setSelectedAlpha(colF.alpha * 255.0);
}
DefineEngineMethod(GuiColorPickerCtrl, getSelectedLinearColor, LinearColorF, (), , "Gets the current selected hsb as a LinearColorF value.")
{
ColorI col;
col.set(ColorI::Hsb(object->getSelectedHue(), object->getSelectedSaturation(), object->getSelectedBrightness()));
col.alpha = object->getSelectedAlpha();
return LinearColorF(col);
LinearColorF col;
col.set(Hsb(object->getSelectedHue(), object->getSelectedSaturation(), object->getSelectedBrightness()));
col.alpha = (F32)object->getSelectedAlpha() / 255.0f;
return col;
}

View file

@ -108,23 +108,27 @@ class GuiColorPickerCtrl : public GuiControl
/// <param name="bounds">The bounds of the ctrl.</param>
void renderAlphaSelector(RectI& bounds);
void renderEyeDropper();
/// @name Core Variables
/// @{
PickMode mDisplayMode; ///< Current color display mode of the selector
PickMode mDisplayMode; ///< Current color display mode of the selector
SelectorMode mSelectorMode; ///< Current color display mode of the selector
F64 mSelectedHue;
F64 mSelectedSaturation;
F64 mSelectedBrightness;
F64 mSelectedAlpha;
U32 mSelectedHue;
U32 mSelectedSaturation;
U32 mSelectedBrightness;
U32 mSelectedAlpha;
Point2I eyeDropperPos;
GBitmap* eyeDropperCap;
GFXTexHandle eyeHandle;
bool mMouseOver; ///< Mouse is over?
bool mMouseDown; ///< Mouse button down?
bool mActionOnMove; ///< Perform onAction() when position has changed?
bool mShowReticle; ///< Show reticle on render
bool mDropperActive; ///< Is the eye dropper active?
bool mMouseOver; ///< Mouse is over?
bool mMouseDown; ///< Mouse button down?
bool mActionOnMove; ///< Perform onAction() when position has changed?
bool mShowReticle; ///< Show reticle on render
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.
S32 mSelectorGap; ///< The half-way "gap" between the selector pos and where the selector is allowed to draw.
GFXStateBlockRef mStateBlock;
/// @}
@ -158,29 +162,32 @@ class GuiColorPickerCtrl : public GuiControl
/// Set the selected hue.
/// </summary>
/// <param name="hueValue">Hue value, 0 - 360.</param>
void setSelectedHue(const F64& hueValue);
F64 getSelectedHue() { return mSelectedHue; }
void setSelectedHue(const U32& hueValue);
U32 getSelectedHue() { return mSelectedHue; }
/// <summary>
/// Set the selected brightness.
/// </summary>
/// <param name="brightValue">Brightness value, 0 - 100.</param>
void setSelectedBrightness(const F64& brightValue);
F64 getSelectedBrightness() { return mSelectedBrightness; }
void setSelectedBrightness(const U32& brightValue);
U32 getSelectedBrightness() { return mSelectedBrightness; }
/// <summary>
/// Set the selected saturation.
/// </summary>
/// <param name="satValue">Saturation value, 0 - 100.</param>
void setSelectedSaturation(const F64& satValue);
F64 getSelectedSaturation() { return mSelectedSaturation; }
void setSelectedSaturation(const U32& satValue);
U32 getSelectedSaturation() { return mSelectedSaturation; }
/// <summary>
/// Set the selected alpha.
/// </summary>
/// <param name="alphaValue">Alpha value, 0 - 255.</param>
void setSelectedAlpha(const F64& alphaValue);
F64 getSelectedAlpha() { return mSelectedAlpha; }
void setSelectedAlpha(const U32& alphaValue);
U32 getSelectedAlpha() { return mSelectedAlpha; }
void activateEyeDropper();
};
typedef GuiColorPickerCtrl::PickMode GuiColorPickMode;

View file

@ -29,6 +29,7 @@
#include "gui/containers/guiScrollCtrl.h"
#include "sim/actionMap.h"
#include "core/strings/stringUnit.h"
#include "console/typeValidators.h"
//-----------------------------------------------------------------------------
// GuiGameListMenuCtrl
@ -1878,10 +1879,10 @@ void GuiGameListMenuProfile::initPersistFields()
addField( "rowSize", TypePoint2I, Offset(mRowSize, GuiGameListMenuProfile),
"The base size (\"width height\") of a row" );
addField("columnSplit", TypeS32, Offset(mColumnSplit, GuiGameListMenuProfile),
addFieldV("columnSplit", TypeRangedS32, Offset(mColumnSplit, GuiGameListMenuProfile), &CommonValidators::PositiveInt,
"Padding between the leftmost edge of the control, and the row's left arrow.");
addField("rightPad", TypeS32, Offset(mRightPad, GuiGameListMenuProfile),
addFieldV("rightPad", TypeRangedS32, Offset(mRightPad, GuiGameListMenuProfile), &CommonValidators::PositiveInt,
"Padding between the rightmost edge of the control and the row's right arrow.");
Parent::initPersistFields();

View file

@ -544,10 +544,10 @@ ConsoleDocClass( GuiGameListOptionsProfile,
void GuiGameListOptionsProfile::initPersistFields()
{
docsURL;
addField( "columnSplit", TypeS32, Offset(mColumnSplit, GuiGameListOptionsProfile),
addFieldV( "columnSplit", TypeRangedS32, Offset(mColumnSplit, GuiGameListOptionsProfile), &CommonValidators::PositiveInt,
"Padding between the leftmost edge of the control, and the row's left arrow." );
addField( "rightPad", TypeS32, Offset(mRightPad, GuiGameListOptionsProfile),
addFieldV( "rightPad", TypeRangedS32, Offset(mRightPad, GuiGameListOptionsProfile), &CommonValidators::PositiveInt,
"Padding between the rightmost edge of the control and the row's right arrow." );
Parent::initPersistFields();

View file

@ -29,6 +29,7 @@
#include "gui/containers/guiScrollCtrl.h"
#include "core/strings/stringUnit.h"
#include "gui/core/guiDefaultControlRender.h"
#include "console/typeValidators.h"
//-----------------------------------------------------------------------------
// GuiGameSettingsCtrl
@ -829,13 +830,13 @@ void GuiGameSettingsCtrl::initPersistFields()
INITPERSISTFIELD_IMAGEASSET_REFACTOR(PreviousBitmap, GuiGameSettingsCtrl, "Bitmap used for the previous button when in list mode.");
INITPERSISTFIELD_IMAGEASSET_REFACTOR(NextBitmap, GuiGameSettingsCtrl, "Bitmap used for the next button when in list mode.");
addField("arrowSize", TypeS32, Offset(mArrowSize, GuiGameSettingsCtrl),
addFieldV("arrowSize", TypeRangedS32, Offset(mArrowSize, GuiGameSettingsCtrl), &CommonValidators::PositiveInt,
"Size of the arrow buttons' extents");
addField("columnSplit", TypeS32, Offset(mColumnSplit, GuiGameSettingsCtrl),
addFieldV("columnSplit", TypeRangedS32, Offset(mColumnSplit, GuiGameSettingsCtrl), &CommonValidators::NaturalNumber,
"Position of the split between the leftside label and the rightside setting parts");
addField("rightPad", TypeS32, Offset(mRightPad, GuiGameSettingsCtrl),
addFieldV("rightPad", TypeRangedS32, Offset(mRightPad, GuiGameSettingsCtrl), &CommonValidators::NaturalNumber,
"Padding between the rightmost edge of the control and right arrow.");
addField("callbackOnA", TypeString, Offset(mCallbackOnA, GuiGameSettingsCtrl),

View file

@ -32,6 +32,7 @@
#include "sfx/sfxTrack.h"
#include "sfx/sfxTypes.h"
#include "console/engineAPI.h"
#include "console/typeValidators.h"
IMPLEMENT_CONOBJECT( GuiMLTextCtrl );
@ -301,18 +302,18 @@ void GuiMLTextCtrl::initPersistFields()
docsURL;
addGroup( "Text" );
addField("lineSpacing", TypeS32, Offset(mLineSpacingPixels, GuiMLTextCtrl), "The number of blank pixels to place between each line.\n");
addFieldV("lineSpacing", TypeRangedS32, Offset(mLineSpacingPixels, GuiMLTextCtrl), &CommonValidators::PositiveInt, "The number of blank pixels to place between each line.\n");
addField("allowColorChars", TypeBool, Offset(mAllowColorChars, GuiMLTextCtrl), "If true, the control will allow characters to have unique colors.");
addField("maxChars", TypeS32, Offset(mMaxBufferSize, GuiMLTextCtrl), "Maximum number of characters that the control will display.");
addFieldV("maxChars", TypeRangedS32, Offset(mMaxBufferSize, GuiMLTextCtrl), &CommonValidators::NegDefaultInt, "Maximum number of characters that the control will display.");
INITPERSISTFIELD_SOUNDASSET(DeniedSound, GuiMLTextCtrl, "If the text will not fit in the control, the deniedSound is played.");
addField("text", TypeCaseString, Offset( mInitialText, GuiMLTextCtrl ), "Text to display in this control.");
addField("useURLMouseCursor", TypeBool, Offset(mUseURLMouseCursor, GuiMLTextCtrl), "If true, the mouse cursor will turn into a hand cursor while over a link in the text.\n"
"This is dependant on the markup language used by the GuiMLTextCtrl\n");
addField("useTypeOverTime", TypeBool, Offset(mUseTypeOverTime, GuiMLTextCtrl), "");
addField("typeOverTimeSpeedMS", TypeF32, Offset(mTypeOverTimeSpeedMS, GuiMLTextCtrl), "");
addFieldV("typeOverTimeSpeedMS", TypeRangedF32, Offset(mTypeOverTimeSpeedMS, GuiMLTextCtrl), &CommonValidators::PositiveFloat, "");
addField("typeoutSound", TypeSFXTrackName, Offset(mTypeoutSound, GuiMLTextCtrl), "Played when the text is being typed out");
addField("typeoutSoundRate", TypeS32, Offset(mTypeoutSoundRate, GuiMLTextCtrl), "Dictates how many characters must be typed out before the sound is played again. -1 for the sound to only play once at the start.");
addFieldV("typeoutSoundRate", TypeRangedS32, Offset(mTypeoutSoundRate, GuiMLTextCtrl), &CommonValidators::NegDefaultInt, "Dictates how many characters must be typed out before the sound is played again. -1 for the sound to only play once at the start.");
endGroup( "Text" );

View file

@ -295,7 +295,7 @@ GuiPopUpMenuCtrl::~GuiPopUpMenuCtrl()
void GuiPopUpMenuCtrl::initPersistFields(void)
{
docsURL;
addField("maxPopupHeight", TypeS32, Offset(mMaxPopupHeight, GuiPopUpMenuCtrl));
addFieldV("maxPopupHeight", TypeRangedS32, Offset(mMaxPopupHeight, GuiPopUpMenuCtrl), &CommonValidators::PositiveInt);
addField("sbUsesNAColor", TypeBool, Offset(mRenderScrollInNA, GuiPopUpMenuCtrl));
addField("reverseTextList", TypeBool, Offset(mReverseTextList, GuiPopUpMenuCtrl));

View file

@ -28,6 +28,7 @@
#include "gfx/primBuilder.h"
#include "gfx/gfxDrawUtil.h"
#include "console/engineAPI.h"
#include "console/typeValidators.h"
ConsoleDocClass( GuiPopUpMenuCtrlEx,
"@brief A control that allows to select a value from a drop-down list.\n\n"
@ -349,7 +350,7 @@ GuiPopUpMenuCtrlEx::~GuiPopUpMenuCtrlEx()
void GuiPopUpMenuCtrlEx::initPersistFields(void)
{
docsURL;
addField("maxPopupHeight", TypeS32, Offset(mMaxPopupHeight, GuiPopUpMenuCtrlEx), "Length of menu when it extends");
addFieldV("maxPopupHeight", TypeRangedS32, Offset(mMaxPopupHeight, GuiPopUpMenuCtrlEx), &CommonValidators::PositiveInt, "Length of menu when it extends");
addField("sbUsesNAColor", TypeBool, Offset(mRenderScrollInNA, GuiPopUpMenuCtrlEx), "Deprecated" "@internal");
addField("reverseTextList", TypeBool, Offset(mReverseTextList, GuiPopUpMenuCtrlEx), "Reverses text list if popup extends up, instead of down");
@ -1229,7 +1230,7 @@ void GuiPopUpMenuCtrlEx::onRender(Point2I offset, const RectI &updateRect)
{
localStart.x = getWidth() - txt_w - 12;
}
}
}
else
{
localStart.x = mProfile->mTextOffset.x; // Use mProfile->mTextOffset as a controlable margin for the control's text.

View file

@ -96,7 +96,7 @@ void GuiTextCtrl::initPersistFields()
addField( "textID", TypeString, Offset( mInitialTextID, GuiTextCtrl ),
"Maps the text of this control to a variable used in localization, rather than raw text.");
addField( "maxLength", TypeS32, Offset( mMaxStrLen, GuiTextCtrl ),
addFieldV( "maxLength", TypeRangedS32, Offset( mMaxStrLen, GuiTextCtrl ), &CommonValidators::PositiveInt,
"Defines the maximum length of the text. The default is 1024." );
Parent::initPersistFields();

View file

@ -36,6 +36,7 @@
#include "sfx/sfxSystem.h"
#include "core/strings/unicode.h"
#include "console/engineAPI.h"
#include "console/typeValidators.h"
IMPLEMENT_CONOBJECT(GuiTextEditCtrl);
@ -177,7 +178,7 @@ void GuiTextEditCtrl::initPersistFields()
addField("validate", TypeRealString,Offset(mValidateCommand, GuiTextEditCtrl), "Script command to be called when the first validater is lost.\n");
addField("escapeCommand", TypeRealString,Offset(mEscapeCommand, GuiTextEditCtrl), "Script command to be called when the Escape key is pressed.\n");
addField("historySize", TypeS32, Offset(mHistorySize, GuiTextEditCtrl), "How large of a history buffer to maintain.\n");
addFieldV("historySize", TypeRangedS32, Offset(mHistorySize, GuiTextEditCtrl), &CommonValidators::PositiveInt, "How large of a history buffer to maintain.\n");
addField("tabComplete", TypeBool, Offset(mTabComplete, GuiTextEditCtrl), "If true, when the 'tab' key is pressed, it will act as if the Enter key was pressed on the control.\n");
addField("deniedSound", TypeSFXTrackName, Offset(mDeniedSound, GuiTextEditCtrl), "If the attempted text cannot be entered, this sound effect will be played.\n");
addField("sinkAllKeyEvents", TypeBool, Offset(mSinkAllKeyEvents, GuiTextEditCtrl), "If true, every key event will act as if the Enter key was pressed.\n");

View file

@ -341,6 +341,8 @@ void GuiTextEditSliderCtrl::onRender(Point2I offset, const RectI &updateRect)
mIncCounter = (mIncCounter > 0.0f) ? mIncCounter-1 : mIncCounter+1;
checkRange();
setValue();
execConsoleCallback();
execAltConsoleCallback();
mCursorPos = 0;
}
}

View file

@ -29,6 +29,7 @@
#include "gui/core/guiDefaultControlRender.h"
#include "gfx/gfxDrawUtil.h"
#include "console/engineAPI.h"
#include "console/typeValidators.h"
IMPLEMENT_CONOBJECT(GuiTextListCtrl);
@ -134,7 +135,7 @@ void GuiTextListCtrl::initPersistFields()
addField("columns", TypeS32Vector, Offset(mColumnOffsets, GuiTextListCtrl), "A vector of column offsets. The number of values determines the number of columns in the table.\n" );
addField("fitParentWidth", TypeBool, Offset(mFitParentWidth, GuiTextListCtrl), "If true, the width of this control will match the width of its parent.\n");
addField("clipColumnText", TypeBool, Offset(mClipColumnText, GuiTextListCtrl), "If true, text exceeding a column's given width will get clipped.\n" );
addField("rowHeightPadding", TypeS32, Offset(mRowHeightPadding, GuiTextListCtrl), "Sets how much padding to add to the row heights on top of the font height");
addFieldV("rowHeightPadding", TypeRangedS32, Offset(mRowHeightPadding, GuiTextListCtrl), &CommonValidators::PositiveInt, "Sets how much padding to add to the row heights on top of the font height");
Parent::initPersistFields();
}

View file

@ -883,10 +883,10 @@ void GuiTreeViewCtrl::initPersistFields()
docsURL;
addGroup( "TreeView" );
addField( "tabSize", TypeS32, Offset(mTabSize, GuiTreeViewCtrl));
addFieldV( "tabSize", TypeRangedS32, Offset(mTabSize, GuiTreeViewCtrl), &CommonValidators::PositiveInt);
addField( "textOffset", TypeS32, Offset(mTextOffset, GuiTreeViewCtrl));
addField( "fullRowSelect", TypeBool, Offset(mFullRowSelect, GuiTreeViewCtrl));
addField( "itemHeight", TypeS32, Offset(mItemHeight, GuiTreeViewCtrl));
addFieldV( "itemHeight", TypeRangedS32, Offset(mItemHeight, GuiTreeViewCtrl), &CommonValidators::PositiveInt);
addField( "destroyTreeOnSleep", TypeBool, Offset(mDestroyOnSleep, GuiTreeViewCtrl),
"If true, the entire tree item hierarchy is deleted when the control goes to sleep." );
addField( "mouseDragging", TypeBool, Offset(mSupportMouseDragging, GuiTreeViewCtrl));