Add cairo interface.

This commit is contained in:
jmsgrogan 2021-04-17 13:57:14 +01:00
parent a03eb9599f
commit 9bcc0ae88e
63 changed files with 1247 additions and 450 deletions

View file

@ -1,39 +0,0 @@
#include "GeometryElement.h"
GeometryElement::GeometryElement()
: mFillColor(Color::Create(255, 255, 255)),
mStrokeColor(Color::Create(0, 0, 0)),
mStrokeThickness(1),
mType(Type::Path)
{
}
Color* GeometryElement::GetFillColor() const
{
return mFillColor.get();
}
Color* GeometryElement::GetStrokeColor() const
{
return mStrokeColor.get();
}
unsigned GeometryElement::GetStrokeThickness() const
{
return mStrokeThickness;
}
void GeometryElement::SetFillColor(ColorUPtr color)
{
mFillColor = std::move(color);
}
void GeometryElement::SetStrokeColor(ColorUPtr color)
{
mStrokeColor = std::move(color);
}
void GeometryElement::SetStrokeThickness(unsigned thickness)
{
mStrokeThickness = thickness;
}

View file

@ -1,37 +0,0 @@
#pragma once
#include "Color.h"
class GeometryElement
{
public:
enum class Type
{
Path,
Rectangle,
Circle,
Arc
};
private:
ColorUPtr mFillColor;
ColorUPtr mStrokeColor;
unsigned mStrokeThickness;
Type mType;
public:
GeometryElement();
virtual ~GeometryElement() = default;
Color* GetFillColor() const;
Color* GetStrokeColor() const;
unsigned GetStrokeThickness() const;
virtual Type GetType() = 0;
void SetFillColor(ColorUPtr color);
void SetStrokeColor(ColorUPtr color);
void SetStrokeThickness(unsigned thickness);
};
using GeometryElementUPtr = std::unique_ptr<GeometryElement>;

View file

@ -1,36 +0,0 @@
#include "RectangleElement.h"
RectangleElement::RectangleElement(const DiscretePoint& loc,
unsigned width, unsigned height)
: mLocation(loc),
mWidth(width),
mHeight(height)
{
}
std::unique_ptr<RectangleElement> RectangleElement::Create(const DiscretePoint& loc,
unsigned width, unsigned height)
{
return std::make_unique<RectangleElement>(loc, width, height);
}
GeometryElement::Type RectangleElement::GetType()
{
return GeometryElement::Type::Rectangle;
}
DiscretePoint RectangleElement::GetLocation() const
{
return mLocation;
}
unsigned RectangleElement::GetWidth() const
{
return mWidth;
}
unsigned RectangleElement::GetHeight() const
{
return mHeight;
}

View file

@ -1,28 +0,0 @@
#pragma once
#include <memory>
#include "GeometryElement.h"
#include "DiscretePoint.h"
class RectangleElement : public GeometryElement
{
DiscretePoint mLocation;
unsigned mWidth;
unsigned mHeight;
public:
RectangleElement(const DiscretePoint& loc, unsigned width, unsigned height);
static std::unique_ptr<RectangleElement> Create(const DiscretePoint& loc,
unsigned width, unsigned height);
GeometryElement::Type GetType() override;
DiscretePoint GetLocation() const;
unsigned GetWidth() const;
unsigned GetHeight() const;
};
using RectangleElementUPtr = std::unique_ptr<RectangleElement>;

View file

@ -1,62 +0,0 @@
#include "TextElement.h"
#include "Color.h"
TextElement::TextElement(const std::string& content, const DiscretePoint& loc)
: mContent(content),
mLocation(loc),
mFontLabel("fixed"),
mFillColor(Color::Create(255, 255, 255)),
mStrokeColor(Color::Create(0, 0, 0))
{
// https://en.wikipedia.org/wiki/Fixed_(typeface)#:~:text=misc%2Dfixed%20is%20a%20collection,to%20a%20single%20font%20family.
}
TextElement::~TextElement()
{
}
std::unique_ptr<TextElement> TextElement::Create(const std::string& content, const DiscretePoint& loc)
{
return std::make_unique<TextElement>(content, loc);
}
Color* TextElement::GetFillColor() const
{
return mFillColor.get();
}
Color* TextElement::GetStrokeColor() const
{
return mStrokeColor.get();
}
DiscretePoint TextElement::GetLocation() const
{
return mLocation;
}
std::string TextElement::GetFontLabel() const
{
return mFontLabel;
}
std::string TextElement::GetContent() const
{
return mContent;
}
void TextElement::SetContent(const std::string& content)
{
mContent = content;
}
void TextElement::SetFillColor(ColorUPtr color)
{
mFillColor = std::move(color);
}
void TextElement::SetStrokeColor(ColorUPtr color)
{
mStrokeColor = std::move(color);
}

View file

@ -1,37 +0,0 @@
#pragma once
#include "DiscretePoint.h"
#include <memory>
#include <string>
class Color;
class TextElement
{
std::string mContent;
DiscretePoint mLocation;
std::string mFontLabel;
std::unique_ptr<Color> mFillColor;
std::unique_ptr<Color> mStrokeColor;
public:
TextElement(const std::string& content, const DiscretePoint& loc);
~TextElement();
static std::unique_ptr<TextElement> Create(const std::string& content, const DiscretePoint& loc);
Color* GetFillColor() const;
Color* GetStrokeColor() const;
DiscretePoint GetLocation() const;
std::string GetContent() const;
std::string GetFontLabel() const;
void SetContent(const std::string& content);
void SetFillColor(std::unique_ptr<Color> color);
void SetStrokeColor(std::unique_ptr<Color> color);
};
using TextElementUPtr = std::unique_ptr<TextElement>;

View file

@ -1,46 +0,0 @@
#include "VisualLayer.h"
#include "GeometryElement.h"
#include "TextElement.h"
VisualLayer::VisualLayer()
: mShape(),
mText()
{
}
std::unique_ptr<VisualLayer> VisualLayer::Create()
{
return std::make_unique<VisualLayer>();
}
bool VisualLayer::HasShape() const
{
return bool(mShape);
}
bool VisualLayer::HasText() const
{
return bool(mText);
}
GeometryElement* VisualLayer::GetShape() const
{
return mShape.get();
}
TextElement* VisualLayer::GetText() const
{
return mText.get();
}
void VisualLayer::SetShape(GeometryElementUPtr shape)
{
mShape = std::move(shape);
}
void VisualLayer::SetText(TextElementUPtr text)
{
mText = std::move(text);
}

View file

@ -1,25 +0,0 @@
#pragma once
#include <memory>
class GeometryElement;
class TextElement;
class VisualLayer
{
std::unique_ptr<GeometryElement> mShape;
std::unique_ptr<TextElement> mText;
public:
VisualLayer();
static std::unique_ptr<VisualLayer> Create();
GeometryElement* GetShape() const;
TextElement* GetText() const;
bool HasShape() const;
bool HasText() const;
void SetShape(std::unique_ptr<GeometryElement> shape);
void SetText(std::unique_ptr<TextElement> text);
};
using VisualLayerUPtr = std::unique_ptr<VisualLayer>;