mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
can key focus
This commit is contained in:
parent
daa0cfef3a
commit
b2095db575
|
|
@ -58,6 +58,7 @@ GuiShaderEditor::GuiShaderEditor()
|
|||
|
||||
// test
|
||||
mCurrNodes.push_back(new ShaderNode());
|
||||
mCurrNodes.push_back(new ShaderNode());
|
||||
}
|
||||
|
||||
bool GuiShaderEditor::onWake()
|
||||
|
|
@ -191,6 +192,22 @@ void GuiShaderEditor::onRender(Point2I offset, const RectI& updateRect)
|
|||
|
||||
bool GuiShaderEditor::onKeyDown(const GuiEvent& event)
|
||||
{
|
||||
if (!mActive)
|
||||
return Parent::onKeyDown(event);
|
||||
|
||||
if (!(event.modifier & SI_PRIMARY_CTRL))
|
||||
{
|
||||
switch (event.keyCode)
|
||||
{
|
||||
case KEY_BACKSPACE:
|
||||
case KEY_DELETE:
|
||||
deleteSelection();
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -367,7 +384,7 @@ void GuiShaderEditor::onMiddleMouseDown(const GuiEvent& event)
|
|||
mLastMousePos = globalToLocalCoord(event.mousePoint);
|
||||
|
||||
setMouseMode(DragPanning);
|
||||
|
||||
getRoot()->showCursor(false);
|
||||
}
|
||||
|
||||
void GuiShaderEditor::onMiddleMouseUp(const GuiEvent& event)
|
||||
|
|
@ -378,6 +395,8 @@ void GuiShaderEditor::onMiddleMouseUp(const GuiEvent& event)
|
|||
return;
|
||||
}
|
||||
|
||||
getRoot()->showCursor(true);
|
||||
|
||||
//unlock the mouse
|
||||
mouseUnlock();
|
||||
|
||||
|
|
@ -471,6 +490,10 @@ void GuiShaderEditor::deleteSelection()
|
|||
for (ShaderNode* node : mSelectedNodes)
|
||||
{
|
||||
mTrash->addObject(node);
|
||||
|
||||
Vector< ShaderNode* >::iterator i = T3D::find(mCurrNodes.begin(), mCurrNodes.end(), node);
|
||||
if (i != mCurrNodes.end())
|
||||
mCurrNodes.erase(i);
|
||||
}
|
||||
|
||||
clearSelection();
|
||||
|
|
|
|||
|
|
@ -38,8 +38,9 @@ ShaderNode::ShaderNode()
|
|||
{
|
||||
mTitle = "Default Node";
|
||||
mSelected = false;
|
||||
mNodeType = NodeTypes::Uniform;
|
||||
// fixed extent for all nodes, only height should be changed
|
||||
setExtent(150, 100);
|
||||
setExtent(210, 100);
|
||||
|
||||
GuiControlProfile* profile = NULL;
|
||||
if (Sim::findObject("ToolsGuiDefaultProfile", profile))
|
||||
|
|
@ -85,14 +86,53 @@ void ShaderNode::onRender(Point2I offset, const RectI& updateRect)
|
|||
|
||||
GFXDrawUtil* drawer = GFX->getDrawUtil();
|
||||
|
||||
// draw background.
|
||||
// Get our rect.
|
||||
RectI winRect;
|
||||
winRect.point = offset;
|
||||
winRect.extent = getExtent();
|
||||
|
||||
// draw background.
|
||||
drawer->drawRectFill(winRect, mProfile->mFillColor);
|
||||
|
||||
// draw header
|
||||
RectI headRect;
|
||||
headRect.point = offset;
|
||||
headRect.extent = Point2I(getExtent().x, 30);
|
||||
|
||||
ColorI header(50, 50, 50, 128);
|
||||
|
||||
switch (mNodeType)
|
||||
{
|
||||
case NodeTypes::Default:
|
||||
header = ColorI(128, 50, 128, 128);
|
||||
break;
|
||||
case NodeTypes::Uniform:
|
||||
header = ColorI(50, 100, 128, 128);
|
||||
break;
|
||||
case NodeTypes::Input:
|
||||
header = ColorI(128, 100, 50, 128);
|
||||
break;
|
||||
case NodeTypes::Output:
|
||||
header = ColorI(50, 100, 50, 128);
|
||||
break;
|
||||
case NodeTypes::TextureSampler:
|
||||
header = ColorI(50, 50, 128, 128);
|
||||
break;
|
||||
case NodeTypes::MathOperation:
|
||||
header = ColorI(128, 0, 128, 128);
|
||||
break;
|
||||
case NodeTypes::Procedural:
|
||||
header = ColorI(128, 100, 0, 128);
|
||||
break;
|
||||
case NodeTypes::Generator:
|
||||
header = ColorI(0, 100, 128, 128);
|
||||
break;
|
||||
default:
|
||||
header = ColorI(128, 0, 0, 128);
|
||||
break;
|
||||
}
|
||||
|
||||
drawer->drawRectFill(headRect, header);
|
||||
|
||||
// draw header text.
|
||||
U32 strWidth = mProfile->mFont->getStrWidth(mTitle.c_str());
|
||||
Point2I headerPos = Point2I((getExtent().x / 2) - (strWidth / 2), (30 / 2) - (mProfile->mFont->getFontSize() / 2));
|
||||
|
|
@ -103,9 +143,8 @@ void ShaderNode::onRender(Point2I offset, const RectI& updateRect)
|
|||
ColorI border(128, 128, 128, 128);
|
||||
|
||||
if (mSelected)
|
||||
border = ColorI(128, 0, 128, 128);
|
||||
border = ColorI(128, 0, 128, 255);
|
||||
|
||||
winRect.inset(1, 1);
|
||||
drawer->drawRect(winRect, border);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ private:
|
|||
|
||||
protected:
|
||||
String mTitle;
|
||||
NodeTypes mNodeType;
|
||||
|
||||
public:
|
||||
ShaderNode();
|
||||
|
|
|
|||
|
|
@ -946,6 +946,7 @@ singleton GuiControlProfile( GuiBackFillProfile )
|
|||
singleton GuiControlProfile(GuiShaderEditorProfile : ToolsGuiDefaultProfile)
|
||||
{
|
||||
opaque = true;
|
||||
canKeyFocus = true;
|
||||
};
|
||||
|
||||
singleton GuiControlProfile(ShaderNodeProfile : ToolsGuiDefaultProfile)
|
||||
|
|
|
|||
Loading…
Reference in a new issue