52 lines
1.1 KiB
C++
52 lines
1.1 KiB
C++
// 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();
|
|
};
|
|
} |