Working example on Mac and Linux
Thanks for the fantastic library. I have
- added a working example with
CMakeList.txtthat automatically download the sources and setup the targets - the example working on SDL2+OpenGL3 and template
CMakeLists.txtis provided inreadme.txtfor other backends - fixed warnings on unused variable in
src/imgui_bezier_math.inl - fixed warning on reordering of class member in
include/ImNodeFlow.h - removed
CMakeLists.txtfrom root folder
I'll be reviewing this in the following weeks as work at uni has me quite busy. Meanwhile thanks for the contribution
Thanks pavanakumar for sharing your example. It would be nice if the documentation.md had a sort of "quick start" section or example.md to reference how to integrate a simple demo/starting point into an app's main loop. And thank you for the awesome node editor, Fattorino 👍
it's sad to leave this PR un-merged and not updating the project more often. I hope one day I'll be able to show some love to it again and fix up some left over things. (University is such a diva taking up all my time lol)
@Fattorino do you need some help to manage this project?
Ok here is the updated CMakeLists that fixes warnings and specify ImGui version. Otherwise, this PR is a must have to quick test and understand the library. Maybe in the future: add the possibility to add nodes + draw them in specified X,Y positions. @AaronAppel can you update your PR?
cmake_minimum_required(VERSION 3.14)
project(MyProject VERSION 1.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(IMGUI_DIR ${CMAKE_CURRENT_LIST_DIR}/includes/imgui)
set(IMNODEFLOW_DIR ${CMAKE_CURRENT_LIST_DIR}/..)
include(FetchContent)
FetchContent_Declare(
imgui
GIT_REPOSITORY "https://github.com/ocornut/imgui.git"
GIT_TAG "v1.91.6" # Update with future minimum compatibility
SOURCE_DIR ${IMGUI_DIR}
GIT_SHALLOW TRUE # Limit history to download
)
FetchContent_MakeAvailable(imgui)
list(APPEND imgui_sources
${IMGUI_DIR}/imgui.cpp
${IMGUI_DIR}/misc/cpp/imgui_stdlib.cpp
${IMGUI_DIR}/imgui_draw.cpp
${IMGUI_DIR}/imgui_tables.cpp
${IMGUI_DIR}/imgui_widgets.cpp
${IMGUI_DIR}/backends/imgui_impl_sdl2.cpp
${IMGUI_DIR}/backends/imgui_impl_opengl3.cpp
)
list(APPEND imnode_flow_sources
${IMNODEFLOW_DIR}/src/ImNodeFlow.cpp
)
add_executable(example example.cpp ${imgui_sources} ${imnode_flow_sources})
target_include_directories(example PRIVATE ${IMGUI_DIR} ${IMNODEFLOW_DIR}/include ${IMGUI_DIR}/backends)
target_compile_definitions(example PRIVATE IMGUI_DEFINE_MATH_OPERATORS)
if(CMAKE_SYSTEM_NAME MATCHES Emscripten)
include(cmake/emscripten.cmake)
else()
include(cmake/desktop.cmake)
endif()
Is this cmake for the example?
This is a change set to the existing CMakeLists.txt for the example I created, have now merged the changes by @arabine and a fix to the window header
Okay nice, go for merge on my side. (not tested ecmascripten).
@pavanakumar I was taling about the "global" CMake, not the example one. I don't like how, now, to use the library you have to manually add the .cpp file to the list of sources of the executable. I much prefer the use of add_subdirectory() and then linking. But Im open to discuss to find the true best solution (Im far from a CMake expert), if you could please open an issue about it so not to discuss it here.