Clean up use of transforms in scene graph.
This commit is contained in:
parent
3915a40c96
commit
f26ee2ebc4
37 changed files with 238 additions and 242 deletions
|
@ -203,9 +203,14 @@ bool Button::isDirty() const
|
|||
|
||||
void Button::doPaint(const PaintEvent* event)
|
||||
{
|
||||
if (mTransformDirty)
|
||||
{
|
||||
mRootNode->setTransform(Transform(mLocation));
|
||||
mTransformDirty = false;
|
||||
}
|
||||
|
||||
updateBackground(event);
|
||||
updateLabel(event);
|
||||
|
||||
updateIcon(event);
|
||||
|
||||
mContentDirty = false;
|
||||
|
@ -215,17 +220,12 @@ void Button::updateLabel(const PaintEvent* event)
|
|||
{
|
||||
if (!mTextNode)
|
||||
{
|
||||
mTextNode = TextNode::Create(mLabel, mLocation);
|
||||
mTextNode = TextNode::Create(mLabel, Transform({ mSize.mWidth /2.0, mSize.mHeight / 2.0 }));
|
||||
mTextNode->setName(mName + "_TextNode");
|
||||
mTextNode->setContent(mLabel);
|
||||
mRootNode->addChild(mTextNode.get());
|
||||
}
|
||||
|
||||
if (mTransformDirty)
|
||||
{
|
||||
mTextNode->setLocation(mLocation);
|
||||
mTextNode->setWidth(mSize.mWidth);
|
||||
mTextNode->setHeight(mSize.mHeight);
|
||||
mRootNode->addChild(mTextNode.get());
|
||||
}
|
||||
|
||||
if (mMaterialDirty)
|
||||
|
@ -255,14 +255,14 @@ void Button::updateIcon(const PaintEvent* event)
|
|||
{
|
||||
if (!mIconNode && mIcon != Resource::Icon::Svg::NONE)
|
||||
{
|
||||
mIconNode = std::make_unique<IconNode>(mLocation);
|
||||
mIconNode = std::make_unique<IconNode>(Transform());
|
||||
mIconNode->setName(mName + "_IconNode");
|
||||
mIconNode->setContent(IconNode::IconType::Svg, MediaResourceManager::getSvgIconNode(mIcon));
|
||||
mIconNode->setSvgContent(MediaResourceManager::getSvgIconNode(mIcon));
|
||||
mRootNode->addChild(mIconNode.get());
|
||||
}
|
||||
else if (mContentDirty && mIcon != Resource::Icon::Svg::NONE)
|
||||
{
|
||||
mIconNode->setContent(IconNode::IconType::Svg, MediaResourceManager::getSvgIconNode(mIcon));
|
||||
mIconNode->setSvgContent(MediaResourceManager::getSvgIconNode(mIcon));
|
||||
}
|
||||
|
||||
if (!mIconNode)
|
||||
|
@ -270,11 +270,6 @@ void Button::updateIcon(const PaintEvent* event)
|
|||
return;
|
||||
}
|
||||
|
||||
if (mTransformDirty)
|
||||
{
|
||||
mIconNode->setLocation(mLocation);
|
||||
}
|
||||
|
||||
if (mMaterialDirty)
|
||||
{
|
||||
auto icon_fill = event->getThemesManager()->getColor(mIconColor);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue