Part one - removed references and smart pointers

This commit is contained in:
2022-11-11 19:08:46 -08:00
parent 4c2fc4cfcf
commit 42645883cd
76 changed files with 3899 additions and 3707 deletions

View File

@ -1,52 +1,80 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "scene/SceneItemComponent.hpp"
#include "display/RenderTarget.hpp"
namespace Dawn {
enum UIDrawType {
UI_DRAW_TYPE_WORLD_ABSOLUTE,
UI_DRAW_TYPE_WORLD_CAMERA_RELATIVE,
UI_DRAW_TYPE_CAMERA_OVERLAY
};
class UIComponent;
class UICanvas : public SceneItemComponent {
protected:
void onBackBufferResize(
RenderTarget &target,
float_t width,
float_t height
);
public:
static std::shared_ptr<UICanvas> createCanvas(
std::shared_ptr<Scene> scene
);
//
std::vector<std::shared_ptr<UIComponent>> children;
UIDrawType drawType = UI_DRAW_TYPE_WORLD_CAMERA_RELATIVE;
UICanvas(SceneItem &item);
template<class T>
std::shared_ptr<T> addElement() {
auto item = std::make_shared<T>(*this);
this->children.push_back(item);
return item;
}
float_t getWidth();
float_t getHeight();
void onStart() override;
~UICanvas();
};
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "scene/SceneItemComponent.hpp"
#include "display/RenderTarget.hpp"
namespace Dawn {
enum UIDrawType {
UI_DRAW_TYPE_WORLD_ABSOLUTE,
UI_DRAW_TYPE_WORLD_CAMERA_RELATIVE,
UI_DRAW_TYPE_CAMERA_OVERLAY
};
class UIComponent;
class UICanvas : public SceneItemComponent {
protected:
void onBackBufferResize(
RenderTarget *target,
float_t width,
float_t height
);
public:
/**
* Creates a UI Canvas Scene Item Element, and attaches it to the provided
* scene.
*
* @param scene Scene to create the UI Canvas for.
* @return Created UI Canvas.
*/
static UICanvas * createCanvas(Scene *scene);
//
std::vector<UIComponent*> children;
UIDrawType drawType = UI_DRAW_TYPE_WORLD_CAMERA_RELATIVE;
/**
* Constructs the UI Canvas Scene Item Component.
*
* @param item Item that this canvas item belongs to.
*/
UICanvas(SceneItem *item);
/**
* Construct and append a UI item to this UI Canvas.
*
* @tparam Type of the UI Item.
* @return Pointer to the created UI Item.
*/
template<class T>
T * addElement() {
auto item = new T(this);
this->children.push_back(item);
return item;
}
/**
* Returns the width of the root UI Canvas size. In future I may allow
* this to be dynamic, right now it uses the render canvas however.
*
* @return Width of the UI Canvas.
*/
float_t getWidth();
/**
* Returns the height of this UI Canvas element.
*
* @return Height of the UI Canvas.
*/
float_t getHeight();
void onStart() override;
~UICanvas();
};
}