Compare commits

..

46 Commits
v1.08 ... v1.11

Author SHA1 Message Date
24028911e3 Added version number in sources 2014-09-10 12:26:12 +01:00
3fd68c3a31 Fixed file-descriptor leak if ImBitmapFont::LoadFromFile() calls to seek/tell fails. 2014-09-10 12:21:38 +01:00
1cf4b313e2 Update README.md 2014-09-10 11:35:34 +01:00
2e85dce1ee Added #define IMGUI_INCLUDE_IMGUI_USER_CPP to optionally include imgui_user.cpp 2014-09-10 11:22:01 +01:00
62d233aaab Added extra_flags parameters to InputInt(), InputFloat(). Used in example code. Commented out broken ImGuiInputTextFlags_AlignCenter. 2014-09-08 16:50:09 +01:00
3cdb4fa456 Merge pull request #44 from xythobuz/master
Added ImGuiInputTextFlags_EnterReturnsTrue
2014-09-08 16:37:16 +01:00
7439df0ba1 Added ImGuiInputTextFlags_EnterReturnsTrue 2014-09-08 15:48:39 +02:00
ad42787543 Made radio button render ascii when logged into tty/file/clipboard 2014-09-02 14:36:03 +01:00
91059da1a5 Added more comments in the code. 2014-09-02 14:35:06 +01:00
b420a51541 Update README.md
Fixed typos, reworded sentence.
2014-09-02 10:59:14 +01:00
c07ab1b56a Minor tweaks to "Memory override" pull request 2014-08-31 12:02:22 +01:00
22a9555a99 Merge branch 'pr/40' 2014-08-31 11:54:45 +01:00
25080d53e5 Memory override #3 2014-08-31 14:58:21 +04:30
43448d9c89 Added FAQ/comments 2014-08-31 08:23:55 +01:00
e20077fbd0 Using spaces instead of tab for web readability 2014-08-30 20:06:53 +01:00
2c677c45c7 Added sample fonts data 2014-08-30 20:02:55 +01:00
3b339efeb2 Added IO.FontYOffset. Added asserts. 2014-08-30 20:02:10 +01:00
8fc50f5ed3 Remove IO.FontHeight, cached automatically. Added assertions. 2014-08-30 18:43:26 +01:00
dd5d251273 Added SetCursorPosX, SetCursorPosY shortcuts 2014-08-29 13:36:31 +01:00
2fb63b6068 Checkbox() return true when pressed 2014-08-28 17:32:03 +01:00
cd3d027df0 Delete obsolete comments in imconfig.h 2014-08-28 14:54:22 +01:00
7adad71042 Moved IMGUI_FONT_TEX_UV_FOR_WHITE define to a variable so font can be changed at runtime 2014-08-28 14:53:41 +01:00
88c33ecc29 Fixes to allow clean 1-pixel thick lines in more use cases. PixelCenterOffset not the same as previously! 2014-08-28 14:52:10 +01:00
1f63e01cc6 Minor fixes to scrollbar rendering, close button and made checkbox/radio button padding more consistent. 2014-08-27 22:16:55 +01:00
bd26de0628 Collapse triangle don't have a shadow unless borders are enabled.
Fixed cross that appears when hovering window close button to be perfectly 45 degrees.
2014-08-27 17:54:11 +01:00
5a9639b423 Fixed collapsing header border (if borders are enabled) being off the clip rectangle.
Tweak demo window.
2014-08-27 11:38:26 +01:00
b90d0c558d Minor text alignment 2014-08-26 19:22:09 +01:00
51f8e33eb4 Added FAQ entry 2014-08-26 18:29:58 +01:00
80dd1e1065 Added comments 2014-08-26 18:27:10 +01:00
5f6b261c9b Fixed uninitialised fields in ImBitmapFont (were unused when uninitialised, but still dodgy) 2014-08-26 18:14:04 +01:00
681ac5f777 Fixed size/padding of slider grab box for vertical symetry (was 1 pixel too high) 2014-08-26 16:56:20 +01:00
0d344e1f03 Merge pull request #34 from orbitcowboy/master
Do not update a variable, which is not used.
2014-08-26 14:28:40 +01:00
d2b43f31e3 Updated URL to new ProggyFonts site 2014-08-25 17:27:42 +01:00
addfa75eb0 Do not update a variable, which is not used. 2014-08-24 07:32:27 +02:00
aa7fc37b37 removed malloc/free proxy fwd declares 2014-08-18 16:19:11 +04:30
c13c2449bb removed libimgui.pro 2014-08-18 16:09:47 +04:30
c2cb727ac9 memory override attempt #2 2014-08-18 16:08:03 +04:30
47fd8431c1 minor fixes 2014-08-18 13:19:35 +04:30
ef628a0a9d argh, removed redundent defines 2014-08-16 13:35:44 +04:30
df5a06f119 removed memory pools, they dont apply well 2014-08-16 13:34:45 +04:30
e9b697698a fixed a typo 2014-08-16 13:12:24 +04:30
5240013c90 merge with upstream 2014-08-16 13:00:39 +04:30
1956703c42 First attempt at memory management 2014-08-16 12:58:29 +04:30
6d6ee4e1f1 revert back to original 2014-08-14 19:21:01 +04:30
e9b0a61f48 :w
a
A
A
A
A
A
A
B
B
B
B
B
B
B
B
B
B
D
D
merged with upste
Merge remote-tracking branch 'upstream/master'
2014-08-14 18:59:08 +04:30
e3001fb986 project update 2014-08-11 20:43:24 +04:30
19 changed files with 466 additions and 211 deletions

View File

@ -34,11 +34,16 @@ Frequently Asked Question
------------------------- -------------------------
<b>How do you use ImGui on a platform that may not have a mouse and keyboard?</b> <b>How do you use ImGui on a platform that may not have a mouse and keyboard?</b>
I recommend using [Synergy](http://synergy-project.org) and the uSynergy.c micro client to share your mouse and keyboard. This way you can seemingly use your PC input devices on a video game console or a tablet. ImGui was also designed to function with touch inputs if you increase the padding of widgets to compensate for the lack of precision of touch devices, but it is recommended you use a mouse to allow optimising for screen real-estate. I recommend using [Synergy](http://synergy-project.org). With the uSynergy.c micro client running you can seamlessly use your PC input devices from a video game console or a tablet. ImGui was also designed to function with touch inputs if you increase the padding of widgets to compensate for the lack of precision of touch devices, but it is recommended you use a mouse to allow optimising for screen real-estate.
<b>I integrated ImGui in my engine and the text or lines are blurry..</b>
- Try adjusting ImGui::GetIO().PixelCenterOffset to 0.0f or 0.5f.
- In your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f).
<b>Can you create elaborate/serious tools with ImGui?</b> <b>Can you create elaborate/serious tools with ImGui?</b>
Yes. I have written data browsers, debuggers, profilers and all sort of non-trivial tools with the library. There's no reason you cannot, and in my experience the simplicity of the API is very empowering. However note that ImGui is very programmer centric and the immediate-mode GUI paradigm might requires a bit of adaptation before you can realize its full potential. Yes. I have written data browsers, debuggers, profilers and all sort of non-trivial tools with the library. There's no reason you cannot, and in my experience the simplicity of the API is very empowering. However note that ImGui is programmer centric and the immediate-mode GUI paradigm might requires a bit of adaptation before you can realize its full potential.
<b>Can you reskin the look of ImGui?</b> <b>Can you reskin the look of ImGui?</b>
@ -46,13 +51,17 @@ Yes, you can alter the look of the interface to some degree: changing colors, si
![skinning screenshot 1](/web/skinning_sample_01.png?raw=true) ![skinning screenshot 1](/web/skinning_sample_01.png?raw=true)
<b>Can you develop features xxxx for ImGui?</b>
Please use GitHub 'Issues' facilities to suggest and discuss improvements. If you are company and would like specific non-trivial features to be implemented, I am available for hire to work on or with ImGui. Donations are also welcome to support further work on the library.
Credits Credits
------- -------
Developed by [Omar Cornut](http://www.miracleworld.net). The library was developed with the support of [Media Molecule](http://www.mediamolecule.com) and first used internally on the game [Tearaway](http://tearaway.mediamolecule.com). Developed by [Omar Cornut](http://www.miracleworld.net). The library was developed with the support of [Media Molecule](http://www.mediamolecule.com) and first used internally on the game [Tearaway](http://tearaway.mediamolecule.com).
Embeds [proggy_clean](http://www.proggyfonts.net/) font by Tristan Grimmer (also MIT license). Embeds [proggy_clean](http://upperbounds.net) font by Tristan Grimmer (also MIT license).
Inspiration, feedback, and testing: Casey Muratori, Atman Binstock, Mikko Mononen, Emmanuel Briney, Stefan Kamoda, Anton Mikhailov, Matt Willis. Thanks! Inspiration, feedback, and testing: Casey Muratori, Atman Binstock, Mikko Mononen, Emmanuel Briney, Stefan Kamoda, Anton Mikhailov, Matt Willis. Thanks!

View File

@ -20,7 +20,10 @@ struct CUSTOMVERTEX
}; };
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1) #define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1)
// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structuer) // This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
// If text or lines are blurry when integrating ImGui in your engine:
// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
// - try adjusting ImGui::GetIO().PixelCenterOffset to 0.5f or 0.375f
static void ImImpl_RenderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_count) static void ImImpl_RenderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_count)
{ {
size_t total_vtx_count = 0; size_t total_vtx_count = 0;
@ -79,7 +82,7 @@ static void ImImpl_RenderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_c
D3DXMatrixIdentity(&mat); D3DXMatrixIdentity(&mat);
g_pd3dDevice->SetTransform(D3DTS_WORLD, &mat); g_pd3dDevice->SetTransform(D3DTS_WORLD, &mat);
g_pd3dDevice->SetTransform(D3DTS_VIEW, &mat); g_pd3dDevice->SetTransform(D3DTS_VIEW, &mat);
D3DXMatrixOrthoOffCenterLH(&mat, 0.0f, ImGui::GetIO().DisplaySize.x, ImGui::GetIO().DisplaySize.y, 0.0f, -1.0f, +1.0f); D3DXMatrixOrthoOffCenterLH(&mat, 0.5f, ImGui::GetIO().DisplaySize.x+0.5f, ImGui::GetIO().DisplaySize.y+0.5f, 0.5f, -1.0f, +1.0f);
g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &mat); g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &mat);
// Render command lists // Render command lists

View File

@ -11,14 +11,17 @@
static GLFWwindow* window; static GLFWwindow* window;
static GLuint fontTex; static GLuint fontTex;
// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structuer) // This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
// We are using the fixed pipeline. // If text or lines are blurry when integrating ImGui in your engine:
// A faster way would be to collate all vertices from all cmd_lists into a single vertex buffer // - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
// - try adjusting ImGui::GetIO().PixelCenterOffset to 0.5f or 0.375f
static void ImImpl_RenderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_count) static void ImImpl_RenderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_count)
{ {
if (cmd_lists_count == 0) if (cmd_lists_count == 0)
return; return;
// We are using the OpenGL fixed pipeline to make the example code simpler to read!
// A probable faster way to render would be to collate all vertices from all cmd_lists into a single vertex buffer.
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers. // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers.
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@ -146,10 +149,10 @@ void InitImGui()
glfwGetWindowSize(window, &w, &h); glfwGetWindowSize(window, &w, &h);
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
io.DisplaySize = ImVec2((float)w, (float)h); // Display size, in pixels. For clamping windows positions. io.DisplaySize = ImVec2((float)w, (float)h); // Display size, in pixels. For clamping windows positions.
io.DeltaTime = 1.0f/60.0f; // Time elapsed since last frame, in seconds (in this sample app we'll override this every frame because our timestep is variable) io.DeltaTime = 1.0f/60.0f; // Time elapsed since last frame, in seconds (in this sample app we'll override this every frame because our timestep is variable)
io.PixelCenterOffset = 0.5f; // Align OpenGL texels io.PixelCenterOffset = 0.0f; // Align OpenGL texels
io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array. io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT; io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT;
io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT; io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT;
io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP; io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP;

BIN
extra_fonts/ProggyClean.zip Normal file

Binary file not shown.

BIN
extra_fonts/ProggySmall.zip Normal file

Binary file not shown.

71
extra_fonts/README.txt Normal file
View File

@ -0,0 +1,71 @@
Extra fonts for ImGui.
THOSE FONTS ARE OPTIONAL.
ImGui embeds a copy of 'proggy_clean' that you can use without any external files.
Export your own font with bmfont (www.angelcode.com/products/bmfont).
bmfont reads fonts (.ttf, .fon, etc.) and output a .fnt file and a texture file, e.g:
proggy_clean.fon --> [bmfont] ---> proggy_clean_13.fnt
proggy_clean_13.png
Configure bmfont:
- Export .fnt as Binary
- Tip: uncheck "Render from TrueType outline" and "Font Smoothing" for best result with non-anti-aliased type fonts.
But you can experiment with other settings if you want anti-aliased fonts.
(A) Use font data embedded in ImGui
// Access embedded font data
const void* fnt_data; // pointer to FNT data
unsigned fnt_size; // size of FNT data
const void* png_data; // pointer to PNG data
unsigned int png_size; // size of PNG data
ImGui::GetDefaultFontData(&fnt_data, &fnt_size, &png_data, &png_size);
1. Load the .FNT data from 'fnt_data' (NB: this is done for you by default if you don't do anything)
ImGuiIO& io = ImGui::GetIO();
io.Font = new ImBitmapFont();
io.Font->LoadFromMemory(fnt_data, fnt_size);
2. Load the .PNG data from 'png_data' into a texture
(B) Use fonts from external files
ImGuiIO& io = ImGui::GetIO();
1. Load the .FNT data, e.g.
// proggy_clean_13 [default]
io.Font->LoadFromFile("proggy_clean_13.fnt");
io.FontTexUvForWhite = ImVec2(0.0f/256.0f,0.0f/128);
io.FontYOffset = +1;
// proggy_small_12
io.Font = new ImBitmapFont();
io.Font->LoadFromFile("proggy_small_12.fnt");
io.FontTexUvForWhite = ImVec2(84.0f/256.0f,20.0f/64);
io.FontYOffset = +2;
// proggy_small_14
io.Font = new ImBitmapFont();
io.Font->LoadFromFile("proggy_small_14.fnt");
io.FontTexUvForWhite = ImVec2(84.0f/256.0f,20.0f/64);
io.FontYOffset = +3;
// courier_new_16
io.Font->LoadFromFile("courier_new_16.fnt");
io.FontTexUvForWhite = ImVec2(1.0f/256.0f,4.0f/128);
// courier_new_18
io.Font->LoadFromFile("courier_new_18.fnt");
io.FontTexUvForWhite = ImVec2(4.0f/256.0f,5.0f/256);
2. Load the matching .PNG data into a texture

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 949 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 949 B

View File

@ -4,6 +4,11 @@
#pragma once #pragma once
//---- Define your own malloc/free/realloc functions if you want to override internal memory allocations for ImGui
//#define IM_MALLOC(_SIZE) MyMalloc(_SIZE) // void* MyMalloc(size_t size);
//#define IM_FREE(_PTR) MyFree(_PTR) // void MyFree(void *ptr);
//#define IM_REALLOC(_PTR, _SIZE) MyRealloc(_PTR, _SIZE) // void* MyRealloc(void *ptr, size_t size);
//---- Define your own ImVector<> type if you don't want to use the provided implementation defined in imgui.h //---- Define your own ImVector<> type if you don't want to use the provided implementation defined in imgui.h
//#include <vector> //#include <vector>
//#define ImVector std::vector //#define ImVector std::vector
@ -15,9 +20,8 @@
//---- Don't implement default clipboard handlers for Windows (so as not to link with OpenClipboard(), etc.) //---- Don't implement default clipboard handlers for Windows (so as not to link with OpenClipboard(), etc.)
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS //#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS
//---- If you are loading a custom font, ImGui expect to find a pure white pixel at (0,0) //---- Include imgui_user.cpp at the end of imgui.cpp so you can include code that extends ImGui using its private data/functions.
// Change it's UV coordinate here if you can't have a white pixel at (0,0) //#define IMGUI_INCLUDE_IMGUI_USER_CPP
//#define IMGUI_FONT_TEX_UV_FOR_WHITE ImVec2(0.f/256.f,0.f/256.f)
//---- Define implicit cast operators to convert back<>forth from your math types and ImVec2/ImVec4. //---- Define implicit cast operators to convert back<>forth from your math types and ImVec2/ImVec4.
/* /*
@ -39,3 +43,4 @@ namespace ImGui
void Value(const char* prefix, const MyVec4& v, const char* float_format = NULL); void Value(const char* prefix, const MyVec4& v, const char* float_format = NULL);
}; };
*/ */

481
imgui.cpp

File diff suppressed because it is too large Load Diff

75
imgui.h
View File

@ -1,4 +1,4 @@
// ImGui library // ImGui library v1.11
// See .cpp file for commentary. // See .cpp file for commentary.
// See ImGui::ShowTestWindow() for sample code. // See ImGui::ShowTestWindow() for sample code.
// Read 'Programmer guide' in .cpp for notes on how to setup ImGui in your codebase. // Read 'Programmer guide' in .cpp for notes on how to setup ImGui in your codebase.
@ -17,7 +17,19 @@ struct ImGuiWindow;
#include "imconfig.h" #include "imconfig.h"
#include <float.h> // FLT_MAX #include <float.h> // FLT_MAX
#include <stdarg.h> // va_list #include <stdarg.h> // va_list
#include <stdlib.h> // NULL #include <stdlib.h> // NULL, malloc
#ifndef IM_MALLOC
#define IM_MALLOC(_SIZE) malloc((_SIZE))
#endif
#ifndef IM_FREE
#define IM_FREE(_PTR) free((_PTR))
#endif
#ifndef IM_REALLOC
#define IM_REALLOC(_PTR, _SIZE) realloc((_PTR), (_SIZE))
#endif
#ifndef IM_ASSERT #ifndef IM_ASSERT
#include <assert.h> #include <assert.h>
@ -72,7 +84,7 @@ public:
typedef const value_type* const_iterator; typedef const value_type* const_iterator;
ImVector() { Size = Capacity = 0; Data = NULL; } ImVector() { Size = Capacity = 0; Data = NULL; }
~ImVector() { if (Data) free(Data); } ~ImVector() { if (Data) IM_FREE(Data); }
inline bool empty() const { return Size == 0; } inline bool empty() const { return Size == 0; }
inline size_t size() const { return Size; } inline size_t size() const { return Size; }
@ -83,7 +95,7 @@ public:
inline value_type& operator[](size_t i) { IM_ASSERT(i < Size); return Data[i]; } inline value_type& operator[](size_t i) { IM_ASSERT(i < Size); return Data[i]; }
inline const value_type& operator[](size_t i) const { IM_ASSERT(i < Size); return Data[i]; } inline const value_type& operator[](size_t i) const { IM_ASSERT(i < Size); return Data[i]; }
inline void clear() { if (Data) { Size = Capacity = 0; free(Data); Data = NULL; } } inline void clear() { if (Data) { Size = Capacity = 0; IM_FREE(Data); Data = NULL; } }
inline iterator begin() { return Data; } inline iterator begin() { return Data; }
inline const_iterator begin() const { return Data; } inline const_iterator begin() const { return Data; }
inline iterator end() { return Data + Size; } inline iterator end() { return Data + Size; }
@ -94,7 +106,7 @@ public:
inline const value_type& back() const { IM_ASSERT(Size > 0); return at(Size-1); } inline const value_type& back() const { IM_ASSERT(Size > 0); return at(Size-1); }
inline void swap(ImVector<T>& rhs) { const size_t rhs_size = rhs.Size; rhs.Size = Size; Size = rhs_size; const size_t rhs_cap = rhs.Capacity; rhs.Capacity = Capacity; Capacity = rhs_cap; value_type* rhs_data = rhs.Data; rhs.Data = Data; Data = rhs_data; } inline void swap(ImVector<T>& rhs) { const size_t rhs_size = rhs.Size; rhs.Size = Size; Size = rhs_size; const size_t rhs_cap = rhs.Capacity; rhs.Capacity = Capacity; Capacity = rhs_cap; value_type* rhs_data = rhs.Data; rhs.Data = Data; Data = rhs_data; }
inline void reserve(size_t new_capacity) { Data = (value_type*)realloc(Data, new_capacity * sizeof(value_type)); Capacity = new_capacity; } inline void reserve(size_t new_capacity) { Data = (value_type*)IM_REALLOC(Data, new_capacity * sizeof(value_type)); Capacity = new_capacity; }
inline void resize(size_t new_size) { if (new_size > Capacity) reserve(new_size); Size = new_size; } inline void resize(size_t new_size) { if (new_size > Capacity) reserve(new_size); Size = new_size; }
inline void push_back(const value_type& v) { if (Size == Capacity) reserve(Capacity ? Capacity * 2 : 4); Data[Size++] = v; } inline void push_back(const value_type& v) { if (Size == Capacity) reserve(Capacity ? Capacity * 2 : 4); Data[Size++] = v; }
@ -133,16 +145,16 @@ namespace ImGui
void BeginChild(const char* str_id, ImVec2 size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0); void BeginChild(const char* str_id, ImVec2 size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0);
void EndChild(); void EndChild();
bool GetWindowIsFocused(); bool GetWindowIsFocused();
float GetWindowWidth();
ImVec2 GetWindowPos(); // you should rarely need/care about the window position, but it can be useful if you want to use your own drawing
void SetWindowPos(const ImVec2& pos); // set current window pos
ImVec2 GetWindowSize(); ImVec2 GetWindowSize();
float GetWindowWidth();
ImVec2 GetWindowPos(); // you should rarely need/care about the window position, but it can be useful if you want to use your own drawing.
void SetWindowPos(const ImVec2& pos); // set current window pos.
ImVec2 GetWindowContentRegionMin(); ImVec2 GetWindowContentRegionMin();
ImVec2 GetWindowContentRegionMax(); ImVec2 GetWindowContentRegionMax();
ImDrawList* GetWindowDrawList(); ImDrawList* GetWindowDrawList(); // get rendering command-list if you want to append your own draw primitives.
void SetFontScale(float scale); void SetFontScale(float scale);
void SetScrollPosHere(); void SetScrollPosHere(); // adjust scrolling position to center into the current cursor position.
void SetTreeStateStorage(ImGuiStorage* tree); void SetTreeStateStorage(ImGuiStorage* tree); // replace tree state storage with our own (if you want to manipulate it yourself, typically clear subsection of it).
ImGuiStorage* GetTreeStateStorage(); ImGuiStorage* GetTreeStateStorage();
void PushItemWidth(float item_width); void PushItemWidth(float item_width);
void PopItemWidth(); void PopItemWidth();
@ -154,7 +166,7 @@ namespace ImGui
// Tooltip // Tooltip
void SetTooltip(const char* fmt, ...); // set tooltip under mouse-cursor, typically use with ImGui::IsHovered(). last call wins. void SetTooltip(const char* fmt, ...); // set tooltip under mouse-cursor, typically use with ImGui::IsHovered(). last call wins.
void BeginTooltip(); // use to create full-featured tooltip windows that aren't just text. void BeginTooltip(); // use to create full-featured tooltip windows that aren't just text.
void EndTooltip(); void EndTooltip();
// Layout // Layout
@ -168,8 +180,10 @@ namespace ImGui
float GetColumnWidth(int column_index = -1); float GetColumnWidth(int column_index = -1);
ImVec2 GetCursorPos(); // cursor position relative to window position ImVec2 GetCursorPos(); // cursor position relative to window position
void SetCursorPos(const ImVec2& pos); // " void SetCursorPos(const ImVec2& pos); // "
void SetCursorPosX(float x); // "
void SetCursorPosY(float y); // "
ImVec2 GetCursorScreenPos(); // cursor position in screen space ImVec2 GetCursorScreenPos(); // cursor position in screen space
void AlignFirstTextHeightToWidgets(); // call once if the first item on the line is a Text() item and you want to vertically lower it to match higher widgets. 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.
float GetTextLineSpacing(); float GetTextLineSpacing();
float GetTextLineHeight(); float GetTextLineHeight();
@ -189,7 +203,7 @@ namespace ImGui
bool Button(const char* label, ImVec2 size = ImVec2(0,0), bool repeat_when_held = false); bool Button(const char* label, ImVec2 size = ImVec2(0,0), bool repeat_when_held = false);
bool SmallButton(const char* label); bool SmallButton(const char* label);
bool CollapsingHeader(const char* label, const char* str_id = NULL, const bool display_frame = true, const bool default_open = false); bool CollapsingHeader(const char* label, const char* str_id = NULL, const bool display_frame = true, const bool default_open = false);
bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f); 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.
bool SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f); bool SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
bool SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f); bool SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
bool SliderFloat4(const char* label, float v[3], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f); bool SliderFloat4(const char* label, float v[3], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
@ -197,16 +211,16 @@ namespace ImGui
bool SliderInt(const char* label, int* v, int v_min, int v_max, const char* display_format = "%.0f"); bool SliderInt(const char* label, int* v, int v_min, int v_max, const char* display_format = "%.0f");
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), size_t stride = sizeof(float)); 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), size_t stride = sizeof(float));
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), size_t stride = sizeof(float)); 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), size_t stride = sizeof(float));
void Checkbox(const char* label, bool* v); bool Checkbox(const char* label, bool* v);
void CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value); bool CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value);
bool RadioButton(const char* label, bool active); bool RadioButton(const char* label, bool active);
bool RadioButton(const char* label, int* v, int v_button); bool RadioButton(const char* label, int* v, int v_button);
bool InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, int decimal_precision = -1); bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0);
bool InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, int decimal_precision = -1, ImGuiInputTextFlags extra_flags = 0);
bool InputFloat2(const char* label, float v[2], int decimal_precision = -1); bool InputFloat2(const char* label, float v[2], int decimal_precision = -1);
bool InputFloat3(const char* label, float v[3], int decimal_precision = -1); bool InputFloat3(const char* label, float v[3], int decimal_precision = -1);
bool InputFloat4(const char* label, float v[4], int decimal_precision = -1); bool InputFloat4(const char* label, float v[4], int decimal_precision = -1);
bool InputInt(const char* label, int* v, int step = 1, int step_fast = 100); bool InputInt(const char* label, int* v, int step = 1, int step_fast = 100, ImGuiInputTextFlags extra_flags = 0);
bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0);
bool Combo(const char* label, int* current_item, const char** items, int items_count, int popup_height_items = 7); bool Combo(const char* label, int* current_item, const char** items, int items_count, int popup_height_items = 7);
bool Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int popup_height_items = 7); // Separate items with \0, end item-list with \0\0 bool Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int popup_height_items = 7); // Separate items with \0, end item-list with \0\0
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 popup_height_items = 7); 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 popup_height_items = 7);
@ -214,10 +228,10 @@ namespace ImGui
bool ColorEdit3(const char* label, float col[3]); bool ColorEdit3(const char* label, float col[3]);
bool ColorEdit4(const char* label, float col[4], bool show_alpha = true); bool ColorEdit4(const char* label, float col[4], bool show_alpha = true);
void ColorEditMode(ImGuiColorEditMode mode); void ColorEditMode(ImGuiColorEditMode mode);
bool TreeNode(const char* str_label_id); // if returning 'true' the user is responsible for calling TreePop bool TreeNode(const char* str_label_id); // if returning 'true' the node is open and the user is responsible for calling TreePop
bool TreeNode(const char* str_id, const char* fmt, ...); // " bool TreeNode(const char* str_id, const char* fmt, ...); // "
bool TreeNode(const void* ptr_id, const char* fmt, ...); // " bool TreeNode(const void* ptr_id, const char* fmt, ...); // "
void TreePush(const char* str_id = NULL); // already called by TreeNode(), but you can call Push/Pop yourself for layout purpose void TreePush(const char* str_id = NULL); // already called by TreeNode(), but you can call Push/Pop yourself for layouting purpose
void TreePush(const void* ptr_id = NULL); // " void TreePush(const void* ptr_id = NULL); // "
void TreePop(); void TreePop();
void OpenNextNode(bool open); // force open/close the next TreeNode or CollapsingHeader void OpenNextNode(bool open); // force open/close the next TreeNode or CollapsingHeader
@ -276,10 +290,11 @@ enum ImGuiWindowFlags_
enum ImGuiInputTextFlags_ enum ImGuiInputTextFlags_
{ {
// Default: 0 // Default: 0
ImGuiInputTextFlags_CharsDecimal = 1 << 0, ImGuiInputTextFlags_CharsDecimal = 1 << 0, // Allow 0123456789.+-*/
ImGuiInputTextFlags_CharsHexadecimal = 1 << 1, ImGuiInputTextFlags_CharsHexadecimal = 1 << 1, // Allow 0123456789ABCDEFabcdef
ImGuiInputTextFlags_AutoSelectAll = 1 << 2, ImGuiInputTextFlags_AutoSelectAll = 1 << 2, // Select entire text when first taking focus
ImGuiInputTextFlags_AlignCenter = 1 << 3, ImGuiInputTextFlags_EnterReturnsTrue = 1 << 3, // Return 'true' when Enter is pressed (as opposed to when the value was modified)
//ImGuiInputTextFlags_AlignCenter = 1 << 3,
}; };
// User fill ImGuiIO.KeyMap[] array with indices into the ImGuiIO.KeysDown[512] array // User fill ImGuiIO.KeyMap[] array with indices into the ImGuiIO.KeysDown[512] array
@ -389,9 +404,10 @@ struct ImGuiIO
float MouseDoubleClickMaxDist; // = 6.0f // Distance threshold to stay in to validate a double-click, in pixels. float MouseDoubleClickMaxDist; // = 6.0f // Distance threshold to stay in to validate a double-click, in pixels.
int KeyMap[ImGuiKey_COUNT]; // <unset> // Map of indices into the KeysDown[512] entries array int KeyMap[ImGuiKey_COUNT]; // <unset> // Map of indices into the KeysDown[512] entries array
ImFont Font; // <auto> // Gets passed to text functions. Typedef ImFont to the type you want (ImBitmapFont* or your own font). ImFont Font; // <auto> // Gets passed to text functions. Typedef ImFont to the type you want (ImBitmapFont* or your own font).
float FontHeight; // <auto> // Default font height, must be the vertical distance between two lines of text, aka == CalcTextSize(" ").y float FontYOffset; // = 0.0f // Offset font rendering by xx pixels in Y axis.
ImVec2 FontTexUvForWhite; // = (0.0f,0.0f) // Font texture must have a white pixel at this UV coordinate. Adjust if you are using custom texture.
bool FontAllowScaling; // = false // Set to allow scaling text with CTRL+Wheel. bool FontAllowScaling; // = false // Set to allow scaling text with CTRL+Wheel.
float PixelCenterOffset; // = 0.5f // Set to 0.0f for DirectX <= 9, 0.5f for Direct3D >= 10 and OpenGL. float PixelCenterOffset; // = 0.0f // Try to set to 0.5f or 0.375f if rendering is blurry
// Settings - Rendering function (REQUIRED) // Settings - Rendering function (REQUIRED)
// See example code if you are unsure of how to implement this. // See example code if you are unsure of how to implement this.
@ -524,10 +540,6 @@ struct ImDrawCmd
ImVec4 clip_rect; ImVec4 clip_rect;
}; };
#ifndef IMGUI_FONT_TEX_UV_FOR_WHITE
#define IMGUI_FONT_TEX_UV_FOR_WHITE ImVec2(0.f,0.f)
#endif
// sizeof() == 20 // sizeof() == 20
struct ImDrawVert struct ImDrawVert
{ {
@ -643,6 +655,7 @@ struct ImBitmapFont
void BuildLookupTable(); void BuildLookupTable();
const FntGlyph * FindGlyph(unsigned short c) const; const FntGlyph * FindGlyph(unsigned short c) const;
float GetFontSize() const { return (float)Info->FontSize; } float GetFontSize() const { return (float)Info->FontSize; }
bool IsLoaded() const { return Info != NULL && Common != NULL && Glyphs != NULL; }
ImVec2 CalcTextSize(float size, float max_width, const char* text_begin, const char* text_end, const char** remaining = NULL) const; ImVec2 CalcTextSize(float size, float max_width, const char* text_begin, const char* text_end, const char** remaining = NULL) const;
void RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, ImDrawVert*& out_vertices) const; void RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, ImDrawVert*& out_vertices) const;