Basic Font integration.

This commit is contained in:
James Grogan 2022-11-15 09:32:28 +00:00
parent ce11c52ae5
commit 72123bc333
36 changed files with 325 additions and 198 deletions

View file

@ -5,7 +5,6 @@ set(platform_LIBS "")
list(APPEND graphics_LIB_INCLUDES
DrawingContext.cpp
DrawingManager.cpp
DrawingSurface.cpp
RasterPainter.cpp
${platform_LIB_INCLUDES}
@ -36,7 +35,7 @@ target_include_directories(graphics PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/opengl"
)
target_link_libraries(graphics PUBLIC visual_elements image ${platform_LIBS})
target_link_libraries(graphics PUBLIC geometry mesh fonts image visual_elements ${platform_LIBS})
set_property(TARGET graphics PROPERTY FOLDER src)
set_target_properties( graphics PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )

View file

@ -9,10 +9,11 @@
#include "DrawingSurface.h"
#include "Scene.h"
DrawingContext::DrawingContext(DrawingSurface* surface, DrawingMode requestedDrawingMode)
DrawingContext::DrawingContext(DrawingSurface* surface, FontsManager* fontsManager, DrawingMode requestedDrawingMode)
: mSurface(surface),
mDrawingMode(requestedDrawingMode),
mScene(std::make_unique<Scene>())
mScene(std::make_unique<Scene>()),
mFontsManager(fontsManager)
{
if (mDrawingMode == DrawingMode::GRAPH)
{
@ -24,9 +25,9 @@ DrawingContext::DrawingContext(DrawingSurface* surface, DrawingMode requestedDra
}
}
std::unique_ptr<DrawingContext> DrawingContext::Create(DrawingSurface* surface, DrawingMode requestedDrawingMode)
std::unique_ptr<DrawingContext> DrawingContext::Create(DrawingSurface* surface, FontsManager* fontsManager, DrawingMode requestedDrawingMode)
{
return std::make_unique<DrawingContext>(surface, requestedDrawingMode);
return std::make_unique<DrawingContext>(surface, fontsManager, requestedDrawingMode);
}
Scene* DrawingContext::getScene() const
@ -41,6 +42,6 @@ DrawingSurface* DrawingContext::getSurface() const
void DrawingContext::paint()
{
mScene->update(mDrawingMode == DrawingMode::RASTER ? mSurface->getImage() : nullptr);
mScene->update(mFontsManager, mDrawingMode == DrawingMode::RASTER ? mSurface->getImage() : nullptr);
mPainter->paint(this);
}

View file

@ -6,6 +6,7 @@
class Scene;
class AbstractPainter;
class DrawingSurface;
class FontsManager;
enum class DrawingMode
{
@ -16,9 +17,9 @@ enum class DrawingMode
class DrawingContext
{
public:
DrawingContext(DrawingSurface* surface, DrawingMode requestedDrawingMode);
DrawingContext(DrawingSurface* surface, FontsManager* fontsManager, DrawingMode requestedDrawingMode);
static std::unique_ptr<DrawingContext> Create(DrawingSurface* surface, DrawingMode requestedDrawingMode);
static std::unique_ptr<DrawingContext> Create(DrawingSurface* surface, FontsManager* fontsManager, DrawingMode requestedDrawingMode);
Scene* getScene() const;
@ -28,7 +29,7 @@ public:
private:
DrawingMode mDrawingMode;
FontsManager* mFontsManager{nullptr};
DrawingSurface* mSurface{nullptr};
std::unique_ptr<Scene> mScene;
std::unique_ptr<AbstractPainter> mPainter;

View file

@ -1,49 +0,0 @@
#include "DrawingManager.h"
#include "DrawingSurface.h"
#include "DrawingContext.h"
#include "AbstractPainter.h"
#include "Grid.h"
#include "Image.h"
#include "TriMesh.h"
#include "Scene.h"
DrawingManager::DrawingManager()
{
}
std::unique_ptr<DrawingManager> DrawingManager::Create()
{
return std::make_unique<DrawingManager>();
}
void DrawingManager::InitalizeSurface(unsigned width, unsigned height)
{
mDrawingSurface = DrawingSurface::Create();
mDrawingSurface->setSize(width, height);
}
void DrawingManager::InitializeContext()
{
//mDrawingContext = DrawingContext::Create();
}
void DrawingManager::AddText(TextNode* text)
{
if (!mDrawingContext)
{
InitializeContext();
}
if (!mDrawingContext)
{
return;
}
}
void DrawingManager::RenderToFile(const std::string& path)
{
}

View file

@ -1,28 +0,0 @@
#pragma once
#include <memory>
#include <string>
class TextNode;
class DrawingSurface;
using DrawingSurfacePtr = std::unique_ptr<DrawingSurface>;
class DrawingContext;
using DrawingContextPtr = std::unique_ptr<DrawingContext>;
class DrawingManager
{
public:
DrawingManager();
static std::unique_ptr<DrawingManager> Create();
void InitalizeSurface(unsigned width, unsigned height);
void InitializeContext();
void AddText(TextNode* text);
void RenderToFile(const std::string& path);
private:
DrawingSurfacePtr mDrawingSurface {nullptr};
DrawingContextPtr mDrawingContext {nullptr};
};
using DrawingManagerPtr = std::unique_ptr<DrawingManager>;