浏览代码

Added a UserData void *pointer so that the callback functions can access user state

"Just in case a project has adverse reactions to adding globals or
statics in their own code."
ocornut 11 年之前
父节点
当前提交
1d9a4748de
共有 2 个文件被更改,包括 4 次插入0 次删除
  1. 1 0
      imgui.cpp
  2. 3 0
      imgui.h

+ 1 - 0
imgui.cpp

@@ -331,6 +331,7 @@ ImGuiIO::ImGuiIO()
     MouseDoubleClickMaxDist = 6.0f;
 
     // User functions
+    UserData = NULL;
     RenderDrawListsFn = NULL;
     MemAllocFn = malloc;
     MemReallocFn = realloc;

+ 3 - 0
imgui.h

@@ -427,6 +427,9 @@ struct ImGuiIO
     // User Functions
     //------------------------------------------------------------------
 
+    // Store your own data for retrieval by callbacks.
+    void*       UserData;                   // = NULL
+
     // REQUIRED: rendering function. 
     // See example code if you are unsure of how to implement this.
     void        (*RenderDrawListsFn)(ImDrawList** const draw_lists, int count);