stuff-from-scratch/apps/notes_tk/image_editor/ImageViewWidget.cpp
2023-01-20 08:07:09 +00:00

46 lines
990 B
C++

#include "ImageViewWidget.h"
#include "GridNode.h"
#include "TransformNode.h"
#include "ThemeManager.h"
#include "PaintEvent.h"
ImageViewWidget::ImageViewWidget()
{
mName = "ImageViewWidget";
}
void ImageViewWidget::doPaint(const PaintEvent* event)
{
if (!mVisible)
{
return;
}
if (!mGridNode)
{
mGridNode = std::make_unique<GridNode>(Transform(mLocation));
mGridNode->setName(mName + "_GridNode");
mGridNode->setNumX(mNumX);
mGridNode->setNumY(mNumY);
mGridNode->setWidth(mSize.mWidth);
mGridNode->setHeight(mSize.mHeight);
mGridNode->setStrokeColor(event->getThemesManager()->getColor(mBorder));
mRootNode->addChild(mGridNode.get());
}
if (mTransformDirty)
{
mGridNode->setWidth(mSize.mWidth);
mGridNode->setHeight(mSize.mHeight);
}
if (mMaterialDirty)
{
mGridNode->setFillColor(event->getThemesManager()->getColor(mBorder));
}
}