1 /*
2  * Copyright (c) 2015 Derelict Developers
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  *   notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  *   notice, this list of conditions and the following disclaimer in the
14  *   documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the names 'Derelict', 'DerelictILUT', nor the names of its contributors
17  *   may be used to endorse or promote products derived from this software
18  *   without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 module derelict.imgui.types;
33 
34 import derelict.util.system;
35 
36 enum
37 {
38     ImGuiKey_Tab,       // for tabbing through fields
39     ImGuiKey_LeftArrow, // for text edit
40     ImGuiKey_RightArrow,// for text edit
41     ImGuiKey_UpArrow,   // for text edit
42     ImGuiKey_DownArrow, // for text edit
43     ImGuiKey_PageUp,
44     ImGuiKey_PageDown,
45     ImGuiKey_Home,      // for text edit
46     ImGuiKey_End,       // for text edit
47     ImGuiKey_Delete,    // for text edit
48     ImGuiKey_Backspace, // for text edit
49     ImGuiKey_Enter,     // for text edit
50     ImGuiKey_Escape,    // for text edit
51     ImGuiKey_A,         // for text edit CTRL+A: select all
52     ImGuiKey_C,         // for text edit CTRL+C: copy
53     ImGuiKey_V,         // for text edit CTRL+V: paste
54     ImGuiKey_X,         // for text edit CTRL+X: cut
55     ImGuiKey_Y,         // for text edit CTRL+Y: redo
56     ImGuiKey_Z,         // for text edit CTRL+Z: undo
57 	ImGuiKey_COUNT
58 };
59 
60 enum
61 {
62     // Default: 0
63     ImGuiWindowFlags_NoTitleBar             = 1 << 0,   // Disable title-bar
64     ImGuiWindowFlags_NoResize               = 1 << 1,   // Disable user resizing with the lower-right grip
65     ImGuiWindowFlags_NoMove                 = 1 << 2,   // Disable user moving the window
66     ImGuiWindowFlags_NoScrollbar            = 1 << 3,   // Disable scrollbar (window can still scroll with mouse or programatically)
67     ImGuiWindowFlags_NoScrollWithMouse      = 1 << 4,   // Disable user scrolling with mouse wheel
68     ImGuiWindowFlags_NoCollapse             = 1 << 5,   // Disable user collapsing window by double-clicking on it
69     ImGuiWindowFlags_AlwaysAutoResize       = 1 << 6,   // Resize every window to its content every frame
70     ImGuiWindowFlags_ShowBorders            = 1 << 7,   // Show borders around windows and items
71     ImGuiWindowFlags_NoSavedSettings        = 1 << 8,   // Never load/save settings in .ini file
72 	ImGuiWindowFlags_NoInputs               = 1 << 9,   // Disable catching mouse or keyboard inputs
73     ImGuiWindowFlags_MenuBar                = 1 << 10,   // Has a menubar
74     ImGuiWindowFlags_HorizontalScrollbar    = 1 << 11,  // Enable horizontal scrollbar (off by default). You need to use SetNextWindowContentSize(ImVec2(width,0.0f)); prior to calling Begin() to specify width. Read code in imgui_demo in the "Horizontal Scrolling" section.
75     ImGuiWindowFlags_NoFocusOnAppearing     = 1 << 12,  // Disable taking focus when transitioning from hidden to visible state
76     ImGuiWindowFlags_NoBringToFrontOnFocus  = 1 << 13,  // Disable bringing window to front when taking focus (e.g. clicking on it or programatically giving it focus)
77     // [Internal]
78     ImGuiWindowFlags_ChildWindow            = 1 << 20,  // Don't use! For internal use by BeginChild()
79     ImGuiWindowFlags_ChildWindowAutoFitX    = 1 << 21,  // Don't use! For internal use by BeginChild()
80     ImGuiWindowFlags_ChildWindowAutoFitY    = 1 << 22,  // Don't use! For internal use by BeginChild()
81     ImGuiWindowFlags_ComboBox               = 1 << 23,  // Don't use! For internal use by ComboBox()
82     ImGuiWindowFlags_Tooltip                = 1 << 24,  // Don't use! For internal use by BeginTooltip()
83     ImGuiWindowFlags_Popup                  = 1 << 25,  // Don't use! For internal use by BeginPopup()
84     ImGuiWindowFlags_Modal                  = 1 << 26,  // Don't use! For internal use by BeginPopupModal()
85     ImGuiWindowFlags_ChildMenu              = 1 << 27   // Don't use! For internal use by BeginMenu()
86 }
87 
88 enum
89 {
90     // Default: 0
91     ImGuiInputTextFlags_CharsDecimal        = 1 << 0,   // Allow 0123456789.+-*/
92     ImGuiInputTextFlags_CharsHexadecimal    = 1 << 1,   // Allow 0123456789ABCDEFabcdef
93     ImGuiInputTextFlags_CharsUppercase      = 1 << 2,   // Turn a..z into A..Z
94     ImGuiInputTextFlags_CharsNoBlank        = 1 << 3,   // Filter out spaces, tabs
95     ImGuiInputTextFlags_AutoSelectAll       = 1 << 4,   // Select entire text when first taking mouse focus
96     ImGuiInputTextFlags_EnterReturnsTrue    = 1 << 5,   // Return 'true' when Enter is pressed (as opposed to when the value was modified)
97     ImGuiInputTextFlags_CallbackCompletion  = 1 << 6,   // Call user function on pressing TAB (for completion handling)
98     ImGuiInputTextFlags_CallbackHistory     = 1 << 7,   // Call user function on pressing Up/Down arrows (for history handling)
99     ImGuiInputTextFlags_CallbackAlways      = 1 << 8,   // Call user function every time
100     ImGuiInputTextFlags_CallbackCharFilter  = 1 << 9,   // Call user function to filter character. Modify data->EventChar to replace/filter input, or return 1 to discard character.
101     ImGuiInputTextFlags_AllowTabInput       = 1 << 10,  // Pressing TAB input a '\t' character into the text field
102     ImGuiInputTextFlags_CtrlEnterForNewLine = 1 << 11,  // In multi-line mode, allow exiting edition by pressing Enter. Ctrl+Enter to add new line (by default adds new lines with Enter).
103     ImGuiInputTextFlags_NoHorizontalScroll  = 1 << 12,  // Disable following the cursor horizontally
104     ImGuiInputTextFlags_AlwaysInsertMode    = 1 << 13,  // Insert mode
105     ImGuiInputTextFlags_ReadOnly            = 1 << 14,  // Read-only mode
106     // [Internal]
107     ImGuiInputTextFlags_Multiline           = 1 << 20   // For internal use by InputTextMultiline()
108 }
109 
110 enum
111 {
112     // Default: 0
113     ImGuiSelectableFlags_DontClosePopups    = 1 << 0,   // Clicking this don't close parent popup window
114     ImGuiSelectableFlags_SpanAllColumns     = 1 << 1    // Selectable frame can span all columns (text will still fit in current column)
115 }
116 
117 enum
118 {
119     ImGuiSetCond_Always        = 1 << 0, // Set the variable
120     ImGuiSetCond_Once          = 1 << 1, // Only set the variable on the first call per runtime session
121     ImGuiSetCond_FirstUseEver  = 1 << 2, // Only set the variable if the window doesn't exist in the .ini file
122     ImGuiSetCond_Appearing     = 1 << 3  // Only set the variable if the window is appearing after being inactive (or the first time)
123 }
124 
125 enum
126 {
127     ImGuiCol_Text,
128     ImGuiCol_TextDisabled,
129     ImGuiCol_WindowBg,
130     ImGuiCol_ChildWindowBg,
131     ImGuiCol_Border,
132     ImGuiCol_BorderShadow,
133     ImGuiCol_FrameBg,               // Background of checkbox, radio button, plot, slider, text input
134     ImGuiCol_FrameBgHovered,
135     ImGuiCol_FrameBgActive,
136     ImGuiCol_TitleBg,
137     ImGuiCol_TitleBgCollapsed,
138     ImGuiCol_TitleBgActive,
139     ImGuiCol_MenuBarBg,
140     ImGuiCol_ScrollbarBg,
141     ImGuiCol_ScrollbarGrab,
142     ImGuiCol_ScrollbarGrabHovered,
143     ImGuiCol_ScrollbarGrabActive,
144     ImGuiCol_ComboBg,
145     ImGuiCol_CheckMark,
146     ImGuiCol_SliderGrab,
147     ImGuiCol_SliderGrabActive,
148     ImGuiCol_Button,
149     ImGuiCol_ButtonHovered,
150     ImGuiCol_ButtonActive,
151     ImGuiCol_Header,
152     ImGuiCol_HeaderHovered,
153     ImGuiCol_HeaderActive,
154     ImGuiCol_Column,
155     ImGuiCol_ColumnHovered,
156     ImGuiCol_ColumnActive,
157     ImGuiCol_ResizeGrip,
158     ImGuiCol_ResizeGripHovered,
159     ImGuiCol_ResizeGripActive,
160     ImGuiCol_CloseButton,
161     ImGuiCol_CloseButtonHovered,
162     ImGuiCol_CloseButtonActive,
163     ImGuiCol_PlotLines,
164     ImGuiCol_PlotLinesHovered,
165     ImGuiCol_PlotHistogram,
166     ImGuiCol_PlotHistogramHovered,
167     ImGuiCol_TextSelectedBg,
168     ImGuiCol_TooltipBg,
169     ImGuiCol_ModalWindowDarkening,  // darken entire screen when a modal window is active
170     ImGuiCol_COUNT
171 }
172 
173 enum
174 {
175 	ImGuiStyleVar_Alpha,               // float
176 	ImGuiStyleVar_WindowPadding,       // ImVec2
177 	ImGuiStyleVar_WindowRounding,      // float
178     ImGuiStyleVar_WindowMinSize,       // ImVec2
179 	ImGuiStyleVar_ChildWindowRounding, // float
180 	ImGuiStyleVar_FramePadding,        // ImVec2
181 	ImGuiStyleVar_FrameRounding,       // float
182 	ImGuiStyleVar_ItemSpacing,         // ImVec2
183 	ImGuiStyleVar_ItemInnerSpacing,    // ImVec2
184 	ImGuiStyleVar_IndentSpacing,       // float
185 	ImGuiStyleVar_GrabMinSize          // float
186 }
187 
188 enum
189 {
190     ImGuiAlign_Left     = 1 << 0,
191     ImGuiAlign_Center   = 1 << 1,
192     ImGuiAlign_Right    = 1 << 2,
193     ImGuiAlign_Top      = 1 << 3,
194     ImGuiAlign_VCenter  = 1 << 4,
195     ImGuiAlign_Default  = ImGuiAlign_Left | ImGuiAlign_Top,
196 }
197 
198 enum
199 {
200 	ImGuiColorEditMode_UserSelect = -2,
201 	ImGuiColorEditMode_UserSelectShowButton = -1,
202 	ImGuiColorEditMode_RGB = 0,
203 	ImGuiColorEditMode_HSV = 1,
204 	ImGuiColorEditMode_HEX = 2
205 }
206 
207 enum
208 {
209 	ImGuiMouseCursor_Arrow = 0,
210 	ImGuiMouseCursor_TextInput,         // When hovering over InputText, etc.
211 	ImGuiMouseCursor_Move,              // Unused
212 	ImGuiMouseCursor_ResizeNS,          // Unused
213 	ImGuiMouseCursor_ResizeEW,          // When hovering over a column
214 	ImGuiMouseCursor_ResizeNESW,        // Unused
215 	ImGuiMouseCursor_ResizeNWSE,        // When hovering over the bottom-right corner of a window
216 	ImGuiMouseCursor_Count_
217 }
218 
219 align(1) struct ImVec2
220 {
221 	float x=0;
222 	float y=0;
223 	ImVec2 opBinary(string op)(const auto ref ImVec2 other) const
224 	{
225 		return mixin("ImVec2(x"~op~"other.x,y"~op~"other.y)");
226 	}
227 }
228 
229 align(1) struct ImVec4
230 {
231 	float x=0;
232 	float y=0;
233 	float z=0;
234 	float w=0;
235 }
236 
237 //struct ImFont{}
238 //struct ImFontAtlas{}
239 //struct ImDrawList{}
240 //struct ImGuiStorage{}
241 align(1) struct ImFontAtlas
242 {
243 	void*                       TexID;              // User data to refer to the texture once it has been uploaded to user's graphic systems. It ia passed back to you during rendering.
244     ubyte*                      TexPixelsAlpha8;    // 1 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight
245     uint*         		        TexPixelsRGBA32;    // 4 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight * 4
246     int                         TexWidth;
247     int                         TexHeight;
248     ImVec2                      TexUvWhitePixel;    // Texture coordinates to a white pixel (part of the TexExtraData block)
249     ImVector!(ImFont*)          Fonts;
250     ImVector!(ImFontConfig)     ConfigData;         // Internal data
251 }
252 
253 align(1) struct ImFont
254 {
255     // Members: Settings
256     float                       FontSize;           // <user set>      // Height of characters, set during loading (don't change after loading)
257     float                       Scale;              // = 1.0f          // Base font scale, multiplied by the per-window font scale which you can adjust with SetFontScale()
258     ImVec2                      DisplayOffset;      // = (0.0f,0.0f)   // Offset font rendering by xx pixels
259     ImWchar                     FallbackChar;       // = '?'           // Replacement glyph if one isn't found. Only set via SetFallbackChar()
260     ImFontConfig*               ConfigData;         //                 // Pointer within ImFontAtlas->ConfigData
261     int                         ConfigDataCount;    //
262 
263     // Members: Runtime data
264     align(1) static struct Glyph
265     {
266         ImWchar                 Codepoint;
267         float                   XAdvance;
268         float                   X0, Y0, X1, Y1;
269         float                   U0, V0, U1, V1;     // Texture coordinates
270     };
271     float                       Ascent, Descent;    // Ascent: distance from top to bottom of e.g. 'A' [0..FontSize]
272     ImFontAtlas*                ContainerAtlas;     // What we has been loaded into
273     ImVector!Glyph              Glyphs;
274     const Glyph*                FallbackGlyph;      // == FindGlyph(FontFallbackChar)
275     float                       FallbackXAdvance;   //
276     ImVector!float              IndexXAdvance;      // Sparse. Glyphs->XAdvance directly indexable (for CalcTextSize functions which are often bottleneck in large UI)
277     ImVector!int                IndexLookup;        // Sparse. Index glyphs by Unicode code-point
278 }
279 
280 align(1) struct ImDrawList
281 {
282     // This is what you have to render
283     ImVector!ImDrawCmd      CmdBuffer;          // Commands. Typically 1 command = 1 gpu draw call.
284     ImVector!ImDrawIdx      IdxBuffer;          // Index buffer. Each command consume ImDrawCmd::ElemCount of those
285     ImVector!ImDrawVert     VtxBuffer;          // Vertex buffer.
286 
287     // [Internal, used while building lists]
288     const char*             _OwnerName;         // Pointer to owner window's name (if any) for debugging
289     uint          		    _VtxCurrentIdx;     // [Internal] == VtxBuffer.Size
290     ImDrawVert*             _VtxWritePtr;       // [Internal] point within VtxBuffer.Data after each add command (to avoid using the ImVector<> operators too much)
291     ImDrawIdx*              _IdxWritePtr;       // [Internal] point within IdxBuffer.Data after each add command (to avoid using the ImVector<> operators too much)
292     ImVector!ImVec4         _ClipRectStack;     // [Internal]
293     ImVector!ImTextureID    _TextureIdStack;    // [Internal]
294     ImVector!ImVec2         _Path;              // [Internal] current path building
295     int                     _ChannelsCurrent;   // [Internal] current channel number (0)
296     int                     _ChannelsCount;     // [Internal] number of active channels (1+)
297     ImVector!ImDrawChannel  _Channels;          // [Internal] draw channels for columns API (not resized down so _ChannelsCount may be smaller than _Channels.Size)
298 }
299 
300 align(1) struct ImGuiStorage
301 {
302     align(1) static struct Pair
303     {
304         ImGuiID key;
305         union { int val_i; float val_f; void* val_p; };
306     };
307     ImVector!Pair    Data;
308 }
309 
310 align(1) struct ImDrawChannel
311 {
312     ImVector!ImDrawCmd CmdBuffer;
313     ImVector!ImDrawIdx IdxBuffer;
314 }
315 
316 alias uint ImU32;
317 alias ushort ImWchar;     // character for display
318 alias void* ImTextureID;          // user data to refer to a texture (e.g. store your texture handle/id)
319 alias ImU32 ImGuiID;              // unique ID used by widgets (typically hashed from a stack of string)
320 alias int ImGuiCol;               // enum ImGuiCol_
321 alias int ImGuiStyleVar;          // enum ImGuiStyleVar_
322 alias int ImGuiKey;               // enum ImGuiKey_
323 alias int ImGuiAlign;             // enum ImGuiAlign_
324 alias int ImGuiColorEditMode;     // enum ImGuiColorEditMode_
325 alias int ImGuiMouseCursor;       // enum ImGuiMouseCursor_
326 alias int ImGuiWindowFlags;       // enum ImGuiWindowFlags_
327 alias int ImGuiSetCond;           // enum ImGuiSetCond_
328 alias int ImGuiInputTextFlags;    // enum ImGuiInputTextFlags_
329 alias int ImGuiSelectableFlags;   // enum ImGuiSelectableFlags_
330 alias int function(ImGuiTextEditCallbackData *data) ImGuiTextEditCallback;
331 
332 extern(C) nothrow {
333     alias RenderDrawListFunc = void function(ImDrawData* data);
334     alias GetClipboardTextFunc = const(char)* function();
335     alias SetClipboardTextFunc = void function(const(char)*);
336     alias MemAllocFunc = void* function(size_t);
337     alias MemFreeFunc = void function(void*);
338     alias ImeSetInputScreenPosFunc = void function(int,int);
339 }
340 
341 // Shared state of InputText(), passed to callback when a ImGuiInputTextFlags_Callback* flag is used.
342 align(1) struct ImGuiTextEditCallbackData
343 {
344     ImGuiInputTextFlags EventFlag;      // One of ImGuiInputTextFlags_Callback* // Read-only
345     ImGuiInputTextFlags Flags;          // What user passed to InputText()      // Read-only
346     void*               UserData;       // What user passed to InputText()      // Read-only
347 
348     // CharFilter event:
349     ImWchar             EventChar;      // Character input                      // Read-write (replace character or set to zero)
350 
351     // Completion,History,Always events:
352     ImGuiKey            EventKey;       // Key pressed (Up/Down/TAB)            // Read-only
353     char*               Buf;            // Current text                         // Read-write (pointed data only)
354     size_t              BufSize;        //                                      // Read-only
355     bool                BufDirty;       // Set if you modify Buf directly       // Write
356     int                 CursorPos;      //                                      // Read-write
357     int                 SelectionStart; //                                      // Read-write (== to SelectionEnd when no selection)
358     int                 SelectionEnd;   //                                      // Read-write
359 
360     // NB: calling those function loses selection.
361     //void DeleteChars(int pos, int bytes_count);
362     //void InsertChars(int pos, const char* text, const char* text_end = NULL);
363 };
364 
365 align(1) struct ImGuiIO
366 {
367 	ImVec2        DisplaySize;              // <unset>              // Display size, in pixels. For clamping windows positions.
368 	float         DeltaTime;                // = 1.0f/60.0f         // Time elapsed since last frame, in seconds.
369 	float         IniSavingRate;            // = 5.0f               // Maximum time between saving positions/sizes to .ini file, in seconds.
370 	const char*   IniFilename;              // = "imgui.ini"        // Path to .ini file. NULL to disable .ini saving.
371 	const char*   LogFilename;              // = "imgui_log.txt"    // Path to .log file (default parameter to ImGui::LogToFile when no file is specified).
372 	float         MouseDoubleClickTime;     // = 0.30f              // Time for a double-click, in seconds.
373 	float         MouseDoubleClickMaxDist;  // = 6.0f               // Distance threshold to stay in to validate a double-click, in pixels.
374 	float         MouseDragThreshold;       // = 6.0f               // Distance threshold before considering we are dragging
375 	int[ImGuiKey_COUNT]           KeyMap;   // <unset>              // Map of indices into the KeysDown[512] entries array
376     float         KeyRepeatDelay;           // = 0.250f             // When holding a key/button, time before it starts repeating, in seconds. (for actions where 'repeat' is active)
377     float         KeyRepeatRate;            // = 0.020f             // When holding a key/button, rate at which it repeats, in seconds.
378 	void*         UserData;                 // = NULL               // Store your own data for retrieval by callbacks.
379 
380 	ImFontAtlas*  Fonts;                    // <auto>               // Load and assemble one or more fonts into a single tightly packed texture. Output to Fonts array.
381 	float         FontGlobalScale;          // = 1.0f               // Global scale all fonts
382 	bool          FontAllowUserScaling;     // = false              // Allow user scaling text of individual window with CTRL+Wheel.
383     ImVec2        DisplayFramebufferScale;  // = (1.0f,1.0f)        // For retina display or other situations where window coordinates are different from framebuffer coordinates. User storage only, presently not used by ImGui.
384 	ImVec2        DisplayVisibleMin;        // <unset> (0.0f,0.0f)  // If you use DisplaySize as a virtual space larger than your screen, set DisplayVisibleMin/Max to the visible area.
385 	ImVec2        DisplayVisibleMax;        // <unset> (0.0f,0.0f)  // If the values are the same, we defaults to Min=(0.0f) and Max=DisplaySize
386 
387 	//------------------------------------------------------------------
388 	// User Functions
389 	//------------------------------------------------------------------
390 
391 	// REQUIRED: rendering function.
392 	// See example code if you are unsure of how to implement this.
393     RenderDrawListFunc RenderDrawListsFn;
394 
395 	// Optional: access OS clipboard
396 	// (default to use native Win32 clipboard on Windows, otherwise uses a private clipboard. Override to access OS clipboard on other architectures)
397     GetClipboardTextFunc GetClipboardTextFn;
398     SetClipboardTextFunc SetClipboardTextFn;
399 
400 	// Optional: override memory allocations. MemFreeFn() may be called with a NULL pointer.
401 	// (default to posix malloc/free)
402 	MemAllocFunc MemAllocFn;
403     MemFreeFunc MemFreeFn;
404 
405 	// Optional: notify OS Input Method Editor of the screen position of your cursor for text input position (e.g. when using Japanese/Chinese IME in Windows)
406 	// (default to use native imm32 api on Windows)
407     ImeSetInputScreenPosFunc ImeSetInputScreenPosFn;
408 	void*       ImeWindowHandle;            // (Windows) Set this to your HWND to get automatic IME cursor positioning.
409 
410 	//------------------------------------------------------------------
411 	// Input - Fill before calling NewFrame()
412 	//------------------------------------------------------------------
413 
414 	ImVec2      	MousePos;                   // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
415 	bool[5]     	MouseDown;        		    // Mouse buttons. ImGui itself only uses button 0 (left button). Others buttons allows to track if mouse is being used by your application + available to user as a convenience via IsMouse** API.
416 	float       	MouseWheel;                 // Mouse wheel: 1 unit scrolls about 5 lines text.
417 	bool        	MouseDrawCursor;            // Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor).
418 	bool        	KeyCtrl;                    // Keyboard modifier pressed: Control
419 	bool        	KeyShift;                   // Keyboard modifier pressed: Shift
420 	bool        	KeyAlt;                     // Keyboard modifier pressed: Alt
421 	bool[512]   	KeysDown;              // Keyboard keys that are pressed (in whatever storage order you naturally have access to keyboard data)
422 	ImWchar[16+1]   InputCharacters;      // List of characters input (translated by user from keypress+keyboard state). Fill using AddInputCharacter() helper.
423 
424 	//------------------------------------------------------------------
425 	// Output - Retrieve after calling NewFrame(), you can use them to discard inputs or hide them from the rest of your application
426 	//------------------------------------------------------------------
427 
428 	bool        WantCaptureMouse;           // Mouse is hovering a window or widget is active (= ImGui will use your mouse input)
429 	bool        WantCaptureKeyboard;        // Widget is active (= ImGui will use your keyboard input)
430     bool        WantTextInput;              // Some text input widget is active, which will read input characters from the InputCharacters array.
431 	float       Framerate;                  // Framerate estimation, in frame per second. Rolling average estimation based on IO.DeltaTime over 120 frames
432     int         MetricsAllocs;              // Number of active memory allocations
433     int         MetricsRenderVertices;      // Vertices processed during last call to Render()
434     int         MetricsRenderIndices;       //
435     int         MetricsActiveWindows;       // Number of visible windows (exclude child windows)
436 
437 	//------------------------------------------------------------------
438 	// [Internal] ImGui will maintain those fields for you
439 	//------------------------------------------------------------------
440 
441 	ImVec2      MousePosPrev;               // Previous mouse position
442 	ImVec2      MouseDelta;                 // Mouse delta. Note that this is zero if either current or previous position are negative to allow mouse enabling/disabling.
443 	bool[5]     MouseClicked;            // Mouse button went from !Down to Down
444 	ImVec2[5]   MouseClickedPos;         // Position at time of clicking
445 	float[5]    MouseClickedTime;        // Time of last click (used to figure out double-click)
446 	bool[5]     MouseDoubleClicked;      // Has mouse button been double-clicked?
447     bool[5]     MouseReleased;           // Mouse button went from Down to !Down
448 	bool[5]     MouseDownOwned;          // Track if button was clicked inside a window. We don't request mouse capture from the application if click started outside ImGui bounds.
449     float[5]    MouseDownDuration;       // Duration the mouse button has been down (0.0f == just clicked)
450     float[5]    MouseDownDurationPrev;   // Previous time the mouse button has been down
451 	float[5]    MouseDragMaxDistanceSqr; // Squared maximum distance of how much mouse has traveled from the click point
452     float[512]  KeysDownDuration;      // Duration the keyboard key has been down (0.0f == just pressed)
453     float[512]  KeysDownDurationPrev;  // Previous duration the key has been down
454 }
455 
456 align(1) struct ImGuiStyle
457 {
458     float       Alpha;                      // Global alpha applies to everything in ImGui
459     ImVec2      WindowPadding;              // Padding within a window
460     ImVec2      WindowMinSize;              // Minimum window size
461     float       WindowRounding;             // Radius of window corners rounding. Set to 0.0f to have rectangular windows
462     ImGuiAlign  WindowTitleAlign;           // Alignment for title bar text
463     float       ChildWindowRounding;        // Radius of child window corners rounding. Set to 0.0f to have rectangular windows
464     ImVec2      FramePadding;               // Padding within a framed rectangle (used by most widgets)
465     float       FrameRounding;              // Radius of frame corners rounding. Set to 0.0f to have rectangular frame (used by most widgets).
466     ImVec2      ItemSpacing;                // Horizontal and vertical spacing between widgets/lines
467     ImVec2      ItemInnerSpacing;           // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label)
468     ImVec2      TouchExtraPadding;          // Expand reactive bounding box for touch-based system where touch position is not accurate enough. Unfortunately we don't sort widgets so priority on overlap will always be given to the first widget. So don't grow this too much!
469     float       WindowFillAlphaDefault;     // Default alpha of window background, if not specified in ImGui::Begin()
470     float       IndentSpacing;              // Horizontal indentation when e.g. entering a tree node
471     float       ColumnsMinSpacing;          // Minimum horizontal spacing between two columns
472     float       ScrollbarSize;             // Width of the vertical scrollbar
473     float       ScrollbarRounding;          // Radius of grab corners for scrollbar
474     float       GrabMinSize;                // Minimum width/height of a grab box for slider/scrollbar
475     float       GrabRounding;               // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
476     ImVec2      DisplayWindowPadding;       // Window positions are clamped to be visible within the display area by at least this amount. Only covers regular windows.
477     ImVec2      DisplaySafeAreaPadding;     // If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. Covers popups/tooltips as well regular windows.
478     bool        AntiAliasedLines;           // Enable anti-aliasing on lines/borders. Disable if you are really tight on CPU/GPU.
479     bool        AntiAliasedShapes;          // Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.)
480     float       CurveTessellationTol;       // Tessellation tolerance. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
481     ImVec4[ImGuiCol_COUNT]      Colors;
482 };
483 
484 align(1) struct ImDrawVert
485 {
486 	ImVec2  pos;
487 	ImVec2  uv;
488 	ImU32   col;
489 };
490 
491 alias ImDrawCallback = void function(const ImDrawList* parent_list, const ImDrawCmd* cmd) nothrow;
492 
493 align(1) struct ImDrawCmd
494 {
495     uint            ElemCount;              // Number of indices (multiple of 3) to be rendered as triangles. Vertices are stored in the callee ImDrawList's vtx_buffer[] array, indices in idx_buffer[].
496     ImVec4          ClipRect;               // Clipping rectangle (x1, y1, x2, y2)
497     ImTextureID     TextureId;              // User-provided texture ID. Set by user in ImfontAtlas::SetTexID() for fonts or passed to Image*() functions. Ignore if never using images or multiple fonts atlas.
498     ImDrawCallback  UserCallback;           // If != NULL, call the function instead of rendering the vertices. clip_rect and texture_id will be set normally.
499     void*           UserCallbackData;       // The draw callback code can access this.
500 }
501 
502 alias ImDrawIdx = ushort;
503 
504 align(1) struct ImDrawData
505 {
506     bool            Valid;
507     ImDrawList**    CmdLists;
508     int             CmdListsCount;
509     int             TotalVtxCount;          // For convenience, sum of all cmd_lists vtx_buffer.Size
510     int             TotalIdxCount;          // For convenience, sum of all cmd_lists idx_buffer.Size
511 }
512 
513 align(1) struct ImFontConfig
514 {
515     void*           FontData;
516     int             FontDataSize;
517     bool            FontDataOwnedByAtlas=true;
518     int             FontNo=0;
519     float           SizePixels=0.0f;
520     int             OversampleH=3, OversampleV=1;
521     bool            PixelSnapH=false;
522     ImVec2          GlyphExtraSpacing;
523     const ImWchar*  GlyphRanges;
524     bool            MergeMode=false;
525     bool            MergeGlyphCenterV=false;
526 
527     // [Internal]
528     char[32]        Name;
529     ImFont*         DstFont;
530 }
531 
532 align(1) struct ImColor
533 {
534     ImU32 value;
535     alias value this;
536 
537     this(ubyte r, ubyte g, ubyte b, ubyte a = 255)
538     {
539         value = r | (g<<8) | (b<<16) | (a<<24);
540     }
541 
542     this(float r, float g, float b, float a = 1.0f)
543     {
544     	static float imSaturate(float f)
545 		{
546 		    return (f < 0.0f) ? 0.0f : (f > 1.0f) ? 1.0f : f;
547 		}
548         value  = (cast(ImU32)(imSaturate(r)*255));
549         value |= (cast(ImU32)(imSaturate(g)*255) << 8);
550         value |= (cast(ImU32)(imSaturate(b)*255) << 16);
551         value |= (cast(ImU32)(imSaturate(a)*255) << 24);
552     }
553 
554     ImVec4 asImVec4() @property
555     {
556 	    float s = 1.0f/255.0f;
557 	    return ImVec4((value & 0xFF) * s, ((value >> 8) & 0xFF) * s, ((value >> 16) & 0xFF) * s, (value >> 24) * s);
558     }
559 }
560 
561 alias ImGuiPlotType = int;
562 enum
563 {
564     ImGuiPlotType_Lines,
565     ImGuiPlotType_Histogram
566 }
567 
568 alias ImGuiLayoutType = int;
569 enum
570 {
571     ImGuiLayoutType_Vertical,
572     ImGuiLayoutType_Horizontal
573 }
574 
575 align(1) struct ImRect
576 {
577     ImVec2          Min;    // Upper-left
578     ImVec2          Max;    // Lower-right
579     float width() const @property
580     {
581     	return Max.x - Min.x;
582     }
583 
584     float height() const @property
585     {
586     	return Max.y - Min.y;
587     }
588 
589     bool contains(ImVec2 vec) const {
590     	return vec.x >= Min.x && vec.x <= Max.x &&
591 			vec.y >= Min.y && vec.y <= Max.y;
592     }
593 }
594 
595 align(1) struct ImVector(T)
596 {
597     int                         Size;
598     int                         Capacity;
599     T*                       Data;
600 }
601 
602 struct ImGuiDrawContext
603 {
604     ImVec2                  CursorPos;
605     ImVec2                  CursorPosPrevLine;
606     ImVec2                  CursorStartPos;
607     ImVec2                  CursorMaxPos;           // Implicitly calculate the size of our contents, always extending. Saved into window->SizeContents at the end of the frame
608     float                   CurrentLineHeight;
609     float                   CurrentLineTextBaseOffset;
610     float                   PrevLineHeight;
611     float                   PrevLineTextBaseOffset;
612     float                   LogLinePosY;
613     int                     TreeDepth;
614     ImGuiID                 LastItemID;
615     ImRect                  LastItemRect;
616     bool                    LastItemHoveredAndUsable;
617     bool                    LastItemHoveredRect;
618     bool                    MenuBarAppending;
619     float                   MenuBarOffsetX;
620     ImVector!(ImGuiWindow*)  ChildWindows;
621     ImGuiStorage*           StateStorage;
622     ImGuiLayoutType         LayoutType;
623 
624     // We store the current settings outside of the vectors to increase memory locality (reduce cache misses). The vectors are rarely modified. Also it allows us to not heap allocate for short-lived windows which are not using those settings.
625     bool                    ButtonRepeat;           // == ButtonRepeatStack.back() [empty == false]
626     bool                    AllowKeyboardFocus;     // == AllowKeyboardFocusStack.back() [empty == true]
627     float                   ItemWidth;              // == ItemWidthStack.back(). 0.0: default, >0.0: width in pixels, <0.0: align xx pixels to the right of window
628     float                   TextWrapPos;            // == TextWrapPosStack.back() [empty == -1.0f]
629     ImVector!(bool)          ButtonRepeatStack;
630     ImVector!(bool)          AllowKeyboardFocusStack;
631     ImVector!(float)         ItemWidthStack;
632     ImVector!(float)         TextWrapPosStack;
633     ImVector!(ImGuiGroupData)GroupStack;
634     ImGuiColorEditMode      ColorEditMode;
635     int[6]                  StackSizesBackup;    // Store size of various stacks for asserting
636 
637     float                   ColumnsStartX;          // Indentation / start position from left of window (increased by TreePush/TreePop, etc.)
638     float                   ColumnsOffsetX;         // Offset to the current column (if ColumnsCurrent > 0). FIXME: This and the above should be a stack to allow use cases like Tree->Column->Tree. Need revamp columns API.
639     int                     ColumnsCurrent;
640     int                     ColumnsCount;
641     ImVec2                  ColumnsStartPos;
642     float                   ColumnsCellMinY;
643     float                   ColumnsCellMaxY;
644     bool                    ColumnsShowBorders;
645     ImGuiID                 ColumnsSetID;
646     ImVector!(float)         ColumnsOffsetsT;        // Columns offset normalized 0.0 (far left) -> 1.0 (far right)
647 }
648 
649 align(1) struct ImGuiWindow
650 {
651     char*                   Name;
652     ImGuiID                 ID;
653     ImGuiWindowFlags        Flags;
654     ImVec2                  PosFloat;
655     ImVec2                  Pos;                                // Position rounded-up to nearest pixel
656     ImVec2                  Size;                               // Current size (==SizeFull or collapsed title bar size)
657     ImVec2                  SizeFull;                           // Size when non collapsed
658     ImVec2                  SizeContents;                       // Size of contents (== extents reach of the drawing cursor) from previous frame
659     ImVec2                  SizeContentsExplicit;               // Size of contents explicitly set by the user via SetNextWindowContentSize()
660     ImVec2                  WindowPadding;                      // Window padding at the time of begin. We need to lock it, in particular manipulation of the ShowBorder would have an effect
661     ImGuiID                 MoveID;                             // == window->GetID("#MOVE")
662     ImVec2                  Scroll;
663     ImVec2                  ScrollTarget;                       // target scroll position. stored as cursor position with scrolling canceled out, so the highest point is always 0.0f. (FLT_MAX for no change)
664     ImVec2                  ScrollTargetCenterRatio;            // 0.0f = scroll so that target position is at top, 0.5f = scroll so that target position is centered
665     bool                    ScrollbarX, ScrollbarY;
666     ImVec2                  ScrollbarSizes;                     //
667     bool                    Active;                             // Set to true on Begin()
668     bool                    WasActive;
669     bool                    Accessed;                           // Set to true when any widget access the current window
670     bool                    Collapsed;                          // Set when collapsing window to become only title-bar
671     bool                    SkipItems;                          // == Visible && !Collapsed
672     int                     BeginCount;                         // Number of Begin() during the current frame (generally 0 or 1, 1+ if appending via multiple Begin/End pairs)
673     ImGuiID                 PopupID;                            // ID in the popup stack when this window is used as a popup/menu (because we use generic Name/ID for recycling)
674     int                     AutoFitFramesX, AutoFitFramesY;
675     bool                    AutoFitOnlyGrows;
676     int                     AutoPosLastDirection;
677     int                     HiddenFrames;
678     int                     SetWindowPosAllowFlags;             // bit ImGuiSetCond_*** specify if SetWindowPos() call will succeed with this particular flag.
679     int                     SetWindowSizeAllowFlags;            // bit ImGuiSetCond_*** specify if SetWindowSize() call will succeed with this particular flag.
680     int                     SetWindowCollapsedAllowFlags;       // bit ImGuiSetCond_*** specify if SetWindowCollapsed() call will succeed with this particular flag.
681     bool                    SetWindowPosCenterWanted;
682 
683     ImGuiDrawContext        DC;                                 // Temporary per-window data, reset at the beginning of the frame
684     ImVector!(ImGuiID)   	IDStack;                            // ID stack. ID are hashes seeded with the value at the top of the stack
685     ImRect                  ClipRect;                           // = DrawList->clip_rect_stack.back(). Scissoring / clipping rectangle. x1, y1, x2, y2.
686     ImRect                  ClippedWindowRect;                  // = ClipRect just after setup in Begin()
687     int                     LastFrameDrawn;
688     float                   ItemWidthDefault;
689     ImGuiSimpleColumns      MenuColumns;                        // Simplified columns storage for menu items
690     ImGuiStorage            StateStorage;
691     float                   FontWindowScale;                    // Scale multiplier per-window
692     ImDrawList*             DrawList;
693     ImGuiWindow*            RootWindow;
694     ImGuiWindow*            RootNonPopupWindow;
695 
696     // Focus
697     int                     FocusIdxAllCounter;                 // Start at -1 and increase as assigned via FocusItemRegister()
698     int                     FocusIdxTabCounter;                 // (same, but only count widgets which you can Tab through)
699     int                     FocusIdxAllRequestCurrent;          // Item being requested for focus
700     int                     FocusIdxTabRequestCurrent;          // Tab-able item being requested for focus
701     int                     FocusIdxAllRequestNext;             // Item being requested for focus, for next update (relies on layout to be stable between the frame pressing TAB and the next frame)
702     int                     FocusIdxTabRequestNext;             // "
703 }
704 
705 align(1) struct ImGuiGroupData
706 {
707     ImVec2          BackupCursorPos;
708     ImVec2          BackupCursorMaxPos;
709     float           BackupColumnsStartX;
710     float           BackupCurrentLineHeight;
711     float           BackupCurrentLineTextBaseOffset;
712     float           BackupLogLinePosY;
713     bool            AdvanceCursor;
714 }
715 
716 align(1) struct ImGuiSimpleColumns
717 {
718     int             Count;
719     float           Spacing;
720     float           Width, NextWidth;
721     float[8]        Pos, NextWidths;
722 }
723 
724 alias ImGuiButtonFlags = int;
725 enum
726 {
727     ImGuiButtonFlags_Repeat             = 1 << 0,
728     ImGuiButtonFlags_PressedOnClick     = 1 << 1,   // return pressed on click only (default requires click+release)
729     ImGuiButtonFlags_PressedOnRelease   = 1 << 2,   // return pressed on release only (default requires click+release)
730     ImGuiButtonFlags_FlattenChilds      = 1 << 3,
731     ImGuiButtonFlags_DontClosePopups    = 1 << 4,
732     ImGuiButtonFlags_Disabled           = 1 << 5,
733     ImGuiButtonFlags_AlignTextBaseLine  = 1 << 6
734 };
735 
736 alias ImGuiTreeNodeFlags = int;
737 enum
738 {
739     ImGuiTreeNodeFlags_DefaultOpen          = 1 << 0,
740     ImGuiTreeNodeFlags_NoAutoExpandOnLog    = 1 << 1
741 };
742 
743 // Main state for ImGui
744 align(1) struct ImGuiState
745 {
746     bool                    Initialized;
747     ImGuiIO                 IO;
748     ImGuiStyle              Style;
749     ImFont*                 Font;                               // (Shortcut) == FontStack.empty() ? IO.Font : FontStack.back()
750     float                   FontSize;                           // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize()
751     float                   FontBaseSize;                       // (Shortcut) == IO.FontGlobalScale * Font->Scale * Font->FontSize. Size of characters.
752     ImVec2                  FontTexUvWhitePixel;                // (Shortcut) == Font->TexUvForWhite
753 
754     float                   Time;
755     int                     FrameCount;
756     int                     FrameCountRendered;
757     ImVector!(ImGuiWindow*) Windows;
758     ImVector!(ImGuiWindow*) WindowsSortBuffer;
759     ImGuiWindow*            CurrentWindow;                      // Being drawn into
760     ImVector!(ImGuiWindow*) CurrentWindowStack;
761     ImGuiWindow*            FocusedWindow;                      // Will catch keyboard inputs
762     ImGuiWindow*            HoveredWindow;                      // Will catch mouse inputs
763     ImGuiWindow*            HoveredRootWindow;                  // Will catch mouse inputs (for focus/move only)
764     ImGuiID                 HoveredId;                          // Hovered widget
765     ImGuiID                 HoveredIdPreviousFrame;
766     ImGuiID                 ActiveId;                           // Active widget
767     ImGuiID                 ActiveIdPreviousFrame;
768     bool                    ActiveIdIsAlive;
769     bool                    ActiveIdIsJustActivated;            // Set at the time of activation for one frame
770     bool                    ActiveIdIsFocusedOnly;              // Set only by active widget. Denote focus but no active interaction
771     ImGuiWindow*            ActiveIdWindow;
772     ImGuiWindow*            MovedWindow;                        // Track the child window we clicked on to move a window. Pointer is only valid if ActiveID is the "#MOVE" identifier of a window.
773     ImVector!(ImGuiIniData) Settings;                           // .ini Settings
774     float                   SettingsDirtyTimer;                 // Save .ini settinngs on disk when time reaches zero
775     int                     DisableHideTextAfterDoubleHash;
776     ImVector!(ImGuiColMod)   ColorModifiers;                     // Stack for PushStyleColor()/PopStyleColor()
777     ImVector!(ImGuiStyleMod) StyleModifiers;                     // Stack for PushStyleVar()/PopStyleVar()
778     ImVector!(ImFont*)       FontStack;                          // Stack for PushFont()/PopFont()
779     ImVector!(ImGuiPopupRef) OpenedPopupStack;                   // Which popups are open (persistent)
780     ImVector!(ImGuiPopupRef) CurrentPopupStack;                  // Which level of BeginPopup() we are in (reset every frame)
781 
782     // Storage for SetNexWindow** and SetNextTreeNode*** functions
783     ImVec2                  SetNextWindowPosVal;
784     ImVec2                  SetNextWindowSizeVal;
785     ImVec2                  SetNextWindowContentSizeVal;
786     bool                    SetNextWindowCollapsedVal;
787     ImGuiSetCond            SetNextWindowPosCond;
788     ImGuiSetCond            SetNextWindowSizeCond;
789     ImGuiSetCond            SetNextWindowContentSizeCond;
790     ImGuiSetCond            SetNextWindowCollapsedCond;
791     bool                    SetNextWindowFocus;
792     bool                    SetNextTreeNodeOpenedVal;
793     ImGuiSetCond            SetNextTreeNodeOpenedCond;
794 
795     // Render
796     ImVector!(ImDrawList*)[3] RenderDrawLists;
797     float                   ModalWindowDarkeningRatio;
798     ImDrawList              OverlayDrawList;                    // Optional software render of mouse cursors, if io.MouseDrawCursor is set + a few debug overlays
799     ImGuiMouseCursor        MouseCursor;
800     ImGuiMouseCursorData[ImGuiMouseCursor_Count_]    MouseCursorData;
801 
802     // Widget state
803     ImGuiTextEditState      InputTextState;
804     ImGuiID                 ScalarAsInputTextId;                // Temporary text input when CTRL+clicking on a slider, etc.
805     ImGuiStorage            ColorEditModeStorage;               // Store user selection of color edit mode
806     ImVec2                  ActiveClickDeltaToCenter;
807     float                   DragCurrentValue;                   // Currently dragged value, always float, not rounded by end-user precision settings
808     ImVec2                  DragLastMouseDelta;
809     float                   DragSpeedDefaultRatio;              // If speed == 0.0f, uses (max-min) * DragSpeedDefaultRatio
810     float                   DragSpeedScaleSlow;
811     float                   DragSpeedScaleFast;
812     ImVec2                  ScrollbarClickDeltaToGrabCenter;   // Distance between mouse and center of grab box, normalized in parent space. Use storage?
813     char[1024]              Tooltip;
814     char*                   PrivateClipboard;                   // If no custom clipboard handler is defined
815 
816     import std.stdio : FILE;
817     // Logging
818     bool                    LogEnabled;
819     FILE*                   LogFile;                            // If != NULL log to stdout/ file
820     ImGuiTextBuffer*        LogClipboard;                       // Else log to clipboard. This is pointer so our GImGui static constructor doesn't call heap allocators.
821     int                     LogStartDepth;
822     int                     LogAutoExpandMaxDepth;
823 
824     // Misc
825     float[120]              FramerateSecPerFrame;          // calculate estimate of framerate for user
826     int                     FramerateSecPerFrameIdx;
827     float                   FramerateSecPerFrameAccum;
828     bool                    CaptureMouseNextFrame;              // explicit capture via CaptureInputs() sets those flags
829     bool                    CaptureKeyboardNextFrame;
830     char[1024*3+1]          TempBuffer;               // temporary text buffer
831 }
832 
833 align(1) struct ImGuiIniData
834 {
835     char*               Name;
836     ImGuiID             ID;
837     ImVec2              Pos;
838     ImVec2              Size;
839     bool                Collapsed;
840 }
841 
842 align(1) struct ImGuiColMod
843 {
844     ImGuiCol        Col;
845     ImVec4          PreviousValue;
846 }
847 
848 align(1) struct ImGuiStyleMod
849 {
850     ImGuiStyleVar   Var;
851     ImVec2          PreviousValue;
852 }
853 
854 align(1) struct ImGuiPopupRef
855 {
856     ImGuiID             PopupID;        // Set on OpenPopup()
857     ImGuiWindow*        Window;         // Resolved on BeginPopup() - may stay unresolved if user never calls OpenPopup()
858     ImGuiWindow*        ParentWindow;   // Set on OpenPopup()
859     ImGuiID             ParentMenuSet;  // Set on OpenPopup()
860     ImVec2              MousePosOnOpen; // Copy of mouse position at the time of opening popup
861 }
862 
863 // Mouse cursor data (used when io.MouseDrawCursor is set)
864 align(1) struct ImGuiMouseCursorData
865 {
866     ImGuiMouseCursor    Type;
867     ImVec2              HotOffset;
868     ImVec2              Size;
869     ImVec2[2]           TexUvMin;
870     ImVec2[2]           TexUvMax;
871 }
872 
873 // Helper: Text buffer for logging/accumulating text
874 align(1) struct ImGuiTextBuffer
875 {
876     ImVector!char Buf;
877 }
878 
879 align(1) struct ImGuiTextEditState
880 {
881     ImGuiID             Id;                             // widget id owning the text state
882     ImVector!ImWchar   Text;                           // edit buffer, we need to persist but can't guarantee the persistence of the user-provided buffer. so we copy into own buffer.
883     ImVector!char      InitialText;                    // backup of end-user buffer at the time of focus (in UTF-8, unaltered)
884     ImVector!char      TempTextBuffer;
885     int                 CurLenA, CurLenW;               // we need to maintain our buffer length in both UTF-8 and wchar format.
886     int                 BufSizeA;                       // end-user buffer size
887     float               ScrollX;
888     STB_TexteditState   StbState;
889     float               CursorAnim;
890     bool                CursorFollow;
891     ImVec2              InputCursorScreenPos;           // Cursor position in screen space to be used by IME callback.
892     bool                SelectedAllMouseLock;
893 }
894 
895 align(1) struct STB_TexteditState
896 {
897    int cursor;
898    int select_start;
899    int select_end;
900    ubyte insert_mode;
901    ubyte cursor_at_end_of_line; // not implemented yet
902    ubyte initialized;
903    ubyte has_preferred_x;
904    ubyte single_line;
905    ubyte padding1, padding2, padding3;
906    float preferred_x;
907    StbUndoState undostate;
908 }
909 
910 enum STB_TEXTEDIT_UNDOSTATECOUNT = 99;
911 enum STB_TEXTEDIT_UNDOCHARCOUNT = 999;
912 alias STB_TEXTEDIT_CHARTYPE = int;
913 alias STB_TEXTEDIT_POSITIONTYPE = int;
914 
915 align(1) struct StbUndoState
916 {
917    // private data
918    StbUndoRecord[STB_TEXTEDIT_UNDOSTATECOUNT]  undo_rec;
919    STB_TEXTEDIT_CHARTYPE[STB_TEXTEDIT_UNDOCHARCOUNT] undo_char;
920    short undo_point, redo_point;
921    short undo_char_point, redo_char_point;
922 }
923 
924 align(1) struct StbUndoRecord
925 {
926    // private data
927    STB_TEXTEDIT_POSITIONTYPE  where;
928    short           insert_length;
929    short           delete_length;
930    short           char_storage;
931 }