Let's just use 1 PD_API header

This commit is contained in:
2026-01-25 20:57:14 +01:00
parent 337c016824
commit fb46f4d36a
63 changed files with 289 additions and 459 deletions

View File

@@ -25,7 +25,7 @@ SOFTWARE.
namespace PD {
namespace UI7 {
PD_UI7_API void Button::HandleInput() {
PD_API void Button::HandleInput() {
/// Ensure to only check input once
if (inp_done) {
return;
@@ -46,7 +46,7 @@ PD_UI7_API void Button::HandleInput() {
//}
inp_done = true;
}
PD_UI7_API void Button::Draw() {
PD_API void Button::Draw() {
// Assert(io.get() && list.get(), "Did you run Container::Init correctly?");
// io->Ren->OnScreen(screen);
list->PathRect(FinalPos(), FinalPos() + size, io->FrameRounding);
@@ -57,7 +57,7 @@ PD_UI7_API void Button::Draw() {
list->LayerDown();
}
PD_UI7_API void Button::Update() {
PD_API void Button::Update() {
// Assert(io.get(), "Did you run Container::Init correctly?");
this->SetSize(tdim + io->FramePadding);
}

View File

@@ -25,7 +25,7 @@ SOFTWARE.
namespace PD {
namespace UI7 {
PD_UI7_API void Checkbox::HandleInput() {
PD_API void Checkbox::HandleInput() {
/// Ensure to only check input once
if (inp_done) {
return;
@@ -45,7 +45,7 @@ PD_UI7_API void Checkbox::HandleInput() {
//}
inp_done = true;
}
PD_UI7_API void Checkbox::Draw() {
PD_API void Checkbox::Draw() {
// Assert(list.get() && io.get(), "Did you run Container::Init correctly?");
// io->Ren->OnScreen(screen);
list->PathRect(FinalPos(), FinalPos() + cbs, io->FrameRounding);
@@ -59,7 +59,7 @@ PD_UI7_API void Checkbox::Draw() {
label, io->Theme->Get(UI7Color_Text));
}
PD_UI7_API void Checkbox::Update() {
PD_API void Checkbox::Update() {
// Assert(io.get(), "Did you run Container::Init correctly?");
cbs = io->ItemRowHeight;
this->SetSize(cbs + fvec2(tdim.x + io->ItemSpace.x, 0));

View File

@@ -26,7 +26,7 @@ SOFTWARE.
namespace PD {
namespace UI7 {
PD_UI7_API void ColorEdit::HandleInput() {
PD_API void ColorEdit::HandleInput() {
/// Ensure to only check input once
if (inp_done) {
return;
@@ -42,7 +42,7 @@ PD_UI7_API void ColorEdit::HandleInput() {
//}
inp_done = true;
}
PD_UI7_API void ColorEdit::Draw() {
PD_API void ColorEdit::Draw() {
// Assert(io.get() && list.get(), "Did you run Container::Init correctly?");
// io->Ren->OnScreen(screen);
list->PathRect(FinalPos(), FinalPos() + io->ItemRowHeight, io->FrameRounding);
@@ -90,7 +90,7 @@ PD_UI7_API void ColorEdit::Draw() {
}
}
PD_UI7_API void ColorEdit::Update() {
PD_API void ColorEdit::Update() {
// Assert(io.get(), "Did you run Container::Init correctly?");
this->SetSize(
fvec2(tdim.x + io->ItemSpace.x + io->ItemRowHeight, io->ItemRowHeight));

View File

@@ -25,7 +25,7 @@ SOFTWARE.
namespace PD {
namespace UI7 {
PD_UI7_API void Container::HandleScrolling(fvec2 scrolling, fvec4 viewport) {
PD_API void Container::HandleScrolling(fvec2 scrolling, fvec4 viewport) {
if (last_use != 0 && OS::GetTime() - last_use > 5000) {
rem = true;
}
@@ -37,7 +37,7 @@ PD_UI7_API void Container::HandleScrolling(fvec2 scrolling, fvec4 viewport) {
viewport.y + viewport.w));
}
PD_UI7_API void Container::HandleInternalInput() {
PD_API void Container::HandleInternalInput() {
/** Requires Handle Scrolling First */
}
} // namespace UI7

View File

@@ -29,15 +29,15 @@ namespace PD {
namespace UI7 {
// Setup Supported Datatypes (Probably making this Object
// header only to not care about datatype support)
template class PD_UI7_API DragData<float>;
template class PD_UI7_API DragData<int>;
template class PD_UI7_API DragData<double>;
template class PD_UI7_API DragData<u8>;
template class PD_UI7_API DragData<u16>;
template class PD_UI7_API DragData<u32>;
template class PD_UI7_API DragData<u64>;
template class PD_API DragData<float>;
template class PD_API DragData<int>;
template class PD_API DragData<double>;
template class PD_API DragData<u8>;
template class PD_API DragData<u16>;
template class PD_API DragData<u32>;
template class PD_API DragData<u64>;
template <typename T>
PD_UI7_API void DragData<T>::HandleInput() {
PD_API void DragData<T>::HandleInput() {
/// Ensure to only check input once
if (inp_done) {
return;
@@ -69,7 +69,7 @@ PD_UI7_API void DragData<T>::HandleInput() {
}
template <typename T>
PD_UI7_API void DragData<T>::Draw() {
PD_API void DragData<T>::Draw() {
// Assert(io.get() && list.get(), "Did you run Container::Init correctly?");
// io->Ren->OnScreen(screen);
float off_x = 0.f;
@@ -97,7 +97,7 @@ PD_UI7_API void DragData<T>::Draw() {
}
template <typename T>
PD_UI7_API void DragData<T>::Update() {
PD_API void DragData<T>::Update() {
// Assert(io.get(), "Did you run Container::Init correctly?");
// Probably need to find a faster solution (caching sizes calculated here)
float off_x = 0;

View File

@@ -26,14 +26,14 @@ SOFTWARE.
namespace PD {
namespace UI7 {
PD_UI7_API void DynObj::Draw() { pRenFun(io, list, this); }
PD_API void DynObj::Draw() { pRenFun(io, list, this); }
PD_UI7_API void DynObj::HandleInput() {
PD_API void DynObj::HandleInput() {
if (pInp) {
pInp(io, this);
}
}
PD_UI7_API void DynObj::Update() {}
PD_API void DynObj::Update() {}
} // namespace UI7
} // namespace PD

View File

@@ -25,7 +25,7 @@ SOFTWARE.
namespace PD {
namespace UI7 {
PD_UI7_API void Image::Draw() {
PD_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);

View File

@@ -25,7 +25,7 @@ SOFTWARE.
namespace PD {
namespace UI7 {
PD_UI7_API void Label::Draw() {
PD_API void Label::Draw() {
// Assert(io.get() && list.get(), "Did you run Container::Init correctly?");
// io->Ren->OnScreen(screen);
if (pCLipRectUsed) {
@@ -38,7 +38,7 @@ PD_UI7_API void Label::Draw() {
}
}
PD_UI7_API void Label::Update() {
PD_API void Label::Update() {
/**
* Todo: This is a hacky workaround
* Needs proper optimisation

View File

@@ -29,15 +29,15 @@ namespace PD {
namespace UI7 {
// Setup Supported Datatypes (Probably making this Object
// header only to not care about datatype support)
template class PD_UI7_API Slider<float>;
template class PD_UI7_API Slider<int>;
template class PD_UI7_API Slider<double>;
template class PD_UI7_API Slider<u8>;
template class PD_UI7_API Slider<u16>;
template class PD_UI7_API Slider<u32>;
template class PD_UI7_API Slider<u64>;
template class PD_API Slider<float>;
template class PD_API Slider<int>;
template class PD_API Slider<double>;
template class PD_API Slider<u8>;
template class PD_API Slider<u16>;
template class PD_API Slider<u32>;
template class PD_API Slider<u64>;
template <typename T>
PD_UI7_API void Slider<T>::HandleInput() {
PD_API void Slider<T>::HandleInput() {
/// Ensure to only check input once
if (inp_done) {
return;
@@ -66,7 +66,7 @@ PD_UI7_API void Slider<T>::HandleInput() {
}
template <typename T>
PD_UI7_API void Slider<T>::Draw() {
PD_API void Slider<T>::Draw() {
// Assert(io.get() && list.get(), "Did you run Container::Init correctly?");
// io->Ren->OnScreen(screen);
std::string p;
@@ -93,7 +93,7 @@ PD_UI7_API void Slider<T>::Draw() {
}
template <typename T>
PD_UI7_API void Slider<T>::Update() {
PD_API void Slider<T>::Update() {
// Assert(io.get(), "Did you run Container::Init correctly?");
// Probably need to find a faster solution (caching sizes calculated here)
slw = std::clamp(static_cast<float>(width / max), 3.f, width);

View File

@@ -25,7 +25,7 @@ SOFTWARE.
#include <pd/ui7/io.hpp>
namespace PD {
PD_UI7_API void UI7::IO::Update() {
PD_API void UI7::IO::Update() {
/** Todo: find out if we even still use the Drawlist regestry */
u64 current = OS::GetNanoTime();
Delta = static_cast<float>(current - LastTime) / 1000000.f;

28
source/ui7/layout.cpp Executable file → Normal file
View File

@@ -26,14 +26,14 @@ SOFTWARE.
namespace PD {
namespace UI7 {
PD_UI7_API void Layout::CursorInit() { Cursor = fvec2(WorkRect.x, WorkRect.y); }
PD_API void Layout::CursorInit() { Cursor = fvec2(WorkRect.x, WorkRect.y); }
PD_UI7_API void Layout::SameLine() {
PD_API void Layout::SameLine() {
BackupCursor = LastObjSize;
Cursor = SamelineCursor;
}
PD_UI7_API void Layout::CursorMove(const fvec2& size) {
PD_API void Layout::CursorMove(const fvec2& size) {
LastObjSize = size;
SamelineCursor = Cursor + fvec2(size.x + IO->ItemSpace.x, 0);
if (BeforeSameLine.y) {
@@ -48,7 +48,7 @@ PD_UI7_API void Layout::CursorMove(const fvec2& size) {
MaxPosition = fvec2(std::max(MaxPosition.x, SamelineCursor.x), Cursor.y);
}
PD_UI7_API bool Layout::ObjectWorkPos(fvec2& movpos) {
PD_API bool Layout::ObjectWorkPos(fvec2& movpos) {
if (Scrolling[1]) {
movpos.y -= ScrollOffset.y;
if (!Li::Renderer::InBox(
@@ -61,7 +61,7 @@ PD_UI7_API bool Layout::ObjectWorkPos(fvec2& movpos) {
return false;
}
PD_UI7_API void Layout::AddObject(Container::Ref obj) {
PD_API void Layout::AddObject(Container::Ref obj) {
obj->Init(IO, DrawList);
obj->SetPos(AlignPosition(Cursor, obj->GetSize(), WorkRect, GetAlignment()));
obj->Update();
@@ -70,7 +70,7 @@ PD_UI7_API void Layout::AddObject(Container::Ref obj) {
Objects.push_back(obj);
}
PD_UI7_API void Layout::AddObjectEx(Container::Ref obj, u32 flags) {
PD_API void Layout::AddObjectEx(Container::Ref obj, u32 flags) {
obj->Init(IO, DrawList);
if (!(flags & UI7LytAdd_NoCursorUpdate)) {
obj->SetPos(
@@ -90,7 +90,7 @@ PD_UI7_API void Layout::AddObjectEx(Container::Ref obj, u32 flags) {
}
}
PD_UI7_API Container::Ref Layout::FindObject(u32 id) {
PD_API Container::Ref Layout::FindObject(u32 id) {
for (auto& it : IDObjects) {
if (it->GetID() == id) {
return it;
@@ -99,8 +99,8 @@ PD_UI7_API Container::Ref Layout::FindObject(u32 id) {
return nullptr;
}
PD_UI7_API fvec2 Layout::AlignPosition(fvec2 pos, fvec2 size, fvec4 area,
UI7Align alignment) {
PD_API fvec2 Layout::AlignPosition(fvec2 pos, fvec2 size, fvec4 area,
UI7Align alignment) {
vec2 p = pos;
if (alignment & UI7Align_Center) {
p.x = (area.x + area.z) * 0.5 - (pos.x - area.x + size.x * 0.5);
@@ -113,7 +113,7 @@ PD_UI7_API fvec2 Layout::AlignPosition(fvec2 pos, fvec2 size, fvec4 area,
return p;
}
PD_UI7_API void Layout::Update() {
PD_API void Layout::Update() {
if (Size == fvec2(0.f)) {
Size = fvec2(MaxPosition) + IO->MenuPadding * 2;
}
@@ -144,14 +144,14 @@ PD_UI7_API void Layout::Update() {
/** SECTION CONTAINERS (STOLEN FROM FORMER MENU) */
PD_UI7_API void Layout::Label(const std::string& label) {
PD_API void Layout::Label(const std::string& label) {
// Layout API
auto r = Label::New(label, IO);
r->SetClipRect(fvec4(GetPosition(), GetPosition() + GetSize()));
AddObject(r);
}
PD_UI7_API bool Layout::Button(const std::string& label) {
PD_API bool Layout::Button(const std::string& label) {
bool ret = false;
u32 id = Strings::FastHash("btn" + label + std::to_string(Objects.size()));
Container::Ref r = FindObject(id);
@@ -166,7 +166,7 @@ PD_UI7_API bool Layout::Button(const std::string& label) {
return ret;
}
PD_UI7_API void Layout::Checkbox(const std::string& label, bool& v) {
PD_API void Layout::Checkbox(const std::string& label, bool& v) {
u32 id = Strings::FastHash("cbx" + label + std::to_string(Objects.size()));
Container::Ref r = FindObject(id);
if (!r) {
@@ -176,7 +176,7 @@ PD_UI7_API void Layout::Checkbox(const std::string& label, bool& v) {
AddObject(r);
}
PD_UI7_API void Layout::Image(Li::Texture::Ref img, fvec2 size, Li::Rect uv) {
PD_API void Layout::Image(Li::Texture::Ref img, fvec2 size, Li::Rect uv) {
Container::Ref r = Image::New(img, size, uv);
AddObject(r);
}

View File

@@ -34,7 +34,7 @@ Menu::Menu(const ID& id, IO::Ref io) : pIO(io), pID(id) {
pLayout->CursorInit();
}
PD_UI7_API void Menu::Label(const std::string& label) {
PD_API void Menu::Label(const std::string& label) {
// Layout API
auto r = Label::New(label, pIO);
r->SetClipRect(fvec4(pLayout->GetPosition(),
@@ -42,7 +42,7 @@ PD_UI7_API void Menu::Label(const std::string& label) {
pLayout->AddObject(r);
}
PD_UI7_API bool Menu::Button(const std::string& label) {
PD_API bool Menu::Button(const std::string& label) {
bool ret = false;
u32 id = Strings::FastHash("btn" + label +
std::to_string(pLayout->Objects.size()));
@@ -58,7 +58,7 @@ PD_UI7_API bool Menu::Button(const std::string& label) {
return ret;
}
PD_UI7_API void Menu::Checkbox(const std::string& label, bool& v) {
PD_API void Menu::Checkbox(const std::string& label, bool& v) {
u32 id = Strings::FastHash("cbx" + label +
std::to_string(pLayout->Objects.size()));
Container::Ref r = pLayout->FindObject(id);
@@ -69,12 +69,12 @@ PD_UI7_API void Menu::Checkbox(const std::string& label, bool& v) {
pLayout->AddObject(r);
}
PD_UI7_API void Menu::Image(Li::Texture::Ref img, fvec2 size, Li::Rect uv) {
PD_API void Menu::Image(Li::Texture::Ref img, fvec2 size, Li::Rect uv) {
Container::Ref r = Image::New(img, size, uv);
pLayout->AddObject(r);
}
PD_UI7_API void Menu::ColorEdit(const std::string& label, u32& clr) {
PD_API void Menu::ColorEdit(const std::string& label, u32& clr) {
u32 id = Strings::FastHash("drd" + label);
Container::Ref r = pLayout->FindObject(id);
if (!r) {
@@ -84,7 +84,7 @@ PD_UI7_API void Menu::ColorEdit(const std::string& label, u32& clr) {
pLayout->AddObject(r);
}
PD_UI7_API void Menu::Separator() {
PD_API void Menu::Separator() {
// Dynamic Objects are very simple...
Container::Ref r = DynObj::New(
[=, this](UI7::IO::Ref io, Li::DrawList::Ref l, UI7::Container* self) {
@@ -98,7 +98,7 @@ PD_UI7_API void Menu::Separator() {
pLayout->AddObject(r);
}
PD_UI7_API void Menu::SeparatorText(const std::string& label) {
PD_API void Menu::SeparatorText(const std::string& label) {
// Also note to use [=] instead of [&] to not undefined access label
Container::Ref r = DynObj::New([=, this](UI7::IO::Ref io, Li::DrawList::Ref l,
UI7::Container* self) {
@@ -127,7 +127,7 @@ PD_UI7_API void Menu::SeparatorText(const std::string& label) {
pIO->Font->PixelHeight * pIO->FontScale));
pLayout->AddObject(r);
}
PD_UI7_API void Menu::HandleFocus() {
PD_API void Menu::HandleFocus() {
// Check if menu can be focused for Selective Menu Input API
vec4 newarea = fvec4(pLayout->Pos, pLayout->Size);
if (!pIsOpen) {
@@ -146,7 +146,7 @@ PD_UI7_API void Menu::HandleFocus() {
}
/** Todo: (func name is self describing) */
PD_UI7_API void Menu::HandleScrolling() {
PD_API void Menu::HandleScrolling() {
if (Flags & UI7MenuFlags_VtScrolling) {
bool allowed =
pLayout->MaxPosition.y > (pLayout->WorkRect.w - pLayout->WorkRect.y);
@@ -184,7 +184,7 @@ PD_UI7_API void Menu::HandleScrolling() {
}
}
PD_UI7_API void Menu::HandleTitlebarActions() {
PD_API void Menu::HandleTitlebarActions() {
// Collapse
if (!(Flags & UI7MenuFlags_NoCollapse)) {
vec2 cpos = pLayout->Pos + pIO->FramePadding;
@@ -247,7 +247,7 @@ PD_UI7_API void Menu::HandleTitlebarActions() {
}
}
PD_UI7_API void Menu::DrawBaseLayout() {
PD_API void Menu::DrawBaseLayout() {
if (pIsOpen) {
/** Resize Sym (Render on Top of Everything) */
if (!(Flags & UI7MenuFlags_NoResize)) {
@@ -348,7 +348,7 @@ PD_UI7_API void Menu::DrawBaseLayout() {
}
}
PD_UI7_API void Menu::Update() {
PD_API void Menu::Update() {
HandleFocus();
if (pLayout->Size == fvec2(0.f) || Flags & UI7MenuFlags_AlwaysAutoSize) {
pLayout->Size = fvec2(pLayout->MaxPosition) + pIO->MenuPadding * 2;
@@ -369,7 +369,7 @@ PD_UI7_API void Menu::Update() {
}
}
PD_UI7_API bool Menu::BeginTreeNode(const ID& id) {
PD_API bool Menu::BeginTreeNode(const ID& id) {
// As of some notes this should work:
auto n = pTreeNodes.find(id);
if (n == pTreeNodes.end()) {
@@ -418,7 +418,7 @@ PD_UI7_API bool Menu::BeginTreeNode(const ID& id) {
return n->second;
}
PD_UI7_API void UI7::Menu::EndTreeNode() {
PD_API void UI7::Menu::EndTreeNode() {
pLayout->InitialCursorOffset.x -= 10.f;
pLayout->Cursor.x -= 10.f;
if (pLayout->InitialCursorOffset.x < 0.f) {

View File

@@ -25,7 +25,7 @@ SOFTWARE.
namespace PD {
namespace UI7 {
PD_UI7_API void Theme::Default(Theme& theme) {
PD_API void Theme::Default(Theme& theme) {
theme.Set(UI7Color_Text, Color("#FFFFFFFF"));
theme.Set(UI7Color_TextDead, Color("#AAAAAAFF"));
theme.Set(UI7Color_Background, Color("#222222aa"));
@@ -45,7 +45,7 @@ PD_UI7_API void Theme::Default(Theme& theme) {
theme.Set(UI7Color_ListOdd, Color("#BBBBBBFF"));
}
PD_UI7_API void Theme::Flashbang(Theme& theme) {
PD_API void Theme::Flashbang(Theme& theme) {
theme.Set(UI7Color_Text, Color("#000000FF"));
theme.Set(UI7Color_TextDead, Color("#333333FF"));
theme.Set(UI7Color_Background, Color("#eeeeeeFF"));

View File

@@ -23,15 +23,15 @@ SOFTWARE.
#include <pd/ui7/ui7.hpp>
#include "pd/pd_p_api.hpp"
#include "pd/ui7/flags.hpp"
#include "pd/ui7/pd_p_api.hpp"
#define UI7DHX32(x) std::format("{}: {:#08x}", #x, x)
#define UI7DTF(x) PD::Strings::FormatNanos(x)
namespace PD {
namespace UI7 {
PD_UI7_API std::string GetVersion(bool show_build) {
PD_API std::string GetVersion(bool show_build) {
std::stringstream s;
s << ((UI7_VERSION >> 24) & 0xFF) << ".";
s << ((UI7_VERSION >> 16) & 0xFF) << ".";
@@ -40,19 +40,19 @@ PD_UI7_API std::string GetVersion(bool show_build) {
return s.str();
}
PD_UI7_API void Context::AddViewPort(const ID& id, const ivec4& vp) {
PD_API void Context::AddViewPort(const ID& id, const ivec4& vp) {
pIO->AddViewPort(id, vp);
}
PD_UI7_API void Context::UseViewPort(const ID& id) {
PD_API void Context::UseViewPort(const ID& id) {
if (!pIO->ViewPorts.count(id)) {
return;
}
pIO->CurrentViewPort = pIO->ViewPorts[id]->GetSize();
}
PD_UI7_API Menu::Ref Context::BeginMenu(const ID& id, UI7MenuFlags flags,
bool* pShow) {
PD_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;
@@ -82,7 +82,7 @@ PD_UI7_API Menu::Ref Context::BeginMenu(const ID& id, UI7MenuFlags flags,
return pCurrent;
}
PD_UI7_API void Context::EndMenu() {
PD_API void Context::EndMenu() {
/**
* Currently it would be a better wy to handle menus as follows
*
@@ -104,7 +104,7 @@ PD_UI7_API void Context::EndMenu() {
// pIO->InputHandler->CurrentMenu = 0;
}
PD_UI7_API void Context::Update() {
PD_API void Context::Update() {
/**
* Cause Commenting each line looks carbage...
* This function simply clears the FinalDrawList, Searches for Menu ID's in
@@ -154,7 +154,7 @@ PD_UI7_API void Context::Update() {
pIO->FDL->pPool.Sort();
}
PD_UI7_API void Context::AboutMenu(bool* show) {
PD_API void Context::AboutMenu(bool* show) {
if (auto m = BeginMenu("About UI7", UI7MenuFlags_Scrolling, show)) {
m->Label("Palladium UI7 " + GetVersion());
m->Separator();
@@ -176,7 +176,7 @@ PD_UI7_API void Context::AboutMenu(bool* show) {
}
}
PD_UI7_API void Context::MetricsMenu(bool* show) {
PD_API void Context::MetricsMenu(bool* show) {
if (auto m = BeginMenu("UI7 Metrics", UI7MenuFlags_Scrolling, show)) {
m->Label("Palladium - UI7 " + GetVersion());
m->Separator();
@@ -301,7 +301,7 @@ PD_UI7_API void Context::MetricsMenu(bool* show) {
}
}
PD_UI7_API void UI7::Context::StyleEditor(bool* show) {
PD_API void UI7::Context::StyleEditor(bool* show) {
if (auto m = BeginMenu("UI7 Style Editor", UI7MenuFlags_Scrolling, show)) {
m->Label("Palladium - UI7 " + GetVersion() + " Style Editor");
m->Separator();