Clean text rendering in editor.

This commit is contained in:
James Grogan 2022-12-02 11:50:15 +00:00
parent 290b64e230
commit f16dd7c0d9
45 changed files with 59 additions and 60 deletions

View file

@ -0,0 +1,6 @@
#include "CanvasController.h"
std::unique_ptr<CanvasController> CanvasController::Create()
{
return std::make_unique<CanvasController>();
}

View file

@ -0,0 +1,9 @@
#pragma once
#include <memory>
class CanvasController
{
public:
static std::unique_ptr<CanvasController> Create();
};

View file

@ -0,0 +1,75 @@
#include "CanvasView.h"
#include "HorizontalSpacer.h"
#include "VerticalSpacer.h"
#include "CanvasController.h"
#include "Theme.h"
#include "TextNode.h"
#include "Label.h"
#include "Button.h"
#include <iostream>
CanvasView::CanvasView()
: mController(CanvasController::Create())
{
initialize();
}
CanvasView::~CanvasView()
{
}
std::unique_ptr<CanvasView> CanvasView::Create()
{
return std::make_unique<CanvasView>();
}
void CanvasView::initialize()
{
auto label = Label::Create();
label->setLabel("Canvas");
label->setBackgroundColor(Theme::getBannerBackground());
label->setMargin(1);
auto hSpacer = HorizontalSpacer::Create();
hSpacer->addWidgetWithScale(std::move(label), 1);
//hSpacer->addWidgetWithScale(std::move(textBox), 14);
auto cache_button_spacer = initializeCacheButtons();
hSpacer->addWidgetWithScale(std::move(cache_button_spacer), 1);
addWidget(std::move(hSpacer));
}
std::unique_ptr<Widget> CanvasView::initializeCacheButtons()
{
auto saveButton = Button::Create();
saveButton->setLabel("Save");
saveButton->setBackgroundColor(Theme::getButtonPrimaryBackground());
saveButton->setMargin(2);
auto clearButton = Button::Create();
clearButton->setLabel("Clear");
clearButton->setBackgroundColor(Theme::getButtonPrimaryBackground());
clearButton->setMargin(2);
auto loadButton = Button::Create();
loadButton->setLabel("Load");
loadButton->setBackgroundColor(Theme::getButtonPrimaryBackground());
loadButton->setMargin(2);
auto buttonSpacer = VerticalSpacer::Create();
buttonSpacer->AddWidgetWithScale(std::move(saveButton), 1);
buttonSpacer->AddWidgetWithScale(std::move(clearButton), 1);
buttonSpacer->AddWidgetWithScale(std::move(loadButton), 1);
return buttonSpacer;
}

View file

@ -0,0 +1,26 @@
#pragma once
#include "Widget.h"
class CanvasController;
class CanvasView : public Widget
{
public:
CanvasView();
~CanvasView();
static std::unique_ptr<CanvasView> Create();
private:
void initialize();
std::unique_ptr<Widget> initializeCacheButtons();
//std::unique_ptr<Widget> initializeCacheButtons();
std::unique_ptr<CanvasController> mController;
};
using CanvasViewPtr = std::unique_ptr<CanvasView>;