Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3575a6787d
|
||
|
|
7fc7a2ecb9
|
||
|
|
03f65e069f
|
||
|
|
c618c616fe
|
||
|
|
ac281dc7a9
|
||
|
|
0cb5de882f
|
@@ -30,7 +30,7 @@ namespace PD {
|
|||||||
* Class to calculate Maximum/Minimum and Average Timings
|
* Class to calculate Maximum/Minimum and Average Timings
|
||||||
*/
|
*/
|
||||||
class TimeStats {
|
class TimeStats {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Constructor taking a lengh for the List
|
* Constructor taking a lengh for the List
|
||||||
* @param l Lengh of the data list
|
* @param l Lengh of the data list
|
||||||
@@ -55,8 +55,7 @@ public:
|
|||||||
* @return Average
|
* @return Average
|
||||||
*/
|
*/
|
||||||
u64 GetAverage() {
|
u64 GetAverage() {
|
||||||
if (!num_val)
|
if (!num_val) return 0.f;
|
||||||
return 0.f;
|
|
||||||
u64 res = 0;
|
u64 res = 0;
|
||||||
for (int i = 0; i < num_val; i++) {
|
for (int i = 0; i < num_val; i++) {
|
||||||
res += val[smart_idx(i)];
|
res += val[smart_idx(i)];
|
||||||
@@ -69,8 +68,7 @@ public:
|
|||||||
* @return Minimum value
|
* @return Minimum value
|
||||||
*/
|
*/
|
||||||
u64 GetMin() {
|
u64 GetMin() {
|
||||||
if (!num_val)
|
if (!num_val) return 0.f;
|
||||||
return 0.f;
|
|
||||||
u64 res = std::numeric_limits<u64>::max();
|
u64 res = std::numeric_limits<u64>::max();
|
||||||
for (int i = 0; i < num_val; i++) {
|
for (int i = 0; i < num_val; i++) {
|
||||||
res = std::min(val[smart_idx(i)], res);
|
res = std::min(val[smart_idx(i)], res);
|
||||||
@@ -83,8 +81,7 @@ public:
|
|||||||
* @return Max Value
|
* @return Max Value
|
||||||
*/
|
*/
|
||||||
u64 GetMax() {
|
u64 GetMax() {
|
||||||
if (!num_val)
|
if (!num_val) return 0.f;
|
||||||
return 0.f;
|
|
||||||
u64 res = 0;
|
u64 res = 0;
|
||||||
for (int i = 0; i < num_val; i++) {
|
for (int i = 0; i < num_val; i++) {
|
||||||
res = std::max(val[smart_idx(i)], res);
|
res = std::max(val[smart_idx(i)], res);
|
||||||
@@ -122,7 +119,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
const size_t GetNumValues() { return num_val; }
|
const size_t GetNumValues() { return num_val; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Get the Next Position to write to
|
* Get the Next Position to write to
|
||||||
* @param c current position
|
* @param c current position
|
||||||
@@ -152,7 +149,7 @@ namespace TT {
|
|||||||
* Data Structure for a TimeTrace Result
|
* Data Structure for a TimeTrace Result
|
||||||
*/
|
*/
|
||||||
class Res {
|
class Res {
|
||||||
public:
|
public:
|
||||||
/** Constructore that Inits a protocol at size of 60 frames */
|
/** Constructore that Inits a protocol at size of 60 frames */
|
||||||
Res() : start(0), end(0) { protocol = TimeStats::New(60); }
|
Res() : start(0), end(0) { protocol = TimeStats::New(60); }
|
||||||
~Res() = default;
|
~Res() = default;
|
||||||
@@ -185,6 +182,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
void SetEnd(u64 v) {
|
void SetEnd(u64 v) {
|
||||||
end = v;
|
end = v;
|
||||||
|
diff = end - start;
|
||||||
protocol->Add(GetLastDiff());
|
protocol->Add(GetLastDiff());
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -197,20 +195,22 @@ public:
|
|||||||
* Get Last Diffrence between end and start
|
* Get Last Diffrence between end and start
|
||||||
* @return end - start
|
* @return end - start
|
||||||
*/
|
*/
|
||||||
u64 GetLastDiff() { return end - start; }
|
u64 GetLastDiff() { return diff; }
|
||||||
/**
|
/**
|
||||||
* Get Protcol Reference
|
* Get Protcol Reference
|
||||||
* @return Protocol Ref
|
* @return Protocol Ref
|
||||||
*/
|
*/
|
||||||
TimeStats::Ref GetProtocol() { return protocol; }
|
TimeStats::Ref GetProtocol() { return protocol; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** Trace ID */
|
/** Trace ID */
|
||||||
std::string id;
|
std::string id;
|
||||||
/** Start time */
|
/** Start time */
|
||||||
u64 start;
|
u64 start;
|
||||||
/** End Time */
|
/** End Time */
|
||||||
u64 end;
|
u64 end;
|
||||||
|
/** Last Diff */
|
||||||
|
u64 diff;
|
||||||
/** Protocol */
|
/** Protocol */
|
||||||
TimeStats::Ref protocol;
|
TimeStats::Ref protocol;
|
||||||
};
|
};
|
||||||
@@ -240,7 +240,7 @@ PD_CORE_API void End(const std::string &id);
|
|||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
class Scope {
|
class Scope {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Constructor requiring a Name for the Trace
|
* Constructor requiring a Name for the Trace
|
||||||
* @param id Name of the Trace
|
* @param id Name of the Trace
|
||||||
@@ -254,9 +254,9 @@ public:
|
|||||||
*/
|
*/
|
||||||
~Scope() { End(ID); }
|
~Scope() { End(ID); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** Trace Name/ID */
|
/** Trace Name/ID */
|
||||||
std::string ID;
|
std::string ID;
|
||||||
};
|
};
|
||||||
} // namespace TT
|
} // namespace TT
|
||||||
} // namespace PD
|
} // namespace PD
|
||||||
@@ -94,6 +94,7 @@ class Gfx {
|
|||||||
|
|
||||||
static void BindTex(Li::TexAddress addr) { pGfx->BindTex(addr); }
|
static void BindTex(Li::TexAddress addr) { pGfx->BindTex(addr); }
|
||||||
static void SetViewPort(const ivec2& vp) { pGfx->SetViewPort(vp); }
|
static void SetViewPort(const ivec2& vp) { pGfx->SetViewPort(vp); }
|
||||||
|
static void SetViewPort(int w, int h) { pGfx->SetViewPort(PD::ivec2(w, h)); }
|
||||||
|
|
||||||
static void RenderDrawData(const std::vector<Li::Command::Ref>& Commands) {
|
static void RenderDrawData(const std::vector<Li::Command::Ref>& Commands) {
|
||||||
pGfx->RenderDrawData(Commands);
|
pGfx->RenderDrawData(Commands);
|
||||||
|
|||||||
@@ -40,6 +40,12 @@ class Command {
|
|||||||
IndexBuffer.push_back(VertexBuffer.size() + idx);
|
IndexBuffer.push_back(VertexBuffer.size() + idx);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
Command& AddIdxs(const u16& a, const u16& b, const u16& c) {
|
||||||
|
IndexBuffer.push_back(VertexBuffer.size() + a);
|
||||||
|
IndexBuffer.push_back(VertexBuffer.size() + b);
|
||||||
|
IndexBuffer.push_back(VertexBuffer.size() + c);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
Command& AddVtx(const Vertex& v) {
|
Command& AddVtx(const Vertex& v) {
|
||||||
VertexBuffer.push_back(std::move(v));
|
VertexBuffer.push_back(std::move(v));
|
||||||
|
|||||||
@@ -68,6 +68,12 @@ class PD_LITHIUM_API DrawList {
|
|||||||
* @param list DrawList to move into current
|
* @param list DrawList to move into current
|
||||||
*/
|
*/
|
||||||
void Merge(DrawList::Ref list);
|
void Merge(DrawList::Ref list);
|
||||||
|
/**
|
||||||
|
* Copy another drawlist to this drawist.
|
||||||
|
* This is important for static prerendered Drawlists
|
||||||
|
* @param list DrawList Reference to copy from
|
||||||
|
*/
|
||||||
|
void Copy(DrawList::Ref list);
|
||||||
/**
|
/**
|
||||||
* Optimize a Drawlist to a more or less perfect order
|
* Optimize a Drawlist to a more or less perfect order
|
||||||
* to reduce drawcall overhead... This function also uses
|
* to reduce drawcall overhead... This function also uses
|
||||||
@@ -80,6 +86,8 @@ class PD_LITHIUM_API DrawList {
|
|||||||
void Clear();
|
void Clear();
|
||||||
void Layer(int l) { this->pLayer = l; }
|
void Layer(int l) { this->pLayer = l; }
|
||||||
int Layer() { return this->pLayer; }
|
int Layer() { return this->pLayer; }
|
||||||
|
void LayerUp() { this->pLayer++; }
|
||||||
|
void LayerDown() { this->pLayer--; }
|
||||||
|
|
||||||
void SetFont(Font::Ref font) { pCurrentFont = font; }
|
void SetFont(Font::Ref font) { pCurrentFont = font; }
|
||||||
void SetFontScale(float scale) { pFontScale = scale; }
|
void SetFontScale(float scale) { pFontScale = scale; }
|
||||||
@@ -198,6 +206,7 @@ class PD_LITHIUM_API DrawList {
|
|||||||
}
|
}
|
||||||
pClipRects.pop();
|
pClipRects.pop();
|
||||||
}
|
}
|
||||||
|
const std::vector<Command::Ref>& Data() const { return pDrawList; }
|
||||||
/** One linear Clip rect Setup */
|
/** One linear Clip rect Setup */
|
||||||
void pClipCmd(Command* cmd);
|
void pClipCmd(Command* cmd);
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ enum LiTextFlags_ {
|
|||||||
LiTextFlags_Wrap = 1 << 3, ///< Wrap Text: May be runs better with TMS
|
LiTextFlags_Wrap = 1 << 3, ///< Wrap Text: May be runs better with TMS
|
||||||
LiTextFlags_Short = 1 << 4, ///< Short Text: May be runs better with TMS
|
LiTextFlags_Short = 1 << 4, ///< Short Text: May be runs better with TMS
|
||||||
LiTextFlags_Scroll = 1 << 5, ///< Not implemented [scoll text if to long]
|
LiTextFlags_Scroll = 1 << 5, ///< Not implemented [scoll text if to long]
|
||||||
|
LiTextFlags_NoOOS = 1 << 6, ///< No Out of Screen Rendering
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
@@ -95,6 +96,11 @@ class PD_LITHIUM_API Font {
|
|||||||
void CmdTextEx(std::vector<Command::Ref>& cmds, const fvec2& pos, u32 color,
|
void CmdTextEx(std::vector<Command::Ref>& cmds, const fvec2& pos, u32 color,
|
||||||
float scale, const std::string& text, LiTextFlags flags = 0,
|
float scale, const std::string& text, LiTextFlags flags = 0,
|
||||||
const fvec2& box = 0);
|
const fvec2& box = 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Garbage collection for TextMapSystem
|
||||||
|
*/
|
||||||
|
void CleanupTMS();
|
||||||
/**
|
/**
|
||||||
* Utility function to create a font atlas
|
* Utility function to create a font atlas
|
||||||
* During TTF loading (Internal and should not be called)
|
* During TTF loading (Internal and should not be called)
|
||||||
@@ -104,7 +110,7 @@ class PD_LITHIUM_API Font {
|
|||||||
std::string pWrapText(const std::string& txt, float scale,
|
std::string pWrapText(const std::string& txt, float scale,
|
||||||
const PD::fvec2& max, PD::fvec2& dim);
|
const PD::fvec2& max, PD::fvec2& dim);
|
||||||
std::string pShortText(const std::string& txt, float scale,
|
std::string pShortText(const std::string& txt, float scale,
|
||||||
const PD::fvec2& max, PD::fvec2& dim);
|
const PD::fvec2& max, PD::fvec2& dim);
|
||||||
|
|
||||||
/** Data Section */
|
/** Data Section */
|
||||||
int PixelHeight;
|
int PixelHeight;
|
||||||
@@ -115,6 +121,14 @@ class PD_LITHIUM_API Font {
|
|||||||
* **Now using unordered map**
|
* **Now using unordered map**
|
||||||
*/
|
*/
|
||||||
std::unordered_map<u32, Codepoint> CodeMap;
|
std::unordered_map<u32, Codepoint> CodeMap;
|
||||||
|
/** TMS */
|
||||||
|
struct TMELEM {
|
||||||
|
PD::u32 ID;
|
||||||
|
PD::fvec2 Size;
|
||||||
|
std::string Text;
|
||||||
|
u64 TimeStamp;
|
||||||
|
};
|
||||||
|
std::unordered_map<u32, TMELEM> pTMS;
|
||||||
};
|
};
|
||||||
} // namespace Li
|
} // namespace Li
|
||||||
} // namespace PD
|
} // namespace PD
|
||||||
@@ -51,6 +51,10 @@ class PD_UI7_API Label : public Container {
|
|||||||
* @note This function is usally called by Menu::Update
|
* @note This function is usally called by Menu::Update
|
||||||
* */
|
* */
|
||||||
void Draw() override;
|
void Draw() override;
|
||||||
|
/**
|
||||||
|
* Override Update func to support Text modifications
|
||||||
|
*/
|
||||||
|
void Update() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
fvec2 tdim; ///< Text Size
|
fvec2 tdim; ///< Text Size
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ class PD_UI7_API IO {
|
|||||||
fvec2 MinSliderDragSize = 10.f; // Min height (Vt) and Min Width (Hz)
|
fvec2 MinSliderDragSize = 10.f; // Min height (Vt) and Min Width (Hz)
|
||||||
bool ShowMenuBorder = true;
|
bool ShowMenuBorder = true;
|
||||||
bool ShowFrameBorder = false; // not implemented yet
|
bool ShowFrameBorder = false; // not implemented yet
|
||||||
|
bool WrapLabels = false; // Beta state
|
||||||
float OverScrollMod = 0.15f;
|
float OverScrollMod = 0.15f;
|
||||||
u64 DoubleClickTime = 500; // Milliseconds
|
u64 DoubleClickTime = 500; // Milliseconds
|
||||||
std::list<std::pair<UI7::ID, Li::DrawList::Ref>> DrawListRegestry;
|
std::list<std::pair<UI7::ID, Li::DrawList::Ref>> DrawListRegestry;
|
||||||
|
|||||||
@@ -103,6 +103,8 @@ class PD_UI7_API Layout {
|
|||||||
|
|
||||||
void Update();
|
void Update();
|
||||||
|
|
||||||
|
fvec2 DbgScrollOffset() { return ScrollOffset; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class Menu;
|
friend class Menu;
|
||||||
friend class Context;
|
friend class Context;
|
||||||
|
|||||||
@@ -103,6 +103,11 @@ class PD_UI7_API Menu {
|
|||||||
void HandleTitlebarActions();
|
void HandleTitlebarActions();
|
||||||
void DrawBaseLayout();
|
void DrawBaseLayout();
|
||||||
|
|
||||||
|
void AddObject(PD::UI7::Container::Ref obj) { pLayout->AddObject(obj); }
|
||||||
|
void AddObjectEx(PD::UI7::Container::Ref obj, PD::u32 flags) {
|
||||||
|
pLayout->AddObjectEx(obj, flags);
|
||||||
|
}
|
||||||
|
|
||||||
void Update();
|
void Update();
|
||||||
|
|
||||||
/** Data Section */
|
/** Data Section */
|
||||||
|
|||||||
@@ -55,10 +55,12 @@ class PD_UI7_API Context {
|
|||||||
|
|
||||||
PD_SHARED(Context);
|
PD_SHARED(Context);
|
||||||
|
|
||||||
|
IO::Ref GetIO() { return pIO; }
|
||||||
void AddViewPort(const ID& id, const ivec4& vp);
|
void AddViewPort(const ID& id, const ivec4& vp);
|
||||||
void UseViewPort(const ID& id);
|
void UseViewPort(const ID& id);
|
||||||
void Update();
|
void Update();
|
||||||
bool BeginMenu(const ID& id, UI7MenuFlags flags = 0, bool* pShow = nullptr);
|
bool BeginMenu(const ID& id, UI7MenuFlags flags = 0, bool* pShow = nullptr);
|
||||||
|
Menu::Ref CurrentMenu() { return pCurrent; }
|
||||||
void EndMenu();
|
void EndMenu();
|
||||||
void AboutMenu(bool* show = nullptr);
|
void AboutMenu(bool* show = nullptr);
|
||||||
void MetricsMenu(bool* show = nullptr);
|
void MetricsMenu(bool* show = nullptr);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
cmake_minimum_required(VERSION 3.22)
|
cmake_minimum_required(VERSION 3.22)
|
||||||
|
|
||||||
## The Core Core Library
|
## The Core Core Library
|
||||||
project(pd-drivers LANGUAGES CXX VERSION 0.5.1)
|
project(pd-drivers LANGUAGES CXX VERSION 0.6.0)
|
||||||
|
|
||||||
set(SRC
|
set(SRC
|
||||||
source/hid.cpp
|
source/hid.cpp
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ PD_LITHIUM_API void DrawList::Clear() {
|
|||||||
pNumVertices = 0;
|
pNumVertices = 0;
|
||||||
pDrawList.clear();
|
pDrawList.clear();
|
||||||
pPath.clear();
|
pPath.clear();
|
||||||
|
if (pCurrentFont) {
|
||||||
|
pCurrentFont->CleanupTMS();
|
||||||
|
}
|
||||||
while (!pClipRects.empty()) {
|
while (!pClipRects.empty()) {
|
||||||
pClipRects.pop();
|
pClipRects.pop();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -196,6 +196,11 @@ PD_LITHIUM_API Font::Codepoint &Font::GetCodepoint(u32 cp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PD_LITHIUM_API fvec2 Font::GetTextBounds(const std::string &text, float scale) {
|
PD_LITHIUM_API fvec2 Font::GetTextBounds(const std::string &text, float scale) {
|
||||||
|
u32 id = PD::FNV1A32(text);
|
||||||
|
if (pTMS.find(id) != pTMS.end()) {
|
||||||
|
pTMS[id].TimeStamp = PD::OS::GetTime();
|
||||||
|
return pTMS[id].Size;
|
||||||
|
}
|
||||||
// Use wstring for exemple for german äöü
|
// Use wstring for exemple for german äöü
|
||||||
auto wtext = Strings::MakeWstring(text);
|
auto wtext = Strings::MakeWstring(text);
|
||||||
// Create a temp position and offset as [0, 0]
|
// Create a temp position and offset as [0, 0]
|
||||||
@@ -237,6 +242,9 @@ PD_LITHIUM_API fvec2 Font::GetTextBounds(const std::string &text, float scale) {
|
|||||||
}
|
}
|
||||||
res.x = std::max(res.x, x);
|
res.x = std::max(res.x, x);
|
||||||
res.y += lh;
|
res.y += lh;
|
||||||
|
pTMS[id].ID = id;
|
||||||
|
pTMS[id].Size = res;
|
||||||
|
pTMS[id].TimeStamp = PD::OS::GetTime();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,6 +280,15 @@ PD_LITHIUM_API void Font::CmdTextEx(std::vector<Command::Ref> &cmds,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (auto &it : lines) {
|
for (auto &it : lines) {
|
||||||
|
if (flags & LiTextFlags_NoOOS) {
|
||||||
|
if (rpos.y + off.y + lh < 0) {
|
||||||
|
off.y += lh;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (rpos.y + off.y > box.y && box.y != 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (flags & LiTextFlags_Short) {
|
if (flags & LiTextFlags_Short) {
|
||||||
fvec2 tmp_dim;
|
fvec2 tmp_dim;
|
||||||
it = pShortText(it, scale, box - pos, tmp_dim);
|
it = pShortText(it, scale, box - pos, tmp_dim);
|
||||||
@@ -322,6 +339,14 @@ PD_LITHIUM_API void Font::CmdTextEx(std::vector<Command::Ref> &cmds,
|
|||||||
PD_LITHIUM_API std::string Font::pWrapText(const std::string &txt, float scale,
|
PD_LITHIUM_API std::string Font::pWrapText(const std::string &txt, float scale,
|
||||||
const PD::fvec2 &max,
|
const PD::fvec2 &max,
|
||||||
PD::fvec2 &dim) {
|
PD::fvec2 &dim) {
|
||||||
|
u32 id = PD::FNV1A32(txt);
|
||||||
|
if (pTMS.find(id) != pTMS.end()) {
|
||||||
|
if (pTMS[id].Text.size()) {
|
||||||
|
dim = pTMS[id].Size;
|
||||||
|
pTMS[id].TimeStamp = PD::OS::GetTime();
|
||||||
|
return pTMS[id].Text;
|
||||||
|
}
|
||||||
|
}
|
||||||
std::string ret;
|
std::string ret;
|
||||||
std::string line;
|
std::string line;
|
||||||
int lx = 0;
|
int lx = 0;
|
||||||
@@ -341,12 +366,24 @@ PD_LITHIUM_API std::string Font::pWrapText(const std::string &txt, float scale,
|
|||||||
}
|
}
|
||||||
ret += line;
|
ret += line;
|
||||||
dim = GetTextBounds(ret, scale);
|
dim = GetTextBounds(ret, scale);
|
||||||
|
pTMS[id].ID = id;
|
||||||
|
pTMS[id].Size = dim;
|
||||||
|
pTMS[id].Text = ret;
|
||||||
|
pTMS[id].TimeStamp = PD::OS::GetTime();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_LITHIUM_API std::string Font::pShortText(const std::string &txt, float scale,
|
PD_LITHIUM_API std::string Font::pShortText(const std::string &txt, float scale,
|
||||||
const PD::fvec2 &max,
|
const PD::fvec2 &max,
|
||||||
PD::fvec2 &dim) {
|
PD::fvec2 &dim) {
|
||||||
|
u32 id = PD::FNV1A32(txt);
|
||||||
|
if (pTMS.find(id) != pTMS.end()) {
|
||||||
|
if (pTMS[id].Text.size()) {
|
||||||
|
dim = pTMS[id].Size;
|
||||||
|
pTMS[id].TimeStamp = PD::OS::GetTime();
|
||||||
|
return pTMS[id].Text;
|
||||||
|
}
|
||||||
|
}
|
||||||
auto test = GetTextBounds(txt, scale);
|
auto test = GetTextBounds(txt, scale);
|
||||||
if (test.x < max.x) {
|
if (test.x < max.x) {
|
||||||
return txt;
|
return txt;
|
||||||
@@ -373,8 +410,23 @@ PD_LITHIUM_API std::string Font::pShortText(const std::string &txt, float scale,
|
|||||||
}
|
}
|
||||||
ret += it;
|
ret += it;
|
||||||
}
|
}
|
||||||
|
pTMS[id].ID = id;
|
||||||
|
pTMS[id].Size = dim;
|
||||||
|
pTMS[id].Text = ret;
|
||||||
|
pTMS[id].TimeStamp = PD::OS::GetTime();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PD_LITHIUM_API void Font::CleanupTMS() {
|
||||||
|
u64 t = PD::OS::GetTime();
|
||||||
|
for (auto it = pTMS.begin(); it != pTMS.end();) {
|
||||||
|
if (t - it->second.TimeStamp > 1000) {
|
||||||
|
it = pTMS.erase(it);
|
||||||
|
} else {
|
||||||
|
it++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Li
|
} // namespace Li
|
||||||
} // namespace PD
|
} // namespace PD
|
||||||
@@ -31,10 +31,27 @@ PD_UI7_API void Label::Draw() {
|
|||||||
if (pCLipRectUsed) {
|
if (pCLipRectUsed) {
|
||||||
list->PushClipRect(pClipRect);
|
list->PushClipRect(pClipRect);
|
||||||
}
|
}
|
||||||
list->DrawText(FinalPos(), label, io->Theme->Get(UI7Color_Text));
|
list->DrawTextEx(FinalPos(), label, io->Theme->Get(UI7Color_Text),
|
||||||
|
LiTextFlags_NoOOS, PD::fvec2(0, io->CurrentViewPort.w));
|
||||||
if (pCLipRectUsed) {
|
if (pCLipRectUsed) {
|
||||||
list->PopClipRect();
|
list->PopClipRect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PD_UI7_API void Label::Update() {
|
||||||
|
/**
|
||||||
|
* Todo: This is a hacky workaround
|
||||||
|
* Needs proper optimisation
|
||||||
|
* Needs a max size (to support sligning dynaically by the window size)
|
||||||
|
*/
|
||||||
|
if (io->WrapLabels) {
|
||||||
|
this->label =
|
||||||
|
io->Font->pWrapText(this->label, io->FontScale,
|
||||||
|
PD::fvec2(io->CurrentViewPort.z - FinalPos().x * 4,
|
||||||
|
io->CurrentViewPort.w),
|
||||||
|
this->tdim);
|
||||||
|
SetSize(tdim);
|
||||||
|
}
|
||||||
|
}
|
||||||
} // namespace UI7
|
} // namespace UI7
|
||||||
} // namespace PD
|
} // namespace PD
|
||||||
@@ -124,15 +124,15 @@ PD_UI7_API void Layout::Update() {
|
|||||||
it->Draw();
|
it->Draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::vector<size_t> tbr;
|
|
||||||
for (size_t i = 0; i < IDObjects.size(); i++) {
|
for (auto it = IDObjects.begin(); it != IDObjects.end();) {
|
||||||
if (IDObjects[i]->Removable()) {
|
if ((*it)->Removable()) {
|
||||||
tbr.push_back(i);
|
it = IDObjects.erase(it);
|
||||||
|
} else {
|
||||||
|
it++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (auto& it : tbr) {
|
|
||||||
IDObjects.erase(IDObjects.begin() + it);
|
|
||||||
}
|
|
||||||
Objects.clear();
|
Objects.clear();
|
||||||
WorkRect = fvec4(fvec2(WorkRect.x, WorkRect.y), Size - IO->MenuPadding);
|
WorkRect = fvec4(fvec2(WorkRect.x, WorkRect.y), Size - IO->MenuPadding);
|
||||||
CursorInit();
|
CursorInit();
|
||||||
|
|||||||
+12
-9
@@ -81,7 +81,9 @@ PD_UI7_API void Menu::Separator() {
|
|||||||
pIO->Theme->Get(UI7Color_TextDead));
|
pIO->Theme->Get(UI7Color_TextDead));
|
||||||
});
|
});
|
||||||
// Set size before pushing (cause Cursor Move will require it)
|
// Set size before pushing (cause Cursor Move will require it)
|
||||||
r->SetSize(fvec2(pLayout->Size.x - 10, 1));
|
r->SetSize(fvec2(
|
||||||
|
pLayout->Size.x - pIO->MenuPadding.x * 2 - pLayout->InitialCursorOffset.x,
|
||||||
|
1));
|
||||||
pLayout->AddObject(r);
|
pLayout->AddObject(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,8 +111,9 @@ PD_UI7_API void Menu::SeparatorText(const std::string& label) {
|
|||||||
fvec2(pLayout->Size.x, self->GetSize().y));
|
fvec2(pLayout->Size.x, self->GetSize().y));
|
||||||
});
|
});
|
||||||
// Set size before pushing (cause Cursor Move will require it)
|
// Set size before pushing (cause Cursor Move will require it)
|
||||||
r->SetSize(
|
r->SetSize(fvec2(
|
||||||
fvec2(pLayout->Size.x - 10, pIO->Font->PixelHeight * pIO->FontScale));
|
pLayout->Size.x - pIO->MenuPadding.x * 2 - pLayout->InitialCursorOffset.x,
|
||||||
|
pIO->Font->PixelHeight * pIO->FontScale));
|
||||||
pLayout->AddObject(r);
|
pLayout->AddObject(r);
|
||||||
}
|
}
|
||||||
PD_UI7_API void Menu::HandleFocus() {
|
PD_UI7_API void Menu::HandleFocus() {
|
||||||
@@ -148,7 +151,7 @@ PD_UI7_API void Menu::HandleScrolling() {
|
|||||||
pLayout->ScrollOffset.y = std::clamp(
|
pLayout->ScrollOffset.y = std::clamp(
|
||||||
pLayout->ScrollStart.y + pIO->InputHandler->DragSourcePos.y -
|
pLayout->ScrollStart.y + pIO->InputHandler->DragSourcePos.y -
|
||||||
pIO->InputHandler->DragPosition.y,
|
pIO->InputHandler->DragPosition.y,
|
||||||
20.f, pLayout->MaxPosition.y - 220);
|
-20.f, pLayout->MaxPosition.y - 220);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -279,12 +282,12 @@ PD_UI7_API void Menu::DrawBaseLayout() {
|
|||||||
l->pLayer = 21;
|
l->pLayer = 21;
|
||||||
/** Inline if statement to shift the Text if collapse sym is shown */
|
/** Inline if statement to shift the Text if collapse sym is shown */
|
||||||
/** What the hell is this code btw (didn't found a better way) */
|
/** What the hell is this code btw (didn't found a better way) */
|
||||||
l->DrawText(self->FinalPos() + fvec2(Flags & UI7MenuFlags_NoClose
|
l->DrawText(self->FinalPos() + fvec2((Flags & UI7MenuFlags_NoCollapse)
|
||||||
? 0
|
? pIO->FramePadding.x
|
||||||
: (TitleBarHeight -
|
: (TitleBarHeight -
|
||||||
pIO->FramePadding.y * 2 +
|
pIO->FramePadding.y * 2 +
|
||||||
(io->FramePadding.x * 2)),
|
(io->FramePadding.x * 2)),
|
||||||
0),
|
2),
|
||||||
pID.GetName(), io->Theme->Get(UI7Color_Text));
|
pID.GetName(), io->Theme->Get(UI7Color_Text));
|
||||||
});
|
});
|
||||||
r->SetSize(fvec2(pLayout->GetSize().x, TitleBarHeight));
|
r->SetSize(fvec2(pLayout->GetSize().x, TitleBarHeight));
|
||||||
@@ -344,11 +347,11 @@ PD_UI7_API void Menu::Update() {
|
|||||||
TitleBarHeight = 0.f;
|
TitleBarHeight = 0.f;
|
||||||
pLayout->WorkRect.y = 5.f;
|
pLayout->WorkRect.y = 5.f;
|
||||||
}
|
}
|
||||||
|
DrawBaseLayout();
|
||||||
|
pLayout->Update();
|
||||||
if (Flags & UI7MenuFlags_VtScrolling || Flags & UI7MenuFlags_HzScrolling) {
|
if (Flags & UI7MenuFlags_VtScrolling || Flags & UI7MenuFlags_HzScrolling) {
|
||||||
HandleScrolling();
|
HandleScrolling();
|
||||||
}
|
}
|
||||||
DrawBaseLayout();
|
|
||||||
pLayout->Update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_UI7_API bool Menu::BeginTreeNode(const ID& id) {
|
PD_UI7_API bool Menu::BeginTreeNode(const ID& id) {
|
||||||
|
|||||||
Reference in New Issue
Block a user