#include "ImageViewWidget.h"

#include "GridNode.h"
#include "TransformNode.h"

#include <iostream>

ImageViewWidget::ImageViewWidget()
{
    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);
    }
}
