Unfiy all sub projects back into 1 libpalladium
This commit is contained in:
@@ -8,29 +8,87 @@ set(PD_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
include(cmake/palladium.cmake)
|
||||
|
||||
option(PD_BUILD_TESTS "Sets if TestApp and TestBench get build" OFF)
|
||||
option(PD_BUILD_SHARED "Build Shared Libraries" OFF)
|
||||
option(PD_BUILD_SHARED "Build Shared Library" OFF)
|
||||
option(PD_BUILD_TOOLS "Build Palladium Tools" OFF)
|
||||
|
||||
if(${PD_BUILD_TOOLS})
|
||||
add_subdirectory(tools)
|
||||
endif()
|
||||
|
||||
## Include Library Source
|
||||
# # Include Library Source
|
||||
set(PD_SOURCES
|
||||
|
||||
add_subdirectory(pd/drivers)
|
||||
add_subdirectory(pd/core)
|
||||
add_subdirectory(pd/image)
|
||||
add_subdirectory(pd/external)
|
||||
add_subdirectory(pd/lithium)
|
||||
add_subdirectory(pd/ui7)
|
||||
# Core
|
||||
source/core/bit_util.cpp
|
||||
source/core/color.cpp
|
||||
source/core/io.cpp
|
||||
source/core/mat.cpp
|
||||
source/core/strings.cpp
|
||||
source/core/timer.cpp
|
||||
source/core/timetrace.cpp
|
||||
|
||||
add_library(palladium INTERFACE)
|
||||
target_link_libraries(palladium INTERFACE
|
||||
pd-core pd-image pd-external pd-lithium pd-ui7 #pd-net
|
||||
# Drivers
|
||||
source/drivers/gfx.cpp
|
||||
source/drivers/hid.cpp
|
||||
source/drivers/os.cpp
|
||||
|
||||
# External
|
||||
source/external/stb.cpp
|
||||
|
||||
# Image
|
||||
source/image/image.cpp
|
||||
source/image/img_blur.cpp
|
||||
source/image/img_convert.cpp
|
||||
|
||||
# Lithium
|
||||
source/lithium/command.cpp
|
||||
source/lithium/drawlist.cpp
|
||||
source/lithium/font.cpp
|
||||
source/lithium/fonts.cpp
|
||||
source/lithium/renderer.cpp
|
||||
|
||||
# UI7
|
||||
source/ui7/container/button.cpp
|
||||
source/ui7/container/checkbox.cpp
|
||||
source/ui7/container/coloredit.cpp
|
||||
source/ui7/container/container.cpp
|
||||
source/ui7/container/dragdata.cpp
|
||||
source/ui7/container/dynobj.cpp
|
||||
source/ui7/container/image.cpp
|
||||
source/ui7/container/label.cpp
|
||||
source/ui7/container/slider.cpp
|
||||
source/ui7/io.cpp
|
||||
source/ui7/layout.cpp
|
||||
source/ui7/menu.cpp
|
||||
source/ui7/theme.cpp
|
||||
source/ui7/ui7.cpp
|
||||
)
|
||||
|
||||
add_dependencies(palladium
|
||||
pd-drivers pd-core pd-image pd-external pd-lithium pd-ui7 #pd-net
|
||||
)
|
||||
if(${PD_BUILD_SHARED})
|
||||
add_library(palladium SHARED ${PD_SOURCES})
|
||||
else()
|
||||
add_library(palladium STATIC ${PD_SOURCES})
|
||||
endif()
|
||||
|
||||
target_include_directories(palladium PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
|
||||
install(DIRECTORY include DESTINATION ".")
|
||||
install(TARGETS palladium)
|
||||
|
||||
find_program(CLANG_FORMAT clang-format)
|
||||
|
||||
file(GLOB_RECURSE PD_FMTFILES CONFIGURE_DEPENDS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/pd/core/*.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/pd/drivers/*.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/pd/image/*.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/pd/lithium/*.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/pd/ui7/*.hpp
|
||||
)
|
||||
|
||||
message(STATUS "Files to format: ${PD_FMTFILES}")
|
||||
|
||||
add_custom_target(pd-clang-format
|
||||
COMMAND ${CLANG_FORMAT} --style=file -i ${PD_FMTFILES}
|
||||
COMMENT "Formatting Project Sources"
|
||||
)
|
||||
12
include/pd/core/timetrace.hpp
Executable file → Normal file
12
include/pd/core/timetrace.hpp
Executable file → Normal file
@@ -102,12 +102,12 @@ class TimeStats {
|
||||
* Get Data Buffer
|
||||
* @return data bufer (not edidable)
|
||||
*/
|
||||
const std::vector<u64> &GetData() { return val; }
|
||||
const std::vector<u64>& GetData() { return val; }
|
||||
/**
|
||||
* Access an element in the list [not edidable]
|
||||
* @return value to access
|
||||
*/
|
||||
const u64 &operator[](int i) { return val[smart_idx(i)]; }
|
||||
const u64& operator[](int i) { return val[smart_idx(i)]; }
|
||||
/**
|
||||
* Get List Lengh
|
||||
* @return Lengh
|
||||
@@ -160,7 +160,7 @@ class Res {
|
||||
* Setter for the ID (Name)
|
||||
* @param v ID of the Trace
|
||||
*/
|
||||
void SetID(const std::string &v) { id = v; }
|
||||
void SetID(const std::string& v) { id = v; }
|
||||
/**
|
||||
* Getter for the traces ID
|
||||
* @return Trace ID
|
||||
@@ -218,12 +218,12 @@ class Res {
|
||||
* Begin a Trace
|
||||
* @param id Name of the Trace
|
||||
*/
|
||||
PD_CORE_API void Beg(const std::string &id);
|
||||
PD_CORE_API void Beg(const std::string& id);
|
||||
/**
|
||||
* End a Trace
|
||||
* @param id Name of the Trace
|
||||
*/
|
||||
PD_CORE_API void End(const std::string &id);
|
||||
PD_CORE_API void End(const std::string& id);
|
||||
/**
|
||||
* Collect Start end end of the trace by tracking
|
||||
* when the Scope object goes out of scope
|
||||
@@ -245,7 +245,7 @@ class Scope {
|
||||
* Constructor requiring a Name for the Trace
|
||||
* @param id Name of the Trace
|
||||
*/
|
||||
Scope(const std::string &id) {
|
||||
Scope(const std::string& id) {
|
||||
this->ID = id;
|
||||
Beg(id);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
4
include/pd/image/img_blur.hpp
Executable file → Normal file
4
include/pd/image/img_blur.hpp
Executable file → Normal file
@@ -49,7 +49,7 @@ PD_IMAGE_API std::vector<float> GaussianKernel(int radius, float si);
|
||||
* @param idxfn Indexing function
|
||||
*/
|
||||
PD_IMAGE_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 {
|
||||
return y * w + x;
|
||||
});
|
||||
@@ -64,7 +64,7 @@ PD_IMAGE_API void GaussianBlur(
|
||||
* @param idxfn Indexing function
|
||||
*/
|
||||
PD_IMAGE_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 {
|
||||
return y * w + x;
|
||||
});
|
||||
|
||||
12
include/pd/image/img_convert.hpp
Executable file → Normal file
12
include/pd/image/img_convert.hpp
Executable file → Normal file
@@ -42,18 +42,18 @@ namespace ImgConvert {
|
||||
* @param h height of the image
|
||||
*/
|
||||
PD_IMAGE_API
|
||||
void RGB24toRGBA32(std::vector<PD::u8> &out, const std::vector<u8> &in,
|
||||
const int &w, const int &h);
|
||||
void RGB24toRGBA32(std::vector<PD::u8>& out, const std::vector<u8>& in,
|
||||
const int& w, const int& h);
|
||||
PD_IMAGE_API
|
||||
void RGB32toRGBA24(std::vector<u8> &out, const std::vector<u8> &in,
|
||||
const int &w, const int &h);
|
||||
void RGB32toRGBA24(std::vector<u8>& out, const std::vector<u8>& in,
|
||||
const int& w, const int& h);
|
||||
/**
|
||||
* Reverse 32 (RGBA -> ABGR || ABGR -> RGBA)
|
||||
* @param buf Buffer to convert
|
||||
* @param w width
|
||||
* @param h height
|
||||
*/
|
||||
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_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);
|
||||
} // namespace ImgConvert
|
||||
} // namespace PD
|
||||
@@ -37,5 +37,5 @@ struct FontFileData {
|
||||
extern FontFileData pFontData[];
|
||||
extern size_t pNumFonts;
|
||||
extern PD::u8 pFontsDataRaw[];
|
||||
} // namespace PD
|
||||
} // namespace PD
|
||||
#endif
|
||||
|
||||
28
include/pd/ui7/layout.hpp
Executable file → Normal file
28
include/pd/ui7/layout.hpp
Executable file → Normal file
@@ -37,7 +37,7 @@ namespace PD {
|
||||
namespace UI7 {
|
||||
class PD_UI7_API Layout {
|
||||
public:
|
||||
Layout(const ID &id, IO::Ref io) : ID(id) {
|
||||
Layout(const ID& id, IO::Ref io) : ID(id) {
|
||||
this->IO = io;
|
||||
DrawList = Li::DrawList::New();
|
||||
DrawList->SetFont(IO->Font);
|
||||
@@ -58,9 +58,9 @@ class PD_UI7_API Layout {
|
||||
* Render a Simple Label
|
||||
* @param label The text to draw
|
||||
*/
|
||||
void Label(const std::string &label);
|
||||
void Label(const std::string& label);
|
||||
template <typename... Args>
|
||||
void Label(std::format_string<Args...> s, Args &&...args) {
|
||||
void Label(std::format_string<Args...> s, Args&&... args) {
|
||||
Label(std::format(s, std::forward<Args>(args)...));
|
||||
}
|
||||
/**
|
||||
@@ -68,13 +68,13 @@ class PD_UI7_API Layout {
|
||||
* @param label The buttons text
|
||||
* @return if the button was pressed
|
||||
*/
|
||||
bool Button(const std::string &label);
|
||||
bool Button(const std::string& label);
|
||||
/**
|
||||
* Render a Checkbox
|
||||
* @param label Label of the Checkbox
|
||||
* @param v A value to update
|
||||
*/
|
||||
void Checkbox(const std::string &label, bool &v);
|
||||
void Checkbox(const std::string& label, bool& v);
|
||||
/**
|
||||
* Render an Image
|
||||
* @param img Texture reference of the image
|
||||
@@ -90,7 +90,7 @@ class PD_UI7_API Layout {
|
||||
* @param precission Difine the Format string len for float/double
|
||||
*/
|
||||
template <typename T>
|
||||
void DragData(const std::string &label, T *data, size_t num_elms = 1,
|
||||
void DragData(const std::string& label, T* data, size_t num_elms = 1,
|
||||
T min = std::numeric_limits<T>::min(),
|
||||
T max = std::numeric_limits<T>::max(), T step = 1,
|
||||
int precision = 1) {
|
||||
@@ -104,7 +104,7 @@ class PD_UI7_API Layout {
|
||||
AddObject(r);
|
||||
}
|
||||
template <typename T>
|
||||
void Slider(const std::string &label, T *data,
|
||||
void Slider(const std::string& label, T* data,
|
||||
T min = std::numeric_limits<T>::min(),
|
||||
T max = std::numeric_limits<T>::max(), int precision = 1) {
|
||||
u32 id = Strings::FastHash("drd" + label + std::to_string((uintptr_t)data));
|
||||
@@ -119,20 +119,20 @@ class PD_UI7_API Layout {
|
||||
/** SECTION OTHERSTUFF */
|
||||
|
||||
const std::string GetName() const { return ID.GetName(); }
|
||||
const UI7::ID &GetID() const { return this->ID; }
|
||||
const UI7::ID& GetID() const { return this->ID; }
|
||||
|
||||
const fvec2 &GetPosition() const { return Pos; }
|
||||
void SetPosition(const fvec2 &v) { Pos = v; }
|
||||
const fvec2 &GetSize() const { return Size; }
|
||||
void SetSize(const fvec2 &v) { Size = v; }
|
||||
const fvec2& GetPosition() const { return Pos; }
|
||||
void SetPosition(const fvec2& v) { Pos = v; }
|
||||
const fvec2& GetSize() const { return Size; }
|
||||
void SetSize(const fvec2& v) { Size = v; }
|
||||
|
||||
Li::DrawList::Ref GetDrawList() { return DrawList; }
|
||||
|
||||
void CursorInit();
|
||||
void SameLine();
|
||||
void CursorMove(const fvec2 &size);
|
||||
void CursorMove(const fvec2& size);
|
||||
|
||||
bool ObjectWorkPos(fvec2 &movpos);
|
||||
bool ObjectWorkPos(fvec2& movpos);
|
||||
|
||||
/**
|
||||
* Extended Object Add Func to Add Object in Front or disable
|
||||
|
||||
22
include/pd/ui7/menu.hpp
Executable file → Normal file
22
include/pd/ui7/menu.hpp
Executable file → Normal file
@@ -36,7 +36,7 @@ namespace PD {
|
||||
namespace UI7 {
|
||||
class PD_UI7_API Menu {
|
||||
public:
|
||||
Menu(const UI7::ID &id, UI7::IO::Ref pIO);
|
||||
Menu(const UI7::ID& id, UI7::IO::Ref pIO);
|
||||
~Menu() {}
|
||||
|
||||
PD_SHARED(Menu);
|
||||
@@ -45,9 +45,9 @@ class PD_UI7_API Menu {
|
||||
* Render a Simple Label
|
||||
* @param label The text to draw
|
||||
*/
|
||||
void Label(const std::string &label);
|
||||
void Label(const std::string& label);
|
||||
template <typename... Args>
|
||||
void Label(std::format_string<Args...> s, Args &&...args) {
|
||||
void Label(std::format_string<Args...> s, Args&&... args) {
|
||||
Label(std::format(s, std::forward<Args>(args)...));
|
||||
}
|
||||
/**
|
||||
@@ -55,13 +55,13 @@ class PD_UI7_API Menu {
|
||||
* @param label The buttons text
|
||||
* @return if the button was pressed
|
||||
*/
|
||||
bool Button(const std::string &label);
|
||||
bool Button(const std::string& label);
|
||||
/**
|
||||
* Render a Checkbox
|
||||
* @param label Label of the Checkbox
|
||||
* @param v A value to update
|
||||
*/
|
||||
void Checkbox(const std::string &label, bool &v);
|
||||
void Checkbox(const std::string& label, bool& v);
|
||||
/**
|
||||
* Render an Image
|
||||
* @param img Texture reference of the image
|
||||
@@ -77,7 +77,7 @@ class PD_UI7_API Menu {
|
||||
* @param precission Difine the Format string len for float/double
|
||||
*/
|
||||
template <typename T>
|
||||
void DragData(const std::string &label, T *data, size_t num_elms = 1,
|
||||
void DragData(const std::string& label, T* data, size_t num_elms = 1,
|
||||
T min = std::numeric_limits<T>::min(),
|
||||
T max = std::numeric_limits<T>::max(), T step = 1,
|
||||
int precision = 1) {
|
||||
@@ -94,7 +94,7 @@ class PD_UI7_API Menu {
|
||||
pLayout->AddObject(r);
|
||||
}
|
||||
template <typename T>
|
||||
void Slider(const std::string &label, T *data,
|
||||
void Slider(const std::string& label, T* data,
|
||||
T min = std::numeric_limits<T>::min(),
|
||||
T max = std::numeric_limits<T>::max(), int precision = 1) {
|
||||
u32 id = Strings::FastHash("drd" + label + std::to_string((uintptr_t)data));
|
||||
@@ -105,11 +105,11 @@ class PD_UI7_API Menu {
|
||||
}
|
||||
pLayout->AddObject(r);
|
||||
}
|
||||
void ColorEdit(const std::string &label, u32 &clr);
|
||||
void ColorEdit(const std::string& label, u32& clr);
|
||||
void SameLine() { pLayout->SameLine(); }
|
||||
void Separator();
|
||||
void SeparatorText(const std::string &label);
|
||||
bool BeginTreeNode(const ID &id);
|
||||
void SeparatorText(const std::string& label);
|
||||
bool BeginTreeNode(const ID& id);
|
||||
void EndTreeNode();
|
||||
|
||||
void HandleFocus();
|
||||
@@ -131,7 +131,7 @@ class PD_UI7_API Menu {
|
||||
Layout::Ref pLayout;
|
||||
IO::Ref pIO;
|
||||
ID pID;
|
||||
bool *pIsShown = nullptr;
|
||||
bool* pIsShown = nullptr;
|
||||
bool pIsOpen = true;
|
||||
std::unordered_map<u32, bool> pTreeNodes;
|
||||
fvec2 TempScrollXY;
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
project(pd-core LANGUAGES CXX VERSION 0.6.0)
|
||||
|
||||
set(SRC
|
||||
source/bit_util.cpp
|
||||
source/color.cpp
|
||||
source/io.cpp
|
||||
source/mat.cpp
|
||||
source/strings.cpp
|
||||
source/timer.cpp
|
||||
source/timetrace.cpp
|
||||
)
|
||||
|
||||
if(PD_BUILD_SHARED)
|
||||
pd_add_lib(pd-core BUILD_SHARED TRUE SRC_FILES ${SRC})
|
||||
else()
|
||||
pd_add_lib(pd-core SRC_FILES ${SRC})
|
||||
endif()
|
||||
|
||||
target_link_libraries(pd-core PUBLIC pd-drivers)
|
||||
@@ -1,13 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
## The Core Core Library
|
||||
project(pd-drivers LANGUAGES CXX VERSION 0.6.0)
|
||||
|
||||
set(SRC
|
||||
source/hid.cpp
|
||||
source/os.cpp
|
||||
source/gfx.cpp
|
||||
)
|
||||
|
||||
# Only Static Supported
|
||||
pd_add_lib(pd-drivers SRC_FILES ${SRC})
|
||||
9
pd/external/CMakeLists.txt
vendored
9
pd/external/CMakeLists.txt
vendored
@@ -1,9 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
project(pd-external LANGUAGES CXX VERSION 0.5.0)
|
||||
|
||||
set(SRC
|
||||
source/stb.cpp
|
||||
)
|
||||
|
||||
pd_add_lib(pd-external SRC_FILES ${SRC})
|
||||
4
pd/external/source/stb.cpp
vendored
4
pd/external/source/stb.cpp
vendored
@@ -1,4 +0,0 @@
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include <pd/external/stb_image.h>
|
||||
#define STB_TRUETYPE_IMPLEMENTATION
|
||||
#include <pd/external/stb_truetype.h>
|
||||
@@ -1,15 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
project(pd-image LANGUAGES CXX VERSION 0.5.0)
|
||||
|
||||
set(SRC
|
||||
source/image.cpp
|
||||
source/img_blur.cpp
|
||||
source/img_convert.cpp
|
||||
)
|
||||
|
||||
if(PD_BUILD_SHARED)
|
||||
pd_add_lib(pd-image BUILD_SHARED TRUE SRC_FILES ${SRC})
|
||||
else()
|
||||
pd_add_lib(pd-image SRC_FILES ${SRC})
|
||||
endif()
|
||||
@@ -1,27 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
project(pd-lithium LANGUAGES CXX VERSION 0.6.0)
|
||||
|
||||
option(PD_LI_INCLUDE_FONTS "Include Fonts" OFF)
|
||||
|
||||
set(SRC
|
||||
source/command.cpp
|
||||
source/drawlist.cpp
|
||||
source/font.cpp
|
||||
source/fonts.cpp
|
||||
source/renderer.cpp
|
||||
)
|
||||
|
||||
if(PD_BUILD_SHARED)
|
||||
pd_add_lib(pd-lithium BUILD_SHARED TRUE SRC_FILES ${SRC})
|
||||
else()
|
||||
pd_add_lib(pd-lithium SRC_FILES ${SRC})
|
||||
endif()
|
||||
|
||||
if(${PD_LI_INCLUDE_FONTS})
|
||||
target_compile_definitions(pd-lithium PUBLIC
|
||||
-DPD_LI_INCLUDE_FONTS=1
|
||||
)
|
||||
endif()
|
||||
|
||||
target_link_libraries(pd-lithium PUBLIC pd-core)
|
||||
@@ -1,29 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
project(pd-ui7 LANGUAGES CXX VERSION 0.6.0)
|
||||
|
||||
set(SRC
|
||||
source/theme.cpp
|
||||
source/ui7.cpp
|
||||
source/io.cpp
|
||||
source/layout.cpp
|
||||
source/menu.cpp
|
||||
|
||||
source/container/button.cpp
|
||||
source/container/checkbox.cpp
|
||||
source/container/coloredit.cpp
|
||||
source/container/container.cpp
|
||||
source/container/dragdata.cpp
|
||||
source/container/dynobj.cpp
|
||||
source/container/image.cpp
|
||||
source/container/label.cpp
|
||||
source/container/slider.cpp
|
||||
)
|
||||
|
||||
if(PD_BUILD_SHARED)
|
||||
pd_add_lib(pd-ui7 BUILD_SHARED TRUE SRC_FILES ${SRC})
|
||||
else()
|
||||
pd_add_lib(pd-ui7 SRC_FILES ${SRC})
|
||||
endif()
|
||||
|
||||
target_link_libraries(pd-ui7 PUBLIC pd-lithium pd-core)
|
||||
4
source/external/stb.cpp
vendored
Executable file
4
source/external/stb.cpp
vendored
Executable file
@@ -0,0 +1,4 @@
|
||||
#define PD_IMAGE_IMPLEMENTATION
|
||||
#include <pd/external/stb_image.hpp>
|
||||
#define PD_TRUETYPE_IMPLEMENTATION
|
||||
#include <pd/external/stb_truetype.hpp>
|
||||
27
pd/image/source/image.cpp → source/image/image.cpp
Executable file → Normal file
27
pd/image/source/image.cpp → source/image/image.cpp
Executable file → Normal file
@@ -23,44 +23,43 @@ SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef PD_IMAGE_BUILD_SHARED
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#define PD_IMAGE_IMPLEMENTATION
|
||||
#endif
|
||||
|
||||
#include <pd/external/stb_image.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <pd/external/stb_image.hpp>
|
||||
#include <pd/image/image.hpp>
|
||||
#include <pd/image/img_convert.hpp>
|
||||
|
||||
namespace PD {
|
||||
PD_IMAGE_API void Image::Load(const std::string& path) {
|
||||
u8* img = stbi_load(path.c_str(), &pWidth, &pHeight, &fmt, 4);
|
||||
u8* img = pdi_load(path.c_str(), &pWidth, &pHeight, &fmt, 4);
|
||||
if (fmt == 3) {
|
||||
stbi_image_free(img);
|
||||
img = stbi_load(path.c_str(), &pWidth, &pHeight, &fmt, 3);
|
||||
pdi_image_free(img);
|
||||
img = pdi_load(path.c_str(), &pWidth, &pHeight, &fmt, 3);
|
||||
pBuffer = std::vector<PD::u8>(img, img + (pWidth * pHeight * 3));
|
||||
pFmt = RGB;
|
||||
stbi_image_free(img);
|
||||
pdi_image_free(img);
|
||||
} else if (fmt == 4) {
|
||||
pBuffer = std::vector<PD::u8>(img, img + (pWidth * pHeight * 4));
|
||||
pFmt = RGBA;
|
||||
stbi_image_free(img);
|
||||
pdi_image_free(img);
|
||||
}
|
||||
}
|
||||
PD_IMAGE_API void Image::Load(const std::vector<u8>& buf) {
|
||||
u8* img =
|
||||
stbi_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) {
|
||||
stbi_image_free(img);
|
||||
img = stbi_load_from_memory(buf.data(), buf.size(), &pWidth, &pHeight, &fmt,
|
||||
3);
|
||||
pdi_image_free(img);
|
||||
img = pdi_load_from_memory(buf.data(), buf.size(), &pWidth, &pHeight, &fmt,
|
||||
3);
|
||||
pBuffer = std::vector<PD::u8>(img, img + (pWidth * pHeight * 3));
|
||||
pFmt = RGB;
|
||||
stbi_image_free(img);
|
||||
pdi_image_free(img);
|
||||
} else if (fmt == 4) {
|
||||
pBuffer = std::vector<PD::u8>(img, img + (pWidth * pHeight * 4));
|
||||
stbi_image_free(img);
|
||||
pdi_image_free(img);
|
||||
pFmt = RGBA;
|
||||
}
|
||||
}
|
||||
12
pd/image/source/img_blur.cpp → source/image/img_blur.cpp
Executable file → Normal file
12
pd/image/source/img_blur.cpp → source/image/img_blur.cpp
Executable file → Normal file
@@ -45,13 +45,13 @@ PD_IMAGE_API std::vector<float> GaussianKernel(int r, float si) {
|
||||
}
|
||||
return kernel;
|
||||
}
|
||||
PD_IMAGE_API void GaussianBlur(std::vector<u8> &buf, int w, int h, float radius,
|
||||
PD_IMAGE_API void GaussianBlur(std::vector<u8>& buf, int w, int h, float radius,
|
||||
float si,
|
||||
std::function<int(int, int, int)> idxfn) {
|
||||
GaussianBlur(buf.data(), w, h, 4, radius, si, idxfn);
|
||||
}
|
||||
|
||||
PD_IMAGE_API void GaussianBlur(void *buf, int w, int h, int bpp, float radius,
|
||||
PD_IMAGE_API void GaussianBlur(void* buf, int w, int h, int bpp, float radius,
|
||||
float si,
|
||||
std::function<int(int, int, int)> idxfn) {
|
||||
if (bpp != 4 && bpp != 3) {
|
||||
@@ -60,7 +60,7 @@ PD_IMAGE_API void GaussianBlur(void *buf, int w, int h, int bpp, float radius,
|
||||
std::vector<float> kernel = GaussianKernel(radius, si);
|
||||
int hks = kernel.size() / 2;
|
||||
int end = w * h * bpp;
|
||||
std::vector<unsigned char> res((u8 *)buf, ((u8 *)buf) + end);
|
||||
std::vector<unsigned char> res((u8*)buf, ((u8*)buf) + end);
|
||||
ImgConvert::Reverse32(res, w, h);
|
||||
for (int y = 0; y < h; y++) {
|
||||
for (int x = 0; x < w; x++) {
|
||||
@@ -72,9 +72,9 @@ PD_IMAGE_API void GaussianBlur(void *buf, int w, int h, int bpp, float radius,
|
||||
int idx = idxfn(xoff, yoff, w) * 4;
|
||||
|
||||
float weight = kernel[ky + hks] * kernel[kx + hks];
|
||||
r += ((u8 *)buf)[idx] * weight;
|
||||
g += ((u8 *)buf)[idx + 1] * weight;
|
||||
b += ((u8 *)buf)[idx + 2] * weight;
|
||||
r += ((u8*)buf)[idx] * weight;
|
||||
g += ((u8*)buf)[idx + 1] * weight;
|
||||
b += ((u8*)buf)[idx + 2] * weight;
|
||||
}
|
||||
}
|
||||
int idx = idxfn(x, y, w) * bpp;
|
||||
12
pd/image/source/img_convert.cpp → source/image/img_convert.cpp
Executable file → Normal file
12
pd/image/source/img_convert.cpp → source/image/img_convert.cpp
Executable file → Normal file
@@ -25,8 +25,8 @@ SOFTWARE.
|
||||
|
||||
namespace PD::ImgConvert {
|
||||
|
||||
PD_IMAGE_API void RGB24toRGBA32(std::vector<u8> &out, const std::vector<u8> &in,
|
||||
const int &w, const int &h) {
|
||||
PD_IMAGE_API void RGB24toRGBA32(std::vector<u8>& out, const std::vector<u8>& in,
|
||||
const int& w, const int& h) {
|
||||
// Converts RGB24 to RGBA32
|
||||
for (int y = 0; y < h; y++) {
|
||||
for (int x = 0; x < w; x++) {
|
||||
@@ -40,8 +40,8 @@ PD_IMAGE_API void RGB24toRGBA32(std::vector<u8> &out, const std::vector<u8> &in,
|
||||
}
|
||||
}
|
||||
|
||||
PD_IMAGE_API void RGB32toRGBA24(std::vector<u8> &out, const std::vector<u8> &in,
|
||||
const int &w, const int &h) {
|
||||
PD_IMAGE_API void RGB32toRGBA24(std::vector<u8>& out, const std::vector<u8>& in,
|
||||
const int& w, const int& h) {
|
||||
// Converts RGB24 to RGBA32
|
||||
for (int y = 0; y < h; y++) {
|
||||
for (int x = 0; x < w; x++) {
|
||||
@@ -54,7 +54,7 @@ PD_IMAGE_API void RGB32toRGBA24(std::vector<u8> &out, const std::vector<u8> &in,
|
||||
}
|
||||
}
|
||||
|
||||
PD_IMAGE_API void Reverse32(std::vector<u8> &buf, const int &w, const int &h) {
|
||||
PD_IMAGE_API void Reverse32(std::vector<u8>& buf, const int& w, const int& h) {
|
||||
for (int x = 0; x < w; x++) {
|
||||
for (int y = 0; y < h; y++) {
|
||||
int i = y * w + x;
|
||||
@@ -68,7 +68,7 @@ PD_IMAGE_API void Reverse32(std::vector<u8> &buf, const int &w, const int &h) {
|
||||
}
|
||||
}
|
||||
|
||||
PD_IMAGE_API void ReverseBuf(std::vector<u8> &buf, size_t bpp, int w, int h) {
|
||||
PD_IMAGE_API void ReverseBuf(std::vector<u8>& buf, size_t bpp, int w, int h) {
|
||||
std::vector<u8> cpy = buf;
|
||||
for (int x = 0; x < w; x++) {
|
||||
for (int y = 0; y < h; y++) {
|
||||
19
pd/lithium/source/font.cpp → source/lithium/font.cpp
Executable file → Normal file
19
pd/lithium/source/font.cpp → source/lithium/font.cpp
Executable file → Normal file
@@ -26,10 +26,9 @@ SOFTWARE.
|
||||
|
||||
/** Due to Limitations of Shared Lib Stuff */
|
||||
#ifdef PD_LITHIUM_BUILD_SHARED
|
||||
#define STB_TRUETYPE_IMPLEMENTATION
|
||||
#define PD_TRUETYPE_IMPLEMENTATION
|
||||
#endif
|
||||
#include <pd/external/stb_truetype.h>
|
||||
|
||||
#include <pd/external/stb_truetype.hpp>
|
||||
#include <pd/lithium/renderer.hpp>
|
||||
|
||||
#ifdef PD_LI_INCLUDE_FONTS
|
||||
@@ -81,15 +80,15 @@ PD_LITHIUM_API void Font::LoadTTF(const std::vector<u8>& data, int height) {
|
||||
texszs = 1024; // Max size
|
||||
}
|
||||
|
||||
stbtt_fontinfo inf;
|
||||
if (!stbtt_InitFont(&inf, data.data(), 0)) {
|
||||
pdtt_fontinfo inf;
|
||||
if (!pdtt_InitFont(&inf, data.data(), 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
float scale = stbtt_ScaleForPixelHeight(&inf, PixelHeight);
|
||||
float scale = pdtt_ScaleForPixelHeight(&inf, PixelHeight);
|
||||
|
||||
int ascent, descent, lineGap;
|
||||
stbtt_GetFontVMetrics(&inf, &ascent, &descent, &lineGap);
|
||||
pdtt_GetFontVMetrics(&inf, &ascent, &descent, &lineGap);
|
||||
int baseline = static_cast<int>(ascent * scale);
|
||||
|
||||
// Cache to not render same codepoint tex twice
|
||||
@@ -102,13 +101,13 @@ PD_LITHIUM_API void Font::LoadTTF(const std::vector<u8>& data, int height) {
|
||||
bool empty = true;
|
||||
|
||||
for (u32 ii = 0x0000; ii <= 0xFFFF; ii++) {
|
||||
int gi = stbtt_FindGlyphIndex(&inf, ii);
|
||||
int gi = pdtt_FindGlyphIndex(&inf, ii);
|
||||
if (gi == 0) continue;
|
||||
if (stbtt_IsGlyphEmpty(&inf, gi)) continue;
|
||||
if (pdtt_IsGlyphEmpty(&inf, gi)) continue;
|
||||
|
||||
int w = 0, h = 0, xo = 0, yo = 0;
|
||||
unsigned char* bitmap =
|
||||
stbtt_GetCodepointBitmap(&inf, scale, scale, ii, &w, &h, &xo, &yo);
|
||||
pdtt_GetCodepointBitmap(&inf, scale, scale, ii, &w, &h, &xo, &yo);
|
||||
if (!bitmap || w <= 0 || h <= 0) {
|
||||
if (bitmap) free(bitmap);
|
||||
continue;
|
||||
38
pd/ui7/source/ui7.cpp → source/ui7/ui7.cpp
Executable file → Normal file
38
pd/ui7/source/ui7.cpp → source/ui7/ui7.cpp
Executable file → Normal file
@@ -40,19 +40,19 @@ PD_UI7_API std::string GetVersion(bool show_build) {
|
||||
return s.str();
|
||||
}
|
||||
|
||||
PD_UI7_API void Context::AddViewPort(const ID &id, const ivec4 &vp) {
|
||||
PD_UI7_API void Context::AddViewPort(const ID& id, const ivec4& vp) {
|
||||
pIO->AddViewPort(id, vp);
|
||||
}
|
||||
|
||||
PD_UI7_API void Context::UseViewPort(const ID &id) {
|
||||
PD_UI7_API void Context::UseViewPort(const ID& id) {
|
||||
if (!pIO->ViewPorts.count(id)) {
|
||||
return;
|
||||
}
|
||||
pIO->CurrentViewPort = pIO->ViewPorts[id]->GetSize();
|
||||
}
|
||||
|
||||
PD_UI7_API Menu::Ref Context::BeginMenu(const ID &id, UI7MenuFlags flags,
|
||||
bool *pShow) {
|
||||
PD_UI7_API Menu::Ref Context::BeginMenu(const ID& id, UI7MenuFlags flags,
|
||||
bool* pShow) {
|
||||
if (pCurrent) {
|
||||
std::cout << "[UI7] Error: You are already in " << pCurrent->pID.GetName()
|
||||
<< " Menu" << std::endl;
|
||||
@@ -141,7 +141,7 @@ PD_UI7_API void Context::Update() {
|
||||
FinalList.insert(FinalList.begin(), pIO->InputHandler->FocusedMenu);
|
||||
}
|
||||
pDFO = FinalList;
|
||||
for (auto &it : FinalList) {
|
||||
for (auto& it : FinalList) {
|
||||
this->pIO->InputHandler->CurrentMenu = it;
|
||||
pMenus[it]->Update(); /** Render */
|
||||
this->pIO->InputHandler->CurrentMenu = 0;
|
||||
@@ -154,7 +154,7 @@ PD_UI7_API void Context::Update() {
|
||||
pIO->FDL->pPool.Sort();
|
||||
}
|
||||
|
||||
PD_UI7_API void Context::AboutMenu(bool *show) {
|
||||
PD_UI7_API void Context::AboutMenu(bool* show) {
|
||||
if (auto m = BeginMenu("About UI7", UI7MenuFlags_Scrolling, show)) {
|
||||
m->Label("Palladium UI7 " + GetVersion());
|
||||
m->Separator();
|
||||
@@ -176,7 +176,7 @@ PD_UI7_API void Context::AboutMenu(bool *show) {
|
||||
}
|
||||
}
|
||||
|
||||
PD_UI7_API void Context::MetricsMenu(bool *show) {
|
||||
PD_UI7_API void Context::MetricsMenu(bool* show) {
|
||||
if (auto m = BeginMenu("UI7 Metrics", UI7MenuFlags_Scrolling, show)) {
|
||||
m->Label("Palladium - UI7 " + GetVersion());
|
||||
m->Separator();
|
||||
@@ -192,7 +192,7 @@ PD_UI7_API void Context::MetricsMenu(bool *show) {
|
||||
m->SeparatorText("TimeTrace");
|
||||
if (m->BeginTreeNode("Traces (" + std::to_string(OS::GetTraceMap().size()) +
|
||||
")")) {
|
||||
for (auto &it : OS::GetTraceMap()) {
|
||||
for (auto& it : OS::GetTraceMap()) {
|
||||
if (m->BeginTreeNode(it.second->GetID())) {
|
||||
m->Label("Diff: " + UI7DTF(it.second->GetLastDiff()));
|
||||
m->Label("Protocol Len: " +
|
||||
@@ -226,7 +226,7 @@ PD_UI7_API void Context::MetricsMenu(bool *show) {
|
||||
/** Section IO */
|
||||
m->SeparatorText("IO");
|
||||
if (m->BeginTreeNode("Menus (" + std::to_string(pMenus.size()) + ")")) {
|
||||
for (auto &it : pMenus) {
|
||||
for (auto& it : pMenus) {
|
||||
if (m->BeginTreeNode(it.second->pID.GetName())) {
|
||||
m->Label("Name: " + it.second->pID.GetName());
|
||||
m->Label(std::format("Pos: {}", it.second->pLayout->GetPosition()));
|
||||
@@ -236,7 +236,7 @@ PD_UI7_API void Context::MetricsMenu(bool *show) {
|
||||
if (m->BeginTreeNode(
|
||||
"ID Objects (" +
|
||||
std::to_string(it.second->pLayout->IDObjects.size()) + ")")) {
|
||||
for (auto &jt : it.second->pLayout->IDObjects) {
|
||||
for (auto& jt : it.second->pLayout->IDObjects) {
|
||||
m->Label(std::format("{:08X}", jt->GetID()));
|
||||
}
|
||||
m->EndTreeNode();
|
||||
@@ -248,7 +248,7 @@ PD_UI7_API void Context::MetricsMenu(bool *show) {
|
||||
}
|
||||
if (m->BeginTreeNode("Active Menus (" +
|
||||
std::to_string(pCurrentMenus.size()) + ")")) {
|
||||
for (auto &it : pCurrentMenus) {
|
||||
for (auto& it : pCurrentMenus) {
|
||||
if (m->BeginTreeNode(pMenus[it]->pID.GetName())) {
|
||||
m->Label("Name: " + pMenus[it]->pID.GetName());
|
||||
m->Label(std::format("Pos: {}", pMenus[it]->pLayout->GetPosition()));
|
||||
@@ -259,7 +259,7 @@ PD_UI7_API void Context::MetricsMenu(bool *show) {
|
||||
"ID Objects (" +
|
||||
std::to_string(pMenus[it]->pLayout->IDObjects.size()) +
|
||||
")")) {
|
||||
for (auto &jt : pMenus[it]->pLayout->IDObjects) {
|
||||
for (auto& jt : pMenus[it]->pLayout->IDObjects) {
|
||||
m->Label(std::format("{:08X}", jt->GetID()));
|
||||
}
|
||||
m->EndTreeNode();
|
||||
@@ -301,14 +301,14 @@ PD_UI7_API void Context::MetricsMenu(bool *show) {
|
||||
}
|
||||
}
|
||||
|
||||
PD_UI7_API void UI7::Context::StyleEditor(bool *show) {
|
||||
PD_UI7_API void UI7::Context::StyleEditor(bool* show) {
|
||||
if (auto m = BeginMenu("UI7 Style Editor", UI7MenuFlags_Scrolling, show)) {
|
||||
m->Label("Palladium - UI7 " + GetVersion() + " Style Editor");
|
||||
m->Separator();
|
||||
m->DragData("MenuPadding", (float *)&pIO->MenuPadding, 2, 0.f, 100.f);
|
||||
m->DragData("FramePadding", (float *)&pIO->FramePadding, 2, 0.f, 100.f);
|
||||
m->DragData("ItemSpace", (float *)&pIO->ItemSpace, 2, 0.f, 100.f);
|
||||
m->DragData("MinSliderSize", (float *)&pIO->MinSliderDragSize, 2, 1.f,
|
||||
m->DragData("MenuPadding", (float*)&pIO->MenuPadding, 2, 0.f, 100.f);
|
||||
m->DragData("FramePadding", (float*)&pIO->FramePadding, 2, 0.f, 100.f);
|
||||
m->DragData("ItemSpace", (float*)&pIO->ItemSpace, 2, 0.f, 100.f);
|
||||
m->DragData("MinSliderSize", (float*)&pIO->MinSliderDragSize, 2, 1.f,
|
||||
100.f);
|
||||
m->DragData("OverScroll Modifier", &pIO->OverScrollMod, 1, 0.01f,
|
||||
std::numeric_limits<float>::max(), 0.01f, 2);
|
||||
@@ -324,8 +324,8 @@ PD_UI7_API void UI7::Context::StyleEditor(bool *show) {
|
||||
}
|
||||
/// Small trick to print without prefix
|
||||
#define ts(x) m->ColorEdit(std::string(#x).substr(9), pIO->Theme->GetRef(x));
|
||||
#define ts2(x) \
|
||||
m->DragData(std::string(#x).substr(9), (u8 *)&pIO->Theme->GetRef(x), 4, \
|
||||
#define ts2(x) \
|
||||
m->DragData(std::string(#x).substr(9), (u8*)&pIO->Theme->GetRef(x), 4, \
|
||||
(u8)0, (u8)255);
|
||||
ts(UI7Color_Background);
|
||||
ts(UI7Color_Border);
|
||||
Reference in New Issue
Block a user