Sample editor back working.
This commit is contained in:
parent
722bda2801
commit
7ad237edc1
10 changed files with 59 additions and 36 deletions
|
@ -78,6 +78,11 @@ void Button::updateLabel(const PaintEvent* event)
|
|||
mRootNode->addChild(mTextNode.get());
|
||||
}
|
||||
|
||||
if (mTransformDirty)
|
||||
{
|
||||
mTextNode->setLocation(middle);
|
||||
}
|
||||
|
||||
if (mMaterialDirty)
|
||||
{
|
||||
mTextNode->setFillColor(mBackgroundColor);
|
||||
|
@ -88,4 +93,9 @@ void Button::updateLabel(const PaintEvent* event)
|
|||
mTextNode->setContent(mLabel);
|
||||
mContentDirty = false;
|
||||
}
|
||||
|
||||
if (mVisibilityDirty)
|
||||
{
|
||||
mTextNode->setIsVisible(mVisible);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ Label::Label()
|
|||
: Widget(),
|
||||
mLabel()
|
||||
{
|
||||
|
||||
mName = "Label";
|
||||
}
|
||||
|
||||
std::unique_ptr<Label> Label::Create()
|
||||
|
@ -52,9 +52,19 @@ void Label::updateLabel(const PaintEvent* event)
|
|||
mTextNode->setFillColor(mBackgroundColor);
|
||||
}
|
||||
|
||||
if (mTransformDirty)
|
||||
{
|
||||
mTextNode->setLocation(middle);
|
||||
}
|
||||
|
||||
if (mContentDirty)
|
||||
{
|
||||
mTextNode->setContent(mLabel);
|
||||
mContentDirty = false;
|
||||
}
|
||||
|
||||
if (mVisibilityDirty)
|
||||
{
|
||||
mTextNode->setIsVisible(mVisible);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "StackWidget.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
StackWidget::StackWidget()
|
||||
{
|
||||
|
||||
|
|
|
@ -130,12 +130,13 @@ void Widget::setVisible(bool visible)
|
|||
if (mVisible != visible)
|
||||
{
|
||||
mVisibilityDirty = true;
|
||||
}
|
||||
mVisible = visible;
|
||||
|
||||
for (auto& child : mChildren)
|
||||
{
|
||||
child->setVisible(mVisible);
|
||||
mVisible = visible;
|
||||
|
||||
for (auto& child : mChildren)
|
||||
{
|
||||
child->setVisible(mVisible);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -174,10 +175,15 @@ void Widget::onPaintEvent(const PaintEvent* event)
|
|||
|
||||
if (isDirty())
|
||||
{
|
||||
mRootNode->setName(mName);
|
||||
mRootNode->setName(mName + "_RootNode");
|
||||
|
||||
doPaint(event);
|
||||
|
||||
if (mVisibilityDirty)
|
||||
{
|
||||
mRootNode->setIsVisible(mVisible);
|
||||
}
|
||||
|
||||
mTransformDirty = false;
|
||||
mMaterialDirty = false;
|
||||
mVisibilityDirty = false;
|
||||
|
@ -203,7 +209,6 @@ void Widget::updateChildLocations()
|
|||
{
|
||||
child->setBounds(mSize.mWidth, mSize.mHeight);
|
||||
child->setLocation(mLocation);
|
||||
child->setVisible(mVisible);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -109,6 +109,11 @@ public:
|
|||
mName = name;
|
||||
}
|
||||
|
||||
const std::string& getName()
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
|
||||
bool needsUpdate() const;
|
||||
|
||||
protected:
|
||||
|
@ -134,7 +139,7 @@ protected:
|
|||
unsigned mBorderThickness{0};
|
||||
Color mBackgroundColor;
|
||||
Color mBorderColor;
|
||||
bool mVisible{false};
|
||||
bool mVisible{true};
|
||||
|
||||
std::unique_ptr<RectangleNode> mBackgroundNode;
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
#include <memory>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
class FontsManager;
|
||||
|
||||
class AbstractVisualNode
|
||||
|
@ -54,6 +56,7 @@ public:
|
|||
|
||||
void setIsVisible(bool isVisible)
|
||||
{
|
||||
//std::cout << "Setting " << mName << " visibility to " << isVisible << std::endl;
|
||||
mIsVisible = isVisible;
|
||||
}
|
||||
|
||||
|
@ -77,6 +80,15 @@ public:
|
|||
return mIsVisible;
|
||||
}
|
||||
|
||||
void setLocation(const DiscretePoint& loc)
|
||||
{
|
||||
if (mLocation != loc)
|
||||
{
|
||||
mTransformIsDirty = true;
|
||||
mLocation = loc;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
DiscretePoint mLocation;
|
||||
std::unique_ptr<SceneItem> mSceneItem;
|
||||
|
|
|
@ -52,15 +52,6 @@ void RectangleNode::setHeight(unsigned height)
|
|||
}
|
||||
}
|
||||
|
||||
void RectangleNode::setLocation(const DiscretePoint& loc)
|
||||
{
|
||||
if (mLocation != loc)
|
||||
{
|
||||
mTransformIsDirty = true;
|
||||
mLocation = loc;
|
||||
}
|
||||
}
|
||||
|
||||
void RectangleNode::update(FontsManager* fontsManager)
|
||||
{
|
||||
if (!mSceneItem || mGeometryIsDirty)
|
||||
|
|
|
@ -17,7 +17,6 @@ public:
|
|||
|
||||
void setWidth(unsigned width);
|
||||
void setHeight(unsigned height);
|
||||
void setLocation(const DiscretePoint& loc);
|
||||
|
||||
void update(FontsManager* fontsManager) override;
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue