Fix The rest of UI7 Mem leaks
Throw OneFrame living objs into a pool
This commit is contained in:
@@ -111,6 +111,25 @@ class PD_API Container {
|
||||
virtual void Draw() {}
|
||||
/** Template function to update internal data (if needed) */
|
||||
virtual void Update() {}
|
||||
/** Template as well as base func for Pool based Containers */
|
||||
virtual void Reset() {
|
||||
pos = 0;
|
||||
size = 0;
|
||||
parent = nullptr;
|
||||
id = 0;
|
||||
pFlags = 0;
|
||||
skippable = false;
|
||||
rem = false;
|
||||
inp_done = false;
|
||||
pSelected = false;
|
||||
pPressed = false;
|
||||
pPressedTwice = false;
|
||||
pCLipRectUsed = false;
|
||||
pClipRect = 0;
|
||||
io = nullptr;
|
||||
list = nullptr;
|
||||
last_use = 0;
|
||||
}
|
||||
|
||||
/** Internal function */
|
||||
void PreDraw();
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace UI7 {
|
||||
*/
|
||||
class PD_API DynObj : public Container {
|
||||
public:
|
||||
DynObj() {}
|
||||
/**
|
||||
* Button Object constructor
|
||||
* @param label Label of the Button
|
||||
@@ -69,6 +70,14 @@ class PD_API DynObj : public Container {
|
||||
/** Function to Update Size if framepadding changes */
|
||||
void Update() override;
|
||||
|
||||
void Reset() override {
|
||||
Container::Reset();
|
||||
color = UI7Color_Button;
|
||||
pressed = false;
|
||||
pRenFun = nullptr;
|
||||
pInp = nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
UI7Color color = UI7Color_Button; ///< current button color
|
||||
bool pressed = false; ///< ispressed value
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace UI7 {
|
||||
*/
|
||||
class PD_API Image : public Container {
|
||||
public:
|
||||
Image() {}
|
||||
/**
|
||||
* Constructor for the Image Object
|
||||
* @param img Image Texture Reference
|
||||
@@ -57,6 +58,13 @@ class PD_API Image : public Container {
|
||||
* */
|
||||
void Draw() override;
|
||||
|
||||
void Reset() override {
|
||||
Container::Reset();
|
||||
img = Li::Texture();
|
||||
newsize = 0.f;
|
||||
cuv = Li::Rect();
|
||||
}
|
||||
|
||||
private:
|
||||
Li::Texture img; ///< Texture
|
||||
fvec2 newsize = 0.f; ///< New Size
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace UI7 {
|
||||
*/
|
||||
class PD_API Label : public Container {
|
||||
public:
|
||||
Label() {}
|
||||
/**
|
||||
* Constructor for Label Object
|
||||
* @param label Label [Text] to Draw
|
||||
@@ -54,6 +55,13 @@ class PD_API Label : public Container {
|
||||
*/
|
||||
void Update() override;
|
||||
|
||||
void Reset() override {
|
||||
Container::Reset();
|
||||
tdim = 0;
|
||||
color = UI7Color_Text;
|
||||
label.clear();
|
||||
}
|
||||
|
||||
private:
|
||||
fvec2 tdim; ///< Text Size
|
||||
UI7Color color = UI7Color_Text; ///< Color
|
||||
|
||||
+10
-7
@@ -31,16 +31,14 @@ SOFTWARE.
|
||||
#include <pd/ui7/viewport.hpp>
|
||||
|
||||
namespace PD {
|
||||
class Context;
|
||||
namespace UI7 {
|
||||
class Label;
|
||||
class Image;
|
||||
class DynObj;
|
||||
class PD_API IO {
|
||||
public:
|
||||
IO() : DeltaStats(60), CurrentViewPort("", 0) {
|
||||
/** Probably not the best solution i guess */
|
||||
// CurrentViewPort =
|
||||
// ViewPort::New("Default", ivec4(ivec2(0, 0), pCtx.Gfx()->ViewPort));
|
||||
}
|
||||
~IO() {}
|
||||
IO();
|
||||
~IO();
|
||||
|
||||
/**
|
||||
* IO Update Internal Variables
|
||||
@@ -84,6 +82,11 @@ class PD_API IO {
|
||||
u32 NumIndices = 0; ///< Debug Indices Num
|
||||
std::vector<u32> MenuOrder;
|
||||
|
||||
// Pools
|
||||
PD::Pool<UI7::Label> LabelPool;
|
||||
PD::Pool<UI7::Image> ImagePool;
|
||||
PD::Pool<UI7::DynObj> DynObjPool;
|
||||
|
||||
// DrawlistApi
|
||||
void RegisterDrawlist(const UI7::ID& id, Li::Drawlist* v) {
|
||||
DrawlistRegestry.push_back(std::make_pair(id, v));
|
||||
|
||||
Reference in New Issue
Block a user