From 4326262d8c81b58fa94eeae7eb710abd8da488f1 Mon Sep 17 00:00:00 2001 From: Allen Dang Date: Tue, 22 Mar 2022 19:17:49 +0800 Subject: [PATCH] Try to fix Unsafe pointer arithmetic issue --- DrawCommandWrapper.cpp | 2 +- FontAtlasWrapper.cpp | 178 +++---- imguiWrapper.cpp | 965 +++++++++---------------------------- imguiWrapperTypes.h | 4 +- imgui_markdown_wrapper.cpp | 141 +++--- 5 files changed, 389 insertions(+), 901 deletions(-) diff --git a/DrawCommandWrapper.cpp b/DrawCommandWrapper.cpp index 05595e04..f00c3b00 100644 --- a/DrawCommandWrapper.cpp +++ b/DrawCommandWrapper.cpp @@ -19,7 +19,7 @@ void iggDrawCommandGetClipRect(IggDrawCmd handle, IggVec4 *rect) { void iggDrawCommandGetTextureID(IggDrawCmd handle, IggTextureID *id) { ImDrawCmd *cmd = reinterpret_cast(handle); - *id = cmd->GetTexID(); + *id = reinterpret_cast(cmd->TextureId); } IggBool iggDrawCommandHasUserCallback(IggDrawCmd handle) { diff --git a/FontAtlasWrapper.cpp b/FontAtlasWrapper.cpp index 0edfd853..47775e50 100644 --- a/FontAtlasWrapper.cpp +++ b/FontAtlasWrapper.cpp @@ -1,147 +1,121 @@ -#include "imguiWrappedHeader.h" #include "FontAtlasWrapper.h" #include "WrapperConverter.h" +#include "imguiWrappedHeader.h" - -IggGlyphRanges iggGetGlyphRangesAll() -{ - static const ImWchar ranges[] = { - 0x0001, 0xFFFF, +IggGlyphRanges iggGetGlyphRangesAll() { + static const ImWchar ranges[] = { + 0x0001, + 0xFFFF, 0, - }; - return static_cast(const_cast(&ranges[0])); + }; + return static_cast(const_cast(&ranges[0])); } -IggGlyphRanges iggGetGlyphRangesDefault(IggFontAtlas handle) -{ - ImFontAtlas *fontAtlas = reinterpret_cast(handle); - return static_cast(const_cast(fontAtlas->GetGlyphRangesDefault())); +IggGlyphRanges iggGetGlyphRangesDefault(IggFontAtlas handle) { + ImFontAtlas *fontAtlas = reinterpret_cast(handle); + return static_cast(const_cast(fontAtlas->GetGlyphRangesDefault())); } -IggGlyphRanges iggGetGlyphRangesKorean(IggFontAtlas handle) -{ - ImFontAtlas *fontAtlas = reinterpret_cast(handle); - return static_cast(const_cast(fontAtlas->GetGlyphRangesKorean())); +IggGlyphRanges iggGetGlyphRangesKorean(IggFontAtlas handle) { + ImFontAtlas *fontAtlas = reinterpret_cast(handle); + return static_cast(const_cast(fontAtlas->GetGlyphRangesKorean())); } -IggGlyphRanges iggGetGlyphRangesJapanese(IggFontAtlas handle) -{ - ImFontAtlas *fontAtlas = reinterpret_cast(handle); - return static_cast(const_cast(fontAtlas->GetGlyphRangesJapanese())); +IggGlyphRanges iggGetGlyphRangesJapanese(IggFontAtlas handle) { + ImFontAtlas *fontAtlas = reinterpret_cast(handle); + return static_cast(const_cast(fontAtlas->GetGlyphRangesJapanese())); } -IggGlyphRanges iggGetGlyphRangesChineseFull(IggFontAtlas handle) -{ - ImFontAtlas *fontAtlas = reinterpret_cast(handle); - return static_cast(const_cast(fontAtlas->GetGlyphRangesChineseFull())); +IggGlyphRanges iggGetGlyphRangesChineseFull(IggFontAtlas handle) { + ImFontAtlas *fontAtlas = reinterpret_cast(handle); + return static_cast(const_cast(fontAtlas->GetGlyphRangesChineseFull())); } -IggGlyphRanges iggGetGlyphRangesChineseSimplifiedCommon(IggFontAtlas handle) -{ - ImFontAtlas *fontAtlas = reinterpret_cast(handle); - return static_cast(const_cast(fontAtlas->GetGlyphRangesChineseSimplifiedCommon())); +IggGlyphRanges iggGetGlyphRangesChineseSimplifiedCommon(IggFontAtlas handle) { + ImFontAtlas *fontAtlas = reinterpret_cast(handle); + return static_cast(const_cast(fontAtlas->GetGlyphRangesChineseSimplifiedCommon())); } -IggGlyphRanges iggGetGlyphRangesCyrillic(IggFontAtlas handle) -{ - ImFontAtlas *fontAtlas = reinterpret_cast(handle); - return static_cast(const_cast(fontAtlas->GetGlyphRangesCyrillic())); +IggGlyphRanges iggGetGlyphRangesCyrillic(IggFontAtlas handle) { + ImFontAtlas *fontAtlas = reinterpret_cast(handle); + return static_cast(const_cast(fontAtlas->GetGlyphRangesCyrillic())); } -IggGlyphRanges iggGetGlyphRangesThai(IggFontAtlas handle) -{ - ImFontAtlas *fontAtlas = reinterpret_cast(handle); - return static_cast(const_cast(fontAtlas->GetGlyphRangesThai())); +IggGlyphRanges iggGetGlyphRangesThai(IggFontAtlas handle) { + ImFontAtlas *fontAtlas = reinterpret_cast(handle); + return static_cast(const_cast(fontAtlas->GetGlyphRangesThai())); } -IggFont iggAddFontDefault(IggFontAtlas handle) -{ - ImFontAtlas *fontAtlas = reinterpret_cast(handle); - ImFont *font = fontAtlas->AddFontDefault(); - return static_cast(font); +IggFont iggAddFontDefault(IggFontAtlas handle) { + ImFontAtlas *fontAtlas = reinterpret_cast(handle); + ImFont *font = fontAtlas->AddFontDefault(); + return static_cast(font); } -IggFont iggAddFontDefaultV(IggFontAtlas handle, IggFontConfig config) -{ - ImFontAtlas *fontAtlas = reinterpret_cast(handle); - ImFontConfig *fontConfig = reinterpret_cast(config); - ImFont *font = fontAtlas->AddFontDefault(fontConfig); - return static_cast(font); +IggFont iggAddFontDefaultV(IggFontAtlas handle, IggFontConfig config) { + ImFontAtlas *fontAtlas = reinterpret_cast(handle); + ImFontConfig *fontConfig = reinterpret_cast(config); + ImFont *font = fontAtlas->AddFontDefault(fontConfig); + return static_cast(font); } -IggFont iggAddFontFromFileTTF(IggFontAtlas handle, char const *filename, float sizePixels, - IggFontConfig config, IggGlyphRanges glyphRanges) -{ - ImFontAtlas *fontAtlas = reinterpret_cast(handle); - ImFontConfig *fontConfig = reinterpret_cast(config); - ImWchar *glyphChars = reinterpret_cast(glyphRanges); - ImFont *font = fontAtlas->AddFontFromFileTTF(filename, sizePixels, fontConfig, glyphChars); - return static_cast(font); +IggFont iggAddFontFromFileTTF(IggFontAtlas handle, char const *filename, float sizePixels, IggFontConfig config, IggGlyphRanges glyphRanges) { + ImFontAtlas *fontAtlas = reinterpret_cast(handle); + ImFontConfig *fontConfig = reinterpret_cast(config); + ImWchar *glyphChars = reinterpret_cast(glyphRanges); + ImFont *font = fontAtlas->AddFontFromFileTTF(filename, sizePixels, fontConfig, glyphChars); + return static_cast(font); } -IggFont iggAddFontFromMemoryTTF(IggFontAtlas handle, char *font_data, int font_size, float sizePixels, - IggFontConfig config, IggGlyphRanges glyphRanges) -{ - ImFontAtlas *fontAtlas = reinterpret_cast(handle); - ImFontConfig *fontConfig = reinterpret_cast(config); - ImWchar *glyphChars = reinterpret_cast(glyphRanges); - ImFont *font = fontAtlas->AddFontFromMemoryTTF(font_data, font_size, sizePixels, fontConfig, glyphChars); - return static_cast(font); +IggFont iggAddFontFromMemoryTTF(IggFontAtlas handle, char *font_data, int font_size, float sizePixels, IggFontConfig config, IggGlyphRanges glyphRanges) { + ImFontAtlas *fontAtlas = reinterpret_cast(handle); + ImFontConfig *fontConfig = reinterpret_cast(config); + ImWchar *glyphChars = reinterpret_cast(glyphRanges); + ImFont *font = fontAtlas->AddFontFromMemoryTTF(font_data, font_size, sizePixels, fontConfig, glyphChars); + return static_cast(font); } - -void iggFontAtlasSetTexDesiredWidth(IggFontAtlas handle, int value) -{ - ImFontAtlas *fontAtlas = reinterpret_cast(handle); - fontAtlas->TexDesiredWidth = value; +void iggFontAtlasSetTexDesiredWidth(IggFontAtlas handle, int value) { + ImFontAtlas *fontAtlas = reinterpret_cast(handle); + fontAtlas->TexDesiredWidth = value; } -void iggFontAtlasGetTexDataAsAlpha8(IggFontAtlas handle, unsigned char **pixels, - int *width, int *height, int *bytesPerPixel) -{ - ImFontAtlas *fontAtlas = reinterpret_cast(handle); - fontAtlas->GetTexDataAsAlpha8(pixels, width, height, bytesPerPixel); +void iggFontAtlasGetTexDataAsAlpha8(IggFontAtlas handle, unsigned char **pixels, int *width, int *height, int *bytesPerPixel) { + ImFontAtlas *fontAtlas = reinterpret_cast(handle); + fontAtlas->GetTexDataAsAlpha8(pixels, width, height, bytesPerPixel); } -void iggFontAtlasGetTexDataAsRGBA32(IggFontAtlas handle, unsigned char **pixels, - int *width, int *height, int *bytesPerPixel) -{ - ImFontAtlas *fontAtlas = reinterpret_cast(handle); - fontAtlas->GetTexDataAsRGBA32(pixels, width, height, bytesPerPixel); +void iggFontAtlasGetTexDataAsRGBA32(IggFontAtlas handle, unsigned char **pixels, int *width, int *height, int *bytesPerPixel) { + ImFontAtlas *fontAtlas = reinterpret_cast(handle); + fontAtlas->GetTexDataAsRGBA32(pixels, width, height, bytesPerPixel); } -void iggFontAtlasSetTextureID(IggFontAtlas handle, IggTextureID id) -{ - ImFontAtlas *fontAtlas = reinterpret_cast(handle); - fontAtlas->SetTexID(id); +void iggFontAtlasSetTextureID(IggFontAtlas handle, IggTextureID id) { + ImFontAtlas *fontAtlas = reinterpret_cast(handle); + fontAtlas->SetTexID(reinterpret_cast(id)); } -void iggFontAtlasBuild(IggFontAtlas handle) -{ - ImFontAtlas *fontAtlas = reinterpret_cast(handle); - fontAtlas->Build(); +void iggFontAtlasBuild(IggFontAtlas handle) { + ImFontAtlas *fontAtlas = reinterpret_cast(handle); + fontAtlas->Build(); } -void iggFontAtlasClear(IggFontAtlas handle) -{ - ImFontAtlas *fontAtlas = reinterpret_cast(handle); - fontAtlas->Clear(); +void iggFontAtlasClear(IggFontAtlas handle) { + ImFontAtlas *fontAtlas = reinterpret_cast(handle); + fontAtlas->Clear(); } -unsigned int iggFontAtlasGetFontBuilderFlags(IggFontAtlas handle) -{ - ImFontAtlas *fontAtlas = reinterpret_cast(handle); - return fontAtlas->FontBuilderFlags; +unsigned int iggFontAtlasGetFontBuilderFlags(IggFontAtlas handle) { + ImFontAtlas *fontAtlas = reinterpret_cast(handle); + return fontAtlas->FontBuilderFlags; } -void iggFontAtlasSetFontBuilderFlags(IggFontAtlas handle, unsigned int flags) -{ - ImFontAtlas *fontAtlas = reinterpret_cast(handle); - fontAtlas->FontBuilderFlags = flags; +void iggFontAtlasSetFontBuilderFlags(IggFontAtlas handle, unsigned int flags) { + ImFontAtlas *fontAtlas = reinterpret_cast(handle); + fontAtlas->FontBuilderFlags = flags; } -int iggFontAtlasFontCount(IggFontAtlas handle) -{ - ImFontAtlas *fontAtlas = reinterpret_cast(handle); - return fontAtlas->Fonts.size(); +int iggFontAtlasFontCount(IggFontAtlas handle) { + ImFontAtlas *fontAtlas = reinterpret_cast(handle); + return fontAtlas->Fonts.size(); } diff --git a/imguiWrapper.cpp b/imguiWrapper.cpp index 2b13df3d..6bc05822 100644 --- a/imguiWrapper.cpp +++ b/imguiWrapper.cpp @@ -1,936 +1,453 @@ -#include "imguiWrappedHeader.h" #include "imguiWrapper.h" #include "WrapperConverter.h" +#include "imguiWrappedHeader.h" -IggContext iggCreateContext(IggFontAtlas sharedFontAtlas) -{ - ImGuiContext *context = ImGui::CreateContext(reinterpret_cast(sharedFontAtlas)); - return reinterpret_cast(context); +IggContext iggCreateContext(IggFontAtlas sharedFontAtlas) { + ImGuiContext *context = ImGui::CreateContext(reinterpret_cast(sharedFontAtlas)); + return reinterpret_cast(context); } -void iggDestroyContext(IggContext context) -{ - ImGui::DestroyContext(reinterpret_cast(context)); -} +void iggDestroyContext(IggContext context) { ImGui::DestroyContext(reinterpret_cast(context)); } -IggContext iggGetCurrentContext() -{ - return reinterpret_cast(ImGui::GetCurrentContext()); -} +IggContext iggGetCurrentContext() { return reinterpret_cast(ImGui::GetCurrentContext()); } -void iggSetCurrentContext(IggContext context) -{ - ImGui::SetCurrentContext(reinterpret_cast(context)); -} +void iggSetCurrentContext(IggContext context) { ImGui::SetCurrentContext(reinterpret_cast(context)); } -void iggSetMaxWaitBeforeNextFrame(double time) -{ - ImGui::SetMaxWaitBeforeNextFrame(time); -} +void iggSetMaxWaitBeforeNextFrame(double time) { ImGui::SetMaxWaitBeforeNextFrame(time); } -IggIO iggGetCurrentIO() -{ - return reinterpret_cast(&ImGui::GetIO()); -} +IggIO iggGetCurrentIO() { return reinterpret_cast(&ImGui::GetIO()); } -IggGuiStyle iggGetCurrentStyle() -{ - return reinterpret_cast(&ImGui::GetStyle()); -} +IggGuiStyle iggGetCurrentStyle() { return reinterpret_cast(&ImGui::GetStyle()); } -void iggNewFrame() -{ - ImGui::NewFrame(); -} +void iggNewFrame() { ImGui::NewFrame(); } -void iggRender() -{ - ImGui::Render(); -} +void iggRender() { ImGui::Render(); } -IggDrawData iggGetDrawData() -{ - return reinterpret_cast(ImGui::GetDrawData()); -} +IggDrawData iggGetDrawData() { return reinterpret_cast(ImGui::GetDrawData()); } -void iggEndFrame() -{ - ImGui::EndFrame(); -} +void iggEndFrame() { ImGui::EndFrame(); } -double iggGetEventWaitingTime() -{ - return ImGui::GetEventWaitingTime(); -} +double iggGetEventWaitingTime() { return ImGui::GetEventWaitingTime(); } -char const *iggGetVersion() -{ - return ImGui::GetVersion(); -} +char const *iggGetVersion() { return ImGui::GetVersion(); } -void iggShowDemoWindow(IggBool *open) -{ - BoolWrapper openArg(open); +void iggShowDemoWindow(IggBool *open) { + BoolWrapper openArg(open); - ImGui::ShowDemoWindow(openArg); + ImGui::ShowDemoWindow(openArg); } -void iggShowUserGuide(void) -{ - ImGui::ShowUserGuide(); -} +void iggShowUserGuide(void) { ImGui::ShowUserGuide(); } -IggBool iggBegin(char const *id, IggBool *open, int flags) -{ - BoolWrapper openArg(open); - return ImGui::Begin(id, openArg, flags) ? 1 : 0; +IggBool iggBegin(char const *id, IggBool *open, int flags) { + BoolWrapper openArg(open); + return ImGui::Begin(id, openArg, flags) ? 1 : 0; } -void iggEnd(void) -{ - ImGui::End(); -} +void iggEnd(void) { ImGui::End(); } -IggBool iggBeginChild(char const *id, IggVec2 const *size, IggBool border, int flags) -{ - Vec2Wrapper sizeArg(size); - return ImGui::BeginChild(id, *sizeArg, border, flags) ? 1 : 0; +IggBool iggBeginChild(char const *id, IggVec2 const *size, IggBool border, int flags) { + Vec2Wrapper sizeArg(size); + return ImGui::BeginChild(id, *sizeArg, border, flags) ? 1 : 0; } -void iggEndChild(void) -{ - ImGui::EndChild(); -} +void iggEndChild(void) { ImGui::EndChild(); } -void iggWindowPos(IggVec2 *pos) -{ - exportValue(*pos, ImGui::GetWindowPos()); -} +void iggWindowPos(IggVec2 *pos) { exportValue(*pos, ImGui::GetWindowPos()); } -void iggWindowSize(IggVec2 *size) -{ - exportValue(*size, ImGui::GetWindowSize()); -} +void iggWindowSize(IggVec2 *size) { exportValue(*size, ImGui::GetWindowSize()); } -float iggWindowWidth(void) -{ - return ImGui::GetWindowWidth(); -} +float iggWindowWidth(void) { return ImGui::GetWindowWidth(); } -float iggWindowHeight(void) -{ - return ImGui::GetWindowHeight(); -} +float iggWindowHeight(void) { return ImGui::GetWindowHeight(); } -void iggContentRegionAvail(IggVec2 *size) -{ - exportValue(*size, ImGui::GetContentRegionAvail()); -} +void iggContentRegionAvail(IggVec2 *size) { exportValue(*size, ImGui::GetContentRegionAvail()); } -IggBool iggIsWindowAppearing() -{ - return ImGui::IsWindowAppearing() ? 1: 0; -} +IggBool iggIsWindowAppearing() { return ImGui::IsWindowAppearing() ? 1 : 0; } -IggBool iggIsWindowCollapsed() -{ - return ImGui::IsWindowCollapsed() ? 1: 0; -} +IggBool iggIsWindowCollapsed() { return ImGui::IsWindowCollapsed() ? 1 : 0; } -IggBool iggIsWindowFocused(int flags) -{ - return ImGui::IsWindowFocused(flags) ? 1: 0; -} +IggBool iggIsWindowFocused(int flags) { return ImGui::IsWindowFocused(flags) ? 1 : 0; } -IggBool iggIsWindowHovered(int flags) -{ - return ImGui::IsWindowHovered(flags) ? 1: 0; -} +IggBool iggIsWindowHovered(int flags) { return ImGui::IsWindowHovered(flags) ? 1 : 0; } -void iggSetNextWindowPos(IggVec2 const *pos, int cond, IggVec2 const *pivot) -{ - Vec2Wrapper posArg(pos); - Vec2Wrapper pivotArg(pivot); - ImGui::SetNextWindowPos(*posArg, cond, *pivotArg); +void iggSetNextWindowPos(IggVec2 const *pos, int cond, IggVec2 const *pivot) { + Vec2Wrapper posArg(pos); + Vec2Wrapper pivotArg(pivot); + ImGui::SetNextWindowPos(*posArg, cond, *pivotArg); } -void iggSetNextWindowSize(IggVec2 const *size, int cond) -{ - Vec2Wrapper sizeArg(size); - ImGui::SetNextWindowSize(*sizeArg, cond); +void iggSetNextWindowSize(IggVec2 const *size, int cond) { + Vec2Wrapper sizeArg(size); + ImGui::SetNextWindowSize(*sizeArg, cond); } -void iggSetNextWindowContentSize(IggVec2 const *size) -{ - Vec2Wrapper sizeArg(size); - ImGui::SetNextWindowContentSize(*sizeArg); +void iggSetNextWindowContentSize(IggVec2 const *size) { + Vec2Wrapper sizeArg(size); + ImGui::SetNextWindowContentSize(*sizeArg); } -void iggSetNextWindowFocus(void) -{ - ImGui::SetNextWindowFocus(); -} +void iggSetNextWindowFocus(void) { ImGui::SetNextWindowFocus(); } -void iggSetNextWindowBgAlpha(float value) -{ - ImGui::SetNextWindowBgAlpha(value); -} +void iggSetNextWindowBgAlpha(float value) { ImGui::SetNextWindowBgAlpha(value); } -void iggPushFont(IggFont handle) -{ - ImFont *font = reinterpret_cast(handle); - ImGui::PushFont(font); +void iggPushFont(IggFont handle) { + ImFont *font = reinterpret_cast(handle); + ImGui::PushFont(font); } -void iggPopFont(void) -{ - ImGui::PopFont(); -} +void iggPopFont(void) { ImGui::PopFont(); } -void iggPushStyleColor(int index, IggVec4 const *col) -{ - Vec4Wrapper colArg(col); - ImGui::PushStyleColor(index, *colArg); +void iggPushStyleColor(int index, IggVec4 const *col) { + Vec4Wrapper colArg(col); + ImGui::PushStyleColor(index, *colArg); } -void iggPopStyleColor(int count) -{ - ImGui::PopStyleColor(count); -} +void iggPopStyleColor(int count) { ImGui::PopStyleColor(count); } -void iggPushStyleVarFloat(int index, float value) -{ - ImGui::PushStyleVar(index, value); -} +void iggPushStyleVarFloat(int index, float value) { ImGui::PushStyleVar(index, value); } -void iggPushStyleVarVec2(int index, IggVec2 const *value) -{ - Vec2Wrapper valueArg(value); - ImGui::PushStyleVar(index, *valueArg); +void iggPushStyleVarVec2(int index, IggVec2 const *value) { + Vec2Wrapper valueArg(value); + ImGui::PushStyleVar(index, *valueArg); } -void iggPopStyleVar(int count) -{ - ImGui::PopStyleVar(count); -} +void iggPopStyleVar(int count) { ImGui::PopStyleVar(count); } -float iggGetFontSize() -{ - return ImGui::GetFontSize(); -} +float iggGetFontSize() { return ImGui::GetFontSize(); } -void iggCalcTextSize(const char *text, int length, IggBool hide_text_after_double_hash, float wrap_width, IggVec2 *value) -{ - exportValue(*value, ImGui::CalcTextSize(text, text + length, hide_text_after_double_hash, wrap_width)); -} +void iggCalcTextSize(const char *text, int length, IggBool hide_text_after_double_hash, float wrap_width, IggVec2 *value) { exportValue(*value, ImGui::CalcTextSize(text, text + length, hide_text_after_double_hash, wrap_width)); } -unsigned int iggGetColorU32(const IggVec4 col) -{ - Vec4Wrapper colArg(&col); - return ImGui::GetColorU32(*colArg); +unsigned int iggGetColorU32(const IggVec4 col) { + Vec4Wrapper colArg(&col); + return ImGui::GetColorU32(*colArg); } -void iggBeginDisabled(IggBool disabled) -{ - ImGui::BeginDisabled(disabled); -} +void iggBeginDisabled(IggBool disabled) { ImGui::BeginDisabled(disabled); } -void iggEndDisabled() -{ - ImGui::EndDisabled(); -} +void iggEndDisabled() { ImGui::EndDisabled(); } -void iggStyleColorsDark() -{ - ImGui::StyleColorsDark(); -} +void iggStyleColorsDark() { ImGui::StyleColorsDark(); } -void iggStyleColorsClassic() -{ - ImGui::StyleColorsClassic(); -} +void iggStyleColorsClassic() { ImGui::StyleColorsClassic(); } -void iggStyleColorsLight() -{ - ImGui::StyleColorsLight(); -} +void iggStyleColorsLight() { ImGui::StyleColorsLight(); } -void iggPushItemWidth(float width) -{ - ImGui::PushItemWidth(width); -} +void iggPushItemWidth(float width) { ImGui::PushItemWidth(width); } -void iggPopItemWidth(void) -{ - ImGui::PopItemWidth(); -} +void iggPopItemWidth(void) { ImGui::PopItemWidth(); } -float iggCalcItemWidth(void) -{ - return ImGui::CalcItemWidth(); -} +float iggCalcItemWidth(void) { return ImGui::CalcItemWidth(); } -void iggPushTextWrapPos(float wrapPosX) -{ - ImGui::PushTextWrapPos(wrapPosX); -} +void iggPushTextWrapPos(float wrapPosX) { ImGui::PushTextWrapPos(wrapPosX); } -void iggPopTextWrapPos(void) -{ - ImGui::PopTextWrapPos(); -} +void iggPopTextWrapPos(void) { ImGui::PopTextWrapPos(); } -void iggPushAllowKeyboardFocus(IggBool allow_keyboard_focus) -{ - ImGui::PushAllowKeyboardFocus(allow_keyboard_focus); -} +void iggPushAllowKeyboardFocus(IggBool allow_keyboard_focus) { ImGui::PushAllowKeyboardFocus(allow_keyboard_focus); } -void iggPopAllowKeyboardFocus(void) -{ - ImGui::PopAllowKeyboardFocus(); -} +void iggPopAllowKeyboardFocus(void) { ImGui::PopAllowKeyboardFocus(); } -void iggPushID(char const *id) -{ - ImGui::PushID(id); -} +void iggPushID(char const *id) { ImGui::PushID(id); } -void iggPopID(void) -{ - ImGui::PopID(); -} +void iggPopID(void) { ImGui::PopID(); } -void iggTextUnformatted(char const *text) -{ - ImGui::TextUnformatted(text); -} +void iggTextUnformatted(char const *text) { ImGui::TextUnformatted(text); } -void iggLabelText(char const *label, char const *text) -{ - ImGui::LabelText(label, "%s", text); -} +void iggLabelText(char const *label, char const *text) { ImGui::LabelText(label, "%s", text); } -IggBool iggButton(char const *label, IggVec2 const *size) -{ - Vec2Wrapper sizeArg(size); - return ImGui::Button(label, *sizeArg) ? 1 : 0; +IggBool iggButton(char const *label, IggVec2 const *size) { + Vec2Wrapper sizeArg(size); + return ImGui::Button(label, *sizeArg) ? 1 : 0; } -IggBool iggSmallButton(char const *label) -{ - return ImGui::SmallButton(label) ? 1 : 0; -} +IggBool iggSmallButton(char const *label) { return ImGui::SmallButton(label) ? 1 : 0; } -IggBool iggArrowButton(const char* id, unsigned char dir) -{ - return ImGui::ArrowButton(id, dir) ? 1 : 0; -} +IggBool iggArrowButton(const char *id, unsigned char dir) { return ImGui::ArrowButton(id, dir) ? 1 : 0; } -IggBool iggInvisibleButton(char const *label, IggVec2 const *size) -{ +IggBool iggInvisibleButton(char const *label, IggVec2 const *size) { Vec2Wrapper sizeArg(size); return ImGui::InvisibleButton(label, *sizeArg) ? 1 : 0; } -void iggImage(IggTextureID textureID, - IggVec2 const *size, IggVec2 const *uv0, IggVec2 const *uv1, - IggVec4 const *tintCol, IggVec4 const *borderCol) -{ - Vec2Wrapper sizeArg(size); - Vec2Wrapper uv0Arg(uv0); - Vec2Wrapper uv1Arg(uv1); - Vec4Wrapper tintColArg(tintCol); - Vec4Wrapper borderColArg(borderCol); - ImGui::Image(static_cast(textureID), *sizeArg, *uv0Arg, *uv1Arg, *tintColArg, *borderColArg); +void iggImage(IggTextureID textureID, IggVec2 const *size, IggVec2 const *uv0, IggVec2 const *uv1, IggVec4 const *tintCol, IggVec4 const *borderCol) { + Vec2Wrapper sizeArg(size); + Vec2Wrapper uv0Arg(uv0); + Vec2Wrapper uv1Arg(uv1); + Vec4Wrapper tintColArg(tintCol); + Vec4Wrapper borderColArg(borderCol); + ImGui::Image(reinterpret_cast(textureID), *sizeArg, *uv0Arg, *uv1Arg, *tintColArg, *borderColArg); } -IggBool iggImageButton(IggTextureID textureID, - IggVec2 const *size, IggVec2 const *uv0, IggVec2 const *uv1, - int framePadding, IggVec4 const *bgCol, - IggVec4 const *tintCol) -{ - Vec2Wrapper sizeArg(size); - Vec2Wrapper uv0Arg(uv0); - Vec2Wrapper uv1Arg(uv1); - Vec4Wrapper bgColArg(bgCol); - Vec4Wrapper tintColArg(tintCol); - return ImGui::ImageButton(static_cast(textureID), *sizeArg, *uv0Arg, *uv1Arg, framePadding, *bgColArg, *tintColArg) ? 1 : 0; +IggBool iggImageButton(IggTextureID textureID, IggVec2 const *size, IggVec2 const *uv0, IggVec2 const *uv1, int framePadding, IggVec4 const *bgCol, IggVec4 const *tintCol) { + Vec2Wrapper sizeArg(size); + Vec2Wrapper uv0Arg(uv0); + Vec2Wrapper uv1Arg(uv1); + Vec4Wrapper bgColArg(bgCol); + Vec4Wrapper tintColArg(tintCol); + return ImGui::ImageButton(reinterpret_cast(textureID), *sizeArg, *uv0Arg, *uv1Arg, framePadding, *bgColArg, *tintColArg) ? 1 : 0; } -IggBool iggCheckbox(char const *label, IggBool *selected) -{ - BoolWrapper selectedArg(selected); - return ImGui::Checkbox(label, selectedArg) ? 1 : 0; +IggBool iggCheckbox(char const *label, IggBool *selected) { + BoolWrapper selectedArg(selected); + return ImGui::Checkbox(label, selectedArg) ? 1 : 0; } -IggBool iggRadioButton(char const *label, IggBool active) -{ - return ImGui::RadioButton(label, active != 0) ? 1 : 0; -} +IggBool iggRadioButton(char const *label, IggBool active) { return ImGui::RadioButton(label, active != 0) ? 1 : 0; } -void iggProgressBar(float fraction, IggVec2 const *size, char const *overlay) -{ - Vec2Wrapper sizeArg(size); - ImGui::ProgressBar(fraction, *sizeArg, overlay); +void iggProgressBar(float fraction, IggVec2 const *size, char const *overlay) { + Vec2Wrapper sizeArg(size); + ImGui::ProgressBar(fraction, *sizeArg, overlay); } -void iggBullet(void) -{ - ImGui::Bullet(); -} +void iggBullet(void) { ImGui::Bullet(); } -void iggBulletText(const char* text) -{ - ImGui::BulletText("%s", text); -} +void iggBulletText(const char *text) { ImGui::BulletText("%s", text); } -IggBool iggBeginCombo(char const *label, char const *previewValue, int flags) -{ - return ImGui::BeginCombo(label, previewValue, flags) ? 1 : 0; -} +IggBool iggBeginCombo(char const *label, char const *previewValue, int flags) { return ImGui::BeginCombo(label, previewValue, flags) ? 1 : 0; } -void iggEndCombo(void) -{ - ImGui::EndCombo(); -} +void iggEndCombo(void) { ImGui::EndCombo(); } -IggBool iggDragFloat(char const *label, float *value, float speed, float min, float max, char const *format, float power) -{ - return ImGui::DragFloat(label, value, speed, min, max, format, power) ? 1 : 0; -} +IggBool iggDragFloat(char const *label, float *value, float speed, float min, float max, char const *format, float power) { return ImGui::DragFloat(label, value, speed, min, max, format, power) ? 1 : 0; } -IggBool iggDragInt(char const *label, int *value, float speed, int min, int max, char const *format) -{ - return ImGui::DragInt(label, value, speed, min, max, format) ? 1 : 0; -} +IggBool iggDragInt(char const *label, int *value, float speed, int min, int max, char const *format) { return ImGui::DragInt(label, value, speed, min, max, format) ? 1 : 0; } -IggBool iggSliderFloat(char const *label, float *value, float minValue, float maxValue, char const *format, float power) -{ - return ImGui::SliderFloat(label, value, minValue, maxValue, format, power) ? 1 : 0; -} +IggBool iggSliderFloat(char const *label, float *value, float minValue, float maxValue, char const *format, float power) { return ImGui::SliderFloat(label, value, minValue, maxValue, format, power) ? 1 : 0; } -IggBool iggSliderFloatN(char const *label, float *value, int n, float minValue, float maxValue, char const *format, float power) -{ - return ImGui::SliderScalarN(label, ImGuiDataType_Float, (void *)value, n, &minValue, &maxValue, format, power) ? 1 : 0; -} +IggBool iggSliderFloatN(char const *label, float *value, int n, float minValue, float maxValue, char const *format, float power) { return ImGui::SliderScalarN(label, ImGuiDataType_Float, (void *)value, n, &minValue, &maxValue, format, power) ? 1 : 0; } -IggBool iggSliderInt(char const *label, int *value, int minValue, int maxValue, char const *format) -{ - return ImGui::SliderInt(label, value, minValue, maxValue, format) ? 1 : 0; -} +IggBool iggSliderInt(char const *label, int *value, int minValue, int maxValue, char const *format) { return ImGui::SliderInt(label, value, minValue, maxValue, format) ? 1 : 0; } -IggBool iggVSliderInt(const char* label, const IggVec2 *size, int* v, int v_min, int v_max, const char* format, int flags) -{ - Vec2Wrapper sizeArg(size); - return ImGui::VSliderInt(label, *sizeArg, v, v_min, v_max, format, flags) ? 1 : 0; +IggBool iggVSliderInt(const char *label, const IggVec2 *size, int *v, int v_min, int v_max, const char *format, int flags) { + Vec2Wrapper sizeArg(size); + return ImGui::VSliderInt(label, *sizeArg, v, v_min, v_max, format, flags) ? 1 : 0; } extern "C" int iggInputTextCallback(IggInputTextCallbackData data, int key); -static int iggInputTextCallbackWrapper(ImGuiInputTextCallbackData *data) -{ - return iggInputTextCallback(reinterpret_cast(data), static_cast(reinterpret_cast(data->UserData))); -} - -IggBool iggInputText(char const *label, char *buf, unsigned int bufSize, int flags, int callbackKey) -{ - return ImGui::InputText(label, buf, static_cast(bufSize), flags, - iggInputTextCallbackWrapper, reinterpret_cast(callbackKey)) - ? 1 - : 0; -} - - -IggBool iggInputTextWithHint(char const *label, char const *hint, char *buf, unsigned int bufSize, - int flags, int callbackKey) -{ - return ImGui::InputTextWithHint(label, hint, buf, static_cast(bufSize), flags, - iggInputTextCallbackWrapper, reinterpret_cast(callbackKey)) - ? 1 - : 0; -} +static int iggInputTextCallbackWrapper(ImGuiInputTextCallbackData *data) { return iggInputTextCallback(reinterpret_cast(data), static_cast(reinterpret_cast(data->UserData))); } -IggBool iggInputTextMultiline(char const *label, char *buf, unsigned int bufSize, IggVec2 const *size, int flags, int callbackKey) -{ - Vec2Wrapper sizeArg(size); - return ImGui::InputTextMultiline(label, buf, static_cast(bufSize), *sizeArg, flags, - iggInputTextCallbackWrapper, reinterpret_cast(callbackKey)) ? 1 : 0; -} +IggBool iggInputText(char const *label, char *buf, unsigned int bufSize, int flags, int callbackKey) { return ImGui::InputText(label, buf, static_cast(bufSize), flags, iggInputTextCallbackWrapper, reinterpret_cast(callbackKey)) ? 1 : 0; } -IggBool iggInputInt(char const *label, int* v, int step, int step_fast, int flags) -{ - return ImGui::InputInt(label, v, step, step_fast, flags) ? 1 : 0; -} +IggBool iggInputTextWithHint(char const *label, char const *hint, char *buf, unsigned int bufSize, int flags, int callbackKey) { return ImGui::InputTextWithHint(label, hint, buf, static_cast(bufSize), flags, iggInputTextCallbackWrapper, reinterpret_cast(callbackKey)) ? 1 : 0; } -IggBool iggInputFloat(char const *label, float* v, float step, float step_fast, const char* format, int flags) -{ - return ImGui::InputFloat(label, v, step, step_fast, format, flags) ? 1 : 0; +IggBool iggInputTextMultiline(char const *label, char *buf, unsigned int bufSize, IggVec2 const *size, int flags, int callbackKey) { + Vec2Wrapper sizeArg(size); + return ImGui::InputTextMultiline(label, buf, static_cast(bufSize), *sizeArg, flags, iggInputTextCallbackWrapper, reinterpret_cast(callbackKey)) ? 1 : 0; } -IggBool iggColorEdit3(char const *label, float *col, int flags) -{ - return ImGui::ColorEdit3(label, col, flags) ? 1 : 0; -} +IggBool iggInputInt(char const *label, int *v, int step, int step_fast, int flags) { return ImGui::InputInt(label, v, step, step_fast, flags) ? 1 : 0; } -IggBool iggColorEdit4(char const *label, float *col, int flags) -{ - return ImGui::ColorEdit4(label, col, flags) ? 1 : 0; -} +IggBool iggInputFloat(char const *label, float *v, float step, float step_fast, const char *format, int flags) { return ImGui::InputFloat(label, v, step, step_fast, format, flags) ? 1 : 0; } -IggBool iggColorPicker3(char const *label, float *col, int flags) -{ - return ImGui::ColorPicker3(label, col, flags) ? 1 : 0; -} +IggBool iggColorEdit3(char const *label, float *col, int flags) { return ImGui::ColorEdit3(label, col, flags) ? 1 : 0; } -IggBool iggColorPicker4(char const *label, float *col, int flags) -{ - return ImGui::ColorPicker4(label, col, flags) ? 1 : 0; -} +IggBool iggColorEdit4(char const *label, float *col, int flags) { return ImGui::ColorEdit4(label, col, flags) ? 1 : 0; } -void iggSeparator(void) -{ - ImGui::Separator(); -} +IggBool iggColorPicker3(char const *label, float *col, int flags) { return ImGui::ColorPicker3(label, col, flags) ? 1 : 0; } -void iggSameLine(float posX, float spacingW) -{ - ImGui::SameLine(posX, spacingW); -} +IggBool iggColorPicker4(char const *label, float *col, int flags) { return ImGui::ColorPicker4(label, col, flags) ? 1 : 0; } -void iggSpacing(void) -{ - ImGui::Spacing(); -} +void iggSeparator(void) { ImGui::Separator(); } -void iggDummy(IggVec2 const *size) -{ - Vec2Wrapper sizeArg(size); - ImGui::Dummy(*sizeArg); -} +void iggSameLine(float posX, float spacingW) { ImGui::SameLine(posX, spacingW); } -void iggBeginGroup(void) -{ - ImGui::BeginGroup(); -} +void iggSpacing(void) { ImGui::Spacing(); } -void iggEndGroup(void) -{ - ImGui::EndGroup(); +void iggDummy(IggVec2 const *size) { + Vec2Wrapper sizeArg(size); + ImGui::Dummy(*sizeArg); } -void iggCursorPos(IggVec2 *pos) -{ - exportValue(*pos, ImGui::GetCursorPos()); -} +void iggBeginGroup(void) { ImGui::BeginGroup(); } -float iggCursorPosX(void) -{ - return ImGui::GetCursorPosX(); -} +void iggEndGroup(void) { ImGui::EndGroup(); } -float iggCursorPosY(void) -{ - return ImGui::GetCursorPosY(); -} +void iggCursorPos(IggVec2 *pos) { exportValue(*pos, ImGui::GetCursorPos()); } -void iggCursorStartPos(IggVec2 *pos) -{ - exportValue(*pos, ImGui::GetCursorStartPos()); -} +float iggCursorPosX(void) { return ImGui::GetCursorPosX(); } -void iggCursorScreenPos(IggVec2 *pos) -{ - exportValue(*pos, ImGui::GetCursorScreenPos()); -} +float iggCursorPosY(void) { return ImGui::GetCursorPosY(); } -void iggSetCursorPos(IggVec2 const *localPos) -{ - Vec2Wrapper localPosArg(localPos); - ImGui::SetCursorPos(*localPosArg); -} +void iggCursorStartPos(IggVec2 *pos) { exportValue(*pos, ImGui::GetCursorStartPos()); } -void iggSetCursorScreenPos(IggVec2 const *absPos) -{ - Vec2Wrapper absPosArg(absPos); - ImGui::SetCursorScreenPos(*absPosArg); -} +void iggCursorScreenPos(IggVec2 *pos) { exportValue(*pos, ImGui::GetCursorScreenPos()); } -void iggMousePos(IggVec2 *pos) -{ - exportValue(*pos, ImGui::GetMousePos()); +void iggSetCursorPos(IggVec2 const *localPos) { + Vec2Wrapper localPosArg(localPos); + ImGui::SetCursorPos(*localPosArg); } -void iggAlignTextToFramePadding() -{ - ImGui::AlignTextToFramePadding(); +void iggSetCursorScreenPos(IggVec2 const *absPos) { + Vec2Wrapper absPosArg(absPos); + ImGui::SetCursorScreenPos(*absPosArg); } -float iggGetTextLineHeight(void) -{ - return ImGui::GetTextLineHeight(); -} +void iggMousePos(IggVec2 *pos) { exportValue(*pos, ImGui::GetMousePos()); } -float iggGetTextLineHeightWithSpacing(void) -{ - return ImGui::GetTextLineHeightWithSpacing(); -} +void iggAlignTextToFramePadding() { ImGui::AlignTextToFramePadding(); } -float iggFrameHeightWithSpacing(void) -{ - return ImGui::GetFrameHeightWithSpacing(); -} +float iggGetTextLineHeight(void) { return ImGui::GetTextLineHeight(); } -IggBool iggTreeNode(char const *label, int flags) -{ - return ImGui::TreeNodeEx(label, flags) ? 1 : 0; -} +float iggGetTextLineHeightWithSpacing(void) { return ImGui::GetTextLineHeightWithSpacing(); } -void iggTreePop(void) -{ - ImGui::TreePop(); -} +float iggFrameHeightWithSpacing(void) { return ImGui::GetFrameHeightWithSpacing(); } -void iggSetNextItemOpen(IggBool open, int cond) -{ - ImGui::SetNextItemOpen(open != 0, cond); -} +IggBool iggTreeNode(char const *label, int flags) { return ImGui::TreeNodeEx(label, flags) ? 1 : 0; } -float iggGetTreeNodeToLabelSpacing(void) -{ - return ImGui::GetTreeNodeToLabelSpacing(); -} +void iggTreePop(void) { ImGui::TreePop(); } -IggBool iggSelectable(char const *label, IggBool selected, int flags, IggVec2 const *size) -{ - Vec2Wrapper sizeArg(size); - return ImGui::Selectable(label, selected != 0, flags, *sizeArg) ? 1 : 0; -} +void iggSetNextItemOpen(IggBool open, int cond) { ImGui::SetNextItemOpen(open != 0, cond); } -IggBool iggListBoxV(char const *label, int *currentItem, char const *const items[], int itemsCount, int heightItems) -{ - return ImGui::ListBox(label, currentItem, items, itemsCount, heightItems) ? 1 : 0; -} +float iggGetTreeNodeToLabelSpacing(void) { return ImGui::GetTreeNodeToLabelSpacing(); } -void iggPlotLines(char const *label, float const *values, int valuesCount, int valuesOffset, char const *overlayText, float scaleMin, float scaleMax, IggVec2 const *graphSize) -{ - Vec2Wrapper graphSizeArg(graphSize); - ImGui::PlotLines(label, values, valuesCount, valuesOffset, overlayText, scaleMin, scaleMax, *graphSizeArg); +IggBool iggSelectable(char const *label, IggBool selected, int flags, IggVec2 const *size) { + Vec2Wrapper sizeArg(size); + return ImGui::Selectable(label, selected != 0, flags, *sizeArg) ? 1 : 0; } -void iggPlotHistogram(char const *label, float const *values, int valuesCount, int valuesOffset, char const *overlayText, float scaleMin, float scaleMax, IggVec2 const *graphSize) -{ - Vec2Wrapper graphSizeArg(graphSize); - ImGui::PlotHistogram(label, values, valuesCount, valuesOffset, overlayText, scaleMin, scaleMax, *graphSizeArg); -} +IggBool iggListBoxV(char const *label, int *currentItem, char const *const items[], int itemsCount, int heightItems) { return ImGui::ListBox(label, currentItem, items, itemsCount, heightItems) ? 1 : 0; } -void iggSetTooltip(char const *text) -{ - ImGui::SetTooltip("%s", text); +void iggPlotLines(char const *label, float const *values, int valuesCount, int valuesOffset, char const *overlayText, float scaleMin, float scaleMax, IggVec2 const *graphSize) { + Vec2Wrapper graphSizeArg(graphSize); + ImGui::PlotLines(label, values, valuesCount, valuesOffset, overlayText, scaleMin, scaleMax, *graphSizeArg); } -void iggBeginTooltip(void) -{ - ImGui::BeginTooltip(); +void iggPlotHistogram(char const *label, float const *values, int valuesCount, int valuesOffset, char const *overlayText, float scaleMin, float scaleMax, IggVec2 const *graphSize) { + Vec2Wrapper graphSizeArg(graphSize); + ImGui::PlotHistogram(label, values, valuesCount, valuesOffset, overlayText, scaleMin, scaleMax, *graphSizeArg); } -void iggEndTooltip(void) -{ - ImGui::EndTooltip(); -} +void iggSetTooltip(char const *text) { ImGui::SetTooltip("%s", text); } -IggBool iggBeginMainMenuBar(void) -{ - return ImGui::BeginMainMenuBar() ? 1 : 0; -} +void iggBeginTooltip(void) { ImGui::BeginTooltip(); } -void iggEndMainMenuBar(void) -{ - ImGui::EndMainMenuBar(); -} +void iggEndTooltip(void) { ImGui::EndTooltip(); } -IggBool iggBeginMenuBar(void) -{ - return ImGui::BeginMenuBar() ? 1 : 0; -} +IggBool iggBeginMainMenuBar(void) { return ImGui::BeginMainMenuBar() ? 1 : 0; } -void iggEndMenuBar(void) -{ - ImGui::EndMenuBar(); -} +void iggEndMainMenuBar(void) { ImGui::EndMainMenuBar(); } -IggBool iggBeginMenu(char const *label, IggBool enabled) -{ - return ImGui::BeginMenu(label, enabled != 0) ? 1 : 0; -} +IggBool iggBeginMenuBar(void) { return ImGui::BeginMenuBar() ? 1 : 0; } -void iggEndMenu(void) -{ - ImGui::EndMenu(); -} +void iggEndMenuBar(void) { ImGui::EndMenuBar(); } -IggBool iggMenuItem(char const *label, char const *shortcut, IggBool selected, IggBool enabled) -{ - return ImGui::MenuItem(label, shortcut, selected != 0, enabled != 0) ? 1 : 0; -} +IggBool iggBeginMenu(char const *label, IggBool enabled) { return ImGui::BeginMenu(label, enabled != 0) ? 1 : 0; } -void iggOpenPopup(char const *id) -{ - ImGui::OpenPopup(id); -} +void iggEndMenu(void) { ImGui::EndMenu(); } +IggBool iggMenuItem(char const *label, char const *shortcut, IggBool selected, IggBool enabled) { return ImGui::MenuItem(label, shortcut, selected != 0, enabled != 0) ? 1 : 0; } -IggBool iggBeginPopup(char const *name, int flags) -{ - return ImGui::BeginPopup(name, flags) ? 1 : 0; -} +void iggOpenPopup(char const *id) { ImGui::OpenPopup(id); } -IggBool iggBeginPopupModal(char const *name, IggBool *open, int flags) -{ - BoolWrapper openArg(open); - return ImGui::BeginPopupModal(name, openArg, flags) ? 1 : 0; -} +IggBool iggBeginPopup(char const *name, int flags) { return ImGui::BeginPopup(name, flags) ? 1 : 0; } -IggBool iggBeginPopupContextItem(char const *label, int mouseButton) -{ - return ImGui::BeginPopupContextItem(label, mouseButton) ? 1 : 0; +IggBool iggBeginPopupModal(char const *name, IggBool *open, int flags) { + BoolWrapper openArg(open); + return ImGui::BeginPopupModal(name, openArg, flags) ? 1 : 0; } -void iggEndPopup(void) -{ - ImGui::EndPopup(); -} +IggBool iggBeginPopupContextItem(char const *label, int mouseButton) { return ImGui::BeginPopupContextItem(label, mouseButton) ? 1 : 0; } -void iggCloseCurrentPopup(void) -{ - ImGui::CloseCurrentPopup(); -} +void iggEndPopup(void) { ImGui::EndPopup(); } -IggBool iggIsItemHovered(int flags) -{ - return ImGui::IsItemHovered(flags) ? 1 : 0; -} +void iggCloseCurrentPopup(void) { ImGui::CloseCurrentPopup(); } +IggBool iggIsItemHovered(int flags) { return ImGui::IsItemHovered(flags) ? 1 : 0; } -IggBool iggIsItemClicked(int mouseButton) -{ - return ImGui::IsItemClicked(mouseButton) ? 1 : 0; -} +IggBool iggIsItemClicked(int mouseButton) { return ImGui::IsItemClicked(mouseButton) ? 1 : 0; } -IggBool iggIsItemActive() -{ - return ImGui::IsItemActive() ? 1 : 0; -} +IggBool iggIsItemActive() { return ImGui::IsItemActive() ? 1 : 0; } -IggBool iggIsAnyItemActive() -{ - return ImGui::IsAnyItemActive() ? 1 : 0; -} +IggBool iggIsAnyItemActive() { return ImGui::IsAnyItemActive() ? 1 : 0; } -IggBool iggIsKeyDown(int key) -{ - return ImGui::IsKeyDown(key); -} +IggBool iggIsKeyDown(int key) { return ImGui::IsKeyDown(key); } -IggBool iggIsKeyPressed(int key, IggBool repeat) -{ - return ImGui::IsKeyPressed(key, repeat); -} +IggBool iggIsKeyPressed(int key, IggBool repeat) { return ImGui::IsKeyPressed(key, repeat); } -IggBool iggIsKeyReleased(int key) -{ - return ImGui::IsKeyReleased(key); -} +IggBool iggIsKeyReleased(int key) { return ImGui::IsKeyReleased(key); } -IggBool iggIsMouseDown(int button) -{ - return ImGui::IsMouseDown(button); -} +IggBool iggIsMouseDown(int button) { return ImGui::IsMouseDown(button); } -IggBool iggIsAnyMouseDown() -{ - return ImGui::IsAnyMouseDown(); -} +IggBool iggIsAnyMouseDown() { return ImGui::IsAnyMouseDown(); } -IggBool iggIsMouseClicked(int button, IggBool repeat) -{ - return ImGui::IsMouseClicked(button, repeat); -} +IggBool iggIsMouseClicked(int button, IggBool repeat) { return ImGui::IsMouseClicked(button, repeat); } -IggBool iggIsMouseReleased(int button) -{ - return ImGui::IsMouseReleased(button); -} +IggBool iggIsMouseReleased(int button) { return ImGui::IsMouseReleased(button); } -IggBool iggIsMouseDoubleClicked(int button) -{ - return ImGui::IsMouseDoubleClicked(button); -} +IggBool iggIsMouseDoubleClicked(int button) { return ImGui::IsMouseDoubleClicked(button); } -void iggColumns(int count, char const *label, IggBool border) -{ - ImGui::Columns(count, label, border); -} +void iggColumns(int count, char const *label, IggBool border) { ImGui::Columns(count, label, border); } -void iggNextColumn() -{ - ImGui::NextColumn(); -} +void iggNextColumn() { ImGui::NextColumn(); } -int iggGetColumnIndex() -{ - return ImGui::GetColumnIndex(); -} +int iggGetColumnIndex() { return ImGui::GetColumnIndex(); } -int iggGetColumnWidth(int index) -{ - return ImGui::GetColumnWidth(index); -} +int iggGetColumnWidth(int index) { return ImGui::GetColumnWidth(index); } -void iggSetColumnWidth(int index, float width) -{ - ImGui::SetColumnWidth(index, width); -} +void iggSetColumnWidth(int index, float width) { ImGui::SetColumnWidth(index, width); } -float iggGetColumnOffset(int index) -{ - return ImGui::GetColumnOffset(index); -} +float iggGetColumnOffset(int index) { return ImGui::GetColumnOffset(index); } -void iggSetColumnOffset(int index, float offsetX) -{ - ImGui::SetColumnOffset(index, offsetX); -} +void iggSetColumnOffset(int index, float offsetX) { ImGui::SetColumnOffset(index, offsetX); } -int iggGetColumnsCount() -{ - return ImGui::GetColumnsCount(); -} +int iggGetColumnsCount() { return ImGui::GetColumnsCount(); } -float iggGetScrollX() -{ - return ImGui::GetScrollX(); -} +float iggGetScrollX() { return ImGui::GetScrollX(); } -float iggGetScrollY() -{ - return ImGui::GetScrollY(); -} +float iggGetScrollY() { return ImGui::GetScrollY(); } -float iggGetScrollMaxX() -{ - return ImGui::GetScrollMaxX(); -} +float iggGetScrollMaxX() { return ImGui::GetScrollMaxX(); } -float iggGetScrollMaxY() -{ - return ImGui::GetScrollMaxY(); -} +float iggGetScrollMaxY() { return ImGui::GetScrollMaxY(); } -void iggSetScrollHereX(float centerXRatio) -{ - ImGui::SetScrollHereX(centerXRatio); -} +void iggSetScrollHereX(float centerXRatio) { ImGui::SetScrollHereX(centerXRatio); } -void iggSetScrollHereY(float centerYRatio) -{ - ImGui::SetScrollHereY(centerYRatio); -} +void iggSetScrollHereY(float centerYRatio) { ImGui::SetScrollHereY(centerYRatio); } -void iggSetScrollX(float scrollX) -{ - ImGui::SetScrollX(scrollX); -} +void iggSetScrollX(float scrollX) { ImGui::SetScrollX(scrollX); } -void iggSetScrollY(float scrollY) -{ - ImGui::SetScrollY(scrollY); -} +void iggSetScrollY(float scrollY) { ImGui::SetScrollY(scrollY); } -void iggSetItemDefaultFocus() -{ - ImGui::SetItemDefaultFocus(); -} +void iggSetItemDefaultFocus() { ImGui::SetItemDefaultFocus(); } -IggBool iggIsItemFocused() -{ - return ImGui::IsItemFocused(); -} +IggBool iggIsItemFocused() { return ImGui::IsItemFocused(); } -IggBool iggIsAnyItemFocused() -{ - return ImGui::IsAnyItemFocused(); -} +IggBool iggIsAnyItemFocused() { return ImGui::IsAnyItemFocused(); } -int iggGetMouseCursor() -{ - return ImGui::GetMouseCursor(); -} +int iggGetMouseCursor() { return ImGui::GetMouseCursor(); } -void iggSetMouseCursor(int cursor) -{ - ImGui::SetMouseCursor(cursor); -} +void iggSetMouseCursor(int cursor) { ImGui::SetMouseCursor(cursor); } -void iggSetKeyboardFocusHere(int offset) -{ - ImGui::SetKeyboardFocusHere(offset); -} +void iggSetKeyboardFocusHere(int offset) { ImGui::SetKeyboardFocusHere(offset); } -IggBool iggBeginTabBar(char const *str_id, int flags) -{ - return ImGui::BeginTabBar(str_id, flags) ? 1 : 0; -} +IggBool iggBeginTabBar(char const *str_id, int flags) { return ImGui::BeginTabBar(str_id, flags) ? 1 : 0; } -void iggEndTabBar() -{ - ImGui::EndTabBar(); -} +void iggEndTabBar() { ImGui::EndTabBar(); } -IggBool iggBeginTabItem(char const *label, IggBool *p_open, int flags) -{ - BoolWrapper openArg(p_open); - return ImGui::BeginTabItem(label, openArg, flags) ? 1 : 0; +IggBool iggBeginTabItem(char const *label, IggBool *p_open, int flags) { + BoolWrapper openArg(p_open); + return ImGui::BeginTabItem(label, openArg, flags) ? 1 : 0; } -void iggEndTabItem() -{ - ImGui::EndTabItem(); -} +void iggEndTabItem() { ImGui::EndTabItem(); } -void iggSetTabItemClosed(char const *tab_or_docked_window_label) -{ - ImGui::SetTabItemClosed(tab_or_docked_window_label); -} +void iggSetTabItemClosed(char const *tab_or_docked_window_label) { ImGui::SetTabItemClosed(tab_or_docked_window_label); } -IggDrawList iggGetWindowDrawList() -{ - ImDrawList* drawlist = ImGui::GetWindowDrawList(); +IggDrawList iggGetWindowDrawList() { + ImDrawList *drawlist = ImGui::GetWindowDrawList(); return static_cast(drawlist); } -void iggGetItemRectMin(IggVec2 *size) -{ - exportValue(*size, ImGui::GetItemRectMin()); -} +void iggGetItemRectMin(IggVec2 *size) { exportValue(*size, ImGui::GetItemRectMin()); } -void iggGetItemRectMax(IggVec2 *size) -{ - exportValue(*size, ImGui::GetItemRectMax()); -} +void iggGetItemRectMax(IggVec2 *size) { exportValue(*size, ImGui::GetItemRectMax()); } -void iggGetItemRectSize(IggVec2 *size) -{ - exportValue(*size, ImGui::GetItemRectSize()); -} +void iggGetItemRectSize(IggVec2 *size) { exportValue(*size, ImGui::GetItemRectSize()); } -void iggPushClipRect(const IggVec2 *clip_rect_min, const IggVec2 *clip_rect_max, IggBool intersect_with_clip_rect) -{ - Vec2Wrapper clipMin(clip_rect_min); - Vec2Wrapper clipMax(clip_rect_max); - ImGui::PushClipRect(*clipMin, *clipMax, intersect_with_clip_rect); +void iggPushClipRect(const IggVec2 *clip_rect_min, const IggVec2 *clip_rect_max, IggBool intersect_with_clip_rect) { + Vec2Wrapper clipMin(clip_rect_min); + Vec2Wrapper clipMax(clip_rect_max); + ImGui::PushClipRect(*clipMin, *clipMax, intersect_with_clip_rect); } -void iggPopClipRect() -{ - ImGui::PopClipRect(); -} +void iggPopClipRect() { ImGui::PopClipRect(); } diff --git a/imguiWrapperTypes.h b/imguiWrapperTypes.h index 2f76c85b..b39a1d29 100644 --- a/imguiWrapperTypes.h +++ b/imguiWrapperTypes.h @@ -1,12 +1,14 @@ #pragma once +#include + #ifdef __cplusplus extern "C" { #endif typedef int IggBool; typedef float IggFloat; -typedef void *IggTextureID; +typedef uintptr_t IggTextureID; typedef void *IggContext; typedef void *IggDrawCmd; diff --git a/imgui_markdown_wrapper.cpp b/imgui_markdown_wrapper.cpp index 7cc02d7d..a840da1d 100644 --- a/imgui_markdown_wrapper.cpp +++ b/imgui_markdown_wrapper.cpp @@ -8,89 +8,84 @@ * ===================================================================================== */ - -#include -#include -#include -#include +#include +#include +#include +#include iggMarkdownLinkCallbackData iggMarkdownLink; static void markdownLinkCallback(ImGui::MarkdownLinkCallbackData); static ImGui::MarkdownImageData markdownImageCallback(ImGui::MarkdownLinkCallbackData); -iggMarkdownLinkCallbackData iggMarkdown( - char* markdown_, - iggMarkdownHeaderData headers_[], int numHeaderLevels - ) { - // clean up link cache. - iggMarkdownLink.link = NULL; - iggMarkdownLink.link_len = 0; - - // create imgui markdown config: - // TODO: implement all these methods - ImGui::MarkdownConfig mdConfig; - - mdConfig.linkCallback = markdownLinkCallback; - for ( int i = 0; i < numHeaderLevels; i++ ) { - ImFont* font = reinterpret_cast(headers_[i].font); - mdConfig.headingFormats[i] = { font, (bool)(headers_[i].separator) }; - } - //mdConfig.tooltipCallback = NULL; - mdConfig.imageCallback = markdownImageCallback; - //mdConfig.linkIcon = ICON_FA_LINK; - //mdConfig.userData = NULL; - //mdConfig.formatCallback = ExampleMarkdownFormatCallback; - - // run ImGui Markdown - ImGui::Markdown( markdown_, strlen(markdown_), mdConfig ); - - return iggMarkdownLink; +iggMarkdownLinkCallbackData iggMarkdown(char *markdown_, iggMarkdownHeaderData headers_[], int numHeaderLevels) { + // clean up link cache. + iggMarkdownLink.link = NULL; + iggMarkdownLink.link_len = 0; + + // create imgui markdown config: + // TODO: implement all these methods + ImGui::MarkdownConfig mdConfig; + + mdConfig.linkCallback = markdownLinkCallback; + for (int i = 0; i < numHeaderLevels; i++) { + ImFont *font = reinterpret_cast(headers_[i].font); + mdConfig.headingFormats[i] = {font, (bool)(headers_[i].separator)}; + } + // mdConfig.tooltipCallback = NULL; + mdConfig.imageCallback = markdownImageCallback; + // mdConfig.linkIcon = ICON_FA_LINK; + // mdConfig.userData = NULL; + // mdConfig.formatCallback = ExampleMarkdownFormatCallback; + + // run ImGui Markdown + ImGui::Markdown(markdown_, strlen(markdown_), mdConfig); + + return iggMarkdownLink; } void markdownLinkCallback(ImGui::MarkdownLinkCallbackData data_) { - iggMarkdownLink.link = (char*)(data_.link); - iggMarkdownLink.link_len = data_.linkLength; + iggMarkdownLink.link = (char *)(data_.link); + iggMarkdownLink.link_len = data_.linkLength; } ImGui::MarkdownImageData markdownImageCallback(ImGui::MarkdownLinkCallbackData data_) { - iggMarkdownLinkCallbackData dataWrapped; - dataWrapped.link = (char*)(data_.link); - dataWrapped.link_len = data_.linkLength; - - iggMarkdownImageData src = goMarkdownImageCallback(dataWrapped); - - ImGui::MarkdownImageData result; - - result.useLinkCallback = src.useLinkCallback; - ImTextureID texture = static_cast(src.texture); - if ( texture == 0 ) { - return result; - } - - result.user_texture_id = texture; - - // scale image size to avoid situation, when image is larger than available region - int availableW = ImGui::GetContentRegionAvail().x; - if (src.shouldScale && src.size.x > availableW) { - src.size.y = src.size.y*availableW/src.size.x; - src.size.x = availableW; - } - - Vec2Wrapper size(&src.size); - - Vec2Wrapper uv0(&src.uv0); - Vec2Wrapper uv1(&src.uv1); - Vec4Wrapper tintColor(&src.tintColor); - Vec4Wrapper borderColor(&src.borderColor); - - result.size = *size; - result.uv0 = *uv0; - result.uv1 = *uv1; - result.tint_col = *tintColor; - result.border_col = *borderColor; - - result.isValid = true; - - return result; + iggMarkdownLinkCallbackData dataWrapped; + dataWrapped.link = (char *)(data_.link); + dataWrapped.link_len = data_.linkLength; + + iggMarkdownImageData src = goMarkdownImageCallback(dataWrapped); + + ImGui::MarkdownImageData result; + + result.useLinkCallback = src.useLinkCallback; + ImTextureID texture = reinterpret_cast(src.texture); + if (texture == 0) { + return result; + } + + result.user_texture_id = texture; + + // scale image size to avoid situation, when image is larger than available region + int availableW = ImGui::GetContentRegionAvail().x; + if (src.shouldScale && src.size.x > availableW) { + src.size.y = src.size.y * availableW / src.size.x; + src.size.x = availableW; + } + + Vec2Wrapper size(&src.size); + + Vec2Wrapper uv0(&src.uv0); + Vec2Wrapper uv1(&src.uv1); + Vec4Wrapper tintColor(&src.tintColor); + Vec4Wrapper borderColor(&src.borderColor); + + result.size = *size; + result.uv0 = *uv0; + result.uv1 = *uv1; + result.tint_col = *tintColor; + result.border_col = *borderColor; + + result.isValid = true; + return result; }