mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
From Nils' UI work
Adds ability to control button margin of IconButtons Adds ability to define button offset of window controls Add mouse drag callback for window controls Tweaks colors of gui slider control Tweak to line split for text edit slider bitmap control Tweaks to colors for text edit slider control Tweaks to colors for Edit control Tweaks to default menubar height
This commit is contained in:
parent
a445a43646
commit
d0f914b3e6
|
|
@ -68,11 +68,12 @@ ConsoleDocClass( GuiIconButtonCtrl,
|
|||
" makeIconSquare = \"1\";\n"
|
||||
" textLocation = \"Bottom\";\n"
|
||||
" textMargin = \"-2\";\n"
|
||||
" autoSize = \"0\";\n"
|
||||
" text = \"Lag Icon\";\n"
|
||||
" textID = \"\"STR_LAG\"\";\n"
|
||||
" buttonType = \"PushButton\";\n"
|
||||
" profile = \"GuiIconButtonProfile\";\n"
|
||||
" bitmapMargin = \"0\";\n"
|
||||
" autoSize = \"0\";\n"
|
||||
" text = \"Lag Icon\";\n"
|
||||
" textID = \"\"STR_LAG\"\";\n"
|
||||
" buttonType = \"PushButton\";\n"
|
||||
" profile = \"GuiIconButtonProfile\";\n"
|
||||
"};\n"
|
||||
"@endtsexample\n\n"
|
||||
|
||||
|
|
@ -96,6 +97,8 @@ GuiIconButtonCtrl::GuiIconButtonCtrl()
|
|||
|
||||
mAutoSize = false;
|
||||
|
||||
mBitmapMargin = 0;
|
||||
|
||||
setExtent(140, 30);
|
||||
}
|
||||
|
||||
|
|
@ -134,6 +137,8 @@ void GuiIconButtonCtrl::initPersistFields()
|
|||
"Options are 0 (None), 1 (Bottom), 2 (Right), 3 (Top), 4 (Left), 5 (Center).\n");
|
||||
addField( "textMargin", TypeS32, Offset( mTextMargin, GuiIconButtonCtrl ),"Margin between the icon and the text.\n");
|
||||
addField( "autoSize", TypeBool, Offset( mAutoSize, GuiIconButtonCtrl ),"If true, the text and icon will be automatically sized to the size of the control.\n");
|
||||
addField( "bitmapMargin", TypeS32, Offset( mBitmapMargin, GuiIconButtonCtrl), "Margin between the icon and the border.\n");
|
||||
|
||||
Parent::initPersistFields();
|
||||
}
|
||||
|
||||
|
|
@ -299,10 +304,16 @@ void GuiIconButtonCtrl::renderButton( Point2I &offset, const RectI& updateRect )
|
|||
// Render the normal bitmap
|
||||
drawer->clearBitmapModulation();
|
||||
|
||||
// Size of the bitmap
|
||||
Point2I textureSize(mBitmap->getWidth(), mBitmap->getHeight());
|
||||
|
||||
// Reduce the size with the margin (if set)
|
||||
textureSize.x = textureSize.x - (mBitmapMargin * 2);
|
||||
textureSize.y = textureSize.y - (mBitmapMargin * 2);
|
||||
|
||||
// Maintain the bitmap size or fill the button?
|
||||
if ( !mFitBitmapToButton )
|
||||
{
|
||||
Point2I textureSize(mBitmap->getWidth(), mBitmap->getHeight() );
|
||||
iconRect.set( offset + mButtonMargin, textureSize );
|
||||
|
||||
if ( mIconLocation == IconLocRight )
|
||||
|
|
@ -326,7 +337,11 @@ void GuiIconButtonCtrl::renderButton( Point2I &offset, const RectI& updateRect )
|
|||
}
|
||||
else
|
||||
{
|
||||
iconRect.set( offset + mButtonMargin, getExtent() - (Point2I(mAbs(mButtonMargin.x), mAbs(mButtonMargin.y)) * 2) );
|
||||
// adding offset with the bitmap margin next to the button margin
|
||||
Point2I bitMapOffset(mBitmapMargin, mBitmapMargin);
|
||||
|
||||
// set the offset
|
||||
iconRect.set( offset + mButtonMargin + bitMapOffset, getExtent() - (Point2I(mAbs(mButtonMargin.x - (mBitmapMargin * 2)), mAbs(mButtonMargin.y - (mBitmapMargin * 2))) * 2) );
|
||||
|
||||
if ( mMakeIconSquare )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -49,6 +49,9 @@ protected:
|
|||
S32 mTextLocation;
|
||||
S32 mTextMargin;
|
||||
Point2I mButtonMargin;
|
||||
|
||||
/// Margin between the icon and the button border
|
||||
S32 mBitmapMargin;
|
||||
|
||||
/// Make the bitmap fill the button extent.
|
||||
bool mFitBitmapToButton;
|
||||
|
|
|
|||
|
|
@ -68,6 +68,8 @@ IMPLEMENT_CALLBACK( GuiWindowCtrl, onRestore, void, (), (),
|
|||
"Called when the window is restored from minimized, maximized, or collapsed state." );
|
||||
IMPLEMENT_CALLBACK(GuiWindowCtrl, onResize, void, (S32 posX, S32 posY, S32 width, S32 height), (0, 0, 0, 0),
|
||||
"Called when the window is resized in a regular manner by mouse manipulation.");
|
||||
IMPLEMENT_CALLBACK(GuiWindowCtrl, onMouseDragged, void, (), (),
|
||||
"Called when the height has changed.");
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -87,7 +89,8 @@ GuiWindowCtrl::GuiWindowCtrl()
|
|||
mCollapseGroup(-1),
|
||||
mCollapseGroupNum(-1),
|
||||
mIsCollapsed(false),
|
||||
mIsMouseResizing(false)
|
||||
mIsMouseResizing(false),
|
||||
mButtonOffset(0, 3)
|
||||
{
|
||||
// mTitleHeight will change in instanciation most likely...
|
||||
mTitleHeight = 24;
|
||||
|
|
@ -154,6 +157,8 @@ void GuiWindowCtrl::initPersistFields()
|
|||
"Script code to execute when the window is closed." );
|
||||
addField( "edgeSnap", TypeBool, Offset( mEdgeSnap,GuiWindowCtrl ),
|
||||
"If true, the window will snap to the edges of other windows when moved close to them." );
|
||||
addField( "buttonOffset", TypePoint2I, Offset (mButtonOffset, GuiWindowCtrl),
|
||||
"Margin between window edge and the button(s).");
|
||||
|
||||
endGroup( "Window" );
|
||||
|
||||
|
|
@ -1019,6 +1024,9 @@ void GuiWindowCtrl::onMouseDragged(const GuiEvent &event)
|
|||
}
|
||||
else // Normal window sizing functionality
|
||||
resize(newPosition, newExtent);
|
||||
|
||||
// Add a callback for the GUI scripts
|
||||
onMouseDragged_callback();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -1409,7 +1417,7 @@ void GuiWindowCtrl::onRender(Point2I offset, const RectI &updateRect)
|
|||
}
|
||||
|
||||
drawUtil->clearBitmapModulation();
|
||||
drawUtil->drawBitmapSR(mTextureObject, offset + mCloseButton.point, mBitmapBounds[bmp]);
|
||||
drawUtil->drawBitmapSR(mTextureObject, mButtonOffset + offset + mCloseButton.point, mBitmapBounds[bmp]);
|
||||
}
|
||||
|
||||
// Draw the maximize button
|
||||
|
|
@ -1428,7 +1436,7 @@ void GuiWindowCtrl::onRender(Point2I offset, const RectI &updateRect)
|
|||
}
|
||||
|
||||
drawUtil->clearBitmapModulation();
|
||||
drawUtil->drawBitmapSR( mTextureObject, offset + mMaximizeButton.point, mBitmapBounds[bmp] );
|
||||
drawUtil->drawBitmapSR( mTextureObject, mButtonOffset + offset + mMaximizeButton.point, mBitmapBounds[bmp] );
|
||||
}
|
||||
|
||||
// Draw the minimize button
|
||||
|
|
@ -1447,7 +1455,7 @@ void GuiWindowCtrl::onRender(Point2I offset, const RectI &updateRect)
|
|||
}
|
||||
|
||||
drawUtil->clearBitmapModulation();
|
||||
drawUtil->drawBitmapSR( mTextureObject, offset + mMinimizeButton.point, mBitmapBounds[bmp] );
|
||||
drawUtil->drawBitmapSR( mTextureObject, mButtonOffset + offset + mMinimizeButton.point, mBitmapBounds[bmp] );
|
||||
}
|
||||
|
||||
if( !mMinimized )
|
||||
|
|
|
|||
|
|
@ -124,6 +124,8 @@ class GuiWindowCtrl : public GuiContainer
|
|||
|
||||
bool mCanDock; ///< Show a docking button on the title bar?
|
||||
bool mEdgeSnap; ///< Should this window snap to other windows edges?
|
||||
|
||||
Point2I mButtonOffset;
|
||||
|
||||
/// @}
|
||||
|
||||
|
|
@ -202,6 +204,7 @@ class GuiWindowCtrl : public GuiContainer
|
|||
DECLARE_CALLBACK( void, onCollapse, () );
|
||||
DECLARE_CALLBACK( void, onRestore, () );
|
||||
DECLARE_CALLBACK(void, onResize, (S32 posX, S32 posY, S32 width, S32 height));
|
||||
DECLARE_CALLBACK(void, onMouseDragged, ());
|
||||
|
||||
/// @}
|
||||
|
||||
|
|
|
|||
|
|
@ -412,7 +412,7 @@ void GuiSliderCtrl::onRender(Point2I offset, const RectI &updateRect)
|
|||
PrimBuild::end();
|
||||
// TODO: it would be nice, if the primitive builder were a little smarter,
|
||||
// so that we could change colors midstream.
|
||||
PrimBuild::color4f(0.9f, 0.9f, 0.9f, 1.0f);
|
||||
PrimBuild::color4f(0.6f, 0.6f, 0.6f, 1.0f);
|
||||
PrimBuild::begin( GFXLineList, ( mTicks + 2 ) * 2 );
|
||||
// tick marks
|
||||
for (U32 t = 0; t <= (mTicks+1); t++)
|
||||
|
|
|
|||
|
|
@ -415,7 +415,7 @@ void GuiTextEditSliderBitmapCtrl::onRender(Point2I offset, const RectI &updateRe
|
|||
|
||||
// Draw the line that splits the number and bitmaps
|
||||
GFX->getDrawUtil()->drawLine(Point2I(offset.x + getWidth() - 14 -2, offset.y + 1 ),
|
||||
Point2I(arrowUpStart.x -2, arrowUpStart.y + getExtent().y),
|
||||
Point2I(arrowUpStart.x -2, arrowUpStart.y + getExtent().y + 2),
|
||||
mProfile->mBorderColor);
|
||||
|
||||
GFX->getDrawUtil()->clearBitmapModulation();
|
||||
|
|
|
|||
|
|
@ -360,12 +360,12 @@ void GuiTextEditSliderCtrl::onRender(Point2I offset, const RectI &updateRect)
|
|||
GFXVertexBufferHandle<GFXVertexPCT> verts(GFX, 6, GFXBufferTypeVolatile);
|
||||
verts.lock();
|
||||
|
||||
verts[0].color.set( 0, 0, 0 );
|
||||
verts[1].color.set( 0, 0, 0 );
|
||||
verts[2].color.set( 0, 0, 0 );
|
||||
verts[3].color.set( 0, 0, 0 );
|
||||
verts[4].color.set( 0, 0, 0 );
|
||||
verts[5].color.set( 0, 0, 0 );
|
||||
verts[0].color.set(128, 128, 128);
|
||||
verts[1].color.set(128, 128, 128);
|
||||
verts[2].color.set(128, 128, 128);
|
||||
verts[3].color.set(128, 128, 128);
|
||||
verts[4].color.set(128, 128, 128);
|
||||
verts[5].color.set(128, 128, 128);
|
||||
|
||||
if(mTextAreaHit == ArrowUp)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2873,7 +2873,7 @@ class GuiEditorRuler : public GuiControl
|
|||
|
||||
void onRender(Point2I offset, const RectI &updateRect)
|
||||
{
|
||||
GFX->getDrawUtil()->drawRectFill(updateRect, ColorI::WHITE);
|
||||
GFX->getDrawUtil()->drawRectFill(updateRect, ColorI::DARK);
|
||||
|
||||
Point2I choffset(0,0);
|
||||
if( mRefCtrl != NULL )
|
||||
|
|
@ -2893,7 +2893,7 @@ class GuiEditorRuler : public GuiControl
|
|||
start = 4;
|
||||
if(!(pos % 100))
|
||||
start = 1;
|
||||
GFX->getDrawUtil()->drawLine(x, offset.y + start, x, offset.y + 10, ColorI::BLACK);
|
||||
GFX->getDrawUtil()->drawLine(x, offset.y + start, x, offset.y + 10, ColorI::LIGHT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2911,7 +2911,7 @@ class GuiEditorRuler : public GuiControl
|
|||
start = 4;
|
||||
if(!(pos % 100))
|
||||
start = 1;
|
||||
GFX->getDrawUtil()->drawLine(offset.x + start, y, offset.x + 10, y, ColorI::BLACK);
|
||||
GFX->getDrawUtil()->drawLine(offset.x + start, y, offset.x + 10, y, ColorI::LIGHT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1100,8 +1100,8 @@ GuiMenuBar::GuiMenuBar()
|
|||
mHorizontalMargin = 6; // Default number of pixels on the left and right side of a manu's text
|
||||
mVerticalMargin = 1; // Default number of pixels on the top and bottom of a menu's text
|
||||
mBitmapMargin = 2; // Default number of pixels between a menu's bitmap and text
|
||||
|
||||
mMenubarHeight = 20;
|
||||
|
||||
mMenubarHeight = 24;
|
||||
|
||||
// Added:
|
||||
mouseDownSubmenu = NULL;
|
||||
|
|
|
|||
Loading…
Reference in a new issue