Files
palladium/include/pd/ultra/container.hpp
tobid7 a776addf11 Implement VCanvas and Update TextElem
- Text now requires a font and is able to take an individual scale
- Container requires &ref for Elements to make sure they always exist
- SetViewport now sets the canvas as well
- SetBaseViewport Sets the Virtual Canvas Size
- Layout Now requires a Drawlist reference in Render function
- main.cpp: updated the template
2026-04-03 12:43:49 +02:00

45 lines
1.3 KiB
C++

#pragma once
#include <pd/lithium/lithium.hpp>
#include <pd/ultra/canvas.hpp>
#include <pd/ultra/elems/element.hpp>
namespace PD {
namespace Ultra {
class Container {
public:
Container() {}
Container(const PD::Li::Rect& r) : pRect(r) {}
virtual ~Container() {}
void Push(PD::Ultra::ElementBase& elem) {
elem.SetParent(this);
pElems.Push(&elem);
}
void Reset() { pElems.ResetFast(); }
const PD::Li::Rect& GetRenderspace() const { return pRect; }
void SetViewport(const PD::fvec2& vp) {
pCanvas.SetViewport(vp);
pRect = PD::fvec4(PD::fvec2(0), vp);
}
void SetBaseViewport(const PD::ivec2& vp) { pCanvas.SetVirtualViewport(vp); }
const PD::fvec2 GetTopLeft() const { return pRect.TopLeft(); }
const PD::fvec2 GetTopRight() const { return pRect.TopRight(); }
const PD::fvec2 GetBotLeft() const { return pRect.BotLeft(); }
const PD::fvec2 GetBotRight() const { return pRect.BotRight(); }
const PD::fvec2 GetSize() const { return pRect.BotRight() - pRect.TopLeft(); }
const PD::fvec2 GetPosition() const { return pRect.TopLeft(); }
const Canvas& GetCanvas() const { return pCanvas; }
protected:
PD::Pool<PD::Ultra::ElementBase*>& GetElements() { return pElems; }
private:
PD::Li::Rect pRect;
Canvas pCanvas;
PD::Pool<PD::Ultra::ElementBase*> pElems;
};
} // namespace Ultra
} // namespace PD