Start adding grid
This commit is contained in:
parent
9301769d58
commit
f04d86e0ad
37 changed files with 709 additions and 211 deletions
|
@ -3,14 +3,25 @@
|
|||
#include "Label.h"
|
||||
#include "Color.h"
|
||||
#include "TextNode.h"
|
||||
#include "Theme.h"
|
||||
#include "ImageViewWidget.h"
|
||||
|
||||
#include "HorizontalSpacer.h"
|
||||
|
||||
ImageEditorView::ImageEditorView()
|
||||
{
|
||||
auto label = Label::Create();
|
||||
label->setLabel("Image Editor");
|
||||
label->setBackgroundColor(Color(200, 189, 160));
|
||||
label->setBackgroundColor(Theme::getBackgroundPrimary());
|
||||
label->setMargin(1);
|
||||
addWidget(std::move(label));
|
||||
|
||||
auto image_widget = std::make_unique<ImageViewWidget>();
|
||||
|
||||
auto hSpacer = HorizontalSpacer::Create();
|
||||
hSpacer->addWidgetWithScale(std::move(label), 1);
|
||||
hSpacer->addWidgetWithScale(std::move(image_widget), 14);
|
||||
|
||||
addWidget(std::move(hSpacer));
|
||||
}
|
||||
|
||||
std::unique_ptr<ImageEditorView> ImageEditorView::Create()
|
||||
|
|
32
apps/sample-gui/image_editor/ImageViewWidget.cpp
Normal file
32
apps/sample-gui/image_editor/ImageViewWidget.cpp
Normal file
|
@ -0,0 +1,32 @@
|
|||
#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)
|
||||
{
|
||||
std::cout << "Setting up grid node" << std::endl;
|
||||
mGridNode = std::make_unique<GridNode>(mLocation);
|
||||
mGridNode->setName(mName + "_GridNode");
|
||||
mGridNode->setNumX(mNumX);
|
||||
mGridNode->setNumY(mNumY);
|
||||
|
||||
mGridNode->setWidth(mSize.mWidth);
|
||||
mGridNode->setHeight(mSize.mHeight);
|
||||
mRootNode->addChild(mGridNode.get());
|
||||
}
|
||||
}
|
18
apps/sample-gui/image_editor/ImageViewWidget.h
Normal file
18
apps/sample-gui/image_editor/ImageViewWidget.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
#pragma once
|
||||
|
||||
#include "Widget.h"
|
||||
|
||||
#include "GridNode.h"
|
||||
|
||||
class ImageViewWidget : public Widget
|
||||
{
|
||||
public:
|
||||
ImageViewWidget();
|
||||
|
||||
private:
|
||||
void doPaint(const PaintEvent* event) override;
|
||||
unsigned mNumX{5};
|
||||
unsigned mNumY{5};
|
||||
|
||||
std::unique_ptr<GridNode> mGridNode;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue