feat(imgui): embeddable plot widget and demo
This commit is contained in:
1 parent
fb2c2f5e4d
commit
15931a2405
9 files changed
+1072
-38
No files matched your search
@@ -0,0 +1,54 @@
|
||||
# The Dear ImGui adapter: a widget that draws a plot into a child region of the
|
||||
# framebuffer ImGui is rendering its own chrome into, and feeds that plot
|
||||
# ImGui's mouse and keyboard state.
|
||||
#
|
||||
# ImGui is not a packaging dependency here: it is fetched pinned to a release
|
||||
# tag (never a branch, so a build is reproducible) and only the sources this
|
||||
# adapter needs are compiled -- the core plus the GLFW and OpenGL 3 backends.
|
||||
# The fetched sources are third-party code: they are not held to this project's
|
||||
# warning set, and the adapter and its example are.
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(imgui
|
||||
GIT_REPOSITORY https://github.com/ocornut/imgui.git
|
||||
GIT_TAG v1.91.9b
|
||||
GIT_SHALLOW TRUE)
|
||||
# imgui has no top-level CMakeLists.txt, so MakeAvailable populates it and stops;
|
||||
# the sources are added to the target below by name.
|
||||
FetchContent_MakeAvailable(imgui)
|
||||
|
||||
if(NOT imgui_SOURCE_DIR OR NOT EXISTS "${imgui_SOURCE_DIR}/imgui.cpp")
|
||||
message(FATAL_ERROR
|
||||
"plot: the Dear ImGui sources for tag v1.91.9b are missing from "
|
||||
"'${imgui_SOURCE_DIR}'. The FetchContent clone failed, so PLOT_BUILD_IMGUI "
|
||||
"cannot link anything; either restore network access or pre-populate the "
|
||||
"source with -DFETCHCONTENT_SOURCE_DIR_IMGUI=<path>.")
|
||||
endif()
|
||||
|
||||
add_library(imgui STATIC
|
||||
"${imgui_SOURCE_DIR}/imgui.cpp"
|
||||
"${imgui_SOURCE_DIR}/imgui_draw.cpp"
|
||||
"${imgui_SOURCE_DIR}/imgui_tables.cpp"
|
||||
"${imgui_SOURCE_DIR}/imgui_widgets.cpp"
|
||||
"${imgui_SOURCE_DIR}/backends/imgui_impl_glfw.cpp"
|
||||
"${imgui_SOURCE_DIR}/backends/imgui_impl_opengl3.cpp")
|
||||
# Both include roots are public: a consumer of the backends -- the adapter and
|
||||
# the example -- reaches them as <imgui.h> and <backends/imgui_impl_glfw.h>.
|
||||
target_include_directories(imgui PUBLIC
|
||||
"${imgui_SOURCE_DIR}"
|
||||
"${imgui_SOURCE_DIR}/backends")
|
||||
|
||||
# imgui_impl_glfw.cpp needs GLFW; a build that also enables the GLFW adapter
|
||||
# gets the same target, never a second copy.
|
||||
plot_find_glfw(plot_imgui_glfw_dep)
|
||||
target_link_libraries(imgui PUBLIC ${plot_imgui_glfw_dep})
|
||||
target_compile_features(imgui PUBLIC cxx_std_20)
|
||||
|
||||
add_library(plot_imgui STATIC imgui_plot.cpp)
|
||||
add_library(plot::imgui ALIAS plot_imgui)
|
||||
# The public include root is `adapters/`, so the header is reached as
|
||||
# <imgui/imgui_plot.hpp> -- the toolkit's name first, like every other adapter's.
|
||||
target_include_directories(plot_imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
||||
# ImGui stays PRIVATE: the adapter's header includes no ImGui header, so a
|
||||
# consumer of plot::imgui does not inherit the toolkit's headers.
|
||||
target_link_libraries(plot_imgui PUBLIC plot::core PRIVATE imgui ${plot_imgui_glfw_dep})
|
||||
plot_apply_warnings(plot_imgui)
|
||||
Reference in new issue
Block a user