Let's just use 1 PD_API header
This commit is contained in:
@@ -24,8 +24,8 @@ SOFTWARE.
|
||||
#include <pd/core/bit_util.hpp>
|
||||
|
||||
namespace PD::BitUtil {
|
||||
PD_CORE_API bool IsSingleBit(u32 v) { return v && !(v & (v - 1)); }
|
||||
PD_CORE_API u32 GetPow2(u32 v) {
|
||||
PD_API bool IsSingleBit(u32 v) { return v && !(v & (v - 1)); }
|
||||
PD_API u32 GetPow2(u32 v) {
|
||||
v--;
|
||||
v |= v >> 1;
|
||||
v |= v >> 2;
|
||||
|
||||
@@ -25,7 +25,7 @@ SOFTWARE.
|
||||
#include <pd/core/color.hpp>
|
||||
|
||||
namespace PD {
|
||||
PD_CORE_API std::string Color::Hex(bool rgba) const {
|
||||
PD_API std::string Color::Hex(bool rgba) const {
|
||||
/** Need to int cast (so it is used as num and not char...) */
|
||||
std::stringstream s;
|
||||
s << "#";
|
||||
|
||||
@@ -25,7 +25,7 @@ SOFTWARE.
|
||||
|
||||
namespace PD {
|
||||
namespace IO {
|
||||
PD_CORE_API std::vector<u8> LoadFile2Mem(const std::string& path) {
|
||||
PD_API std::vector<u8> LoadFile2Mem(const std::string& path) {
|
||||
std::ifstream iff(path, std::ios::binary);
|
||||
if (!iff) {
|
||||
return std::vector<u8>();
|
||||
@@ -39,7 +39,7 @@ PD_CORE_API std::vector<u8> LoadFile2Mem(const std::string& path) {
|
||||
return res;
|
||||
}
|
||||
|
||||
PD_CORE_API std::string LoadFile2Str(const std::string& path) {
|
||||
PD_API std::string LoadFile2Str(const std::string& path) {
|
||||
std::ifstream iff(path, std::ios::binary);
|
||||
if (!iff) {
|
||||
return "";
|
||||
@@ -53,7 +53,7 @@ PD_CORE_API std::string LoadFile2Str(const std::string& path) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
PD_CORE_API u32 HashMemory(const std::vector<u8>& data) {
|
||||
PD_API u32 HashMemory(const std::vector<u8>& data) {
|
||||
u32 hash = 4477;
|
||||
for (auto& it : data) {
|
||||
hash = (hash * 33) + it;
|
||||
@@ -61,7 +61,7 @@ PD_CORE_API u32 HashMemory(const std::vector<u8>& data) {
|
||||
return hash;
|
||||
}
|
||||
|
||||
PD_CORE_API void DecompressRLE(std::vector<u8>& data) {
|
||||
PD_API void DecompressRLE(std::vector<u8>& data) {
|
||||
if ((data.size() % 2) != 0) {
|
||||
return;
|
||||
}
|
||||
@@ -72,7 +72,7 @@ PD_CORE_API void DecompressRLE(std::vector<u8>& data) {
|
||||
}
|
||||
}
|
||||
|
||||
PD_CORE_API void CompressRLE(std::vector<u8>& data) {
|
||||
PD_API void CompressRLE(std::vector<u8>& data) {
|
||||
if (data.empty()) {
|
||||
/** No exceptions enabled :( */
|
||||
return;
|
||||
|
||||
14
source/core/mat.cpp
Executable file → Normal file
14
source/core/mat.cpp
Executable file → Normal file
@@ -25,7 +25,7 @@ SOFTWARE.
|
||||
#include <pd/core/mat.hpp>
|
||||
|
||||
namespace PD {
|
||||
PD_CORE_API Mat4 Mat4::RotateX(float a) {
|
||||
PD_API Mat4 Mat4::RotateX(float a) {
|
||||
float c = std::cos(a);
|
||||
float s = std::sin(a);
|
||||
Mat4 ret = Identity();
|
||||
@@ -36,7 +36,7 @@ PD_CORE_API Mat4 Mat4::RotateX(float a) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
PD_CORE_API Mat4 Mat4::RotateY(float a) {
|
||||
PD_API Mat4 Mat4::RotateY(float a) {
|
||||
float c = std::cos(a);
|
||||
float s = std::sin(a);
|
||||
Mat4 ret = Identity();
|
||||
@@ -47,7 +47,7 @@ PD_CORE_API Mat4 Mat4::RotateY(float a) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
PD_CORE_API Mat4 Mat4::RotateZ(float a) {
|
||||
PD_API Mat4 Mat4::RotateZ(float a) {
|
||||
float c = std::cos(a);
|
||||
float s = std::sin(a);
|
||||
Mat4 ret = Identity();
|
||||
@@ -58,7 +58,7 @@ PD_CORE_API Mat4 Mat4::RotateZ(float a) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
PD_CORE_API Mat4 Mat4::Rotate(fvec3 axis, float a) {
|
||||
PD_API Mat4 Mat4::Rotate(fvec3 axis, float a) {
|
||||
float s = std::sin(a);
|
||||
float c = std::cos(a);
|
||||
float t = 1.f - c;
|
||||
@@ -81,7 +81,7 @@ PD_CORE_API Mat4 Mat4::Rotate(fvec3 axis, float a) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
PD_CORE_API Mat4 Mat4::Perspective(float fov, float aspect, float n, float f) {
|
||||
PD_API Mat4 Mat4::Perspective(float fov, float aspect, float n, float f) {
|
||||
float _fov = std::tan(fov / 2.f);
|
||||
Mat4 ret;
|
||||
ret(0, 0) = 1.f / (aspect * _fov);
|
||||
@@ -98,8 +98,8 @@ PD_CORE_API Mat4 Mat4::Perspective(float fov, float aspect, float n, float f) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
PD_CORE_API Mat4 Mat4::LookAt(const fvec3& pos, const fvec3& center,
|
||||
const fvec3& up) {
|
||||
PD_API Mat4 Mat4::LookAt(const fvec3& pos, const fvec3& center,
|
||||
const fvec3& up) {
|
||||
auto f = fvec3(center - pos).Normalize();
|
||||
auto s = f.Cross(up).Normalize();
|
||||
auto u = s.Cross(f);
|
||||
|
||||
20
source/core/strings.cpp
Executable file → Normal file
20
source/core/strings.cpp
Executable file → Normal file
@@ -24,8 +24,8 @@ SOFTWARE.
|
||||
#include <pd/core/strings.hpp>
|
||||
|
||||
namespace PD::Strings {
|
||||
PD_CORE_API bool StringEndsWith(const std::string& str,
|
||||
const std::vector<std::string>& exts) {
|
||||
PD_API bool StringEndsWith(const std::string& str,
|
||||
const std::vector<std::string>& exts) {
|
||||
// Changed order to not do an substr on empty string
|
||||
if (str.empty()) {
|
||||
return false;
|
||||
@@ -44,7 +44,7 @@ PD_CORE_API bool StringEndsWith(const std::string& str,
|
||||
return false;
|
||||
}
|
||||
|
||||
PD_CORE_API std::wstring MakeWstring(const std::string& s) {
|
||||
PD_API std::wstring MakeWstring(const std::string& s) {
|
||||
// Manually convert to wstring as they removed wstring_convert :(
|
||||
std::wstring result;
|
||||
size_t i = 0;
|
||||
@@ -85,7 +85,7 @@ PD_CORE_API std::wstring MakeWstring(const std::string& s) {
|
||||
return result;
|
||||
}
|
||||
|
||||
PD_CORE_API const std::string FormatNanos(unsigned long long nanos) {
|
||||
PD_API const std::string FormatNanos(unsigned long long nanos) {
|
||||
// Based on some code of my minecraft plugins
|
||||
if (nanos < 1000) {
|
||||
return std::format("{}ns", nanos);
|
||||
@@ -106,7 +106,7 @@ PD_CORE_API const std::string FormatNanos(unsigned long long nanos) {
|
||||
return "";
|
||||
}
|
||||
|
||||
PD_CORE_API const std::string FormatMillis(unsigned long long millis) {
|
||||
PD_API const std::string FormatMillis(unsigned long long millis) {
|
||||
// Original Code can be found in some of my mv plugins
|
||||
if (millis < 1000) {
|
||||
return std::format("{}ms", millis);
|
||||
@@ -121,7 +121,7 @@ PD_CORE_API const std::string FormatMillis(unsigned long long millis) {
|
||||
return "";
|
||||
}
|
||||
|
||||
PD_CORE_API const std::string FormatBytes(unsigned long long bytes) {
|
||||
PD_API const std::string FormatBytes(unsigned long long bytes) {
|
||||
static const std::vector<std::string> endings = {
|
||||
"B", "KB", "MB", "GB", "TB", "Unk",
|
||||
};
|
||||
@@ -137,8 +137,8 @@ PD_CORE_API const std::string FormatBytes(unsigned long long bytes) {
|
||||
return std::format("{:.1f} {}", b, endings[i]);
|
||||
}
|
||||
|
||||
PD_CORE_API const std::string GetFileName(const std::string& path,
|
||||
const std::string& saperators) {
|
||||
PD_API const std::string GetFileName(const std::string& path,
|
||||
const std::string& saperators) {
|
||||
auto pos = path.find_last_of(saperators);
|
||||
if (pos != path.npos) {
|
||||
return path.substr(pos + 1);
|
||||
@@ -147,7 +147,7 @@ PD_CORE_API const std::string GetFileName(const std::string& path,
|
||||
return path;
|
||||
}
|
||||
|
||||
PD_CORE_API const std::string PathRemoveExtension(const std::string& path) {
|
||||
PD_API const std::string PathRemoveExtension(const std::string& path) {
|
||||
auto pos = path.find_last_of('.');
|
||||
if (pos != path.npos) {
|
||||
return path.substr(0, pos);
|
||||
@@ -156,7 +156,7 @@ PD_CORE_API const std::string PathRemoveExtension(const std::string& path) {
|
||||
return path;
|
||||
}
|
||||
|
||||
PD_CORE_API u32 FastHash(const std::string& s) {
|
||||
PD_API u32 FastHash(const std::string& s) {
|
||||
u32 hash = 5381;
|
||||
for (auto& it : s) {
|
||||
hash = (hash * 33) + static_cast<u8>(it);
|
||||
|
||||
@@ -26,25 +26,25 @@ SOFTWARE.
|
||||
#include <pd/drivers/drivers.hpp>
|
||||
|
||||
namespace PD {
|
||||
PD_CORE_API Timer::Timer(bool autostart) {
|
||||
PD_API Timer::Timer(bool autostart) {
|
||||
pIsRunning = autostart;
|
||||
Reset();
|
||||
}
|
||||
|
||||
PD_CORE_API void Timer::Reset() {
|
||||
PD_API void Timer::Reset() {
|
||||
pStart = OS::GetTime();
|
||||
pNow = pStart;
|
||||
}
|
||||
|
||||
PD_CORE_API void Timer::Update() {
|
||||
PD_API void Timer::Update() {
|
||||
if (pIsRunning) {
|
||||
pNow = OS::GetTime();
|
||||
}
|
||||
}
|
||||
|
||||
PD_CORE_API void Timer::Pause() { pIsRunning = false; }
|
||||
PD_CORE_API void Timer::Rseume() { pIsRunning = true; }
|
||||
PD_CORE_API bool Timer::IsRunning() const { return pIsRunning; }
|
||||
PD_CORE_API u64 Timer::Get() { return pNow - pStart; }
|
||||
PD_CORE_API double Timer::GetSeconds() { return (double)Get() / 1000.0; }
|
||||
PD_API void Timer::Pause() { pIsRunning = false; }
|
||||
PD_API void Timer::Rseume() { pIsRunning = true; }
|
||||
PD_API bool Timer::IsRunning() const { return pIsRunning; }
|
||||
PD_API u64 Timer::Get() { return pNow - pStart; }
|
||||
PD_API double Timer::GetSeconds() { return (double)Get() / 1000.0; }
|
||||
} // namespace PD
|
||||
@@ -25,12 +25,12 @@ SOFTWARE.
|
||||
#include <pd/drivers/drivers.hpp>
|
||||
|
||||
namespace PD::TT {
|
||||
PD_CORE_API void Beg(const std::string& id) {
|
||||
PD_API void Beg(const std::string& id) {
|
||||
auto trace = OS::GetTraceRef(id);
|
||||
trace->SetStart(PD::OS::GetNanoTime());
|
||||
}
|
||||
|
||||
PD_CORE_API void End(const std::string& id) {
|
||||
PD_API void End(const std::string& id) {
|
||||
auto trace = OS::GetTraceRef(id);
|
||||
trace->SetEnd(PD::OS::GetNanoTime());
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ SOFTWARE.
|
||||
#include <pd/image/img_convert.hpp>
|
||||
|
||||
namespace PD {
|
||||
PD_IMAGE_API void Image::Load(const std::string& path) {
|
||||
PD_API void Image::Load(const std::string& path) {
|
||||
u8* img = pdi_load(path.c_str(), &pWidth, &pHeight, &fmt, 4);
|
||||
if (fmt == 3) {
|
||||
pdi_image_free(img);
|
||||
@@ -47,7 +47,7 @@ PD_IMAGE_API void Image::Load(const std::string& path) {
|
||||
pdi_image_free(img);
|
||||
}
|
||||
}
|
||||
PD_IMAGE_API void Image::Load(const std::vector<u8>& buf) {
|
||||
PD_API void Image::Load(const std::vector<u8>& buf) {
|
||||
u8* img =
|
||||
pdi_load_from_memory(buf.data(), buf.size(), &pWidth, &pHeight, &fmt, 4);
|
||||
if (fmt == 3) {
|
||||
@@ -63,8 +63,7 @@ PD_IMAGE_API void Image::Load(const std::vector<u8>& buf) {
|
||||
pFmt = RGBA;
|
||||
}
|
||||
}
|
||||
PD_IMAGE_API void Image::Copy(const std::vector<u8>& buf, int w, int h,
|
||||
int bpp) {
|
||||
PD_API void Image::Copy(const std::vector<u8>& buf, int w, int h, int bpp) {
|
||||
this->fmt = bpp;
|
||||
if (buf.size() != (size_t)w * h * bpp) {
|
||||
// Size Error
|
||||
@@ -76,7 +75,7 @@ PD_IMAGE_API void Image::Copy(const std::vector<u8>& buf, int w, int h,
|
||||
}
|
||||
}
|
||||
|
||||
PD_IMAGE_API void Image::FlipHorizontal() {
|
||||
PD_API void Image::FlipHorizontal() {
|
||||
/**
|
||||
* Dont know if i am brain dead but i think this code
|
||||
* should Horizpntal flip an image
|
||||
@@ -96,7 +95,7 @@ PD_IMAGE_API void Image::FlipHorizontal() {
|
||||
}
|
||||
}
|
||||
|
||||
PD_IMAGE_API void Image::FlipVertical() {
|
||||
PD_API void Image::FlipVertical() {
|
||||
/**
|
||||
* Dont know if i am brain dead but i think this code
|
||||
* should Vertical flip an image
|
||||
@@ -116,7 +115,7 @@ PD_IMAGE_API void Image::FlipVertical() {
|
||||
}
|
||||
}
|
||||
|
||||
PD_IMAGE_API void Image::Convert(Image::Ref img, Image::Format dst) {
|
||||
PD_API void Image::Convert(Image::Ref img, Image::Format dst) {
|
||||
if (img->pFmt == dst) {
|
||||
return;
|
||||
} else if (img->pFmt == Image::RGB && dst == Image::BGR) {
|
||||
@@ -163,7 +162,7 @@ PD_IMAGE_API void Image::Convert(Image::Ref img, Image::Format dst) {
|
||||
}
|
||||
}
|
||||
|
||||
PD_IMAGE_API int Image::Fmt2Bpp(Format fmt) {
|
||||
PD_API int Image::Fmt2Bpp(Format fmt) {
|
||||
switch (fmt) {
|
||||
case RGBA:
|
||||
case ABGR:
|
||||
@@ -183,9 +182,9 @@ PD_IMAGE_API int Image::Fmt2Bpp(Format fmt) {
|
||||
}
|
||||
}
|
||||
|
||||
PD_IMAGE_API void Image::ReTile(Image::Ref img,
|
||||
std::function<u32(int x, int y, int w)> src,
|
||||
std::function<u32(int x, int y, int w)> dst) {
|
||||
PD_API void Image::ReTile(Image::Ref img,
|
||||
std::function<u32(int x, int y, int w)> src,
|
||||
std::function<u32(int x, int y, int w)> dst) {
|
||||
std::vector<PD::u8> cpy = img->pBuffer;
|
||||
/** could use fmt here but for 565 that woulnt work as it is not supported by
|
||||
* file loading where fmt is used */
|
||||
|
||||
@@ -29,7 +29,7 @@ SOFTWARE.
|
||||
|
||||
namespace PD {
|
||||
namespace ImgBlur {
|
||||
PD_IMAGE_API std::vector<float> GaussianKernel(int r, float si) {
|
||||
PD_API std::vector<float> GaussianKernel(int r, float si) {
|
||||
/// Define radius as r to be shorter
|
||||
int size = 2 * r + 1;
|
||||
std::vector<float> kernel(size);
|
||||
@@ -45,15 +45,13 @@ PD_IMAGE_API std::vector<float> GaussianKernel(int r, float si) {
|
||||
}
|
||||
return kernel;
|
||||
}
|
||||
PD_IMAGE_API void GaussianBlur(std::vector<u8>& buf, int w, int h, float radius,
|
||||
float si,
|
||||
std::function<int(int, int, int)> idxfn) {
|
||||
PD_API void GaussianBlur(std::vector<u8>& buf, int w, int h, float radius,
|
||||
float si, std::function<int(int, int, int)> idxfn) {
|
||||
GaussianBlur(buf.data(), w, h, 4, radius, si, idxfn);
|
||||
}
|
||||
|
||||
PD_IMAGE_API void GaussianBlur(void* buf, int w, int h, int bpp, float radius,
|
||||
float si,
|
||||
std::function<int(int, int, int)> idxfn) {
|
||||
PD_API void GaussianBlur(void* buf, int w, int h, int bpp, float radius,
|
||||
float si, std::function<int(int, int, int)> idxfn) {
|
||||
if (bpp != 4 && bpp != 3) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ SOFTWARE.
|
||||
|
||||
namespace PD::ImgConvert {
|
||||
|
||||
PD_IMAGE_API void RGB24toRGBA32(std::vector<u8>& out, const std::vector<u8>& in,
|
||||
const int& w, const int& h) {
|
||||
PD_API void RGB24toRGBA32(std::vector<u8>& out, const std::vector<u8>& in,
|
||||
const int& w, const int& h) {
|
||||
// Converts RGB24 to RGBA32
|
||||
for (int y = 0; y < h; y++) {
|
||||
for (int x = 0; x < w; x++) {
|
||||
@@ -40,8 +40,8 @@ PD_IMAGE_API void RGB24toRGBA32(std::vector<u8>& out, const std::vector<u8>& in,
|
||||
}
|
||||
}
|
||||
|
||||
PD_IMAGE_API void RGB32toRGBA24(std::vector<u8>& out, const std::vector<u8>& in,
|
||||
const int& w, const int& h) {
|
||||
PD_API void RGB32toRGBA24(std::vector<u8>& out, const std::vector<u8>& in,
|
||||
const int& w, const int& h) {
|
||||
// Converts RGB24 to RGBA32
|
||||
for (int y = 0; y < h; y++) {
|
||||
for (int x = 0; x < w; x++) {
|
||||
@@ -54,7 +54,7 @@ PD_IMAGE_API void RGB32toRGBA24(std::vector<u8>& out, const std::vector<u8>& in,
|
||||
}
|
||||
}
|
||||
|
||||
PD_IMAGE_API void Reverse32(std::vector<u8>& buf, const int& w, const int& h) {
|
||||
PD_API void Reverse32(std::vector<u8>& buf, const int& w, const int& h) {
|
||||
for (int x = 0; x < w; x++) {
|
||||
for (int y = 0; y < h; y++) {
|
||||
int i = y * w + x;
|
||||
@@ -68,7 +68,7 @@ PD_IMAGE_API void Reverse32(std::vector<u8>& buf, const int& w, const int& h) {
|
||||
}
|
||||
}
|
||||
|
||||
PD_IMAGE_API void ReverseBuf(std::vector<u8>& buf, size_t bpp, int w, int h) {
|
||||
PD_API void ReverseBuf(std::vector<u8>& buf, size_t bpp, int w, int h) {
|
||||
std::vector<u8> cpy = buf;
|
||||
for (int x = 0; x < w; x++) {
|
||||
for (int y = 0; y < h; y++) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <pd/lithium/command.hpp>
|
||||
|
||||
PD_LITHIUM_API PD::Li::Command::Ref PD::Li::CmdPool::NewCmd() {
|
||||
PD_API PD::Li::Command::Ref PD::Li::CmdPool::NewCmd() {
|
||||
if (pPoolIdx >= pPool.size()) {
|
||||
Resize(pPool.size() + 128);
|
||||
}
|
||||
@@ -10,18 +10,16 @@ PD_LITHIUM_API PD::Li::Command::Ref PD::Li::CmdPool::NewCmd() {
|
||||
return nu;
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void PD::Li::CmdPool::Init(size_t initial_size) {
|
||||
Resize(initial_size);
|
||||
}
|
||||
PD_API void PD::Li::CmdPool::Init(size_t initial_size) { Resize(initial_size); }
|
||||
|
||||
PD_LITHIUM_API void PD::Li::CmdPool::Deinit() {
|
||||
PD_API void PD::Li::CmdPool::Deinit() {
|
||||
for (auto it : pPool) {
|
||||
Command::Delete(it);
|
||||
}
|
||||
pPool.clear();
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void PD::Li::CmdPool::Resize(size_t nulen) {
|
||||
PD_API void PD::Li::CmdPool::Resize(size_t nulen) {
|
||||
if (nulen <= pPool.size()) {
|
||||
return; // no idea yet
|
||||
}
|
||||
@@ -32,7 +30,7 @@ PD_LITHIUM_API void PD::Li::CmdPool::Resize(size_t nulen) {
|
||||
}
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void PD::Li::CmdPool::Reset() {
|
||||
PD_API void PD::Li::CmdPool::Reset() {
|
||||
for (u32 i = 0; i < pPoolIdx; i++) {
|
||||
pPool[i]->Clear();
|
||||
}
|
||||
@@ -47,12 +45,12 @@ PD::Li::Command::Ref PD::Li::CmdPool::GetCmd(size_t idx) { return pPool[idx]; }
|
||||
size_t PD::Li::CmdPool::Size() const { return pPoolIdx; }
|
||||
size_t PD::Li::CmdPool::Cap() const { return pPool.size(); }
|
||||
|
||||
PD_LITHIUM_API void PD::Li::CmdPool::Merge(CmdPool& p) {
|
||||
PD_API void PD::Li::CmdPool::Merge(CmdPool& p) {
|
||||
Copy(p);
|
||||
p.Reset();
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void PD::Li::CmdPool::Copy(CmdPool& p) {
|
||||
PD_API void PD::Li::CmdPool::Copy(CmdPool& p) {
|
||||
if (pPoolIdx + p.Size() > pPool.size()) {
|
||||
Resize(pPoolIdx + p.Size());
|
||||
}
|
||||
@@ -64,13 +62,13 @@ PD_LITHIUM_API void PD::Li::CmdPool::Copy(CmdPool& p) {
|
||||
}
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void PD::Li::CmdPool::Sort() {
|
||||
PD_API void PD::Li::CmdPool::Sort() {
|
||||
if (pPoolIdx < 2) return;
|
||||
std::sort(begin(), end(), pTheOrder);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API bool PD::Li::CmdPool::pTheOrder(const Command::Ref& a,
|
||||
const Command::Ref& b) {
|
||||
PD_API bool PD::Li::CmdPool::pTheOrder(const Command::Ref& a,
|
||||
const Command::Ref& b) {
|
||||
if (a->Layer == b->Layer) {
|
||||
if (a->Tex == b->Tex) {
|
||||
return a->Index < b->Index;
|
||||
|
||||
78
source/lithium/drawlist.cpp
Executable file → Normal file
78
source/lithium/drawlist.cpp
Executable file → Normal file
@@ -31,19 +31,19 @@ SOFTWARE.
|
||||
|
||||
namespace PD {
|
||||
namespace Li {
|
||||
PD_LITHIUM_API DrawList::DrawList(int initial_size) {
|
||||
PD_API DrawList::DrawList(int initial_size) {
|
||||
DrawSolid();
|
||||
pPool.Init(initial_size);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API DrawList::~DrawList() {
|
||||
PD_API DrawList::~DrawList() {
|
||||
Clear();
|
||||
pPool.Deinit();
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::DrawSolid() { CurrentTex = Gfx::GetSolidTex(); }
|
||||
PD_API void DrawList::DrawSolid() { CurrentTex = Gfx::GetSolidTex(); }
|
||||
|
||||
PD_LITHIUM_API void DrawList::Clear() {
|
||||
PD_API void DrawList::Clear() {
|
||||
pNumIndices = 0;
|
||||
pNumVertices = 0;
|
||||
pPool.Reset();
|
||||
@@ -56,7 +56,7 @@ PD_LITHIUM_API void DrawList::Clear() {
|
||||
}
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::Merge(DrawList::Ref list) {
|
||||
PD_API void DrawList::Merge(DrawList::Ref list) {
|
||||
pPool.Merge(list->pPool);
|
||||
/*for (size_t i = 0; i < list->pDrawList.size(); i++) {
|
||||
pNumIndices += list->pDrawList[i]->IndexBuffer.size();
|
||||
@@ -68,11 +68,9 @@ 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_API void DrawList::Copy(DrawList::Ref list) { pPool.Copy(list->pPool); }
|
||||
|
||||
PD_LITHIUM_API void DrawList::Optimize() {
|
||||
PD_API void DrawList::Optimize() {
|
||||
#ifndef NDEBUG
|
||||
PD::TT::Scope s("Optimize");
|
||||
#endif
|
||||
@@ -88,7 +86,7 @@ PD_LITHIUM_API void DrawList::Optimize() {
|
||||
});*/
|
||||
}
|
||||
|
||||
PD_LITHIUM_API Command::Ref DrawList::GetNewCmd() {
|
||||
PD_API Command::Ref DrawList::GetNewCmd() {
|
||||
Command::Ref cmd = pPool.NewCmd();
|
||||
cmd->Index = pPool.Size() - 1;
|
||||
cmd->Tex = CurrentTex->Address;
|
||||
@@ -96,16 +94,15 @@ PD_LITHIUM_API Command::Ref DrawList::GetNewCmd() {
|
||||
return cmd;
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::pClipCmd(Command::Ref cmd) {
|
||||
PD_API void DrawList::pClipCmd(Command::Ref cmd) {
|
||||
if (!pClipRects.empty()) {
|
||||
cmd->ScissorOn = true;
|
||||
cmd->ScissorRect = ivec4(pClipRects.top());
|
||||
}
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::PathArcToN(const fvec2& c, float radius,
|
||||
float a_min, float a_max,
|
||||
int segments) {
|
||||
PD_API void DrawList::PathArcToN(const fvec2& c, float radius, float a_min,
|
||||
float a_max, int segments) {
|
||||
// Path.push_back(c);
|
||||
PathReserve(segments + 1);
|
||||
for (int i = 0; i < segments; i++) {
|
||||
@@ -114,8 +111,8 @@ PD_LITHIUM_API void DrawList::PathArcToN(const fvec2& c, float radius,
|
||||
}
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::PathFastArcToN(const fvec2& c, float r,
|
||||
float amin, float amax, int s) {
|
||||
PD_API void DrawList::PathFastArcToN(const fvec2& c, float r, float amin,
|
||||
float amax, int s) {
|
||||
/**
|
||||
* Funcion with less division overhead
|
||||
* Usefull for stuff where a lot of calculations are required
|
||||
@@ -128,7 +125,7 @@ PD_LITHIUM_API void DrawList::PathFastArcToN(const fvec2& c, float r,
|
||||
}
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::PathRect(fvec2 a, fvec2 b, float rounding) {
|
||||
PD_API void DrawList::PathRect(fvec2 a, fvec2 b, float rounding) {
|
||||
if (rounding == 0.f) {
|
||||
PathAdd(a);
|
||||
PathAdd(vec2(b.x, a.y));
|
||||
@@ -160,8 +157,7 @@ PD_LITHIUM_API void DrawList::PathRect(fvec2 a, fvec2 b, float rounding) {
|
||||
}
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::PathRectEx(fvec2 a, fvec2 b, float rounding,
|
||||
u32 flags) {
|
||||
PD_API void DrawList::PathRectEx(fvec2 a, fvec2 b, float rounding, u32 flags) {
|
||||
if (rounding == 0.f) {
|
||||
PathAdd(a);
|
||||
PathAdd(vec2(b.x, a.y));
|
||||
@@ -210,8 +206,8 @@ PD_LITHIUM_API void DrawList::PathRectEx(fvec2 a, fvec2 b, float rounding,
|
||||
}
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::DrawRect(const fvec2& pos, const fvec2& size,
|
||||
u32 color, int thickness) {
|
||||
PD_API void DrawList::DrawRect(const fvec2& pos, const fvec2& size, u32 color,
|
||||
int thickness) {
|
||||
PathRect(pos, pos + size);
|
||||
// Flags is currently hardcoded (1 = close)
|
||||
PathStroke(color, thickness, 1);
|
||||
@@ -221,26 +217,24 @@ void DrawList::DrawRectFilled(const fvec2& pos, const fvec2& size, u32 color) {
|
||||
PathFill(color);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::DrawTriangle(const fvec2& a, const fvec2& b,
|
||||
const fvec2& c, u32 color,
|
||||
int thickness) {
|
||||
PD_API void DrawList::DrawTriangle(const fvec2& a, const fvec2& b,
|
||||
const fvec2& c, u32 color, int thickness) {
|
||||
PathAdd(a);
|
||||
PathAdd(b);
|
||||
PathAdd(c);
|
||||
PathStroke(color, thickness, 1);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::DrawTriangleFilled(const fvec2& a, const fvec2& b,
|
||||
const fvec2& c, u32 color) {
|
||||
PD_API void DrawList::DrawTriangleFilled(const fvec2& a, const fvec2& b,
|
||||
const fvec2& c, u32 color) {
|
||||
PathAdd(a);
|
||||
PathAdd(b);
|
||||
PathAdd(c);
|
||||
PathFill(color);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::DrawCircle(const fvec2& center, float rad,
|
||||
u32 color, int num_segments,
|
||||
int thickness) {
|
||||
PD_API void DrawList::DrawCircle(const fvec2& center, float rad, u32 color,
|
||||
int num_segments, int thickness) {
|
||||
if (num_segments <= 0) {
|
||||
// Auto Segment
|
||||
} else {
|
||||
@@ -251,8 +245,8 @@ PD_LITHIUM_API void DrawList::DrawCircle(const fvec2& center, float rad,
|
||||
PathStroke(color, thickness, (1 << 0));
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::DrawCircleFilled(const fvec2& center, float rad,
|
||||
u32 color, int num_segments) {
|
||||
PD_API void DrawList::DrawCircleFilled(const fvec2& center, float rad,
|
||||
u32 color, int num_segments) {
|
||||
if (num_segments <= 0) {
|
||||
// Auto Segment
|
||||
} else {
|
||||
@@ -263,8 +257,8 @@ PD_LITHIUM_API void DrawList::DrawCircleFilled(const fvec2& center, float rad,
|
||||
}
|
||||
|
||||
// TODO: Don't render OOS
|
||||
PD_LITHIUM_API void DrawList::DrawPolyLine(const std::vector<fvec2>& points,
|
||||
u32 clr, u32 flags, int thickness) {
|
||||
PD_API void DrawList::DrawPolyLine(const std::vector<fvec2>& points, u32 clr,
|
||||
u32 flags, int thickness) {
|
||||
if (points.size() < 2) {
|
||||
return;
|
||||
}
|
||||
@@ -284,8 +278,8 @@ PD_LITHIUM_API void DrawList::DrawPolyLine(const std::vector<fvec2>& points,
|
||||
}
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::DrawConvexPolyFilled(
|
||||
const std::vector<fvec2>& points, u32 clr) {
|
||||
PD_API void DrawList::DrawConvexPolyFilled(const std::vector<fvec2>& points,
|
||||
u32 clr) {
|
||||
if (points.size() < 3) {
|
||||
return; // Need at least three points
|
||||
}
|
||||
@@ -293,25 +287,25 @@ PD_LITHIUM_API void DrawList::DrawConvexPolyFilled(
|
||||
Renderer::CmdConvexPolyFilled(cmd, points, clr, CurrentTex);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::DrawText(const fvec2& pos,
|
||||
const std::string& text, u32 color) {
|
||||
PD_API void DrawList::DrawText(const fvec2& pos, const std::string& text,
|
||||
u32 color) {
|
||||
if (!pCurrentFont) {
|
||||
return;
|
||||
}
|
||||
pCurrentFont->CmdTextEx(pPool, pos, color, pFontScale, text);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::DrawTextEx(const fvec2& p,
|
||||
const std::string& text, u32 color,
|
||||
LiTextFlags flags, const fvec2& box) {
|
||||
PD_API void DrawList::DrawTextEx(const fvec2& p, const std::string& text,
|
||||
u32 color, LiTextFlags flags,
|
||||
const fvec2& box) {
|
||||
if (!pCurrentFont) {
|
||||
return;
|
||||
}
|
||||
pCurrentFont->CmdTextEx(pPool, p, color, pFontScale, text, flags, box);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void DrawList::DrawLine(const fvec2& a, const fvec2& b,
|
||||
u32 color, int t) {
|
||||
PD_API void DrawList::DrawLine(const fvec2& a, const fvec2& b, u32 color,
|
||||
int t) {
|
||||
PathAdd(a);
|
||||
PathAdd(b);
|
||||
PathStroke(color, t);
|
||||
|
||||
@@ -37,7 +37,7 @@ SOFTWARE.
|
||||
|
||||
namespace PD {
|
||||
namespace Li {
|
||||
PD_LITHIUM_API void Font::LoadDefaultFont(int id, int pixel_height) {
|
||||
PD_API void Font::LoadDefaultFont(int id, int pixel_height) {
|
||||
#ifdef PD_LI_INCLUDE_FONTS
|
||||
if (id < pNumFonts) {
|
||||
auto font = pFontData[id];
|
||||
@@ -48,7 +48,7 @@ PD_LITHIUM_API void Font::LoadDefaultFont(int id, int pixel_height) {
|
||||
#endif
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void Font::LoadTTF(const std::string& path, int height) {
|
||||
PD_API void Font::LoadTTF(const std::string& path, int height) {
|
||||
/**
|
||||
* Just use LoadFile2Mem which looks way cleaner
|
||||
* and helps not having the font loading code twice
|
||||
@@ -59,15 +59,15 @@ PD_LITHIUM_API void Font::LoadTTF(const std::string& path, int height) {
|
||||
LoadTTF(font, height);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void Font::pMakeAtlas(bool final, std::vector<u8>& font_tex,
|
||||
int texszs, PD::Li::Texture::Ref tex) {
|
||||
PD_API void Font::pMakeAtlas(bool final, std::vector<u8>& font_tex, int texszs,
|
||||
PD::Li::Texture::Ref tex) {
|
||||
auto t =
|
||||
Gfx::LoadTex(font_tex, texszs, texszs, Texture::RGBA32, Texture::LINEAR);
|
||||
tex->CopyFrom(t);
|
||||
Textures.push_back(tex);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void Font::LoadTTF(const std::vector<u8>& data, int height) {
|
||||
PD_API void Font::LoadTTF(const std::vector<u8>& data, int height) {
|
||||
/**
|
||||
* Some additional Info:
|
||||
* Removed the stbtt get bitmapbox as we dont need to place
|
||||
@@ -183,7 +183,7 @@ PD_LITHIUM_API void Font::LoadTTF(const std::vector<u8>& data, int height) {
|
||||
}
|
||||
}
|
||||
|
||||
PD_LITHIUM_API Font::Codepoint& Font::GetCodepoint(u32 cp) {
|
||||
PD_API Font::Codepoint& Font::GetCodepoint(u32 cp) {
|
||||
// Check if codepoijt exist or return a static invalid one
|
||||
auto res = CodeMap.find(cp);
|
||||
if (res == CodeMap.end()) {
|
||||
@@ -194,7 +194,7 @@ PD_LITHIUM_API Font::Codepoint& Font::GetCodepoint(u32 cp) {
|
||||
return res->second;
|
||||
}
|
||||
|
||||
PD_LITHIUM_API fvec2 Font::GetTextBounds(const std::string& text, float scale) {
|
||||
PD_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();
|
||||
@@ -247,9 +247,9 @@ PD_LITHIUM_API fvec2 Font::GetTextBounds(const std::string& text, float scale) {
|
||||
return res;
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void Font::CmdTextEx(CmdPool& cmds, const fvec2& pos, u32 color,
|
||||
float scale, const std::string& text,
|
||||
LiTextFlags flags, const fvec2& box) {
|
||||
PD_API void Font::CmdTextEx(CmdPool& cmds, const fvec2& pos, u32 color,
|
||||
float scale, const std::string& text,
|
||||
LiTextFlags flags, const fvec2& box) {
|
||||
fvec2 off;
|
||||
float cfs = (DefaultPixelHeight * scale) / (float)PixelHeight;
|
||||
float lh = (float)PixelHeight * cfs;
|
||||
@@ -336,9 +336,8 @@ PD_LITHIUM_API void Font::CmdTextEx(CmdPool& cmds, const fvec2& pos, u32 color,
|
||||
}
|
||||
}
|
||||
|
||||
PD_LITHIUM_API std::string Font::pWrapText(const std::string& txt, float scale,
|
||||
const PD::fvec2& max,
|
||||
PD::fvec2& dim) {
|
||||
PD_API std::string Font::pWrapText(const std::string& txt, float scale,
|
||||
const PD::fvec2& max, PD::fvec2& dim) {
|
||||
u32 id = PD::FNV1A32(txt);
|
||||
if (pTMS.find(id) != pTMS.end()) {
|
||||
if (pTMS[id].Text.size()) {
|
||||
@@ -373,9 +372,8 @@ PD_LITHIUM_API std::string Font::pWrapText(const std::string& txt, float scale,
|
||||
return ret;
|
||||
}
|
||||
|
||||
PD_LITHIUM_API std::string Font::pShortText(const std::string& txt, float scale,
|
||||
const PD::fvec2& max,
|
||||
PD::fvec2& dim) {
|
||||
PD_API std::string Font::pShortText(const std::string& txt, float scale,
|
||||
const PD::fvec2& max, PD::fvec2& dim) {
|
||||
u32 id = PD::FNV1A32(txt);
|
||||
if (pTMS.find(id) != pTMS.end()) {
|
||||
if (pTMS[id].Text.size()) {
|
||||
@@ -417,7 +415,7 @@ PD_LITHIUM_API std::string Font::pShortText(const std::string& txt, float scale,
|
||||
return ret;
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void Font::CleanupTMS() {
|
||||
PD_API void Font::CleanupTMS() {
|
||||
u64 t = PD::OS::GetTime();
|
||||
for (auto it = pTMS.begin(); it != pTMS.end();) {
|
||||
if (t - it->second.TimeStamp > 1000) {
|
||||
|
||||
35
source/lithium/renderer.cpp
Executable file → Normal file
35
source/lithium/renderer.cpp
Executable file → Normal file
@@ -26,34 +26,33 @@ SOFTWARE.
|
||||
|
||||
namespace PD {
|
||||
namespace Li {
|
||||
PD_LITHIUM_API bool Renderer::InBox(const fvec2& pos, const fvec2& szs,
|
||||
const fvec4& rect) {
|
||||
PD_API bool Renderer::InBox(const fvec2& pos, const fvec2& szs,
|
||||
const fvec4& rect) {
|
||||
return (pos.x + szs.x >= rect.x && pos.y + szs.y >= rect.y &&
|
||||
pos.x <= rect.z && pos.y <= rect.w);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API bool Renderer::InBox(const fvec2& pos, const fvec4& rect) {
|
||||
PD_API bool Renderer::InBox(const fvec2& pos, const fvec4& rect) {
|
||||
return (pos.x > rect.x && pos.x < rect.x + rect.z && pos.y > rect.y &&
|
||||
pos.y < rect.y + rect.w);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API bool Renderer::InBox(const fvec2& alpha, const fvec2& bravo,
|
||||
const fvec2& charlie, const fvec4& rect) {
|
||||
PD_API bool Renderer::InBox(const fvec2& alpha, const fvec2& bravo,
|
||||
const fvec2& charlie, const fvec4& rect) {
|
||||
return ((alpha.x < rect.z && bravo.x < rect.z && charlie.x < rect.z) ||
|
||||
(alpha.y < rect.w && bravo.y < rect.w && charlie.y < rect.w) ||
|
||||
(alpha.x > 0 && bravo.x > 0 && charlie.x > 0) ||
|
||||
(alpha.y > 0 && bravo.y > 0 && charlie.y > 0));
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void Renderer::RotateCorner(fvec2& pos, float sinus,
|
||||
float cosinus) {
|
||||
PD_API void Renderer::RotateCorner(fvec2& pos, float sinus, float cosinus) {
|
||||
float x = pos.x * cosinus - pos.y * sinus;
|
||||
float y = pos.y * cosinus - pos.x * sinus;
|
||||
pos = fvec2(x, y);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API Rect Renderer::PrimRect(const fvec2& pos, const fvec2& size,
|
||||
float angle) {
|
||||
PD_API Rect Renderer::PrimRect(const fvec2& pos, const fvec2& size,
|
||||
float angle) {
|
||||
fvec2 c = size * 0.5f; // Center
|
||||
fvec2 corner[4] = {
|
||||
fvec2(-c.x, -c.y),
|
||||
@@ -76,8 +75,7 @@ PD_LITHIUM_API Rect Renderer::PrimRect(const fvec2& pos, const fvec2& size,
|
||||
corner[3] + pos + c);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API Rect Renderer::PrimLine(const fvec2& a, const fvec2& b,
|
||||
int thickness) {
|
||||
PD_API Rect Renderer::PrimLine(const fvec2& a, const fvec2& b, int thickness) {
|
||||
// Using the vec maths api makes the code as short as it is
|
||||
vec2 dir = a - b;
|
||||
float len = dir.Len();
|
||||
@@ -88,8 +86,8 @@ PD_LITHIUM_API Rect Renderer::PrimLine(const fvec2& a, const fvec2& b,
|
||||
return Rect(a + off, b + off, a - off, b - off);
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void Renderer::CmdQuad(Command::Ref cmd, const Rect& quad,
|
||||
const Rect& uv, u32 color) {
|
||||
PD_API void Renderer::CmdQuad(Command::Ref cmd, const Rect& quad,
|
||||
const Rect& uv, u32 color) {
|
||||
cmd->AddIdx(0).AddIdx(1).AddIdx(2);
|
||||
cmd->AddIdx(0).AddIdx(2).AddIdx(3);
|
||||
cmd->AddVtx(Vertex(quad.BotRight(), uv.BotRight(), color));
|
||||
@@ -98,9 +96,8 @@ PD_LITHIUM_API void Renderer::CmdQuad(Command::Ref cmd, const Rect& quad,
|
||||
cmd->AddVtx(Vertex(quad.BotLeft(), uv.BotLeft(), color));
|
||||
}
|
||||
|
||||
PD_LITHIUM_API void Renderer::CmdTriangle(Command::Ref cmd, const fvec2 a,
|
||||
const fvec2 b, const fvec2 c,
|
||||
u32 clr) {
|
||||
PD_API void Renderer::CmdTriangle(Command::Ref cmd, const fvec2 a,
|
||||
const fvec2 b, const fvec2 c, u32 clr) {
|
||||
cmd->AddIdx(2).AddIdx(1).AddIdx(0);
|
||||
cmd->AddVtx(Vertex(a, vec2(0.f, 1.f), clr));
|
||||
cmd->AddVtx(Vertex(b, vec2(1.f, 1.f), clr));
|
||||
@@ -110,9 +107,9 @@ PD_LITHIUM_API void Renderer::CmdTriangle(Command::Ref cmd, const fvec2 a,
|
||||
// TODO: Don't render OOS (Probably make it with a define as it
|
||||
// would probably be faster to render out of screen than checking if
|
||||
// it could be skipped)
|
||||
PD_LITHIUM_API void Renderer::CmdConvexPolyFilled(
|
||||
Command::Ref cmd, const std::vector<fvec2>& points, u32 clr,
|
||||
Texture::Ref tex) {
|
||||
PD_API void Renderer::CmdConvexPolyFilled(Command::Ref cmd,
|
||||
const std::vector<fvec2>& points,
|
||||
u32 clr, Texture::Ref tex) {
|
||||
if (points.size() < 3 || tex == nullptr) {
|
||||
return; // Need at least three points
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
28
source/ui7/layout.cpp
Executable file → Normal 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);
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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"));
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user