diff --git a/cimgui/Makefile b/cimgui/Makefile index 7a45ba3..01a0103 100644 --- a/cimgui/Makefile +++ b/cimgui/Makefile @@ -3,6 +3,8 @@ # Compatible with Ubuntu 14.04.1 and Mac OS X OBJS = cimgui.o +OBJS += fontAtlas.o +OBJS += drawList.o OBJS += ../imgui/imgui.o UNAME_S := $(shell uname -s) diff --git a/cimgui/cimgui.cpp b/cimgui/cimgui.cpp index 1ee9d91..f000027 100644 --- a/cimgui/cimgui.cpp +++ b/cimgui/cimgui.cpp @@ -3,49 +3,201 @@ #include #include "../imgui/imgui.h" +#include "cimgui.h" -#if defined _WIN32 || defined __CYGWIN__ -#define API __declspec(dllexport) -#else -#define API -#endif - -extern "C" API ImGuiIO* ImGui_GetIO() +CIMGUI_API ImGuiIO* ig_GetIO() { return &ImGui::GetIO(); } -extern "C" API void ImGui_Shutdown() +CIMGUI_API ImGuiStyle* ig_GetStyle() { - ImGui::Shutdown(); + return &ImGui::GetStyle(); } -extern "C" API void ImGui_NewFrame() +CIMGUI_API void ig_NewFrame() { ImGui::NewFrame(); } -extern "C" API void ImGui_Render() +CIMGUI_API void ig_Render() { ImGui::Render(); } -extern "C" API void ImGui_ShowTestWindow(bool* opened) +CIMGUI_API void ig_Shutdown() +{ + ImGui::Shutdown(); +} + +CIMGUI_API void ig_ShowUserGuide() +{ + ImGui::ShowUserGuide(); +} + +CIMGUI_API void ig_ShowStyleEditor(ImGuiStyle* ref) +{ + ImGui::ShowStyleEditor(ref); +} + +CIMGUI_API void ig_ShowTestWindow(bool* opened) { ImGui::ShowTestWindow(opened); } -extern "C" API bool ImGui_Begin(const char* name, bool* p_opened, ImGuiWindowFlags flags) +IMGUI_API void ig_ShowMetricsWindow(bool* opened) +{ + ImGui::ShowMetricsWindow(opened); +} + +// Window + +CIMGUI_API bool ig_Begin(const char* name, bool* p_opened, ImGuiWindowFlags flags) { return ImGui::Begin(name, p_opened, flags); } -extern "C" API void ImGui_End() +CIMGUI_API bool ig_Begin2(const char* name, bool* p_opened, const ImVec2& size_on_first_use, float bg_alpha, ImGuiWindowFlags flags) +{ + return ImGui::Begin(name, p_opened, size_on_first_use, bg_alpha, flags); +} + +CIMGUI_API void ig_End() { ImGui::End(); } -extern "C" API void ImGui_Text(const char* text, ...) +CIMGUI_API bool ig_BeginChild(const char* str_id, const ImVec2& size, bool border, ImGuiWindowFlags extra_flags) +{ + return ImGui::BeginChild(str_id, size, border, extra_flags); +} + +CIMGUI_API bool ig_BeginChild2(ImGuiID id, const ImVec2& size, bool border, ImGuiWindowFlags extra_flags) +{ + return ImGui::BeginChild(id, size, border, extra_flags); +} + +CIMGUI_API void ig_EndChild() +{ + ImGui::EndChild(); +} + +CIMGUI_API void ig_GetContentRegionMax(ImVec2& out) +{ + out = ImGui::GetContentRegionMax(); +} + +CIMGUI_API void ig_GetWindowContentRegionMin(ImVec2& out) +{ + out = ImGui::GetWindowContentRegionMin(); +} + +CIMGUI_API void ig_GetWindowContentRegionMax(ImVec2& out) +{ + out = ImGui::GetWindowContentRegionMax(); +} + +CIMGUI_API ImDrawList* ig_GetWindowDrawList() +{ + return ImGui::GetWindowDrawList(); +} + +CIMGUI_API ImFont* ig_GetWindowFont() +{ + return ImGui::GetWindowFont(); +} + +CIMGUI_API float ig_GetWindowFontSize() +{ + return ImGui::GetWindowFontSize(); +} + +CIMGUI_API void ig_SetWindowFontScale(float scale) +{ + ImGui::SetWindowFontScale(scale); +} + +CIMGUI_API void ig_GetWindowPos(ImVec2& out) +{ + out = ImGui::GetWindowPos(); +} + +CIMGUI_API void ig_GetWindowSize(ImVec2& out) +{ + out = ImGui::GetWindowSize(); +} + +CIMGUI_API float ig_GetWindowWidth() +{ + return ImGui::GetWindowWidth(); +} + +CIMGUI_API bool ig_GetWindowCollapsed() +{ + return ImGui::GetWindowCollapsed(); +} + +CIMGUI_API void ig_SetNextWindowPos(const ImVec2& pos, ImGuiSetCond cond) +{ + ImGui::SetNextWindowPos(pos, cond); +} + +CIMGUI_API void ig_SetNextWindowSize(const ImVec2& size, ImGuiSetCond cond) +{ + ImGui::SetNextWindowSize(size, cond); +} + +CIMGUI_API void ig_SetNextWindowCollapsed(bool collapsed, ImGuiSetCond cond) +{ + ImGui::SetNextWindowCollapsed(collapsed,cond); +} + +CIMGUI_API void ig_SetNextWindowFocus() +{ + ImGui::SetNextWindowFocus(); +} + +CIMGUI_API void ig_SetWindowPos(const ImVec2& pos, ImGuiSetCond cond) +{ + ImGui::SetWindowPos(pos,cond); +} + +CIMGUI_API void ig_SetWindowSize(const ImVec2& size, ImGuiSetCond cond) +{ + ImGui::SetWindowSize(size, cond); +} + +CIMGUI_API void ig_SetWindowCollapsed(bool collapsed, ImGuiSetCond cond) +{ + ImGui::SetWindowCollapsed(collapsed,cond); +} + +CIMGUI_API void ig_SetWindowFocus() +{ + ImGui::SetWindowFocus(); +} + +CIMGUI_API void ig_SetWindowPos2(const char* name, const ImVec2& pos, ImGuiSetCond cond) +{ + ImGui::SetWindowPos(name,pos,cond); +} + +CIMGUI_API void ig_SetWindowSize2(const char* name, const ImVec2& size, ImGuiSetCond cond) +{ + ImGui::SetWindowSize(name, size, cond); +} + +CIMGUI_API void ig_SetWindowCollapsed2(const char* name, bool collapsed, ImGuiSetCond cond) +{ + ImGui::SetWindowCollapsed(name, collapsed, cond); +} + +CIMGUI_API void ig_SetWindowFocus2(const char* name) +{ + ImGui::SetWindowFocus(name); +} + +CIMGUI_API void ig_Text(const char* text, ...) { char buffer[256]; va_list args; @@ -56,42 +208,32 @@ extern "C" API void ImGui_Text(const char* text, ...) ImGui::Text(buffer); } -extern "C" API bool ImGui_ColorEdit3(const char* label, float col[3]) +CIMGUI_API bool ig_ColorEdit3(const char* label, float col[3]) { return ImGui::ColorEdit3(label,col); } -extern "C" API void ImGui_SetNextWindowPos(const ImVec2 pos, ImGuiSetCond cond) -{ - ImGui::SetNextWindowPos(pos,cond); -} - -extern "C" API void ImGui_SetNextWindowSize(const ImVec2 size, ImGuiSetCond cond) -{ - ImGui::SetNextWindowSize(size, cond); -} - -extern "C" API void ImGui_SliderFloat(const char* label, float* v, float v_min, float v_max, const char* display_format, float power) +CIMGUI_API void ig_SliderFloat(const char* label, float* v, float v_min, float v_max, const char* display_format, float power) { ImGui::SliderFloat(label,v,v_min,v_max,display_format,power); } -extern "C" API bool ImGui_Button(const char* label, const ImVec2& size, bool repeat_when_held) +CIMGUI_API bool ig_Button(const char* label, const ImVec2& size, bool repeat_when_held) { return ImGui::Button(label,size,repeat_when_held); } -extern "C" API bool ImGui_SmallButton(const char* label) +CIMGUI_API bool ig_SmallButton(const char* label) { return ImGui::SmallButton(label); } -extern "C" API bool ImGui_TreeNode(const char* str_label_id) +CIMGUI_API bool ig_TreeNode(const char* str_label_id) { return ImGui::TreeNode(str_label_id); } -extern "C" API bool ImGui_TreeNode_IdFmt(const void* ptr_id, const char* fmt, ...) +CIMGUI_API bool ig_TreeNode_IdFmt(const void* ptr_id, const char* fmt, ...) { char buffer[256]; va_list args; @@ -103,47 +245,17 @@ extern "C" API bool ImGui_TreeNode_IdFmt(const void* ptr_id, const char* fmt, .. return ImGui::TreeNode(ptr_id,"%s",buffer); } -extern "C" API void ImGui_TreePop() +CIMGUI_API void ig_TreePop() { ImGui::TreePop(); } -extern "C" API void ImGui_SameLine(int column_x, int spacing_w) +CIMGUI_API void ig_SameLine(int column_x, int spacing_w) { ImGui::SameLine(column_x,spacing_w); } -extern "C" API void ImFontAtlas_GetTexDataAsRGBA32(ImFontAtlas* atlas, unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel) -{ - atlas->GetTexDataAsRGBA32(out_pixels,out_width,out_height,out_bytes_per_pixel); -} - -extern "C" API void ImFontAtlas_SetTexID(ImFontAtlas* atlas, void* tex) -{ - atlas->TexID = tex; -} - -extern "C" API int ImDrawList_GetVertexBufferSize(ImDrawList* list) -{ - return list->vtx_buffer.size(); -} - -extern "C" API ImDrawVert* ImDrawList_GetVertexPtr(ImDrawList* list, int n) -{ - return &list->vtx_buffer[n]; -} - -extern "C" API int ImDrawList_GetCmdSize(ImDrawList* list) -{ - return list->commands.size(); -} - -extern "C" API ImDrawCmd* ImDrawList_GetCmdPtr(ImDrawList* list, int n) -{ - return &list->commands[n]; -} - -extern "C" API void ImGuiIO_AddInputCharacter(unsigned short c) +CIMGUI_API void ImGuiIO_AddInputCharacter(unsigned short c) { ImGui::GetIO().AddInputCharacter(c); } diff --git a/cimgui/cimgui.h b/cimgui/cimgui.h new file mode 100644 index 0000000..17a411b --- /dev/null +++ b/cimgui/cimgui.h @@ -0,0 +1,51 @@ + +#if defined _WIN32 || defined __CYGWIN__ +#define API __declspec(dllexport) +#else +#define API +#endif + +#define EXTERN extern "C" +#define CIMGUI_API EXTERN API + +CIMGUI_API ImGuiIO* ig_GetIO(); +CIMGUI_API ImGuiStyle* ig_GetStyle(); +CIMGUI_API void ig_NewFrame(); +CIMGUI_API void ig_Render(); +CIMGUI_API void ig_Shutdown(); +CIMGUI_API void ig_ShowUserGuide(); +CIMGUI_API void ig_ShowStyleEditor(ImGuiStyle* ref); +CIMGUI_API void ig_ShowTestWindow(bool* opened = NULL); +CIMGUI_API void ig_ShowMetricsWindow(bool* opened = NULL); + +// Window +CIMGUI_API bool ig_Begin(const char* name = "Debug", bool* p_opened = NULL, ImGuiWindowFlags flags = 0); +CIMGUI_API bool ig_Begin2(const char* name, bool* p_opened, const ImVec2& size_on_first_use, float bg_alpha = -1.0f, ImGuiWindowFlags flags = 0); +CIMGUI_API void ig_End(); +CIMGUI_API bool ig_BeginChild(const char* str_id, const ImVec2& size = ImVec2(0, 0), bool border = false, ImGuiWindowFlags extra_flags = 0); +CIMGUI_API bool ig_BeginChild2(ImGuiID id, const ImVec2& size = ImVec2(0, 0), bool border = false, ImGuiWindowFlags extra_flags = 0); +CIMGUI_API void ig_EndChild(); +CIMGUI_API void ig_GetContentRegionMax(ImVec2& out); +CIMGUI_API void ig_GetWindowContentRegionMin(ImVec2& out); +CIMGUI_API void ig_GetWindowContentRegionMax(ImVec2& out); +CIMGUI_API ImDrawList* ig_GetWindowDrawList(); +CIMGUI_API ImFont* ig_GetWindowFont(); +CIMGUI_API float ig_GetWindowFontSize(); +CIMGUI_API void ig_SetWindowFontScale(float scale); +CIMGUI_API void ig_GetWindowPos(ImVec2& out); +CIMGUI_API void ig_GetWindowSize(ImVec2& out); +CIMGUI_API float ig_GetWindowWidth(); +CIMGUI_API bool ig_GetWindowCollapsed(); + +CIMGUI_API void ig_SetNextWindowPos(const ImVec2& pos, ImGuiSetCond cond = 0); +CIMGUI_API void ig_SetNextWindowSize(const ImVec2& size, ImGuiSetCond cond = 0); +CIMGUI_API void ig_SetNextWindowCollapsed(bool collapsed, ImGuiSetCond cond = 0); +CIMGUI_API void ig_SetNextWindowFocus(); +CIMGUI_API void ig_SetWindowPos(const ImVec2& pos, ImGuiSetCond cond = 0); +CIMGUI_API void ig_SetWindowSize(const ImVec2& size, ImGuiSetCond cond = 0); +CIMGUI_API void ig_SetWindowCollapsed(bool collapsed, ImGuiSetCond cond = 0); +CIMGUI_API void ig_SetWindowFocus(); +CIMGUI_API void ig_SetWindowPos2(const char* name, const ImVec2& pos, ImGuiSetCond cond = 0); +CIMGUI_API void ig_SetWindowSize2(const char* name, const ImVec2& size, ImGuiSetCond cond = 0); +CIMGUI_API void ig_SetWindowCollapsed2(const char* name, bool collapsed, ImGuiSetCond cond = 0); +CIMGUI_API void ig_SetWindowFocus2(const char* name); \ No newline at end of file diff --git a/cimgui/cimgui.vcxproj b/cimgui/cimgui.vcxproj index 21adeb0..dcd3fbc 100644 --- a/cimgui/cimgui.vcxproj +++ b/cimgui/cimgui.vcxproj @@ -78,6 +78,11 @@ + + + + + diff --git a/cimgui/cimgui.vcxproj.filters b/cimgui/cimgui.vcxproj.filters index 503f5a4..ea0acef 100644 --- a/cimgui/cimgui.vcxproj.filters +++ b/cimgui/cimgui.vcxproj.filters @@ -21,5 +21,16 @@ Source Files + + Source Files + + + Source Files + + + + + Source Files + \ No newline at end of file diff --git a/cimgui/drawList.cpp b/cimgui/drawList.cpp new file mode 100644 index 0000000..ef20a76 --- /dev/null +++ b/cimgui/drawList.cpp @@ -0,0 +1,23 @@ + +#include "../imgui/imgui.h" +#include "cimgui.h" + +EXTERN API int ImDrawList_GetVertexBufferSize(ImDrawList* list) +{ + return list->vtx_buffer.size(); +} + +EXTERN API ImDrawVert* ImDrawList_GetVertexPtr(ImDrawList* list, int n) +{ + return &list->vtx_buffer[n]; +} + +EXTERN API int ImDrawList_GetCmdSize(ImDrawList* list) +{ + return list->commands.size(); +} + +EXTERN API ImDrawCmd* ImDrawList_GetCmdPtr(ImDrawList* list, int n) +{ + return &list->commands[n]; +} \ No newline at end of file diff --git a/cimgui/fontAtlas.cpp b/cimgui/fontAtlas.cpp new file mode 100644 index 0000000..3fca05f --- /dev/null +++ b/cimgui/fontAtlas.cpp @@ -0,0 +1,18 @@ + +#include "../imgui/imgui.h" +#include "cimgui.h" + +EXTERN API void ImFontAtlas_GetTexDataAsRGBA32(ImFontAtlas* atlas, unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel) +{ + atlas->GetTexDataAsRGBA32(out_pixels, out_width, out_height, out_bytes_per_pixel); +} + +EXTERN API void ImFontAtlas_GetTexDataAsAlpha8(ImFontAtlas* atlas, unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel) +{ + atlas->GetTexDataAsAlpha8(out_pixels, out_width, out_height, out_bytes_per_pixel); +} + +EXTERN API void ImFontAtlas_SetTexID(ImFontAtlas* atlas, void* tex) +{ + atlas->TexID = tex; +} \ No newline at end of file