Convert visual layers to scene nodes.
This commit is contained in:
parent
798cb365d7
commit
3e53bd9e00
64 changed files with 863 additions and 551 deletions
|
@ -1,9 +1,9 @@
|
|||
#include "TextBox.h"
|
||||
|
||||
#include "TextNode.h"
|
||||
#include "VisualLayer.h"
|
||||
#include "GeometryNode.h"
|
||||
#include "KeyboardEvent.h"
|
||||
#include "TransformNode.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
|
@ -24,6 +24,7 @@ std::unique_ptr<TextBox> TextBox::Create()
|
|||
void TextBox::setContent(const std::string& text)
|
||||
{
|
||||
mContent = text;
|
||||
mContentDirty = true;
|
||||
}
|
||||
|
||||
std::string TextBox::getContent() const
|
||||
|
@ -34,6 +35,7 @@ std::string TextBox::getContent() const
|
|||
void TextBox::appendContent(const std::string& text)
|
||||
{
|
||||
mContent += text;
|
||||
mContentDirty = true;
|
||||
}
|
||||
|
||||
bool TextBox::onMyKeyboardEvent(const KeyboardEvent* event)
|
||||
|
@ -72,6 +74,7 @@ bool TextBox::onMyKeyboardEvent(const KeyboardEvent* event)
|
|||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
void TextBox::onPaintEvent(const PaintEvent* event)
|
||||
{
|
||||
mMyLayers.clear();
|
||||
|
@ -101,3 +104,38 @@ void TextBox::onPaintEvent(const PaintEvent* event)
|
|||
}
|
||||
addMyLayers();
|
||||
}
|
||||
*/
|
||||
|
||||
bool TextBox::isDirty() const
|
||||
{
|
||||
return Widget::isDirty() || mContentDirty;
|
||||
}
|
||||
|
||||
void TextBox::doPaint(const PaintEvent* event)
|
||||
{
|
||||
updateBackground(event);
|
||||
updateLabel(event);
|
||||
}
|
||||
|
||||
void TextBox::updateLabel(const PaintEvent* event)
|
||||
{
|
||||
unsigned fontOffset = unsigned(mContent.size()) * 4;
|
||||
auto middle = DiscretePoint(mLocation.GetX() + mSize.mWidth/2 - fontOffset, mLocation.GetY() + mSize.mHeight/2 + 4);
|
||||
|
||||
if (!mTextNode)
|
||||
{
|
||||
mTextNode = TextNode::Create(mContent, middle);
|
||||
mRootNode->addChild(mTextNode.get());
|
||||
}
|
||||
|
||||
if (mMaterialDirty)
|
||||
{
|
||||
mTextNode->setFillColor(mBackgroundColor);
|
||||
}
|
||||
|
||||
if (mContentDirty)
|
||||
{
|
||||
mTextNode->setContent(mContent);
|
||||
mContentDirty = false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue