Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to access certain things within ImGuiContext #108

Closed
gingerBill opened this issue Nov 10, 2019 · 36 comments
Closed

Add support to access certain things within ImGuiContext #108

gingerBill opened this issue Nov 10, 2019 · 36 comments

Comments

@gingerBill
Copy link

Would it be possible to add support for things that in the ImGuiContext such as ActiveIdTimer, LastActiveIdTimer and many of the other ActiveId* tracking information.

I understand why the ImGuiContext is not defined in the definitions but certain things such as the *ActiveIdTimers are useful for adding custom animated widgets.

I am currently just making my own wrappers, which is fine. I am not sure if others have wanted this, or if they are just adding their own functionality to get this.

@sonoro1234
Copy link
Contributor

Only structs appearing in imgui.h are wrapped and considered in the public API
ImGuiContext is in imgui_internal.h (so it is not in the public API) which is not a cimgui decision but an imgui decision.

@gingerBill
Copy link
Author

@sonoro1234 I understand that, but being able to add widgets which animations do them does require accessing the internal ImGuiContext, which is currently possible. Again, I am just adding my own wrappers at the moment, so it's not that much of a problem.

@sonoro1234
Copy link
Contributor

ocornut/imgui#1925

@gingerBill
Copy link
Author

@sonoro1234 Thank you. I am also trying to use a bit more of the internal stuff too, but thank you. I'll keep to my current solution.

@sonoro1234
Copy link
Contributor

Perhaps @ocornut has something to say about imgui.h and imgui_internal.h?

@ocornut
Copy link

ocornut commented Nov 15, 2019

You could probably provide a cimgui_internal.h with some data structure if you wanted. Nothing in there is guaranteed to be fwd compatible tho.

@sonoro1234
Copy link
Contributor

sonoro1234 commented Nov 15, 2019

@gingerBill
This could be output in cimgui_internal.h

typedef struct ImVector{int Size;int Capacity;void* Data;} ImVector;
typedef struct ImVector_float {int Size;int Capacity;float* Data;} ImVector_float;
typedef struct ImVector_ImWchar {int Size;int Capacity;ImWchar* Data;} ImVector_ImWchar;
typedef struct ImVector_unsigned_char {int Size;int Capacity;unsigned char* Data;} ImVector_unsigned_char;
typedef struct ImVector_ImGuiSettingsHandler {int Size;int Capacity;ImGuiSettingsHandler* Data;} ImVector_ImGuiSettingsHandle
r;
typedef struct ImVector_T {int Size;int Capacity;T* Data;} ImVector_T;
typedef struct ImVector_ImGuiStyleMod {int Size;int Capacity;ImGuiStyleMod* Data;} ImVector_ImGuiStyleMod;
typedef struct ImVector_ImGuiPopupData {int Size;int Capacity;ImGuiPopupData* Data;} ImVector_ImGuiPopupData;
typedef struct ImVector_ImGuiItemFlags {int Size;int Capacity;ImGuiItemFlags* Data;} ImVector_ImGuiItemFlags;
typedef struct ImVector_ImGuiTabItem {int Size;int Capacity;ImGuiTabItem* Data;} ImVector_ImGuiTabItem;
typedef struct ImVector_ImGuiWindowPtr {int Size;int Capacity;ImGuiWindow** Data;} ImVector_ImGuiWindowPtr;
typedef struct ImVector_ImGuiColumns {int Size;int Capacity;ImGuiColumns* Data;} ImVector_ImGuiColumns;
typedef struct ImVector_ImGuiShrinkWidthItem {int Size;int Capacity;ImGuiShrinkWidthItem* Data;} ImVector_ImGuiShrinkWidthIte
m;
typedef struct ImVector_ImGuiID {int Size;int Capacity;ImGuiID* Data;} ImVector_ImGuiID;
typedef struct ImVector_ImGuiGroupData {int Size;int Capacity;ImGuiGroupData* Data;} ImVector_ImGuiGroupData;
typedef struct ImVector_int {int Size;int Capacity;int* Data;} ImVector_int;
typedef struct ImVector_ImGuiColumnData {int Size;int Capacity;ImGuiColumnData* Data;} ImVector_ImGuiColumnData;
typedef struct ImVector_ImDrawListPtr {int Size;int Capacity;ImDrawList** Data;} ImVector_ImDrawListPtr;
typedef struct ImVector_ImFontPtr {int Size;int Capacity;ImFont** Data;} ImVector_ImFontPtr;
typedef struct ImVector_ImGuiWindowSettings {int Size;int Capacity;ImGuiWindowSettings* Data;} ImVector_ImGuiWindowSettings;
typedef struct ImVector_char {int Size;int Capacity;char* Data;} ImVector_char;
typedef struct ImVector_ImGuiColorMod {int Size;int Capacity;ImGuiColorMod* Data;} ImVector_ImGuiColorMod;
typedef struct ImVector_ImGuiPtrOrIndex {int Size;int Capacity;ImGuiPtrOrIndex* Data;} ImVector_ImGuiPtrOrIndex;
struct ImGuiContext
{
    bool Initialized;
    bool FrameScopeActive;
    bool FrameScopePushedImplicitWindow;
    bool FontAtlasOwnedByContext;
    ImGuiIO IO;
    ImGuiStyle Style;
    ImFont* Font;
    float FontSize;
    float FontBaseSize;
    ImDrawListSharedData DrawListSharedData;
    double Time;
    int FrameCount;
    int FrameCountEnded;
    int FrameCountRendered;
    ImVector_ImGuiWindowPtr Windows;
    ImVector_ImGuiWindowPtr WindowsFocusOrder;
    ImVector_ImGuiWindowPtr WindowsSortBuffer;
    ImVector_ImGuiWindowPtr CurrentWindowStack;
    ImGuiStorage WindowsById;
    int WindowsActiveCount;
    ImGuiWindow* CurrentWindow;
    ImGuiWindow* HoveredWindow;
    ImGuiWindow* HoveredRootWindow;
    ImGuiWindow* MovingWindow;
    ImGuiWindow* WheelingWindow;
    ImVec2 WheelingWindowRefMousePos;
    float WheelingWindowTimer;
    ImGuiID HoveredId;
    bool HoveredIdAllowOverlap;
    ImGuiID HoveredIdPreviousFrame;
    float HoveredIdTimer;
    float HoveredIdNotActiveTimer;
    ImGuiID ActiveId;
    ImGuiID ActiveIdIsAlive;
    float ActiveIdTimer;
    bool ActiveIdIsJustActivated;
    bool ActiveIdAllowOverlap;
    bool ActiveIdHasBeenPressedBefore;
    bool ActiveIdHasBeenEditedBefore;
    bool ActiveIdHasBeenEditedThisFrame;
    int ActiveIdAllowNavDirFlags;
    int ActiveIdBlockNavInputFlags;
    ImVec2 ActiveIdClickOffset;
    ImGuiWindow* ActiveIdWindow;
    ImGuiInputSource ActiveIdSource;
    ImGuiID ActiveIdPreviousFrame;
    bool ActiveIdPreviousFrameIsAlive;
    bool ActiveIdPreviousFrameHasBeenEditedBefore;
    ImGuiWindow* ActiveIdPreviousFrameWindow;
    ImGuiID LastActiveId;
    float LastActiveIdTimer;
    ImGuiNextWindowData NextWindowData;
    ImGuiNextItemData NextItemData;
    ImVector_ImGuiColorMod ColorModifiers;
    ImVector_ImGuiStyleMod StyleModifiers;
    ImVector_ImFontPtr FontStack;
    ImVector_ImGuiPopupData OpenPopupStack;
    ImVector_ImGuiPopupData BeginPopupStack;
    ImGuiWindow* NavWindow;
    ImGuiID NavId;
    ImGuiID NavActivateId;
    ImGuiID NavActivateDownId;
    ImGuiID NavActivatePressedId;
    ImGuiID NavInputId;
    ImGuiID NavJustTabbedId;
    ImGuiID NavJustMovedToId;
    ImGuiID NavJustMovedToMultiSelectScopeId;
    ImGuiID NavNextActivateId;
    ImGuiInputSource NavInputSource;
    ImRect NavScoringRectScreen;
    int NavScoringCount;
    ImGuiWindow* NavWindowingTarget;
    ImGuiWindow* NavWindowingTargetAnim;
    ImGuiWindow* NavWindowingList;
    float NavWindowingTimer;
    float NavWindowingHighlightAlpha;
    bool NavWindowingToggleLayer;
    ImGuiNavLayer NavLayer;
    int NavIdTabCounter;
    bool NavIdIsAlive;
    bool NavMousePosDirty;
    bool NavDisableHighlight;
    bool NavDisableMouseHover;
    bool NavAnyRequest;
    bool NavInitRequest;
    bool NavInitRequestFromMove;
    ImGuiID NavInitResultId;
    ImRect NavInitResultRectRel;
    bool NavMoveFromClampedRefRect;
    bool NavMoveRequest;
    ImGuiNavMoveFlags NavMoveRequestFlags;
    ImGuiNavForward NavMoveRequestForward;
    ImGuiDir NavMoveDir;
    ImGuiDir NavMoveDirLast;
    ImGuiDir NavMoveClipDir;
    ImGuiNavMoveResult NavMoveResultLocal;
    ImGuiNavMoveResult NavMoveResultLocalVisibleSet;
    ImGuiNavMoveResult NavMoveResultOther;
    ImGuiWindow* FocusRequestCurrWindow;
    ImGuiWindow* FocusRequestNextWindow;
    int FocusRequestCurrCounterAll;
    int FocusRequestCurrCounterTab;
    int FocusRequestNextCounterAll;
    int FocusRequestNextCounterTab;
    bool FocusTabPressed;
    ImDrawData DrawData;
    ImDrawDataBuilder DrawDataBuilder;
    float DimBgRatio;
    ImDrawList BackgroundDrawList;
    ImDrawList ForegroundDrawList;
    ImGuiMouseCursor MouseCursor;
    bool DragDropActive;
    bool DragDropWithinSourceOrTarget;
    ImGuiDragDropFlags DragDropSourceFlags;
    int DragDropSourceFrameCount;
    int DragDropMouseButton;
    ImGuiPayload DragDropPayload;
    ImRect DragDropTargetRect;
    ImGuiID DragDropTargetId;
    ImGuiDragDropFlags DragDropAcceptFlags;
    float DragDropAcceptIdCurrRectSurface;
    ImGuiID DragDropAcceptIdCurr;
    ImGuiID DragDropAcceptIdPrev;
    int DragDropAcceptFrameCount;
    ImVector_unsigned_char DragDropPayloadBufHeap;
    unsigned char DragDropPayloadBufLocal[8];
    ImGuiTabBar* CurrentTabBar;
    ImPool_ImGuiTabBar TabBars;
    ImVector_ImGuiPtrOrIndex CurrentTabBarStack;
    ImVector_ImGuiShrinkWidthItem ShrinkWidthBuffer;
    ImVec2 LastValidMousePos;
    ImGuiInputTextState InputTextState;
    ImFont InputTextPasswordFont;
    ImGuiID TempInputTextId;
    ImGuiColorEditFlags ColorEditOptions;
    float ColorEditLastHue;
    float ColorEditLastColor[3];
    ImVec4 ColorPickerRef;
    bool DragCurrentAccumDirty;
    float DragCurrentAccum;
    float DragSpeedDefaultRatio;
    float ScrollbarClickDeltaToGrabCenter;
    int TooltipOverrideCount;
    ImVector_char PrivateClipboard;
    ImGuiID MultiSelectScopeId;
    ImVec2 PlatformImePos;
    ImVec2 PlatformImeLastPos;
    bool SettingsLoaded;
    float SettingsDirtyTimer;
    ImGuiTextBuffer SettingsIniData;
    ImVector_ImGuiSettingsHandler SettingsHandlers;
    ImVector_ImGuiWindowSettings SettingsWindows;
    bool LogEnabled;
    ImGuiLogType LogType;
    FILE* LogFile;
    ImGuiTextBuffer LogBuffer;
    float LogLinePosY;
    bool LogLineFirstItem;
    int LogDepthRef;
    int LogDepthToExpand;
    int LogDepthToExpandDefault;
    bool DebugItemPickerActive;
    ImGuiID DebugItemPickerBreakID;
    float FramerateSecPerFrame[120];
    int FramerateSecPerFrameIdx;
    float FramerateSecPerFrameAccum;
    int WantCaptureMouseNextFrame;
    int WantCaptureKeyboardNextFrame;
    int WantTextInputNextFrame;
    char TempBuffer[1024*3+1];
}

Would it be useful?
Better the json file?

@opticfluorine
Copy link

@sonoro1234 Just wanted to chime in that this would be very useful. I know it's not part of the public API and subject to change, but the flexibility this gives is often used in C++ projects and would be very helpful in cimgui-based bindings.

@sonoro1234
Copy link
Contributor

What should I provide?
cimgui_internal.h as above?
a json file for ImGuiContext?

@gingerBill
Copy link
Author

This would be very useful!!! Thank you! I'm not too bothered about forward compatibility as I just fix the version any way for the project I am using.

@sonoro1234
Copy link
Contributor

I still have no answer to my questions.
1- Which part of imgui_internal should be exposed? (some specific struct, all structs, functions also, ...)
2- How should be done? (cimgui_internal.h alone, json files alone, both of them)

@gingerBill
Copy link
Author

@sonoro1234 Who were the questions directed at?

Myself? If so, just exposing the context structure alone is more than enough for 99.9% of things.

@sonoro1234
Copy link
Contributor

Who were the questions directed at?

To everybody having any interest in imgui_internal.h
@gingerBill @opticfluorine @mellinoe and a long etc..

Myself? If so, just exposing the context structure alone is more than enough for 99.9% of things.

I your case I would propose just changing ImGuiContext definition in cimgui.h by the definition in imgui_internal.h

@sonoro1234
Copy link
Contributor

trying the above and compiling the test says

In file included from C:\luaGL\gitsources\anima\LuaJIT-ImGui\cimgui\test\main.c:3:0:
C:/luaGL/gitsources/anima/LuaJIT-ImGui/cimgui/cimgui.h:1156:26: error: field 'DrawListSharedData' has incomplete type
     ImDrawListSharedData DrawListSharedData;
                          ^~~~~~~~~~~~~~~~~~
C:/luaGL/gitsources/anima/LuaJIT-ImGui/cimgui/cimgui.h:1198:25: error: field 'NextWindowData' has incomplete type
     ImGuiNextWindowData NextWindowData;
                         ^~~~~~~~~~~~~~
C:/luaGL/gitsources/anima/LuaJIT-ImGui/cimgui/cimgui.h:1199:23: error: field 'NextItemData' has incomplete type
     ImGuiNextItemData NextItemData;
                       ^~~~~~~~~~~~
C:/luaGL/gitsources/anima/LuaJIT-ImGui/cimgui/cimgui.h:1216:12: error: field 'NavScoringRectScreen' has incomplete type
     ImRect NavScoringRectScreen;
            ^~~~~~~~~~~~~~~~~~~~
C:/luaGL/gitsources/anima/LuaJIT-ImGui/cimgui/cimgui.h:1224:5: error: unknown type name 'ImGuiNavLayer'
     ImGuiNavLayer NavLayer;
     ^~~~~~~~~~~~~
C:/luaGL/gitsources/anima/LuaJIT-ImGui/cimgui/cimgui.h:1234:12: error: field 'NavInitResultRectRel' has incomplete type
     ImRect NavInitResultRectRel;
            ^~~~~~~~~~~~~~~~~~~~
C:/luaGL/gitsources/anima/LuaJIT-ImGui/cimgui/cimgui.h:1238:5: error: unknown type name 'ImGuiNavForward'
     ImGuiNavForward NavMoveRequestForward;
     ^~~~~~~~~~~~~~~
C:/luaGL/gitsources/anima/LuaJIT-ImGui/cimgui/cimgui.h:1241:24: error: field 'NavMoveResultLocal' has incomplete type
     ImGuiNavMoveResult NavMoveResultLocal;
                        ^~~~~~~~~~~~~~~~~~
C:/luaGL/gitsources/anima/LuaJIT-ImGui/cimgui/cimgui.h:1242:24: error: field 'NavMoveResultLocalVisibleSet' has incomplete ty
pe
     ImGuiNavMoveResult NavMoveResultLocalVisibleSet;
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/luaGL/gitsources/anima/LuaJIT-ImGui/cimgui/cimgui.h:1243:24: error: field 'NavMoveResultOther' has incomplete type
     ImGuiNavMoveResult NavMoveResultOther;
                        ^~~~~~~~~~~~~~~~~~
C:/luaGL/gitsources/anima/LuaJIT-ImGui/cimgui/cimgui.h:1252:23: error: field 'DrawDataBuilder' has incomplete type
     ImDrawDataBuilder DrawDataBuilder;
                       ^~~~~~~~~~~~~~~
C:/luaGL/gitsources/anima/LuaJIT-ImGui/cimgui/cimgui.h:1263:12: error: field 'DragDropTargetRect' has incomplete type
     ImRect DragDropTargetRect;
            ^~~~~~~~~~~~~~~~~~
C:/luaGL/gitsources/anima/LuaJIT-ImGui/cimgui/cimgui.h:1273:5: error: unknown type name 'ImPool_ImGuiTabBar'
     ImPool_ImGuiTabBar TabBars;
     ^~~~~~~~~~~~~~~~~~
C:/luaGL/gitsources/anima/LuaJIT-ImGui/cimgui/cimgui.h:1277:25: error: field 'InputTextState' has incomplete type
     ImGuiInputTextState InputTextState;
                         ^~~~~~~~~~~~~~
C:/luaGL/gitsources/anima/LuaJIT-ImGui/cimgui/cimgui.h:1299:5: error: unknown type name 'ImGuiLogType'
     ImGuiLogType LogType;
     ^~~~~~~~~~~~

@sonoro1234
Copy link
Contributor

Adding the structures definitions missing it says

In file included from C:\luaGL\gitsources\anima\LuaJIT-ImGui\cimgui\test\main.c:3:0:
C:/luaGL/gitsources/anima/LuaJIT-ImGui/cimgui/cimgui.h:1197:5: error: expected specifier-qualifier-list before 'ImStb'
     ImStb::STB_TexteditState Stb;
     ^~~~~
C:/luaGL/gitsources/anima/LuaJIT-ImGui/cimgui/cimgui.h:1376:5: error: unknown type name 'ImGuiInputSource'
     ImGuiInputSource ActiveIdSource;
     ^~~~~~~~~~~~~~~~
C:/luaGL/gitsources/anima/LuaJIT-ImGui/cimgui/cimgui.h:1400:5: error: unknown type name 'ImGuiInputSource'
     ImGuiInputSource NavInputSource;
     ^~~~~~~~~~~~~~~~
C:/luaGL/gitsources/anima/LuaJIT-ImGui/cimgui/cimgui.h:1409:5: error: unknown type name 'ImGuiNavLayer'
     ImGuiNavLayer NavLayer;
     ^~~~~~~~~~~~~
C:/luaGL/gitsources/anima/LuaJIT-ImGui/cimgui/cimgui.h:1423:5: error: unknown type name 'ImGuiNavForward'
     ImGuiNavForward NavMoveRequestForward;
     ^~~~~~~~~~~~~~~
C:/luaGL/gitsources/anima/LuaJIT-ImGui/cimgui/cimgui.h:1458:5: error: unknown type name 'ImPool_ImGuiTabBar'
     ImPool_ImGuiTabBar TabBars;
     ^~~~~~~~~~~~~~~~~~
C:/luaGL/gitsources/anima/LuaJIT-ImGui/cimgui/cimgui.h:1484:5: error: unknown type name 'ImGuiLogType'
     ImGuiLogType LogType;
     ^~~~~~~~~~~~
C:/luaGL/gitsources/anima/LuaJIT-ImGui/cimgui/cimgui.h:1518:5: error: unknown type name 'ImGuiNavLayer'
     ImGuiNavLayer NavLayerCurrent;
     ^~~~~~~~~~~~~

Which could be still worked adding enum keyword before enum types declaration and dropping namespace ImStb

But now cimgui.h is too big for only having ImGuiContext defined in it!!!

@sonoro1234
Copy link
Contributor

@ocornut
One stopper for imgui_internal inclusion is in cimgui_test building

[ 12%] Building CXX object CMakeFiles/cimgui.dir/cimgui.cpp.obj
C:\luaGL\gitsources\anima\LuaJIT-ImGui\cimgui\cimgui.cpp: In function 'ImDrawList* igGetForegroundDrawListWindowPtr(ImGuiWind
ow*)':
C:\luaGL\gitsources\anima\LuaJIT-ImGui\cimgui\cimgui.cpp:3117:52: error: expected primary-expression before '*' token
     return ImGui::GetForegroundDrawList(ImGuiWindow*);
                                                    ^
C:\luaGL\gitsources\anima\LuaJIT-ImGui\cimgui\cimgui.cpp:3117:53: error: expected primary-expression before ')' token
     return ImGui::GetForegroundDrawList(ImGuiWindow*);
                                                     ^
mingw32-make[2]: *** [CMakeFiles\cimgui.dir\build.make:63: CMakeFiles/cimgui.dir/cimgui.cpp.obj] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:67: CMakeFiles/cimgui.dir/all] Error 2
mingw32-make: *** [Makefile:127: all] Error 2

It is caused by https://github.com/ocornut/imgui/blob/master/imgui_internal.h#L1603
which should be GetForegroundDrawList(ImGuiWindow* dummy_arg) or whatever in order to have an argument name (Althought not used)

ocornut added a commit to ocornut/imgui that referenced this issue Nov 27, 2019
@ocornut
Copy link

ocornut commented Nov 27, 2019

Pushed fix.

@sonoro1234
Copy link
Contributor

@ocornut
Thanks!
The last stopper comes in

In file included from C:\luaGL\gitsources\anima\LuaJIT-ImGui\cimgui\test\main.c:3:0:
C:/luaGL/gitsources/anima/LuaJIT-ImGui/cimgui/cimgui.h:241:74: error: field 'Map' has incomplete type
 typedef struct ImPool_ImGuiTabBar {ImVector_ImGuiTabBar Buf;ImGuiStorage Map;ImPoolIdx FreeIdx;} ImPool_ImGuiTabBar;

where this typedef needed in C code typedef struct ImPool_ImGuiTabBar {ImVector_ImGuiTabBar Buf;ImGuiStorage Map;ImPoolIdx FreeIdx;} ImPool_ImGuiTabBar; is written before ImGuiStorage is fully defined.
It is not possible to avoid that because typedefs needed in C code must be written before all the struct declarations from imgui.h and imgui_internal.h

The workaround would be to use ImGuiStorage* Map in ImPool. That would only need to adapt ImPool functions that use Map having idx = Map->GetInt(key, -1) instead of idx = Map.GetInt(key, -1) and also Map = new ImGuiStorage() in ImPool constructor and freing memory on destructor

@ocornut
Copy link

ocornut commented Nov 27, 2019

I don't understand how ImGuiTabBar (imgui_internal.h) can be declared before ImGuiStorage (imgui.h). Why is this code in cimgui.h anyway shouldn't it be in cimgui_internal.h ?

The workaround would be to use ImGuiStorage* Map in ImPool.

Unfortunately that's not acceptable (to add an extra indirection/alloc) in such a low-level primitive.

@sonoro1234
Copy link
Contributor

I don't understand how ImGuiTabBar (imgui_internal.h) can be declared before ImGuiStorage (imgui.h). Why is this code in cimgui.h anyway shouldn't it be in cimgui_internal.h ?

Because it is a typedef created by cimgui before all stuff is written to allow C compatibility.

Unfortunately that's not acceptable (to add an extra indirection/alloc) in such a low-level primitive.

Ok. Then I will hack a little to move ImGuiStorage declaration before the relevant typedef.

@sonoro1234
Copy link
Contributor

@gingerBill just pushed cimgui_internal.h generation providing acces to structs and enums in imgui_internal. It should be included after cimgui.h. Does it work correctly?

@gingerBill
Copy link
Author

@sonoro1234 I will give it a go tomorrow. Thank you for everything :)

@sonoro1234
Copy link
Contributor

Just dropped cimgui_internal.h generation because #111

@ocornut
Copy link

ocornut commented Feb 24, 2020

It is caused by cimgui_internal generation. It still can't handle cpp inheritance.
Just pushed a commit to drop it temporarily.

Have you looked into how to support it? It is mostly a parsing issue?

The exporter generally "only" need to replace

struct XXX : public YYY
{
  // Other fields
}

by

struct XXX
{
  YYY yyy;
  // Other fields
}

@sonoro1234
Copy link
Contributor

Well, gingerBill just didn't answer!!
Also, exposing internal api (which is not guaranteed to remain without changes) makes cimgui too big.
May be I will give it a try!!

@ocornut
Copy link

ocornut commented Feb 24, 2020

The reason I found this issue again is that I often see people using other languages (relying on cimgui) being stuck with some of the more experimental features.

If you expose it it should definitively be in another header file (e.g. cimgui_internal.h)
And then high-level wrappers such as C# can wrap it in a different namespace.

@gingerBill
Copy link
Author

@sonoro1234 @ocornut

I apologize I did not answer. I did test it and it did work.

The solution that I have worked out for my stuff is to just replicate the ImContext structure in C along with all of its dependencies and use that. I know this is not the safest approach which will guarantee much, but t solved all of my requirements for it. However, I still manually generate this structure.

I do agree that this should be a completely separate header file because of a lot of it is more "advanced" than the non-internal API.

@sonoro1234
Copy link
Contributor

Too busy at the moment, I expect to work on this next week.

@sonoro1234
Copy link
Contributor

@ocornut I have been working a little
I cant find the meaning of ImGuiDockNodeFlags_SharedFlagsInheritMask_ = ~0, or int rounding_corners_flags = ~0

@ocornut
Copy link

ocornut commented Feb 28, 2020 via email

@sonoro1234
Copy link
Contributor

sonoro1234 commented Feb 29, 2020

Thanks (I should have googled C++ operators)
I pushed yesterday a commit for cimgui_internal.h generation.
Also did more robust parsing of enum values and structs_and_enums_i.(lua/json) generation (althought the generated files were not attached in the commit)

I think it is finished?

@ocornut
Copy link

ocornut commented Mar 2, 2020

I think it is finished?

If it works with Docking branch then I would say yes!
It would be nice if both master and docking branch had pre-generated version of cimgui header files.

Bonus suggestion :)

If you are generating bindings for the docking branch of imgui, you must define the IMGUI_DOCKING constant in CMakeLists.txt. This includes extra custom definitions that are needed for some functionality on the docking branch.

imgui.h has

#define IMGUI_HAS_VIEWPORT          1 // Viewport WIP branch
#define IMGUI_HAS_DOCK              1 // Docking WIP branch

And others depending on branches/features, so if those are somehow copied to cimgui.h then the code can automatically handle both branches?

@sonoro1234
Copy link
Contributor

sonoro1234 commented Mar 2, 2020

My git knowledge is quite limited, but perhaps you have some suggestion.
The problem with my docking branch is that it has lost all the changes to generator done in master after docking was created. The only way should be to delete the docking branch and then recreate it from the new master, pull imgui/docking, generate and push again.

Perhaps you know a better way?

Added branch docking_last

@ocornut
Copy link

ocornut commented Mar 9, 2020 via email

@sonoro1234
Copy link
Contributor

They can be generated but I only add generated files in the commit of last_docking branch

@sonoro1234
Copy link
Contributor

sonoro1234 commented Mar 24, 2020

seeing ocornut/imgui#2951
and #123 (comment)
It would seem that people expects imgui_internal functions to be wrapped. I think it is possible but the size would be much bigger, perhaps a solution would be to add a parameter to generate external api only or both apis depending on users choice.

It is done now in internal_functions branch. Could not generate separated cimgui and cimgui_internal files because the parsing cant be separated to avoid collisions between both. An option was added to .bat and .sh files to generate or not the internal wrapping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants