Let's just use 1 PD_API header
This commit is contained in:
@@ -66,6 +66,7 @@ set(PD_SOURCES
|
|||||||
|
|
||||||
if(${PD_BUILD_SHARED})
|
if(${PD_BUILD_SHARED})
|
||||||
add_library(palladium SHARED ${PD_SOURCES})
|
add_library(palladium SHARED ${PD_SOURCES})
|
||||||
|
target_compile_definitions(palladium PRIVATE -DPD_BUILD_SHARED)
|
||||||
else()
|
else()
|
||||||
add_library(palladium STATIC ${PD_SOURCES})
|
add_library(palladium STATIC ${PD_SOURCES})
|
||||||
endif()
|
endif()
|
||||||
@@ -86,8 +87,6 @@ file(GLOB_RECURSE PD_FMTFILES CONFIGURE_DEPENDS
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/include/pd/ui7/*.hpp
|
${CMAKE_CURRENT_SOURCE_DIR}/include/pd/ui7/*.hpp
|
||||||
)
|
)
|
||||||
|
|
||||||
message(STATUS "Files to format: ${PD_FMTFILES}")
|
|
||||||
|
|
||||||
add_custom_target(pd-clang-format
|
add_custom_target(pd-clang-format
|
||||||
COMMAND ${CLANG_FORMAT} --style=file -i ${PD_FMTFILES}
|
COMMAND ${CLANG_FORMAT} --style=file -i ${PD_FMTFILES}
|
||||||
COMMENT "Formatting Project Sources"
|
COMMENT "Formatting Project Sources"
|
||||||
|
|||||||
@@ -36,12 +36,12 @@ namespace BitUtil {
|
|||||||
* @param v 32 bit unsigned int
|
* @param v 32 bit unsigned int
|
||||||
* @return true if its a single bit number
|
* @return true if its a single bit number
|
||||||
*/
|
*/
|
||||||
PD_CORE_API bool IsSingleBit(u32 v);
|
PD_API bool IsSingleBit(u32 v);
|
||||||
/**
|
/**
|
||||||
* Get the Next Power of two Number
|
* Get the Next Power of two Number
|
||||||
* @param v Current Number
|
* @param v Current Number
|
||||||
* @return Next Number thats a Pow of 2
|
* @return Next Number thats a Pow of 2
|
||||||
*/
|
*/
|
||||||
PD_CORE_API u32 GetPow2(u32 v);
|
PD_API u32 GetPow2(u32 v);
|
||||||
} // namespace BitUtil
|
} // namespace BitUtil
|
||||||
} // namespace PD
|
} // namespace PD
|
||||||
@@ -27,7 +27,7 @@ SOFTWARE.
|
|||||||
#include <pd/core/strings.hpp>
|
#include <pd/core/strings.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
class PD_CORE_API Color {
|
class PD_API Color {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Default Constructor (all variables are set to 0)
|
* Default Constructor (all variables are set to 0)
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ SOFTWARE.
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
/** Dynamic Lib loading */
|
/** Dynamic Lib loading */
|
||||||
#include <pd/core/pd_p_api.hpp>
|
#include <pd/pd_p_api.hpp>
|
||||||
|
|
||||||
/** Memory Management */
|
/** Memory Management */
|
||||||
|
|
||||||
|
|||||||
@@ -35,28 +35,28 @@ namespace IO {
|
|||||||
* @param path Path to the File
|
* @param path Path to the File
|
||||||
* @return 8Bit FileBuffer
|
* @return 8Bit FileBuffer
|
||||||
*/
|
*/
|
||||||
PD_CORE_API std::vector<u8> LoadFile2Mem(const std::string& path);
|
PD_API std::vector<u8> LoadFile2Mem(const std::string& path);
|
||||||
/**
|
/**
|
||||||
* Load a File into a std::string
|
* Load a File into a std::string
|
||||||
* @param path Path to the File
|
* @param path Path to the File
|
||||||
* @return std::string file content
|
* @return std::string file content
|
||||||
*/
|
*/
|
||||||
PD_CORE_API std::string LoadFile2Str(const std::string& path);
|
PD_API std::string LoadFile2Str(const std::string& path);
|
||||||
/**
|
/**
|
||||||
* Hash a 8Bit Memory Buffer
|
* Hash a 8Bit Memory Buffer
|
||||||
* @param data 8Bit input Buffer
|
* @param data 8Bit input Buffer
|
||||||
* @return 32Bit Hash
|
* @return 32Bit Hash
|
||||||
*/
|
*/
|
||||||
PD_CORE_API u32 HashMemory(const std::vector<u8>& data);
|
PD_API u32 HashMemory(const std::vector<u8>& data);
|
||||||
/**
|
/**
|
||||||
* Function to decrompress RLE buffer
|
* Function to decrompress RLE buffer
|
||||||
* @param data Data buffer to decompress
|
* @param data Data buffer to decompress
|
||||||
*/
|
*/
|
||||||
PD_CORE_API void DecompressRLE(std::vector<u8>& data);
|
PD_API void DecompressRLE(std::vector<u8>& data);
|
||||||
/**
|
/**
|
||||||
* Function to compress data with RLE Algorithm
|
* Function to compress data with RLE Algorithm
|
||||||
* @param data Data buf
|
* @param data Data buf
|
||||||
*/
|
*/
|
||||||
PD_CORE_API void CompressRLE(std::vector<u8>& data);
|
PD_API void CompressRLE(std::vector<u8>& data);
|
||||||
} // namespace IO
|
} // namespace IO
|
||||||
} // namespace PD
|
} // namespace PD
|
||||||
@@ -41,7 +41,7 @@ constexpr float Radians(float v) { return v * (Numbers::Tau / 360.0f); }
|
|||||||
* @note That this is not a full Matrix Library
|
* @note That this is not a full Matrix Library
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct PD_CORE_API Mat4 {
|
struct PD_API Mat4 {
|
||||||
std::array<float, 16> m;
|
std::array<float, 16> m;
|
||||||
constexpr Mat4() : m{} {}
|
constexpr Mat4() : m{} {}
|
||||||
constexpr static Mat4 Diagonal(float x, float y, float z, float w) {
|
constexpr static Mat4 Diagonal(float x, float y, float z, float w) {
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
/*
|
|
||||||
MIT License
|
|
||||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** Generated with ppam */
|
|
||||||
|
|
||||||
#ifdef _WIN32 // Windows (MSVC Tested)
|
|
||||||
#ifdef PD_CORE_BUILD_SHARED
|
|
||||||
#define PD_CORE_API __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
#define PD_CORE_API __declspec(dllimport)
|
|
||||||
#endif
|
|
||||||
#elif defined(__APPLE__) // macOS (untested yet)
|
|
||||||
#ifdef PD_CORE_BUILD_SHARED
|
|
||||||
#define PD_CORE_API __attribute__((visibility("default")))
|
|
||||||
#else
|
|
||||||
#define PD_CORE_API
|
|
||||||
#endif
|
|
||||||
#elif defined(__linux__) // Linux (untested yet)
|
|
||||||
#ifdef PD_CORE_BUILD_SHARED
|
|
||||||
#define PD_CORE_API __attribute__((visibility("default")))
|
|
||||||
#else
|
|
||||||
#define PD_CORE_API
|
|
||||||
#endif
|
|
||||||
#elif defined(__3DS__) // 3ds Specific
|
|
||||||
// Only Static supported
|
|
||||||
#define PD_CORE_API
|
|
||||||
#else
|
|
||||||
#define PD_CORE_API
|
|
||||||
#endif
|
|
||||||
20
include/pd/core/strings.hpp
Executable file → Normal file
20
include/pd/core/strings.hpp
Executable file → Normal file
@@ -43,47 +43,47 @@ constexpr int HexChar2Int(char c) {
|
|||||||
* @param exts List of Extensions to check for
|
* @param exts List of Extensions to check for
|
||||||
* @return true if one of the extensions is found in the String
|
* @return true if one of the extensions is found in the String
|
||||||
*/
|
*/
|
||||||
PD_CORE_API bool StringEndsWith(const std::string& str,
|
PD_API bool StringEndsWith(const std::string& str,
|
||||||
const std::vector<std::string>& exts);
|
const std::vector<std::string>& exts);
|
||||||
/**
|
/**
|
||||||
* Function to Create a wstring of a string
|
* Function to Create a wstring of a string
|
||||||
* @param s Input String to Convert
|
* @param s Input String to Convert
|
||||||
* @return Result wstring
|
* @return Result wstring
|
||||||
* @note Returns Empty if it has an error
|
* @note Returns Empty if it has an error
|
||||||
*/
|
*/
|
||||||
PD_CORE_API std::wstring MakeWstring(const std::string& s);
|
PD_API std::wstring MakeWstring(const std::string& s);
|
||||||
/**
|
/**
|
||||||
* Generate a Formatted String by an Nanoseconds Input
|
* Generate a Formatted String by an Nanoseconds Input
|
||||||
* @param nanos Nanoseconds Input
|
* @param nanos Nanoseconds Input
|
||||||
* @return Result String
|
* @return Result String
|
||||||
*/
|
*/
|
||||||
PD_CORE_API const std::string FormatNanos(unsigned long long nanos);
|
PD_API const std::string FormatNanos(unsigned long long nanos);
|
||||||
/**
|
/**
|
||||||
* Generate a Formatted String by an Milliseconds Input
|
* Generate a Formatted String by an Milliseconds Input
|
||||||
* @param millis Milliseconds Input
|
* @param millis Milliseconds Input
|
||||||
* @return Result String
|
* @return Result String
|
||||||
*/
|
*/
|
||||||
PD_CORE_API const std::string FormatMillis(unsigned long long millis);
|
PD_API const std::string FormatMillis(unsigned long long millis);
|
||||||
/**
|
/**
|
||||||
* Create a formatted String by an input bytes value
|
* Create a formatted String by an input bytes value
|
||||||
* @param bytes value in bytes
|
* @param bytes value in bytes
|
||||||
* @result Formatted String for example `2.5MB`
|
* @result Formatted String for example `2.5MB`
|
||||||
*/
|
*/
|
||||||
PD_CORE_API const std::string FormatBytes(unsigned long long bytes);
|
PD_API const std::string FormatBytes(unsigned long long bytes);
|
||||||
/**
|
/**
|
||||||
* Extract the Filename out of a Path
|
* Extract the Filename out of a Path
|
||||||
* @param path Path to extract from
|
* @param path Path to extract from
|
||||||
* @param saperators Path Split Chars
|
* @param saperators Path Split Chars
|
||||||
* @return extracted filename
|
* @return extracted filename
|
||||||
*/
|
*/
|
||||||
PD_CORE_API const std::string GetFileName(
|
PD_API const std::string GetFileName(const std::string& path,
|
||||||
const std::string& path, const std::string& saperators = "/\\");
|
const std::string& saperators = "/\\");
|
||||||
/**
|
/**
|
||||||
* Remove Extension from a Path / Filename
|
* Remove Extension from a Path / Filename
|
||||||
* @param path Input Path
|
* @param path Input Path
|
||||||
* @return Path without Extension
|
* @return Path without Extension
|
||||||
*/
|
*/
|
||||||
PD_CORE_API const std::string PathRemoveExtension(const std::string& path);
|
PD_API const std::string PathRemoveExtension(const std::string& path);
|
||||||
/**
|
/**
|
||||||
* Function to Convert a Type to a hex value
|
* Function to Convert a Type to a hex value
|
||||||
* @tparam T Type
|
* @tparam T Type
|
||||||
@@ -101,7 +101,7 @@ inline const std::string ToHex(const T& v) {
|
|||||||
* @param s String to hash
|
* @param s String to hash
|
||||||
* @return 32Bit Hash
|
* @return 32Bit Hash
|
||||||
*/
|
*/
|
||||||
PD_CORE_API u32 FastHash(const std::string& s);
|
PD_API u32 FastHash(const std::string& s);
|
||||||
/**
|
/**
|
||||||
* Function to Generate a Compiler Name and Version String
|
* Function to Generate a Compiler Name and Version String
|
||||||
* Based on their Macros
|
* Based on their Macros
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace PD {
|
|||||||
/**
|
/**
|
||||||
* Timer class
|
* Timer class
|
||||||
*/
|
*/
|
||||||
class PD_CORE_API Timer {
|
class PD_API Timer {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
|||||||
@@ -218,12 +218,12 @@ class Res {
|
|||||||
* Begin a Trace
|
* Begin a Trace
|
||||||
* @param id Name of the Trace
|
* @param id Name of the Trace
|
||||||
*/
|
*/
|
||||||
PD_CORE_API void Beg(const std::string& id);
|
PD_API void Beg(const std::string& id);
|
||||||
/**
|
/**
|
||||||
* End a Trace
|
* End a Trace
|
||||||
* @param id Name of the Trace
|
* @param id Name of the Trace
|
||||||
*/
|
*/
|
||||||
PD_CORE_API void End(const std::string& id);
|
PD_API void End(const std::string& id);
|
||||||
/**
|
/**
|
||||||
* Collect Start end end of the trace by tracking
|
* Collect Start end end of the trace by tracking
|
||||||
* when the Scope object goes out of scope
|
* when the Scope object goes out of scope
|
||||||
|
|||||||
@@ -25,10 +25,10 @@ SOFTWARE.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/core/core.hpp>
|
#include <pd/core/core.hpp>
|
||||||
#include <pd/image/pd_p_api.hpp>
|
#include <pd/pd_p_api.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
class PD_IMAGE_API Image {
|
class PD_API Image {
|
||||||
public:
|
public:
|
||||||
enum Format {
|
enum Format {
|
||||||
RGBA, // bpp == 4
|
RGBA, // bpp == 4
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ SOFTWARE.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/core/core.hpp>
|
#include <pd/core/core.hpp>
|
||||||
#include <pd/image/pd_p_api.hpp>
|
#include <pd/pd_p_api.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
/**
|
/**
|
||||||
@@ -38,7 +38,7 @@ namespace ImgBlur {
|
|||||||
* @param si sigma value to use
|
* @param si sigma value to use
|
||||||
* @return list of kernel values
|
* @return list of kernel values
|
||||||
*/
|
*/
|
||||||
PD_IMAGE_API std::vector<float> GaussianKernel(int radius, float si);
|
PD_API std::vector<float> GaussianKernel(int radius, float si);
|
||||||
/**
|
/**
|
||||||
* Gaussian Blur for basic Image Buffer
|
* Gaussian Blur for basic Image Buffer
|
||||||
* @param buf Image Buffer (unsigned char)
|
* @param buf Image Buffer (unsigned char)
|
||||||
@@ -48,7 +48,7 @@ PD_IMAGE_API std::vector<float> GaussianKernel(int radius, float si);
|
|||||||
* @param si Blur sigma
|
* @param si Blur sigma
|
||||||
* @param idxfn Indexing function
|
* @param idxfn Indexing function
|
||||||
*/
|
*/
|
||||||
PD_IMAGE_API void GaussianBlur(
|
PD_API void GaussianBlur(
|
||||||
std::vector<u8>& buf, int w, int h, float radius, float si,
|
std::vector<u8>& buf, int w, int h, float radius, float si,
|
||||||
std::function<int(int, int, int)> idxfn = [](int x, int y, int w) -> int {
|
std::function<int(int, int, int)> idxfn = [](int x, int y, int w) -> int {
|
||||||
return y * w + x;
|
return y * w + x;
|
||||||
@@ -63,7 +63,7 @@ PD_IMAGE_API void GaussianBlur(
|
|||||||
* @param si Blur sigma
|
* @param si Blur sigma
|
||||||
* @param idxfn Indexing function
|
* @param idxfn Indexing function
|
||||||
*/
|
*/
|
||||||
PD_IMAGE_API void GaussianBlur(
|
PD_API void GaussianBlur(
|
||||||
void* buf, int w, int h, int bpp, float radius, float si,
|
void* buf, int w, int h, int bpp, float radius, float si,
|
||||||
std::function<int(int, int, int)> idxfn = [](int x, int y, int w) -> int {
|
std::function<int(int, int, int)> idxfn = [](int x, int y, int w) -> int {
|
||||||
return y * w + x;
|
return y * w + x;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include <pd/core/core.hpp>
|
#include <pd/core/core.hpp>
|
||||||
#include <pd/image/image.hpp>
|
#include <pd/image/image.hpp>
|
||||||
#include <pd/image/pd_p_api.hpp>
|
#include <pd/pd_p_api.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
/**
|
/**
|
||||||
@@ -41,10 +41,10 @@ namespace ImgConvert {
|
|||||||
* @param w width of the image
|
* @param w width of the image
|
||||||
* @param h height of the image
|
* @param h height of the image
|
||||||
*/
|
*/
|
||||||
PD_IMAGE_API
|
PD_API
|
||||||
void RGB24toRGBA32(std::vector<PD::u8>& out, const std::vector<u8>& in,
|
void RGB24toRGBA32(std::vector<PD::u8>& out, const std::vector<u8>& in,
|
||||||
const int& w, const int& h);
|
const int& w, const int& h);
|
||||||
PD_IMAGE_API
|
PD_API
|
||||||
void RGB32toRGBA24(std::vector<u8>& out, const std::vector<u8>& in,
|
void RGB32toRGBA24(std::vector<u8>& out, const std::vector<u8>& in,
|
||||||
const int& w, const int& h);
|
const int& w, const int& h);
|
||||||
/**
|
/**
|
||||||
@@ -53,7 +53,7 @@ void RGB32toRGBA24(std::vector<u8>& out, const std::vector<u8>& in,
|
|||||||
* @param w width
|
* @param w width
|
||||||
* @param h height
|
* @param h height
|
||||||
*/
|
*/
|
||||||
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);
|
||||||
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);
|
||||||
} // namespace ImgConvert
|
} // namespace ImgConvert
|
||||||
} // namespace PD
|
} // namespace PD
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
/*
|
|
||||||
MIT License
|
|
||||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** Generated with ppam */
|
|
||||||
|
|
||||||
#ifdef _WIN32 // Windows (MSVC Tested)
|
|
||||||
#ifdef PD_IMAGE_BUILD_SHARED
|
|
||||||
#define PD_IMAGE_API __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
#define PD_IMAGE_API __declspec(dllimport)
|
|
||||||
#endif
|
|
||||||
#elif defined(__APPLE__) // macOS (untested yet)
|
|
||||||
#ifdef PD_IMAGE_BUILD_SHARED
|
|
||||||
#define PD_IMAGE_API __attribute__((visibility("default")))
|
|
||||||
#else
|
|
||||||
#define PD_IMAGE_API
|
|
||||||
#endif
|
|
||||||
#elif defined(__linux__) // Linux (untested yet)
|
|
||||||
#ifdef PD_IMAGE_BUILD_SHARED
|
|
||||||
#define PD_IMAGE_API __attribute__((visibility("default")))
|
|
||||||
#else
|
|
||||||
#define PD_IMAGE_API
|
|
||||||
#endif
|
|
||||||
#elif defined(__3DS__) // 3ds Specific
|
|
||||||
// Only Static supported
|
|
||||||
#define PD_IMAGE_API
|
|
||||||
#else
|
|
||||||
#define PD_IMAGE_API
|
|
||||||
#endif
|
|
||||||
4
include/pd/lithium/command.hpp
Executable file → Normal file
4
include/pd/lithium/command.hpp
Executable file → Normal file
@@ -24,9 +24,9 @@ SOFTWARE.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/core/core.hpp>
|
#include <pd/core/core.hpp>
|
||||||
#include <pd/lithium/pd_p_api.hpp>
|
|
||||||
#include <pd/lithium/texture.hpp>
|
#include <pd/lithium/texture.hpp>
|
||||||
#include <pd/lithium/vertex.hpp>
|
#include <pd/lithium/vertex.hpp>
|
||||||
|
#include <pd/pd_p_api.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace Li {
|
namespace Li {
|
||||||
@@ -72,7 +72,7 @@ class Command {
|
|||||||
TexAddress Tex;
|
TexAddress Tex;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PD_LITHIUM_API CmdPool {
|
class PD_API CmdPool {
|
||||||
public:
|
public:
|
||||||
CmdPool() {}
|
CmdPool() {}
|
||||||
~CmdPool() {}
|
~CmdPool() {}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include <pd/lithium/command.hpp>
|
#include <pd/lithium/command.hpp>
|
||||||
#include <pd/lithium/font.hpp>
|
#include <pd/lithium/font.hpp>
|
||||||
#include <pd/lithium/pd_p_api.hpp>
|
#include <pd/pd_p_api.hpp>
|
||||||
|
|
||||||
/** Path Rect Flags */
|
/** Path Rect Flags */
|
||||||
using LiPathRectFlags = PD::u32;
|
using LiPathRectFlags = PD::u32;
|
||||||
@@ -46,7 +46,7 @@ enum LiPathRectFlags_ : PD::u32 {
|
|||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace Li {
|
namespace Li {
|
||||||
class PD_LITHIUM_API DrawList {
|
class PD_API DrawList {
|
||||||
public:
|
public:
|
||||||
DrawList(int initial_size = 64);
|
DrawList(int initial_size = 64);
|
||||||
~DrawList();
|
~DrawList();
|
||||||
|
|||||||
4
include/pd/lithium/font.hpp
Executable file → Normal file
4
include/pd/lithium/font.hpp
Executable file → Normal file
@@ -26,9 +26,9 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include <pd/core/core.hpp>
|
#include <pd/core/core.hpp>
|
||||||
#include <pd/lithium/command.hpp>
|
#include <pd/lithium/command.hpp>
|
||||||
#include <pd/lithium/pd_p_api.hpp>
|
|
||||||
#include <pd/lithium/rect.hpp>
|
#include <pd/lithium/rect.hpp>
|
||||||
#include <pd/lithium/texture.hpp>
|
#include <pd/lithium/texture.hpp>
|
||||||
|
#include <pd/pd_p_api.hpp>
|
||||||
|
|
||||||
using LiTextFlags = PD::u32;
|
using LiTextFlags = PD::u32;
|
||||||
enum LiTextFlags_ {
|
enum LiTextFlags_ {
|
||||||
@@ -44,7 +44,7 @@ enum LiTextFlags_ {
|
|||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace Li {
|
namespace Li {
|
||||||
class PD_LITHIUM_API Font {
|
class PD_API Font {
|
||||||
public:
|
public:
|
||||||
/** Codepoint Data holder */
|
/** Codepoint Data holder */
|
||||||
struct Codepoint {
|
struct Codepoint {
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
/*
|
|
||||||
MIT License
|
|
||||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** Generated with ppam */
|
|
||||||
|
|
||||||
#ifdef _WIN32 // Windows (MSVC Tested)
|
|
||||||
#ifdef PD_LITHIUM_BUILD_SHARED
|
|
||||||
#define PD_LITHIUM_API __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
#define PD_LITHIUM_API __declspec(dllimport)
|
|
||||||
#endif
|
|
||||||
#elif defined(__APPLE__) // macOS (untested yet)
|
|
||||||
#ifdef PD_LITHIUM_BUILD_SHARED
|
|
||||||
#define PD_LITHIUM_API __attribute__((visibility("default")))
|
|
||||||
#else
|
|
||||||
#define PD_LITHIUM_API
|
|
||||||
#endif
|
|
||||||
#elif defined(__linux__) // Linux (untested yet)
|
|
||||||
#ifdef PD_LITHIUM_BUILD_SHARED
|
|
||||||
#define PD_LITHIUM_API __attribute__((visibility("default")))
|
|
||||||
#else
|
|
||||||
#define PD_LITHIUM_API
|
|
||||||
#endif
|
|
||||||
#elif defined(__3DS__) // 3ds Specific
|
|
||||||
// Only Static supported
|
|
||||||
#define PD_LITHIUM_API
|
|
||||||
#else
|
|
||||||
#define PD_LITHIUM_API
|
|
||||||
#endif
|
|
||||||
4
include/pd/lithium/renderer.hpp
Executable file → Normal file
4
include/pd/lithium/renderer.hpp
Executable file → Normal file
@@ -25,15 +25,15 @@ SOFTWARE.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/drivers/drivers.hpp>
|
#include <pd/drivers/drivers.hpp>
|
||||||
#include <pd/lithium/pd_p_api.hpp>
|
|
||||||
#include <pd/lithium/rect.hpp>
|
#include <pd/lithium/rect.hpp>
|
||||||
|
#include <pd/pd_p_api.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace Li {
|
namespace Li {
|
||||||
/**
|
/**
|
||||||
* Static Class Render Setup Functions
|
* Static Class Render Setup Functions
|
||||||
*/
|
*/
|
||||||
class PD_LITHIUM_API Renderer {
|
class PD_API Renderer {
|
||||||
public:
|
public:
|
||||||
Renderer() = default;
|
Renderer() = default;
|
||||||
~Renderer() = default;
|
~Renderer() = default;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
MIT License
|
MIT License
|
||||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
@@ -26,26 +26,26 @@ SOFTWARE.
|
|||||||
/** Generated with ppam */
|
/** Generated with ppam */
|
||||||
|
|
||||||
#ifdef _WIN32 // Windows (MSVC Tested)
|
#ifdef _WIN32 // Windows (MSVC Tested)
|
||||||
#ifdef PD_UI7_BUILD_SHARED
|
#ifdef PD_BUILD_SHARED
|
||||||
#define PD_UI7_API __declspec(dllexport)
|
#define PD_API __declspec(dllexport)
|
||||||
#else
|
#else
|
||||||
#define PD_UI7_API __declspec(dllimport)
|
#define PD_API __declspec(dllimport)
|
||||||
#endif
|
#endif
|
||||||
#elif defined(__APPLE__) // macOS (untested yet)
|
#elif defined(__APPLE__) // macOS (untested yet)
|
||||||
#ifdef PD_UI7_BUILD_SHARED
|
#ifdef PD_BUILD_SHARED
|
||||||
#define PD_UI7_API __attribute__((visibility("default")))
|
#define PD_API __attribute__((visibility("default")))
|
||||||
#else
|
#else
|
||||||
#define PD_UI7_API
|
#define PD_API
|
||||||
#endif
|
#endif
|
||||||
#elif defined(__linux__) // Linux (untested yet)
|
#elif defined(__linux__) // Linux (untested yet)
|
||||||
#ifdef PD_UI7_BUILD_SHARED
|
#ifdef PD_BUILD_SHARED
|
||||||
#define PD_UI7_API __attribute__((visibility("default")))
|
#define PD_API __attribute__((visibility("default")))
|
||||||
#else
|
#else
|
||||||
#define PD_UI7_API
|
#define PD_API
|
||||||
#endif
|
#endif
|
||||||
#elif defined(__3DS__) // 3ds Specific
|
#elif defined(__3DS__) // 3ds Specific
|
||||||
// Only Static supported
|
// Only Static supported
|
||||||
#define PD_UI7_API
|
#define PD_API
|
||||||
#else
|
#else
|
||||||
#define PD_UI7_API
|
#define PD_API
|
||||||
#endif
|
#endif
|
||||||
@@ -35,7 +35,7 @@ namespace UI7 {
|
|||||||
* This only means that InPressed is responding the info in
|
* This only means that InPressed is responding the info in
|
||||||
* the next frame
|
* the next frame
|
||||||
*/
|
*/
|
||||||
class PD_UI7_API Button : public Container {
|
class PD_API Button : public Container {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Button Object constructor
|
* Button Object constructor
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace UI7 {
|
|||||||
* Context::Update while the visual update is done
|
* Context::Update while the visual update is done
|
||||||
* during the Update
|
* during the Update
|
||||||
*/
|
*/
|
||||||
class PD_UI7_API Checkbox : public Container {
|
class PD_API Checkbox : public Container {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Constructor for Checkbox Object
|
* Constructor for Checkbox Object
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace UI7 {
|
|||||||
/**
|
/**
|
||||||
* Color Editor (Creating a PopUP when clicking)
|
* Color Editor (Creating a PopUP when clicking)
|
||||||
*/
|
*/
|
||||||
class PD_UI7_API ColorEdit : public Container {
|
class PD_API ColorEdit : public Container {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
|||||||
4
include/pd/ui7/container/container.hpp
Executable file → Normal file
4
include/pd/ui7/container/container.hpp
Executable file → Normal file
@@ -24,8 +24,8 @@ SOFTWARE.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/core/core.hpp>
|
#include <pd/core/core.hpp>
|
||||||
|
#include <pd/pd_p_api.hpp>
|
||||||
#include <pd/ui7/io.hpp>
|
#include <pd/ui7/io.hpp>
|
||||||
#include <pd/ui7/pd_p_api.hpp>
|
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace UI7 {
|
namespace UI7 {
|
||||||
@@ -33,7 +33,7 @@ namespace UI7 {
|
|||||||
* Container base class all Objects are based on
|
* Container base class all Objects are based on
|
||||||
* @note this class can be used to create custom Objects as well
|
* @note this class can be used to create custom Objects as well
|
||||||
*/
|
*/
|
||||||
class PD_UI7_API Container {
|
class PD_API Container {
|
||||||
public:
|
public:
|
||||||
Container() = default;
|
Container() = default;
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace UI7 {
|
|||||||
* and modifys these by moving left or right when dragging
|
* and modifys these by moving left or right when dragging
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class PD_UI7_API DragData : public Container {
|
class PD_API DragData : public Container {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace UI7 {
|
|||||||
* This only means that InPressed is responding the info in
|
* This only means that InPressed is responding the info in
|
||||||
* the next frame
|
* the next frame
|
||||||
*/
|
*/
|
||||||
class PD_UI7_API DynObj : public Container {
|
class PD_API DynObj : public Container {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Button Object constructor
|
* Button Object constructor
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace UI7 {
|
|||||||
/**
|
/**
|
||||||
* Image Object
|
* Image Object
|
||||||
*/
|
*/
|
||||||
class PD_UI7_API Image : public Container {
|
class PD_API Image : public Container {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Constructor for the Image Object
|
* Constructor for the Image Object
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace UI7 {
|
|||||||
/**
|
/**
|
||||||
* Label [Text] Object
|
* Label [Text] Object
|
||||||
*/
|
*/
|
||||||
class PD_UI7_API Label : public Container {
|
class PD_API Label : public Container {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Constructor for Label Object
|
* Constructor for Label Object
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace UI7 {
|
|||||||
* and modifys these by moving left or right when dragging
|
* and modifys these by moving left or right when dragging
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class PD_UI7_API Slider : public Container {
|
class PD_API Slider : public Container {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
|||||||
2
include/pd/ui7/input_api.hpp
Executable file → Normal file
2
include/pd/ui7/input_api.hpp
Executable file → Normal file
@@ -26,8 +26,8 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include <pd/core/core.hpp>
|
#include <pd/core/core.hpp>
|
||||||
#include <pd/lithium/lithium.hpp>
|
#include <pd/lithium/lithium.hpp>
|
||||||
|
#include <pd/pd_p_api.hpp>
|
||||||
#include <pd/ui7/id.hpp>
|
#include <pd/ui7/id.hpp>
|
||||||
#include <pd/ui7/pd_p_api.hpp>
|
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace UI7 {
|
namespace UI7 {
|
||||||
|
|||||||
4
include/pd/ui7/io.hpp
Executable file → Normal file
4
include/pd/ui7/io.hpp
Executable file → Normal file
@@ -25,14 +25,14 @@ SOFTWARE.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/core/core.hpp>
|
#include <pd/core/core.hpp>
|
||||||
|
#include <pd/pd_p_api.hpp>
|
||||||
#include <pd/ui7/input_api.hpp>
|
#include <pd/ui7/input_api.hpp>
|
||||||
#include <pd/ui7/pd_p_api.hpp>
|
|
||||||
#include <pd/ui7/theme.hpp>
|
#include <pd/ui7/theme.hpp>
|
||||||
#include <pd/ui7/viewport.hpp>
|
#include <pd/ui7/viewport.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace UI7 {
|
namespace UI7 {
|
||||||
class PD_UI7_API IO {
|
class PD_API IO {
|
||||||
public:
|
public:
|
||||||
IO() {
|
IO() {
|
||||||
Time = Timer::New();
|
Time = Timer::New();
|
||||||
|
|||||||
@@ -25,17 +25,17 @@ SOFTWARE.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/core/core.hpp>
|
#include <pd/core/core.hpp>
|
||||||
|
#include <pd/pd_p_api.hpp>
|
||||||
#include <pd/ui7/container/container.hpp>
|
#include <pd/ui7/container/container.hpp>
|
||||||
#include <pd/ui7/container/dragdata.hpp>
|
#include <pd/ui7/container/dragdata.hpp>
|
||||||
#include <pd/ui7/container/slider.hpp>
|
#include <pd/ui7/container/slider.hpp>
|
||||||
#include <pd/ui7/flags.hpp>
|
#include <pd/ui7/flags.hpp>
|
||||||
#include <pd/ui7/input_api.hpp>
|
#include <pd/ui7/input_api.hpp>
|
||||||
#include <pd/ui7/pd_p_api.hpp>
|
|
||||||
#include <pd/ui7/theme.hpp>
|
#include <pd/ui7/theme.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace UI7 {
|
namespace UI7 {
|
||||||
class PD_UI7_API Layout {
|
class PD_API Layout {
|
||||||
public:
|
public:
|
||||||
Layout(const ID& id, IO::Ref io) : ID(id) {
|
Layout(const ID& id, IO::Ref io) : ID(id) {
|
||||||
this->IO = io;
|
this->IO = io;
|
||||||
|
|||||||
@@ -25,16 +25,16 @@ SOFTWARE.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/core/core.hpp>
|
#include <pd/core/core.hpp>
|
||||||
|
#include <pd/pd_p_api.hpp>
|
||||||
#include <pd/ui7/containers.hpp>
|
#include <pd/ui7/containers.hpp>
|
||||||
#include <pd/ui7/io.hpp>
|
#include <pd/ui7/io.hpp>
|
||||||
#include <pd/ui7/layout.hpp>
|
#include <pd/ui7/layout.hpp>
|
||||||
#include <pd/ui7/pd_p_api.hpp>
|
|
||||||
|
|
||||||
#include "pd/ui7/container/dragdata.hpp"
|
#include "pd/ui7/container/dragdata.hpp"
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace UI7 {
|
namespace UI7 {
|
||||||
class PD_UI7_API Menu {
|
class PD_API Menu {
|
||||||
public:
|
public:
|
||||||
Menu(const UI7::ID& id, UI7::IO::Ref pIO);
|
Menu(const UI7::ID& id, UI7::IO::Ref pIO);
|
||||||
~Menu() {}
|
~Menu() {}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ SOFTWARE.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/core/core.hpp>
|
#include <pd/core/core.hpp>
|
||||||
#include <pd/ui7/pd_p_api.hpp>
|
#include <pd/pd_p_api.hpp>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Using this to support 32bit color values as well as
|
* Using this to support 32bit color values as well as
|
||||||
@@ -55,7 +55,7 @@ enum UI7Color_ {
|
|||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace UI7 {
|
namespace UI7 {
|
||||||
class PD_UI7_API Theme {
|
class PD_API Theme {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Default Constructor Setting up the Default theme
|
* Default Constructor Setting up the Default theme
|
||||||
|
|||||||
6
include/pd/ui7/ui7.hpp
Executable file → Normal file
6
include/pd/ui7/ui7.hpp
Executable file → Normal file
@@ -25,9 +25,9 @@ SOFTWARE.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/core/core.hpp>
|
#include <pd/core/core.hpp>
|
||||||
|
#include <pd/pd_p_api.hpp>
|
||||||
#include <pd/ui7/io.hpp>
|
#include <pd/ui7/io.hpp>
|
||||||
#include <pd/ui7/menu.hpp>
|
#include <pd/ui7/menu.hpp>
|
||||||
#include <pd/ui7/pd_p_api.hpp>
|
|
||||||
|
|
||||||
#include "pd/ui7/flags.hpp"
|
#include "pd/ui7/flags.hpp"
|
||||||
|
|
||||||
@@ -46,9 +46,9 @@ namespace UI7 {
|
|||||||
* @param show_build Show build num (mostly unused)
|
* @param show_build Show build num (mostly unused)
|
||||||
* @return Version String (1.0.0-1 for example)
|
* @return Version String (1.0.0-1 for example)
|
||||||
*/
|
*/
|
||||||
PD_UI7_API std::string GetVersion(bool show_build = false);
|
PD_API std::string GetVersion(bool show_build = false);
|
||||||
/** Base Context for UI7 */
|
/** Base Context for UI7 */
|
||||||
class PD_UI7_API Context {
|
class PD_API Context {
|
||||||
public:
|
public:
|
||||||
Context() { pIO = IO::New(); }
|
Context() { pIO = IO::New(); }
|
||||||
~Context() = default;
|
~Context() = default;
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ SOFTWARE.
|
|||||||
#include <pd/core/bit_util.hpp>
|
#include <pd/core/bit_util.hpp>
|
||||||
|
|
||||||
namespace PD::BitUtil {
|
namespace PD::BitUtil {
|
||||||
PD_CORE_API bool IsSingleBit(u32 v) { return v && !(v & (v - 1)); }
|
PD_API bool IsSingleBit(u32 v) { return v && !(v & (v - 1)); }
|
||||||
PD_CORE_API u32 GetPow2(u32 v) {
|
PD_API u32 GetPow2(u32 v) {
|
||||||
v--;
|
v--;
|
||||||
v |= v >> 1;
|
v |= v >> 1;
|
||||||
v |= v >> 2;
|
v |= v >> 2;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ SOFTWARE.
|
|||||||
#include <pd/core/color.hpp>
|
#include <pd/core/color.hpp>
|
||||||
|
|
||||||
namespace PD {
|
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...) */
|
/** Need to int cast (so it is used as num and not char...) */
|
||||||
std::stringstream s;
|
std::stringstream s;
|
||||||
s << "#";
|
s << "#";
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace IO {
|
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);
|
std::ifstream iff(path, std::ios::binary);
|
||||||
if (!iff) {
|
if (!iff) {
|
||||||
return std::vector<u8>();
|
return std::vector<u8>();
|
||||||
@@ -39,7 +39,7 @@ PD_CORE_API std::vector<u8> LoadFile2Mem(const std::string& path) {
|
|||||||
return res;
|
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);
|
std::ifstream iff(path, std::ios::binary);
|
||||||
if (!iff) {
|
if (!iff) {
|
||||||
return "";
|
return "";
|
||||||
@@ -53,7 +53,7 @@ PD_CORE_API std::string LoadFile2Str(const std::string& path) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_CORE_API u32 HashMemory(const std::vector<u8>& data) {
|
PD_API u32 HashMemory(const std::vector<u8>& data) {
|
||||||
u32 hash = 4477;
|
u32 hash = 4477;
|
||||||
for (auto& it : data) {
|
for (auto& it : data) {
|
||||||
hash = (hash * 33) + it;
|
hash = (hash * 33) + it;
|
||||||
@@ -61,7 +61,7 @@ PD_CORE_API u32 HashMemory(const std::vector<u8>& data) {
|
|||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_CORE_API void DecompressRLE(std::vector<u8>& data) {
|
PD_API void DecompressRLE(std::vector<u8>& data) {
|
||||||
if ((data.size() % 2) != 0) {
|
if ((data.size() % 2) != 0) {
|
||||||
return;
|
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()) {
|
if (data.empty()) {
|
||||||
/** No exceptions enabled :( */
|
/** No exceptions enabled :( */
|
||||||
return;
|
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>
|
#include <pd/core/mat.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
PD_CORE_API Mat4 Mat4::RotateX(float a) {
|
PD_API Mat4 Mat4::RotateX(float a) {
|
||||||
float c = std::cos(a);
|
float c = std::cos(a);
|
||||||
float s = std::sin(a);
|
float s = std::sin(a);
|
||||||
Mat4 ret = Identity();
|
Mat4 ret = Identity();
|
||||||
@@ -36,7 +36,7 @@ PD_CORE_API Mat4 Mat4::RotateX(float a) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_CORE_API Mat4 Mat4::RotateY(float a) {
|
PD_API Mat4 Mat4::RotateY(float a) {
|
||||||
float c = std::cos(a);
|
float c = std::cos(a);
|
||||||
float s = std::sin(a);
|
float s = std::sin(a);
|
||||||
Mat4 ret = Identity();
|
Mat4 ret = Identity();
|
||||||
@@ -47,7 +47,7 @@ PD_CORE_API Mat4 Mat4::RotateY(float a) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_CORE_API Mat4 Mat4::RotateZ(float a) {
|
PD_API Mat4 Mat4::RotateZ(float a) {
|
||||||
float c = std::cos(a);
|
float c = std::cos(a);
|
||||||
float s = std::sin(a);
|
float s = std::sin(a);
|
||||||
Mat4 ret = Identity();
|
Mat4 ret = Identity();
|
||||||
@@ -58,7 +58,7 @@ PD_CORE_API Mat4 Mat4::RotateZ(float a) {
|
|||||||
return ret;
|
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 s = std::sin(a);
|
||||||
float c = std::cos(a);
|
float c = std::cos(a);
|
||||||
float t = 1.f - c;
|
float t = 1.f - c;
|
||||||
@@ -81,7 +81,7 @@ PD_CORE_API Mat4 Mat4::Rotate(fvec3 axis, float a) {
|
|||||||
return ret;
|
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);
|
float _fov = std::tan(fov / 2.f);
|
||||||
Mat4 ret;
|
Mat4 ret;
|
||||||
ret(0, 0) = 1.f / (aspect * _fov);
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_CORE_API Mat4 Mat4::LookAt(const fvec3& pos, const fvec3& center,
|
PD_API Mat4 Mat4::LookAt(const fvec3& pos, const fvec3& center,
|
||||||
const fvec3& up) {
|
const fvec3& up) {
|
||||||
auto f = fvec3(center - pos).Normalize();
|
auto f = fvec3(center - pos).Normalize();
|
||||||
auto s = f.Cross(up).Normalize();
|
auto s = f.Cross(up).Normalize();
|
||||||
auto u = s.Cross(f);
|
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>
|
#include <pd/core/strings.hpp>
|
||||||
|
|
||||||
namespace PD::Strings {
|
namespace PD::Strings {
|
||||||
PD_CORE_API bool StringEndsWith(const std::string& str,
|
PD_API bool StringEndsWith(const std::string& str,
|
||||||
const std::vector<std::string>& exts) {
|
const std::vector<std::string>& exts) {
|
||||||
// Changed order to not do an substr on empty string
|
// Changed order to not do an substr on empty string
|
||||||
if (str.empty()) {
|
if (str.empty()) {
|
||||||
return false;
|
return false;
|
||||||
@@ -44,7 +44,7 @@ PD_CORE_API bool StringEndsWith(const std::string& str,
|
|||||||
return false;
|
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 :(
|
// Manually convert to wstring as they removed wstring_convert :(
|
||||||
std::wstring result;
|
std::wstring result;
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
@@ -85,7 +85,7 @@ PD_CORE_API std::wstring MakeWstring(const std::string& s) {
|
|||||||
return result;
|
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
|
// Based on some code of my minecraft plugins
|
||||||
if (nanos < 1000) {
|
if (nanos < 1000) {
|
||||||
return std::format("{}ns", nanos);
|
return std::format("{}ns", nanos);
|
||||||
@@ -106,7 +106,7 @@ PD_CORE_API const std::string FormatNanos(unsigned long long nanos) {
|
|||||||
return "";
|
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
|
// Original Code can be found in some of my mv plugins
|
||||||
if (millis < 1000) {
|
if (millis < 1000) {
|
||||||
return std::format("{}ms", millis);
|
return std::format("{}ms", millis);
|
||||||
@@ -121,7 +121,7 @@ PD_CORE_API const std::string FormatMillis(unsigned long long millis) {
|
|||||||
return "";
|
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 = {
|
static const std::vector<std::string> endings = {
|
||||||
"B", "KB", "MB", "GB", "TB", "Unk",
|
"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]);
|
return std::format("{:.1f} {}", b, endings[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_CORE_API const std::string GetFileName(const std::string& path,
|
PD_API const std::string GetFileName(const std::string& path,
|
||||||
const std::string& saperators) {
|
const std::string& saperators) {
|
||||||
auto pos = path.find_last_of(saperators);
|
auto pos = path.find_last_of(saperators);
|
||||||
if (pos != path.npos) {
|
if (pos != path.npos) {
|
||||||
return path.substr(pos + 1);
|
return path.substr(pos + 1);
|
||||||
@@ -147,7 +147,7 @@ PD_CORE_API const std::string GetFileName(const std::string& path,
|
|||||||
return 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('.');
|
auto pos = path.find_last_of('.');
|
||||||
if (pos != path.npos) {
|
if (pos != path.npos) {
|
||||||
return path.substr(0, pos);
|
return path.substr(0, pos);
|
||||||
@@ -156,7 +156,7 @@ PD_CORE_API const std::string PathRemoveExtension(const std::string& path) {
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_CORE_API u32 FastHash(const std::string& s) {
|
PD_API u32 FastHash(const std::string& s) {
|
||||||
u32 hash = 5381;
|
u32 hash = 5381;
|
||||||
for (auto& it : s) {
|
for (auto& it : s) {
|
||||||
hash = (hash * 33) + static_cast<u8>(it);
|
hash = (hash * 33) + static_cast<u8>(it);
|
||||||
|
|||||||
@@ -26,25 +26,25 @@ SOFTWARE.
|
|||||||
#include <pd/drivers/drivers.hpp>
|
#include <pd/drivers/drivers.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
PD_CORE_API Timer::Timer(bool autostart) {
|
PD_API Timer::Timer(bool autostart) {
|
||||||
pIsRunning = autostart;
|
pIsRunning = autostart;
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_CORE_API void Timer::Reset() {
|
PD_API void Timer::Reset() {
|
||||||
pStart = OS::GetTime();
|
pStart = OS::GetTime();
|
||||||
pNow = pStart;
|
pNow = pStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_CORE_API void Timer::Update() {
|
PD_API void Timer::Update() {
|
||||||
if (pIsRunning) {
|
if (pIsRunning) {
|
||||||
pNow = OS::GetTime();
|
pNow = OS::GetTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_CORE_API void Timer::Pause() { pIsRunning = false; }
|
PD_API void Timer::Pause() { pIsRunning = false; }
|
||||||
PD_CORE_API void Timer::Rseume() { pIsRunning = true; }
|
PD_API void Timer::Rseume() { pIsRunning = true; }
|
||||||
PD_CORE_API bool Timer::IsRunning() const { return pIsRunning; }
|
PD_API bool Timer::IsRunning() const { return pIsRunning; }
|
||||||
PD_CORE_API u64 Timer::Get() { return pNow - pStart; }
|
PD_API u64 Timer::Get() { return pNow - pStart; }
|
||||||
PD_CORE_API double Timer::GetSeconds() { return (double)Get() / 1000.0; }
|
PD_API double Timer::GetSeconds() { return (double)Get() / 1000.0; }
|
||||||
} // namespace PD
|
} // namespace PD
|
||||||
@@ -25,12 +25,12 @@ SOFTWARE.
|
|||||||
#include <pd/drivers/drivers.hpp>
|
#include <pd/drivers/drivers.hpp>
|
||||||
|
|
||||||
namespace PD::TT {
|
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);
|
auto trace = OS::GetTraceRef(id);
|
||||||
trace->SetStart(PD::OS::GetNanoTime());
|
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);
|
auto trace = OS::GetTraceRef(id);
|
||||||
trace->SetEnd(PD::OS::GetNanoTime());
|
trace->SetEnd(PD::OS::GetNanoTime());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ SOFTWARE.
|
|||||||
#include <pd/image/img_convert.hpp>
|
#include <pd/image/img_convert.hpp>
|
||||||
|
|
||||||
namespace PD {
|
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);
|
u8* img = pdi_load(path.c_str(), &pWidth, &pHeight, &fmt, 4);
|
||||||
if (fmt == 3) {
|
if (fmt == 3) {
|
||||||
pdi_image_free(img);
|
pdi_image_free(img);
|
||||||
@@ -47,7 +47,7 @@ PD_IMAGE_API void Image::Load(const std::string& path) {
|
|||||||
pdi_image_free(img);
|
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 =
|
u8* img =
|
||||||
pdi_load_from_memory(buf.data(), buf.size(), &pWidth, &pHeight, &fmt, 4);
|
pdi_load_from_memory(buf.data(), buf.size(), &pWidth, &pHeight, &fmt, 4);
|
||||||
if (fmt == 3) {
|
if (fmt == 3) {
|
||||||
@@ -63,8 +63,7 @@ PD_IMAGE_API void Image::Load(const std::vector<u8>& buf) {
|
|||||||
pFmt = RGBA;
|
pFmt = RGBA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PD_IMAGE_API void Image::Copy(const std::vector<u8>& buf, int w, int h,
|
PD_API void Image::Copy(const std::vector<u8>& buf, int w, int h, int bpp) {
|
||||||
int bpp) {
|
|
||||||
this->fmt = bpp;
|
this->fmt = bpp;
|
||||||
if (buf.size() != (size_t)w * h * bpp) {
|
if (buf.size() != (size_t)w * h * bpp) {
|
||||||
// Size Error
|
// 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
|
* Dont know if i am brain dead but i think this code
|
||||||
* should Horizpntal flip an image
|
* 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
|
* Dont know if i am brain dead but i think this code
|
||||||
* should Vertical flip an image
|
* 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) {
|
if (img->pFmt == dst) {
|
||||||
return;
|
return;
|
||||||
} else if (img->pFmt == Image::RGB && dst == Image::BGR) {
|
} 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) {
|
switch (fmt) {
|
||||||
case RGBA:
|
case RGBA:
|
||||||
case ABGR:
|
case ABGR:
|
||||||
@@ -183,9 +182,9 @@ PD_IMAGE_API int Image::Fmt2Bpp(Format fmt) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_IMAGE_API void Image::ReTile(Image::Ref img,
|
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)> src,
|
||||||
std::function<u32(int x, int y, int w)> dst) {
|
std::function<u32(int x, int y, int w)> dst) {
|
||||||
std::vector<PD::u8> cpy = img->pBuffer;
|
std::vector<PD::u8> cpy = img->pBuffer;
|
||||||
/** could use fmt here but for 565 that woulnt work as it is not supported by
|
/** could use fmt here but for 565 that woulnt work as it is not supported by
|
||||||
* file loading where fmt is used */
|
* file loading where fmt is used */
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace ImgBlur {
|
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
|
/// Define radius as r to be shorter
|
||||||
int size = 2 * r + 1;
|
int size = 2 * r + 1;
|
||||||
std::vector<float> kernel(size);
|
std::vector<float> kernel(size);
|
||||||
@@ -45,15 +45,13 @@ PD_IMAGE_API std::vector<float> GaussianKernel(int r, float si) {
|
|||||||
}
|
}
|
||||||
return kernel;
|
return kernel;
|
||||||
}
|
}
|
||||||
PD_IMAGE_API void GaussianBlur(std::vector<u8>& buf, int w, int h, float radius,
|
PD_API void GaussianBlur(std::vector<u8>& buf, int w, int h, float radius,
|
||||||
float si,
|
float si, std::function<int(int, int, int)> idxfn) {
|
||||||
std::function<int(int, int, int)> idxfn) {
|
|
||||||
GaussianBlur(buf.data(), w, h, 4, radius, si, 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,
|
PD_API void GaussianBlur(void* buf, int w, int h, int bpp, float radius,
|
||||||
float si,
|
float si, std::function<int(int, int, int)> idxfn) {
|
||||||
std::function<int(int, int, int)> idxfn) {
|
|
||||||
if (bpp != 4 && bpp != 3) {
|
if (bpp != 4 && bpp != 3) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ SOFTWARE.
|
|||||||
|
|
||||||
namespace PD::ImgConvert {
|
namespace PD::ImgConvert {
|
||||||
|
|
||||||
PD_IMAGE_API void RGB24toRGBA32(std::vector<u8>& out, const std::vector<u8>& in,
|
PD_API void RGB24toRGBA32(std::vector<u8>& out, const std::vector<u8>& in,
|
||||||
const int& w, const int& h) {
|
const int& w, const int& h) {
|
||||||
// Converts RGB24 to RGBA32
|
// Converts RGB24 to RGBA32
|
||||||
for (int y = 0; y < h; y++) {
|
for (int y = 0; y < h; y++) {
|
||||||
for (int x = 0; x < w; x++) {
|
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,
|
PD_API void RGB32toRGBA24(std::vector<u8>& out, const std::vector<u8>& in,
|
||||||
const int& w, const int& h) {
|
const int& w, const int& h) {
|
||||||
// Converts RGB24 to RGBA32
|
// Converts RGB24 to RGBA32
|
||||||
for (int y = 0; y < h; y++) {
|
for (int y = 0; y < h; y++) {
|
||||||
for (int x = 0; x < w; x++) {
|
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 x = 0; x < w; x++) {
|
||||||
for (int y = 0; y < h; y++) {
|
for (int y = 0; y < h; y++) {
|
||||||
int i = y * w + x;
|
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;
|
std::vector<u8> cpy = buf;
|
||||||
for (int x = 0; x < w; x++) {
|
for (int x = 0; x < w; x++) {
|
||||||
for (int y = 0; y < h; y++) {
|
for (int y = 0; y < h; y++) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <pd/lithium/command.hpp>
|
#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()) {
|
if (pPoolIdx >= pPool.size()) {
|
||||||
Resize(pPool.size() + 128);
|
Resize(pPool.size() + 128);
|
||||||
}
|
}
|
||||||
@@ -10,18 +10,16 @@ PD_LITHIUM_API PD::Li::Command::Ref PD::Li::CmdPool::NewCmd() {
|
|||||||
return nu;
|
return nu;
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_LITHIUM_API void PD::Li::CmdPool::Init(size_t initial_size) {
|
PD_API void PD::Li::CmdPool::Init(size_t initial_size) { Resize(initial_size); }
|
||||||
Resize(initial_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
PD_LITHIUM_API void PD::Li::CmdPool::Deinit() {
|
PD_API void PD::Li::CmdPool::Deinit() {
|
||||||
for (auto it : pPool) {
|
for (auto it : pPool) {
|
||||||
Command::Delete(it);
|
Command::Delete(it);
|
||||||
}
|
}
|
||||||
pPool.clear();
|
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()) {
|
if (nulen <= pPool.size()) {
|
||||||
return; // no idea yet
|
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++) {
|
for (u32 i = 0; i < pPoolIdx; i++) {
|
||||||
pPool[i]->Clear();
|
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::Size() const { return pPoolIdx; }
|
||||||
size_t PD::Li::CmdPool::Cap() const { return pPool.size(); }
|
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);
|
Copy(p);
|
||||||
p.Reset();
|
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()) {
|
if (pPoolIdx + p.Size() > pPool.size()) {
|
||||||
Resize(pPoolIdx + p.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;
|
if (pPoolIdx < 2) return;
|
||||||
std::sort(begin(), end(), pTheOrder);
|
std::sort(begin(), end(), pTheOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_LITHIUM_API bool PD::Li::CmdPool::pTheOrder(const Command::Ref& a,
|
PD_API bool PD::Li::CmdPool::pTheOrder(const Command::Ref& a,
|
||||||
const Command::Ref& b) {
|
const Command::Ref& b) {
|
||||||
if (a->Layer == b->Layer) {
|
if (a->Layer == b->Layer) {
|
||||||
if (a->Tex == b->Tex) {
|
if (a->Tex == b->Tex) {
|
||||||
return a->Index < b->Index;
|
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 PD {
|
||||||
namespace Li {
|
namespace Li {
|
||||||
PD_LITHIUM_API DrawList::DrawList(int initial_size) {
|
PD_API DrawList::DrawList(int initial_size) {
|
||||||
DrawSolid();
|
DrawSolid();
|
||||||
pPool.Init(initial_size);
|
pPool.Init(initial_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_LITHIUM_API DrawList::~DrawList() {
|
PD_API DrawList::~DrawList() {
|
||||||
Clear();
|
Clear();
|
||||||
pPool.Deinit();
|
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;
|
pNumIndices = 0;
|
||||||
pNumVertices = 0;
|
pNumVertices = 0;
|
||||||
pPool.Reset();
|
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);
|
pPool.Merge(list->pPool);
|
||||||
/*for (size_t i = 0; i < list->pDrawList.size(); i++) {
|
/*for (size_t i = 0; i < list->pDrawList.size(); i++) {
|
||||||
pNumIndices += list->pDrawList[i]->IndexBuffer.size();
|
pNumIndices += list->pDrawList[i]->IndexBuffer.size();
|
||||||
@@ -68,11 +68,9 @@ PD_LITHIUM_API void DrawList::Merge(DrawList::Ref list) {
|
|||||||
list->Clear();
|
list->Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_LITHIUM_API void DrawList::Copy(DrawList::Ref list) {
|
PD_API void DrawList::Copy(DrawList::Ref list) { pPool.Copy(list->pPool); }
|
||||||
pPool.Copy(list->pPool);
|
|
||||||
}
|
|
||||||
|
|
||||||
PD_LITHIUM_API void DrawList::Optimize() {
|
PD_API void DrawList::Optimize() {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
PD::TT::Scope s("Optimize");
|
PD::TT::Scope s("Optimize");
|
||||||
#endif
|
#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();
|
Command::Ref cmd = pPool.NewCmd();
|
||||||
cmd->Index = pPool.Size() - 1;
|
cmd->Index = pPool.Size() - 1;
|
||||||
cmd->Tex = CurrentTex->Address;
|
cmd->Tex = CurrentTex->Address;
|
||||||
@@ -96,16 +94,15 @@ PD_LITHIUM_API Command::Ref DrawList::GetNewCmd() {
|
|||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_LITHIUM_API void DrawList::pClipCmd(Command::Ref cmd) {
|
PD_API void DrawList::pClipCmd(Command::Ref cmd) {
|
||||||
if (!pClipRects.empty()) {
|
if (!pClipRects.empty()) {
|
||||||
cmd->ScissorOn = true;
|
cmd->ScissorOn = true;
|
||||||
cmd->ScissorRect = ivec4(pClipRects.top());
|
cmd->ScissorRect = ivec4(pClipRects.top());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_LITHIUM_API void DrawList::PathArcToN(const fvec2& c, float radius,
|
PD_API void DrawList::PathArcToN(const fvec2& c, float radius, float a_min,
|
||||||
float a_min, float a_max,
|
float a_max, int segments) {
|
||||||
int segments) {
|
|
||||||
// Path.push_back(c);
|
// Path.push_back(c);
|
||||||
PathReserve(segments + 1);
|
PathReserve(segments + 1);
|
||||||
for (int i = 0; i < segments; i++) {
|
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,
|
PD_API void DrawList::PathFastArcToN(const fvec2& c, float r, float amin,
|
||||||
float amin, float amax, int s) {
|
float amax, int s) {
|
||||||
/**
|
/**
|
||||||
* Funcion with less division overhead
|
* Funcion with less division overhead
|
||||||
* Usefull for stuff where a lot of calculations are required
|
* 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) {
|
if (rounding == 0.f) {
|
||||||
PathAdd(a);
|
PathAdd(a);
|
||||||
PathAdd(vec2(b.x, a.y));
|
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,
|
PD_API void DrawList::PathRectEx(fvec2 a, fvec2 b, float rounding, u32 flags) {
|
||||||
u32 flags) {
|
|
||||||
if (rounding == 0.f) {
|
if (rounding == 0.f) {
|
||||||
PathAdd(a);
|
PathAdd(a);
|
||||||
PathAdd(vec2(b.x, a.y));
|
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,
|
PD_API void DrawList::DrawRect(const fvec2& pos, const fvec2& size, u32 color,
|
||||||
u32 color, int thickness) {
|
int thickness) {
|
||||||
PathRect(pos, pos + size);
|
PathRect(pos, pos + size);
|
||||||
// Flags is currently hardcoded (1 = close)
|
// Flags is currently hardcoded (1 = close)
|
||||||
PathStroke(color, thickness, 1);
|
PathStroke(color, thickness, 1);
|
||||||
@@ -221,26 +217,24 @@ void DrawList::DrawRectFilled(const fvec2& pos, const fvec2& size, u32 color) {
|
|||||||
PathFill(color);
|
PathFill(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_LITHIUM_API void DrawList::DrawTriangle(const fvec2& a, const fvec2& b,
|
PD_API void DrawList::DrawTriangle(const fvec2& a, const fvec2& b,
|
||||||
const fvec2& c, u32 color,
|
const fvec2& c, u32 color, int thickness) {
|
||||||
int thickness) {
|
|
||||||
PathAdd(a);
|
PathAdd(a);
|
||||||
PathAdd(b);
|
PathAdd(b);
|
||||||
PathAdd(c);
|
PathAdd(c);
|
||||||
PathStroke(color, thickness, 1);
|
PathStroke(color, thickness, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_LITHIUM_API void DrawList::DrawTriangleFilled(const fvec2& a, const fvec2& b,
|
PD_API void DrawList::DrawTriangleFilled(const fvec2& a, const fvec2& b,
|
||||||
const fvec2& c, u32 color) {
|
const fvec2& c, u32 color) {
|
||||||
PathAdd(a);
|
PathAdd(a);
|
||||||
PathAdd(b);
|
PathAdd(b);
|
||||||
PathAdd(c);
|
PathAdd(c);
|
||||||
PathFill(color);
|
PathFill(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_LITHIUM_API void DrawList::DrawCircle(const fvec2& center, float rad,
|
PD_API void DrawList::DrawCircle(const fvec2& center, float rad, u32 color,
|
||||||
u32 color, int num_segments,
|
int num_segments, int thickness) {
|
||||||
int thickness) {
|
|
||||||
if (num_segments <= 0) {
|
if (num_segments <= 0) {
|
||||||
// Auto Segment
|
// Auto Segment
|
||||||
} else {
|
} else {
|
||||||
@@ -251,8 +245,8 @@ PD_LITHIUM_API void DrawList::DrawCircle(const fvec2& center, float rad,
|
|||||||
PathStroke(color, thickness, (1 << 0));
|
PathStroke(color, thickness, (1 << 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_LITHIUM_API void DrawList::DrawCircleFilled(const fvec2& center, float rad,
|
PD_API void DrawList::DrawCircleFilled(const fvec2& center, float rad,
|
||||||
u32 color, int num_segments) {
|
u32 color, int num_segments) {
|
||||||
if (num_segments <= 0) {
|
if (num_segments <= 0) {
|
||||||
// Auto Segment
|
// Auto Segment
|
||||||
} else {
|
} else {
|
||||||
@@ -263,8 +257,8 @@ PD_LITHIUM_API void DrawList::DrawCircleFilled(const fvec2& center, float rad,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Don't render OOS
|
// TODO: Don't render OOS
|
||||||
PD_LITHIUM_API void DrawList::DrawPolyLine(const std::vector<fvec2>& points,
|
PD_API void DrawList::DrawPolyLine(const std::vector<fvec2>& points, u32 clr,
|
||||||
u32 clr, u32 flags, int thickness) {
|
u32 flags, int thickness) {
|
||||||
if (points.size() < 2) {
|
if (points.size() < 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -284,8 +278,8 @@ PD_LITHIUM_API void DrawList::DrawPolyLine(const std::vector<fvec2>& points,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_LITHIUM_API void DrawList::DrawConvexPolyFilled(
|
PD_API void DrawList::DrawConvexPolyFilled(const std::vector<fvec2>& points,
|
||||||
const std::vector<fvec2>& points, u32 clr) {
|
u32 clr) {
|
||||||
if (points.size() < 3) {
|
if (points.size() < 3) {
|
||||||
return; // Need at least three points
|
return; // Need at least three points
|
||||||
}
|
}
|
||||||
@@ -293,25 +287,25 @@ PD_LITHIUM_API void DrawList::DrawConvexPolyFilled(
|
|||||||
Renderer::CmdConvexPolyFilled(cmd, points, clr, CurrentTex);
|
Renderer::CmdConvexPolyFilled(cmd, points, clr, CurrentTex);
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_LITHIUM_API void DrawList::DrawText(const fvec2& pos,
|
PD_API void DrawList::DrawText(const fvec2& pos, const std::string& text,
|
||||||
const std::string& text, u32 color) {
|
u32 color) {
|
||||||
if (!pCurrentFont) {
|
if (!pCurrentFont) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pCurrentFont->CmdTextEx(pPool, pos, color, pFontScale, text);
|
pCurrentFont->CmdTextEx(pPool, pos, color, pFontScale, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_LITHIUM_API void DrawList::DrawTextEx(const fvec2& p,
|
PD_API void DrawList::DrawTextEx(const fvec2& p, const std::string& text,
|
||||||
const std::string& text, u32 color,
|
u32 color, LiTextFlags flags,
|
||||||
LiTextFlags flags, const fvec2& box) {
|
const fvec2& box) {
|
||||||
if (!pCurrentFont) {
|
if (!pCurrentFont) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pCurrentFont->CmdTextEx(pPool, p, color, pFontScale, text, flags, box);
|
pCurrentFont->CmdTextEx(pPool, p, color, pFontScale, text, flags, box);
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_LITHIUM_API void DrawList::DrawLine(const fvec2& a, const fvec2& b,
|
PD_API void DrawList::DrawLine(const fvec2& a, const fvec2& b, u32 color,
|
||||||
u32 color, int t) {
|
int t) {
|
||||||
PathAdd(a);
|
PathAdd(a);
|
||||||
PathAdd(b);
|
PathAdd(b);
|
||||||
PathStroke(color, t);
|
PathStroke(color, t);
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace Li {
|
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
|
#ifdef PD_LI_INCLUDE_FONTS
|
||||||
if (id < pNumFonts) {
|
if (id < pNumFonts) {
|
||||||
auto font = pFontData[id];
|
auto font = pFontData[id];
|
||||||
@@ -48,7 +48,7 @@ PD_LITHIUM_API void Font::LoadDefaultFont(int id, int pixel_height) {
|
|||||||
#endif
|
#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
|
* Just use LoadFile2Mem which looks way cleaner
|
||||||
* and helps not having the font loading code twice
|
* 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);
|
LoadTTF(font, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_LITHIUM_API void Font::pMakeAtlas(bool final, std::vector<u8>& font_tex,
|
PD_API void Font::pMakeAtlas(bool final, std::vector<u8>& font_tex, int texszs,
|
||||||
int texszs, PD::Li::Texture::Ref tex) {
|
PD::Li::Texture::Ref tex) {
|
||||||
auto t =
|
auto t =
|
||||||
Gfx::LoadTex(font_tex, texszs, texszs, Texture::RGBA32, Texture::LINEAR);
|
Gfx::LoadTex(font_tex, texszs, texszs, Texture::RGBA32, Texture::LINEAR);
|
||||||
tex->CopyFrom(t);
|
tex->CopyFrom(t);
|
||||||
Textures.push_back(tex);
|
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:
|
* Some additional Info:
|
||||||
* Removed the stbtt get bitmapbox as we dont need to place
|
* 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
|
// Check if codepoijt exist or return a static invalid one
|
||||||
auto res = CodeMap.find(cp);
|
auto res = CodeMap.find(cp);
|
||||||
if (res == CodeMap.end()) {
|
if (res == CodeMap.end()) {
|
||||||
@@ -194,7 +194,7 @@ PD_LITHIUM_API Font::Codepoint& Font::GetCodepoint(u32 cp) {
|
|||||||
return res->second;
|
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);
|
u32 id = PD::FNV1A32(text);
|
||||||
if (pTMS.find(id) != pTMS.end()) {
|
if (pTMS.find(id) != pTMS.end()) {
|
||||||
pTMS[id].TimeStamp = PD::OS::GetTime();
|
pTMS[id].TimeStamp = PD::OS::GetTime();
|
||||||
@@ -247,9 +247,9 @@ PD_LITHIUM_API fvec2 Font::GetTextBounds(const std::string& text, float scale) {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_LITHIUM_API void Font::CmdTextEx(CmdPool& cmds, const fvec2& pos, u32 color,
|
PD_API void Font::CmdTextEx(CmdPool& cmds, const fvec2& pos, u32 color,
|
||||||
float scale, const std::string& text,
|
float scale, const std::string& text,
|
||||||
LiTextFlags flags, const fvec2& box) {
|
LiTextFlags flags, const fvec2& box) {
|
||||||
fvec2 off;
|
fvec2 off;
|
||||||
float cfs = (DefaultPixelHeight * scale) / (float)PixelHeight;
|
float cfs = (DefaultPixelHeight * scale) / (float)PixelHeight;
|
||||||
float lh = (float)PixelHeight * cfs;
|
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,
|
PD_API std::string Font::pWrapText(const std::string& txt, float scale,
|
||||||
const PD::fvec2& max,
|
const PD::fvec2& max, PD::fvec2& dim) {
|
||||||
PD::fvec2& dim) {
|
|
||||||
u32 id = PD::FNV1A32(txt);
|
u32 id = PD::FNV1A32(txt);
|
||||||
if (pTMS.find(id) != pTMS.end()) {
|
if (pTMS.find(id) != pTMS.end()) {
|
||||||
if (pTMS[id].Text.size()) {
|
if (pTMS[id].Text.size()) {
|
||||||
@@ -373,9 +372,8 @@ PD_LITHIUM_API std::string Font::pWrapText(const std::string& txt, float scale,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_LITHIUM_API std::string Font::pShortText(const std::string& txt, float scale,
|
PD_API std::string Font::pShortText(const std::string& txt, float scale,
|
||||||
const PD::fvec2& max,
|
const PD::fvec2& max, PD::fvec2& dim) {
|
||||||
PD::fvec2& dim) {
|
|
||||||
u32 id = PD::FNV1A32(txt);
|
u32 id = PD::FNV1A32(txt);
|
||||||
if (pTMS.find(id) != pTMS.end()) {
|
if (pTMS.find(id) != pTMS.end()) {
|
||||||
if (pTMS[id].Text.size()) {
|
if (pTMS[id].Text.size()) {
|
||||||
@@ -417,7 +415,7 @@ PD_LITHIUM_API std::string Font::pShortText(const std::string& txt, float scale,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_LITHIUM_API void Font::CleanupTMS() {
|
PD_API void Font::CleanupTMS() {
|
||||||
u64 t = PD::OS::GetTime();
|
u64 t = PD::OS::GetTime();
|
||||||
for (auto it = pTMS.begin(); it != pTMS.end();) {
|
for (auto it = pTMS.begin(); it != pTMS.end();) {
|
||||||
if (t - it->second.TimeStamp > 1000) {
|
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 PD {
|
||||||
namespace Li {
|
namespace Li {
|
||||||
PD_LITHIUM_API bool Renderer::InBox(const fvec2& pos, const fvec2& szs,
|
PD_API bool Renderer::InBox(const fvec2& pos, const fvec2& szs,
|
||||||
const fvec4& rect) {
|
const fvec4& rect) {
|
||||||
return (pos.x + szs.x >= rect.x && pos.y + szs.y >= rect.y &&
|
return (pos.x + szs.x >= rect.x && pos.y + szs.y >= rect.y &&
|
||||||
pos.x <= rect.z && pos.y <= rect.w);
|
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 &&
|
return (pos.x > rect.x && pos.x < rect.x + rect.z && pos.y > rect.y &&
|
||||||
pos.y < rect.y + rect.w);
|
pos.y < rect.y + rect.w);
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_LITHIUM_API bool Renderer::InBox(const fvec2& alpha, const fvec2& bravo,
|
PD_API bool Renderer::InBox(const fvec2& alpha, const fvec2& bravo,
|
||||||
const fvec2& charlie, const fvec4& rect) {
|
const fvec2& charlie, const fvec4& rect) {
|
||||||
return ((alpha.x < rect.z && bravo.x < rect.z && charlie.x < rect.z) ||
|
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.y < rect.w && bravo.y < rect.w && charlie.y < rect.w) ||
|
||||||
(alpha.x > 0 && bravo.x > 0 && charlie.x > 0) ||
|
(alpha.x > 0 && bravo.x > 0 && charlie.x > 0) ||
|
||||||
(alpha.y > 0 && bravo.y > 0 && charlie.y > 0));
|
(alpha.y > 0 && bravo.y > 0 && charlie.y > 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_LITHIUM_API void Renderer::RotateCorner(fvec2& pos, float sinus,
|
PD_API void Renderer::RotateCorner(fvec2& pos, float sinus, float cosinus) {
|
||||||
float cosinus) {
|
|
||||||
float x = pos.x * cosinus - pos.y * sinus;
|
float x = pos.x * cosinus - pos.y * sinus;
|
||||||
float y = pos.y * cosinus - pos.x * sinus;
|
float y = pos.y * cosinus - pos.x * sinus;
|
||||||
pos = fvec2(x, y);
|
pos = fvec2(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_LITHIUM_API Rect Renderer::PrimRect(const fvec2& pos, const fvec2& size,
|
PD_API Rect Renderer::PrimRect(const fvec2& pos, const fvec2& size,
|
||||||
float angle) {
|
float angle) {
|
||||||
fvec2 c = size * 0.5f; // Center
|
fvec2 c = size * 0.5f; // Center
|
||||||
fvec2 corner[4] = {
|
fvec2 corner[4] = {
|
||||||
fvec2(-c.x, -c.y),
|
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);
|
corner[3] + pos + c);
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_LITHIUM_API Rect Renderer::PrimLine(const fvec2& a, const fvec2& b,
|
PD_API Rect Renderer::PrimLine(const fvec2& a, const fvec2& b, int thickness) {
|
||||||
int thickness) {
|
|
||||||
// Using the vec maths api makes the code as short as it is
|
// Using the vec maths api makes the code as short as it is
|
||||||
vec2 dir = a - b;
|
vec2 dir = a - b;
|
||||||
float len = dir.Len();
|
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);
|
return Rect(a + off, b + off, a - off, b - off);
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_LITHIUM_API void Renderer::CmdQuad(Command::Ref cmd, const Rect& quad,
|
PD_API void Renderer::CmdQuad(Command::Ref cmd, const Rect& quad,
|
||||||
const Rect& uv, u32 color) {
|
const Rect& uv, u32 color) {
|
||||||
cmd->AddIdx(0).AddIdx(1).AddIdx(2);
|
cmd->AddIdx(0).AddIdx(1).AddIdx(2);
|
||||||
cmd->AddIdx(0).AddIdx(2).AddIdx(3);
|
cmd->AddIdx(0).AddIdx(2).AddIdx(3);
|
||||||
cmd->AddVtx(Vertex(quad.BotRight(), uv.BotRight(), color));
|
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));
|
cmd->AddVtx(Vertex(quad.BotLeft(), uv.BotLeft(), color));
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_LITHIUM_API void Renderer::CmdTriangle(Command::Ref cmd, const fvec2 a,
|
PD_API void Renderer::CmdTriangle(Command::Ref cmd, const fvec2 a,
|
||||||
const fvec2 b, const fvec2 c,
|
const fvec2 b, const fvec2 c, u32 clr) {
|
||||||
u32 clr) {
|
|
||||||
cmd->AddIdx(2).AddIdx(1).AddIdx(0);
|
cmd->AddIdx(2).AddIdx(1).AddIdx(0);
|
||||||
cmd->AddVtx(Vertex(a, vec2(0.f, 1.f), clr));
|
cmd->AddVtx(Vertex(a, vec2(0.f, 1.f), clr));
|
||||||
cmd->AddVtx(Vertex(b, vec2(1.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
|
// 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
|
// would probably be faster to render out of screen than checking if
|
||||||
// it could be skipped)
|
// it could be skipped)
|
||||||
PD_LITHIUM_API void Renderer::CmdConvexPolyFilled(
|
PD_API void Renderer::CmdConvexPolyFilled(Command::Ref cmd,
|
||||||
Command::Ref cmd, const std::vector<fvec2>& points, u32 clr,
|
const std::vector<fvec2>& points,
|
||||||
Texture::Ref tex) {
|
u32 clr, Texture::Ref tex) {
|
||||||
if (points.size() < 3 || tex == nullptr) {
|
if (points.size() < 3 || tex == nullptr) {
|
||||||
return; // Need at least three points
|
return; // Need at least three points
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace UI7 {
|
namespace UI7 {
|
||||||
PD_UI7_API void Button::HandleInput() {
|
PD_API void Button::HandleInput() {
|
||||||
/// Ensure to only check input once
|
/// Ensure to only check input once
|
||||||
if (inp_done) {
|
if (inp_done) {
|
||||||
return;
|
return;
|
||||||
@@ -46,7 +46,7 @@ PD_UI7_API void Button::HandleInput() {
|
|||||||
//}
|
//}
|
||||||
inp_done = true;
|
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?");
|
// Assert(io.get() && list.get(), "Did you run Container::Init correctly?");
|
||||||
// io->Ren->OnScreen(screen);
|
// io->Ren->OnScreen(screen);
|
||||||
list->PathRect(FinalPos(), FinalPos() + size, io->FrameRounding);
|
list->PathRect(FinalPos(), FinalPos() + size, io->FrameRounding);
|
||||||
@@ -57,7 +57,7 @@ PD_UI7_API void Button::Draw() {
|
|||||||
list->LayerDown();
|
list->LayerDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_UI7_API void Button::Update() {
|
PD_API void Button::Update() {
|
||||||
// Assert(io.get(), "Did you run Container::Init correctly?");
|
// Assert(io.get(), "Did you run Container::Init correctly?");
|
||||||
this->SetSize(tdim + io->FramePadding);
|
this->SetSize(tdim + io->FramePadding);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace UI7 {
|
namespace UI7 {
|
||||||
PD_UI7_API void Checkbox::HandleInput() {
|
PD_API void Checkbox::HandleInput() {
|
||||||
/// Ensure to only check input once
|
/// Ensure to only check input once
|
||||||
if (inp_done) {
|
if (inp_done) {
|
||||||
return;
|
return;
|
||||||
@@ -45,7 +45,7 @@ PD_UI7_API void Checkbox::HandleInput() {
|
|||||||
//}
|
//}
|
||||||
inp_done = true;
|
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?");
|
// Assert(list.get() && io.get(), "Did you run Container::Init correctly?");
|
||||||
// io->Ren->OnScreen(screen);
|
// io->Ren->OnScreen(screen);
|
||||||
list->PathRect(FinalPos(), FinalPos() + cbs, io->FrameRounding);
|
list->PathRect(FinalPos(), FinalPos() + cbs, io->FrameRounding);
|
||||||
@@ -59,7 +59,7 @@ PD_UI7_API void Checkbox::Draw() {
|
|||||||
label, io->Theme->Get(UI7Color_Text));
|
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?");
|
// Assert(io.get(), "Did you run Container::Init correctly?");
|
||||||
cbs = io->ItemRowHeight;
|
cbs = io->ItemRowHeight;
|
||||||
this->SetSize(cbs + fvec2(tdim.x + io->ItemSpace.x, 0));
|
this->SetSize(cbs + fvec2(tdim.x + io->ItemSpace.x, 0));
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace UI7 {
|
namespace UI7 {
|
||||||
PD_UI7_API void ColorEdit::HandleInput() {
|
PD_API void ColorEdit::HandleInput() {
|
||||||
/// Ensure to only check input once
|
/// Ensure to only check input once
|
||||||
if (inp_done) {
|
if (inp_done) {
|
||||||
return;
|
return;
|
||||||
@@ -42,7 +42,7 @@ PD_UI7_API void ColorEdit::HandleInput() {
|
|||||||
//}
|
//}
|
||||||
inp_done = true;
|
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?");
|
// Assert(io.get() && list.get(), "Did you run Container::Init correctly?");
|
||||||
// io->Ren->OnScreen(screen);
|
// io->Ren->OnScreen(screen);
|
||||||
list->PathRect(FinalPos(), FinalPos() + io->ItemRowHeight, io->FrameRounding);
|
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?");
|
// Assert(io.get(), "Did you run Container::Init correctly?");
|
||||||
this->SetSize(
|
this->SetSize(
|
||||||
fvec2(tdim.x + io->ItemSpace.x + io->ItemRowHeight, io->ItemRowHeight));
|
fvec2(tdim.x + io->ItemSpace.x + io->ItemRowHeight, io->ItemRowHeight));
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace UI7 {
|
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) {
|
if (last_use != 0 && OS::GetTime() - last_use > 5000) {
|
||||||
rem = true;
|
rem = true;
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,7 @@ PD_UI7_API void Container::HandleScrolling(fvec2 scrolling, fvec4 viewport) {
|
|||||||
viewport.y + viewport.w));
|
viewport.y + viewport.w));
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_UI7_API void Container::HandleInternalInput() {
|
PD_API void Container::HandleInternalInput() {
|
||||||
/** Requires Handle Scrolling First */
|
/** Requires Handle Scrolling First */
|
||||||
}
|
}
|
||||||
} // namespace UI7
|
} // namespace UI7
|
||||||
|
|||||||
@@ -29,15 +29,15 @@ namespace PD {
|
|||||||
namespace UI7 {
|
namespace UI7 {
|
||||||
// Setup Supported Datatypes (Probably making this Object
|
// Setup Supported Datatypes (Probably making this Object
|
||||||
// header only to not care about datatype support)
|
// header only to not care about datatype support)
|
||||||
template class PD_UI7_API DragData<float>;
|
template class PD_API DragData<float>;
|
||||||
template class PD_UI7_API DragData<int>;
|
template class PD_API DragData<int>;
|
||||||
template class PD_UI7_API DragData<double>;
|
template class PD_API DragData<double>;
|
||||||
template class PD_UI7_API DragData<u8>;
|
template class PD_API DragData<u8>;
|
||||||
template class PD_UI7_API DragData<u16>;
|
template class PD_API DragData<u16>;
|
||||||
template class PD_UI7_API DragData<u32>;
|
template class PD_API DragData<u32>;
|
||||||
template class PD_UI7_API DragData<u64>;
|
template class PD_API DragData<u64>;
|
||||||
template <typename T>
|
template <typename T>
|
||||||
PD_UI7_API void DragData<T>::HandleInput() {
|
PD_API void DragData<T>::HandleInput() {
|
||||||
/// Ensure to only check input once
|
/// Ensure to only check input once
|
||||||
if (inp_done) {
|
if (inp_done) {
|
||||||
return;
|
return;
|
||||||
@@ -69,7 +69,7 @@ PD_UI7_API void DragData<T>::HandleInput() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
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?");
|
// Assert(io.get() && list.get(), "Did you run Container::Init correctly?");
|
||||||
// io->Ren->OnScreen(screen);
|
// io->Ren->OnScreen(screen);
|
||||||
float off_x = 0.f;
|
float off_x = 0.f;
|
||||||
@@ -97,7 +97,7 @@ PD_UI7_API void DragData<T>::Draw() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
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?");
|
// Assert(io.get(), "Did you run Container::Init correctly?");
|
||||||
// Probably need to find a faster solution (caching sizes calculated here)
|
// Probably need to find a faster solution (caching sizes calculated here)
|
||||||
float off_x = 0;
|
float off_x = 0;
|
||||||
|
|||||||
@@ -26,14 +26,14 @@ SOFTWARE.
|
|||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace UI7 {
|
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) {
|
if (pInp) {
|
||||||
pInp(io, this);
|
pInp(io, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_UI7_API void DynObj::Update() {}
|
PD_API void DynObj::Update() {}
|
||||||
} // namespace UI7
|
} // namespace UI7
|
||||||
} // namespace PD
|
} // namespace PD
|
||||||
@@ -25,7 +25,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace UI7 {
|
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(io.get() && list.get(), "Did you run Container::Init correctly?");
|
||||||
// Assert(img.get(), "Image is nullptr!");
|
// Assert(img.get(), "Image is nullptr!");
|
||||||
// io->Ren->OnScreen(screen);
|
// io->Ren->OnScreen(screen);
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace UI7 {
|
namespace UI7 {
|
||||||
PD_UI7_API void Label::Draw() {
|
PD_API void Label::Draw() {
|
||||||
// Assert(io.get() && list.get(), "Did you run Container::Init correctly?");
|
// Assert(io.get() && list.get(), "Did you run Container::Init correctly?");
|
||||||
// io->Ren->OnScreen(screen);
|
// io->Ren->OnScreen(screen);
|
||||||
if (pCLipRectUsed) {
|
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
|
* Todo: This is a hacky workaround
|
||||||
* Needs proper optimisation
|
* Needs proper optimisation
|
||||||
|
|||||||
@@ -29,15 +29,15 @@ namespace PD {
|
|||||||
namespace UI7 {
|
namespace UI7 {
|
||||||
// Setup Supported Datatypes (Probably making this Object
|
// Setup Supported Datatypes (Probably making this Object
|
||||||
// header only to not care about datatype support)
|
// header only to not care about datatype support)
|
||||||
template class PD_UI7_API Slider<float>;
|
template class PD_API Slider<float>;
|
||||||
template class PD_UI7_API Slider<int>;
|
template class PD_API Slider<int>;
|
||||||
template class PD_UI7_API Slider<double>;
|
template class PD_API Slider<double>;
|
||||||
template class PD_UI7_API Slider<u8>;
|
template class PD_API Slider<u8>;
|
||||||
template class PD_UI7_API Slider<u16>;
|
template class PD_API Slider<u16>;
|
||||||
template class PD_UI7_API Slider<u32>;
|
template class PD_API Slider<u32>;
|
||||||
template class PD_UI7_API Slider<u64>;
|
template class PD_API Slider<u64>;
|
||||||
template <typename T>
|
template <typename T>
|
||||||
PD_UI7_API void Slider<T>::HandleInput() {
|
PD_API void Slider<T>::HandleInput() {
|
||||||
/// Ensure to only check input once
|
/// Ensure to only check input once
|
||||||
if (inp_done) {
|
if (inp_done) {
|
||||||
return;
|
return;
|
||||||
@@ -66,7 +66,7 @@ PD_UI7_API void Slider<T>::HandleInput() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
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?");
|
// Assert(io.get() && list.get(), "Did you run Container::Init correctly?");
|
||||||
// io->Ren->OnScreen(screen);
|
// io->Ren->OnScreen(screen);
|
||||||
std::string p;
|
std::string p;
|
||||||
@@ -93,7 +93,7 @@ PD_UI7_API void Slider<T>::Draw() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
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?");
|
// Assert(io.get(), "Did you run Container::Init correctly?");
|
||||||
// Probably need to find a faster solution (caching sizes calculated here)
|
// Probably need to find a faster solution (caching sizes calculated here)
|
||||||
slw = std::clamp(static_cast<float>(width / max), 3.f, width);
|
slw = std::clamp(static_cast<float>(width / max), 3.f, width);
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ SOFTWARE.
|
|||||||
#include <pd/ui7/io.hpp>
|
#include <pd/ui7/io.hpp>
|
||||||
|
|
||||||
namespace PD {
|
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 */
|
/** Todo: find out if we even still use the Drawlist regestry */
|
||||||
u64 current = OS::GetNanoTime();
|
u64 current = OS::GetNanoTime();
|
||||||
Delta = static_cast<float>(current - LastTime) / 1000000.f;
|
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 PD {
|
||||||
namespace UI7 {
|
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;
|
BackupCursor = LastObjSize;
|
||||||
Cursor = SamelineCursor;
|
Cursor = SamelineCursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_UI7_API void Layout::CursorMove(const fvec2& size) {
|
PD_API void Layout::CursorMove(const fvec2& size) {
|
||||||
LastObjSize = size;
|
LastObjSize = size;
|
||||||
SamelineCursor = Cursor + fvec2(size.x + IO->ItemSpace.x, 0);
|
SamelineCursor = Cursor + fvec2(size.x + IO->ItemSpace.x, 0);
|
||||||
if (BeforeSameLine.y) {
|
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);
|
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]) {
|
if (Scrolling[1]) {
|
||||||
movpos.y -= ScrollOffset.y;
|
movpos.y -= ScrollOffset.y;
|
||||||
if (!Li::Renderer::InBox(
|
if (!Li::Renderer::InBox(
|
||||||
@@ -61,7 +61,7 @@ PD_UI7_API bool Layout::ObjectWorkPos(fvec2& movpos) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_UI7_API void Layout::AddObject(Container::Ref obj) {
|
PD_API void Layout::AddObject(Container::Ref obj) {
|
||||||
obj->Init(IO, DrawList);
|
obj->Init(IO, DrawList);
|
||||||
obj->SetPos(AlignPosition(Cursor, obj->GetSize(), WorkRect, GetAlignment()));
|
obj->SetPos(AlignPosition(Cursor, obj->GetSize(), WorkRect, GetAlignment()));
|
||||||
obj->Update();
|
obj->Update();
|
||||||
@@ -70,7 +70,7 @@ PD_UI7_API void Layout::AddObject(Container::Ref obj) {
|
|||||||
Objects.push_back(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);
|
obj->Init(IO, DrawList);
|
||||||
if (!(flags & UI7LytAdd_NoCursorUpdate)) {
|
if (!(flags & UI7LytAdd_NoCursorUpdate)) {
|
||||||
obj->SetPos(
|
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) {
|
for (auto& it : IDObjects) {
|
||||||
if (it->GetID() == id) {
|
if (it->GetID() == id) {
|
||||||
return it;
|
return it;
|
||||||
@@ -99,8 +99,8 @@ PD_UI7_API Container::Ref Layout::FindObject(u32 id) {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_UI7_API fvec2 Layout::AlignPosition(fvec2 pos, fvec2 size, fvec4 area,
|
PD_API fvec2 Layout::AlignPosition(fvec2 pos, fvec2 size, fvec4 area,
|
||||||
UI7Align alignment) {
|
UI7Align alignment) {
|
||||||
vec2 p = pos;
|
vec2 p = pos;
|
||||||
if (alignment & UI7Align_Center) {
|
if (alignment & UI7Align_Center) {
|
||||||
p.x = (area.x + area.z) * 0.5 - (pos.x - area.x + size.x * 0.5);
|
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;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_UI7_API void Layout::Update() {
|
PD_API void Layout::Update() {
|
||||||
if (Size == fvec2(0.f)) {
|
if (Size == fvec2(0.f)) {
|
||||||
Size = fvec2(MaxPosition) + IO->MenuPadding * 2;
|
Size = fvec2(MaxPosition) + IO->MenuPadding * 2;
|
||||||
}
|
}
|
||||||
@@ -144,14 +144,14 @@ PD_UI7_API void Layout::Update() {
|
|||||||
|
|
||||||
/** SECTION CONTAINERS (STOLEN FROM FORMER MENU) */
|
/** 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
|
// Layout API
|
||||||
auto r = Label::New(label, IO);
|
auto r = Label::New(label, IO);
|
||||||
r->SetClipRect(fvec4(GetPosition(), GetPosition() + GetSize()));
|
r->SetClipRect(fvec4(GetPosition(), GetPosition() + GetSize()));
|
||||||
AddObject(r);
|
AddObject(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_UI7_API bool Layout::Button(const std::string& label) {
|
PD_API bool Layout::Button(const std::string& label) {
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
u32 id = Strings::FastHash("btn" + label + std::to_string(Objects.size()));
|
u32 id = Strings::FastHash("btn" + label + std::to_string(Objects.size()));
|
||||||
Container::Ref r = FindObject(id);
|
Container::Ref r = FindObject(id);
|
||||||
@@ -166,7 +166,7 @@ PD_UI7_API bool Layout::Button(const std::string& label) {
|
|||||||
return ret;
|
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()));
|
u32 id = Strings::FastHash("cbx" + label + std::to_string(Objects.size()));
|
||||||
Container::Ref r = FindObject(id);
|
Container::Ref r = FindObject(id);
|
||||||
if (!r) {
|
if (!r) {
|
||||||
@@ -176,7 +176,7 @@ PD_UI7_API void Layout::Checkbox(const std::string& label, bool& v) {
|
|||||||
AddObject(r);
|
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);
|
Container::Ref r = Image::New(img, size, uv);
|
||||||
AddObject(r);
|
AddObject(r);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ Menu::Menu(const ID& id, IO::Ref io) : pIO(io), pID(id) {
|
|||||||
pLayout->CursorInit();
|
pLayout->CursorInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_UI7_API void Menu::Label(const std::string& label) {
|
PD_API void Menu::Label(const std::string& label) {
|
||||||
// Layout API
|
// Layout API
|
||||||
auto r = Label::New(label, pIO);
|
auto r = Label::New(label, pIO);
|
||||||
r->SetClipRect(fvec4(pLayout->GetPosition(),
|
r->SetClipRect(fvec4(pLayout->GetPosition(),
|
||||||
@@ -42,7 +42,7 @@ PD_UI7_API void Menu::Label(const std::string& label) {
|
|||||||
pLayout->AddObject(r);
|
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;
|
bool ret = false;
|
||||||
u32 id = Strings::FastHash("btn" + label +
|
u32 id = Strings::FastHash("btn" + label +
|
||||||
std::to_string(pLayout->Objects.size()));
|
std::to_string(pLayout->Objects.size()));
|
||||||
@@ -58,7 +58,7 @@ PD_UI7_API bool Menu::Button(const std::string& label) {
|
|||||||
return ret;
|
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 +
|
u32 id = Strings::FastHash("cbx" + label +
|
||||||
std::to_string(pLayout->Objects.size()));
|
std::to_string(pLayout->Objects.size()));
|
||||||
Container::Ref r = pLayout->FindObject(id);
|
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);
|
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);
|
Container::Ref r = Image::New(img, size, uv);
|
||||||
pLayout->AddObject(r);
|
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);
|
u32 id = Strings::FastHash("drd" + label);
|
||||||
Container::Ref r = pLayout->FindObject(id);
|
Container::Ref r = pLayout->FindObject(id);
|
||||||
if (!r) {
|
if (!r) {
|
||||||
@@ -84,7 +84,7 @@ PD_UI7_API void Menu::ColorEdit(const std::string& label, u32& clr) {
|
|||||||
pLayout->AddObject(r);
|
pLayout->AddObject(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_UI7_API void Menu::Separator() {
|
PD_API void Menu::Separator() {
|
||||||
// Dynamic Objects are very simple...
|
// Dynamic Objects are very simple...
|
||||||
Container::Ref r = DynObj::New(
|
Container::Ref r = DynObj::New(
|
||||||
[=, this](UI7::IO::Ref io, Li::DrawList::Ref l, UI7::Container* self) {
|
[=, 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);
|
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
|
// 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,
|
Container::Ref r = DynObj::New([=, this](UI7::IO::Ref io, Li::DrawList::Ref l,
|
||||||
UI7::Container* self) {
|
UI7::Container* self) {
|
||||||
@@ -127,7 +127,7 @@ PD_UI7_API void Menu::SeparatorText(const std::string& label) {
|
|||||||
pIO->Font->PixelHeight * pIO->FontScale));
|
pIO->Font->PixelHeight * pIO->FontScale));
|
||||||
pLayout->AddObject(r);
|
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
|
// Check if menu can be focused for Selective Menu Input API
|
||||||
vec4 newarea = fvec4(pLayout->Pos, pLayout->Size);
|
vec4 newarea = fvec4(pLayout->Pos, pLayout->Size);
|
||||||
if (!pIsOpen) {
|
if (!pIsOpen) {
|
||||||
@@ -146,7 +146,7 @@ PD_UI7_API void Menu::HandleFocus() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Todo: (func name is self describing) */
|
/** Todo: (func name is self describing) */
|
||||||
PD_UI7_API void Menu::HandleScrolling() {
|
PD_API void Menu::HandleScrolling() {
|
||||||
if (Flags & UI7MenuFlags_VtScrolling) {
|
if (Flags & UI7MenuFlags_VtScrolling) {
|
||||||
bool allowed =
|
bool allowed =
|
||||||
pLayout->MaxPosition.y > (pLayout->WorkRect.w - pLayout->WorkRect.y);
|
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
|
// Collapse
|
||||||
if (!(Flags & UI7MenuFlags_NoCollapse)) {
|
if (!(Flags & UI7MenuFlags_NoCollapse)) {
|
||||||
vec2 cpos = pLayout->Pos + pIO->FramePadding;
|
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) {
|
if (pIsOpen) {
|
||||||
/** Resize Sym (Render on Top of Everything) */
|
/** Resize Sym (Render on Top of Everything) */
|
||||||
if (!(Flags & UI7MenuFlags_NoResize)) {
|
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();
|
HandleFocus();
|
||||||
if (pLayout->Size == fvec2(0.f) || Flags & UI7MenuFlags_AlwaysAutoSize) {
|
if (pLayout->Size == fvec2(0.f) || Flags & UI7MenuFlags_AlwaysAutoSize) {
|
||||||
pLayout->Size = fvec2(pLayout->MaxPosition) + pIO->MenuPadding * 2;
|
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:
|
// As of some notes this should work:
|
||||||
auto n = pTreeNodes.find(id);
|
auto n = pTreeNodes.find(id);
|
||||||
if (n == pTreeNodes.end()) {
|
if (n == pTreeNodes.end()) {
|
||||||
@@ -418,7 +418,7 @@ PD_UI7_API bool Menu::BeginTreeNode(const ID& id) {
|
|||||||
return n->second;
|
return n->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_UI7_API void UI7::Menu::EndTreeNode() {
|
PD_API void UI7::Menu::EndTreeNode() {
|
||||||
pLayout->InitialCursorOffset.x -= 10.f;
|
pLayout->InitialCursorOffset.x -= 10.f;
|
||||||
pLayout->Cursor.x -= 10.f;
|
pLayout->Cursor.x -= 10.f;
|
||||||
if (pLayout->InitialCursorOffset.x < 0.f) {
|
if (pLayout->InitialCursorOffset.x < 0.f) {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace UI7 {
|
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_Text, Color("#FFFFFFFF"));
|
||||||
theme.Set(UI7Color_TextDead, Color("#AAAAAAFF"));
|
theme.Set(UI7Color_TextDead, Color("#AAAAAAFF"));
|
||||||
theme.Set(UI7Color_Background, Color("#222222aa"));
|
theme.Set(UI7Color_Background, Color("#222222aa"));
|
||||||
@@ -45,7 +45,7 @@ PD_UI7_API void Theme::Default(Theme& theme) {
|
|||||||
theme.Set(UI7Color_ListOdd, Color("#BBBBBBFF"));
|
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_Text, Color("#000000FF"));
|
||||||
theme.Set(UI7Color_TextDead, Color("#333333FF"));
|
theme.Set(UI7Color_TextDead, Color("#333333FF"));
|
||||||
theme.Set(UI7Color_Background, Color("#eeeeeeFF"));
|
theme.Set(UI7Color_Background, Color("#eeeeeeFF"));
|
||||||
|
|||||||
@@ -23,15 +23,15 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include <pd/ui7/ui7.hpp>
|
#include <pd/ui7/ui7.hpp>
|
||||||
|
|
||||||
|
#include "pd/pd_p_api.hpp"
|
||||||
#include "pd/ui7/flags.hpp"
|
#include "pd/ui7/flags.hpp"
|
||||||
#include "pd/ui7/pd_p_api.hpp"
|
|
||||||
|
|
||||||
#define UI7DHX32(x) std::format("{}: {:#08x}", #x, x)
|
#define UI7DHX32(x) std::format("{}: {:#08x}", #x, x)
|
||||||
#define UI7DTF(x) PD::Strings::FormatNanos(x)
|
#define UI7DTF(x) PD::Strings::FormatNanos(x)
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace UI7 {
|
namespace UI7 {
|
||||||
PD_UI7_API std::string GetVersion(bool show_build) {
|
PD_API std::string GetVersion(bool show_build) {
|
||||||
std::stringstream s;
|
std::stringstream s;
|
||||||
s << ((UI7_VERSION >> 24) & 0xFF) << ".";
|
s << ((UI7_VERSION >> 24) & 0xFF) << ".";
|
||||||
s << ((UI7_VERSION >> 16) & 0xFF) << ".";
|
s << ((UI7_VERSION >> 16) & 0xFF) << ".";
|
||||||
@@ -40,19 +40,19 @@ PD_UI7_API std::string GetVersion(bool show_build) {
|
|||||||
return s.str();
|
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);
|
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)) {
|
if (!pIO->ViewPorts.count(id)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pIO->CurrentViewPort = pIO->ViewPorts[id]->GetSize();
|
pIO->CurrentViewPort = pIO->ViewPorts[id]->GetSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_UI7_API Menu::Ref Context::BeginMenu(const ID& id, UI7MenuFlags flags,
|
PD_API Menu::Ref Context::BeginMenu(const ID& id, UI7MenuFlags flags,
|
||||||
bool* pShow) {
|
bool* pShow) {
|
||||||
if (pCurrent) {
|
if (pCurrent) {
|
||||||
std::cout << "[UI7] Error: You are already in " << pCurrent->pID.GetName()
|
std::cout << "[UI7] Error: You are already in " << pCurrent->pID.GetName()
|
||||||
<< " Menu" << std::endl;
|
<< " Menu" << std::endl;
|
||||||
@@ -82,7 +82,7 @@ PD_UI7_API Menu::Ref Context::BeginMenu(const ID& id, UI7MenuFlags flags,
|
|||||||
return pCurrent;
|
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
|
* 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;
|
// pIO->InputHandler->CurrentMenu = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_UI7_API void Context::Update() {
|
PD_API void Context::Update() {
|
||||||
/**
|
/**
|
||||||
* Cause Commenting each line looks carbage...
|
* Cause Commenting each line looks carbage...
|
||||||
* This function simply clears the FinalDrawList, Searches for Menu ID's in
|
* 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();
|
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)) {
|
if (auto m = BeginMenu("About UI7", UI7MenuFlags_Scrolling, show)) {
|
||||||
m->Label("Palladium UI7 " + GetVersion());
|
m->Label("Palladium UI7 " + GetVersion());
|
||||||
m->Separator();
|
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)) {
|
if (auto m = BeginMenu("UI7 Metrics", UI7MenuFlags_Scrolling, show)) {
|
||||||
m->Label("Palladium - UI7 " + GetVersion());
|
m->Label("Palladium - UI7 " + GetVersion());
|
||||||
m->Separator();
|
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)) {
|
if (auto m = BeginMenu("UI7 Style Editor", UI7MenuFlags_Scrolling, show)) {
|
||||||
m->Label("Palladium - UI7 " + GetVersion() + " Style Editor");
|
m->Label("Palladium - UI7 " + GetVersion() + " Style Editor");
|
||||||
m->Separator();
|
m->Separator();
|
||||||
|
|||||||
Reference in New Issue
Block a user