Reimplement list sorting and Fix UI7 Layers
This commit is contained in:
@@ -132,10 +132,24 @@ class CmdPool {
|
||||
size_t idx = pPoolIdx++;
|
||||
*pPool[idx] = *p.GetCmd(i);
|
||||
pPool[idx]->Index = idx;
|
||||
pPool[idx]->Layer += Layer;
|
||||
}
|
||||
}
|
||||
|
||||
void Sort() {
|
||||
std::sort(begin(), end(),
|
||||
[](const Command::Ref& a, const Command::Ref& b) -> bool {
|
||||
if (a->Layer == b->Layer) {
|
||||
return a->Tex < b->Tex;
|
||||
}
|
||||
return a->Layer < b->Layer;
|
||||
});
|
||||
}
|
||||
|
||||
private:
|
||||
friend class DrawList;
|
||||
Command::Ref* begin() { return &pPool[0]; }
|
||||
Command::Ref* end() { return &pPool[pPoolIdx]; }
|
||||
std::vector<Command::Ref> pPool;
|
||||
u32 pPoolIdx = 0;
|
||||
int Layer = 0;
|
||||
|
||||
@@ -83,10 +83,10 @@ class PD_LITHIUM_API DrawList {
|
||||
|
||||
Command::Ref GetNewCmd();
|
||||
void Clear();
|
||||
void Layer(int l) { this->pLayer = l; }
|
||||
int Layer() { return this->pLayer; }
|
||||
void LayerUp() { this->pLayer++; }
|
||||
void LayerDown() { this->pLayer--; }
|
||||
void Layer(int l) { this->pPool.Layer = l; }
|
||||
int Layer() { return this->pPool.Layer; }
|
||||
void LayerUp() { this->pPool.Layer++; }
|
||||
void LayerDown() { this->pPool.Layer--; }
|
||||
|
||||
void SetFont(Font::Ref font) { pCurrentFont = font; }
|
||||
void SetFontScale(float scale) { pFontScale = scale; }
|
||||
@@ -212,7 +212,6 @@ class PD_LITHIUM_API DrawList {
|
||||
/** Data Section */
|
||||
|
||||
std::stack<fvec4> pClipRects;
|
||||
int pLayer;
|
||||
float pFontScale = 0.7f;
|
||||
Font::Ref pCurrentFont;
|
||||
Texture::Ref CurrentTex;
|
||||
|
||||
@@ -107,6 +107,7 @@ class PD_UI7_API Menu {
|
||||
void AddObjectEx(PD::UI7::Container::Ref obj, PD::u32 flags) {
|
||||
pLayout->AddObjectEx(obj, flags);
|
||||
}
|
||||
Container::Ref FindObject(u32 id) { return pLayout->FindObject(id); }
|
||||
|
||||
void Update();
|
||||
|
||||
|
||||
@@ -90,7 +90,6 @@ PD_LITHIUM_API void DrawList::Optimize() {
|
||||
|
||||
PD_LITHIUM_API Command::Ref DrawList::GetNewCmd() {
|
||||
Command::Ref cmd = pPool.NewCmd();
|
||||
cmd->Layer = pLayer;
|
||||
cmd->Index = pPool.Size() - 1;
|
||||
cmd->Tex = CurrentTex;
|
||||
pClipCmd(cmd);
|
||||
|
||||
@@ -51,10 +51,10 @@ PD_UI7_API void Button::Draw() {
|
||||
// io->Ren->OnScreen(screen);
|
||||
list->PathRect(FinalPos(), FinalPos() + size, io->FrameRounding);
|
||||
list->PathFill(io->Theme->Get(color));
|
||||
list->pLayer++;
|
||||
list->LayerUp();
|
||||
list->DrawText(FinalPos() + size * 0.5 - tdim * 0.5, label,
|
||||
io->Theme->Get(UI7Color_Text));
|
||||
list->pLayer--;
|
||||
list->LayerDown();
|
||||
}
|
||||
|
||||
PD_UI7_API void Button::Update() {
|
||||
|
||||
@@ -84,11 +84,11 @@ PD_UI7_API void DragData<T>::Draw() {
|
||||
list->PathRect(FinalPos() + fvec2(off_x, 0),
|
||||
FinalPos() + td + io->FramePadding, io->FrameRounding);
|
||||
list->PathFill(io->Theme->Get(UI7Color_Button));
|
||||
list->pLayer++;
|
||||
list->LayerUp();
|
||||
list->DrawTextEx(FinalPos() + fvec2(off_x, 0), p,
|
||||
io->Theme->Get(UI7Color_Text), LiTextFlags_AlignMid,
|
||||
td + io->FramePadding);
|
||||
list->pLayer--;
|
||||
list->LayerDown();
|
||||
off_x += td.x + io->ItemSpace.x + io->FramePadding.x;
|
||||
}
|
||||
list->DrawText(FinalPos() + fvec2(off_x, io->FramePadding.y * 0.5), label,
|
||||
|
||||
@@ -29,11 +29,11 @@ PD_UI7_API void Image::Draw() {
|
||||
// Assert(io.get() && list.get(), "Did you run Container::Init correctly?");
|
||||
// Assert(img.get(), "Image is nullptr!");
|
||||
// io->Ren->OnScreen(screen);
|
||||
list->pLayer++;
|
||||
list->LayerUp();
|
||||
list->DrawTexture(img);
|
||||
list->DrawRectFilled(FinalPos(), newsize, 0xffffffff);
|
||||
list->DrawSolid();
|
||||
list->pLayer--;
|
||||
list->LayerDown();
|
||||
}
|
||||
} // namespace UI7
|
||||
} // namespace PD
|
||||
@@ -242,7 +242,7 @@ PD_UI7_API void Menu::DrawBaseLayout() {
|
||||
if (!(Flags & UI7MenuFlags_NoResize)) {
|
||||
Container::Ref r = DynObj::New(
|
||||
[](IO::Ref io, Li::DrawList::Ref l, UI7::Container* self) {
|
||||
l->pLayer = 1;
|
||||
l->Layer(1);
|
||||
l->PathAdd(self->FinalPos() + self->GetSize() - fvec2(0, 20));
|
||||
l->PathAdd(self->FinalPos() + self->GetSize());
|
||||
l->PathAdd(self->FinalPos() + self->GetSize() - fvec2(20, 0));
|
||||
@@ -258,7 +258,7 @@ PD_UI7_API void Menu::DrawBaseLayout() {
|
||||
/** Background */
|
||||
Container::Ref r = DynObj::New([](IO::Ref io, Li::DrawList::Ref l,
|
||||
UI7::Container* self) {
|
||||
l->pLayer = 0;
|
||||
l->Layer(0);
|
||||
l->PathRectEx(self->FinalPos(), self->FinalPos() + self->GetSize(), 10.f,
|
||||
LiPathRectFlags_KeepTop | LiPathRectFlags_KeepBot);
|
||||
l->PathFill(io->Theme->Get(UI7Color_Background));
|
||||
@@ -275,11 +275,11 @@ PD_UI7_API void Menu::DrawBaseLayout() {
|
||||
if (!(Flags & UI7MenuFlags_NoTitlebar)) {
|
||||
Container::Ref r = DynObj::New(
|
||||
[=, this](UI7::IO::Ref io, Li::DrawList::Ref l, UI7::Container* self) {
|
||||
l->pLayer = 20;
|
||||
l->Layer(20);
|
||||
/** Header Bar */
|
||||
l->DrawRectFilled(self->FinalPos(), self->GetSize(),
|
||||
io->Theme->Get(UI7Color_Header));
|
||||
l->pLayer = 21;
|
||||
l->Layer(21);
|
||||
/** 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) */
|
||||
l->DrawText(self->FinalPos() + fvec2((Flags & UI7MenuFlags_NoCollapse)
|
||||
@@ -300,7 +300,7 @@ PD_UI7_API void Menu::DrawBaseLayout() {
|
||||
r = DynObj::New([=, this](UI7::IO::Ref io, Li::DrawList::Ref l,
|
||||
UI7::Container* self) {
|
||||
/** This sym actually requires layer 21 (i dont know why) */
|
||||
l->pLayer = 21;
|
||||
l->Layer(21);
|
||||
/**
|
||||
* Symbol (Position Swapping set by pIsOpen ? openpos : closepos;)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user