More stuff done at Project Ultra
- Added renderspace - Revision System (to not always update pRenderspace - added some test scene
This commit is contained in:
@@ -2,19 +2,7 @@
|
||||
|
||||
#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,
|
||||
};
|
||||
#include <pd/ultra/flags.hpp>
|
||||
|
||||
namespace PD {
|
||||
namespace Ultra {
|
||||
@@ -31,18 +19,24 @@ class PD_API Canvas {
|
||||
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;
|
||||
UltraAlignment align,
|
||||
bool size_modified = false) const;
|
||||
PD::Li::Rect TranslateObject(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;
|
||||
const PD::u32& GetRevision() const;
|
||||
|
||||
private:
|
||||
PD::fvec2 pViewport;
|
||||
PD::fvec2 pVirtualViewPort;
|
||||
float pVfactor = 0.f;
|
||||
PD::fvec2 pVoff;
|
||||
PD::u32 pRev; // revision
|
||||
};
|
||||
} // namespace Ultra
|
||||
} // namespace PD
|
||||
@@ -1,10 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <pd/lithium/lithium.hpp>
|
||||
#include <pd/ultra/flags.hpp>
|
||||
|
||||
namespace PD {
|
||||
namespace Ultra {
|
||||
class ElementBase {
|
||||
class Canvas;
|
||||
class PD_API ElementBase {
|
||||
public:
|
||||
ElementBase() {}
|
||||
~ElementBase() {}
|
||||
@@ -14,8 +16,22 @@ class ElementBase {
|
||||
* Reset Function (for PD::Pool::FastReset)
|
||||
*/
|
||||
virtual void Reset() {}
|
||||
void Update(Canvas& c);
|
||||
|
||||
private:
|
||||
void SetAlignment(UltraAlignment a) { pAlignment = a; }
|
||||
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); }
|
||||
|
||||
protected:
|
||||
bool RevisionUpdate(PD::u32 req);
|
||||
PD::u32 pCanvasRev = 0;
|
||||
PD::Li::Rect pRenderspace;
|
||||
UltraAlignment pAlignment = 0;
|
||||
PD::fvec2 pPos;
|
||||
PD::fvec2 pSize;
|
||||
ElementBase* pParent = nullptr;
|
||||
};
|
||||
} // namespace Ultra
|
||||
} // namespace PD
|
||||
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
#include <pd/core/core.hpp>
|
||||
#include <pd/ultra/elems/element.hpp>
|
||||
|
||||
namespace PD {
|
||||
namespace Ultra {
|
||||
class PD_API Image : public ElementBase {
|
||||
public:
|
||||
Image() {}
|
||||
Image(PD::Li::Texture* tex, const PD::fvec2& pos, float rounding = 0.f,
|
||||
UltraAlignment align = 0)
|
||||
: pColor(0xffffffff), pRounding(rounding) {
|
||||
this->pAlignment = align;
|
||||
this->pPos = pos;
|
||||
SetTexture(tex);
|
||||
}
|
||||
Image(PD::Li::Texture* tex, float x, float y, float rounding = 0.f,
|
||||
UltraAlignment align = 0)
|
||||
: pColor(0xffffffff), pRounding(rounding) {
|
||||
this->pAlignment = align;
|
||||
this->pPos = PD::fvec2(x, y);
|
||||
SetTexture(tex);
|
||||
}
|
||||
~Image() {}
|
||||
|
||||
void Draw(PD::Li::Drawlist& l) override;
|
||||
|
||||
void SetColor(const PD::Color& color) { pColor = color; }
|
||||
void SetRounding(float r) { pRounding = r; }
|
||||
void SetTexture(PD::Li::Texture* tex) {
|
||||
pTex = tex;
|
||||
SetSize(pTex->GetSize());
|
||||
}
|
||||
|
||||
private:
|
||||
PD::Color pColor = 0xffffffff;
|
||||
PD::Li::Texture* pTex = nullptr;
|
||||
float pRounding = 0.f;
|
||||
};
|
||||
} // namespace Ultra
|
||||
|
||||
} // namespace PD
|
||||
@@ -8,20 +8,28 @@ namespace Ultra {
|
||||
class PD_API Rect : public ElementBase {
|
||||
public:
|
||||
Rect() {}
|
||||
Rect(const PD::fvec2& pos, const PD::fvec2& size, const PD::Color& color,
|
||||
float rounding = 0.f, UltraAlignment align = 0)
|
||||
: pColor(color), pRounding(rounding) {
|
||||
this->pAlignment = align;
|
||||
this->pPos = pos;
|
||||
this->pSize = size;
|
||||
}
|
||||
Rect(float x, float y, float w, float h, const PD::Color& color,
|
||||
float rounding = 0.f, UltraAlignment align = 0)
|
||||
: pColor(color), pRounding(rounding) {
|
||||
this->pAlignment = align;
|
||||
this->pPos = PD::fvec2(x, y);
|
||||
this->pSize = PD::fvec2(w, h);
|
||||
}
|
||||
~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;
|
||||
};
|
||||
|
||||
@@ -12,13 +12,10 @@ class PD_API Text : public ElementBase {
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <pd/common.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_CenterVertical = 1 << 4,
|
||||
UltraAlignment_CenterHorizontal = 1 << 5,
|
||||
UltraAlignment_TopLeft = UltraAlignment_Top | UltraAlignment_Left,
|
||||
UltraAlignment_TopRight = UltraAlignment_Top | UltraAlignment_Right,
|
||||
UltraAlignment_BotLeft = UltraAlignment_Bot | UltraAlignment_Left,
|
||||
UltraAlignment_BotRight = UltraAlignment_Bot | UltraAlignment_Right,
|
||||
};
|
||||
Reference in New Issue
Block a user