Files
cimgui/generator/cimgui_template.cpp

142 lines
4.1 KiB
C++
Raw Normal View History

2018-05-07 10:27:55 +02:00
2018-09-02 17:20:46 +02:00
#include "./imgui/imgui.h"
#include "./imgui/imgui_internal.h"
2018-05-07 10:27:55 +02:00
#include "cimgui.h"
2018-05-07 10:27:55 +02:00
#include "auto_funcs.cpp"
2018-05-07 10:27:55 +02:00
/////////////////////////////manual written functions
CIMGUI_API void igLogText(CONST char *fmt, ...)
{
char buffer[256];
va_list args;
va_start(args, fmt);
vsnprintf(buffer, 256, fmt, args);
va_end(args);
ImGui::LogText("%s", buffer);
}
CIMGUI_API void ImGuiTextBuffer_appendf(struct ImGuiTextBuffer *buffer, const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
buffer->appendfv(fmt, args);
va_end(args);
}
2018-06-16 17:49:16 +02:00
CIMGUI_API float igGET_FLT_MAX()
{
return FLT_MAX;
2018-06-16 17:49:16 +02:00
}
CIMGUI_API void igColorConvertRGBtoHSV(float r,float g,float b,float *out_h,float *out_s,float *out_v)
{
ImGui::ColorConvertRGBtoHSV(r,g,b,*out_h,*out_s,*out_v);
}
CIMGUI_API void igColorConvertHSVtoRGB(float h,float s,float v,float *out_r,float *out_g,float *out_b)
{
ImGui::ColorConvertHSVtoRGB(h,s,v,*out_r,*out_g,*out_b);
}
2018-10-17 20:08:40 +02:00
2020-03-25 12:21:04 +01:00
#ifndef IMGUI_USE_WCHAR32
CIMGUI_API ImVector_ImWchar16* ImVector_ImWchar16_create()
2018-10-17 20:08:40 +02:00
{
2020-03-25 12:21:04 +01:00
return IM_NEW(ImVector<ImWchar16>) ();
2018-10-17 20:08:40 +02:00
}
2019-02-14 13:05:49 +01:00
2020-03-25 12:21:04 +01:00
CIMGUI_API void ImVector_ImWchar16_destroy(ImVector_ImWchar16* self)
{
IM_DELETE(self);
}
2020-03-25 12:21:04 +01:00
CIMGUI_API void ImVector_ImWchar16_Init(ImVector_ImWchar16* p)
2018-10-17 20:08:40 +02:00
{
2020-03-25 12:21:04 +01:00
IM_PLACEMENT_NEW(p) ImVector<ImWchar16>();
2018-10-17 20:08:40 +02:00
}
2020-03-25 12:21:04 +01:00
CIMGUI_API void ImVector_ImWchar16_UnInit(ImVector_ImWchar16* p)
2018-10-17 20:08:40 +02:00
{
2020-03-25 12:21:04 +01:00
p->~ImVector<ImWchar16>();
2018-10-17 20:08:40 +02:00
}
2020-03-25 12:21:04 +01:00
#else
CIMGUI_API ImVector_ImWchar32* ImVector_ImWchar32_create()
{
return IM_NEW(ImVector<ImWchar32>) ();
}
CIMGUI_API void ImVector_ImWchar32_destroy(ImVector_ImWchar32* self)
{
IM_DELETE(self);
}
CIMGUI_API void ImVector_ImWchar32_Init(ImVector_ImWchar32* p)
{
IM_PLACEMENT_NEW(p) ImVector<ImWchar32>();
}
CIMGUI_API void ImVector_ImWchar32_UnInit(ImVector_ImWchar32* p)
{
p->~ImVector<ImWchar32>();
}
#endif
2018-10-17 20:08:40 +02:00
#ifdef IMGUI_HAS_DOCK
// NOTE: Some function pointers in the ImGuiPlatformIO structure are not C-compatible because of their
// use of a complex return type. To work around this, we store a custom CimguiStorage object inside
// ImGuiIO::BackendLanguageUserData, which contains C-compatible function pointer variants for these
// functions. When a user function pointer is provided, we hook up the underlying ImGuiPlatformIO
// function pointer to a thunk which accesses the user function pointer through CimguiStorage.
struct CimguiStorage
{
void(*Platform_GetWindowPos)(ImGuiViewport* vp, ImVec2* out_pos);
void(*Platform_GetWindowSize)(ImGuiViewport* vp, ImVec2* out_pos);
};
// Gets a reference to the CimguiStorage object stored in the current ImGui context's BackendLanguageUserData.
CimguiStorage& GetCimguiStorage()
{
ImGuiIO& io = ImGui::GetIO();
if (io.BackendLanguageUserData == NULL)
{
io.BackendLanguageUserData = new CimguiStorage();
}
return *(CimguiStorage*)io.BackendLanguageUserData;
}
// Thunk satisfying the signature of ImGuiPlatformIO::Platform_GetWindowPos.
ImVec2 Platform_GetWindowPos_hook(ImGuiViewport* vp)
{
ImVec2 pos;
GetCimguiStorage().Platform_GetWindowPos(vp, &pos);
return pos;
};
// Fully C-compatible function pointer setter for ImGuiPlatformIO::Platform_GetWindowPos.
CIMGUI_API void ImGuiPlatformIO_Set_Platform_GetWindowPos(ImGuiPlatformIO* platform_io, void(*user_callback)(ImGuiViewport* vp, ImVec2* out_pos))
{
CimguiStorage& storage = GetCimguiStorage();
storage.Platform_GetWindowPos = user_callback;
platform_io->Platform_GetWindowPos = &Platform_GetWindowPos_hook;
}
// Thunk satisfying the signature of ImGuiPlatformIO::Platform_GetWindowSize.
ImVec2 Platform_GetWindowSize_hook(ImGuiViewport* vp)
{
ImVec2 size;
GetCimguiStorage().Platform_GetWindowSize(vp, &size);
return size;
};
// Fully C-compatible function pointer setter for ImGuiPlatformIO::Platform_GetWindowSize.
CIMGUI_API void ImGuiPlatformIO_Set_Platform_GetWindowSize(ImGuiPlatformIO* platform_io, void(*user_callback)(ImGuiViewport* vp, ImVec2* out_size))
{
CimguiStorage& storage = GetCimguiStorage();
storage.Platform_GetWindowSize = user_callback;
platform_io->Platform_GetWindowSize = &Platform_GetWindowSize_hook;
}
#endif