- Added DestroyTex to 3ds backend
- Added Size() -> ivec2 to PD::Image
- Added CmdPool Copy as well as DrawList Copy (Static rendering)
- Added == ooperator for Rect
- Added UI7 Frame Rounding
- Fix UI7 Image usage withour size or uv
- Added New way to use BeginMenu
This commit is contained in:
2026-01-18 19:25:50 +01:00
parent 0ef6d34435
commit 2b7d25cf06
16 changed files with 59 additions and 32 deletions

View File

@@ -48,6 +48,7 @@ class GfxC3D : public GfxDriver {
PD::Li::Texture::Type type = PD::Li::Texture::Type::RGBA32,
PD::Li::Texture::Filter filter =
PD::Li::Texture::Filter::LINEAR) override;
void DestroyTex(PD::Li::Texture::Ref tex) override;
std::vector<Li::Vertex, LinearAllocator<Li::Vertex>> VertexBuffer;
std::vector<u16, LinearAllocator<u16>> IndexBuffer;

View File

@@ -260,4 +260,11 @@ PD::Li::Texture::Ref GfxC3D::LoadTex(const std::vector<PD::u8>& pixels, int w,
<< std::endl;
return res;
}
void GfxC3D::DestroyTex(PD::Li::Texture::Ref tex) {
C3D_Tex* t = reinterpret_cast<C3D_Tex*>(tex->Address);
C3D_TexDelete(t);
delete t;
tex->Address = 0;
}
} // namespace PD

View File

@@ -61,6 +61,8 @@ class GfxDriver {
return nullptr;
}
virtual void DestroyTex(PD::Li::Texture::Ref tex) {}
Li::Texture::Ref GetSolidTex() { return pSolid; }
const std::string pName = "NullGfx";
@@ -108,6 +110,8 @@ class Gfx {
return pGfx->LoadTex(pixels, w, h, type, filter);
}
static void DestroyTex(Li::Texture::Ref tex) { pGfx->DestroyTex(tex); }
static Li::Texture::Ref GetSolidTex() { return pGfx->GetSolidTex(); }
static GfxDriver::Ref pGfx;

View File

@@ -57,6 +57,7 @@ class PD_IMAGE_API Image {
int Width() const { return pWidth; }
int Height() const { return pHeight; }
ivec2 Size() const { return ivec2(pWidth, pHeight); }
Format Fmt() const { return pFmt; }
void FlipVertical();

View File

@@ -120,6 +120,11 @@ class CmdPool {
size_t Cap() const { return pPool.size(); }
void Merge(CmdPool& p) {
Copy(p);
p.Reset();
}
void Copy(CmdPool& p) {
if (pPoolIdx + p.Size() > pPool.size()) {
Resize(pPoolIdx + p.Size());
}
@@ -128,7 +133,6 @@ class CmdPool {
*pPool[idx] = *p.GetCmd(i);
pPool[idx]->Index = idx;
}
p.Reset();
}
private:

View File

@@ -131,6 +131,8 @@ class Rect {
return *this;
}
bool operator==(Rect& r) { return Top == r.Top && Bot == r.Bot; }
void SwapVec2XY() {
Top.SwapXY();
Top.SwapZW();

View File

@@ -39,13 +39,14 @@ class PD_UI7_API Image : public Container {
*/
Image(Li::Texture::Ref img, fvec2 size = 0.f, Li::Rect uv = fvec4(0.f)) {
this->img = img;
this->newsize = size;
this->cuv = uv;
if (size.x != 0 || size.y != 0) {
this->SetSize(size);
} else {
this->SetSize(fvec2(img->GetSize().x, img->GetSize().y));
if (size == fvec2(0.f)) {
size = img->GetSize();
}
if (uv == Li::Rect(fvec4(0.f))) {
uv = img->GetUV();
}
this->cuv = uv;
this->newsize = size;
}
~Image() = default;

View File

@@ -57,7 +57,7 @@ class ID {
~ID() = default;
/** Get The ID Initial Name */
constexpr const std::string_view& GetNameView() const { return pName; }
// constexpr const std::string_view& GetNameView() const { return pName; }
const std::string GetName() const { return std::string(pName); }
/** Getter for the raw 32bit int id */

View File

@@ -73,6 +73,7 @@ class PD_UI7_API IO {
UI7::Theme::Ref Theme;
fvec2 MenuPadding = 5.f;
fvec2 FramePadding = 5.f;
float FrameRounding = 0.f;
fvec2 ItemSpace = vec2(5.f, 2.f);
fvec2 MinSliderDragSize = 10.f; // Min height (Vt) and Min Width (Hz)
bool ShowMenuBorder = true;

View File

@@ -59,7 +59,8 @@ class PD_UI7_API Context {
void AddViewPort(const ID& id, const ivec4& vp);
void UseViewPort(const ID& id);
void Update();
bool BeginMenu(const ID& id, UI7MenuFlags flags = 0, bool* pShow = nullptr);
Menu::Ref BeginMenu(const ID& id, UI7MenuFlags flags = 0,
bool* pShow = nullptr);
Menu::Ref CurrentMenu() { return pCurrent; }
void EndMenu();
void AboutMenu(bool* show = nullptr);

View File

@@ -68,6 +68,10 @@ PD_LITHIUM_API void DrawList::Merge(DrawList::Ref list) {
list->Clear();
}
PD_LITHIUM_API void DrawList::Copy(DrawList::Ref list) {
pPool.Copy(list->pPool);
}
PD_LITHIUM_API void DrawList::Optimize() {
#ifndef NDEBUG
PD::TT::Scope s("Optimize");

View File

@@ -49,7 +49,8 @@ PD_UI7_API void Button::HandleInput() {
PD_UI7_API void Button::Draw() {
// Assert(io.get() && list.get(), "Did you run Container::Init correctly?");
// io->Ren->OnScreen(screen);
list->DrawRectFilled(FinalPos(), size, io->Theme->Get(color));
list->PathRect(FinalPos(), FinalPos() + size, io->FrameRounding);
list->PathFill(io->Theme->Get(color));
list->pLayer++;
list->DrawText(FinalPos() + size * 0.5 - tdim * 0.5, label,
io->Theme->Get(UI7Color_Text));

View File

@@ -48,10 +48,11 @@ PD_UI7_API void Checkbox::HandleInput() {
PD_UI7_API void Checkbox::Draw() {
// Assert(list.get() && io.get(), "Did you run Container::Init correctly?");
// io->Ren->OnScreen(screen);
list->DrawRectFilled(FinalPos(), cbs, io->Theme->Get(color));
list->PathRect(FinalPos(), FinalPos() + cbs, io->FrameRounding);
list->PathFill(io->Theme->Get(color));
if (usr_ref) {
list->DrawRectFilled(FinalPos() + 2, cbs - 4,
io->Theme->Get(UI7Color_Checkmark));
list->PathRect(FinalPos() + 2, FinalPos() + cbs - 2, io->FrameRounding);
list->PathFill(io->Theme->Get(UI7Color_Checkmark));
}
list->DrawText(
FinalPos() + fvec2(cbs.x + io->ItemSpace.x, cbs.y * 0.5 - tdim.y * 0.5),

View File

@@ -44,8 +44,9 @@ PD_UI7_API void ColorEdit::HandleInput() {
PD_UI7_API void ColorEdit::Draw() {
// Assert(io.get() && list.get(), "Did you run Container::Init correctly?");
// io->Ren->OnScreen(screen);
list->DrawRectFilled(FinalPos(), fvec2(20, 20), *color_ref);
list->DrawText(FinalPos() + fvec2(io->ItemSpace.x + 20, 0), label,
list->PathRect(FinalPos(), FinalPos() + 18, io->FrameRounding);
list->PathFill(*color_ref);
list->DrawText(FinalPos() + fvec2(io->ItemSpace.x + 18, 0), label,
io->Theme->Get(UI7Color_Text));
if (is_shown) {
if (!layout) {
@@ -53,13 +54,14 @@ PD_UI7_API void ColorEdit::Draw() {
}
layout->AddObject(Label::New("Hello World!", io));
layout->Update();
io->RegisterDrawList(GetID(), layout->GetDrawList());
list->Merge(layout->GetDrawList());
// io->RegisterDrawList(GetID(), layout->GetDrawList());
}
}
PD_UI7_API void ColorEdit::Update() {
// Assert(io.get(), "Did you run Container::Init correctly?");
this->SetSize(fvec2(tdim.x + io->ItemSpace.x + 20, 20));
this->SetSize(fvec2(tdim.x + io->ItemSpace.x + 18, 18));
}
} // namespace UI7
} // namespace PD

View File

@@ -81,8 +81,9 @@ PD_UI7_API void DragData<T>::Draw() {
p = std::format("{}", data[i]);
}
vec2 td = io->Font->GetTextBounds(p, io->FontScale);
list->DrawRectFilled(FinalPos() + fvec2(off_x, 0), td + io->FramePadding,
io->Theme->Get(UI7Color_Button));
list->PathRect(FinalPos() + fvec2(off_x, 0),
FinalPos() + td + io->FramePadding, io->FrameRounding);
list->PathFill(io->Theme->Get(UI7Color_Button));
list->pLayer++;
list->DrawTextEx(FinalPos() + fvec2(off_x, 0), p,
io->Theme->Get(UI7Color_Text), LiTextFlags_AlignMid,

View File

@@ -51,25 +51,25 @@ PD_UI7_API void Context::UseViewPort(const ID &id) {
pIO->CurrentViewPort = pIO->ViewPorts[id]->GetSize();
}
PD_UI7_API bool Context::BeginMenu(const ID &id, UI7MenuFlags flags,
bool *pShow) {
PD_UI7_API Menu::Ref Context::BeginMenu(const ID &id, UI7MenuFlags flags,
bool *pShow) {
if (pCurrent) {
std::cout << "[UI7] Error: You are already in " << pCurrent->pID.GetName()
<< " Menu" << std::endl;
return false;
return nullptr;
}
if (std::find(pCurrentMenus.begin(), pCurrentMenus.end(), (u32)id) !=
pCurrentMenus.end()) {
std::cout << "[UI7] Error: Menu " << id.GetName() << " already exists!"
<< std::endl;
return false;
return nullptr;
}
pCurrent = pGetOrCreateMenu(id);
this->pCurrent->pIsShown = pShow;
if (pCurrent->pIsShown != nullptr) {
if (!*pCurrent->pIsShown) {
pCurrent = nullptr;
return false;
return nullptr;
}
}
/** Probably we dont even need Input Handling in this stage */
@@ -79,7 +79,7 @@ PD_UI7_API bool Context::BeginMenu(const ID &id, UI7MenuFlags flags,
if (!pCurrent->pIsOpen) {
pCurrent = nullptr;
}
return pCurrent != nullptr;
return pCurrent;
}
PD_UI7_API void Context::EndMenu() {
@@ -154,8 +154,7 @@ PD_UI7_API void Context::Update() {
}
PD_UI7_API void Context::AboutMenu(bool *show) {
if (BeginMenu("About UI7", UI7MenuFlags_Scrolling, show)) {
auto m = pCurrent;
if (auto m = BeginMenu("About UI7", UI7MenuFlags_Scrolling, show)) {
m->Label("Palladium UI7 " + GetVersion());
m->Separator();
m->Label("(c) 2023-2025 René Amthor");
@@ -177,8 +176,7 @@ PD_UI7_API void Context::AboutMenu(bool *show) {
}
PD_UI7_API void Context::MetricsMenu(bool *show) {
if (BeginMenu("UI7 Metrics", UI7MenuFlags_Scrolling, show)) {
auto m = pCurrent;
if (auto m = BeginMenu("UI7 Metrics", UI7MenuFlags_Scrolling, show)) {
m->Label("Palladium - UI7 " + GetVersion());
m->Separator();
m->Label(
@@ -303,9 +301,7 @@ PD_UI7_API void Context::MetricsMenu(bool *show) {
}
PD_UI7_API void UI7::Context::StyleEditor(bool *show) {
if (this->BeginMenu("UI7 Style Editor", UI7MenuFlags_Scrolling, show)) {
auto m = pCurrent;
if (auto m = BeginMenu("UI7 Style Editor", UI7MenuFlags_Scrolling, show)) {
m->Label("Palladium - UI7 " + GetVersion() + " Style Editor");
m->Separator();
m->DragData("MenuPadding", (float *)&pIO->MenuPadding, 2, 0.f, 100.f);