📄 guibuttoncolorctrl.cc
字号:
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
#include "console/console.h"
#include "dgl/dgl.h"
#include "console/consoleTypes.h"
#include "platform/platformAudio.h"
#include "gui/core/guiCanvas.h"
#include "gui/controls/guiButtonColorCtrl.h"
#include "gui/core/guiDefaultControlRender.h"
IMPLEMENT_CONOBJECT(GuiButtonColorCtrl);///TGE_ColorPick
///TGE_ColorPick
GuiButtonColorCtrl::GuiButtonColorCtrl()
{
mBounds.extent.set(140, 30);
mButtonText = StringTable->insert("Button");
m_ciSpecial.set(0xff,0xff,0xff);
}
///TGE_ColorPick
void GuiButtonColorCtrl::onRender(Point2I offset,
const RectI& updateRect)
{
bool highlight = mMouseOver;
bool depressed = mDepressed;
ColorI fontColor(~m_ciSpecial.red,~m_ciSpecial.green,~m_ciSpecial.blue,255);
// ColorI backColor = m_ciSpecial;
//ColorI borderColor = mActive ? mProfile->mBorderColor : mProfile->mBorderColorNA;
RectI boundsRect(offset, mBounds.extent);
//绘画透明底格
if(m_ciSpecial.alpha != 255)
{
int nCols = (mBounds.extent.x+4) >> 3;
int nRows = (mBounds.extent.y+4) >> 3;
glBegin(GL_QUADS);
int yBase;
int xBase;
for(int row = 0; row < nRows; row++)
{
yBase=offset.y + row*8;
for(int col = 0; col < nCols; col++)
{
xBase=offset.x + col*8;
if((col&1) ^ (row&1) )
glColor3ub(206,206,206);
else
glColor3ub(255,255,255);
glVertex2i(xBase,yBase);
glVertex2i(xBase+8,yBase);
glVertex2i(xBase+8,yBase+8);
glVertex2i(xBase,yBase+8);
}
}
glEnd();
}
if( mProfile->mBorder != 0 )
{
if (mDepressed || mStateOn)
renderFilledBorder( boundsRect, mProfile->mBorderColorHL, m_ciSpecial );
else
renderFilledBorder( boundsRect, mProfile->mBorderColor, m_ciSpecial );
}
Point2I textPos = offset;
if(depressed)
textPos += Point2I(1,1);
dglSetBitmapModulation( fontColor );
renderJustifiedText(textPos, mBounds.extent, mButtonText);
//render the children
renderChildControls( offset, updateRect);
}
ConsoleMethodGroupBegin(GuiButtonColorCtrl,GuiButtonColorCtrlGroup,"")
ConsoleMethod(GuiButtonColorCtrl,setColor,void,3,3,"object.setColor(r,g,b,a) float channel 0~1")
{
argc;
ColorF clr;
dSscanf(argv[2],"%g %g %g %g",&clr.red,&clr.green,&clr.blue,&clr.alpha);
object->setColor(clr);
}
ConsoleMethodGroupEnd(GuiButtonColorCtrl,GuiButtonColorCtrlGroup)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -