├── .gitignore ├── .gitmodules ├── examples ├── import.py └── minimal.py ├── pyimgui ├── __init__.py ├── cimgui.pxd └── imgui.pyx ├── readme.md ├── setup.py └── tests ├── test_import.py └── test_io.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.gitignore.io/api/python,c 2 | 3 | ### Python ### 4 | # Byte-compiled / optimized / DLL files 5 | __pycache__/ 6 | *.py[cod] 7 | *$py.class 8 | 9 | # C extensions 10 | *.so 11 | 12 | # Distribution / packaging 13 | .Python 14 | env/ 15 | build/ 16 | develop-eggs/ 17 | dist/ 18 | downloads/ 19 | eggs/ 20 | .eggs/ 21 | lib/ 22 | lib64/ 23 | parts/ 24 | sdist/ 25 | var/ 26 | *.egg-info/ 27 | .installed.cfg 28 | *.egg 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *,cover 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | 57 | # Sphinx documentation 58 | docs/_build/ 59 | 60 | # PyBuilder 61 | target/ 62 | 63 | 64 | ### C ### 65 | # Object files 66 | *.o 67 | *.ko 68 | *.obj 69 | *.elf 70 | 71 | # Precompiled Headers 72 | *.gch 73 | *.pch 74 | 75 | # Libraries 76 | *.lib 77 | *.a 78 | *.la 79 | *.lo 80 | 81 | # Shared objects (inc. Windows DLLs) 82 | *.dll 83 | *.so 84 | *.so.* 85 | *.dylib 86 | 87 | # Executables 88 | *.exe 89 | *.out 90 | *.app 91 | *.i*86 92 | *.x86_64 93 | *.hex 94 | 95 | # Debug files 96 | *.dSYM/ 97 | 98 | # Ignore generated cpp and *.c files 99 | *.cpp 100 | *.c 101 | 102 | # Cython files 103 | cython_debug 104 | 105 | # Imgui files 106 | imgui.ini 107 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "imgui"] 2 | path = imgui 3 | url = https://github.com/ocornut/imgui.git 4 | -------------------------------------------------------------------------------- /examples/import.py: -------------------------------------------------------------------------------- 1 | import imgui 2 | -------------------------------------------------------------------------------- /examples/minimal.py: -------------------------------------------------------------------------------- 1 | import imgui 2 | 3 | def my_render_function(): 4 | print 'foo' 5 | 6 | io = imgui.get_io() 7 | io.display_size = 1920.0, 1280.0 8 | io.render_draw_lists_fn = my_render_function 9 | io.fonts.add_font_default() 10 | io.fonts.get_tex_data_as_rgba32() 11 | 12 | 13 | ## Application main loop 14 | while True: 15 | io = imgui.get_io(); 16 | io.delta_time = 1.0/60.0; 17 | 18 | print 'Render' 19 | imgui.new_frame() 20 | imgui.begin("My window") 21 | imgui.text("Hello, world.") 22 | imgui.end() 23 | imgui.render() 24 | print '...done' 25 | #io.mouse_pos = mouse_pos; 26 | #io.mouse_down[0] = mouse_button_0; 27 | # io.KeysDown[i] = ... 28 | # 29 | # 30 | -------------------------------------------------------------------------------- /pyimgui/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chromy/cyimgui/fde850902855759c6128b083836183c9aa57d282/pyimgui/__init__.py -------------------------------------------------------------------------------- /pyimgui/cimgui.pxd: -------------------------------------------------------------------------------- 1 | # distutils: language = c++ 2 | # distutils: include_dirs = imgui 3 | from libcpp cimport bool 4 | 5 | cdef extern from "imgui.h": 6 | ctypedef struct ImVec2: 7 | float x; 8 | float y; 9 | 10 | ctypedef struct ImGuiIO: 11 | ImVec2 DisplaySize; 12 | float DeltaTime; 13 | float IniSavingRate; 14 | const char* IniFilename; 15 | const char* LogFilename; 16 | float MouseDoubleClickTime; 17 | float MouseDoubleClickMaxDist; 18 | float MouseDragThreshold; 19 | #int KeyMap[ImGuiKey_COUNT]; 20 | float KeyRepeatDelay; 21 | float KeyRepeatRate; 22 | #void* UserData; 23 | 24 | ImFontAtlas* Fonts; 25 | #float FontGlobalScale; 26 | #bool FontAllowUserScaling; 27 | #ImVec2 DisplayFramebufferScale; 28 | #ImVec2 DisplayVisibleMin; 29 | #ImVec2 DisplayVisibleMax; 30 | 31 | void (*RenderDrawListsFn)(ImDrawData* data); 32 | #const char* (*GetClipboardTextFn)(); 33 | #void (*SetClipboardTextFn)(const char* text); 34 | #void* (*MemAllocFn)(size_t sz); 35 | #void (*MemFreeFn)(void* ptr); 36 | #void (*ImeSetInputScreenPosFn)(int x, int y); 37 | #void* ImeWindowHandle; 38 | 39 | #ImVec2 MousePos; 40 | #bool MouseDown[5]; 41 | #float MouseWheel; 42 | #bool MouseDrawCursor; 43 | #bool KeyCtrl; 44 | #bool KeyShift; 45 | #bool KeyAlt; 46 | #bool KeysDown[512]; 47 | #ImWchar InputCharacters[16+1]; 48 | 49 | #void AddInputCharacter(ImWchar c); 50 | #void AddInputCharactersUTF8(const char* utf8_chars); 51 | 52 | #bool WantCaptureMouse; 53 | #bool WantCaptureKeyboard; 54 | #bool WantTextInput; 55 | #float Framerate; 56 | #int MetricsAllocs; 57 | #int MetricsRenderVertices; 58 | #int MetricsRenderIndices; 59 | #int MetricsActiveWindows; 60 | 61 | #ImVec2 MousePosPrev; 62 | #ImVec2 MouseDelta; 63 | #bool MouseClicked[5]; 64 | #ImVec2 MouseClickedPos[5]; 65 | #float MouseClickedTime[5]; 66 | #bool MouseDoubleClicked[5]; 67 | #bool MouseReleased[5]; 68 | #bool MouseDownOwned[5]; 69 | #float MouseDownDuration[5]; 70 | #float MouseDownDurationPrev[5]; 71 | #float MouseDragMaxDistanceSqr[5]; 72 | #float KeysDownDuration[512]; 73 | #float KeysDownDurationPrev[512]; 74 | 75 | ctypedef struct ImGuiStyle: 76 | pass 77 | ctypedef struct ImDrawCmd: 78 | pass 79 | ctypedef struct ImDrawList: 80 | pass 81 | ctypedef struct ImDrawData: 82 | bool Valid 83 | ImDrawList** CmdLists 84 | int CmdListsCount 85 | int TotalVtxCount 86 | int TotalIdxCount 87 | void DeIndexAllBuffers() 88 | void ScaleClipRects(const ImVec2& sc) 89 | 90 | ctypedef struct ImFontConfig: 91 | pass 92 | ctypedef struct ImFont: 93 | pass 94 | ctypedef struct ImFontAtlas: 95 | ImFont* AddFontDefault(const ImFontConfig* font_cfg = NULL); 96 | void GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL) 97 | void GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL) 98 | 99 | ctypedef struct ImGuiIO: 100 | pass 101 | ctypedef struct ImGuiStorage: 102 | pass 103 | ctypedef struct ImGuiStyle: 104 | pass 105 | 106 | ctypedef int ImGuiCol; 107 | ctypedef int ImGuiStyleVar; 108 | ctypedef int ImGuiKey; 109 | ctypedef int ImGuiAlign; 110 | ctypedef int ImGuiColorEditMode; 111 | ctypedef int ImGuiMouseCursor; 112 | ctypedef int ImGuiWindowFlags; 113 | ctypedef int ImGuiSetCond; 114 | ctypedef int ImGuiInputTextFlags; 115 | ctypedef int ImGuiSelectableFlags; 116 | 117 | cdef extern from "imgui.h" namespace "ImGui": 118 | # Main 119 | ImGuiIO& GetIO(); 120 | ImGuiStyle& GetStyle(); 121 | ImDrawData* GetDrawData(); 122 | void NewFrame(); 123 | void Render(); 124 | void Shutdown(); 125 | void ShowUserGuide(); 126 | void ShowStyleEditor(ImGuiStyle* ref); #TODO: add optional arguments 127 | void ShowTestWindow(bool* opened); 128 | void ShowTestWindow(); 129 | void ShowMetricsWindow(bool* opened); 130 | void ShowMetricsWindow(); 131 | 132 | # Window 133 | bool Begin(const char* name, bool* p_opened, ImGuiWindowFlags flags); #TODO add optional arguments 134 | #bool Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_use, float bg_alpha, ImGuiWindowFlags flags); 135 | void End(); 136 | #bool BeginChild(const char* str_id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags); # begin a scrolling region. size==0.0f: use remaining window size, size<0.0f: use remaining window size minus abs(size). size>0.0f: fixed size. each axis can use a different mode, e.g. ImVec2(0,400). 137 | #bool BeginChild(ImGuiID id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0); # " 138 | void EndChild() 139 | #ImVec2 GetContentRegionMax(); # current content boundaries (typically window boundaries including scrolling, or current column boundaries), in windows coordinates 140 | #ImVec2 GetContentRegionAvail(); # == GetContentRegionMax() - GetCursorPos() 141 | #float GetContentRegionAvailWidth(); # 142 | #ImVec2 GetWindowContentRegionMin(); # content boundaries min (roughly (0,0)-Scroll), in window coordinates 143 | #ImVec2 GetWindowContentRegionMax(); # content boundaries max (roughly (0,0)+Size-Scroll) where Size can be override with SetNextWindowContentSize(), in window coordinates 144 | #float GetWindowContentRegionWidth(); # 145 | #ImDrawList* GetWindowDrawList(); # get rendering command-list if you want to append your own draw primitives 146 | #ImFont* GetWindowFont(); 147 | #float GetWindowFontSize(); # size (also height in pixels) of current font with current scale applied 148 | void SetWindowFontScale(float scale) 149 | ImVec2 GetWindowPos() 150 | ImVec2 GetWindowSize() 151 | #float GetWindowWidth(); 152 | #float GetWindowHeight(); 153 | #bool IsWindowCollapsed(); 154 | 155 | #void SetNextWindowPos(const ImVec2& pos, ImGuiSetCond cond = 0); # set next window position. call before Begin() 156 | #void SetNextWindowPosCenter(ImGuiSetCond cond = 0); # set next window position to be centered on screen. call before Begin() 157 | #void SetNextWindowSize(const ImVec2& size, ImGuiSetCond cond = 0); # set next window size. set axis to 0.0f to force an auto-fit on this axis. call before Begin() 158 | #void SetNextWindowContentSize(const ImVec2& size); # set next window content size (enforce the range of scrollbars). set axis to 0.0f to leave it automatic. call before Begin() 159 | #void SetNextWindowContentWidth(float width); # set next window content width (enforce the range of horizontal scrollbar). call before Begin() 160 | #void SetNextWindowCollapsed(bool collapsed, ImGuiSetCond cond = 0); # set next window collapsed state. call before Begin() 161 | #void SetNextWindowFocus(); # set next window to be focused / front-most. call before Begin() 162 | #void SetWindowPos(const ImVec2& pos, ImGuiSetCond cond = 0); # set current window position - call within Begin()/End(). may incur tearing 163 | #void SetWindowSize(const ImVec2& size, ImGuiSetCond cond = 0); # set current window size. set to ImVec2(0,0) to force an auto-fit. may incur tearing 164 | #void SetWindowCollapsed(bool collapsed, ImGuiSetCond cond = 0); # set current window collapsed state 165 | #void SetWindowFocus(); # set current window to be focused / front-most 166 | #void SetWindowPos(const char* name, const ImVec2& pos, ImGuiSetCond cond = 0); # set named window position - call within Begin()/End(). may incur tearing 167 | #void SetWindowSize(const char* name, const ImVec2& size, ImGuiSetCond cond = 0); # set named window size. set axis to 0.0f to force an auto-fit on this axis. may incur tearing 168 | #void SetWindowCollapsed(const char* name, bool collapsed, ImGuiSetCond cond = 0); # set named window collapsed state 169 | #void SetWindowFocus(const char* name); # set named window to be focused / front-most. use NULL to remove focus. 170 | 171 | #float GetScrollX(); # get scrolling amount [0..GetScrollMaxX()] 172 | #float GetScrollY(); # get scrolling amount [0..GetScrollMaxY()] 173 | #float GetScrollMaxX(); # get maximum scrolling amount ~~ ContentSize.X - WindowSize.X 174 | #float GetScrollMaxY(); # get maximum scrolling amount ~~ ContentSize.Y - WindowSize.Y 175 | #void SetScrollX(float scroll_x); # set scrolling amount [0..GetScrollMaxX()] 176 | #void SetScrollY(float scroll_y); # set scrolling amount [0..GetScrollMaxY()] 177 | #void SetScrollHere(float center_y_ratio = 0.5f); # adjust scrolling amount to make current cursor position visible. center_y_ratio=0.0: top, 0.5: center, 1.0: bottom. 178 | #void SetScrollFromPosY(float pos_y, float center_y_ratio = 0.5f); # adjust scrolling amount to make given position valid. use GetCursorPos() or GetCursorStartPos()+offset to get valid positions. 179 | #void SetKeyboardFocusHere(int offset = 0); # focus keyboard on the next widget. Use positive 'offset' to access sub components of a multiple component widget 180 | #void SetStateStorage(ImGuiStorage* tree); # replace tree state storage with our own (if you want to manipulate it yourself, typically clear subsection of it) 181 | #ImGuiStorage* GetStateStorage(); 182 | 183 | ## Parameters stacks (shared) 184 | #void PushFont(ImFont* font); # use NULL as a shortcut to push default font 185 | #void PopFont(); 186 | #void PushStyleColor(ImGuiCol idx, const ImVec4& col); 187 | #void PopStyleColor(int count = 1); 188 | #void PushStyleVar(ImGuiStyleVar idx, float val); 189 | #void PushStyleVar(ImGuiStyleVar idx, const ImVec2& val); 190 | #void PopStyleVar(int count = 1); 191 | 192 | ## Parameters stacks (current window) 193 | #void PushItemWidth(float item_width); # width of items for the common item+label case, pixels. 0.0f = default to ~2/3 of windows width, >0.0f: width in pixels, <0.0f align xx pixels to the right of window (so -1.0f always align width to the right side) 194 | #void PopItemWidth(); 195 | #float CalcItemWidth(); # width of item given pushed settings and current cursor position 196 | #void PushTextWrapPos(float wrap_pos_x = 0.0f); # word-wrapping for Text*() commands. < 0.0f: no wrapping; 0.0f: wrap to end of window (or column); > 0.0f: wrap at 'wrap_pos_x' position in window local space 197 | #void PopTextWrapPos(); 198 | #void PushAllowKeyboardFocus(bool v); # allow focusing using TAB/Shift-TAB, enabled by default but you can disable it for certain widgets 199 | #void PopAllowKeyboardFocus(); 200 | #void PushButtonRepeat(bool repeat); # in 'repeat' mode, Button*() functions return repeated true in a typematic manner (uses io.KeyRepeatDelay/io.KeyRepeatRate for now). Note that you can call IsItemActive() after any Button() to tell if the button is held in the current frame. 201 | #void PopButtonRepeat(); 202 | 203 | ## Cursor / Layout 204 | #void BeginGroup(); # lock horizontal starting position. once closing a group it is seen as a single item (so you can use IsItemHovered() on a group, SameLine() between groups, etc. 205 | #void EndGroup(); 206 | #void Separator(); # horizontal line 207 | #void SameLine(float local_pos_x = 0.0f, float spacing_w = -1.0f); # call between widgets or groups to layout them horizontally 208 | #void Spacing(); # add spacing 209 | #void Dummy(const ImVec2& size); # add a dummy item of given size 210 | #void Indent(); # move content position toward the right by style.IndentSpacing pixels 211 | #void Unindent(); # move content position back to the left (cancel Indent) 212 | #void Columns(int count = 1, const char* id = NULL, bool border=true); # setup number of columns. use an identifier to distinguish multiple column sets. close with Columns(1). 213 | #void NextColumn(); # next column 214 | #int GetColumnIndex(); # get current column index 215 | #float GetColumnOffset(int column_index = -1); # get position of column line (in pixels, from the left side of the contents region). pass -1 to use current column, otherwise 0..GetcolumnsCount() inclusive. column 0 is usually 0.0f and not resizable unless you call this 216 | #void SetColumnOffset(int column_index, float offset_x); # set position of column line (in pixels, from the left side of the contents region). pass -1 to use current column 217 | #float GetColumnWidth(int column_index = -1); # column width (== GetColumnOffset(GetColumnIndex()+1) - GetColumnOffset(GetColumnOffset()) 218 | #int GetColumnsCount(); # number of columns (what was passed to Columns()) 219 | #ImVec2 GetCursorPos(); # cursor position is relative to window position 220 | #float GetCursorPosX(); # " 221 | #float GetCursorPosY(); # " 222 | #void SetCursorPos(const ImVec2& local_pos); # " 223 | #void SetCursorPosX(float x); # " 224 | #void SetCursorPosY(float y); # " 225 | #ImVec2 GetCursorStartPos(); # initial cursor position 226 | #ImVec2 GetCursorScreenPos(); # cursor position in absolute screen coordinates [0..io.DisplaySize] 227 | #void SetCursorScreenPos(const ImVec2& pos); # cursor position in absolute screen coordinates [0..io.DisplaySize] 228 | #void AlignFirstTextHeightToWidgets(); # call once if the first item on the line is a Text() item and you want to vertically lower it to match subsequent (bigger) widgets 229 | #float GetTextLineHeight(); # height of font == GetWindowFontSize() 230 | #float GetTextLineHeightWithSpacing(); # distance (in pixels) between 2 consecutive lines of text == GetWindowFontSize() + GetStyle().ItemSpacing.y 231 | #float GetItemsLineHeightWithSpacing(); # distance (in pixels) between 2 consecutive lines of standard height widgets == GetWindowFontSize() + GetStyle().FramePadding.y*2 + GetStyle().ItemSpacing.y 232 | 233 | ## ID scopes 234 | ## If you are creating widgets in a loop you most likely want to push a unique identifier so ImGui can differentiate them. 235 | ## You can also use "##extra" within your widget name to distinguish them from each others. Read the FAQ for more details. 236 | #void PushID(const char* str_id); # push identifier into the ID stack. IDs are hash of the *entire* stack! 237 | #void PushID(const char* str_id_begin, const char* str_id_end); 238 | #void PushID(const void* ptr_id); 239 | #void PushID(int int_id); 240 | #void PopID(); 241 | #ImGuiID GetID(const char* str_id); # calculate unique ID (hash of whole ID stack + given parameter). useful if you want to query into ImGuiStorage yourself. otherwise rarely needed 242 | #ImGuiID GetID(const char* str_id_begin, const char* str_id_end); 243 | #ImGuiID GetID(const void* ptr_id); 244 | 245 | ## Widgets 246 | void Text(const char* text) 247 | #void TextV(const char* fmt, va_list args); 248 | #void TextColored(const ImVec4& col, const char* fmt, ...) IM_PRINTFARGS(2); # shortcut for PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor(); 249 | #void TextColoredV(const ImVec4& col, const char* fmt, va_list args); 250 | #void TextDisabled(const char* fmt, ...) IM_PRINTFARGS(1); # shortcut for PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]); Text(fmt, ...); PopStyleColor(); 251 | #void TextDisabledV(const char* fmt, va_list args); 252 | #void TextWrapped(const char* fmt, ...) IM_PRINTFARGS(1); # shortcut for PushTextWrapPos(0.0f); Text(fmt, ...); PopTextWrapPos();. Note that this won't work on an auto-resizing window if there's no other widgets to extend the window width, yoy may need to set a size using SetNextWindowSize(). 253 | #void TextWrappedV(const char* fmt, va_list args); 254 | #void TextUnformatted(const char* text, const char* text_end = NULL); # doesn't require null terminated string if 'text_end' is specified. no copy done to any bounded stack buffer, recommended for long chunks of text 255 | #void LabelText(const char* label, const char* fmt, ...) IM_PRINTFARGS(2); # display text+label aligned the same way as value+label widgets 256 | #void LabelTextV(const char* label, const char* fmt, va_list args); 257 | #void Bullet(); 258 | #void BulletText(const char* fmt, ...) IM_PRINTFARGS(1); 259 | #void BulletTextV(const char* fmt, va_list args); 260 | #bool Button(const char* label, const ImVec2& size = ImVec2(0,0)); 261 | #bool SmallButton(const char* label); 262 | #bool InvisibleButton(const char* str_id, const ImVec2& size); 263 | #void Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), const ImVec4& tint_col = ImVec4(1,1,1,1), const ImVec4& border_col = ImVec4(0,0,0,0)); 264 | #bool ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0,0,0,0), const ImVec4& tint_col = ImVec4(1,1,1,1)); # <0 frame_padding uses default frame padding settings. 0 for no padding 265 | #bool CollapsingHeader(const char* label, const char* str_id = NULL, bool display_frame = true, bool default_open = false); 266 | #bool Checkbox(const char* label, bool* v); 267 | #bool CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value); 268 | #bool RadioButton(const char* label, bool active); 269 | #bool RadioButton(const char* label, int* v, int v_button); 270 | #bool Combo(const char* label, int* current_item, const char** items, int items_count, int height_in_items = -1); 271 | #bool Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int height_in_items = -1); # separate items with \0, end item-list with \0\0 272 | #bool Combo(const char* label, int* current_item, bool (*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int height_in_items = -1); 273 | #bool ColorButton(const ImVec4& col, bool small_height = false, bool outline_border = true); 274 | #bool ColorEdit3(const char* label, float col[3]); 275 | #bool ColorEdit4(const char* label, float col[4], bool show_alpha = true); 276 | #void ColorEditMode(ImGuiColorEditMode mode); 277 | #void PlotLines(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0), int stride = sizeof(float)); 278 | #void PlotLines(const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0)); 279 | #void PlotHistogram(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0), int stride = sizeof(float)); 280 | #void PlotHistogram(const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0)); 281 | 282 | ## Widgets: Drags (tip: ctrl+click on a drag box to input text) 283 | #bool DragFloat(const char* label, float* v, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", float power = 1.0f); # If v_min >= v_max we have no bound 284 | #bool DragFloat2(const char* label, float v[2], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", float power = 1.0f); 285 | #bool DragFloat3(const char* label, float v[3], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", float power = 1.0f); 286 | #bool DragFloat4(const char* label, float v[4], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", float power = 1.0f); 287 | #bool DragFloatRange2(const char* label, float* v_current_min, float* v_current_max, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", const char* display_format_max = NULL, float power = 1.0f); 288 | #bool DragInt(const char* label, int* v, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* display_format = "%.0f"); # If v_min >= v_max we have no bound 289 | #bool DragInt2(const char* label, int v[2], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* display_format = "%.0f"); 290 | #bool DragInt3(const char* label, int v[3], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* display_format = "%.0f"); 291 | #bool DragInt4(const char* label, int v[4], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* display_format = "%.0f"); 292 | #bool DragIntRange2(const char* label, int* v_current_min, int* v_current_max, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* display_format = "%.0f", const char* display_format_max = NULL); 293 | 294 | ## Widgets: Input 295 | #bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiTextEditCallback callback = NULL, void* user_data = NULL); 296 | #bool InputTextMultiline(const char* label, char* buf, size_t buf_size, const ImVec2& size = ImVec2(0,0), ImGuiInputTextFlags flags = 0, ImGuiTextEditCallback callback = NULL, void* user_data = NULL); 297 | #bool InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, int decimal_precision = -1, ImGuiInputTextFlags extra_flags = 0); 298 | #bool InputFloat2(const char* label, float v[2], int decimal_precision = -1, ImGuiInputTextFlags extra_flags = 0); 299 | #bool InputFloat3(const char* label, float v[3], int decimal_precision = -1, ImGuiInputTextFlags extra_flags = 0); 300 | #bool InputFloat4(const char* label, float v[4], int decimal_precision = -1, ImGuiInputTextFlags extra_flags = 0); 301 | #bool InputInt(const char* label, int* v, int step = 1, int step_fast = 100, ImGuiInputTextFlags extra_flags = 0); 302 | #bool InputInt2(const char* label, int v[2], ImGuiInputTextFlags extra_flags = 0); 303 | #bool InputInt3(const char* label, int v[3], ImGuiInputTextFlags extra_flags = 0); 304 | #bool InputInt4(const char* label, int v[4], ImGuiInputTextFlags extra_flags = 0); 305 | 306 | ## Widgets: Sliders (tip: ctrl+click on a slider to input text) 307 | #bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f); # adjust display_format to decorate the value with a prefix or a suffix. Use power!=1.0 for logarithmic sliders 308 | #bool SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f); 309 | #bool SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f); 310 | #bool SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f); 311 | #bool SliderAngle(const char* label, float* v_rad, float v_degrees_min = -360.0f, float v_degrees_max = +360.0f); 312 | #bool SliderInt(const char* label, int* v, int v_min, int v_max, const char* display_format = "%.0f"); 313 | #bool SliderInt2(const char* label, int v[2], int v_min, int v_max, const char* display_format = "%.0f"); 314 | #bool SliderInt3(const char* label, int v[3], int v_min, int v_max, const char* display_format = "%.0f"); 315 | #bool SliderInt4(const char* label, int v[4], int v_min, int v_max, const char* display_format = "%.0f"); 316 | #bool VSliderFloat(const char* label, const ImVec2& size, float* v, float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f); 317 | #bool VSliderInt(const char* label, const ImVec2& size, int* v, int v_min, int v_max, const char* display_format = "%.0f"); 318 | 319 | ## Widgets: Trees 320 | #bool TreeNode(const char* str_label_id); # if returning 'true' the node is open and the user is responsible for calling TreePop() 321 | #bool TreeNode(const char* str_id, const char* fmt, ...) IM_PRINTFARGS(2); # " 322 | #bool TreeNode(const void* ptr_id, const char* fmt, ...) IM_PRINTFARGS(2); # " 323 | #bool TreeNodeV(const char* str_id, const char* fmt, va_list args); # " 324 | #bool TreeNodeV(const void* ptr_id, const char* fmt, va_list args); # " 325 | #void TreePush(const char* str_id = NULL); # already called by TreeNode(), but you can call Push/Pop yourself for layouting purpose 326 | #void TreePush(const void* ptr_id = NULL); # " 327 | #void TreePop(); 328 | #void SetNextTreeNodeOpened(bool opened, ImGuiSetCond cond = 0); # set next tree node to be opened. 329 | 330 | ## Widgets: Selectable / Lists 331 | #bool Selectable(const char* label, bool selected = false, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0,0)); # size.x==0.0: use remaining width, size.x>0.0: specify width. size.y==0.0: use label height, size.y>0.0: specify height 332 | #bool Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0,0)); 333 | #bool ListBox(const char* label, int* current_item, const char** items, int items_count, int height_in_items = -1); 334 | #bool ListBox(const char* label, int* current_item, bool (*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int height_in_items = -1); 335 | #bool ListBoxHeader(const char* label, const ImVec2& size = ImVec2(0,0)); # use if you want to reimplement ListBox() will custom data or interactions. make sure to call ListBoxFooter() afterwards. 336 | #bool ListBoxHeader(const char* label, int items_count, int height_in_items = -1); # " 337 | #void ListBoxFooter(); # terminate the scrolling region 338 | 339 | ## Widgets: Value() Helpers. Output single value in "name: value" format (tip: freely declare more in your code to handle your types. you can add functions to the ImGui namespace) 340 | #void Value(const char* prefix, bool b); 341 | #void Value(const char* prefix, int v); 342 | #void Value(const char* prefix, unsigned int v); 343 | #void Value(const char* prefix, float v, const char* float_format = NULL); 344 | #void Color(const char* prefix, const ImVec4& v); 345 | #void Color(const char* prefix, unsigned int v); 346 | 347 | ## Tooltip 348 | #void SetTooltip(const char* fmt, ...) IM_PRINTFARGS(1); # set tooltip under mouse-cursor, typically use with ImGui::IsHovered(). last call wins 349 | #void SetTooltipV(const char* fmt, va_list args); 350 | #void BeginTooltip(); # use to create full-featured tooltip windows that aren't just text 351 | #void EndTooltip(); 352 | 353 | ## Menus 354 | #bool BeginMainMenuBar(); # create and append to a full screen menu-bar. only call EndMainMenuBar() if this returns true! 355 | #void EndMainMenuBar(); 356 | #bool BeginMenuBar(); # append to menu-bar of current window (requires ImGuiWindowFlags_MenuBar flag set). only call EndMenuBar() if this returns true! 357 | #void EndMenuBar(); 358 | #bool BeginMenu(const char* label, bool enabled = true); # create a sub-menu entry. only call EndMenu() if this returns true! 359 | #void EndMenu(); 360 | #bool MenuItem(const char* label, const char* shortcut = NULL, bool selected = false, bool enabled = true); # return true when activated. shortcuts are displayed for convenience but not processed by ImGui at the moment 361 | #bool MenuItem(const char* label, const char* shortcut, bool* p_selected, bool enabled = true); # return true when activated + toggle (*p_selected) if p_selected != NULL 362 | 363 | ## Popup 364 | #void OpenPopup(const char* str_id); # mark popup as open. popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level). close childs popups if any. will close popup when user click outside, or activate a pressable item, or CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block. 365 | #bool BeginPopup(const char* str_id); # return true if popup if opened and start outputting to it. only call EndPopup() if BeginPopup() returned true! 366 | #bool BeginPopupModal(const char* name, bool* p_opened = NULL, ImGuiWindowFlags extra_flags = 0); # modal dialog (can't close them by clicking outside) 367 | #bool BeginPopupContextItem(const char* str_id, int mouse_button = 1); # helper to open and begin popup when clicked on last item 368 | #bool BeginPopupContextWindow(bool also_over_items = true, const char* str_id = NULL, int mouse_button = 1); # helper to open and begin popup when clicked on current window 369 | #bool BeginPopupContextVoid(const char* str_id = NULL, int mouse_button = 1); # helper to open and begin popup when clicked in void (no window) 370 | #void EndPopup(); 371 | #void CloseCurrentPopup(); # close the popup we have begin-ed into. clicking on a MenuItem or Selectable automatically close the current popup. 372 | 373 | ## Logging: all text output from interface is redirected to tty/file/clipboard. Tree nodes are automatically opened. 374 | #void LogToTTY(int max_depth = -1); # start logging to tty 375 | #void LogToFile(int max_depth = -1, const char* filename = NULL); # start logging to file 376 | #void LogToClipboard(int max_depth = -1); # start logging to OS clipboard 377 | #void LogFinish(); # stop logging (close file, etc.) 378 | #void LogButtons(); # helper to display buttons for logging to tty/file/clipboard 379 | #void LogText(const char* fmt, ...) IM_PRINTFARGS(1); # pass text data straight to log (without being displayed) 380 | 381 | ## Utilities 382 | #bool IsItemHovered(); # was the last item hovered by mouse? 383 | #bool IsItemHoveredRect(); # was the last item hovered by mouse? even if another item is active while we are hovering this 384 | #bool IsItemActive(); # was the last item active? (e.g. button being held, text field being edited- items that don't interact will always return false) 385 | #bool IsItemVisible(); # was the last item visible? (aka not out of sight due to clipping/scrolling.) 386 | #bool IsAnyItemHovered(); 387 | #bool IsAnyItemActive(); 388 | #ImVec2 GetItemRectMin(); # get bounding rect of last item in screen space 389 | #ImVec2 GetItemRectMax(); # " 390 | #ImVec2 GetItemRectSize(); # " 391 | #bool IsWindowHovered(); # is current window hovered and hoverable (not blocked by a popup) (differentiate child windows from each others) 392 | #bool IsWindowFocused(); # is current window focused 393 | #bool IsRootWindowFocused(); # is current root window focused (top parent window in case of child windows) 394 | #bool IsRootWindowOrAnyChildFocused(); # is current root window or any of its child (including current window) focused 395 | #bool IsRectVisible(const ImVec2& size); # test if rectangle of given size starting from cursor pos is visible (not clipped). to perform coarse clipping on user's side (as an optimization) 396 | #bool IsPosHoveringAnyWindow(const ImVec2& pos); # is given position hovering any active imgui window 397 | #float GetTime(); 398 | #int GetFrameCount(); 399 | #const char* GetStyleColName(ImGuiCol idx); 400 | #ImVec2 CalcItemRectClosestPoint(const ImVec2& pos, bool on_edge = false, float outward = +0.0f); # utility to find the closest point the last item bounding rectangle edge. useful to visually link items 401 | #ImVec2 CalcTextSize(const char* text, const char* text_end = NULL, bool hide_text_after_double_hash = false, float wrap_width = -1.0f); 402 | #void CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end); # calculate coarse clipping for large list of evenly sized items. Prefer using the ImGuiListClipper higher-level helper if you can. 403 | 404 | #bool BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags extra_flags = 0); # helper to create a child window / scrolling region that looks like a normal widget frame 405 | #void EndChildFrame(); 406 | 407 | #ImVec4 ColorConvertU32ToFloat4(ImU32 in); 408 | #ImU32 ColorConvertFloat4ToU32(const ImVec4& in); 409 | #void ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& out_s, float& out_v); 410 | #void ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b); 411 | 412 | ## Inputs 413 | #int GetKeyIndex(ImGuiKey key); # map ImGuiKey_* values into user's key index. == io.KeyMap[key] 414 | #bool IsKeyDown(int key_index); # key_index into the keys_down[] array, imgui doesn't know the semantic of each entry, uses your own indices! 415 | #bool IsKeyPressed(int key_index, bool repeat = true); # uses user's key indices as stored in the keys_down[] array. if repeat=true. uses io.KeyRepeatDelay / KeyRepeatRate 416 | #bool IsKeyReleased(int key_index); # " 417 | #bool IsMouseDown(int button); # is mouse button held 418 | #bool IsMouseClicked(int button, bool repeat = false); # did mouse button clicked (went from !Down to Down) 419 | #bool IsMouseDoubleClicked(int button); # did mouse button double-clicked. a double-click returns false in IsMouseClicked(). uses io.MouseDoubleClickTime. 420 | #bool IsMouseReleased(int button); # did mouse button released (went from Down to !Down) 421 | #bool IsMouseHoveringWindow(); # is mouse hovering current window ("window" in API names always refer to current window). disregarding of any consideration of being blocked by a popup. (unlike IsWindowHovered() this will return true even if the window is blocked because of a popup) 422 | #bool IsMouseHoveringAnyWindow(); # is mouse hovering any visible window 423 | #bool IsMouseHoveringRect(const ImVec2& pos_min, const ImVec2& pos_max, bool clip = true); # is mouse hovering given bounding rect (in screen space). clipped by current clipping settings. disregarding of consideration of focus/window ordering/blocked by a popup. 424 | #bool IsMouseDragging(int button = 0, float lock_threshold = -1.0f); # is mouse dragging. if lock_threshold < -1.0f uses io.MouseDraggingThreshold 425 | #ImVec2 GetMousePos(); # shortcut to ImGui::GetIO().MousePos provided by user, to be consistent with other calls 426 | #ImVec2 GetMousePosOnOpeningCurrentPopup(); # retrieve backup of mouse positioning at the time of opening popup we have BeginPopup() into 427 | #ImVec2 GetMouseDragDelta(int button = 0, float lock_threshold = -1.0f); # dragging amount since clicking. if lock_threshold < -1.0f uses io.MouseDraggingThreshold 428 | #void ResetMouseDragDelta(int button = 0); # 429 | #ImGuiMouseCursor GetMouseCursor(); # get desired cursor type, reset in ImGui::NewFrame(), this updated during the frame. valid before Render(). If you use software rendering by setting io.MouseDrawCursor ImGui will render those for you 430 | #void SetMouseCursor(ImGuiMouseCursor type); # set desired cursor type 431 | #void CaptureKeyboardFromApp(); # manually enforce imgui setting the io.WantCaptureKeyboard flag next frame (your application needs to handle it). e.g. capture keyboard when your widget is being hovered. 432 | #void CaptureMouseFromApp(); # manually enforce imgui setting the io.WantCaptureMouse flag next frame (your application needs to handle it). 433 | 434 | ## Helpers functions to access functions pointers in ImGui::GetIO() 435 | #void* MemAlloc(size_t sz); 436 | #void MemFree(void* ptr); 437 | #const char* GetClipboardText(); 438 | #void SetClipboardText(const char* text); 439 | 440 | ## Internal state/context access - if you want to use multiple ImGui context, or share context between modules (e.g. DLL), or allocate the memory yourself 441 | #const char* GetVersion(); 442 | #void* GetInternalState(); 443 | #size_t GetInternalStateSize(); 444 | #void SetInternalState(void* state, bool construct = false); 445 | -------------------------------------------------------------------------------- /pyimgui/imgui.pyx: -------------------------------------------------------------------------------- 1 | # distutils: language = c++ 2 | # distutils: sources = imgui/imgui.cpp imgui/imgui_draw.cpp 3 | cimport cimgui 4 | from cimgui cimport ImVec2, ImGuiIO, ImDrawData, ImFontAtlas, ImDrawData 5 | 6 | cdef object wrap_ImVec2(ImVec2 v): 7 | return v.x, v.y 8 | 9 | cdef ImVec2 unwrap_ImVec2(pair): 10 | cdef ImVec2 v 11 | v.x, v.y = pair 12 | return v 13 | 14 | cdef class Fonts: 15 | cdef ImFontAtlas* ptr 16 | cdef object render_draw_lists_fn 17 | 18 | @staticmethod 19 | cdef create(ImFontAtlas* ptr): 20 | this = Fonts() 21 | this.ptr = ptr 22 | return this 23 | 24 | def add_font_default(self): 25 | self.ptr.AddFontDefault() 26 | 27 | def get_tex_data_as_alpha8(self): 28 | cdef unsigned char* pixels 29 | cdef int width 30 | cdef int height 31 | self.ptr.GetTexDataAsAlpha8(&pixels, &width, &height) 32 | return width, height, pixels 33 | 34 | def get_tex_data_as_rgba32(self): 35 | cdef unsigned char* pixels 36 | cdef int width 37 | cdef int height 38 | self.ptr.GetTexDataAsRGBA32(&pixels, &width, &height) 39 | return width, height, pixels 40 | 41 | cdef class DrawData: 42 | cdef ImDrawData* ptr 43 | 44 | @staticmethod 45 | cdef create(ImDrawData* ptr): 46 | this = DrawData() 47 | this.ptr = ptr 48 | return this 49 | 50 | cdef class IO: 51 | cdef ImGuiIO* thisref 52 | cdef object render_draw_lists_fn 53 | 54 | @staticmethod 55 | cdef create(ImGuiIO& ref): 56 | io = IO() 57 | io.thisref = &ref 58 | return io 59 | 60 | property display_size: 61 | def __get__(self): 62 | return wrap_ImVec2(self.thisref.DisplaySize) 63 | 64 | def __set__(self, v): 65 | self.thisref.DisplaySize = unwrap_ImVec2(v) 66 | 67 | property render_draw_lists_fn: 68 | def __get__(self): 69 | return self.render_draw_lists_fn 70 | 71 | def __set__(self, object fn): 72 | self.render_draw_lists_fn = fn 73 | self.thisref.RenderDrawListsFn = draw_callback 74 | 75 | property delta_time: 76 | def __get__(self): 77 | return self.thisref.DeltaTime 78 | 79 | def __set__(self, float time): 80 | self.thisref.DeltaTime = time 81 | 82 | 83 | property fonts: 84 | def __get__(self): 85 | return Fonts.create(self.thisref.Fonts) 86 | 87 | cdef void draw_callback(ImDrawData* draw_data): 88 | print 'foo' 89 | 90 | def get_io(): 91 | return IO.create(cimgui.GetIO()) 92 | 93 | #def GetStyle(): 94 | # style = cimgui.GetStyle() 95 | # return style 96 | # 97 | #def GetDrawData(): 98 | # drawData = cimgui.GetDrawData() 99 | # return drawData 100 | # 101 | 102 | def new_frame(): 103 | cimgui.NewFrame() 104 | 105 | def render(): 106 | cimgui.Render() 107 | 108 | def shutdown(): 109 | cimgui.Shutdown() 110 | 111 | def begin(char* name): 112 | cdef cimgui.bool foo 113 | return cimgui.Begin(name, &foo, 0) 114 | 115 | def end(): 116 | cimgui.End() 117 | 118 | def text(char* text): 119 | cimgui.Text(text) 120 | 121 | #bool BeginChild(const char* str_id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags); # begin a scrolling region. size==0.0f: use remaining window size, size<0.0f: use remaining window size minus abs(size). size>0.0f: fixed size. each axis can use a different mode, e.g. ImVec2(0,400). 122 | #bool BeginChild(ImGuiID id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0); # " 123 | def end_child(): 124 | cimgui.EndChild() 125 | #ImVec2 GetContentRegionMax(); # current content boundaries (typically window boundaries including scrolling, or current column boundaries), in windows coordinates 126 | #ImVec2 GetContentRegionAvail(); # == GetContentRegionMax() - GetCursorPos() 127 | #float GetContentRegionAvailWidth(); # 128 | #ImVec2 GetWindowContentRegionMin(); # content boundaries min (roughly (0,0)-Scroll), in window coordinates 129 | #ImVec2 GetWindowContentRegionMax(); # content boundaries max (roughly (0,0)+Size-Scroll) where Size can be override with SetNextWindowContentSize(), in window coordinates 130 | #float GetWindowContentRegionWidth(); # 131 | #ImDrawList* GetWindowDrawList(); # get rendering command-list if you want to append your own draw primitives 132 | #ImFont* GetWindowFont(); 133 | #float GetWindowFontSize(); # size (also height in pixels) of current font with current scale applied 134 | def set_window_font_scale(float scale): 135 | cimgui.SetWindowFontScale(scale) 136 | 137 | def get_window_pos(): 138 | return wrap_ImVec2(cimgui.GetWindowPos()) 139 | 140 | def get_window_size(): 141 | return wrap_ImVec2(cimgui.GetWindowSize()) 142 | 143 | #float GetWindowWidth(); 144 | #float GetWindowHeight(); 145 | #bool IsWindowCollapsed(); 146 | 147 | #void SetNextWindowPos(const ImVec2& pos, ImGuiSetCond cond = 0); # set next window position. call before Begin() 148 | #void SetNextWindowPosCenter(ImGuiSetCond cond = 0); # set next window position to be centered on screen. call before Begin() 149 | #void SetNextWindowSize(const ImVec2& size, ImGuiSetCond cond = 0); # set next window size. set axis to 0.0f to force an auto-fit on this axis. call before Begin() 150 | #void SetNextWindowContentSize(const ImVec2& size); # set next window content size (enforce the range of scrollbars). set axis to 0.0f to leave it automatic. call before Begin() 151 | #void SetNextWindowContentWidth(float width); # set next window content width (enforce the range of horizontal scrollbar). call before Begin() 152 | #void SetNextWindowCollapsed(bool collapsed, ImGuiSetCond cond = 0); # set next window collapsed state. call before Begin() 153 | #void SetNextWindowFocus(); # set next window to be focused / front-most. call before Begin() 154 | #void SetWindowPos(const ImVec2& pos, ImGuiSetCond cond = 0); # set current window position - call within Begin()/End(). may incur tearing 155 | #void SetWindowSize(const ImVec2& size, ImGuiSetCond cond = 0); # set current window size. set to ImVec2(0,0) to force an auto-fit. may incur tearing 156 | #void SetWindowCollapsed(bool collapsed, ImGuiSetCond cond = 0); # set current window collapsed state 157 | #void SetWindowFocus(); # set current window to be focused / front-most 158 | #void SetWindowPos(const char* name, const ImVec2& pos, ImGuiSetCond cond = 0); # set named window position - call within Begin()/End(). may incur tearing 159 | #void SetWindowSize(const char* name, const ImVec2& size, ImGuiSetCond cond = 0); # set named window size. set axis to 0.0f to force an auto-fit on this axis. may incur tearing 160 | #void SetWindowCollapsed(const char* name, bool collapsed, ImGuiSetCond cond = 0); # set named window collapsed state 161 | #void SetWindowFocus(const char* name); # set named window to be focused / front-most. use NULL to remove focus. 162 | 163 | #float GetScrollX(); # get scrolling amount [0..GetScrollMaxX()] 164 | #float GetScrollY(); # get scrolling amount [0..GetScrollMaxY()] 165 | #float GetScrollMaxX(); # get maximum scrolling amount ~~ ContentSize.X - WindowSize.X 166 | #float GetScrollMaxY(); # get maximum scrolling amount ~~ ContentSize.Y - WindowSize.Y 167 | #void SetScrollX(float scroll_x); # set scrolling amount [0..GetScrollMaxX()] 168 | #void SetScrollY(float scroll_y); # set scrolling amount [0..GetScrollMaxY()] 169 | #void SetScrollHere(float center_y_ratio = 0.5f); # adjust scrolling amount to make current cursor position visible. center_y_ratio=0.0: top, 0.5: center, 1.0: bottom. 170 | #void SetScrollFromPosY(float pos_y, float center_y_ratio = 0.5f); # adjust scrolling amount to make given position valid. use GetCursorPos() or GetCursorStartPos()+offset to get valid positions. 171 | #void SetKeyboardFocusHere(int offset = 0); # focus keyboard on the next widget. Use positive 'offset' to access sub components of a multiple component widget 172 | #void SetStateStorage(ImGuiStorage* tree); # replace tree state storage with our own (if you want to manipulate it yourself, typically clear subsection of it) 173 | #ImGuiStorage* GetStateStorage(); 174 | 175 | ## Parameters stacks (shared) 176 | #void PushFont(ImFont* font); # use NULL as a shortcut to push default font 177 | #void PopFont(); 178 | #void PushStyleColor(ImGuiCol idx, const ImVec4& col); 179 | #void PopStyleColor(int count = 1); 180 | #void PushStyleVar(ImGuiStyleVar idx, float val); 181 | #void PushStyleVar(ImGuiStyleVar idx, const ImVec2& val); 182 | #void PopStyleVar(int count = 1); 183 | 184 | ## Parameters stacks (current window) 185 | #void PushItemWidth(float item_width); # width of items for the common item+label case, pixels. 0.0f = default to ~2/3 of windows width, >0.0f: width in pixels, <0.0f align xx pixels to the right of window (so -1.0f always align width to the right side) 186 | #void PopItemWidth(); 187 | #float CalcItemWidth(); # width of item given pushed settings and current cursor position 188 | #void PushTextWrapPos(float wrap_pos_x = 0.0f); # word-wrapping for Text*() commands. < 0.0f: no wrapping; 0.0f: wrap to end of window (or column); > 0.0f: wrap at 'wrap_pos_x' position in window local space 189 | #void PopTextWrapPos(); 190 | #void PushAllowKeyboardFocus(bool v); # allow focusing using TAB/Shift-TAB, enabled by default but you can disable it for certain widgets 191 | #void PopAllowKeyboardFocus(); 192 | #void PushButtonRepeat(bool repeat); # in 'repeat' mode, Button*() functions return repeated true in a typematic manner (uses io.KeyRepeatDelay/io.KeyRepeatRate for now). Note that you can call IsItemActive() after any Button() to tell if the button is held in the current frame. 193 | #void PopButtonRepeat(); 194 | 195 | ## Cursor / Layout 196 | #void BeginGroup(); # lock horizontal starting position. once closing a group it is seen as a single item (so you can use IsItemHovered() on a group, SameLine() between groups, etc. 197 | #void EndGroup(); 198 | #void Separator(); # horizontal line 199 | #void SameLine(float local_pos_x = 0.0f, float spacing_w = -1.0f); # call between widgets or groups to layout them horizontally 200 | #void Spacing(); # add spacing 201 | #void Dummy(const ImVec2& size); # add a dummy item of given size 202 | #void Indent(); # move content position toward the right by style.IndentSpacing pixels 203 | #void Unindent(); # move content position back to the left (cancel Indent) 204 | #void Columns(int count = 1, const char* id = NULL, bool border=true); # setup number of columns. use an identifier to distinguish multiple column sets. close with Columns(1). 205 | #void NextColumn(); # next column 206 | #int GetColumnIndex(); # get current column index 207 | #float GetColumnOffset(int column_index = -1); # get position of column line (in pixels, from the left side of the contents region). pass -1 to use current column, otherwise 0..GetcolumnsCount() inclusive. column 0 is usually 0.0f and not resizable unless you call this 208 | #void SetColumnOffset(int column_index, float offset_x); # set position of column line (in pixels, from the left side of the contents region). pass -1 to use current column 209 | #float GetColumnWidth(int column_index = -1); # column width (== GetColumnOffset(GetColumnIndex()+1) - GetColumnOffset(GetColumnOffset()) 210 | #int GetColumnsCount(); # number of columns (what was passed to Columns()) 211 | #ImVec2 GetCursorPos(); # cursor position is relative to window position 212 | #float GetCursorPosX(); # " 213 | #float GetCursorPosY(); # " 214 | #void SetCursorPos(const ImVec2& local_pos); # " 215 | #void SetCursorPosX(float x); # " 216 | #void SetCursorPosY(float y); # " 217 | #ImVec2 GetCursorStartPos(); # initial cursor position 218 | #ImVec2 GetCursorScreenPos(); # cursor position in absolute screen coordinates [0..io.DisplaySize] 219 | #void SetCursorScreenPos(const ImVec2& pos); # cursor position in absolute screen coordinates [0..io.DisplaySize] 220 | #void AlignFirstTextHeightToWidgets(); # call once if the first item on the line is a Text() item and you want to vertically lower it to match subsequent (bigger) widgets 221 | #float GetTextLineHeight(); # height of font == GetWindowFontSize() 222 | #float GetTextLineHeightWithSpacing(); # distance (in pixels) between 2 consecutive lines of text == GetWindowFontSize() + GetStyle().ItemSpacing.y 223 | #float GetItemsLineHeightWithSpacing(); # distance (in pixels) between 2 consecutive lines of standard height widgets == GetWindowFontSize() + GetStyle().FramePadding.y*2 + GetStyle().ItemSpacing.y 224 | 225 | ## ID scopes 226 | ## If you are creating widgets in a loop you most likely want to push a unique identifier so ImGui can differentiate them. 227 | ## You can also use "##extra" within your widget name to distinguish them from each others. Read the FAQ for more details. 228 | #void PushID(const char* str_id); # push identifier into the ID stack. IDs are hash of the *entire* stack! 229 | #void PushID(const char* str_id_begin, const char* str_id_end); 230 | #void PushID(const void* ptr_id); 231 | #void PushID(int int_id); 232 | #void PopID(); 233 | #ImGuiID GetID(const char* str_id); # calculate unique ID (hash of whole ID stack + given parameter). useful if you want to query into ImGuiStorage yourself. otherwise rarely needed 234 | #ImGuiID GetID(const char* str_id_begin, const char* str_id_end); 235 | #ImGuiID GetID(const void* ptr_id); 236 | 237 | ## Widgets 238 | #void TextV(const char* fmt, va_list args); 239 | #void TextColored(const ImVec4& col, const char* fmt, ...) IM_PRINTFARGS(2); # shortcut for PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor(); 240 | #void TextColoredV(const ImVec4& col, const char* fmt, va_list args); 241 | #void TextDisabled(const char* fmt, ...) IM_PRINTFARGS(1); # shortcut for PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]); Text(fmt, ...); PopStyleColor(); 242 | #void TextDisabledV(const char* fmt, va_list args); 243 | #void TextWrapped(const char* fmt, ...) IM_PRINTFARGS(1); # shortcut for PushTextWrapPos(0.0f); Text(fmt, ...); PopTextWrapPos();. Note that this won't work on an auto-resizing window if there's no other widgets to extend the window width, yoy may need to set a size using SetNextWindowSize(). 244 | #void TextWrappedV(const char* fmt, va_list args); 245 | #void TextUnformatted(const char* text, const char* text_end = NULL); # doesn't require null terminated string if 'text_end' is specified. no copy done to any bounded stack buffer, recommended for long chunks of text 246 | #void LabelText(const char* label, const char* fmt, ...) IM_PRINTFARGS(2); # display text+label aligned the same way as value+label widgets 247 | #void LabelTextV(const char* label, const char* fmt, va_list args); 248 | #void Bullet(); 249 | #void BulletText(const char* fmt, ...) IM_PRINTFARGS(1); 250 | #void BulletTextV(const char* fmt, va_list args); 251 | #bool Button(const char* label, const ImVec2& size = ImVec2(0,0)); 252 | #bool SmallButton(const char* label); 253 | #bool InvisibleButton(const char* str_id, const ImVec2& size); 254 | #void Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), const ImVec4& tint_col = ImVec4(1,1,1,1), const ImVec4& border_col = ImVec4(0,0,0,0)); 255 | #bool ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0,0,0,0), const ImVec4& tint_col = ImVec4(1,1,1,1)); # <0 frame_padding uses default frame padding settings. 0 for no padding 256 | #bool CollapsingHeader(const char* label, const char* str_id = NULL, bool display_frame = true, bool default_open = false); 257 | #bool Checkbox(const char* label, bool* v); 258 | #bool CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value); 259 | #bool RadioButton(const char* label, bool active); 260 | #bool RadioButton(const char* label, int* v, int v_button); 261 | #bool Combo(const char* label, int* current_item, const char** items, int items_count, int height_in_items = -1); 262 | #bool Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int height_in_items = -1); # separate items with \0, end item-list with \0\0 263 | #bool Combo(const char* label, int* current_item, bool (*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int height_in_items = -1); 264 | #bool ColorButton(const ImVec4& col, bool small_height = false, bool outline_border = true); 265 | #bool ColorEdit3(const char* label, float col[3]); 266 | #bool ColorEdit4(const char* label, float col[4], bool show_alpha = true); 267 | #void ColorEditMode(ImGuiColorEditMode mode); 268 | #void PlotLines(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0), int stride = sizeof(float)); 269 | #void PlotLines(const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0)); 270 | #void PlotHistogram(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0), int stride = sizeof(float)); 271 | #void PlotHistogram(const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0)); 272 | 273 | ## Widgets: Drags (tip: ctrl+click on a drag box to input text) 274 | #bool DragFloat(const char* label, float* v, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", float power = 1.0f); # If v_min >= v_max we have no bound 275 | #bool DragFloat2(const char* label, float v[2], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", float power = 1.0f); 276 | #bool DragFloat3(const char* label, float v[3], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", float power = 1.0f); 277 | #bool DragFloat4(const char* label, float v[4], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", float power = 1.0f); 278 | #bool DragFloatRange2(const char* label, float* v_current_min, float* v_current_max, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f", const char* display_format_max = NULL, float power = 1.0f); 279 | #bool DragInt(const char* label, int* v, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* display_format = "%.0f"); # If v_min >= v_max we have no bound 280 | #bool DragInt2(const char* label, int v[2], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* display_format = "%.0f"); 281 | #bool DragInt3(const char* label, int v[3], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* display_format = "%.0f"); 282 | #bool DragInt4(const char* label, int v[4], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* display_format = "%.0f"); 283 | #bool DragIntRange2(const char* label, int* v_current_min, int* v_current_max, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* display_format = "%.0f", const char* display_format_max = NULL); 284 | 285 | ## Widgets: Input 286 | #bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiTextEditCallback callback = NULL, void* user_data = NULL); 287 | #bool InputTextMultiline(const char* label, char* buf, size_t buf_size, const ImVec2& size = ImVec2(0,0), ImGuiInputTextFlags flags = 0, ImGuiTextEditCallback callback = NULL, void* user_data = NULL); 288 | #bool InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, int decimal_precision = -1, ImGuiInputTextFlags extra_flags = 0); 289 | #bool InputFloat2(const char* label, float v[2], int decimal_precision = -1, ImGuiInputTextFlags extra_flags = 0); 290 | #bool InputFloat3(const char* label, float v[3], int decimal_precision = -1, ImGuiInputTextFlags extra_flags = 0); 291 | #bool InputFloat4(const char* label, float v[4], int decimal_precision = -1, ImGuiInputTextFlags extra_flags = 0); 292 | #bool InputInt(const char* label, int* v, int step = 1, int step_fast = 100, ImGuiInputTextFlags extra_flags = 0); 293 | #bool InputInt2(const char* label, int v[2], ImGuiInputTextFlags extra_flags = 0); 294 | #bool InputInt3(const char* label, int v[3], ImGuiInputTextFlags extra_flags = 0); 295 | #bool InputInt4(const char* label, int v[4], ImGuiInputTextFlags extra_flags = 0); 296 | 297 | ## Widgets: Sliders (tip: ctrl+click on a slider to input text) 298 | #bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f); # adjust display_format to decorate the value with a prefix or a suffix. Use power!=1.0 for logarithmic sliders 299 | #bool SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f); 300 | #bool SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f); 301 | #bool SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f); 302 | #bool SliderAngle(const char* label, float* v_rad, float v_degrees_min = -360.0f, float v_degrees_max = +360.0f); 303 | #bool SliderInt(const char* label, int* v, int v_min, int v_max, const char* display_format = "%.0f"); 304 | #bool SliderInt2(const char* label, int v[2], int v_min, int v_max, const char* display_format = "%.0f"); 305 | #bool SliderInt3(const char* label, int v[3], int v_min, int v_max, const char* display_format = "%.0f"); 306 | #bool SliderInt4(const char* label, int v[4], int v_min, int v_max, const char* display_format = "%.0f"); 307 | #bool VSliderFloat(const char* label, const ImVec2& size, float* v, float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f); 308 | #bool VSliderInt(const char* label, const ImVec2& size, int* v, int v_min, int v_max, const char* display_format = "%.0f"); 309 | 310 | ## Widgets: Trees 311 | #bool TreeNode(const char* str_label_id); # if returning 'true' the node is open and the user is responsible for calling TreePop() 312 | #bool TreeNode(const char* str_id, const char* fmt, ...) IM_PRINTFARGS(2); # " 313 | #bool TreeNode(const void* ptr_id, const char* fmt, ...) IM_PRINTFARGS(2); # " 314 | #bool TreeNodeV(const char* str_id, const char* fmt, va_list args); # " 315 | #bool TreeNodeV(const void* ptr_id, const char* fmt, va_list args); # " 316 | #void TreePush(const char* str_id = NULL); # already called by TreeNode(), but you can call Push/Pop yourself for layouting purpose 317 | #void TreePush(const void* ptr_id = NULL); # " 318 | #void TreePop(); 319 | #void SetNextTreeNodeOpened(bool opened, ImGuiSetCond cond = 0); # set next tree node to be opened. 320 | 321 | ## Widgets: Selectable / Lists 322 | #bool Selectable(const char* label, bool selected = false, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0,0)); # size.x==0.0: use remaining width, size.x>0.0: specify width. size.y==0.0: use label height, size.y>0.0: specify height 323 | #bool Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0,0)); 324 | #bool ListBox(const char* label, int* current_item, const char** items, int items_count, int height_in_items = -1); 325 | #bool ListBox(const char* label, int* current_item, bool (*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int height_in_items = -1); 326 | #bool ListBoxHeader(const char* label, const ImVec2& size = ImVec2(0,0)); # use if you want to reimplement ListBox() will custom data or interactions. make sure to call ListBoxFooter() afterwards. 327 | #bool ListBoxHeader(const char* label, int items_count, int height_in_items = -1); # " 328 | #void ListBoxFooter(); # terminate the scrolling region 329 | 330 | ## Widgets: Value() Helpers. Output single value in "name: value" format (tip: freely declare more in your code to handle your types. you can add functions to the ImGui namespace) 331 | #void Value(const char* prefix, bool b); 332 | #void Value(const char* prefix, int v); 333 | #void Value(const char* prefix, unsigned int v); 334 | #void Value(const char* prefix, float v, const char* float_format = NULL); 335 | #void Color(const char* prefix, const ImVec4& v); 336 | #void Color(const char* prefix, unsigned int v); 337 | 338 | ## Tooltip 339 | #void SetTooltip(const char* fmt, ...) IM_PRINTFARGS(1); # set tooltip under mouse-cursor, typically use with ImGui::IsHovered(). last call wins 340 | #void SetTooltipV(const char* fmt, va_list args); 341 | #void BeginTooltip(); # use to create full-featured tooltip windows that aren't just text 342 | #void EndTooltip(); 343 | 344 | ## Menus 345 | #bool BeginMainMenuBar(); # create and append to a full screen menu-bar. only call EndMainMenuBar() if this returns true! 346 | #void EndMainMenuBar(); 347 | #bool BeginMenuBar(); # append to menu-bar of current window (requires ImGuiWindowFlags_MenuBar flag set). only call EndMenuBar() if this returns true! 348 | #void EndMenuBar(); 349 | #bool BeginMenu(const char* label, bool enabled = true); # create a sub-menu entry. only call EndMenu() if this returns true! 350 | #void EndMenu(); 351 | #bool MenuItem(const char* label, const char* shortcut = NULL, bool selected = false, bool enabled = true); # return true when activated. shortcuts are displayed for convenience but not processed by ImGui at the moment 352 | #bool MenuItem(const char* label, const char* shortcut, bool* p_selected, bool enabled = true); # return true when activated + toggle (*p_selected) if p_selected != NULL 353 | 354 | ## Popup 355 | #void OpenPopup(const char* str_id); # mark popup as open. popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level). close childs popups if any. will close popup when user click outside, or activate a pressable item, or CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block. 356 | #bool BeginPopup(const char* str_id); # return true if popup if opened and start outputting to it. only call EndPopup() if BeginPopup() returned true! 357 | #bool BeginPopupModal(const char* name, bool* p_opened = NULL, ImGuiWindowFlags extra_flags = 0); # modal dialog (can't close them by clicking outside) 358 | #bool BeginPopupContextItem(const char* str_id, int mouse_button = 1); # helper to open and begin popup when clicked on last item 359 | #bool BeginPopupContextWindow(bool also_over_items = true, const char* str_id = NULL, int mouse_button = 1); # helper to open and begin popup when clicked on current window 360 | #bool BeginPopupContextVoid(const char* str_id = NULL, int mouse_button = 1); # helper to open and begin popup when clicked in void (no window) 361 | #void EndPopup(); 362 | #void CloseCurrentPopup(); # close the popup we have begin-ed into. clicking on a MenuItem or Selectable automatically close the current popup. 363 | 364 | ## Logging: all text output from interface is redirected to tty/file/clipboard. Tree nodes are automatically opened. 365 | #void LogToTTY(int max_depth = -1); # start logging to tty 366 | #void LogToFile(int max_depth = -1, const char* filename = NULL); # start logging to file 367 | #void LogToClipboard(int max_depth = -1); # start logging to OS clipboard 368 | #void LogFinish(); # stop logging (close file, etc.) 369 | #void LogButtons(); # helper to display buttons for logging to tty/file/clipboard 370 | #void LogText(const char* fmt, ...) IM_PRINTFARGS(1); # pass text data straight to log (without being displayed) 371 | 372 | ## Utilities 373 | #bool IsItemHovered(); # was the last item hovered by mouse? 374 | #bool IsItemHoveredRect(); # was the last item hovered by mouse? even if another item is active while we are hovering this 375 | #bool IsItemActive(); # was the last item active? (e.g. button being held, text field being edited- items that don't interact will always return false) 376 | #bool IsItemVisible(); # was the last item visible? (aka not out of sight due to clipping/scrolling.) 377 | #bool IsAnyItemHovered(); 378 | #bool IsAnyItemActive(); 379 | #ImVec2 GetItemRectMin(); # get bounding rect of last item in screen space 380 | #ImVec2 GetItemRectMax(); # " 381 | #ImVec2 GetItemRectSize(); # " 382 | #bool IsWindowHovered(); # is current window hovered and hoverable (not blocked by a popup) (differentiate child windows from each others) 383 | #bool IsWindowFocused(); # is current window focused 384 | #bool IsRootWindowFocused(); # is current root window focused (top parent window in case of child windows) 385 | #bool IsRootWindowOrAnyChildFocused(); # is current root window or any of its child (including current window) focused 386 | #bool IsRectVisible(const ImVec2& size); # test if rectangle of given size starting from cursor pos is visible (not clipped). to perform coarse clipping on user's side (as an optimization) 387 | #bool IsPosHoveringAnyWindow(const ImVec2& pos); # is given position hovering any active imgui window 388 | #float GetTime(); 389 | #int GetFrameCount(); 390 | #const char* GetStyleColName(ImGuiCol idx); 391 | #ImVec2 CalcItemRectClosestPoint(const ImVec2& pos, bool on_edge = false, float outward = +0.0f); # utility to find the closest point the last item bounding rectangle edge. useful to visually link items 392 | #ImVec2 CalcTextSize(const char* text, const char* text_end = NULL, bool hide_text_after_double_hash = false, float wrap_width = -1.0f); 393 | #void CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end); # calculate coarse clipping for large list of evenly sized items. Prefer using the ImGuiListClipper higher-level helper if you can. 394 | 395 | #bool BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags extra_flags = 0); # helper to create a child window / scrolling region that looks like a normal widget frame 396 | #void EndChildFrame(); 397 | 398 | #ImVec4 ColorConvertU32ToFloat4(ImU32 in); 399 | #ImU32 ColorConvertFloat4ToU32(const ImVec4& in); 400 | #void ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& out_s, float& out_v); 401 | #void ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b); 402 | 403 | ## Inputs 404 | #int GetKeyIndex(ImGuiKey key); # map ImGuiKey_* values into user's key index. == io.KeyMap[key] 405 | #bool IsKeyDown(int key_index); # key_index into the keys_down[] array, imgui doesn't know the semantic of each entry, uses your own indices! 406 | #bool IsKeyPressed(int key_index, bool repeat = true); # uses user's key indices as stored in the keys_down[] array. if repeat=true. uses io.KeyRepeatDelay / KeyRepeatRate 407 | #bool IsKeyReleased(int key_index); # " 408 | #bool IsMouseDown(int button); # is mouse button held 409 | #bool IsMouseClicked(int button, bool repeat = false); # did mouse button clicked (went from !Down to Down) 410 | #bool IsMouseDoubleClicked(int button); # did mouse button double-clicked. a double-click returns false in IsMouseClicked(). uses io.MouseDoubleClickTime. 411 | #bool IsMouseReleased(int button); # did mouse button released (went from Down to !Down) 412 | #bool IsMouseHoveringWindow(); # is mouse hovering current window ("window" in API names always refer to current window). disregarding of any consideration of being blocked by a popup. (unlike IsWindowHovered() this will return true even if the window is blocked because of a popup) 413 | #bool IsMouseHoveringAnyWindow(); # is mouse hovering any visible window 414 | #bool IsMouseHoveringRect(const ImVec2& pos_min, const ImVec2& pos_max, bool clip = true); # is mouse hovering given bounding rect (in screen space). clipped by current clipping settings. disregarding of consideration of focus/window ordering/blocked by a popup. 415 | #bool IsMouseDragging(int button = 0, float lock_threshold = -1.0f); # is mouse dragging. if lock_threshold < -1.0f uses io.MouseDraggingThreshold 416 | #ImVec2 GetMousePos(); # shortcut to ImGui::GetIO().MousePos provided by user, to be consistent with other calls 417 | #ImVec2 GetMousePosOnOpeningCurrentPopup(); # retrieve backup of mouse positioning at the time of opening popup we have BeginPopup() into 418 | #ImVec2 GetMouseDragDelta(int button = 0, float lock_threshold = -1.0f); # dragging amount since clicking. if lock_threshold < -1.0f uses io.MouseDraggingThreshold 419 | #void ResetMouseDragDelta(int button = 0); # 420 | #ImGuiMouseCursor GetMouseCursor(); # get desired cursor type, reset in ImGui::NewFrame(), this updated during the frame. valid before Render(). If you use software rendering by setting io.MouseDrawCursor ImGui will render those for you 421 | #void SetMouseCursor(ImGuiMouseCursor type); # set desired cursor type 422 | #void CaptureKeyboardFromApp(); # manually enforce imgui setting the io.WantCaptureKeyboard flag next frame (your application needs to handle it). e.g. capture keyboard when your widget is being hovered. 423 | #void CaptureMouseFromApp(); # manually enforce imgui setting the io.WantCaptureMouse flag next frame (your application needs to handle it). 424 | 425 | ## Helpers functions to access functions pointers in ImGui::GetIO() 426 | #void* MemAlloc(size_t sz); 427 | #void MemFree(void* ptr); 428 | #const char* GetClipboardText(); 429 | #void SetClipboardText(const char* text); 430 | 431 | ## Internal state/context access - if you want to use multiple ImGui context, or share context between modules (e.g. DLL), or allocate the memory yourself 432 | #const char* GetVersion(); 433 | #void* GetInternalState(); 434 | #size_t GetInternalStateSize(); 435 | #void SetInternalState(void* state, bool construct = false); 436 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | CyImGui 2 | ======= 3 | 4 | Python bindings for ImGui using Cython, heavily under construction help 5 | desired urgently. 6 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from distutils.core import setup, Extension 3 | from Cython.Build import cythonize 4 | 5 | setup( 6 | name='cyimgui', 7 | ext_modules = cythonize('pyimgui/imgui.pyx', gdb_debug=True) 8 | ) 9 | -------------------------------------------------------------------------------- /tests/test_import.py: -------------------------------------------------------------------------------- 1 | def test_import(): 2 | import imgui 3 | -------------------------------------------------------------------------------- /tests/test_io.py: -------------------------------------------------------------------------------- 1 | import imgui 2 | 3 | def test_getting_and_setting_display_size(): 4 | io = imgui.get_io() 5 | io.display_size = (1.0, 2.0) 6 | assert io.display_size == (1.0, 2.0) 7 | assert io.display_size == imgui.get_io().display_size 8 | 9 | --------------------------------------------------------------------------------