Files
OpenVulkano/openVulkanoCpp/Scene/UI/UI.hpp

54 lines
912 B
C++

/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "Base/ITickable.hpp"
#include <memory>
#include <vector>
namespace openVulkanoCpp::Scene::UI
{
class UiElement : public ITickable
{
public:
std::vector<std::shared_ptr<UiElement>> children;
~UiElement() override = default;
void Tick() override {};
void Render()
{
BeginDraw();
Draw();
for(const auto& child : children)
{
if (child->ShouldDraw())
child->Render();
}
EndDraw();
}
protected:
virtual void BeginDraw() {};
virtual void Draw() = 0;
virtual void EndDraw() {};
virtual bool ShouldDraw() { return true; }
};
class Ui : public UiElement
{
public:
virtual void Init() = 0;
void Draw() override {}
};
}