diff --git a/backend_test/CMakeLists.txt b/backend_test/CMakeLists.txt index 9b84a4b..c21e680 100644 --- a/backend_test/CMakeLists.txt +++ b/backend_test/CMakeLists.txt @@ -12,6 +12,12 @@ else() set(BAKENDS_FOLDER "../imgui/examples/") endif() +if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../imgui/imgui_tables.cpp) + set(TABLES_SOURCE "../imgui/imgui_tables.cpp") +else() + set(TABLES_SOURCE "") +endif() + include_directories(../imgui) add_definitions("-DIMGUI_DISABLE_OBSOLETE_FUNCTIONS=1") @@ -20,7 +26,8 @@ set(IMGUI_SOURCES ../cimgui.cpp ../imgui/imgui.cpp ../imgui/imgui_draw.cpp ../imgui/imgui_demo.cpp -../imgui/imgui_widgets.cpp +../imgui/imgui_widgets.cpp +${TABLES_SOURCE} ) set(IMGUI_SOURCES_sdl) @@ -45,9 +52,9 @@ if(IMGUI_FREETYPE) endif(IMGUI_FREETYPE) #opengl3 -list(APPEND IMGUI_SOURCES ${BAKENDS_FOLDER}imgui_impl_opengl3.cpp ${BAKENDS_FOLDER}libs/gl3w/GL/gl3w.c) +list(APPEND IMGUI_SOURCES ${BAKENDS_FOLDER}imgui_impl_opengl3.cpp ../imgui/examples/libs/gl3w/GL/gl3w.c) list(APPEND IMGUI_SOURCES ./cimgui_extras.cpp) -include_directories(${BAKENDS_FOLDER}libs/gl3w) +include_directories(../imgui/examples/libs/gl3w) if(WIN32) list(APPEND IMGUI_LIBRARIES opengl32) else(WIN32)#Unix diff --git a/backend_test/main.c b/backend_test/main.c index f166d14..f405d08 100644 --- a/backend_test/main.c +++ b/backend_test/main.c @@ -11,7 +11,7 @@ #include #include -//#define USE_DOCKING + SDL_Window *window = NULL; @@ -78,7 +78,7 @@ int main(int argc, char* argv[]) ImGuiIO* ioptr = igGetIO(); ioptr->ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls //ioptr->ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls -#ifdef USE_DOCKING +#ifdef IMGUI_HAS_DOCK ioptr->ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking ioptr->ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows #endif @@ -167,7 +167,7 @@ int main(int argc, char* argv[]) glClearColor(clearColor.x, clearColor.y, clearColor.z, clearColor.w); glClear(GL_COLOR_BUFFER_BIT); ImGui_ImplOpenGL3_RenderDrawData(igGetDrawData()); -#ifdef USE_DOCKING +#ifdef IMGUI_HAS_DOCK if (ioptr->ConfigFlags & ImGuiConfigFlags_ViewportsEnable) { SDL_Window* backup_current_window = SDL_GL_GetCurrentWindow(); diff --git a/generator/generator.lua b/generator/generator.lua index 21cd1a6..cb6341a 100644 --- a/generator/generator.lua +++ b/generator/generator.lua @@ -306,7 +306,11 @@ local function cimgui_generation(parser) outpost = outpost1..table.concat(outtabpool)..outpost2 local cstructsstr = outpre..table.concat(outtab,"")..outpost --..(extra or "") - + + if gdefines.IMGUI_HAS_DOCK then + cstructsstr = cstructsstr.."\n#define IMGUI_HAS_DOCK 1\n" + end + hstrfile = hstrfile:gsub([[#include "imgui_structs%.h"]],cstructsstr) local cfuncsstr = func_header_generate(parser) hstrfile = hstrfile:gsub([[#include "auto_funcs%.h"]],cfuncsstr) @@ -324,18 +328,30 @@ end -------------------------------------------------------- -----------------------------do it---------------------- -------------------------------------------------------- ---get imgui.h version-------------------------- +--get imgui.h version and IMGUI_HAS_DOCK-------------------------- +--get some defines wont work for cl ---------------- +gdefines = get_defines{"IMGUI_VERSION","FLT_MAX","IMGUI_HAS_DOCK"} +--this will work for cl local pipe,err = io.open("../imgui/imgui.h","r") if not pipe then error("could not open file:"..err) end -local imgui_version +local imgui_version,has_dock while true do local line = pipe:read"*l" - imgui_version = line:match([[#define%s+IMGUI_VERSION%s+(".+")]]) - if imgui_version then break end + if not line then break end + if not imgui_version then + imgui_version = line:match([[#define%s+IMGUI_VERSION%s+(".+")]]) + end + if not has_dock then + has_dock = line:match([[#define%s+IMGUI_HAS_DOCK%s+(".+")]]) + end + if imgui_version and has_dock then break end end pipe:close() + +if has_dock then gdefines.IMGUI_HAS_DOCK = true end + cimgui_header = cimgui_header:gsub("XXX",imgui_version) if INTERNAL_GENERATION then cimgui_header = cimgui_header..[[//with imgui_internal.h api @@ -345,9 +361,13 @@ if FREETYPE_GENERATION then cimgui_header = cimgui_header..[[//with imgui_freetype.h api ]] end +if gdefines.IMGUI_HAS_DOCK then + cimgui_header = cimgui_header..[[//docking branch +]] + print("IMGUI_HAS_DOCK",gdefines.IMGUI_HAS_DOCK) +end print("IMGUI_VERSION",imgui_version) ---get some defines---------------------------- -gdefines = get_defines{"IMGUI_VERSION","FLT_MAX"} + --funtion for parsing imgui headers local function parseImGuiHeader(header,names) diff --git a/generator/output/structs_and_enums.json b/generator/output/structs_and_enums.json index ebb60a9..1a87014 100644 --- a/generator/output/structs_and_enums.json +++ b/generator/output/structs_and_enums.json @@ -2643,6 +2643,7 @@ } ] }, + "enumtypes": [], "locations": { "ImBitVector": "imgui_internal:470", "ImColor": "imgui:1953", diff --git a/generator/output/structs_and_enums.lua b/generator/output/structs_and_enums.lua index 41b0e2b..5d1b292 100644 --- a/generator/output/structs_and_enums.lua +++ b/generator/output/structs_and_enums.lua @@ -2080,6 +2080,7 @@ defs["enums"]["ImGuiWindowFlags_"][30] = {} defs["enums"]["ImGuiWindowFlags_"][30]["calc_value"] = 268435456 defs["enums"]["ImGuiWindowFlags_"][30]["name"] = "ImGuiWindowFlags_ChildMenu" defs["enums"]["ImGuiWindowFlags_"][30]["value"] = "1 << 28" +defs["enumtypes"] = {} defs["locations"] = {} defs["locations"]["ImBitVector"] = "imgui_internal:470" defs["locations"]["ImColor"] = "imgui:1953" diff --git a/test/main.c b/test/main.c index dca3440..0a9d0c5 100644 --- a/test/main.c +++ b/test/main.c @@ -24,11 +24,13 @@ int main(void) io->DisplaySize = display_size; io->DeltaTime = 1.0f / 60.0f; igNewFrame(); - + + igBegin("mainwindow",NULL,ImGuiWindowFlags_NoTitleBar); static float f = 0.0f; igText("Hello World!"); igSliderFloat("float", &f, 0.0f, 1.0f, "%.3f", 0); igText("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io->Framerate, io->Framerate); + igEnd(); igShowDemoWindow(NULL); igRender();