WIP (Codename Ultra) UI lib
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
#pragma once
|
||||
|
||||
#include <pd/core/core.hpp>
|
||||
#include <pd/lithium/lithium.hpp>
|
||||
|
||||
using UltraAlignment = PD::u32;
|
||||
enum UltraAlignment_ {
|
||||
UltraAlignment_None = 0,
|
||||
UltraAlignment_Top = 1 << 0,
|
||||
UltraAlignment_Bot = 1 << 1,
|
||||
UltraAlignment_Left = 1 << 2,
|
||||
UltraAlignment_Right = 1 << 3,
|
||||
UltraAlignment_TopLeft = UltraAlignment_Top | UltraAlignment_Left,
|
||||
UltraAlignment_TopRight = UltraAlignment_Top | UltraAlignment_Right,
|
||||
UltraAlignment_BotLeft = UltraAlignment_Bot | UltraAlignment_Left,
|
||||
UltraAlignment_BotRight = UltraAlignment_Bot | UltraAlignment_Right,
|
||||
};
|
||||
|
||||
namespace PD {
|
||||
namespace Ultra {
|
||||
class PD_API Canvas {
|
||||
public:
|
||||
Canvas();
|
||||
Canvas(const PD::fvec2& size);
|
||||
~Canvas();
|
||||
|
||||
void SetVirtualViewport(const PD::fvec2& size);
|
||||
void SetViewport(const PD::fvec2& size);
|
||||
|
||||
PD::fvec2 VTranslatePos(const PD::fvec2& p) const;
|
||||
PD::fvec2 VTranslateAlignPos(const PD::fvec2& pos, const PD::fvec2& size,
|
||||
UltraAlignment align) const;
|
||||
PD::Li::Rect VTranslateObject(const PD::fvec2& pos, const PD::fvec2& size,
|
||||
UltraAlignment align, bool size_modified = false) const;
|
||||
PD::fvec2 TranslatePos(const PD::fvec2& p) const;
|
||||
PD::fvec2 VTranslateSize(const PD::fvec2& s) const;
|
||||
PD::fvec2 TranslateSize(const PD::fvec2& s) const;
|
||||
float VTranslateFontscale(float f) const;
|
||||
float TranslateFontscale(float f) const;
|
||||
|
||||
private:
|
||||
PD::fvec2 pViewport;
|
||||
PD::fvec2 pVirtualViewPort;
|
||||
float pVfactor = 0.f;
|
||||
PD::fvec2 pVoff;
|
||||
};
|
||||
} // namespace Ultra
|
||||
} // namespace PD
|
||||
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <pd/lithium/lithium.hpp>
|
||||
|
||||
namespace PD {
|
||||
namespace Ultra {
|
||||
class ElementBase {
|
||||
public:
|
||||
ElementBase() {}
|
||||
~ElementBase() {}
|
||||
|
||||
virtual void Draw(PD::Li::Drawlist& dl) = 0;
|
||||
/**
|
||||
* Reset Function (for PD::Pool::FastReset)
|
||||
*/
|
||||
virtual void Reset() {}
|
||||
|
||||
private:
|
||||
};
|
||||
} // namespace Ultra
|
||||
} // namespace PD
|
||||
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <pd/core/core.hpp>
|
||||
#include <pd/ultra/elems/element.hpp>
|
||||
|
||||
namespace PD {
|
||||
namespace Ultra {
|
||||
class PD_API Rect : public ElementBase {
|
||||
public:
|
||||
Rect() {}
|
||||
~Rect() {}
|
||||
|
||||
void Draw(PD::Li::Drawlist& l) override;
|
||||
|
||||
void SetPosition(const PD::fvec2& pos) { pPos = pos; }
|
||||
void SetPosition(float x, float y) { pPos = PD::fvec2(x, y); }
|
||||
void SetSize(const PD::fvec2& size) { pSize = size; }
|
||||
void SetSize(float w, float h) { pSize = PD::fvec2(w, h); }
|
||||
void SetColor(const PD::Color& color) { pColor = color; }
|
||||
void SetRounding(float r) { pRounding = r; }
|
||||
|
||||
private:
|
||||
PD::fvec2 pPos;
|
||||
PD::fvec2 pSize;
|
||||
PD::Color pColor;
|
||||
float pRounding = 0.f;
|
||||
};
|
||||
} // namespace Ultra
|
||||
|
||||
} // namespace PD
|
||||
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <pd/core/core.hpp>
|
||||
#include <pd/ultra/elems/element.hpp>
|
||||
|
||||
namespace PD {
|
||||
namespace Ultra {
|
||||
class PD_API Text : public ElementBase {
|
||||
public:
|
||||
Text() {}
|
||||
~Text() {}
|
||||
|
||||
void Draw(PD::Li::Drawlist& l) override;
|
||||
|
||||
void SetPosition(const PD::fvec2& pos) { pPos = pos; }
|
||||
void SetPosition(float x, float y) { pPos = PD::fvec2(x, y); }
|
||||
void SetColor(const PD::Color& color) { pColor = color; }
|
||||
void SetText(const std::string& text) { pText = text; }
|
||||
|
||||
private:
|
||||
PD::fvec2 pPos;
|
||||
PD::Color pColor;
|
||||
std::string pText;
|
||||
};
|
||||
} // namespace Ultra
|
||||
|
||||
} // namespace PD
|
||||
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <pd/ultra/canvas.hpp>
|
||||
#include <pd/ultra/elems/element.hpp>
|
||||
|
||||
namespace PD {
|
||||
namespace Ultra {
|
||||
class PD_API Layout {
|
||||
public:
|
||||
Layout() {}
|
||||
~Layout() {}
|
||||
|
||||
void Add(ElementBase& elem);
|
||||
|
||||
void SetFont(PD::Li::Font& font);
|
||||
|
||||
void Render();
|
||||
|
||||
const PD::Li::Drawlist& Data() const { return pList; }
|
||||
Canvas& GetCanvas() { return pCanvas; }
|
||||
const Canvas& GetCanvas() const { return pCanvas; }
|
||||
|
||||
private:
|
||||
Canvas pCanvas;
|
||||
PD::Pool<ElementBase*> pElements;
|
||||
PD::Li::Drawlist pList;
|
||||
};
|
||||
} // namespace Ultra
|
||||
} // namespace PD
|
||||
Reference in New Issue
Block a user