Clean text rendering in editor.
This commit is contained in:
parent
290b64e230
commit
f16dd7c0d9
45 changed files with 59 additions and 60 deletions
30
apps/notes_tk/image_editor/ImageEditorView.cpp
Normal file
30
apps/notes_tk/image_editor/ImageEditorView.cpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
#include "ImageEditorView.h"
|
||||
|
||||
#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(Theme::getBackgroundPrimary());
|
||||
label->setMargin(1);
|
||||
|
||||
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()
|
||||
{
|
||||
return std::make_unique<ImageEditorView>();
|
||||
}
|
14
apps/notes_tk/image_editor/ImageEditorView.h
Normal file
14
apps/notes_tk/image_editor/ImageEditorView.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
#pragma once
|
||||
|
||||
#include "Widget.h"
|
||||
|
||||
class ImageEditorView : public Widget
|
||||
{
|
||||
public:
|
||||
|
||||
ImageEditorView();
|
||||
|
||||
static std::unique_ptr<ImageEditorView> Create();
|
||||
};
|
||||
|
||||
using ImageEditorViewUPtr = std::unique_ptr<ImageEditorView>;
|
46
apps/notes_tk/image_editor/ImageViewWidget.cpp
Normal file
46
apps/notes_tk/image_editor/ImageViewWidget.cpp
Normal file
|
@ -0,0 +1,46 @@
|
|||
#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);
|
||||
}
|
||||
}
|
18
apps/notes_tk/image_editor/ImageViewWidget.h
Normal file
18
apps/notes_tk/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