stuff-from-scratch/apps/notes_tk/image_editor/ImageViewWidget.cpp

52 lines
1 KiB
C++
Raw Normal View History

2022-11-17 17:33:48 +00:00
#include "ImageViewWidget.h"
#include "GridNode.h"
#include "TransformNode.h"
2023-01-17 13:01:59 +00:00
#include "ThemeManager.h"
#include "PaintEvent.h"
2022-11-17 17:33:48 +00:00
ImageViewWidget::ImageViewWidget()
{
mName = "ImageViewWidget";
}
2023-01-23 10:08:29 +00:00
ImageViewWidget::~ImageViewWidget()
{
}
2022-11-17 17:33:48 +00:00
void ImageViewWidget::doPaint(const PaintEvent* event)
{
if (!mVisible)
{
return;
}
if (!mGridNode)
{
2023-02-26 18:23:21 +00:00
mGridNode = std::make_unique<GridNode>(Transform(Point3(mLocation)));
2022-11-17 17:33:48 +00:00
mGridNode->setName(mName + "_GridNode");
mGridNode->setNumX(mNumX);
mGridNode->setNumY(mNumY);
mGridNode->setWidth(mSize.mWidth);
mGridNode->setHeight(mSize.mHeight);
2022-11-18 09:43:22 +00:00
2023-01-17 13:01:59 +00:00
mGridNode->setStrokeColor(event->getThemesManager()->getColor(mBorder));
2022-11-18 09:43:22 +00:00
2022-11-17 17:33:48 +00:00
mRootNode->addChild(mGridNode.get());
}
2022-11-18 09:43:22 +00:00
if (mTransformDirty)
{
mGridNode->setWidth(mSize.mWidth);
mGridNode->setHeight(mSize.mHeight);
}
if (mMaterialDirty)
{
2023-01-17 13:01:59 +00:00
mGridNode->setFillColor(event->getThemesManager()->getColor(mBorder));
2022-11-18 09:43:22 +00:00
}
2022-11-17 17:33:48 +00:00
}