stuff-from-scratch/apps/sample-gui/image_editor/ImageViewWidget.cpp
2022-11-18 17:05:33 +00:00

47 lines
988 B
C++

#include "ImageViewWidget.h"
#include "GridNode.h"
#include "TransformNode.h"
#include <iostream>
ImageViewWidget::ImageViewWidget()
{
std::cout << "Creating image view widget" << std::endl;
mName = "ImageViewWidget";
}
void ImageViewWidget::doPaint(const PaintEvent* event)
{
if (!mVisible)
{
return;
}
if (!mGridNode)
{
mGridNode = std::make_unique<GridNode>(mLocation);
mGridNode->setName(mName + "_GridNode");
mGridNode->setNumX(mNumX);
mGridNode->setNumY(mNumY);
mGridNode->setWidth(mSize.mWidth);
mGridNode->setHeight(mSize.mHeight);
mGridNode->setStrokeColor(mBorderColor);
mRootNode->addChild(mGridNode.get());
}
if (mTransformDirty)
{
mGridNode->setLocation(mLocation);
mGridNode->setWidth(mSize.mWidth);
mGridNode->setHeight(mSize.mHeight);
}
if (mMaterialDirty)
{
mGridNode->setFillColor(mBorderColor);
}
}