# Changes 0.2.8

- Fix Flickering problem in StaticText api
- Fix Lagacy and Container HandleScrolling InBox checks
- Add IO Flags define for future
- Implement Single Object Dragging API by IO Context
- Add TreeNodes
- Use ioMenuPadding and ItemSpace
- Add StyleEditorMenu
- Rework ContainerApi to take functions from IO and add an Update function template for Updating internal values if required
- Use new DragApi for MenuCollabse, MenuDragging, MenuResize, SliderDragging and TreeNodes Open/Close
- Add Helper Defines for Metrics Menu [INTERNAL]
- Add TimeTrace as Tree to Metrics as well as other new Data
- Add GetRawObject to StaticText for custom rendering like ui7
- Add DrawlistRegestry to correctly render Menus in their own layer ranges
This commit is contained in:
2025-03-08 13:52:11 +01:00
parent e282d0ec7e
commit 09b1937a8d
22 changed files with 536 additions and 266 deletions

View File

@@ -24,6 +24,18 @@ SOFTWARE.
#include <pd/core/timetrace.hpp>
#include <pd/ui7/ui7.hpp>
// Helpers
#define UI7DV4(x) \
std::format("{}: [{:.2f}, {:.2f}, {:.2f}, {:.2f}]", #x, x[0], x[1], x[2], \
x[3])
#define UI7DV4N(x) \
std::format("[{:.2f}, {:.2f}, {:.2f}, {:.2f}]", x[0], x[1], x[2], x[3])
#define UI7DV2(x) std::format("{}: [{:.2f}, {:.2f}]", #x, x[0], x[1])
#define UI7DV2N(x) std::format("[{:.2f}, {:.2f}]", x[0], x[1])
#define UI7DHX32(x) std::format("{}: {:#08x}", #x, x)
#define UI7DTF(x) PD::Strings::FormatNanos(x)
namespace PD {
std::string UI7::GetVersion(bool show_build) {
std::stringstream s;
@@ -39,22 +51,22 @@ bool UI7::Context::BeginMenu(const ID& id, UI7MenuFlags flags) {
"Menu Name Already used or\nContext::Update not called!");
auto menu = this->menus.find(id);
if (menu == this->menus.end()) {
this->menus[id] = Menu::New(id, theme, inp);
this->menus[id]->ViewArea(this->ren->GetViewport());
this->menus[id] = Menu::New(id, io);
this->menus[id]->ViewArea(this->io->Ren->GetViewport());
menu = this->menus.find(id);
}
this->current = menu->second;
if (!this->current->BackList()) {
this->current->BackList(DrawList::New(ren));
this->current->BackList()->BaseLayer(root_layer + 30);
this->current->BackList(DrawList::New(io->Ren));
io->RegisterDrawList(this->current->name + "back", this->current->back);
}
if (!this->current->MainList()) {
this->current->MainList(DrawList::New(ren));
this->current->MainList()->BaseLayer(root_layer + 40);
this->current->MainList(DrawList::New(io->Ren));
io->RegisterDrawList(this->current->name + "main", this->current->main);
}
if (!this->current->FrontList()) {
this->current->FrontList(DrawList::New(ren));
this->current->FrontList()->BaseLayer(root_layer + 50);
this->current->FrontList(DrawList::New(io->Ren));
io->RegisterDrawList(this->current->name + "front", this->current->front);
}
this->current->PreHandler(flags);
amenus.push_back(this->current->GetID());
@@ -85,16 +97,19 @@ void UI7::Context::EndMenu() {
void UI7::Context::Update(float delta) {
TT::Scope st("UI7_Update");
Assert(current == nullptr, "Still in a Menu!");
this->delta = delta;
s_delta->Add(delta * 1000);
this->back->BaseLayer(root_layer + 10);
this->back->Process();
this->io->Delta = delta;
io->DeltaStats->Add(io->Delta * 1000);
for (auto it : amenus) {
menus[it]->Update(delta);
menus[it]->Update(io->Delta);
}
int list = 1;
for (auto it : io->DrawListRegestry) {
it.second->BaseLayer(list * 10);
it.second->Process();
list++;
}
this->front->BaseLayer(root_layer + 60);
this->front->Process();
this->amenus.clear();
this->io->Update();
}
void UI7::Context::AboutMenu() {
@@ -126,14 +141,110 @@ void UI7::Context::MetricsMenu() {
m->Label("Palladium - UI7 " + GetVersion());
m->Separator();
m->Label(std::format("Average {:.3f} ms/f ({:.1f} FPS)",
((float)s_delta->GetAverage() / 1000.f),
1000.f / ((float)s_delta->GetAverage() / 1000.f)));
m->Label(
std::format("Average {:.3f} ms/f ({:.1f} FPS)",
((float)io->DeltaStats->GetAverage() / 1000.f),
1000.f / ((float)io->DeltaStats->GetAverage() / 1000.f)));
m->Label("Menus: " + std::to_string(menus.size()));
m->SeparatorText("Lithium");
m->Label(std::format("Vertices: {} Indices: {}", ren->Vertices(),
ren->Indices()));
m->Label("Triangles: " + std::to_string(ren->Indices() / 3));
m->Label(std::format("Vertices: {} Indices: {}", io->Ren->Vertices(),
io->Ren->Indices()));
m->Label("Triangles: " + std::to_string(io->Ren->Indices() / 3));
m->SeparatorText("TimeTrace");
if (m->BeginTreeNode("Traces (" +
std::to_string(Sys::GetTraceMap().size()) + ")")) {
for (auto& it : Sys::GetTraceMap()) {
if (m->BeginTreeNode(it.second->GetID())) {
m->Label("Diff: " + UI7DTF(it.second->GetLastDiff()));
m->Label("Protocol Len: " +
std::to_string(it.second->GetProtocol()->GetLen()));
m->Label("Average: " +
UI7DTF(it.second->GetProtocol()->GetAverage()));
m->Label("Min: " + UI7DTF(it.second->GetProtocol()->GetMin()));
m->Label("Max: " + UI7DTF(it.second->GetProtocol()->GetMax()));
m->EndTreeNode();
}
}
m->EndTreeNode();
}
m->SeparatorText("IO");
if (m->BeginTreeNode("Menus (" + std::to_string(menus.size()) + ")")) {
for (auto& it : menus) {
if (m->BeginTreeNode(it.second->name)) {
m->Label("Name: " + it.second->name);
m->Label("Pos: " + UI7DV2N(it.second->view_area.xy()));
m->Label("Size: " + UI7DV2N(it.second->view_area.zw()));
m->Label("Main Area: " + UI7DV4N(it.second->main_area));
m->Label("Cursor: " + UI7DV2N(it.second->cursor));
if (m->BeginTreeNode("ID Objects (" +
std::to_string(it.second->idobjs.size()) +
")")) {
for (auto& jt : it.second->idobjs) {
m->Label(UI7DHX32(jt->GetID()));
}
m->EndTreeNode();
}
m->EndTreeNode();
}
}
m->EndTreeNode();
}
if (m->BeginTreeNode("DrawLists (" +
std::to_string(io->DrawListRegestry.size()) + ")")) {
for (auto& it : io->DrawListRegestry) {
m->Label(it.first.GetName());
}
m->EndTreeNode();
}
m->Label("io->Time: " + Strings::FormatMillis(io->Time->Get()));
m->Label(std::format("io->Delta: {:.3f}", io->Delta));
m->Label(std::format("io->Framerate: {:.2f}", io->Framerate));
m->Label(UI7DHX32(io->DraggedObject));
m->Label(std::format("io->DragTime: {:.2f}s", io->DragTime->GetSeconds()));
m->Label(UI7DV4(io->DragDestination));
m->Label(UI7DV2(io->DragSourcePos));
m->Label(UI7DV2(io->DragPosition));
m->Label(UI7DV2(io->DragLastPosition));
this->EndMenu();
}
}
void UI7::Context::StyleEditor() {
if (this->BeginMenu("UI7 Style Editor", UI7MenuFlags_Scrolling)) {
auto m = this->GetCurrentMenu();
m->Label("Palladium - UI7 " + GetVersion() + " Style Editor");
m->Separator();
m->Label(std::format("MenuPadding: {}, {}", io->MenuPadding.x(),
io->MenuPadding.y()));
m->SameLine();
if (m->Button("-")) {
io->MenuPadding -= 1;
}
m->SameLine();
if (m->Button("+")) {
io->MenuPadding += 1;
}
m->Label(std::format("FramePadding: {}, {}", io->FramePadding.x(),
io->FramePadding.y()));
m->SameLine();
if (m->Button("-")) {
io->FramePadding -= 1;
}
m->SameLine();
if (m->Button("+")) {
io->FramePadding += 1;
}
m->Label(
std::format("ItemSpace: {}, {}", io->ItemSpace.x(), io->ItemSpace.y()));
m->SameLine();
if (m->Button("-")) {
io->ItemSpace -= 1;
}
m->SameLine();
if (m->Button("+")) {
io->ItemSpace += 1;
}
this->EndMenu();
}
}