Canvas and UI Component #222

Merged
maverickdgg merged 5 commits from SP3-20-UI-System into main 2022-11-18 12:29:40 +08:00
5 changed files with 117 additions and 4 deletions
Showing only changes of commit 0bb97413ef - Show all commits

View File

@ -37,8 +37,6 @@ namespace SHADE
void Exit (void);
friend class EditorCameraUpdate;
class SH_API CameraSystemUpdate final: public SHSystemRoutine
{
public:

View File

@ -0,0 +1,55 @@
#include "SHpch.h"
#include "SHCanvasComponent.h"
namespace SHADE
{
SHCanvasComponent::SHCanvasComponent()
:width(1),height(1), dirtyMatrix(false)
{
}
void SHCanvasComponent::SetCanvasSize(CanvasSizeType width, CanvasSizeType height) noexcept
{
this->width = width;
this->height = height;
}
void SHCanvasComponent::SetCanvasWidth(CanvasSizeType val) noexcept
{
width = val;
}
void SHCanvasComponent::SetCanvasHeight(CanvasSizeType val) noexcept
{
height = val;
}
SHCanvasComponent::CanvasSizeType const SHCanvasComponent::GetCanvasWidth() const noexcept
{
return width;
}
SHCanvasComponent::CanvasSizeType const SHCanvasComponent::GetCanvasHeight() const noexcept
{
return height;
}
}
RTTR_REGISTRATION
{
using namespace SHADE;
using namespace rttr;
registration::class_<SHCanvasComponent>("Canvas Component")
.property("Canvas Width", &SHCanvasComponent::GetCanvasWidth, &SHCanvasComponent::SetCanvasWidth)
.property("Canvas Height", &SHCanvasComponent::GetCanvasHeight, &SHCanvasComponent::SetCanvasHeight)
;
}

View File

@ -1,7 +1,10 @@
#pragma once
#include <rttr/registration>
#include "SH_API.h"
#include "ECS_Base/Components/SHComponent.h"
#include "Math/SHMatrix.h"
namespace SHADE
@ -13,6 +16,9 @@ namespace SHADE
public:
friend class SHUISystem;
SHCanvasComponent();
~SHCanvasComponent() = default;
@ -26,9 +32,11 @@ namespace SHADE
private:
CanvasSizeType width;
CanvasSizeType height;
bool dirtyMatrix;
SHMatrix modelToCanvasMatrix;
RTTR_ENABLE()
};

View File

@ -0,0 +1,20 @@
#include "SHpch.h"
#include "SHUIComponent.h"
namespace SHADE
{
SHUIComponent::SHUIComponent()
{
}
SHMatrix const& SHUIComponent::GetMatrix()const noexcept
{
return LocalToCanvasMatrix;
}
}

View File

@ -0,0 +1,32 @@
#pragma once
#include <rttr/registration>
#include "SH_API.h"
#include "ECS_Base/Components/SHComponent.h"
#include "Math/SHMatrix.h"
namespace SHADE
{
class SH_API SHUIComponent final: public SHComponent
{
public:
friend class SHUISystem;
SHUIComponent();
~SHUIComponent() = default;
SHMatrix const& GetMatrix() const noexcept;
private:
SHMatrix LocalToCanvasMatrix;
RTTR_ENABLE()
}
}