Add widget state support.
This commit is contained in:
parent
19091a0e80
commit
8536908eab
19 changed files with 385 additions and 46 deletions
|
@ -33,6 +33,11 @@ double RectangleNode::getHeight() const
|
|||
return mHeight;
|
||||
}
|
||||
|
||||
double RectangleNode::getRadius() const
|
||||
{
|
||||
return mRadius;
|
||||
}
|
||||
|
||||
void RectangleNode::setWidth(double width)
|
||||
{
|
||||
if (mWidth != width)
|
||||
|
@ -51,20 +56,42 @@ void RectangleNode::setHeight(double height)
|
|||
}
|
||||
}
|
||||
|
||||
void RectangleNode::setRadius(double radius)
|
||||
{
|
||||
if (mRadius != radius)
|
||||
{
|
||||
mGeometryIsDirty = true;
|
||||
mRadius = radius;
|
||||
}
|
||||
}
|
||||
|
||||
void RectangleNode::createOrUpdateGeometry(SceneInfo* sceneInfo)
|
||||
{
|
||||
if (sceneInfo->mSupportsGeometryPrimitives)
|
||||
if (!mBackgroundItem)
|
||||
{
|
||||
auto rect = std::make_unique<ntk::Rectangle>(Point{ 0, 0 }, 1, 1);
|
||||
mBackgroundItem = std::make_unique<SceneModel>(std::move(rect));
|
||||
if (sceneInfo->mSupportsGeometryPrimitives)
|
||||
{
|
||||
auto rect = std::make_unique<ntk::Rectangle>(Point{ 0, 0 }, 1, 1);
|
||||
rect->setRadius(mRadius);
|
||||
mBackgroundItem = std::make_unique<SceneModel>(std::move(rect));
|
||||
}
|
||||
else
|
||||
{
|
||||
auto mesh = MeshPrimitives::buildRectangleAsTriMesh();
|
||||
mBackgroundItem = std::make_unique<SceneModel>(std::move(mesh));
|
||||
|
||||
}
|
||||
mBackgroundItem->setName(mName + "_Model");
|
||||
}
|
||||
else
|
||||
{
|
||||
auto mesh = MeshPrimitives::buildRectangleAsTriMesh();
|
||||
mBackgroundItem = std::make_unique<SceneModel>(std::move(mesh));
|
||||
|
||||
if (sceneInfo->mSupportsGeometryPrimitives)
|
||||
{
|
||||
auto rect = std::make_unique<ntk::Rectangle>(Point{ 0, 0 }, 1, 1);
|
||||
rect->setRadius(mRadius);
|
||||
mBackgroundItem->updateGeometry(std::move(rect));
|
||||
}
|
||||
}
|
||||
mBackgroundItem->setName(mName + "_Model");
|
||||
}
|
||||
|
||||
void RectangleNode::updateTransform()
|
||||
|
|
|
@ -14,15 +14,19 @@ public:
|
|||
|
||||
double getWidth() const;
|
||||
double getHeight() const;
|
||||
double getRadius() const;
|
||||
|
||||
void setWidth(double width);
|
||||
void setHeight(double height);
|
||||
void setRadius(double radius);
|
||||
|
||||
private:
|
||||
void createOrUpdateGeometry(SceneInfo* sceneInfo) override;
|
||||
void updateTransform() override;
|
||||
|
||||
double mWidth{1};
|
||||
double mHeight{1};
|
||||
double mRadius{ 0.0 };
|
||||
};
|
||||
|
||||
using RectangleNodePtr = std::unique_ptr<RectangleNode>;
|
||||
|
|
|
@ -29,6 +29,15 @@ void MaterialNode::setHasStrokeColor(bool hasStroke)
|
|||
}
|
||||
}
|
||||
|
||||
void MaterialNode::setHasFillColor(bool hasFill)
|
||||
{
|
||||
if (mHasFillColor != hasFill)
|
||||
{
|
||||
mHasFillColor = hasFill;
|
||||
mMaterialIsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void MaterialNode::setFillColor(const Color& color)
|
||||
{
|
||||
mHasFillColor = true;
|
||||
|
|
|
@ -13,6 +13,7 @@ public:
|
|||
const Color& getStrokeColor() const;
|
||||
|
||||
void setHasStrokeColor(bool hasStroke);
|
||||
void setHasFillColor(bool hasFill);
|
||||
|
||||
void setFillColor(const Color& color);
|
||||
void setStrokeColor(const Color& color);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue