ImNodeFlow icon indicating copy to clipboard operation
ImNodeFlow copied to clipboard

Working example on Mac and Linux

Open pavanakumar opened this issue 1 year ago • 1 comments

Thanks for the fantastic library. I have

  • added a working example with CMakeList.txt that automatically download the sources and setup the targets
  • the example working on SDL2+OpenGL3 and template CMakeLists.txt is provided in readme.txt for 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.txt from root folder

pavanakumar avatar Sep 04 '24 12:09 pavanakumar

I'll be reviewing this in the following weeks as work at uni has me quite busy. Meanwhile thanks for the contribution

Fattorino avatar Sep 08 '24 09:09 Fattorino

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 👍

AaronAppel avatar Apr 19 '25 13:04 AaronAppel

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 avatar Apr 20 '25 21:04 Fattorino

@Fattorino do you need some help to manage this project?

arabine avatar Apr 24 '25 09:04 arabine

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()

arabine avatar Apr 28 '25 07:04 arabine

Is this cmake for the example?

Fattorino avatar Apr 28 '25 12:04 Fattorino

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

pavanakumar avatar Apr 28 '25 13:04 pavanakumar

Okay nice, go for merge on my side. (not tested ecmascripten).

arabine avatar Apr 28 '25 13:04 arabine

@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.

Fattorino avatar Apr 30 '25 06:04 Fattorino