Repository: conan-io/conan-center-index

Issue:
[request] imgui/any. "Docking" feature
### Package Details
  * Package Name/Version: **imgui/any**
  * Homepage: **https://github.com/ocornut/imgui**

There is a feature "Docking" in this library that lives in a separate branch a long time (from 2018) and is still regularly updated over time (last merge from master about 14 days ago). I'd wanted to have a package with this feature, maybe something like `imgui/1.84.2-docking`


Discussion:
Hi! Why is this feature in a branch? Why is not merged to `master`? Here we are packaging released library versions, and we have some strict policy around patches (to avoid diverging from official releases), so maybe you need to push first that feature into `imgui` and then we will package it.
This will likely answer your questions : https://github.com/ocornut/imgui/wiki/Docking#preamble
In particular,
> It is safe and recommended to use that branch.

@jgsogo i can't just come into some other's people repo and merge everything I want. @Sahnvour mentioned a useful link (thank you). I'm sure this can be done in a some way that won't affect main package. Like adding a suffix in version or a brand new package
Hi @jgsogo, did you have any time to think about it ? What would be needed to get the docking branch packaged ?
Hey nothing done yet? @Sahnvour and @xahon did you managed to get it? Please help I also want to use docking branch with conan.
Not that I know of. It should be really easy to do, the issue is more to know wether the conan folks will accept it.

Resolving patch:
diff --git a/recipes/imgui/all/conanfile.py b/recipes/imgui/all/conanfile.py
--- a/recipes/imgui/all/conanfile.py
+++ b/recipes/imgui/all/conanfile.py
@@ -1,5 +1,6 @@
 from conans import ConanFile, CMake, tools
 import os
+import re
 
 required_conan_version = ">=1.33.0"
 
@@ -55,9 +56,11 @@ def build(self):
 
     def package(self):
         self.copy(pattern="LICENSE.txt", dst="licenses", src=self._source_subfolder)
+        m = re.match(r'cci\.\d{8}\+(?P<version>\d+\.\d+)\.docking', str(self.version))
+        version = tools.Version(m.group('version')) if m else tools.Version(self.version)
         backends_folder = os.path.join(
             self._source_subfolder,
-            "backends" if tools.Version(self.version) >= "1.80" else "examples"
+            "backends" if version >= "1.80" else "examples"
         )
         self.copy(pattern="imgui_impl_*",
                   dst=os.path.join("res", "bindings"),


Test patch:
diff --git a/recipes/imgui/all/test_package/CMakeLists.txt b/recipes/imgui/all/test_package/CMakeLists.txt
--- a/recipes/imgui/all/test_package/CMakeLists.txt
+++ b/recipes/imgui/all/test_package/CMakeLists.txt
@@ -10,3 +10,6 @@ set(CMAKE_CXX_STANDARD 11)
 
 add_executable(${PROJECT_NAME} test_package.cpp)
 target_link_libraries(${PROJECT_NAME} imgui::imgui)
+if (DOCKING)
+    target_compile_definitions(${PROJECT_NAME} PRIVATE -DDOCKING)
+endif()
diff --git a/recipes/imgui/all/test_package/conanfile.py b/recipes/imgui/all/test_package/conanfile.py
--- a/recipes/imgui/all/test_package/conanfile.py
+++ b/recipes/imgui/all/test_package/conanfile.py
@@ -4,9 +4,14 @@
 class TestPackageConan(ConanFile):
     settings = "os", "arch", "compiler", "build_type"
     generators = "cmake", "cmake_find_package"
+    test_type = "explicit"
+
+    def requirements(self):
+        self.requires(self.tested_reference_str)
 
     def build(self):
         cmake = CMake(self)
+        cmake.definitions["DOCKING"] = 'docking' in self.tested_reference_str
         cmake.configure()
         cmake.build()
 
diff --git a/recipes/imgui/all/test_package/test_package.cpp b/recipes/imgui/all/test_package/test_package.cpp
--- a/recipes/imgui/all/test_package/test_package.cpp
+++ b/recipes/imgui/all/test_package/test_package.cpp
@@ -1,4 +1,8 @@
 #include <imgui.h>
+#ifdef DOCKING
+    #include <imgui_internal.h>
+#endif
+
 #include <stdio.h>
 
 int main(int, char**)
@@ -21,6 +25,13 @@ int main(int, char**)
         io.DeltaTime = 1.0f / 60.0f;
         ImGui::NewFrame();
 
+#ifdef DOCKING
+        auto dockspaceID = ImGui::GetID("MyDockSpace");
+        static ImGuiDockNodeFlags dockspace_flags = ImGuiDockNodeFlags_None;
+        ImGui::DockSpace(dockspaceID, ImVec2(0.0f, 0.0f), dockspace_flags);
+        printf("  with docking\n");
+#endif
+
         static float f = 0.0f;
         ImGui::Text("Hello, world!");
         ImGui::Text("%s", textBuffer.begin());