mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-13 00:09:55 +02:00
Compare commits
109 Commits
Author | SHA1 | Date | |
---|---|---|---|
77bcb7152b | |||
f195bf744f | |||
4ab43dce19 | |||
13daaf78a2 | |||
e4ef140e10 | |||
350d96466e | |||
1eef2c9108 | |||
71026d3655 | |||
7a31030978 | |||
e5e9c5cfbe | |||
bbf09fd47d | |||
a3cad2ff06 | |||
6eed3dc7c8 | |||
73e73e6ef9 | |||
afa0346a0b | |||
e1f8fed734 | |||
f128a8bce1 | |||
8edbdb9775 | |||
e68d3c614e | |||
9e5fb40ddd | |||
65a191c005 | |||
9eed672725 | |||
d88b73a8b7 | |||
fc13ae2aa5 | |||
e0c375e7b8 | |||
b326c8fd1f | |||
b994dd777a | |||
0aa353868f | |||
aa35547f94 | |||
2d565d4bfb | |||
64fcb5e568 | |||
65fe60f2b2 | |||
0bb46c824e | |||
f2c68109a6 | |||
c381d58fb1 | |||
62a3142036 | |||
da807e55ea | |||
5ebd61f89c | |||
e7cc048d81 | |||
0a11024459 | |||
30461345aa | |||
8430c88451 | |||
b803d284c3 | |||
90e5c97f13 | |||
d2e529e533 | |||
80ad773c87 | |||
55ea2988d2 | |||
e58f99179a | |||
a36001212f | |||
8b225923f8 | |||
59d498f3d0 | |||
62671ef96e | |||
8cf7df7ec4 | |||
822eaf1751 | |||
08b345efd9 | |||
77b82ecad7 | |||
ad00d88923 | |||
f0aca186cc | |||
ad3c9f620d | |||
466f01b313 | |||
43d073db1e | |||
b76353bbb1 | |||
063d26a191 | |||
9a0650dbd0 | |||
b1987d697f | |||
425c6cb3a3 | |||
73917115a8 | |||
7eca754094 | |||
01a17aa78e | |||
e885b08914 | |||
0e898fb480 | |||
5f4cbed7ce | |||
b28858b33b | |||
23ce837dc7 | |||
d80869189a | |||
06c7453ee2 | |||
bbced3f0f0 | |||
4ac4d1ac37 | |||
ccbc72e98b | |||
97be3428f1 | |||
215747635d | |||
c016f6c171 | |||
698c7cae85 | |||
ede5956b28 | |||
0a6d6da732 | |||
67b2b5f3a9 | |||
07de0448f9 | |||
307ed78006 | |||
b770f3ffaf | |||
42567a9516 | |||
72d3fca52f | |||
d36a634ac8 | |||
c98318a914 | |||
f421f2f47e | |||
bcb83ed24e | |||
4630815fb0 | |||
f1f4d68f7f | |||
0c9fcdbe71 | |||
915b46f1c1 | |||
48ed0a10d7 | |||
9a97ef673e | |||
6a90ac2094 | |||
3604aecf8f | |||
23e7bdebcf | |||
32f15b9c9a | |||
aa3c26fd30 | |||
b637850260 | |||
14822609bd | |||
947cf3434f |
11
README.md
11
README.md
@ -7,7 +7,7 @@ ImGui
|
|||||||
|
|
||||||
ImGui is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is portable, renderer agnostic and self-contained (no external dependencies). It is based on an "immediate mode" graphical user interface paradigm which enables you to build user interfaces with ease.
|
ImGui is a bloat-free graphical user interface library for C++. It outputs vertex buffers that you can render in your 3D-pipeline enabled application. It is portable, renderer agnostic and self-contained (no external dependencies). It is based on an "immediate mode" graphical user interface paradigm which enables you to build user interfaces with ease.
|
||||||
|
|
||||||
ImGui is designed to enable fast iteration and allow programmers to create "content creation" or "debug" tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
|
ImGui is designed to enable fast iteration and empower programmers to create content creation tools and visualization/debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and thus lacks certain features normally found in more high-level libraries.
|
||||||
|
|
||||||
ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
|
ImGui is particularly suited to integration in realtime 3D applications, fullscreen applications, embedded applications, games, or any applications on consoles platforms where operating system features are non-standard.
|
||||||
|
|
||||||
@ -33,10 +33,12 @@ ImGui outputs vertex buffers and simple command-lists that you can render in you
|
|||||||
|
|
||||||
ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, etc.
|
ImGui allows you create elaborate tools as well as very short-lived ones. On the extreme side of short-liveness: using the Edit&Continue feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, etc.
|
||||||
|
|
||||||
|
Some of the features supported in some way by ImGui: window management (ordering, moving, resizing, collapsing, persistent settings), button, slider, dragging value, checkbox, radio button, text input (with selection, clipboard support, and standard keyboard controls), multiline text input, filtering text input, tree nodes, collapsing header, word-wrapping, utf-8 text, images, selectable items, vertical and horizontal scrolling, sub-window with independant scrolling/clipping, ttf font loading, basic styling, logging any ui output into text data (clipboard/tty/file), hovering, tooltips, popup windows, modal windows, menu bars, menu items, context menus, combo boxes, list box, plotting lines and histograms, resizable columns, keyboard tabbing, dragging, simple drawing api (anti-aliased, with stroking, convex fill), and low-level primitives to create custom widgets.
|
||||||
|
|
||||||
Demo
|
Demo
|
||||||
----
|
----
|
||||||
|
|
||||||
You should be able to build the examples from sources (tested on Windows/Mac/Linux). If you don't, let me know! If you want to have a quick look at the features of ImGui, you can download binaries of the demo app here.
|
You should be able to build the examples from sources (tested on Windows/Mac/Linux). If you don't, let me know! If you want to have a quick look at the features of ImGui, you can download Windows binaries of the demo app here.
|
||||||
- [imgui-demo-binaries-20150716.zip](http://www.miracleworld.net/imgui/binaries/imgui-demo-binaries-20150716.zip) (Windows binaries, ImGui 1.43 WIP 2015/07/16, 4 executables, 475 KB)
|
- [imgui-demo-binaries-20150716.zip](http://www.miracleworld.net/imgui/binaries/imgui-demo-binaries-20150716.zip) (Windows binaries, ImGui 1.43 WIP 2015/07/16, 4 executables, 475 KB)
|
||||||
|
|
||||||
|
|
||||||
@ -54,13 +56,13 @@ Gallery
|
|||||||
ImGui can load TTF fonts. UTF-8 is supported for text display and input. Here using Arial Unicode font to display Japanese. Initialize custom font with:
|
ImGui can load TTF fonts. UTF-8 is supported for text display and input. Here using Arial Unicode font to display Japanese. Initialize custom font with:
|
||||||
```
|
```
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.Fonts->AddFontFromFileTTF("ArialUni.ttf", 18.0f, io.Fonts->GetGlyphRangesJapanese());
|
io.Fonts->AddFontFromFileTTF("ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
|
||||||
```
|
```
|
||||||
For Microsoft IME, pass your HWND to enable IME positioning:
|
For Microsoft IME, pass your HWND to enable IME positioning:
|
||||||
```
|
```
|
||||||
io.ImeWindowHandle = my_hwnd;
|
io.ImeWindowHandle = my_hwnd;
|
||||||
```
|
```
|
||||||

|

|
||||||
|
|
||||||
References
|
References
|
||||||
----------
|
----------
|
||||||
@ -79,6 +81,7 @@ Frequently Asked Question
|
|||||||
- The documentation is at the top of imgui.cpp + effectively imgui.h.
|
- The documentation is at the top of imgui.cpp + effectively imgui.h.
|
||||||
- Example code is in imgui_demo.cpp and particularly the ImGui::ShowTestWindow() function. It covers most features of ImGui so you can read the code and call the function itself to see its output.
|
- Example code is in imgui_demo.cpp and particularly the ImGui::ShowTestWindow() function. It covers most features of ImGui so you can read the code and call the function itself to see its output.
|
||||||
- Standalone example applications using e.g. OpenGL/DirectX are provided in the examples/ folder.
|
- Standalone example applications using e.g. OpenGL/DirectX are provided in the examples/ folder.
|
||||||
|
- It obviously needs better documentation! Consider helping or becoming a [Patron](http://www.patreon.com/imgui) to promote this effort.
|
||||||
|
|
||||||
<b>How do you use ImGui on a platform that may not have a mouse or keyboard?</b>
|
<b>How do you use ImGui on a platform that may not have a mouse or keyboard?</b>
|
||||||
|
|
||||||
|
3
examples/.gitignore
vendored
3
examples/.gitignore
vendored
@ -15,14 +15,17 @@ opengl_example/Debug/*
|
|||||||
opengl_example/Release/*
|
opengl_example/Release/*
|
||||||
opengl_example/ipch/*
|
opengl_example/ipch/*
|
||||||
opengl_example/x64/*
|
opengl_example/x64/*
|
||||||
|
opengl_example/opengl_example
|
||||||
opengl3_example/Debug/*
|
opengl3_example/Debug/*
|
||||||
opengl3_example/Release/*
|
opengl3_example/Release/*
|
||||||
opengl3_example/ipch/*
|
opengl3_example/ipch/*
|
||||||
opengl3_example/x64/*
|
opengl3_example/x64/*
|
||||||
|
opengl3_example/opengl3_example
|
||||||
*.opensdf
|
*.opensdf
|
||||||
*.sdf
|
*.sdf
|
||||||
*.suo
|
*.suo
|
||||||
*.vcxproj.user
|
*.vcxproj.user
|
||||||
|
*.o
|
||||||
|
|
||||||
## Ini files
|
## Ini files
|
||||||
imgui.ini
|
imgui.ini
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
Those are standalone ready-to-build applications to demonstrate ImGui.
|
Those are standalone ready-to-build applications to demonstrate ImGui.
|
||||||
Binaries of those demos are available from the main GitHub page.
|
Binaries of some of those demos are available at http://www.miracleworld.net/imgui/binaries
|
||||||
|
|
||||||
TL;DR;
|
TL;DR;
|
||||||
Refer to 'opengl_example' (not 'opengl3_example') to understand how the library is setup.
|
Refer to 'opengl_example' to understand how the library is setup, because it is the simplest one.
|
||||||
Copy the imgui_impl_xxx.cpp/.h file you need if you are using one of the rendering backend used in an example.
|
Copy the imgui_impl_xxx.cpp/.h files you need if you are using one of provided rendering/IO backends.
|
||||||
If you are using a different or your own backend, copy opengl_example/imgui_impl_opengl.cpp/.h to get started.
|
If using different or your own backend, copy opengl_example/imgui_impl_opengl.cpp/.h to get started.
|
||||||
|
|
||||||
|
|
||||||
ImGui is highly portable and only requires a few things to run:
|
ImGui is highly portable and only requires a few things to run:
|
||||||
@ -25,12 +25,12 @@ opengl_example/
|
|||||||
OpenGL example, using GLFW + fixed pipeline.
|
OpenGL example, using GLFW + fixed pipeline.
|
||||||
This is simple and should work for all OpenGL enabled applications.
|
This is simple and should work for all OpenGL enabled applications.
|
||||||
Prefer following this example to learn how ImGui works!
|
Prefer following this example to learn how ImGui works!
|
||||||
|
(You can use this code in a GL3/GL4 context but make sure you disable the programmable pipeline
|
||||||
|
by calling "glUseProgram(0)" before ImGui::Render.)
|
||||||
|
|
||||||
opengl3_example/
|
opengl3_example/
|
||||||
OpenGL example, using GLFW/GL3W + programmable pipeline.
|
OpenGL example, using GLFW/GL3W + programmable pipeline.
|
||||||
This uses more modern OpenGL calls and custom shaders.
|
This uses more modern OpenGL calls and custom shaders. It's more messy.
|
||||||
Even if your application is using modern OpenGL you are better off copying the code from the fixed pipeline version!
|
|
||||||
I don't think there is an advantage using this over the simpler example, but it is provided for reference.
|
|
||||||
|
|
||||||
directx9_example/
|
directx9_example/
|
||||||
DirectX9 example, Windows only.
|
DirectX9 example, Windows only.
|
||||||
@ -41,7 +41,8 @@ directx11_example/
|
|||||||
|
|
||||||
ios_example/
|
ios_example/
|
||||||
iOS example.
|
iOS example.
|
||||||
Using Synergy to access keyboard/mouse data from server computer. Synergy keyboard integration is rather hacky.
|
Using Synergy to access keyboard/mouse data from server computer.
|
||||||
|
Synergy keyboard integration is rather hacky.
|
||||||
|
|
||||||
sdl_opengl_example/
|
sdl_opengl_example/
|
||||||
SDL2 + OpenGL example.
|
SDL2 + OpenGL example.
|
||||||
|
@ -7,12 +7,11 @@
|
|||||||
struct ALLEGRO_DISPLAY;
|
struct ALLEGRO_DISPLAY;
|
||||||
union ALLEGRO_EVENT;
|
union ALLEGRO_EVENT;
|
||||||
|
|
||||||
bool ImGui_ImplA5_Init(ALLEGRO_DISPLAY* display);
|
IMGUI_API bool ImGui_ImplA5_Init(ALLEGRO_DISPLAY* display);
|
||||||
void ImGui_ImplA5_Shutdown();
|
IMGUI_API void ImGui_ImplA5_Shutdown();
|
||||||
void ImGui_ImplA5_NewFrame();
|
IMGUI_API void ImGui_ImplA5_NewFrame();
|
||||||
|
IMGUI_API bool ImGui_ImplA5_ProcessEvent(ALLEGRO_EVENT* event);
|
||||||
bool ImGui_ImplA5_ProcessEvent(ALLEGRO_EVENT* event);
|
|
||||||
|
|
||||||
// Use if you want to reset your rendering device without losing ImGui state.
|
// Use if you want to reset your rendering device without losing ImGui state.
|
||||||
bool Imgui_ImplA5_CreateDeviceObjects();
|
IMGUI_API bool Imgui_ImplA5_CreateDeviceObjects();
|
||||||
void ImGui_ImplA5_InvalidateDeviceObjects();
|
IMGUI_API void ImGui_ImplA5_InvalidateDeviceObjects();
|
||||||
|
@ -29,8 +29,7 @@ static ID3D11SamplerState* g_pFontSampler = NULL;
|
|||||||
static ID3D11ShaderResourceView*g_pFontTextureView = NULL;
|
static ID3D11ShaderResourceView*g_pFontTextureView = NULL;
|
||||||
static ID3D11RasterizerState* g_pRasterizerState = NULL;
|
static ID3D11RasterizerState* g_pRasterizerState = NULL;
|
||||||
static ID3D11BlendState* g_pBlendState = NULL;
|
static ID3D11BlendState* g_pBlendState = NULL;
|
||||||
static int VERTEX_BUFFER_SIZE = 20000; // TODO: Make buffers smaller and grow dynamically as needed.
|
static int g_VertexBufferSize = 5000, g_IndexBufferSize = 10000;
|
||||||
static int INDEX_BUFFER_SIZE = 40000; // TODO: Make buffers smaller and grow dynamically as needed.
|
|
||||||
|
|
||||||
struct VERTEX_CONSTANT_BUFFER
|
struct VERTEX_CONSTANT_BUFFER
|
||||||
{
|
{
|
||||||
@ -42,6 +41,35 @@ struct VERTEX_CONSTANT_BUFFER
|
|||||||
// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
|
// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
|
||||||
static void ImGui_ImplDX11_RenderDrawLists(ImDrawData* draw_data)
|
static void ImGui_ImplDX11_RenderDrawLists(ImDrawData* draw_data)
|
||||||
{
|
{
|
||||||
|
// Create and grow vertex/index buffers if needed
|
||||||
|
if (!g_pVB || g_VertexBufferSize < draw_data->TotalVtxCount)
|
||||||
|
{
|
||||||
|
if (g_pVB) { g_pVB->Release(); g_pVB = NULL; }
|
||||||
|
g_VertexBufferSize = draw_data->TotalVtxCount + 5000;
|
||||||
|
D3D11_BUFFER_DESC desc;
|
||||||
|
memset(&desc, 0, sizeof(D3D11_BUFFER_DESC));
|
||||||
|
desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||||
|
desc.ByteWidth = g_VertexBufferSize * sizeof(ImDrawVert);
|
||||||
|
desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
||||||
|
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||||
|
desc.MiscFlags = 0;
|
||||||
|
if (g_pd3dDevice->CreateBuffer(&desc, NULL, &g_pVB) < 0)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!g_pIB || g_IndexBufferSize < draw_data->TotalIdxCount)
|
||||||
|
{
|
||||||
|
if (g_pIB) { g_pIB->Release(); g_pIB = NULL; }
|
||||||
|
g_IndexBufferSize = draw_data->TotalIdxCount + 10000;
|
||||||
|
D3D11_BUFFER_DESC bufferDesc;
|
||||||
|
memset(&bufferDesc, 0, sizeof(D3D11_BUFFER_DESC));
|
||||||
|
bufferDesc.Usage = D3D11_USAGE_DYNAMIC;
|
||||||
|
bufferDesc.ByteWidth = g_IndexBufferSize * sizeof(ImDrawIdx);
|
||||||
|
bufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
||||||
|
bufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||||
|
if (g_pd3dDevice->CreateBuffer(&bufferDesc, NULL, &g_pIB) < 0)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Copy and convert all vertices into a single contiguous buffer
|
// Copy and convert all vertices into a single contiguous buffer
|
||||||
D3D11_MAPPED_SUBRESOURCE vtx_resource, idx_resource;
|
D3D11_MAPPED_SUBRESOURCE vtx_resource, idx_resource;
|
||||||
if (g_pd3dDeviceContext->Map(g_pVB, 0, D3D11_MAP_WRITE_DISCARD, 0, &vtx_resource) != S_OK)
|
if (g_pd3dDeviceContext->Map(g_pVB, 0, D3D11_MAP_WRITE_DISCARD, 0, &vtx_resource) != S_OK)
|
||||||
@ -144,7 +172,7 @@ static void ImGui_ImplDX11_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
g_pd3dDeviceContext->VSSetShader(NULL, NULL, 0);
|
g_pd3dDeviceContext->VSSetShader(NULL, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT ImGui_ImplDX11_WndProcHandler(HWND, UINT msg, WPARAM wParam, LPARAM lParam)
|
IMGUI_API LRESULT ImGui_ImplDX11_WndProcHandler(HWND, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
switch (msg)
|
switch (msg)
|
||||||
@ -161,6 +189,12 @@ LRESULT ImGui_ImplDX11_WndProcHandler(HWND, UINT msg, WPARAM wParam, LPARAM lPar
|
|||||||
case WM_RBUTTONUP:
|
case WM_RBUTTONUP:
|
||||||
io.MouseDown[1] = false;
|
io.MouseDown[1] = false;
|
||||||
return true;
|
return true;
|
||||||
|
case WM_MBUTTONDOWN:
|
||||||
|
io.MouseDown[2] = true;
|
||||||
|
return true;
|
||||||
|
case WM_MBUTTONUP:
|
||||||
|
io.MouseDown[2] = false;
|
||||||
|
return true;
|
||||||
case WM_MOUSEWHEEL:
|
case WM_MOUSEWHEEL:
|
||||||
io.MouseWheel += GET_WHEEL_DELTA_WPARAM(wParam) > 0 ? +1.0f : -1.0f;
|
io.MouseWheel += GET_WHEEL_DELTA_WPARAM(wParam) > 0 ? +1.0f : -1.0f;
|
||||||
return true;
|
return true;
|
||||||
@ -253,13 +287,13 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
|
|||||||
{
|
{
|
||||||
if (!g_pd3dDevice)
|
if (!g_pd3dDevice)
|
||||||
return false;
|
return false;
|
||||||
if (g_pVB)
|
if (g_pFontSampler)
|
||||||
ImGui_ImplDX11_InvalidateDeviceObjects();
|
ImGui_ImplDX11_InvalidateDeviceObjects();
|
||||||
|
|
||||||
// Create the vertex shader
|
// Create the vertex shader
|
||||||
{
|
{
|
||||||
static const char* vertexShader =
|
static const char* vertexShader =
|
||||||
"cbuffer vertexBuffer : register(c0) \
|
"cbuffer vertexBuffer : register(b0) \
|
||||||
{\
|
{\
|
||||||
float4x4 ProjectionMatrix; \
|
float4x4 ProjectionMatrix; \
|
||||||
};\
|
};\
|
||||||
@ -366,31 +400,6 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
|
|||||||
g_pd3dDevice->CreateRasterizerState(&desc, &g_pRasterizerState);
|
g_pd3dDevice->CreateRasterizerState(&desc, &g_pRasterizerState);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the vertex buffer
|
|
||||||
{
|
|
||||||
D3D11_BUFFER_DESC desc;
|
|
||||||
memset(&desc, 0, sizeof(D3D11_BUFFER_DESC));
|
|
||||||
desc.Usage = D3D11_USAGE_DYNAMIC;
|
|
||||||
desc.ByteWidth = VERTEX_BUFFER_SIZE * sizeof(ImDrawVert);
|
|
||||||
desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
|
||||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
|
||||||
desc.MiscFlags = 0;
|
|
||||||
if (g_pd3dDevice->CreateBuffer(&desc, NULL, &g_pVB) < 0)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the index buffer
|
|
||||||
{
|
|
||||||
D3D11_BUFFER_DESC bufferDesc;
|
|
||||||
memset(&bufferDesc, 0, sizeof(D3D11_BUFFER_DESC));
|
|
||||||
bufferDesc.Usage = D3D11_USAGE_DYNAMIC;
|
|
||||||
bufferDesc.ByteWidth = INDEX_BUFFER_SIZE * sizeof(ImDrawIdx);
|
|
||||||
bufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
|
||||||
bufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
|
||||||
if (g_pd3dDevice->CreateBuffer(&bufferDesc, NULL, &g_pIB) < 0)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui_ImplDX11_CreateFontsTexture();
|
ImGui_ImplDX11_CreateFontsTexture();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -4,17 +4,17 @@
|
|||||||
struct ID3D11Device;
|
struct ID3D11Device;
|
||||||
struct ID3D11DeviceContext;
|
struct ID3D11DeviceContext;
|
||||||
|
|
||||||
bool ImGui_ImplDX11_Init(void* hwnd, ID3D11Device* device, ID3D11DeviceContext* device_context);
|
IMGUI_API bool ImGui_ImplDX11_Init(void* hwnd, ID3D11Device* device, ID3D11DeviceContext* device_context);
|
||||||
void ImGui_ImplDX11_Shutdown();
|
IMGUI_API void ImGui_ImplDX11_Shutdown();
|
||||||
void ImGui_ImplDX11_NewFrame();
|
IMGUI_API void ImGui_ImplDX11_NewFrame();
|
||||||
|
|
||||||
// Use if you want to reset your rendering device without losing ImGui state.
|
// Use if you want to reset your rendering device without losing ImGui state.
|
||||||
void ImGui_ImplDX11_InvalidateDeviceObjects();
|
IMGUI_API void ImGui_ImplDX11_InvalidateDeviceObjects();
|
||||||
bool ImGui_ImplDX11_CreateDeviceObjects();
|
IMGUI_API bool ImGui_ImplDX11_CreateDeviceObjects();
|
||||||
|
|
||||||
// Handler for Win32 messages, update mouse/keyboard data.
|
// Handler for Win32 messages, update mouse/keyboard data.
|
||||||
// You may or not need this for your implementation, but it can serve as reference for handling inputs.
|
// You may or not need this for your implementation, but it can serve as reference for handling inputs.
|
||||||
// Commented out to avoid dragging dependencies on <windows.h> types. You can copy the extern declaration in your code.
|
// Commented out to avoid dragging dependencies on <windows.h> types. You can copy the extern declaration in your code.
|
||||||
/*
|
/*
|
||||||
extern LRESULT ImGui_ImplDX11_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
IMGUI_API LRESULT ImGui_ImplDX11_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
*/
|
*/
|
||||||
|
@ -16,8 +16,8 @@ static INT64 g_TicksPerSecond = 0;
|
|||||||
static LPDIRECT3DDEVICE9 g_pd3dDevice = NULL;
|
static LPDIRECT3DDEVICE9 g_pd3dDevice = NULL;
|
||||||
static LPDIRECT3DVERTEXBUFFER9 g_pVB = NULL;
|
static LPDIRECT3DVERTEXBUFFER9 g_pVB = NULL;
|
||||||
static LPDIRECT3DINDEXBUFFER9 g_pIB = NULL;
|
static LPDIRECT3DINDEXBUFFER9 g_pIB = NULL;
|
||||||
static int VERTEX_BUFFER_SIZE = 20000; // TODO: Make buffers smaller and grow dynamically as needed.
|
static LPDIRECT3DTEXTURE9 g_FontTexture = NULL;
|
||||||
static int INDEX_BUFFER_SIZE = 40000; // TODO: Make buffers smaller and grow dynamically as needed.
|
static int g_VertexBufferSize = 5000, g_IndexBufferSize = 10000;
|
||||||
|
|
||||||
struct CUSTOMVERTEX
|
struct CUSTOMVERTEX
|
||||||
{
|
{
|
||||||
@ -32,6 +32,22 @@ struct CUSTOMVERTEX
|
|||||||
// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
|
// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
|
||||||
static void ImGui_ImplDX9_RenderDrawLists(ImDrawData* draw_data)
|
static void ImGui_ImplDX9_RenderDrawLists(ImDrawData* draw_data)
|
||||||
{
|
{
|
||||||
|
// Create and grow buffers if needed
|
||||||
|
if (!g_pVB || g_VertexBufferSize < draw_data->TotalVtxCount)
|
||||||
|
{
|
||||||
|
if (g_pVB) { g_pVB->Release(); g_pVB = NULL; }
|
||||||
|
g_VertexBufferSize = draw_data->TotalVtxCount + 5000;
|
||||||
|
if (g_pd3dDevice->CreateVertexBuffer(g_VertexBufferSize * sizeof(CUSTOMVERTEX), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB, NULL) < 0)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!g_pIB || g_IndexBufferSize < draw_data->TotalIdxCount)
|
||||||
|
{
|
||||||
|
if (g_pIB) { g_pIB->Release(); g_pIB = NULL; }
|
||||||
|
g_IndexBufferSize = draw_data->TotalIdxCount + 10000;
|
||||||
|
if (g_pd3dDevice->CreateIndexBuffer(g_IndexBufferSize * sizeof(ImDrawIdx), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFMT_INDEX16, D3DPOOL_DEFAULT, &g_pIB, NULL) < 0)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Copy and convert all vertices into a single contiguous buffer
|
// Copy and convert all vertices into a single contiguous buffer
|
||||||
CUSTOMVERTEX* vtx_dst;
|
CUSTOMVERTEX* vtx_dst;
|
||||||
ImDrawIdx* idx_dst;
|
ImDrawIdx* idx_dst;
|
||||||
@ -86,10 +102,10 @@ static void ImGui_ImplDX9_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
// Setup orthographic projection matrix
|
// Setup orthographic projection matrix
|
||||||
D3DXMATRIXA16 mat;
|
D3DXMATRIXA16 mat;
|
||||||
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.5f, ImGui::GetIO().DisplaySize.x+0.5f, ImGui::GetIO().DisplaySize.y+0.5f, 0.5f, -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
|
||||||
int vtx_offset = 0;
|
int vtx_offset = 0;
|
||||||
@ -108,8 +124,8 @@ static void ImGui_ImplDX9_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
{
|
{
|
||||||
const RECT r = { (LONG)pcmd->ClipRect.x, (LONG)pcmd->ClipRect.y, (LONG)pcmd->ClipRect.z, (LONG)pcmd->ClipRect.w };
|
const RECT r = { (LONG)pcmd->ClipRect.x, (LONG)pcmd->ClipRect.y, (LONG)pcmd->ClipRect.z, (LONG)pcmd->ClipRect.w };
|
||||||
g_pd3dDevice->SetTexture( 0, (LPDIRECT3DTEXTURE9)pcmd->TextureId );
|
g_pd3dDevice->SetTexture( 0, (LPDIRECT3DTEXTURE9)pcmd->TextureId );
|
||||||
g_pd3dDevice->SetScissorRect(&r);
|
g_pd3dDevice->SetScissorRect( &r );
|
||||||
g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.size(), idx_offset, pcmd->ElemCount/3);
|
g_pd3dDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.size(), idx_offset, pcmd->ElemCount/3 );
|
||||||
}
|
}
|
||||||
idx_offset += pcmd->ElemCount;
|
idx_offset += pcmd->ElemCount;
|
||||||
}
|
}
|
||||||
@ -117,7 +133,7 @@ static void ImGui_ImplDX9_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT ImGui_ImplDX9_WndProcHandler(HWND, UINT msg, WPARAM wParam, LPARAM lParam)
|
IMGUI_API LRESULT ImGui_ImplDX9_WndProcHandler(HWND, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
switch (msg)
|
switch (msg)
|
||||||
@ -134,6 +150,12 @@ LRESULT ImGui_ImplDX9_WndProcHandler(HWND, UINT msg, WPARAM wParam, LPARAM lPara
|
|||||||
case WM_RBUTTONUP:
|
case WM_RBUTTONUP:
|
||||||
io.MouseDown[1] = false;
|
io.MouseDown[1] = false;
|
||||||
return true;
|
return true;
|
||||||
|
case WM_MBUTTONDOWN:
|
||||||
|
io.MouseDown[2] = true;
|
||||||
|
return true;
|
||||||
|
case WM_MBUTTONUP:
|
||||||
|
io.MouseDown[2] = false;
|
||||||
|
return true;
|
||||||
case WM_MOUSEWHEEL:
|
case WM_MOUSEWHEEL:
|
||||||
io.MouseWheel += GET_WHEEL_DELTA_WPARAM(wParam) > 0 ? +1.0f : -1.0f;
|
io.MouseWheel += GET_WHEEL_DELTA_WPARAM(wParam) > 0 ? +1.0f : -1.0f;
|
||||||
return true;
|
return true;
|
||||||
@ -203,7 +225,7 @@ void ImGui_ImplDX9_Shutdown()
|
|||||||
g_hWnd = 0;
|
g_hWnd = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplDX9_CreateFontsTexture()
|
static bool ImGui_ImplDX9_CreateFontsTexture()
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
@ -213,42 +235,31 @@ static void ImGui_ImplDX9_CreateFontsTexture()
|
|||||||
io.Fonts->GetTexDataAsAlpha8(&pixels, &width, &height, &bytes_per_pixel);
|
io.Fonts->GetTexDataAsAlpha8(&pixels, &width, &height, &bytes_per_pixel);
|
||||||
|
|
||||||
// Create DX9 texture
|
// Create DX9 texture
|
||||||
LPDIRECT3DTEXTURE9 pTexture = NULL;
|
g_FontTexture = NULL;
|
||||||
if (D3DXCreateTexture(g_pd3dDevice, width, height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8, D3DPOOL_DEFAULT, &pTexture) < 0)
|
if (D3DXCreateTexture(g_pd3dDevice, width, height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8, D3DPOOL_DEFAULT, &g_FontTexture) < 0)
|
||||||
{
|
return false;
|
||||||
IM_ASSERT(0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
D3DLOCKED_RECT tex_locked_rect;
|
D3DLOCKED_RECT tex_locked_rect;
|
||||||
if (pTexture->LockRect(0, &tex_locked_rect, NULL, 0) != D3D_OK)
|
if (g_FontTexture->LockRect(0, &tex_locked_rect, NULL, 0) != D3D_OK)
|
||||||
{
|
return false;
|
||||||
IM_ASSERT(0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (int y = 0; y < height; y++)
|
for (int y = 0; y < height; y++)
|
||||||
memcpy((unsigned char *)tex_locked_rect.pBits + tex_locked_rect.Pitch * y, pixels + (width * bytes_per_pixel) * y, (width * bytes_per_pixel));
|
memcpy((unsigned char *)tex_locked_rect.pBits + tex_locked_rect.Pitch * y, pixels + (width * bytes_per_pixel) * y, (width * bytes_per_pixel));
|
||||||
pTexture->UnlockRect(0);
|
g_FontTexture->UnlockRect(0);
|
||||||
|
|
||||||
// Store our identifier
|
// Store our identifier
|
||||||
io.Fonts->TexID = (void *)pTexture;
|
io.Fonts->TexID = (void *)g_FontTexture;
|
||||||
|
|
||||||
// Cleanup (don't clear the input data if you want to append new fonts later)
|
// Cleanup (don't clear the input data if you want to append new fonts later)
|
||||||
io.Fonts->ClearInputData();
|
io.Fonts->ClearInputData();
|
||||||
io.Fonts->ClearTexData();
|
io.Fonts->ClearTexData();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplDX9_CreateDeviceObjects()
|
bool ImGui_ImplDX9_CreateDeviceObjects()
|
||||||
{
|
{
|
||||||
if (!g_pd3dDevice)
|
if (!g_pd3dDevice)
|
||||||
return false;
|
return false;
|
||||||
|
if (!ImGui_ImplDX9_CreateFontsTexture())
|
||||||
if (g_pd3dDevice->CreateVertexBuffer(VERTEX_BUFFER_SIZE * sizeof(CUSTOMVERTEX), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB, NULL) < 0)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (g_pd3dDevice->CreateIndexBuffer(INDEX_BUFFER_SIZE * sizeof(ImDrawIdx), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFMT_INDEX16, D3DPOOL_DEFAULT, &g_pIB, NULL) < 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
ImGui_ImplDX9_CreateFontsTexture();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,7 +286,7 @@ void ImGui_ImplDX9_InvalidateDeviceObjects()
|
|||||||
|
|
||||||
void ImGui_ImplDX9_NewFrame()
|
void ImGui_ImplDX9_NewFrame()
|
||||||
{
|
{
|
||||||
if (!g_pVB)
|
if (!g_FontTexture)
|
||||||
ImGui_ImplDX9_CreateDeviceObjects();
|
ImGui_ImplDX9_CreateDeviceObjects();
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
@ -3,17 +3,17 @@
|
|||||||
|
|
||||||
struct IDirect3DDevice9;
|
struct IDirect3DDevice9;
|
||||||
|
|
||||||
bool ImGui_ImplDX9_Init(void* hwnd, IDirect3DDevice9* device);
|
IMGUI_API bool ImGui_ImplDX9_Init(void* hwnd, IDirect3DDevice9* device);
|
||||||
void ImGui_ImplDX9_Shutdown();
|
IMGUI_API void ImGui_ImplDX9_Shutdown();
|
||||||
void ImGui_ImplDX9_NewFrame();
|
IMGUI_API void ImGui_ImplDX9_NewFrame();
|
||||||
|
|
||||||
// Use if you want to reset your rendering device without losing ImGui state.
|
// Use if you want to reset your rendering device without losing ImGui state.
|
||||||
void ImGui_ImplDX9_InvalidateDeviceObjects();
|
IMGUI_API void ImGui_ImplDX9_InvalidateDeviceObjects();
|
||||||
bool ImGui_ImplDX9_CreateDeviceObjects();
|
IMGUI_API bool ImGui_ImplDX9_CreateDeviceObjects();
|
||||||
|
|
||||||
// Handler for Win32 messages, update mouse/keyboard data.
|
// Handler for Win32 messages, update mouse/keyboard data.
|
||||||
// You may or not need this for your implementation, but it can serve as reference for handling inputs.
|
// You may or not need this for your implementation, but it can serve as reference for handling inputs.
|
||||||
// Commented out to avoid dragging dependencies on <windows.h> types. You can copy the extern declaration in your code.
|
// Commented out to avoid dragging dependencies on <windows.h> types. You can copy the extern declaration in your code.
|
||||||
/*
|
/*
|
||||||
extern LRESULT ImGui_ImplDX9_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
IMGUI_API LRESULT ImGui_ImplDX9_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
*/
|
*/
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
|
197E1E871B8943FE00E3FE6A /* imgui_draw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 197E1E861B8943FE00E3FE6A /* imgui_draw.cpp */; };
|
||||||
|
197E1E891B89443600E3FE6A /* imgui_demo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 197E1E881B89443600E3FE6A /* imgui_demo.cpp */; };
|
||||||
6D1E39171B35EEF10017B40F /* uSynergy.c in Sources */ = {isa = PBXBuildFile; fileRef = 6D1E39151B35EEF10017B40F /* uSynergy.c */; };
|
6D1E39171B35EEF10017B40F /* uSynergy.c in Sources */ = {isa = PBXBuildFile; fileRef = 6D1E39151B35EEF10017B40F /* uSynergy.c */; };
|
||||||
6D2FC55A1B2E632000C130BA /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D2FC5591B2E632000C130BA /* main.m */; };
|
6D2FC55A1B2E632000C130BA /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D2FC5591B2E632000C130BA /* main.m */; };
|
||||||
6D2FC55D1B2E632000C130BA /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D2FC55C1B2E632000C130BA /* AppDelegate.m */; };
|
6D2FC55D1B2E632000C130BA /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D2FC55C1B2E632000C130BA /* AppDelegate.m */; };
|
||||||
@ -24,6 +26,8 @@
|
|||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
|
197E1E861B8943FE00E3FE6A /* imgui_draw.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_draw.cpp; path = ../../imgui_draw.cpp; sourceTree = "<group>"; };
|
||||||
|
197E1E881B89443600E3FE6A /* imgui_demo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_demo.cpp; path = ../../../imgui_demo.cpp; sourceTree = "<group>"; };
|
||||||
6D1E39151B35EEF10017B40F /* uSynergy.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = uSynergy.c; sourceTree = "<group>"; };
|
6D1E39151B35EEF10017B40F /* uSynergy.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = uSynergy.c; sourceTree = "<group>"; };
|
||||||
6D1E39161B35EEF10017B40F /* uSynergy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = uSynergy.h; sourceTree = "<group>"; };
|
6D1E39161B35EEF10017B40F /* uSynergy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = uSynergy.h; sourceTree = "<group>"; };
|
||||||
6D2FC5541B2E632000C130BA /* imguiex.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = imguiex.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
6D2FC5541B2E632000C130BA /* imguiex.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = imguiex.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
@ -95,6 +99,7 @@
|
|||||||
children = (
|
children = (
|
||||||
6D2FC5811B2E63A100C130BA /* imgui_impl_ios.mm */,
|
6D2FC5811B2E63A100C130BA /* imgui_impl_ios.mm */,
|
||||||
6D2FC5821B2E63A100C130BA /* imgui_impl_ios.h */,
|
6D2FC5821B2E63A100C130BA /* imgui_impl_ios.h */,
|
||||||
|
197E1E881B89443600E3FE6A /* imgui_demo.cpp */,
|
||||||
6D2FC5891B2E6A5500C130BA /* debug_hud.cpp */,
|
6D2FC5891B2E6A5500C130BA /* debug_hud.cpp */,
|
||||||
6D2FC58A1B2E6A5500C130BA /* debug_hud.h */,
|
6D2FC58A1B2E6A5500C130BA /* debug_hud.h */,
|
||||||
6D2FC55B1B2E632000C130BA /* AppDelegate.h */,
|
6D2FC55B1B2E632000C130BA /* AppDelegate.h */,
|
||||||
@ -126,6 +131,7 @@
|
|||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
6D2FC5851B2E64AB00C130BA /* imconfig.h */,
|
6D2FC5851B2E64AB00C130BA /* imconfig.h */,
|
||||||
|
197E1E861B8943FE00E3FE6A /* imgui_draw.cpp */,
|
||||||
6D2FC5861B2E64AB00C130BA /* imgui.cpp */,
|
6D2FC5861B2E64AB00C130BA /* imgui.cpp */,
|
||||||
6D2FC5871B2E64AB00C130BA /* imgui.h */,
|
6D2FC5871B2E64AB00C130BA /* imgui.h */,
|
||||||
);
|
);
|
||||||
@ -211,6 +217,8 @@
|
|||||||
6D2FC55A1B2E632000C130BA /* main.m in Sources */,
|
6D2FC55A1B2E632000C130BA /* main.m in Sources */,
|
||||||
6D2FC5881B2E64AB00C130BA /* imgui.cpp in Sources */,
|
6D2FC5881B2E64AB00C130BA /* imgui.cpp in Sources */,
|
||||||
6D2FC58B1B2E6A5500C130BA /* debug_hud.cpp in Sources */,
|
6D2FC58B1B2E6A5500C130BA /* debug_hud.cpp in Sources */,
|
||||||
|
197E1E871B8943FE00E3FE6A /* imgui_draw.cpp in Sources */,
|
||||||
|
197E1E891B89443600E3FE6A /* imgui_demo.cpp in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#CXX = g++
|
#CXX = g++
|
||||||
|
|
||||||
|
EXE = opengl3_example
|
||||||
OBJS = main.o imgui_impl_glfw_gl3.o
|
OBJS = main.o imgui_impl_glfw_gl3.o
|
||||||
OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o
|
OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o
|
||||||
OBJS += ../libs/gl3w/GL/gl3w.o
|
OBJS += ../libs/gl3w/GL/gl3w.o
|
||||||
@ -22,7 +23,7 @@ ifeq ($(UNAME_S), Linux) #LINUX
|
|||||||
LIBS = `pkg-config --static --libs glfw3`
|
LIBS = `pkg-config --static --libs glfw3`
|
||||||
|
|
||||||
CXXFLAGS = -I../../ -I../libs/gl3w `pkg-config --cflags glfw3`
|
CXXFLAGS = -I../../ -I../libs/gl3w `pkg-config --cflags glfw3`
|
||||||
CXXFLAGS += -Wall
|
CXXFLAGS += -Wall -Wformat
|
||||||
CFLAGS = $(CXXFLAGS)
|
CFLAGS = $(CXXFLAGS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -33,7 +34,7 @@ ifeq ($(UNAME_S), Darwin) #APPLE
|
|||||||
LIBS += -lglfw3
|
LIBS += -lglfw3
|
||||||
|
|
||||||
CXXFLAGS = -I../../ -I../libs/gl3w -I/usr/local/Cellar/glew/1.10.0/include -I/usr/local/include
|
CXXFLAGS = -I../../ -I../libs/gl3w -I/usr/local/Cellar/glew/1.10.0/include -I/usr/local/include
|
||||||
CXXFLAGS += -Wall
|
CXXFLAGS += -Wall -Wformat
|
||||||
# CXXFLAGS += -D__APPLE__
|
# CXXFLAGS += -D__APPLE__
|
||||||
CFLAGS = $(CXXFLAGS)
|
CFLAGS = $(CXXFLAGS)
|
||||||
endif
|
endif
|
||||||
@ -41,12 +42,12 @@ endif
|
|||||||
.cpp.o:
|
.cpp.o:
|
||||||
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
all:imgui_example
|
all: $(EXE)
|
||||||
@echo Build complete for $(ECHO_MESSAGE)
|
@echo Build complete for $(ECHO_MESSAGE)
|
||||||
|
|
||||||
imgui_example:$(OBJS)
|
$(EXE): $(OBJS)
|
||||||
$(CXX) -o imgui_example $(OBJS) $(CXXFLAGS) $(LIBS)
|
$(CXX) -o $(EXE) $(OBJS) $(CXXFLAGS) $(LIBS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm $(OBJS)
|
rm $(EXE) $(OBJS)
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
// GL3W/GLFW
|
// GL3W/GLFW
|
||||||
#include <GL/gl3w.h>
|
#include <GL/gl3w.h>
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
#ifdef _MSC_VER
|
#ifdef _WIN32
|
||||||
#undef APIENTRY
|
#undef APIENTRY
|
||||||
#define GLFW_EXPOSE_NATIVE_WIN32
|
#define GLFW_EXPOSE_NATIVE_WIN32
|
||||||
#define GLFW_EXPOSE_NATIVE_WGL
|
#define GLFW_EXPOSE_NATIVE_WGL
|
||||||
@ -30,10 +30,15 @@ static unsigned int g_VboHandle = 0, g_VaoHandle = 0, g_ElementsHandle = 0;
|
|||||||
// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
|
// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
|
||||||
static void ImGui_ImplGlfwGL3_RenderDrawLists(ImDrawData* draw_data)
|
static void ImGui_ImplGlfwGL3_RenderDrawLists(ImDrawData* draw_data)
|
||||||
{
|
{
|
||||||
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled
|
// Backup GL state
|
||||||
GLint last_program, last_texture;
|
GLint last_program, last_texture, last_array_buffer, last_element_array_buffer, last_vertex_array;
|
||||||
glGetIntegerv(GL_CURRENT_PROGRAM, &last_program);
|
glGetIntegerv(GL_CURRENT_PROGRAM, &last_program);
|
||||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
||||||
|
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
|
||||||
|
glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &last_element_array_buffer);
|
||||||
|
glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array);
|
||||||
|
|
||||||
|
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendEquation(GL_FUNC_ADD);
|
glBlendEquation(GL_FUNC_ADD);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
@ -42,15 +47,18 @@ static void ImGui_ImplGlfwGL3_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
glEnable(GL_SCISSOR_TEST);
|
glEnable(GL_SCISSOR_TEST);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
|
||||||
|
// Handle cases of screen coordinates != from framebuffer coordinates (e.g. retina displays)
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
float fb_height = io.DisplaySize.y * io.DisplayFramebufferScale.y;
|
||||||
|
draw_data->ScaleClipRects(io.DisplayFramebufferScale);
|
||||||
|
|
||||||
// Setup orthographic projection matrix
|
// Setup orthographic projection matrix
|
||||||
const float width = ImGui::GetIO().DisplaySize.x;
|
|
||||||
const float height = ImGui::GetIO().DisplaySize.y;
|
|
||||||
const float ortho_projection[4][4] =
|
const float ortho_projection[4][4] =
|
||||||
{
|
{
|
||||||
{ 2.0f/width, 0.0f, 0.0f, 0.0f },
|
{ 2.0f/io.DisplaySize.x, 0.0f, 0.0f, 0.0f },
|
||||||
{ 0.0f, 2.0f/-height, 0.0f, 0.0f },
|
{ 0.0f, 2.0f/-io.DisplaySize.y, 0.0f, 0.0f },
|
||||||
{ 0.0f, 0.0f, -1.0f, 0.0f },
|
{ 0.0f, 0.0f, -1.0f, 0.0f },
|
||||||
{ -1.0f, 1.0f, 0.0f, 1.0f },
|
{-1.0f, 1.0f, 0.0f, 1.0f },
|
||||||
};
|
};
|
||||||
glUseProgram(g_ShaderHandle);
|
glUseProgram(g_ShaderHandle);
|
||||||
glUniform1i(g_AttribLocationTex, 0);
|
glUniform1i(g_AttribLocationTex, 0);
|
||||||
@ -77,20 +85,20 @@ static void ImGui_ImplGlfwGL3_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
|
glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
|
||||||
glScissor((int)pcmd->ClipRect.x, (int)(height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
|
glScissor((int)pcmd->ClipRect.x, (int)(fb_height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
|
||||||
glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, GL_UNSIGNED_SHORT, idx_buffer_offset);
|
glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, GL_UNSIGNED_SHORT, idx_buffer_offset);
|
||||||
}
|
}
|
||||||
idx_buffer_offset += pcmd->ElemCount;
|
idx_buffer_offset += pcmd->ElemCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore modified state
|
// Restore modified GL state
|
||||||
glBindVertexArray(0);
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
|
||||||
glUseProgram(last_program);
|
glUseProgram(last_program);
|
||||||
glDisable(GL_SCISSOR_TEST);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, last_texture);
|
glBindTexture(GL_TEXTURE_2D, last_texture);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, last_element_array_buffer);
|
||||||
|
glBindVertexArray(last_vertex_array);
|
||||||
|
glDisable(GL_SCISSOR_TEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* ImGui_ImplGlfwGL3_GetClipboardText()
|
static const char* ImGui_ImplGlfwGL3_GetClipboardText()
|
||||||
@ -159,6 +167,12 @@ void ImGui_ImplGlfwGL3_CreateFontsTexture()
|
|||||||
|
|
||||||
bool ImGui_ImplGlfwGL3_CreateDeviceObjects()
|
bool ImGui_ImplGlfwGL3_CreateDeviceObjects()
|
||||||
{
|
{
|
||||||
|
// Backup GL state
|
||||||
|
GLint last_texture, last_array_buffer, last_vertex_array;
|
||||||
|
glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
||||||
|
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
|
||||||
|
glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array);
|
||||||
|
|
||||||
const GLchar *vertex_shader =
|
const GLchar *vertex_shader =
|
||||||
"#version 330\n"
|
"#version 330\n"
|
||||||
"uniform mat4 ProjMtx;\n"
|
"uniform mat4 ProjMtx;\n"
|
||||||
@ -217,11 +231,14 @@ bool ImGui_ImplGlfwGL3_CreateDeviceObjects()
|
|||||||
glVertexAttribPointer(g_AttribLocationUV, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)OFFSETOF(ImDrawVert, uv));
|
glVertexAttribPointer(g_AttribLocationUV, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)OFFSETOF(ImDrawVert, uv));
|
||||||
glVertexAttribPointer(g_AttribLocationColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ImDrawVert), (GLvoid*)OFFSETOF(ImDrawVert, col));
|
glVertexAttribPointer(g_AttribLocationColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ImDrawVert), (GLvoid*)OFFSETOF(ImDrawVert, col));
|
||||||
#undef OFFSETOF
|
#undef OFFSETOF
|
||||||
glBindVertexArray(0);
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
|
||||||
|
|
||||||
ImGui_ImplGlfwGL3_CreateFontsTexture();
|
ImGui_ImplGlfwGL3_CreateFontsTexture();
|
||||||
|
|
||||||
|
// Restore modified GL state
|
||||||
|
glBindTexture(GL_TEXTURE_2D, last_texture);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
|
||||||
|
glBindVertexArray(last_vertex_array);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,7 +270,7 @@ bool ImGui_ImplGlfwGL3_Init(GLFWwindow* window, bool install_callbacks)
|
|||||||
io.RenderDrawListsFn = ImGui_ImplGlfwGL3_RenderDrawLists;
|
io.RenderDrawListsFn = ImGui_ImplGlfwGL3_RenderDrawLists;
|
||||||
io.SetClipboardTextFn = ImGui_ImplGlfwGL3_SetClipboardText;
|
io.SetClipboardTextFn = ImGui_ImplGlfwGL3_SetClipboardText;
|
||||||
io.GetClipboardTextFn = ImGui_ImplGlfwGL3_GetClipboardText;
|
io.GetClipboardTextFn = ImGui_ImplGlfwGL3_GetClipboardText;
|
||||||
#ifdef _MSC_VER
|
#ifdef _WIN32
|
||||||
io.ImeWindowHandle = glfwGetWin32Window(g_Window);
|
io.ImeWindowHandle = glfwGetWin32Window(g_Window);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -307,7 +324,8 @@ void ImGui_ImplGlfwGL3_NewFrame()
|
|||||||
int display_w, display_h;
|
int display_w, display_h;
|
||||||
glfwGetWindowSize(g_Window, &w, &h);
|
glfwGetWindowSize(g_Window, &w, &h);
|
||||||
glfwGetFramebufferSize(g_Window, &display_w, &display_h);
|
glfwGetFramebufferSize(g_Window, &display_w, &display_h);
|
||||||
io.DisplaySize = ImVec2((float)display_w, (float)display_h);
|
io.DisplaySize = ImVec2((float)w, (float)h);
|
||||||
|
io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h);
|
||||||
|
|
||||||
// Setup time step
|
// Setup time step
|
||||||
double current_time = glfwGetTime();
|
double current_time = glfwGetTime();
|
||||||
@ -320,9 +338,7 @@ void ImGui_ImplGlfwGL3_NewFrame()
|
|||||||
{
|
{
|
||||||
double mouse_x, mouse_y;
|
double mouse_x, mouse_y;
|
||||||
glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
|
glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
|
||||||
mouse_x *= (float)display_w / w; // Convert mouse coordinates to pixels
|
io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
|
||||||
mouse_y *= (float)display_h / h;
|
|
||||||
io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
|
|
||||||
struct GLFWwindow;
|
struct GLFWwindow;
|
||||||
|
|
||||||
bool ImGui_ImplGlfwGL3_Init(GLFWwindow* window, bool install_callbacks);
|
IMGUI_API bool ImGui_ImplGlfwGL3_Init(GLFWwindow* window, bool install_callbacks);
|
||||||
void ImGui_ImplGlfwGL3_Shutdown();
|
IMGUI_API void ImGui_ImplGlfwGL3_Shutdown();
|
||||||
void ImGui_ImplGlfwGL3_NewFrame();
|
IMGUI_API void ImGui_ImplGlfwGL3_NewFrame();
|
||||||
|
|
||||||
// Use if you want to reset your rendering device without losing ImGui state.
|
// Use if you want to reset your rendering device without losing ImGui state.
|
||||||
void ImGui_ImplGlfwGL3_InvalidateDeviceObjects();
|
IMGUI_API void ImGui_ImplGlfwGL3_InvalidateDeviceObjects();
|
||||||
bool ImGui_ImplGlfwGL3_CreateDeviceObjects();
|
IMGUI_API bool ImGui_ImplGlfwGL3_CreateDeviceObjects();
|
||||||
|
|
||||||
// GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization)
|
// GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization)
|
||||||
// Provided here if you want to chain callbacks.
|
// Provided here if you want to chain callbacks.
|
||||||
// You can also handle inputs yourself and use those as a reference.
|
// You can also handle inputs yourself and use those as a reference.
|
||||||
void ImGui_ImplGlfwGL3_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
|
IMGUI_API void ImGui_ImplGlfwGL3_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
|
||||||
void ImGui_ImplGlfwGL3_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
|
IMGUI_API void ImGui_ImplGlfwGL3_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
|
||||||
void ImGui_ImplGlfwGL3_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
|
IMGUI_API void ImGui_ImplGlfwGL3_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
|
||||||
void ImGui_ImplGlfwGL3_CharCallback(GLFWwindow* window, unsigned int c);
|
IMGUI_API void ImGui_ImplGlfwGL3_CharCallback(GLFWwindow* window, unsigned int c);
|
||||||
|
@ -53,7 +53,6 @@ int main(int, char**)
|
|||||||
// Main loop
|
// Main loop
|
||||||
while (!glfwWindowShouldClose(window))
|
while (!glfwWindowShouldClose(window))
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
ImGui_ImplGlfwGL3_NewFrame();
|
ImGui_ImplGlfwGL3_NewFrame();
|
||||||
|
|
||||||
@ -86,7 +85,9 @@ int main(int, char**)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Rendering
|
// Rendering
|
||||||
glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y);
|
int display_w, display_h;
|
||||||
|
glfwGetFramebufferSize(window, &display_w, &display_h);
|
||||||
|
glViewport(0, 0, display_w, display_h);
|
||||||
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
|
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#CXX = g++
|
#CXX = g++
|
||||||
|
|
||||||
|
EXE = opengl_example
|
||||||
OBJS = main.o imgui_impl_glfw.o
|
OBJS = main.o imgui_impl_glfw.o
|
||||||
OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o
|
OBJS += ../../imgui.o ../../imgui_demo.o ../../imgui_draw.o
|
||||||
|
|
||||||
@ -21,7 +22,7 @@ ifeq ($(UNAME_S), Linux) #LINUX
|
|||||||
LIBS = `pkg-config --static --libs glfw3`
|
LIBS = `pkg-config --static --libs glfw3`
|
||||||
|
|
||||||
CXXFLAGS = -I../../ `pkg-config --cflags glfw3`
|
CXXFLAGS = -I../../ `pkg-config --cflags glfw3`
|
||||||
CXXFLAGS += -Wall
|
CXXFLAGS += -Wall -Wformat
|
||||||
CFLAGS = $(CXXFLAGS)
|
CFLAGS = $(CXXFLAGS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -32,7 +33,7 @@ ifeq ($(UNAME_S), Darwin) #APPLE
|
|||||||
LIBS += -lglfw3
|
LIBS += -lglfw3
|
||||||
|
|
||||||
CXXFLAGS = -I../../ -I/usr/local/include
|
CXXFLAGS = -I../../ -I/usr/local/include
|
||||||
CXXFLAGS += -Wall
|
CXXFLAGS += -Wall -Wformat
|
||||||
# CXXFLAGS += -D__APPLE__
|
# CXXFLAGS += -D__APPLE__
|
||||||
CFLAGS = $(CXXFLAGS)
|
CFLAGS = $(CXXFLAGS)
|
||||||
endif
|
endif
|
||||||
@ -40,12 +41,12 @@ endif
|
|||||||
.cpp.o:
|
.cpp.o:
|
||||||
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
all:imgui_example
|
all: $(EXE)
|
||||||
@echo Build complete for $(ECHO_MESSAGE)
|
@echo Build complete for $(ECHO_MESSAGE)
|
||||||
|
|
||||||
imgui_example:$(OBJS)
|
$(EXE): $(OBJS)
|
||||||
$(CXX) -o imgui_example $(OBJS) $(CXXFLAGS) $(LIBS)
|
$(CXX) -o $(EXE) $(OBJS) $(CXXFLAGS) $(LIBS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm $(OBJS)
|
rm $(EXE) $(OBJS)
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
// GLFW
|
// GLFW
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
#ifdef _MSC_VER
|
#ifdef _WIN32
|
||||||
#undef APIENTRY
|
#undef APIENTRY
|
||||||
#define GLFW_EXPOSE_NATIVE_WIN32
|
#define GLFW_EXPOSE_NATIVE_WIN32
|
||||||
#define GLFW_EXPOSE_NATIVE_WGL
|
#define GLFW_EXPOSE_NATIVE_WGL
|
||||||
@ -28,6 +28,8 @@ static void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
// We are using the OpenGL fixed pipeline to make the example code simpler to read!
|
// 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.
|
// 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.
|
||||||
|
GLint last_texture;
|
||||||
|
glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
||||||
glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
|
glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
@ -40,13 +42,16 @@ static void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
//glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context
|
//glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context
|
||||||
|
|
||||||
|
// Handle cases of screen coordinates != from framebuffer coordinates (e.g. retina displays)
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
float fb_height = io.DisplaySize.y * io.DisplayFramebufferScale.y;
|
||||||
|
draw_data->ScaleClipRects(io.DisplayFramebufferScale);
|
||||||
|
|
||||||
// Setup orthographic projection matrix
|
// Setup orthographic projection matrix
|
||||||
const float width = ImGui::GetIO().DisplaySize.x;
|
|
||||||
const float height = ImGui::GetIO().DisplaySize.y;
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glOrtho(0.0f, width, height, 0.0f, -1.0f, +1.0f);
|
glOrtho(0.0f, io.DisplaySize.x, io.DisplaySize.y, 0.0f, -1.0f, +1.0f);
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
@ -72,7 +77,7 @@ static void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
|
glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
|
||||||
glScissor((int)pcmd->ClipRect.x, (int)(height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
|
glScissor((int)pcmd->ClipRect.x, (int)(fb_height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
|
||||||
glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, GL_UNSIGNED_SHORT, idx_buffer);
|
glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, GL_UNSIGNED_SHORT, idx_buffer);
|
||||||
}
|
}
|
||||||
idx_buffer += pcmd->ElemCount;
|
idx_buffer += pcmd->ElemCount;
|
||||||
@ -84,7 +89,7 @@ static void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
glDisableClientState(GL_COLOR_ARRAY);
|
glDisableClientState(GL_COLOR_ARRAY);
|
||||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
glDisableClientState(GL_VERTEX_ARRAY);
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, last_texture);
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
@ -144,6 +149,8 @@ bool ImGui_ImplGlfw_CreateDeviceObjects()
|
|||||||
io.Fonts->GetTexDataAsAlpha8(&pixels, &width, &height);
|
io.Fonts->GetTexDataAsAlpha8(&pixels, &width, &height);
|
||||||
|
|
||||||
// Create texture
|
// Create texture
|
||||||
|
GLint last_texture;
|
||||||
|
glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
||||||
glGenTextures(1, &g_FontTexture);
|
glGenTextures(1, &g_FontTexture);
|
||||||
glBindTexture(GL_TEXTURE_2D, g_FontTexture);
|
glBindTexture(GL_TEXTURE_2D, g_FontTexture);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
@ -156,6 +163,7 @@ bool ImGui_ImplGlfw_CreateDeviceObjects()
|
|||||||
// Cleanup (don't clear the input data if you want to append new fonts later)
|
// Cleanup (don't clear the input data if you want to append new fonts later)
|
||||||
io.Fonts->ClearInputData();
|
io.Fonts->ClearInputData();
|
||||||
io.Fonts->ClearTexData();
|
io.Fonts->ClearTexData();
|
||||||
|
glBindTexture(GL_TEXTURE_2D, last_texture);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -198,7 +206,7 @@ bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks)
|
|||||||
io.RenderDrawListsFn = ImGui_ImplGlfw_RenderDrawLists;
|
io.RenderDrawListsFn = ImGui_ImplGlfw_RenderDrawLists;
|
||||||
io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
|
io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
|
||||||
io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
|
io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
|
||||||
#ifdef _MSC_VER
|
#ifdef _WIN32
|
||||||
io.ImeWindowHandle = glfwGetWin32Window(g_Window);
|
io.ImeWindowHandle = glfwGetWin32Window(g_Window);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -231,7 +239,8 @@ void ImGui_ImplGlfw_NewFrame()
|
|||||||
int display_w, display_h;
|
int display_w, display_h;
|
||||||
glfwGetWindowSize(g_Window, &w, &h);
|
glfwGetWindowSize(g_Window, &w, &h);
|
||||||
glfwGetFramebufferSize(g_Window, &display_w, &display_h);
|
glfwGetFramebufferSize(g_Window, &display_w, &display_h);
|
||||||
io.DisplaySize = ImVec2((float)display_w, (float)display_h);
|
io.DisplaySize = ImVec2((float)w, (float)h);
|
||||||
|
io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h);
|
||||||
|
|
||||||
// Setup time step
|
// Setup time step
|
||||||
double current_time = glfwGetTime();
|
double current_time = glfwGetTime();
|
||||||
@ -244,9 +253,7 @@ void ImGui_ImplGlfw_NewFrame()
|
|||||||
{
|
{
|
||||||
double mouse_x, mouse_y;
|
double mouse_x, mouse_y;
|
||||||
glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
|
glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
|
||||||
mouse_x *= (float)display_w / w; // Convert mouse coordinates to pixels
|
io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
|
||||||
mouse_y *= (float)display_h / h;
|
|
||||||
io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3,18 +3,18 @@
|
|||||||
|
|
||||||
struct GLFWwindow;
|
struct GLFWwindow;
|
||||||
|
|
||||||
bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks);
|
IMGUI_API bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks);
|
||||||
void ImGui_ImplGlfw_Shutdown();
|
IMGUI_API void ImGui_ImplGlfw_Shutdown();
|
||||||
void ImGui_ImplGlfw_NewFrame();
|
IMGUI_API void ImGui_ImplGlfw_NewFrame();
|
||||||
|
|
||||||
// Use if you want to reset your rendering device without losing ImGui state.
|
// Use if you want to reset your rendering device without losing ImGui state.
|
||||||
void ImGui_ImplGlfw_InvalidateDeviceObjects();
|
IMGUI_API void ImGui_ImplGlfw_InvalidateDeviceObjects();
|
||||||
bool ImGui_ImplGlfw_CreateDeviceObjects();
|
IMGUI_API bool ImGui_ImplGlfw_CreateDeviceObjects();
|
||||||
|
|
||||||
// GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization)
|
// GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization)
|
||||||
// Provided here if you want to chain callbacks.
|
// Provided here if you want to chain callbacks.
|
||||||
// You can also handle inputs yourself and use those as a reference.
|
// You can also handle inputs yourself and use those as a reference.
|
||||||
void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
|
IMGUI_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
|
||||||
void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
|
IMGUI_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
|
||||||
void ImGui_ImplGlFw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
|
IMGUI_API void ImGui_ImplGlFw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
|
||||||
void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
|
IMGUI_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
|
||||||
|
@ -77,7 +77,9 @@ int main(int, char**)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Rendering
|
// Rendering
|
||||||
glViewport(0, 0, (int)ImGui::GetIO().DisplaySize.x, (int)ImGui::GetIO().DisplaySize.y);
|
int display_w, display_h;
|
||||||
|
glfwGetFramebufferSize(window, &display_w, &display_h);
|
||||||
|
glViewport(0, 0, display_w, display_h);
|
||||||
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
|
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
|
@ -9,8 +9,15 @@
|
|||||||
cl /MD /I <sdl2path\include> /I ..\.. main.cpp imgui_impl_sdl.cpp ..\..\imgui*.cpp /link /LIBPATH:<sdl2path\lib> SDL2.lib SDL2main.lib
|
cl /MD /I <sdl2path\include> /I ..\.. main.cpp imgui_impl_sdl.cpp ..\..\imgui*.cpp /link /LIBPATH:<sdl2path\lib> SDL2.lib SDL2main.lib
|
||||||
```
|
```
|
||||||
|
|
||||||
- On Linux and similar Unices
|
- On Linux and similar Unixes
|
||||||
|
|
||||||
```
|
```
|
||||||
c++ `sdl2-config --cflags` -I ../.. main.cpp imgui_impl_sdl.cpp ../../imgui*.cpp `sdl2-config --libs` -lGL -o sdl2example
|
c++ `sdl2-config --cflags` -I ../.. main.cpp imgui_impl_sdl.cpp ../../imgui*.cpp `sdl2-config --libs` -lGL -o sdl2example
|
||||||
```
|
```
|
||||||
|
|
||||||
|
- On Mac OS X
|
||||||
|
|
||||||
|
```
|
||||||
|
brew install sdl2
|
||||||
|
c++ `sdl2-config --cflags` -I ../.. main.cpp imgui_impl_sdl.cpp ../../imgui*.cpp `sdl2-config --libs` -framework OpenGl -o sdl2example
|
||||||
|
```
|
||||||
|
@ -198,7 +198,7 @@ bool ImGui_ImplSdl_Init(SDL_Window *window)
|
|||||||
io.SetClipboardTextFn = ImGui_ImplSdl_SetClipboardText;
|
io.SetClipboardTextFn = ImGui_ImplSdl_SetClipboardText;
|
||||||
io.GetClipboardTextFn = ImGui_ImplSdl_GetClipboardText;
|
io.GetClipboardTextFn = ImGui_ImplSdl_GetClipboardText;
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _WIN32
|
||||||
SDL_SysWMinfo wmInfo;
|
SDL_SysWMinfo wmInfo;
|
||||||
SDL_VERSION(&wmInfo.version);
|
SDL_VERSION(&wmInfo.version);
|
||||||
SDL_GetWindowWMInfo(window, &wmInfo);
|
SDL_GetWindowWMInfo(window, &wmInfo);
|
||||||
|
@ -4,11 +4,11 @@
|
|||||||
struct SDL_Window;
|
struct SDL_Window;
|
||||||
typedef union SDL_Event SDL_Event;
|
typedef union SDL_Event SDL_Event;
|
||||||
|
|
||||||
bool ImGui_ImplSdl_Init(SDL_Window *window);
|
IMGUI_API bool ImGui_ImplSdl_Init(SDL_Window *window);
|
||||||
void ImGui_ImplSdl_Shutdown();
|
IMGUI_API void ImGui_ImplSdl_Shutdown();
|
||||||
void ImGui_ImplSdl_NewFrame(SDL_Window *window);
|
IMGUI_API void ImGui_ImplSdl_NewFrame(SDL_Window *window);
|
||||||
bool ImGui_ImplSdl_ProcessEvent(SDL_Event* event);
|
IMGUI_API bool ImGui_ImplSdl_ProcessEvent(SDL_Event* event);
|
||||||
|
|
||||||
// Use if you want to reset your rendering device without losing ImGui state.
|
// Use if you want to reset your rendering device without losing ImGui state.
|
||||||
void ImGui_ImplSdl_InvalidateDeviceObjects();
|
IMGUI_API void ImGui_ImplSdl_InvalidateDeviceObjects();
|
||||||
bool ImGui_ImplSdl_CreateDeviceObjects();
|
IMGUI_API bool ImGui_ImplSdl_CreateDeviceObjects();
|
||||||
|
@ -97,6 +97,9 @@
|
|||||||
|
|
||||||
Typefaces for source code beautification
|
Typefaces for source code beautification
|
||||||
https://github.com/chrissimpkins/codeface
|
https://github.com/chrissimpkins/codeface
|
||||||
|
|
||||||
|
Programmation fonts
|
||||||
|
http://s9w.github.io/font_compare/
|
||||||
|
|
||||||
Proggy Programming Fonts
|
Proggy Programming Fonts
|
||||||
http://upperbounds.net
|
http://upperbounds.net
|
||||||
|
197
imgui.h
197
imgui.h
@ -1,4 +1,4 @@
|
|||||||
// ImGui library v1.44
|
// ImGui library v1.45 WIP
|
||||||
// Headers
|
// Headers
|
||||||
|
|
||||||
// See imgui.cpp file for documentation.
|
// See imgui.cpp file for documentation.
|
||||||
@ -17,7 +17,7 @@
|
|||||||
#include <stdlib.h> // NULL, malloc, free, qsort, atoi
|
#include <stdlib.h> // NULL, malloc, free, qsort, atoi
|
||||||
#include <string.h> // memset, memmove, memcpy, strlen, strchr, strcpy, strcmp
|
#include <string.h> // memset, memmove, memcpy, strlen, strchr, strcpy, strcmp
|
||||||
|
|
||||||
#define IMGUI_VERSION "1.44"
|
#define IMGUI_VERSION "1.45 WIP"
|
||||||
|
|
||||||
// Define assertion handler.
|
// Define assertion handler.
|
||||||
#ifndef IM_ASSERT
|
#ifndef IM_ASSERT
|
||||||
@ -30,6 +30,12 @@
|
|||||||
#define IMGUI_API
|
#define IMGUI_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__clang__) || defined(__GNUC__)
|
||||||
|
#define IM_PRINTFARGS(FMT) __attribute__((format(printf, FMT, (FMT+1))))
|
||||||
|
#else
|
||||||
|
#define IM_PRINTFARGS(FMT)
|
||||||
|
#endif
|
||||||
|
|
||||||
// Forward declarations
|
// Forward declarations
|
||||||
struct ImDrawCmd;
|
struct ImDrawCmd;
|
||||||
struct ImDrawList;
|
struct ImDrawList;
|
||||||
@ -54,7 +60,7 @@ typedef int ImGuiWindowFlags; // enum ImGuiWindowFlags_
|
|||||||
typedef int ImGuiSetCond; // enum ImGuiSetCond_
|
typedef int ImGuiSetCond; // enum ImGuiSetCond_
|
||||||
typedef int ImGuiInputTextFlags; // enum ImGuiInputTextFlags_
|
typedef int ImGuiInputTextFlags; // enum ImGuiInputTextFlags_
|
||||||
typedef int ImGuiSelectableFlags; // enum ImGuiSelectableFlags_
|
typedef int ImGuiSelectableFlags; // enum ImGuiSelectableFlags_
|
||||||
struct ImGuiTextEditCallbackData; // for advanced uses of InputText()
|
struct ImGuiTextEditCallbackData; // for advanced uses of InputText()
|
||||||
typedef int (*ImGuiTextEditCallback)(ImGuiTextEditCallbackData *data);
|
typedef int (*ImGuiTextEditCallback)(ImGuiTextEditCallbackData *data);
|
||||||
|
|
||||||
struct ImVec2
|
struct ImVec2
|
||||||
@ -87,7 +93,7 @@ struct ImVec4
|
|||||||
// - struct ImGuiStorage // Custom key value storage (if you need to alter open/close states manually)
|
// - struct ImGuiStorage // Custom key value storage (if you need to alter open/close states manually)
|
||||||
// - struct ImGuiTextEditCallbackData // Shared state of ImGui::InputText() when using custom callbacks
|
// - struct ImGuiTextEditCallbackData // Shared state of ImGui::InputText() when using custom callbacks
|
||||||
// - struct ImGuiListClipper // Helper to manually clip large list of items.
|
// - struct ImGuiListClipper // Helper to manually clip large list of items.
|
||||||
// - struct ImColor // Helper functions to created packed 32-bit RGBA color values
|
// - struct ImColor // Helper functions to created packed 32-bit RGBA color values
|
||||||
// - struct ImDrawList // Draw command list
|
// - struct ImDrawList // Draw command list
|
||||||
// - struct ImFontAtlas // Bake multiple fonts into a single texture, TTF font loader, bake glyphs into bitmap
|
// - struct ImFontAtlas // Bake multiple fonts into a single texture, TTF font loader, bake glyphs into bitmap
|
||||||
// - struct ImFont // Single font
|
// - struct ImFont // Single font
|
||||||
@ -108,16 +114,18 @@ namespace ImGui
|
|||||||
IMGUI_API void ShowMetricsWindow(bool* opened = NULL); // metrics window for debugging imgui
|
IMGUI_API void ShowMetricsWindow(bool* opened = NULL); // metrics window for debugging imgui
|
||||||
|
|
||||||
// Window
|
// Window
|
||||||
IMGUI_API bool Begin(const char* name = "Debug", bool* p_opened = NULL, ImGuiWindowFlags flags = 0); // see .cpp for details. return false when window is collapsed, so you can early out in your code. 'bool* p_opened' creates a widget on the upper-right to close the window (which sets your bool to false).
|
IMGUI_API bool Begin(const char* name, bool* p_opened = NULL, ImGuiWindowFlags flags = 0); // see .cpp for details. return false when window is collapsed, so you can early out in your code. 'bool* p_opened' creates a widget on the upper-right to close the window (which sets your bool to false).
|
||||||
IMGUI_API bool Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_use, float bg_alpha = -1.0f, ImGuiWindowFlags flags = 0); // this is the older/longer API. call SetNextWindowSize() instead if you want to set a window size. For regular windows, 'size_on_first_use' only applies to the first time EVER the window is created and probably not what you want! maybe obsolete this API eventually.
|
IMGUI_API bool Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_use, float bg_alpha = -1.0f, ImGuiWindowFlags flags = 0); // this is the older/longer API. call SetNextWindowSize() instead if you want to set a window size. For regular windows, 'size_on_first_use' only applies to the first time EVER the window is created and probably not what you want! maybe obsolete this API eventually.
|
||||||
IMGUI_API void End();
|
IMGUI_API void End();
|
||||||
IMGUI_API bool BeginChild(const char* str_id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0); // 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).
|
IMGUI_API bool BeginChild(const char* str_id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0); // 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).
|
||||||
IMGUI_API bool BeginChild(ImGuiID id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0); // "
|
IMGUI_API bool BeginChild(ImGuiID id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0); // "
|
||||||
IMGUI_API void EndChild();
|
IMGUI_API void EndChild();
|
||||||
IMGUI_API ImVec2 GetContentRegionMax(); // window or current column boundaries, in windows coordinates
|
IMGUI_API ImVec2 GetContentRegionMax(); // current content boundaries (typically window boundaries including scrolling, or current column boundaries), in windows coordinates
|
||||||
IMGUI_API ImVec2 GetContentRegionAvail(); // == GetContentRegionMax() - GetCursorPos()
|
IMGUI_API ImVec2 GetContentRegionAvail(); // == GetContentRegionMax() - GetCursorPos()
|
||||||
IMGUI_API ImVec2 GetWindowContentRegionMin(); // window boundaries, in windows coordinates
|
IMGUI_API float GetContentRegionAvailWidth(); //
|
||||||
IMGUI_API ImVec2 GetWindowContentRegionMax();
|
IMGUI_API ImVec2 GetWindowContentRegionMin(); // content boundaries min (roughly (0,0)-Scroll), in window coordinates
|
||||||
|
IMGUI_API ImVec2 GetWindowContentRegionMax(); // content boundaries max (roughly (0,0)+Size-Scroll) where Size can be override with SetNextWindowContentSize(), in window coordinates
|
||||||
|
IMGUI_API float GetWindowContentRegionWidth(); //
|
||||||
IMGUI_API ImDrawList* GetWindowDrawList(); // get rendering command-list if you want to append your own draw primitives
|
IMGUI_API ImDrawList* GetWindowDrawList(); // get rendering command-list if you want to append your own draw primitives
|
||||||
IMGUI_API ImFont* GetWindowFont();
|
IMGUI_API ImFont* GetWindowFont();
|
||||||
IMGUI_API float GetWindowFontSize(); // size (also height in pixels) of current font with current scale applied
|
IMGUI_API float GetWindowFontSize(); // size (also height in pixels) of current font with current scale applied
|
||||||
@ -125,11 +133,14 @@ namespace ImGui
|
|||||||
IMGUI_API ImVec2 GetWindowPos(); // get current window position in screen space (useful if you want to do your own drawing via the DrawList api)
|
IMGUI_API ImVec2 GetWindowPos(); // get current window position in screen space (useful if you want to do your own drawing via the DrawList api)
|
||||||
IMGUI_API ImVec2 GetWindowSize(); // get current window size
|
IMGUI_API ImVec2 GetWindowSize(); // get current window size
|
||||||
IMGUI_API float GetWindowWidth();
|
IMGUI_API float GetWindowWidth();
|
||||||
|
IMGUI_API float GetWindowHeight();
|
||||||
IMGUI_API bool IsWindowCollapsed();
|
IMGUI_API bool IsWindowCollapsed();
|
||||||
|
|
||||||
IMGUI_API void SetNextWindowPos(const ImVec2& pos, ImGuiSetCond cond = 0); // set next window position. call before Begin()
|
IMGUI_API void SetNextWindowPos(const ImVec2& pos, ImGuiSetCond cond = 0); // set next window position. call before Begin()
|
||||||
IMGUI_API void SetNextWindowPosCenter(ImGuiSetCond cond = 0); // set next window position to be centered on screen. call before Begin()
|
IMGUI_API void SetNextWindowPosCenter(ImGuiSetCond cond = 0); // set next window position to be centered on screen. call before Begin()
|
||||||
IMGUI_API void SetNextWindowSize(const ImVec2& size, ImGuiSetCond cond = 0); // set next window size. set to ImVec2(0,0) to force an auto-fit. call before Begin()
|
IMGUI_API 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()
|
||||||
|
IMGUI_API 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()
|
||||||
|
IMGUI_API void SetNextWindowContentWidth(float width); // set next window content width (enforce the range of horizontal scrollbar). call before Begin()
|
||||||
IMGUI_API void SetNextWindowCollapsed(bool collapsed, ImGuiSetCond cond = 0); // set next window collapsed state. call before Begin()
|
IMGUI_API void SetNextWindowCollapsed(bool collapsed, ImGuiSetCond cond = 0); // set next window collapsed state. call before Begin()
|
||||||
IMGUI_API void SetNextWindowFocus(); // set next window to be focused / front-most. call before Begin()
|
IMGUI_API void SetNextWindowFocus(); // set next window to be focused / front-most. call before Begin()
|
||||||
IMGUI_API void SetWindowPos(const ImVec2& pos, ImGuiSetCond cond = 0); // set current window position - call within Begin()/End(). may incur tearing
|
IMGUI_API void SetWindowPos(const ImVec2& pos, ImGuiSetCond cond = 0); // set current window position - call within Begin()/End(). may incur tearing
|
||||||
@ -137,12 +148,15 @@ namespace ImGui
|
|||||||
IMGUI_API void SetWindowCollapsed(bool collapsed, ImGuiSetCond cond = 0); // set current window collapsed state
|
IMGUI_API void SetWindowCollapsed(bool collapsed, ImGuiSetCond cond = 0); // set current window collapsed state
|
||||||
IMGUI_API void SetWindowFocus(); // set current window to be focused / front-most
|
IMGUI_API void SetWindowFocus(); // set current window to be focused / front-most
|
||||||
IMGUI_API void SetWindowPos(const char* name, const ImVec2& pos, ImGuiSetCond cond = 0); // set named window position - call within Begin()/End(). may incur tearing
|
IMGUI_API void SetWindowPos(const char* name, const ImVec2& pos, ImGuiSetCond cond = 0); // set named window position - call within Begin()/End(). may incur tearing
|
||||||
IMGUI_API void SetWindowSize(const char* name, const ImVec2& size, ImGuiSetCond cond = 0); // set named window size. set to ImVec2(0,0) to force an auto-fit. may incur tearing
|
IMGUI_API 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
|
||||||
IMGUI_API void SetWindowCollapsed(const char* name, bool collapsed, ImGuiSetCond cond = 0); // set named window collapsed state
|
IMGUI_API void SetWindowCollapsed(const char* name, bool collapsed, ImGuiSetCond cond = 0); // set named window collapsed state
|
||||||
IMGUI_API void SetWindowFocus(const char* name); // set named window to be focused / front-most. use NULL to remove focus.
|
IMGUI_API void SetWindowFocus(const char* name); // set named window to be focused / front-most. use NULL to remove focus.
|
||||||
|
|
||||||
|
IMGUI_API float GetScrollX(); // get scrolling amount [0..GetScrollMaxX()]
|
||||||
IMGUI_API float GetScrollY(); // get scrolling amount [0..GetScrollMaxY()]
|
IMGUI_API float GetScrollY(); // get scrolling amount [0..GetScrollMaxY()]
|
||||||
IMGUI_API float GetScrollMaxY(); // get maximum scrolling amount == ContentSize.Y - WindowSize.Y
|
IMGUI_API float GetScrollMaxX(); // get maximum scrolling amount ~~ ContentSize.X - WindowSize.X
|
||||||
|
IMGUI_API float GetScrollMaxY(); // get maximum scrolling amount ~~ ContentSize.Y - WindowSize.Y
|
||||||
|
IMGUI_API void SetScrollX(float scroll_x); // set scrolling amount [0..GetScrollMaxX()]
|
||||||
IMGUI_API void SetScrollY(float scroll_y); // set scrolling amount [0..GetScrollMaxY()]
|
IMGUI_API void SetScrollY(float scroll_y); // set scrolling amount [0..GetScrollMaxY()]
|
||||||
IMGUI_API 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.
|
IMGUI_API 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.
|
||||||
IMGUI_API 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.
|
IMGUI_API 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.
|
||||||
@ -167,14 +181,14 @@ namespace ImGui
|
|||||||
IMGUI_API void PopAllowKeyboardFocus();
|
IMGUI_API void PopAllowKeyboardFocus();
|
||||||
IMGUI_API 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
|
IMGUI_API 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
|
||||||
IMGUI_API void PopTextWrapPos();
|
IMGUI_API void PopTextWrapPos();
|
||||||
IMGUI_API void PushButtonRepeat(bool repeat); // in 'repeat' mode, Button*() functions return true multiple times as you hold them (uses io.KeyRepeatDelay/io.KeyRepeatRate for now)
|
IMGUI_API 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.
|
||||||
IMGUI_API void PopButtonRepeat();
|
IMGUI_API void PopButtonRepeat();
|
||||||
|
|
||||||
// Cursor / Layout
|
// Cursor / Layout
|
||||||
IMGUI_API void BeginGroup(); // once closing a group it is seen as a single item (so you can use IsItemHovered() on a group, SameLine() between groups, etc.
|
IMGUI_API 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.
|
||||||
IMGUI_API void EndGroup();
|
IMGUI_API void EndGroup();
|
||||||
IMGUI_API void Separator(); // horizontal line
|
IMGUI_API void Separator(); // horizontal line
|
||||||
IMGUI_API void SameLine(float pos_x = 0.0f, float spacing_w = -1.0f); // call between widgets or groups to layout them horizontally
|
IMGUI_API void SameLine(float local_pos_x = 0.0f, float spacing_w = -1.0f); // call between widgets or groups to layout them horizontally
|
||||||
IMGUI_API void Spacing(); // add spacing
|
IMGUI_API void Spacing(); // add spacing
|
||||||
IMGUI_API void Dummy(const ImVec2& size); // add a dummy item of given size
|
IMGUI_API void Dummy(const ImVec2& size); // add a dummy item of given size
|
||||||
IMGUI_API void Indent(); // move content position toward the right by style.IndentSpacing pixels
|
IMGUI_API void Indent(); // move content position toward the right by style.IndentSpacing pixels
|
||||||
@ -189,10 +203,10 @@ namespace ImGui
|
|||||||
IMGUI_API ImVec2 GetCursorPos(); // cursor position is relative to window position
|
IMGUI_API ImVec2 GetCursorPos(); // cursor position is relative to window position
|
||||||
IMGUI_API float GetCursorPosX(); // "
|
IMGUI_API float GetCursorPosX(); // "
|
||||||
IMGUI_API float GetCursorPosY(); // "
|
IMGUI_API float GetCursorPosY(); // "
|
||||||
IMGUI_API void SetCursorPos(const ImVec2& pos); // "
|
IMGUI_API void SetCursorPos(const ImVec2& local_pos); // "
|
||||||
IMGUI_API void SetCursorPosX(float x); // "
|
IMGUI_API void SetCursorPosX(float x); // "
|
||||||
IMGUI_API void SetCursorPosY(float y); // "
|
IMGUI_API void SetCursorPosY(float y); // "
|
||||||
IMGUI_API ImVec2 GetCursorStartPos(); // initial cursor position
|
IMGUI_API ImVec2 GetCursorStartPos(); // initial cursor position
|
||||||
IMGUI_API ImVec2 GetCursorScreenPos(); // cursor position in absolute screen coordinates [0..io.DisplaySize]
|
IMGUI_API ImVec2 GetCursorScreenPos(); // cursor position in absolute screen coordinates [0..io.DisplaySize]
|
||||||
IMGUI_API void SetCursorScreenPos(const ImVec2& pos); // cursor position in absolute screen coordinates [0..io.DisplaySize]
|
IMGUI_API void SetCursorScreenPos(const ImVec2& pos); // cursor position in absolute screen coordinates [0..io.DisplaySize]
|
||||||
IMGUI_API 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
|
IMGUI_API 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
|
||||||
@ -213,19 +227,19 @@ namespace ImGui
|
|||||||
IMGUI_API ImGuiID GetID(const void* ptr_id);
|
IMGUI_API ImGuiID GetID(const void* ptr_id);
|
||||||
|
|
||||||
// Widgets
|
// Widgets
|
||||||
IMGUI_API void Text(const char* fmt, ...);
|
IMGUI_API void Text(const char* fmt, ...) IM_PRINTFARGS(1);
|
||||||
IMGUI_API void TextV(const char* fmt, va_list args);
|
IMGUI_API void TextV(const char* fmt, va_list args);
|
||||||
IMGUI_API void TextColored(const ImVec4& col, const char* fmt, ...); // shortcut for PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor();
|
IMGUI_API void TextColored(const ImVec4& col, const char* fmt, ...) IM_PRINTFARGS(2); // shortcut for PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor();
|
||||||
IMGUI_API void TextColoredV(const ImVec4& col, const char* fmt, va_list args);
|
IMGUI_API void TextColoredV(const ImVec4& col, const char* fmt, va_list args);
|
||||||
IMGUI_API void TextDisabled(const char* fmt, ...); // shortcut for PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]); Text(fmt, ...); PopStyleColor();
|
IMGUI_API void TextDisabled(const char* fmt, ...) IM_PRINTFARGS(1); // shortcut for PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]); Text(fmt, ...); PopStyleColor();
|
||||||
IMGUI_API void TextDisabledV(const char* fmt, va_list args);
|
IMGUI_API void TextDisabledV(const char* fmt, va_list args);
|
||||||
IMGUI_API void TextWrapped(const char* fmt, ...); // 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().
|
IMGUI_API 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().
|
||||||
IMGUI_API void TextWrappedV(const char* fmt, va_list args);
|
IMGUI_API void TextWrappedV(const char* fmt, va_list args);
|
||||||
IMGUI_API 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
|
IMGUI_API 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
|
||||||
IMGUI_API void LabelText(const char* label, const char* fmt, ...); // display text+label aligned the same way as value+label widgets
|
IMGUI_API void LabelText(const char* label, const char* fmt, ...) IM_PRINTFARGS(2); // display text+label aligned the same way as value+label widgets
|
||||||
IMGUI_API void LabelTextV(const char* label, const char* fmt, va_list args);
|
IMGUI_API void LabelTextV(const char* label, const char* fmt, va_list args);
|
||||||
IMGUI_API void Bullet();
|
IMGUI_API void Bullet();
|
||||||
IMGUI_API void BulletText(const char* fmt, ...);
|
IMGUI_API void BulletText(const char* fmt, ...) IM_PRINTFARGS(1);
|
||||||
IMGUI_API void BulletTextV(const char* fmt, va_list args);
|
IMGUI_API void BulletTextV(const char* fmt, va_list args);
|
||||||
IMGUI_API bool Button(const char* label, const ImVec2& size = ImVec2(0,0));
|
IMGUI_API bool Button(const char* label, const ImVec2& size = ImVec2(0,0));
|
||||||
IMGUI_API bool SmallButton(const char* label);
|
IMGUI_API bool SmallButton(const char* label);
|
||||||
@ -287,18 +301,18 @@ namespace ImGui
|
|||||||
IMGUI_API bool VSliderInt(const char* label, const ImVec2& size, int* v, int v_min, int v_max, const char* display_format = "%.0f");
|
IMGUI_API bool VSliderInt(const char* label, const ImVec2& size, int* v, int v_min, int v_max, const char* display_format = "%.0f");
|
||||||
|
|
||||||
// Widgets: Trees
|
// Widgets: Trees
|
||||||
IMGUI_API bool TreeNode(const char* str_label_id); // if returning 'true' the node is open and the user is responsible for calling TreePop
|
IMGUI_API bool TreeNode(const char* str_label_id); // if returning 'true' the node is open and the user is responsible for calling TreePop()
|
||||||
IMGUI_API bool TreeNode(const char* str_id, const char* fmt, ...); // "
|
IMGUI_API bool TreeNode(const char* str_id, const char* fmt, ...) IM_PRINTFARGS(2); // "
|
||||||
IMGUI_API bool TreeNode(const void* ptr_id, const char* fmt, ...); // "
|
IMGUI_API bool TreeNode(const void* ptr_id, const char* fmt, ...) IM_PRINTFARGS(2); // "
|
||||||
IMGUI_API bool TreeNodeV(const char* str_id, const char* fmt, va_list args); // "
|
IMGUI_API bool TreeNodeV(const char* str_id, const char* fmt, va_list args); // "
|
||||||
IMGUI_API bool TreeNodeV(const void* ptr_id, const char* fmt, va_list args); // "
|
IMGUI_API bool TreeNodeV(const void* ptr_id, const char* fmt, va_list args); // "
|
||||||
IMGUI_API void TreePush(const char* str_id = NULL); // already called by TreeNode(), but you can call Push/Pop yourself for layouting purpose
|
IMGUI_API void TreePush(const char* str_id = NULL); // already called by TreeNode(), but you can call Push/Pop yourself for layouting purpose
|
||||||
IMGUI_API void TreePush(const void* ptr_id = NULL); // "
|
IMGUI_API void TreePush(const void* ptr_id = NULL); // "
|
||||||
IMGUI_API void TreePop();
|
IMGUI_API void TreePop();
|
||||||
IMGUI_API void SetNextTreeNodeOpened(bool opened, ImGuiSetCond cond = 0); // set next tree node to be opened.
|
IMGUI_API void SetNextTreeNodeOpened(bool opened, ImGuiSetCond cond = 0); // set next tree node to be opened.
|
||||||
|
|
||||||
// Widgets: Selectable / Lists
|
// Widgets: Selectable / Lists
|
||||||
IMGUI_API 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
|
IMGUI_API 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
|
||||||
IMGUI_API bool Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0,0));
|
IMGUI_API bool Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0,0));
|
||||||
IMGUI_API bool ListBox(const char* label, int* current_item, const char** items, int items_count, int height_in_items = -1);
|
IMGUI_API bool ListBox(const char* label, int* current_item, const char** items, int items_count, int height_in_items = -1);
|
||||||
IMGUI_API 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);
|
IMGUI_API 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);
|
||||||
@ -315,7 +329,7 @@ namespace ImGui
|
|||||||
IMGUI_API void Color(const char* prefix, unsigned int v);
|
IMGUI_API void Color(const char* prefix, unsigned int v);
|
||||||
|
|
||||||
// Tooltip
|
// Tooltip
|
||||||
IMGUI_API void SetTooltip(const char* fmt, ...); // set tooltip under mouse-cursor, typically use with ImGui::IsHovered(). last call wins
|
IMGUI_API void SetTooltip(const char* fmt, ...) IM_PRINTFARGS(1); // set tooltip under mouse-cursor, typically use with ImGui::IsHovered(). last call wins
|
||||||
IMGUI_API void SetTooltipV(const char* fmt, va_list args);
|
IMGUI_API void SetTooltipV(const char* fmt, va_list args);
|
||||||
IMGUI_API void BeginTooltip(); // use to create full-featured tooltip windows that aren't just text
|
IMGUI_API void BeginTooltip(); // use to create full-featured tooltip windows that aren't just text
|
||||||
IMGUI_API void EndTooltip();
|
IMGUI_API void EndTooltip();
|
||||||
@ -346,20 +360,20 @@ namespace ImGui
|
|||||||
IMGUI_API void LogToClipboard(int max_depth = -1); // start logging to OS clipboard
|
IMGUI_API void LogToClipboard(int max_depth = -1); // start logging to OS clipboard
|
||||||
IMGUI_API void LogFinish(); // stop logging (close file, etc.)
|
IMGUI_API void LogFinish(); // stop logging (close file, etc.)
|
||||||
IMGUI_API void LogButtons(); // helper to display buttons for logging to tty/file/clipboard
|
IMGUI_API void LogButtons(); // helper to display buttons for logging to tty/file/clipboard
|
||||||
IMGUI_API void LogText(const char* fmt, ...); // pass text data straight to log (without being displayed)
|
IMGUI_API void LogText(const char* fmt, ...) IM_PRINTFARGS(1); // pass text data straight to log (without being displayed)
|
||||||
|
|
||||||
// Utilities
|
// Utilities
|
||||||
IMGUI_API bool IsItemHovered(); // was the last item hovered by mouse?
|
IMGUI_API bool IsItemHovered(); // was the last item hovered by mouse?
|
||||||
IMGUI_API bool IsItemHoveredRect(); // was the last item hovered by mouse? even if another item is active while we are hovering this
|
IMGUI_API bool IsItemHoveredRect(); // was the last item hovered by mouse? even if another item is active while we are hovering this
|
||||||
IMGUI_API 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)
|
IMGUI_API 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)
|
||||||
IMGUI_API bool IsItemVisible();
|
IMGUI_API bool IsItemVisible(); // was the last item visible? (aka not out of sight due to clipping/scrolling.)
|
||||||
IMGUI_API bool IsAnyItemHovered();
|
IMGUI_API bool IsAnyItemHovered();
|
||||||
IMGUI_API bool IsAnyItemActive();
|
IMGUI_API bool IsAnyItemActive();
|
||||||
IMGUI_API ImVec2 GetItemRectMin(); // get bounding rect of last item in screen space
|
IMGUI_API ImVec2 GetItemRectMin(); // get bounding rect of last item in screen space
|
||||||
IMGUI_API ImVec2 GetItemRectMax(); // "
|
IMGUI_API ImVec2 GetItemRectMax(); // "
|
||||||
IMGUI_API ImVec2 GetItemRectSize(); // "
|
IMGUI_API ImVec2 GetItemRectSize(); // "
|
||||||
IMGUI_API bool IsWindowHovered();
|
IMGUI_API bool IsWindowHovered(); // is current window hovered and hoverable (not blocked by a popup) (differentiate child windows from each others)
|
||||||
IMGUI_API bool IsWindowFocused(); // is current window focused (differentiate child windows from each others)
|
IMGUI_API bool IsWindowFocused(); // is current window focused
|
||||||
IMGUI_API bool IsRootWindowFocused(); // is current root window focused (top parent window in case of child windows)
|
IMGUI_API bool IsRootWindowFocused(); // is current root window focused (top parent window in case of child windows)
|
||||||
IMGUI_API bool IsRootWindowOrAnyChildFocused(); // is current root window or any of its child (including current window) focused
|
IMGUI_API bool IsRootWindowOrAnyChildFocused(); // is current root window or any of its child (including current window) focused
|
||||||
IMGUI_API 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)
|
IMGUI_API 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)
|
||||||
@ -374,6 +388,7 @@ namespace ImGui
|
|||||||
IMGUI_API bool BeginChildFrame(ImGuiID id, const ImVec2& size); // helper to create a child window / scrolling region that looks like a normal widget frame
|
IMGUI_API bool BeginChildFrame(ImGuiID id, const ImVec2& size); // helper to create a child window / scrolling region that looks like a normal widget frame
|
||||||
IMGUI_API void EndChildFrame();
|
IMGUI_API void EndChildFrame();
|
||||||
|
|
||||||
|
IMGUI_API ImVec4 ColorConvertU32ToFloat4(ImU32 in);
|
||||||
IMGUI_API ImU32 ColorConvertFloat4ToU32(const ImVec4& in);
|
IMGUI_API ImU32 ColorConvertFloat4ToU32(const ImVec4& in);
|
||||||
IMGUI_API void ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& out_s, float& out_v);
|
IMGUI_API void ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& out_s, float& out_v);
|
||||||
IMGUI_API void ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b);
|
IMGUI_API void ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b);
|
||||||
@ -383,17 +398,18 @@ namespace ImGui
|
|||||||
IMGUI_API 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!
|
IMGUI_API 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!
|
||||||
IMGUI_API 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
|
IMGUI_API 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
|
||||||
IMGUI_API bool IsKeyReleased(int key_index); // "
|
IMGUI_API bool IsKeyReleased(int key_index); // "
|
||||||
IMGUI_API bool IsMouseDown(int button); // is mouse button held
|
IMGUI_API bool IsMouseDown(int button); // is mouse button held
|
||||||
IMGUI_API bool IsMouseClicked(int button, bool repeat = false); // did mouse button clicked (went from !Down to Down)
|
IMGUI_API bool IsMouseClicked(int button, bool repeat = false); // did mouse button clicked (went from !Down to Down)
|
||||||
IMGUI_API bool IsMouseDoubleClicked(int button); // did mouse button double-clicked. a double-click returns false in IsMouseClicked(). uses io.MouseDoubleClickTime.
|
IMGUI_API bool IsMouseDoubleClicked(int button); // did mouse button double-clicked. a double-click returns false in IsMouseClicked(). uses io.MouseDoubleClickTime.
|
||||||
IMGUI_API bool IsMouseReleased(int button); // did mouse button released (went from Down to !Down)
|
IMGUI_API bool IsMouseReleased(int button); // did mouse button released (went from Down to !Down)
|
||||||
IMGUI_API bool IsMouseHoveringWindow(); // is mouse hovering current window ("window" in API names always refer to current window)
|
IMGUI_API 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)
|
||||||
IMGUI_API bool IsMouseHoveringAnyWindow(); // is mouse hovering any active imgui window
|
IMGUI_API bool IsMouseHoveringAnyWindow(); // is mouse hovering any visible window
|
||||||
IMGUI_API bool IsMouseHoveringRect(const ImVec2& rect_min, const ImVec2& rect_max);// is mouse hovering given bounding rect
|
IMGUI_API bool IsMouseHoveringRect(const ImVec2& pos_min, const ImVec2& pos_max); // 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.
|
||||||
IMGUI_API bool IsMouseDragging(int button = 0, float lock_threshold = -1.0f); // is mouse dragging. if lock_threshold < -1.0f uses io.MouseDraggingThreshold
|
IMGUI_API bool IsMouseDragging(int button = 0, float lock_threshold = -1.0f); // is mouse dragging. if lock_threshold < -1.0f uses io.MouseDraggingThreshold
|
||||||
IMGUI_API ImVec2 GetMousePos(); // shortcut to ImGui::GetIO().MousePos provided by user, to be consistent with other calls
|
IMGUI_API ImVec2 GetMousePos(); // shortcut to ImGui::GetIO().MousePos provided by user, to be consistent with other calls
|
||||||
IMGUI_API ImVec2 GetMouseDragDelta(int button = 0, float lock_threshold = -1.0f); // dragging amount since clicking, also see: GetItemActiveDragDelta(). if lock_threshold < -1.0f uses io.MouseDraggingThreshold
|
IMGUI_API ImVec2 GetMousePosOnOpeningCurrentPopup(); // retrieve backup of mouse positioning at the time of opening popup we have BeginPopup() into
|
||||||
IMGUI_API void ResetMouseDragDelta(int button = 0); //
|
IMGUI_API ImVec2 GetMouseDragDelta(int button = 0, float lock_threshold = -1.0f); // dragging amount since clicking. if lock_threshold < -1.0f uses io.MouseDraggingThreshold
|
||||||
|
IMGUI_API void ResetMouseDragDelta(int button = 0); //
|
||||||
IMGUI_API 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
|
IMGUI_API 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
|
||||||
IMGUI_API void SetMouseCursor(ImGuiMouseCursor type); // set desired cursor type
|
IMGUI_API void SetMouseCursor(ImGuiMouseCursor type); // set desired cursor type
|
||||||
IMGUI_API 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.
|
IMGUI_API 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.
|
||||||
@ -439,6 +455,7 @@ enum ImGuiWindowFlags_
|
|||||||
ImGuiWindowFlags_NoSavedSettings = 1 << 8, // Never load/save settings in .ini file
|
ImGuiWindowFlags_NoSavedSettings = 1 << 8, // Never load/save settings in .ini file
|
||||||
ImGuiWindowFlags_NoInputs = 1 << 9, // Disable catching mouse or keyboard inputs
|
ImGuiWindowFlags_NoInputs = 1 << 9, // Disable catching mouse or keyboard inputs
|
||||||
ImGuiWindowFlags_MenuBar = 1 << 10, // Has a menu-bar
|
ImGuiWindowFlags_MenuBar = 1 << 10, // Has a menu-bar
|
||||||
|
ImGuiWindowFlags_HorizontalScrollbar = 1 << 11, // Enable horizontal scrollbar (off by default). You need to use SetNextWindowContentSize(ImVec2(width,0.0f)); prior to calling Begin() to specify width. Read code in imgui_demo in the "Horizontal Scrolling" section.
|
||||||
// [Internal]
|
// [Internal]
|
||||||
ImGuiWindowFlags_ChildWindow = 1 << 20, // Don't use! For internal use by BeginChild()
|
ImGuiWindowFlags_ChildWindow = 1 << 20, // Don't use! For internal use by BeginChild()
|
||||||
ImGuiWindowFlags_ChildWindowAutoFitX = 1 << 21, // Don't use! For internal use by BeginChild()
|
ImGuiWindowFlags_ChildWindowAutoFitX = 1 << 21, // Don't use! For internal use by BeginChild()
|
||||||
@ -630,7 +647,7 @@ struct ImGuiStyle
|
|||||||
float WindowFillAlphaDefault; // Default alpha of window background, if not specified in ImGui::Begin()
|
float WindowFillAlphaDefault; // Default alpha of window background, if not specified in ImGui::Begin()
|
||||||
float IndentSpacing; // Horizontal indentation when e.g. entering a tree node
|
float IndentSpacing; // Horizontal indentation when e.g. entering a tree node
|
||||||
float ColumnsMinSpacing; // Minimum horizontal spacing between two columns
|
float ColumnsMinSpacing; // Minimum horizontal spacing between two columns
|
||||||
float ScrollbarWidth; // Width of the vertical scrollbar
|
float ScrollbarSize; // Width of the vertical scrollbar, Height of the horizontal scrollbar
|
||||||
float ScrollbarRounding; // Radius of grab corners for scrollbar
|
float ScrollbarRounding; // Radius of grab corners for scrollbar
|
||||||
float GrabMinSize; // Minimum width/height of a grab box for slider/scrollbar
|
float GrabMinSize; // Minimum width/height of a grab box for slider/scrollbar
|
||||||
float GrabRounding; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
|
float GrabRounding; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
|
||||||
@ -638,6 +655,7 @@ struct ImGuiStyle
|
|||||||
ImVec2 DisplaySafeAreaPadding; // If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. Covers popups/tooltips as well regular windows.
|
ImVec2 DisplaySafeAreaPadding; // If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. Covers popups/tooltips as well regular windows.
|
||||||
bool AntiAliasedLines; // Enable anti-aliasing on lines/borders. Disable if you are really tight on CPU/GPU.
|
bool AntiAliasedLines; // Enable anti-aliasing on lines/borders. Disable if you are really tight on CPU/GPU.
|
||||||
bool AntiAliasedShapes; // Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.)
|
bool AntiAliasedShapes; // Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.)
|
||||||
|
float CurveTessellationTol; // Tessellation tolerance. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
|
||||||
ImVec4 Colors[ImGuiCol_COUNT];
|
ImVec4 Colors[ImGuiCol_COUNT];
|
||||||
|
|
||||||
IMGUI_API ImGuiStyle();
|
IMGUI_API ImGuiStyle();
|
||||||
@ -667,6 +685,7 @@ struct ImGuiIO
|
|||||||
ImFontAtlas* Fonts; // <auto> // Load and assemble one or more fonts into a single tightly packed texture. Output to Fonts array.
|
ImFontAtlas* Fonts; // <auto> // Load and assemble one or more fonts into a single tightly packed texture. Output to Fonts array.
|
||||||
float FontGlobalScale; // = 1.0f // Global scale all fonts
|
float FontGlobalScale; // = 1.0f // Global scale all fonts
|
||||||
bool FontAllowUserScaling; // = false // Allow user scaling text of individual window with CTRL+Wheel.
|
bool FontAllowUserScaling; // = false // Allow user scaling text of individual window with CTRL+Wheel.
|
||||||
|
ImVec2 DisplayFramebufferScale; // = (1.0f,1.0f) // For retina display or other situations where window coordinates are different from framebuffer coordinates. User storage only, presently not used by ImGui.
|
||||||
ImVec2 DisplayVisibleMin; // <unset> (0.0f,0.0f) // If you use DisplaySize as a virtual space larger than your screen, set DisplayVisibleMin/Max to the visible area.
|
ImVec2 DisplayVisibleMin; // <unset> (0.0f,0.0f) // If you use DisplaySize as a virtual space larger than your screen, set DisplayVisibleMin/Max to the visible area.
|
||||||
ImVec2 DisplayVisibleMax; // <unset> (0.0f,0.0f) // If the values are the same, we defaults to Min=(0.0f) and Max=DisplaySize
|
ImVec2 DisplayVisibleMax; // <unset> (0.0f,0.0f) // If the values are the same, we defaults to Min=(0.0f) and Max=DisplaySize
|
||||||
|
|
||||||
@ -674,9 +693,9 @@ struct ImGuiIO
|
|||||||
// User Functions
|
// User Functions
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
// REQUIRED: rendering function.
|
// REQUIRED: rendering function.
|
||||||
// See example code if you are unsure of how to implement this.
|
// See example code if you are unsure of how to implement this.
|
||||||
void (*RenderDrawListsFn)(ImDrawData* data);
|
void (*RenderDrawListsFn)(ImDrawData* data);
|
||||||
|
|
||||||
// Optional: access OS clipboard
|
// Optional: access OS clipboard
|
||||||
// (default to use native Win32 clipboard on Windows, otherwise uses a private clipboard. Override to access OS clipboard on other architectures)
|
// (default to use native Win32 clipboard on Windows, otherwise uses a private clipboard. Override to access OS clipboard on other architectures)
|
||||||
@ -699,7 +718,7 @@ struct ImGuiIO
|
|||||||
|
|
||||||
ImVec2 MousePos; // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
|
ImVec2 MousePos; // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
|
||||||
bool MouseDown[5]; // Mouse buttons: left, right, middle + extras. ImGui itself mostly only uses left button (BeginPopupContext** are using right button). Others buttons allows us to track if the mouse is being used by your application + available to user as a convenience via IsMouse** API.
|
bool MouseDown[5]; // Mouse buttons: left, right, middle + extras. ImGui itself mostly only uses left button (BeginPopupContext** are using right button). Others buttons allows us to track if the mouse is being used by your application + available to user as a convenience via IsMouse** API.
|
||||||
float MouseWheel; // Mouse wheel: 1 unit scrolls about 5 lines text.
|
float MouseWheel; // Mouse wheel: 1 unit scrolls about 5 lines text.
|
||||||
bool MouseDrawCursor; // Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor).
|
bool MouseDrawCursor; // Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor).
|
||||||
bool KeyCtrl; // Keyboard modifier pressed: Control
|
bool KeyCtrl; // Keyboard modifier pressed: Control
|
||||||
bool KeyShift; // Keyboard modifier pressed: Shift
|
bool KeyShift; // Keyboard modifier pressed: Shift
|
||||||
@ -717,6 +736,7 @@ struct ImGuiIO
|
|||||||
|
|
||||||
bool WantCaptureMouse; // Mouse is hovering a window or widget is active (= ImGui will use your mouse input)
|
bool WantCaptureMouse; // Mouse is hovering a window or widget is active (= ImGui will use your mouse input)
|
||||||
bool WantCaptureKeyboard; // Widget is active (= ImGui will use your keyboard input)
|
bool WantCaptureKeyboard; // Widget is active (= ImGui will use your keyboard input)
|
||||||
|
bool WantTextInput; // Some text input widget is active, which will read input characters from the InputCharacters array.
|
||||||
float Framerate; // Framerate estimation, in frame per second. Rolling average estimation based on IO.DeltaTime over 120 frames
|
float Framerate; // Framerate estimation, in frame per second. Rolling average estimation based on IO.DeltaTime over 120 frames
|
||||||
int MetricsAllocs; // Number of active memory allocations
|
int MetricsAllocs; // Number of active memory allocations
|
||||||
int MetricsRenderVertices; // Vertices output during last call to Render()
|
int MetricsRenderVertices; // Vertices output during last call to Render()
|
||||||
@ -748,7 +768,7 @@ struct ImGuiIO
|
|||||||
// Helpers
|
// Helpers
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Lightweight std::vector<> like class to avoid dragging dependencies (also: windows implementation of STL with debug enabled is absurdly slow, so let's bypass it so our code runs fast in debug).
|
// Lightweight std::vector<> like class to avoid dragging dependencies (also: windows implementation of STL with debug enabled is absurdly slow, so let's bypass it so our code runs fast in debug).
|
||||||
// Our implementation does NOT call c++ constructors because we don't use them in ImGui. Don't use this class as a straight std::vector replacement in your code!
|
// Our implementation does NOT call c++ constructors because we don't use them in ImGui. Don't use this class as a straight std::vector replacement in your code!
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class ImVector
|
class ImVector
|
||||||
@ -786,14 +806,14 @@ public:
|
|||||||
inline int _grow_capacity(int new_size) { int new_capacity = Capacity ? (Capacity + Capacity/2) : 8; return new_capacity > new_size ? new_capacity : new_size; }
|
inline int _grow_capacity(int new_size) { int new_capacity = Capacity ? (Capacity + Capacity/2) : 8; return new_capacity > new_size ? new_capacity : new_size; }
|
||||||
|
|
||||||
inline void resize(int new_size) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); Size = new_size; }
|
inline void resize(int new_size) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); Size = new_size; }
|
||||||
inline void reserve(int new_capacity)
|
inline void reserve(int new_capacity)
|
||||||
{
|
{
|
||||||
if (new_capacity <= Capacity) return;
|
if (new_capacity <= Capacity) return;
|
||||||
T* new_data = (value_type*)ImGui::MemAlloc((size_t)new_capacity * sizeof(value_type));
|
T* new_data = (value_type*)ImGui::MemAlloc((size_t)new_capacity * sizeof(value_type));
|
||||||
memcpy(new_data, Data, (size_t)Size * sizeof(value_type));
|
memcpy(new_data, Data, (size_t)Size * sizeof(value_type));
|
||||||
ImGui::MemFree(Data);
|
ImGui::MemFree(Data);
|
||||||
Data = new_data;
|
Data = new_data;
|
||||||
Capacity = new_capacity;
|
Capacity = new_capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void push_back(const value_type& v) { if (Size == Capacity) reserve(_grow_capacity(Size+1)); Data[Size++] = v; }
|
inline void push_back(const value_type& v) { if (Size == Capacity) reserve(_grow_capacity(Size+1)); Data[Size++] = v; }
|
||||||
@ -844,8 +864,8 @@ struct ImGuiTextFilter
|
|||||||
|
|
||||||
ImGuiTextFilter(const char* default_filter = "");
|
ImGuiTextFilter(const char* default_filter = "");
|
||||||
void Clear() { InputBuf[0] = 0; Build(); }
|
void Clear() { InputBuf[0] = 0; Build(); }
|
||||||
void Draw(const char* label = "Filter (inc,-exc)", float width = -1.0f); // Helper calling InputText+Build
|
void Draw(const char* label = "Filter (inc,-exc)", float width = 0.0f); // Helper calling InputText+Build
|
||||||
bool PassFilter(const char* val) const;
|
bool PassFilter(const char* text, const char* text_end = NULL) const;
|
||||||
bool IsActive() const { return !Filters.empty(); }
|
bool IsActive() const { return !Filters.empty(); }
|
||||||
IMGUI_API void Build();
|
IMGUI_API void Build();
|
||||||
};
|
};
|
||||||
@ -856,12 +876,13 @@ struct ImGuiTextBuffer
|
|||||||
ImVector<char> Buf;
|
ImVector<char> Buf;
|
||||||
|
|
||||||
ImGuiTextBuffer() { Buf.push_back(0); }
|
ImGuiTextBuffer() { Buf.push_back(0); }
|
||||||
|
inline char operator[](int i) { return Buf.Data[i]; }
|
||||||
const char* begin() const { return &Buf.front(); }
|
const char* begin() const { return &Buf.front(); }
|
||||||
const char* end() const { return &Buf.back(); } // Buf is zero-terminated, so end() will point on the zero-terminator
|
const char* end() const { return &Buf.back(); } // Buf is zero-terminated, so end() will point on the zero-terminator
|
||||||
int size() const { return Buf.Size-1; }
|
int size() const { return Buf.Size - 1; }
|
||||||
bool empty() { return size() >= 1; }
|
bool empty() { return Buf.Size >= 2; }
|
||||||
void clear() { Buf.clear(); Buf.push_back(0); }
|
void clear() { Buf.clear(); Buf.push_back(0); }
|
||||||
IMGUI_API void append(const char* fmt, ...);
|
IMGUI_API void append(const char* fmt, ...) IM_PRINTFARGS(2);
|
||||||
IMGUI_API void appendv(const char* fmt, va_list args);
|
IMGUI_API void appendv(const char* fmt, va_list args);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -875,13 +896,13 @@ struct ImGuiTextBuffer
|
|||||||
// - You want to store custom debug data easily without adding or editing structures in your code.
|
// - You want to store custom debug data easily without adding or editing structures in your code.
|
||||||
struct ImGuiStorage
|
struct ImGuiStorage
|
||||||
{
|
{
|
||||||
struct Pair
|
struct Pair
|
||||||
{
|
{
|
||||||
ImGuiID key;
|
ImGuiID key;
|
||||||
union { int val_i; float val_f; void* val_p; };
|
union { int val_i; float val_f; void* val_p; };
|
||||||
Pair(ImGuiID _key, int _val_i) { key = _key; val_i = _val_i; }
|
Pair(ImGuiID _key, int _val_i) { key = _key; val_i = _val_i; }
|
||||||
Pair(ImGuiID _key, float _val_f) { key = _key; val_f = _val_f; }
|
Pair(ImGuiID _key, float _val_f) { key = _key; val_f = _val_f; }
|
||||||
Pair(ImGuiID _key, void* _val_p) { key = _key; val_p = _val_p; }
|
Pair(ImGuiID _key, void* _val_p) { key = _key; val_p = _val_p; }
|
||||||
};
|
};
|
||||||
ImVector<Pair> Data;
|
ImVector<Pair> Data;
|
||||||
|
|
||||||
@ -896,7 +917,7 @@ struct ImGuiStorage
|
|||||||
IMGUI_API void* GetVoidPtr(ImGuiID key) const; // default_val is NULL
|
IMGUI_API void* GetVoidPtr(ImGuiID key) const; // default_val is NULL
|
||||||
IMGUI_API void SetVoidPtr(ImGuiID key, void* val);
|
IMGUI_API void SetVoidPtr(ImGuiID key, void* val);
|
||||||
|
|
||||||
// - Get***Ref() functions finds pair, insert on demand if missing, return pointer. Useful if you intend to do Get+Set.
|
// - Get***Ref() functions finds pair, insert on demand if missing, return pointer. Useful if you intend to do Get+Set.
|
||||||
// - References are only valid until a new value is added to the storage. Calling a Set***() function or a Get***Ref() function invalidates the pointer.
|
// - References are only valid until a new value is added to the storage. Calling a Set***() function or a Get***Ref() function invalidates the pointer.
|
||||||
// - A typical use case where this is convenient:
|
// - A typical use case where this is convenient:
|
||||||
// float* pvar = ImGui::GetFloatRef(key); ImGui::SliderFloat("var", pvar, 0, 100.0f); some_var += *pvar;
|
// float* pvar = ImGui::GetFloatRef(key); ImGui::SliderFloat("var", pvar, 0, 100.0f); some_var += *pvar;
|
||||||
@ -940,7 +961,8 @@ struct ImColor
|
|||||||
{
|
{
|
||||||
ImVec4 Value;
|
ImVec4 Value;
|
||||||
|
|
||||||
ImColor(int r, int g, int b, int a = 255) { Value.x = (float)r / 255.0f; Value.y = (float)g / 255.0f; Value.z = (float)b / 255.0f; Value.w = (float)a / 255.0f; }
|
ImColor(int r, int g, int b, int a = 255) { float sc = 1.0f/255.0f; Value.x = (float)r * sc; Value.y = (float)g * sc; Value.z = (float)b * sc; Value.w = (float)a * sc; }
|
||||||
|
ImColor(ImU32 rgba) { float sc = 1.0f/255.0f; Value.x = (float)(rgba&0xFF) * sc; Value.y = (float)((rgba>>8)&0xFF) * sc; Value.z = (float)((rgba>>16)&0xFF) * sc; Value.w = (float)(rgba >> 24) * sc; }
|
||||||
ImColor(float r, float g, float b, float a = 1.0f) { Value.x = r; Value.y = g; Value.z = b; Value.w = a; }
|
ImColor(float r, float g, float b, float a = 1.0f) { Value.x = r; Value.y = g; Value.z = b; Value.w = a; }
|
||||||
ImColor(const ImVec4& col) { Value = col; }
|
ImColor(const ImVec4& col) { Value = col; }
|
||||||
operator ImU32() const { return ImGui::ColorConvertFloat4ToU32(Value); }
|
operator ImU32() const { return ImGui::ColorConvertFloat4ToU32(Value); }
|
||||||
@ -956,6 +978,7 @@ struct ImColor
|
|||||||
// for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) // display only visible items
|
// for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) // display only visible items
|
||||||
// ImGui::Text("line number %d", i);
|
// ImGui::Text("line number %d", i);
|
||||||
// clipper.End();
|
// clipper.End();
|
||||||
|
// NB: 'count' is only used to clamp the result, if you don't know your count you can use INT_MAX
|
||||||
struct ImGuiListClipper
|
struct ImGuiListClipper
|
||||||
{
|
{
|
||||||
float ItemsHeight;
|
float ItemsHeight;
|
||||||
@ -1005,10 +1028,14 @@ struct ImDrawCmd
|
|||||||
ImTextureID TextureId; // User-provided texture ID. Set by user in ImfontAtlas::SetTexID() for fonts or passed to Image*() functions. Ignore if never using images or multiple fonts atlas.
|
ImTextureID TextureId; // User-provided texture ID. Set by user in ImfontAtlas::SetTexID() for fonts or passed to Image*() functions. Ignore if never using images or multiple fonts atlas.
|
||||||
ImDrawCallback UserCallback; // If != NULL, call the function instead of rendering the vertices. clip_rect and texture_id will be set normally.
|
ImDrawCallback UserCallback; // If != NULL, call the function instead of rendering the vertices. clip_rect and texture_id will be set normally.
|
||||||
void* UserCallbackData; // The draw callback code can access this.
|
void* UserCallbackData; // The draw callback code can access this.
|
||||||
|
|
||||||
|
ImDrawCmd() { ElemCount = 0; ClipRect.x = ClipRect.y = -8192.0f; ClipRect.z = ClipRect.w = +8192.0f; TextureId = NULL; UserCallback = NULL; UserCallbackData = NULL; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Vertex index
|
// Vertex index (override with, e.g. '#define ImDrawIdx unsigned int' in ImConfig)
|
||||||
|
#ifndef ImDrawIdx
|
||||||
typedef unsigned short ImDrawIdx;
|
typedef unsigned short ImDrawIdx;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Vertex layout
|
// Vertex layout
|
||||||
#ifndef IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT
|
#ifndef IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT
|
||||||
@ -1026,6 +1053,7 @@ IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Draw channels are used by the Columns API to "split" the render list into different channels while building, so items of each column can be batched together.
|
// Draw channels are used by the Columns API to "split" the render list into different channels while building, so items of each column can be batched together.
|
||||||
|
// You can also use them to simulate drawing layers and submit primitives in a different order than how they will be rendered.
|
||||||
struct ImDrawChannel
|
struct ImDrawChannel
|
||||||
{
|
{
|
||||||
ImVector<ImDrawCmd> CmdBuffer;
|
ImVector<ImDrawCmd> CmdBuffer;
|
||||||
@ -1052,10 +1080,11 @@ struct ImDrawList
|
|||||||
ImDrawVert* _VtxWritePtr; // [Internal] point within VtxBuffer.Data after each add command (to avoid using the ImVector<> operators too much)
|
ImDrawVert* _VtxWritePtr; // [Internal] point within VtxBuffer.Data after each add command (to avoid using the ImVector<> operators too much)
|
||||||
ImDrawIdx* _IdxWritePtr; // [Internal] point within IdxBuffer.Data after each add command (to avoid using the ImVector<> operators too much)
|
ImDrawIdx* _IdxWritePtr; // [Internal] point within IdxBuffer.Data after each add command (to avoid using the ImVector<> operators too much)
|
||||||
ImVector<ImVec4> _ClipRectStack; // [Internal]
|
ImVector<ImVec4> _ClipRectStack; // [Internal]
|
||||||
ImVector<ImTextureID> _TextureIdStack; // [Internal]
|
ImVector<ImTextureID> _TextureIdStack; // [Internal]
|
||||||
ImVector<ImVec2> _Path; // [Internal] current path building
|
ImVector<ImVec2> _Path; // [Internal] current path building
|
||||||
int _ChannelCurrent; // [Internal] current channel number (0)
|
int _ChannelsCurrent; // [Internal] current channel number (0)
|
||||||
ImVector<ImDrawChannel> _Channels; // [Internal] draw channels for columns API
|
int _ChannelsCount; // [Internal] number of active channels (1+)
|
||||||
|
ImVector<ImDrawChannel> _Channels; // [Internal] draw channels for columns API (not resized down so _ChannelsCount may be smaller than _Channels.Size)
|
||||||
|
|
||||||
ImDrawList() { _OwnerName = NULL; Clear(); }
|
ImDrawList() { _OwnerName = NULL; Clear(); }
|
||||||
~ImDrawList() { ClearFreeMemory(); }
|
~ImDrawList() { ClearFreeMemory(); }
|
||||||
@ -1067,7 +1096,7 @@ struct ImDrawList
|
|||||||
IMGUI_API void PushTextureID(const ImTextureID& texture_id);
|
IMGUI_API void PushTextureID(const ImTextureID& texture_id);
|
||||||
IMGUI_API void PopTextureID();
|
IMGUI_API void PopTextureID();
|
||||||
|
|
||||||
// Primitives
|
// Primitives
|
||||||
IMGUI_API void AddLine(const ImVec2& a, const ImVec2& b, ImU32 col, float thickness = 1.0f);
|
IMGUI_API void AddLine(const ImVec2& a, const ImVec2& b, ImU32 col, float thickness = 1.0f);
|
||||||
IMGUI_API void AddRect(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding = 0.0f, int rounding_corners = 0x0F);
|
IMGUI_API void AddRect(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding = 0.0f, int rounding_corners = 0x0F);
|
||||||
IMGUI_API void AddRectFilled(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding = 0.0f, int rounding_corners = 0x0F);
|
IMGUI_API void AddRectFilled(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding = 0.0f, int rounding_corners = 0x0F);
|
||||||
@ -1080,22 +1109,29 @@ struct ImDrawList
|
|||||||
IMGUI_API void AddImage(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv0, const ImVec2& uv1, ImU32 col = 0xFFFFFFFF);
|
IMGUI_API void AddImage(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv0, const ImVec2& uv1, ImU32 col = 0xFFFFFFFF);
|
||||||
IMGUI_API void AddPolyline(const ImVec2* points, const int num_points, ImU32 col, bool closed, float thickness, bool anti_aliased);
|
IMGUI_API void AddPolyline(const ImVec2* points, const int num_points, ImU32 col, bool closed, float thickness, bool anti_aliased);
|
||||||
IMGUI_API void AddConvexPolyFilled(const ImVec2* points, const int num_points, ImU32 col, bool anti_aliased);
|
IMGUI_API void AddConvexPolyFilled(const ImVec2* points, const int num_points, ImU32 col, bool anti_aliased);
|
||||||
|
IMGUI_API void AddBezierCurve(const ImVec2& pos0, const ImVec2& cp0, const ImVec2& cp1, const ImVec2& pos1, ImU32 col, float thickness, int num_segments = 0);
|
||||||
|
|
||||||
// Stateful path API, add points then finish with PathFill() or PathStroke()
|
// Stateful path API, add points then finish with PathFill() or PathStroke()
|
||||||
inline void PathClear() { _Path.resize(0); }
|
inline void PathClear() { _Path.resize(0); }
|
||||||
inline void PathLineTo(const ImVec2& p) { _Path.push_back(p); }
|
inline void PathLineTo(const ImVec2& pos) { _Path.push_back(pos); }
|
||||||
IMGUI_API void PathArcTo(const ImVec2& centre, float radius, float a_min, float a_max, int num_segments = 10);
|
inline void PathLineToMergeDuplicate(const ImVec2& pos) { if (_Path.Size == 0 || _Path[_Path.Size-1].x != pos.x || _Path[_Path.Size-1].y != pos.y) _Path.push_back(pos); }
|
||||||
IMGUI_API void PathArcToFast(const ImVec2& centre, float radius, int a_min_of_12, int a_max_of_12);
|
|
||||||
IMGUI_API void PathRect(const ImVec2& a, const ImVec2& b, float rounding = 0.0f, int rounding_corners = 0x0F);
|
|
||||||
inline void PathFill(ImU32 col) { AddConvexPolyFilled(_Path.Data, _Path.Size, col, true); PathClear(); }
|
inline void PathFill(ImU32 col) { AddConvexPolyFilled(_Path.Data, _Path.Size, col, true); PathClear(); }
|
||||||
inline void PathStroke(ImU32 col, bool closed, float thickness = 1.0f) { AddPolyline(_Path.Data, _Path.Size, col, closed, thickness, true); PathClear(); }
|
inline void PathStroke(ImU32 col, bool closed, float thickness = 1.0f) { AddPolyline(_Path.Data, _Path.Size, col, closed, thickness, true); PathClear(); }
|
||||||
|
IMGUI_API void PathArcTo(const ImVec2& centre, float radius, float a_min, float a_max, int num_segments = 10);
|
||||||
|
IMGUI_API void PathArcToFast(const ImVec2& centre, float radius, int a_min_of_12, int a_max_of_12); // Use precomputed angles for a 12 steps circle
|
||||||
|
IMGUI_API void PathBezierCurveTo(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, int num_segments = 0);
|
||||||
|
IMGUI_API void PathRect(const ImVec2& rect_min, const ImVec2& rect_max, float rounding = 0.0f, int rounding_corners = 0x0F);
|
||||||
|
|
||||||
|
// Channels
|
||||||
|
// - Use to simulate layers. By switching channels to can render out-of-order (e.g. submit foreground primitives before background primitives)
|
||||||
|
// - Use to minimize draw calls (e.g. if going back-and-forth between multiple non-overlapping clipping rectangles, prefer to append into separate channels then merge at the end)
|
||||||
|
IMGUI_API void ChannelsSplit(int channels_count);
|
||||||
|
IMGUI_API void ChannelsMerge();
|
||||||
|
IMGUI_API void ChannelsSetCurrent(int channel_index);
|
||||||
|
|
||||||
// Advanced
|
// Advanced
|
||||||
IMGUI_API void AddCallback(ImDrawCallback callback, void* callback_data); // Your rendering function must check for 'UserCallback' in ImDrawCmd and call the function instead of rendering triangles.
|
IMGUI_API void AddCallback(ImDrawCallback callback, void* callback_data); // Your rendering function must check for 'UserCallback' in ImDrawCmd and call the function instead of rendering triangles.
|
||||||
IMGUI_API void AddDrawCmd(); // This is useful if you need to forcefully create a new draw call (to allow for dependent rendering / blending). Otherwise primitives are merged into the same draw-call as much as possible
|
IMGUI_API void AddDrawCmd(); // This is useful if you need to forcefully create a new draw call (to allow for dependent rendering / blending). Otherwise primitives are merged into the same draw-call as much as possible
|
||||||
IMGUI_API void ChannelsSplit(int channel_count);
|
|
||||||
IMGUI_API void ChannelsMerge(int channel_count);
|
|
||||||
IMGUI_API void ChannelsSetCurrent(int idx);
|
|
||||||
|
|
||||||
// Internal helpers
|
// Internal helpers
|
||||||
// NB: all primitives needs to be reserved via PrimReserve() beforehand!
|
// NB: all primitives needs to be reserved via PrimReserve() beforehand!
|
||||||
@ -1119,13 +1155,14 @@ struct ImDrawData
|
|||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
void DeIndexAllBuffers(); // For backward compatibility: convert all buffers from indexed to de-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering!
|
void DeIndexAllBuffers(); // For backward compatibility: convert all buffers from indexed to de-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering!
|
||||||
|
void ScaleClipRects(const ImVec2& sc); // Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than ImGui expects, or if there is a difference between your window resolution and framebuffer resolution.
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ImFontConfig
|
struct ImFontConfig
|
||||||
{
|
{
|
||||||
void* FontData; // // TTF data
|
void* FontData; // // TTF data
|
||||||
int FontDataSize; // // TTF data size
|
int FontDataSize; // // TTF data size
|
||||||
bool FontDataOwnedByAtlas; // true // TTF data ownership taken by the container ImFontAtlas (will delete memory itself). Set to true
|
bool FontDataOwnedByAtlas; // true // TTF data ownership taken by the container ImFontAtlas (will delete memory itself). Set to true
|
||||||
int FontNo; // 0 // Index of font within TTF file
|
int FontNo; // 0 // Index of font within TTF file
|
||||||
float SizePixels; // // Size in pixels for rasterizer
|
float SizePixels; // // Size in pixels for rasterizer
|
||||||
int OversampleH, OversampleV; // 3, 1 // Rasterize at higher quality for sub-pixel positioning. We don't use sub-pixel positions on the Y axis.
|
int OversampleH, OversampleV; // 3, 1 // Rasterize at higher quality for sub-pixel positioning. We don't use sub-pixel positions on the Y axis.
|
||||||
@ -1134,7 +1171,7 @@ struct ImFontConfig
|
|||||||
const ImWchar* GlyphRanges; // // List of Unicode range (2 value per range, values are inclusive, zero-terminated list)
|
const ImWchar* GlyphRanges; // // List of Unicode range (2 value per range, values are inclusive, zero-terminated list)
|
||||||
bool MergeMode; // false // Merge into previous ImFont, so you can combine multiple inputs font into one ImFont (e.g. ASCII font + icons + Japanese glyphs).
|
bool MergeMode; // false // Merge into previous ImFont, so you can combine multiple inputs font into one ImFont (e.g. ASCII font + icons + Japanese glyphs).
|
||||||
bool MergeGlyphCenterV; // false // When merging (multiple ImFontInput for one ImFont), vertically center new glyphs instead of aligning their baseline
|
bool MergeGlyphCenterV; // false // When merging (multiple ImFontInput for one ImFont), vertically center new glyphs instead of aligning their baseline
|
||||||
|
|
||||||
// [Internal]
|
// [Internal]
|
||||||
char Name[32]; // Name (strictly for debugging)
|
char Name[32]; // Name (strictly for debugging)
|
||||||
ImFont* DstFont;
|
ImFont* DstFont;
|
||||||
|
292
imgui_demo.cpp
292
imgui_demo.cpp
@ -1,4 +1,4 @@
|
|||||||
// ImGui library v1.44
|
// ImGui library v1.45 WIP
|
||||||
// Demo code
|
// Demo code
|
||||||
|
|
||||||
// Don't remove this file from your project! It is useful reference code that you can execute.
|
// Don't remove this file from your project! It is useful reference code that you can execute.
|
||||||
@ -15,20 +15,21 @@
|
|||||||
#include <stdio.h> // vsnprintf, sscanf, printf
|
#include <stdio.h> // vsnprintf, sscanf, printf
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff)
|
|
||||||
#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
|
#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
|
||||||
#define snprintf _snprintf
|
#define snprintf _snprintf
|
||||||
#endif
|
#endif
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations" // warning : 'xx' is deprecated: The POSIX name for this item.. // for strdup used in demo code (so user can copy & paste the code)
|
#pragma clang diagnostic ignored "-Wdeprecated-declarations" // warning : 'xx' is deprecated: The POSIX name for this item.. // for strdup used in demo code (so user can copy & paste the code)
|
||||||
#pragma clang diagnostic ignored "-Wint-to-void-pointer-cast" // warning : cast to 'void *' from smaller integer type 'int'
|
#pragma clang diagnostic ignored "-Wint-to-void-pointer-cast" // warning : cast to 'void *' from smaller integer type 'int'
|
||||||
|
#pragma clang diagnostic ignored "-Wformat-security" // warning : warning: format string is not a string literal
|
||||||
#endif
|
#endif
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast" // warning: cast to pointer from integer of different size
|
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast" // warning: cast to pointer from integer of different size
|
||||||
|
#pragma GCC diagnostic ignored "-Wformat-security" // warning : format string is not a string literal (potentially insecure)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Play it nice with Windows users. Notepad in 2015 still doesn't display text data with Unix-style \n.
|
// Play it nice with Windows users. Notepad in 2015 still doesn't display text data with Unix-style \n.
|
||||||
#ifdef _MSC_VER
|
#ifdef _WIN32
|
||||||
#define IM_NEWLINE "\r\n"
|
#define IM_NEWLINE "\r\n"
|
||||||
#else
|
#else
|
||||||
#define IM_NEWLINE "\n"
|
#define IM_NEWLINE "\n"
|
||||||
@ -43,6 +44,7 @@
|
|||||||
#ifndef IMGUI_DISABLE_TEST_WINDOWS
|
#ifndef IMGUI_DISABLE_TEST_WINDOWS
|
||||||
|
|
||||||
static void ShowExampleAppConsole(bool* opened);
|
static void ShowExampleAppConsole(bool* opened);
|
||||||
|
static void ShowExampleAppLog(bool* opened);
|
||||||
static void ShowExampleAppLayout(bool* opened);
|
static void ShowExampleAppLayout(bool* opened);
|
||||||
static void ShowExampleAppLongText(bool* opened);
|
static void ShowExampleAppLongText(bool* opened);
|
||||||
static void ShowExampleAppAutoResize(bool* opened);
|
static void ShowExampleAppAutoResize(bool* opened);
|
||||||
@ -54,8 +56,8 @@ static void ShowExampleMenuFile();
|
|||||||
|
|
||||||
static void ShowHelpMarker(const char* desc)
|
static void ShowHelpMarker(const char* desc)
|
||||||
{
|
{
|
||||||
ImGui::TextDisabled("(?)");
|
ImGui::TextDisabled("(?)");
|
||||||
if (ImGui::IsItemHovered())
|
if (ImGui::IsItemHovered())
|
||||||
ImGui::SetTooltip(desc);
|
ImGui::SetTooltip(desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,6 +90,7 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||||||
static bool show_app_metrics = false;
|
static bool show_app_metrics = false;
|
||||||
static bool show_app_main_menu_bar = false;
|
static bool show_app_main_menu_bar = false;
|
||||||
static bool show_app_console = false;
|
static bool show_app_console = false;
|
||||||
|
static bool show_app_log = false;
|
||||||
static bool show_app_layout = false;
|
static bool show_app_layout = false;
|
||||||
static bool show_app_long_text = false;
|
static bool show_app_long_text = false;
|
||||||
static bool show_app_auto_resize = false;
|
static bool show_app_auto_resize = false;
|
||||||
@ -98,6 +101,7 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||||||
if (show_app_metrics) ImGui::ShowMetricsWindow(&show_app_metrics);
|
if (show_app_metrics) ImGui::ShowMetricsWindow(&show_app_metrics);
|
||||||
if (show_app_main_menu_bar) ShowExampleAppMainMenuBar();
|
if (show_app_main_menu_bar) ShowExampleAppMainMenuBar();
|
||||||
if (show_app_console) ShowExampleAppConsole(&show_app_console);
|
if (show_app_console) ShowExampleAppConsole(&show_app_console);
|
||||||
|
if (show_app_log) ShowExampleAppLog(&show_app_log);
|
||||||
if (show_app_layout) ShowExampleAppLayout(&show_app_layout);
|
if (show_app_layout) ShowExampleAppLayout(&show_app_layout);
|
||||||
if (show_app_long_text) ShowExampleAppLongText(&show_app_long_text);
|
if (show_app_long_text) ShowExampleAppLongText(&show_app_long_text);
|
||||||
if (show_app_auto_resize) ShowExampleAppAutoResize(&show_app_auto_resize);
|
if (show_app_auto_resize) ShowExampleAppAutoResize(&show_app_auto_resize);
|
||||||
@ -138,7 +142,7 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||||||
ImGui::End();
|
ImGui::End();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.65f); // 2/3 of the space for widget and 1/3 for labels
|
//ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.65f); // 2/3 of the space for widget and 1/3 for labels
|
||||||
ImGui::PushItemWidth(-140); // Right align, keep 140 pixels for labels
|
ImGui::PushItemWidth(-140); // Right align, keep 140 pixels for labels
|
||||||
|
|
||||||
@ -156,6 +160,7 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||||||
{
|
{
|
||||||
ImGui::MenuItem("Main menu bar", NULL, &show_app_main_menu_bar);
|
ImGui::MenuItem("Main menu bar", NULL, &show_app_main_menu_bar);
|
||||||
ImGui::MenuItem("Console", NULL, &show_app_console);
|
ImGui::MenuItem("Console", NULL, &show_app_console);
|
||||||
|
ImGui::MenuItem("Log", NULL, &show_app_log);
|
||||||
ImGui::MenuItem("Simple layout", NULL, &show_app_layout);
|
ImGui::MenuItem("Simple layout", NULL, &show_app_layout);
|
||||||
ImGui::MenuItem("Long text display", NULL, &show_app_long_text);
|
ImGui::MenuItem("Long text display", NULL, &show_app_long_text);
|
||||||
ImGui::MenuItem("Auto-resizing window", NULL, &show_app_auto_resize);
|
ImGui::MenuItem("Auto-resizing window", NULL, &show_app_auto_resize);
|
||||||
@ -184,7 +189,7 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||||||
{
|
{
|
||||||
ImGui::Checkbox("no titlebar", &no_titlebar); ImGui::SameLine(150);
|
ImGui::Checkbox("no titlebar", &no_titlebar); ImGui::SameLine(150);
|
||||||
ImGui::Checkbox("no border", &no_border); ImGui::SameLine(300);
|
ImGui::Checkbox("no border", &no_border); ImGui::SameLine(300);
|
||||||
ImGui::Checkbox("no resize", &no_resize);
|
ImGui::Checkbox("no resize", &no_resize);
|
||||||
ImGui::Checkbox("no move", &no_move); ImGui::SameLine(150);
|
ImGui::Checkbox("no move", &no_move); ImGui::SameLine(150);
|
||||||
ImGui::Checkbox("no scrollbar", &no_scrollbar); ImGui::SameLine(300);
|
ImGui::Checkbox("no scrollbar", &no_scrollbar); ImGui::SameLine(300);
|
||||||
ImGui::Checkbox("no collapse", &no_collapse);
|
ImGui::Checkbox("no collapse", &no_collapse);
|
||||||
@ -426,7 +431,7 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||||||
if (ImGui::Button("Button")) { printf("Clicked\n"); a ^= 1; }
|
if (ImGui::Button("Button")) { printf("Clicked\n"); a ^= 1; }
|
||||||
if (a)
|
if (a)
|
||||||
{
|
{
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::Text("Thanks for clicking me!");
|
ImGui::Text("Thanks for clicking me!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -530,7 +535,7 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||||||
static float col2[4] = { 0.4f,0.7f,0.0f,0.5f };
|
static float col2[4] = { 0.4f,0.7f,0.0f,0.5f };
|
||||||
ImGui::ColorEdit3("color 1", col1);
|
ImGui::ColorEdit3("color 1", col1);
|
||||||
ImGui::SameLine(); ShowHelpMarker("Click on the colored square to change edit mode.\nCTRL+click on individual component to input value.\n");
|
ImGui::SameLine(); ShowHelpMarker("Click on the colored square to change edit mode.\nCTRL+click on individual component to input value.\n");
|
||||||
|
|
||||||
ImGui::ColorEdit4("color 2", col2);
|
ImGui::ColorEdit4("color 2", col2);
|
||||||
|
|
||||||
const char* listbox_items[] = { "Apple", "Banana", "Cherry", "Kiwi", "Mango", "Orange", "Pineapple", "Strawberry", "Watermelon" };
|
const char* listbox_items[] = { "Apple", "Banana", "Cherry", "Kiwi", "Mango", "Orange", "Pineapple", "Strawberry", "Watermelon" };
|
||||||
@ -663,21 +668,21 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||||||
ImGui::PlotLines("Frame Times", arr, IM_ARRAYSIZE(arr));
|
ImGui::PlotLines("Frame Times", arr, IM_ARRAYSIZE(arr));
|
||||||
|
|
||||||
static bool pause;
|
static bool pause;
|
||||||
static ImVector<float> values; if (values.empty()) { values.resize(90); memset(values.Data, 0, values.Size*sizeof(float)); }
|
static ImVector<float> values; if (values.empty()) { values.resize(90); memset(values.Data, 0, values.Size*sizeof(float)); }
|
||||||
static int values_offset = 0;
|
static int values_offset = 0;
|
||||||
if (!pause)
|
if (!pause)
|
||||||
{
|
{
|
||||||
static float refresh_time = ImGui::GetTime(); // Create dummy data at fixed 60 hz rate for the demo
|
static float refresh_time = ImGui::GetTime(); // Create dummy data at fixed 60 hz rate for the demo
|
||||||
for (; ImGui::GetTime() > refresh_time + 1.0f/60.0f; refresh_time += 1.0f/60.0f)
|
for (; ImGui::GetTime() > refresh_time + 1.0f/60.0f; refresh_time += 1.0f/60.0f)
|
||||||
{
|
{
|
||||||
static float phase = 0.0f;
|
static float phase = 0.0f;
|
||||||
values[values_offset] = cosf(phase);
|
values[values_offset] = cosf(phase);
|
||||||
values_offset = (values_offset+1)%values.Size;
|
values_offset = (values_offset+1)%values.Size;
|
||||||
phase += 0.10f*values_offset;
|
phase += 0.10f*values_offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::PlotLines("##Graph", values.Data, values.Size, values_offset, "avg 0.0", -1.0f, 1.0f, ImVec2(0,80));
|
ImGui::PlotLines("##Graph", values.Data, values.Size, values_offset, "avg 0.0", -1.0f, 1.0f, ImVec2(0,80));
|
||||||
ImGui::SameLine(0, ImGui::GetStyle().ItemInnerSpacing.x);
|
ImGui::SameLine(0, ImGui::GetStyle().ItemInnerSpacing.x);
|
||||||
ImGui::BeginGroup();
|
ImGui::BeginGroup();
|
||||||
ImGui::Text("Graph");
|
ImGui::Text("Graph");
|
||||||
ImGui::Checkbox("pause", &pause);
|
ImGui::Checkbox("pause", &pause);
|
||||||
@ -692,11 +697,11 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||||||
ImGui::Text("Without border");
|
ImGui::Text("Without border");
|
||||||
static int line = 50;
|
static int line = 50;
|
||||||
bool goto_line = ImGui::Button("Goto");
|
bool goto_line = ImGui::Button("Goto");
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::PushItemWidth(100);
|
ImGui::PushItemWidth(100);
|
||||||
goto_line |= ImGui::InputInt("##Line", &line, 0, 0, ImGuiInputTextFlags_EnterReturnsTrue);
|
goto_line |= ImGui::InputInt("##Line", &line, 0, 0, ImGuiInputTextFlags_EnterReturnsTrue);
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
ImGui::BeginChild("Sub1", ImVec2(ImGui::GetWindowWidth() * 0.5f,300));
|
ImGui::BeginChild("Sub1", ImVec2(ImGui::GetWindowContentRegionWidth() * 0.5f,300), false, ImGuiWindowFlags_HorizontalScrollbar);
|
||||||
for (int i = 0; i < 100; i++)
|
for (int i = 0; i < 100; i++)
|
||||||
{
|
{
|
||||||
ImGui::Text("%04d: scrollable region", i);
|
ImGui::Text("%04d: scrollable region", i);
|
||||||
@ -730,19 +735,24 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||||||
if (ImGui::TreeNode("Widgets Alignment"))
|
if (ImGui::TreeNode("Widgets Alignment"))
|
||||||
{
|
{
|
||||||
static float f = 0.0f;
|
static float f = 0.0f;
|
||||||
ImGui::Text("Fixed: 100 pixels");
|
ImGui::Text("PushItemWidth(100)");
|
||||||
ImGui::PushItemWidth(100);
|
ImGui::PushItemWidth(100);
|
||||||
ImGui::InputFloat("float##1", &f);
|
ImGui::DragFloat("float##1", &f);
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
|
|
||||||
ImGui::Text("Proportional: 50%% of window width");
|
ImGui::Text("PushItemWidth(GetWindowWidth() * 0.5f);");
|
||||||
ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.5f);
|
ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.5f);
|
||||||
ImGui::InputFloat("float##2", &f);
|
ImGui::DragFloat("float##2", &f);
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
|
|
||||||
ImGui::Text("Right-aligned: Leave 100 pixels for label");
|
ImGui::Text("PushItemWidth(GetContentRegionAvailWidth() * 0.5f);");
|
||||||
|
ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth() * 0.5f);
|
||||||
|
ImGui::DragFloat("float##3", &f);
|
||||||
|
ImGui::PopItemWidth();
|
||||||
|
|
||||||
|
ImGui::Text("PushItemWidth(-100);");
|
||||||
ImGui::PushItemWidth(-100);
|
ImGui::PushItemWidth(-100);
|
||||||
ImGui::InputFloat("float##3", &f);
|
ImGui::DragFloat("float##4", &f);
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
|
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
@ -773,7 +783,7 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||||||
ImGui::Text("can fit within a text block.");
|
ImGui::Text("can fit within a text block.");
|
||||||
|
|
||||||
// Aligned to arbitrary position. Easy/cheap column.
|
// Aligned to arbitrary position. Easy/cheap column.
|
||||||
ImGui::Text("Aligned");
|
ImGui::Text("Aligned");
|
||||||
ImGui::SameLine(150); ImGui::Text("x=150");
|
ImGui::SameLine(150); ImGui::Text("x=150");
|
||||||
ImGui::SameLine(300); ImGui::Text("x=300");
|
ImGui::SameLine(300); ImGui::Text("x=300");
|
||||||
ImGui::Text("Aligned");
|
ImGui::Text("Aligned");
|
||||||
@ -795,7 +805,7 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||||||
ImGui::Combo("Combo", &item, items, IM_ARRAYSIZE(items)); ImGui::SameLine();
|
ImGui::Combo("Combo", &item, items, IM_ARRAYSIZE(items)); ImGui::SameLine();
|
||||||
ImGui::SliderFloat("X", &f0, 0.0f,5.0f); ImGui::SameLine();
|
ImGui::SliderFloat("X", &f0, 0.0f,5.0f); ImGui::SameLine();
|
||||||
ImGui::SliderFloat("Y", &f1, 0.0f,5.0f); ImGui::SameLine();
|
ImGui::SliderFloat("Y", &f1, 0.0f,5.0f); ImGui::SameLine();
|
||||||
ImGui::SliderFloat("Z", &f2, 0.0f,5.0f);
|
ImGui::SliderFloat("Z", &f2, 0.0f,5.0f);
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
|
|
||||||
ImGui::PushItemWidth(80);
|
ImGui::PushItemWidth(80);
|
||||||
@ -807,7 +817,7 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||||||
ImGui::PushID(i);
|
ImGui::PushID(i);
|
||||||
ImGui::ListBox("", &selection[i], items, IM_ARRAYSIZE(items));
|
ImGui::ListBox("", &selection[i], items, IM_ARRAYSIZE(items));
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
//if (ImGui::IsItemHovered()) ImGui::SetTooltip("ListBox %d hovered", i);
|
//if (ImGui::IsItemHovered()) ImGui::SetTooltip("ListBox %d hovered", i);
|
||||||
}
|
}
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
|
|
||||||
@ -822,7 +832,7 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||||||
|
|
||||||
if (ImGui::TreeNode("Groups"))
|
if (ImGui::TreeNode("Groups"))
|
||||||
{
|
{
|
||||||
ImGui::TextWrapped("(Using ImGui::BeginGroup()/EndGroup() to layout items)");
|
ImGui::TextWrapped("(Using ImGui::BeginGroup()/EndGroup() to layout items. BeginGroup() basically locks the horizontal position. EndGroup() bundled the whole group so that you can use functions such as IsItemHovered() on it.)");
|
||||||
ImGui::BeginGroup();
|
ImGui::BeginGroup();
|
||||||
{
|
{
|
||||||
ImGui::BeginGroup();
|
ImGui::BeginGroup();
|
||||||
@ -864,9 +874,9 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||||||
|
|
||||||
if (ImGui::TreeNode("Text Baseline Alignment"))
|
if (ImGui::TreeNode("Text Baseline Alignment"))
|
||||||
{
|
{
|
||||||
ImGui::TextWrapped("(This is testing the vertical alignment that occurs on text to keep it at the same baseline as widgets. Lines only composed of text or \"small\" widgets fit in less vertical spaces than lines with normal widgets)");
|
ImGui::TextWrapped("(This is testing the vertical alignment that occurs on text to keep it at the same baseline as widgets. Lines only composed of text or \"small\" widgets fit in less vertical spaces than lines with normal widgets)");
|
||||||
|
|
||||||
ImGui::Text("One\nTwo\nThree"); ImGui::SameLine();
|
ImGui::Text("One\nTwo\nThree"); ImGui::SameLine();
|
||||||
ImGui::Text("Hello\nWorld"); ImGui::SameLine();
|
ImGui::Text("Hello\nWorld"); ImGui::SameLine();
|
||||||
ImGui::Text("Banana");
|
ImGui::Text("Banana");
|
||||||
|
|
||||||
@ -898,11 +908,11 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||||||
|
|
||||||
if (ImGui::TreeNode("Scrolling"))
|
if (ImGui::TreeNode("Scrolling"))
|
||||||
{
|
{
|
||||||
ImGui::TextWrapped("Use SetScrollHere() or SetScrollFromPosY() to scroll to a given position.");
|
ImGui::TextWrapped("(Use SetScrollHere() or SetScrollFromPosY() to scroll to a given position.)");
|
||||||
static bool track = true;
|
static bool track = true;
|
||||||
static int track_line = 50, scroll_to_px = 200;
|
static int track_line = 50, scroll_to_px = 200;
|
||||||
ImGui::Checkbox("Track", &track);
|
ImGui::Checkbox("Track", &track);
|
||||||
ImGui::SameLine(130); track |= ImGui::DragInt("##line", &track_line, 0.25f, 0, 9999, "Line %.0f");
|
ImGui::SameLine(130); track |= ImGui::DragInt("##line", &track_line, 0.25f, 0, 99, "Line %.0f");
|
||||||
bool scroll_to = ImGui::Button("Scroll To");
|
bool scroll_to = ImGui::Button("Scroll To");
|
||||||
ImGui::SameLine(130); scroll_to |= ImGui::DragInt("##pos_y", &scroll_to_px, 1.00f, 0, 9999, "y = %.0f px");
|
ImGui::SameLine(130); scroll_to |= ImGui::DragInt("##pos_y", &scroll_to_px, 1.00f, 0, 9999, "y = %.0f px");
|
||||||
if (scroll_to) track = false;
|
if (scroll_to) track = false;
|
||||||
@ -933,6 +943,47 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ImGui::TreeNode("Horizontal Scrolling"))
|
||||||
|
{
|
||||||
|
ImGui::Bullet(); ImGui::TextWrapped("Horizontal scrolling for a window has to be enabled explicitly via the ImGuiWindowFlags_HorizontalScrollbar flag.");
|
||||||
|
ImGui::Bullet(); ImGui::TextWrapped("You may want to explicitly specify content width by calling SetNextWindowContentWidth() before Begin().");
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2.0f, 1.0f));
|
||||||
|
ImGui::BeginChild("scrolling", ImVec2(0, ImGui::GetItemsLineHeightWithSpacing()*7 + 30), true, ImGuiWindowFlags_HorizontalScrollbar);
|
||||||
|
for (int line = 0; line < 7; line++)
|
||||||
|
{
|
||||||
|
// Display random stuff
|
||||||
|
int num_buttons = 10 + ((line & 1) ? line * 9 : line * 3);
|
||||||
|
for (int n = 0; n < num_buttons; n++)
|
||||||
|
{
|
||||||
|
if (n > 0) ImGui::SameLine();
|
||||||
|
ImGui::PushID(n + line * 1000);
|
||||||
|
char num_buf[16];
|
||||||
|
const char* label = (!(n%15)) ? "FizzBuzz" : (!(n%3)) ? "Fizz" : (!(n%5)) ? "Buzz" : (sprintf(num_buf, "%d", n), num_buf);
|
||||||
|
float hue = n*0.05f;
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_Button, ImColor::HSV(hue, 0.6f, 0.6f));
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImColor::HSV(hue, 0.7f, 0.7f));
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImColor::HSV(hue, 0.8f, 0.8f));
|
||||||
|
ImGui::Button(label, ImVec2(40.0f + sinf((float)(line + n)) * 20.0f, 0.0f));
|
||||||
|
ImGui::PopStyleColor(3);
|
||||||
|
ImGui::PopID();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::EndChild();
|
||||||
|
ImGui::PopStyleVar(2);
|
||||||
|
float scroll_x_delta = 0.0f;
|
||||||
|
ImGui::SmallButton("<<"); if (ImGui::IsItemActive()) scroll_x_delta = -ImGui::GetIO().DeltaTime * 1000.0f;
|
||||||
|
ImGui::SameLine(); ImGui::Text("Scroll from code"); ImGui::SameLine();
|
||||||
|
ImGui::SmallButton(">>"); if (ImGui::IsItemActive()) scroll_x_delta = +ImGui::GetIO().DeltaTime * 1000.0f;
|
||||||
|
if (scroll_x_delta != 0.0f)
|
||||||
|
{
|
||||||
|
ImGui::BeginChild("scrolling"); // Demonstrate a trick: you can use Begin to set yourself in the context of another window (here we are already out of your child window)
|
||||||
|
ImGui::SetScrollX(ImGui::GetScrollX() + scroll_x_delta);
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
ImGui::TreePop();
|
||||||
|
}
|
||||||
|
|
||||||
if (ImGui::TreeNode("Clipping"))
|
if (ImGui::TreeNode("Clipping"))
|
||||||
{
|
{
|
||||||
static ImVec2 size(100, 100), offset(50, 20);
|
static ImVec2 size(100, 100), offset(50, 20);
|
||||||
@ -1032,8 +1083,8 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||||||
ImGui::Text("Value = %.3f (<-- right-click here)", value);
|
ImGui::Text("Value = %.3f (<-- right-click here)", value);
|
||||||
if (ImGui::BeginPopupContextItem("item context menu"))
|
if (ImGui::BeginPopupContextItem("item context menu"))
|
||||||
{
|
{
|
||||||
if (ImGui::Selectable("Set to zero")) value = 0.0f;
|
if (ImGui::Selectable("Set to zero")) value = 0.0f;
|
||||||
if (ImGui::Selectable("Set to PI")) value = 3.1415f;
|
if (ImGui::Selectable("Set to PI")) value = 3.1415f;
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1053,7 +1104,7 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui::TreeNode("Modals"))
|
if (ImGui::TreeNode("Modals"))
|
||||||
{
|
{
|
||||||
ImGui::TextWrapped("Modal windows are like popups but the user cannot close them by clicking outside the window.");
|
ImGui::TextWrapped("Modal windows are like popups but the user cannot close them by clicking outside the window.");
|
||||||
|
|
||||||
if (ImGui::Button("Delete.."))
|
if (ImGui::Button("Delete.."))
|
||||||
@ -1062,7 +1113,7 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||||||
{
|
{
|
||||||
ImGui::Text("All those beautiful files will be deleted.\nThis operation cannot be undone!\n\n");
|
ImGui::Text("All those beautiful files will be deleted.\nThis operation cannot be undone!\n\n");
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
static bool dont_ask_me_next_time = false;
|
static bool dont_ask_me_next_time = false;
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0,0));
|
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0,0));
|
||||||
ImGui::Checkbox("Don't ask me next time", &dont_ask_me_next_time);
|
ImGui::Checkbox("Don't ask me next time", &dont_ask_me_next_time);
|
||||||
@ -1121,7 +1172,7 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||||||
selected = i;
|
selected = i;
|
||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
ImGui::Text(names[i]); ImGui::NextColumn();
|
ImGui::Text(names[i]); ImGui::NextColumn();
|
||||||
ImGui::Text(paths[i]); ImGui::NextColumn();
|
ImGui::Text(paths[i]); ImGui::NextColumn();
|
||||||
ImGui::Text("...."); ImGui::NextColumn();
|
ImGui::Text("...."); ImGui::NextColumn();
|
||||||
}
|
}
|
||||||
ImGui::Columns(1);
|
ImGui::Columns(1);
|
||||||
@ -1161,24 +1212,24 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
static int e = 0;
|
static int e = 0;
|
||||||
ImGui::Text("Hello");
|
ImGui::Text("Hello");
|
||||||
ImGui::Button("Banana");
|
ImGui::Button("Banana");
|
||||||
ImGui::RadioButton("radio a", &e, 0);
|
ImGui::RadioButton("radio a", &e, 0);
|
||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
|
|
||||||
ImGui::Text("ImGui");
|
ImGui::Text("ImGui");
|
||||||
ImGui::Button("Apple");
|
ImGui::Button("Apple");
|
||||||
ImGui::RadioButton("radio b", &e, 1);
|
ImGui::RadioButton("radio b", &e, 1);
|
||||||
static float foo = 1.0f;
|
static float foo = 1.0f;
|
||||||
ImGui::InputFloat("red", &foo, 0.05f, 0, 3);
|
ImGui::InputFloat("red", &foo, 0.05f, 0, 3);
|
||||||
ImGui::Text("An extra line here.");
|
ImGui::Text("An extra line here.");
|
||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
|
|
||||||
ImGui::Text("Sailor");
|
ImGui::Text("Sailor");
|
||||||
ImGui::Button("Corniflower");
|
ImGui::Button("Corniflower");
|
||||||
ImGui::RadioButton("radio c", &e, 2);
|
ImGui::RadioButton("radio c", &e, 2);
|
||||||
static float bar = 1.0f;
|
static float bar = 1.0f;
|
||||||
ImGui::InputFloat("blue", &bar, 0.05f, 0, 3);
|
ImGui::InputFloat("blue", &bar, 0.05f, 0, 3);
|
||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
|
|
||||||
if (ImGui::CollapsingHeader("Category A")) ImGui::Text("Blah blah blah"); ImGui::NextColumn();
|
if (ImGui::CollapsingHeader("Category A")) ImGui::Text("Blah blah blah"); ImGui::NextColumn();
|
||||||
@ -1200,7 +1251,7 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
|
|
||||||
// Word-wrapping
|
// Word wrapping
|
||||||
ImGui::Text("Word-wrapping:");
|
ImGui::Text("Word-wrapping:");
|
||||||
ImGui::Columns(2, "word-wrapping");
|
ImGui::Columns(2, "word-wrapping");
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
@ -1281,11 +1332,11 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||||||
bool focus_3 = ImGui::Button("Focus on 3");
|
bool focus_3 = ImGui::Button("Focus on 3");
|
||||||
int has_focus = 0;
|
int has_focus = 0;
|
||||||
static char buf[128] = "click on a button to set focus";
|
static char buf[128] = "click on a button to set focus";
|
||||||
|
|
||||||
if (focus_1) ImGui::SetKeyboardFocusHere();
|
if (focus_1) ImGui::SetKeyboardFocusHere();
|
||||||
ImGui::InputText("1", buf, IM_ARRAYSIZE(buf));
|
ImGui::InputText("1", buf, IM_ARRAYSIZE(buf));
|
||||||
if (ImGui::IsItemActive()) has_focus = 1;
|
if (ImGui::IsItemActive()) has_focus = 1;
|
||||||
|
|
||||||
if (focus_2) ImGui::SetKeyboardFocusHere();
|
if (focus_2) ImGui::SetKeyboardFocusHere();
|
||||||
ImGui::InputText("2", buf, IM_ARRAYSIZE(buf));
|
ImGui::InputText("2", buf, IM_ARRAYSIZE(buf));
|
||||||
if (ImGui::IsItemActive()) has_focus = 2;
|
if (ImGui::IsItemActive()) has_focus = 2;
|
||||||
@ -1297,7 +1348,7 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||||||
ImGui::PopAllowKeyboardFocus();
|
ImGui::PopAllowKeyboardFocus();
|
||||||
if (has_focus)
|
if (has_focus)
|
||||||
ImGui::Text("Item with focus: %d", has_focus);
|
ImGui::Text("Item with focus: %d", has_focus);
|
||||||
else
|
else
|
||||||
ImGui::Text("Item with focus: <none>");
|
ImGui::Text("Item with focus: <none>");
|
||||||
ImGui::TextWrapped("Cursor & selection are preserved when refocusing last used item in code.");
|
ImGui::TextWrapped("Cursor & selection are preserved when refocusing last used item in code.");
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
@ -1338,6 +1389,7 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||||||
|
|
||||||
ImGui::Text("WantCaptureMouse: %s", io.WantCaptureMouse ? "true" : "false");
|
ImGui::Text("WantCaptureMouse: %s", io.WantCaptureMouse ? "true" : "false");
|
||||||
ImGui::Text("WantCaptureKeyboard: %s", io.WantCaptureKeyboard ? "true" : "false");
|
ImGui::Text("WantCaptureKeyboard: %s", io.WantCaptureKeyboard ? "true" : "false");
|
||||||
|
ImGui::Text("WantTextInput: %s", io.WantTextInput ? "true" : "false");
|
||||||
|
|
||||||
ImGui::Button("Hover me\nto enforce\ninputs capture");
|
ImGui::Button("Hover me\nto enforce\ninputs capture");
|
||||||
if (ImGui::IsItemHovered())
|
if (ImGui::IsItemHovered())
|
||||||
@ -1355,8 +1407,8 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||||||
{
|
{
|
||||||
char label[32];
|
char label[32];
|
||||||
sprintf(label, "Mouse cursor %d", i);
|
sprintf(label, "Mouse cursor %d", i);
|
||||||
ImGui::Bullet(); ImGui::Selectable(label, false);
|
ImGui::Bullet(); ImGui::Selectable(label, false);
|
||||||
if (ImGui::IsItemHovered())
|
if (ImGui::IsItemHovered())
|
||||||
ImGui::SetMouseCursor(i);
|
ImGui::SetMouseCursor(i);
|
||||||
}
|
}
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
@ -1386,6 +1438,10 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
|||||||
{
|
{
|
||||||
ImGui::Checkbox("Anti-aliased lines", &style.AntiAliasedLines);
|
ImGui::Checkbox("Anti-aliased lines", &style.AntiAliasedLines);
|
||||||
ImGui::Checkbox("Anti-aliased shapes", &style.AntiAliasedShapes);
|
ImGui::Checkbox("Anti-aliased shapes", &style.AntiAliasedShapes);
|
||||||
|
ImGui::PushItemWidth(100);
|
||||||
|
ImGui::DragFloat("Curve Tessellation Tolerance", &style.CurveTessellationTol, 0.02f, 0.10f, FLT_MAX, NULL, 2.0f);
|
||||||
|
if (style.CurveTessellationTol < 0.0f) style.CurveTessellationTol = 0.10f;
|
||||||
|
ImGui::PopItemWidth();
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1401,7 +1457,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
|||||||
ImGui::SliderFloat2("ItemInnerSpacing", (float*)&style.ItemInnerSpacing, 0.0f, 20.0f, "%.0f");
|
ImGui::SliderFloat2("ItemInnerSpacing", (float*)&style.ItemInnerSpacing, 0.0f, 20.0f, "%.0f");
|
||||||
ImGui::SliderFloat2("TouchExtraPadding", (float*)&style.TouchExtraPadding, 0.0f, 10.0f, "%.0f");
|
ImGui::SliderFloat2("TouchExtraPadding", (float*)&style.TouchExtraPadding, 0.0f, 10.0f, "%.0f");
|
||||||
ImGui::SliderFloat("IndentSpacing", &style.IndentSpacing, 0.0f, 30.0f, "%.0f");
|
ImGui::SliderFloat("IndentSpacing", &style.IndentSpacing, 0.0f, 30.0f, "%.0f");
|
||||||
ImGui::SliderFloat("ScrollbarWidth", &style.ScrollbarWidth, 1.0f, 20.0f, "%.0f");
|
ImGui::SliderFloat("ScrollbarWidth", &style.ScrollbarSize, 1.0f, 20.0f, "%.0f");
|
||||||
ImGui::SliderFloat("ScrollbarRounding", &style.ScrollbarRounding, 0.0f, 16.0f, "%.0f");
|
ImGui::SliderFloat("ScrollbarRounding", &style.ScrollbarRounding, 0.0f, 16.0f, "%.0f");
|
||||||
ImGui::SliderFloat("GrabMinSize", &style.GrabMinSize, 1.0f, 20.0f, "%.0f");
|
ImGui::SliderFloat("GrabMinSize", &style.GrabMinSize, 1.0f, 20.0f, "%.0f");
|
||||||
ImGui::SliderFloat("GrabRounding", &style.GrabRounding, 0.0f, 16.0f, "%.0f");
|
ImGui::SliderFloat("GrabRounding", &style.GrabRounding, 0.0f, 16.0f, "%.0f");
|
||||||
@ -1424,7 +1480,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
|||||||
const ImVec4& col = style.Colors[i];
|
const ImVec4& col = style.Colors[i];
|
||||||
const char* name = ImGui::GetStyleColName(i);
|
const char* name = ImGui::GetStyleColName(i);
|
||||||
if (!output_only_modified || memcmp(&col, (ref ? &ref->Colors[i] : &def.Colors[i]), sizeof(ImVec4)) != 0)
|
if (!output_only_modified || memcmp(&col, (ref ? &ref->Colors[i] : &def.Colors[i]), sizeof(ImVec4)) != 0)
|
||||||
ImGui::LogText("style.Colors[ImGuiCol_%s]%*s= ImVec4(%.2ff, %.2ff, %.2ff, %.2ff);" IM_NEWLINE, name, 22 - strlen(name), "", col.x, col.y, col.z, col.w);
|
ImGui::LogText("style.Colors[ImGuiCol_%s]%*s= ImVec4(%.2ff, %.2ff, %.2ff, %.2ff);" IM_NEWLINE, name, 22 - (int)strlen(name), "", col.x, col.y, col.z, col.w);
|
||||||
}
|
}
|
||||||
ImGui::LogFinish();
|
ImGui::LogFinish();
|
||||||
}
|
}
|
||||||
@ -1572,7 +1628,7 @@ static void ShowExampleAppFixedOverlay(bool* opened)
|
|||||||
}
|
}
|
||||||
ImGui::Text("Simple overlay\non the top-left side of the screen.");
|
ImGui::Text("Simple overlay\non the top-left side of the screen.");
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
ImGui::Text("Mouse Position: (%.1f,%.1f)", ImGui::GetIO().MousePos.x, ImGui::GetIO().MousePos.y);
|
ImGui::Text("Mouse Position: (%.1f,%.1f)", ImGui::GetIO().MousePos.x, ImGui::GetIO().MousePos.y);
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1635,6 +1691,9 @@ static void ShowExampleAppCustomRendering(bool* opened)
|
|||||||
if (canvas_size.y < 50.0f) canvas_size.y = 50.0f;
|
if (canvas_size.y < 50.0f) canvas_size.y = 50.0f;
|
||||||
draw_list->AddRectFilledMultiColor(canvas_pos, ImVec2(canvas_pos.x + canvas_size.x, canvas_pos.y + canvas_size.y), ImColor(0,0,0), ImColor(255,0,0), ImColor(255,255,0), ImColor(0,255,0));
|
draw_list->AddRectFilledMultiColor(canvas_pos, ImVec2(canvas_pos.x + canvas_size.x, canvas_pos.y + canvas_size.y), ImColor(0,0,0), ImColor(255,0,0), ImColor(255,255,0), ImColor(0,255,0));
|
||||||
draw_list->AddRect(canvas_pos, ImVec2(canvas_pos.x + canvas_size.x, canvas_pos.y + canvas_size.y), ImColor(255,255,255));
|
draw_list->AddRect(canvas_pos, ImVec2(canvas_pos.x + canvas_size.x, canvas_pos.y + canvas_size.y), ImColor(255,255,255));
|
||||||
|
|
||||||
|
draw_list->AddBezierCurve(ImVec2(canvas_pos.x+20,canvas_pos.y+20), ImVec2(canvas_pos.x+100,canvas_pos.y+20), ImVec2(canvas_pos.x+canvas_size.x-100,canvas_pos.y+canvas_size.y-20), ImVec2(canvas_pos.x+canvas_size.x-20,canvas_pos.y+canvas_size.y-20), ImColor(255,200,0), 5.0f);
|
||||||
|
|
||||||
bool adding_preview = false;
|
bool adding_preview = false;
|
||||||
ImGui::InvisibleButton("canvas", canvas_size);
|
ImGui::InvisibleButton("canvas", canvas_size);
|
||||||
if (ImGui::IsItemHovered())
|
if (ImGui::IsItemHovered())
|
||||||
@ -1661,7 +1720,7 @@ static void ShowExampleAppCustomRendering(bool* opened)
|
|||||||
}
|
}
|
||||||
draw_list->PushClipRect(ImVec4(canvas_pos.x, canvas_pos.y, canvas_pos.x+canvas_size.x, canvas_pos.y+canvas_size.y)); // clip lines within the canvas (if we resize it, etc.)
|
draw_list->PushClipRect(ImVec4(canvas_pos.x, canvas_pos.y, canvas_pos.x+canvas_size.x, canvas_pos.y+canvas_size.y)); // clip lines within the canvas (if we resize it, etc.)
|
||||||
for (int i = 0; i < points.Size - 1; i += 2)
|
for (int i = 0; i < points.Size - 1; i += 2)
|
||||||
draw_list->AddLine(ImVec2(canvas_pos.x + points[i].x, canvas_pos.y + points[i].y), ImVec2(canvas_pos.x + points[i+1].x, canvas_pos.y + points[i+1].y), 0xFF00FFFF);
|
draw_list->AddLine(ImVec2(canvas_pos.x + points[i].x, canvas_pos.y + points[i].y), ImVec2(canvas_pos.x + points[i+1].x, canvas_pos.y + points[i+1].y), 0xFF00FFFF, 2.0f);
|
||||||
draw_list->PopClipRect();
|
draw_list->PopClipRect();
|
||||||
if (adding_preview)
|
if (adding_preview)
|
||||||
points.pop_back();
|
points.pop_back();
|
||||||
@ -1690,19 +1749,19 @@ struct ExampleAppConsole
|
|||||||
~ExampleAppConsole()
|
~ExampleAppConsole()
|
||||||
{
|
{
|
||||||
ClearLog();
|
ClearLog();
|
||||||
for (int i = 0; i < Items.Size; i++)
|
for (int i = 0; i < Items.Size; i++)
|
||||||
free(History[i]);
|
free(History[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearLog()
|
void ClearLog()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < Items.Size; i++)
|
for (int i = 0; i < Items.Size; i++)
|
||||||
free(Items[i]);
|
free(Items[i]);
|
||||||
Items.clear();
|
Items.clear();
|
||||||
ScrollToBottom = true;
|
ScrollToBottom = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddLog(const char* fmt, ...)
|
void AddLog(const char* fmt, ...) IM_PRINTFARGS(2)
|
||||||
{
|
{
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
va_list args;
|
va_list args;
|
||||||
@ -1714,7 +1773,7 @@ struct ExampleAppConsole
|
|||||||
ScrollToBottom = true;
|
ScrollToBottom = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Run(const char* title, bool* opened)
|
void Draw(const char* title, bool* opened)
|
||||||
{
|
{
|
||||||
ImGui::SetNextWindowSize(ImVec2(520,600), ImGuiSetCond_FirstUseEver);
|
ImGui::SetNextWindowSize(ImVec2(520,600), ImGuiSetCond_FirstUseEver);
|
||||||
if (!ImGui::Begin(title, opened))
|
if (!ImGui::Begin(title, opened))
|
||||||
@ -1728,8 +1787,8 @@ struct ExampleAppConsole
|
|||||||
|
|
||||||
// TODO: display items starting from the bottom
|
// TODO: display items starting from the bottom
|
||||||
|
|
||||||
if (ImGui::SmallButton("Add Dummy Text")) { AddLog("%d some text", Items.Size); AddLog("some more text"); AddLog("display very important message here!"); } ImGui::SameLine();
|
if (ImGui::SmallButton("Add Dummy Text")) { AddLog("%d some text", Items.Size); AddLog("some more text"); AddLog("display very important message here!"); } ImGui::SameLine();
|
||||||
if (ImGui::SmallButton("Add Dummy Error")) AddLog("[error] something went wrong"); ImGui::SameLine();
|
if (ImGui::SmallButton("Add Dummy Error")) AddLog("[error] something went wrong"); ImGui::SameLine();
|
||||||
if (ImGui::SmallButton("Clear")) ClearLog();
|
if (ImGui::SmallButton("Clear")) ClearLog();
|
||||||
//static float t = 0.0f; if (ImGui::GetTime() - t > 0.02f) { t = ImGui::GetTime(); AddLog("Spam %f", t); }
|
//static float t = 0.0f; if (ImGui::GetTime() - t > 0.02f) { t = ImGui::GetTime(); AddLog("Spam %f", t); }
|
||||||
|
|
||||||
@ -1744,7 +1803,7 @@ struct ExampleAppConsole
|
|||||||
// Display every line as a separate entry so we can change their color or add custom widgets. If you only want raw text you can use ImGui::TextUnformatted(log.begin(), log.end());
|
// Display every line as a separate entry so we can change their color or add custom widgets. If you only want raw text you can use ImGui::TextUnformatted(log.begin(), log.end());
|
||||||
// NB- if you have thousands of entries this approach may be too inefficient. You can seek and display only the lines that are visible - CalcListClipping() is a helper to compute this information.
|
// NB- if you have thousands of entries this approach may be too inefficient. You can seek and display only the lines that are visible - CalcListClipping() is a helper to compute this information.
|
||||||
// If your items are of variable size you may want to implement code similar to what CalcListClipping() does. Or split your data into fixed height items to allow random-seeking into your list.
|
// If your items are of variable size you may want to implement code similar to what CalcListClipping() does. Or split your data into fixed height items to allow random-seeking into your list.
|
||||||
ImGui::BeginChild("ScrollingRegion", ImVec2(0,-ImGui::GetItemsLineHeightWithSpacing()));
|
ImGui::BeginChild("ScrollingRegion", ImVec2(0,-ImGui::GetItemsLineHeightWithSpacing()), false, ImGuiWindowFlags_HorizontalScrollbar);
|
||||||
if (ImGui::BeginPopupContextWindow())
|
if (ImGui::BeginPopupContextWindow())
|
||||||
{
|
{
|
||||||
if (ImGui::Selectable("Clear")) ClearLog();
|
if (ImGui::Selectable("Clear")) ClearLog();
|
||||||
@ -1862,7 +1921,7 @@ struct ExampleAppConsole
|
|||||||
if (candidates.Size == 0)
|
if (candidates.Size == 0)
|
||||||
{
|
{
|
||||||
// No match
|
// No match
|
||||||
AddLog("No match for \"%.*s\"!\n", word_end-word_start, word_start);
|
AddLog("No match for \"%.*s\"!\n", (int)(word_end-word_start), word_start);
|
||||||
}
|
}
|
||||||
else if (candidates.Size == 1)
|
else if (candidates.Size == 1)
|
||||||
{
|
{
|
||||||
@ -1937,7 +1996,88 @@ struct ExampleAppConsole
|
|||||||
static void ShowExampleAppConsole(bool* opened)
|
static void ShowExampleAppConsole(bool* opened)
|
||||||
{
|
{
|
||||||
static ExampleAppConsole console;
|
static ExampleAppConsole console;
|
||||||
console.Run("Example: Console", opened);
|
console.Draw("Example: Console", opened);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Usage:
|
||||||
|
// static ExampleAppLog my_log;
|
||||||
|
// my_log.AddLog("Hello %d world\n", 123);
|
||||||
|
// my_log.Draw("title");
|
||||||
|
struct ExampleAppLog
|
||||||
|
{
|
||||||
|
ImGuiTextBuffer Buf;
|
||||||
|
ImGuiTextFilter Filter;
|
||||||
|
ImVector<int> LineOffsets; // Index to lines offset
|
||||||
|
bool ScrollToBottom;
|
||||||
|
|
||||||
|
void Clear() { Buf.clear(); LineOffsets.clear(); }
|
||||||
|
|
||||||
|
void AddLog(const char* fmt, ...) IM_PRINTFARGS(2)
|
||||||
|
{
|
||||||
|
int old_size = Buf.size();
|
||||||
|
va_list args;
|
||||||
|
va_start(args, fmt);
|
||||||
|
Buf.appendv(fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
for (int new_size = Buf.size(); old_size < new_size; old_size++)
|
||||||
|
if (Buf[old_size] == '\n')
|
||||||
|
LineOffsets.push_back(old_size);
|
||||||
|
ScrollToBottom = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Draw(const char* title, bool* p_opened = NULL)
|
||||||
|
{
|
||||||
|
ImGui::SetNextWindowSize(ImVec2(500,400), ImGuiSetCond_FirstUseEver);
|
||||||
|
ImGui::Begin(title, p_opened);
|
||||||
|
if (ImGui::Button("Clear")) Clear();
|
||||||
|
ImGui::SameLine();
|
||||||
|
bool copy = ImGui::Button("Copy");
|
||||||
|
ImGui::SameLine();
|
||||||
|
Filter.Draw("Filter", -100.0f);
|
||||||
|
ImGui::Separator();
|
||||||
|
ImGui::BeginChild("scrolling", ImVec2(0,0), false, ImGuiWindowFlags_HorizontalScrollbar);
|
||||||
|
if (copy) ImGui::LogToClipboard();
|
||||||
|
|
||||||
|
if (Filter.IsActive())
|
||||||
|
{
|
||||||
|
const char* buf_begin = Buf.begin();
|
||||||
|
const char* line = buf_begin;
|
||||||
|
for (int line_no = 0; line != NULL; line_no++)
|
||||||
|
{
|
||||||
|
const char* line_end = (line_no < LineOffsets.Size) ? buf_begin + LineOffsets[line_no] : NULL;
|
||||||
|
if (Filter.PassFilter(line, line_end))
|
||||||
|
ImGui::TextUnformatted(line, line_end);
|
||||||
|
line = line_end && line_end[1] ? line_end + 1 : NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ImGui::TextUnformatted(Buf.begin());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ScrollToBottom)
|
||||||
|
ImGui::SetScrollHere(1.0f);
|
||||||
|
ScrollToBottom = false;
|
||||||
|
ImGui::EndChild();
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static void ShowExampleAppLog(bool* opened)
|
||||||
|
{
|
||||||
|
static ExampleAppLog log;
|
||||||
|
|
||||||
|
// Demo fill
|
||||||
|
static float last_time = -1.0f;
|
||||||
|
float time = ImGui::GetTime();
|
||||||
|
if (time - last_time >= 0.3f)
|
||||||
|
{
|
||||||
|
const char* random_words[] = { "system", "info", "warning", "error", "fatal", "notice", "log" };
|
||||||
|
log.AddLog("[%s] Hello, time is %.1f, rand() %d\n", random_words[rand() % IM_ARRAYSIZE(random_words)], time, (int)rand());
|
||||||
|
last_time = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Draw("Example: Log", opened);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ShowExampleAppLayout(bool* opened)
|
static void ShowExampleAppLayout(bool* opened)
|
||||||
@ -1967,7 +2107,7 @@ static void ShowExampleAppLayout(bool* opened)
|
|||||||
}
|
}
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|
||||||
// right
|
// right
|
||||||
ImGui::BeginGroup();
|
ImGui::BeginGroup();
|
||||||
ImGui::BeginChild("item view", ImVec2(0, -ImGui::GetItemsLineHeightWithSpacing())); // Leave room for 1 line below us
|
ImGui::BeginChild("item view", ImVec2(0, -ImGui::GetItemsLineHeightWithSpacing())); // Leave room for 1 line below us
|
||||||
@ -1998,7 +2138,7 @@ static void ShowExampleAppLongText(bool* opened)
|
|||||||
static ImGuiTextBuffer log;
|
static ImGuiTextBuffer log;
|
||||||
static int lines = 0;
|
static int lines = 0;
|
||||||
ImGui::Text("Printing unusually long amount of text.");
|
ImGui::Text("Printing unusually long amount of text.");
|
||||||
ImGui::Combo("Test type", &test_type, "Single call to TextUnformatted()\0Multiple calls to Text(), clipped manually\0Multiple calls to Text(), not clipped");
|
ImGui::Combo("Test type", &test_type, "Single call to TextUnformatted()\0Multiple calls to Text(), clipped manually\0Multiple calls to Text(), not clipped\0");
|
||||||
ImGui::Text("Buffer contents: %d lines, %d bytes", lines, log.size());
|
ImGui::Text("Buffer contents: %d lines, %d bytes", lines, log.size());
|
||||||
if (ImGui::Button("Clear")) { log.clear(); lines = 0; }
|
if (ImGui::Button("Clear")) { log.clear(); lines = 0; }
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
@ -2016,16 +2156,16 @@ static void ShowExampleAppLongText(bool* opened)
|
|||||||
ImGui::TextUnformatted(log.begin(), log.end());
|
ImGui::TextUnformatted(log.begin(), log.end());
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
// Multiple calls to Text(), manually coarsely clipped - demonstrate how to use the CalcListClipping() helper.
|
{
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0,0));
|
// Multiple calls to Text(), manually coarsely clipped - demonstrate how to use the ImGuiListClipper helper.
|
||||||
int display_start, display_end;
|
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0,0));
|
||||||
ImGui::CalcListClipping(lines, ImGui::GetTextLineHeight(), &display_start, &display_end);
|
ImGuiListClipper clipper(lines, ImGui::GetTextLineHeight());
|
||||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + (display_start) * ImGui::GetTextLineHeight());
|
for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
|
||||||
for (int i = display_start; i < display_end; i++)
|
ImGui::Text("%i The quick brown fox jumps over the lazy dog\n", i);
|
||||||
ImGui::Text("%i The quick brown fox jumps over the lazy dog\n", i);
|
clipper.End();
|
||||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + (lines - display_end) * ImGui::GetTextLineHeight());
|
ImGui::PopStyleVar();
|
||||||
ImGui::PopStyleVar();
|
break;
|
||||||
break;
|
}
|
||||||
case 2:
|
case 2:
|
||||||
// Multiple calls to Text(), not clipped (slow)
|
// Multiple calls to Text(), not clipped (slow)
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0,0));
|
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0,0));
|
||||||
|
198
imgui_draw.cpp
198
imgui_draw.cpp
@ -1,4 +1,4 @@
|
|||||||
// ImGui library v1.44
|
// ImGui library v1.45 WIP
|
||||||
// Drawing and font code
|
// Drawing and font code
|
||||||
|
|
||||||
// Contains implementation for
|
// Contains implementation for
|
||||||
@ -19,7 +19,7 @@
|
|||||||
#include <stdio.h> // vsnprintf, sscanf, printf
|
#include <stdio.h> // vsnprintf, sscanf, printf
|
||||||
#include <new> // new (ptr)
|
#include <new> // new (ptr)
|
||||||
#ifndef alloca
|
#ifndef alloca
|
||||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
#if _WIN32
|
||||||
#include <malloc.h> // alloca
|
#include <malloc.h> // alloca
|
||||||
#else
|
#else
|
||||||
#include <alloca.h> // alloca
|
#include <alloca.h> // alloca
|
||||||
@ -31,6 +31,9 @@
|
|||||||
#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
|
#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
|
||||||
#define snprintf _snprintf
|
#define snprintf _snprintf
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used
|
||||||
|
#endif
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// STB libraries implementation
|
// STB libraries implementation
|
||||||
@ -82,7 +85,7 @@ using namespace IMGUI_STB_NAMESPACE;
|
|||||||
// ImDrawList
|
// ImDrawList
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
static ImVec4 GNullClipRect(-9999.0f,-9999.0f, +9999.0f, +9999.0f);
|
static ImVec4 GNullClipRect(-8192.0f, -8192.0f, +8192.0f, +8192.0f); // Large values that are easy to encode in a few bits+shift
|
||||||
|
|
||||||
void ImDrawList::Clear()
|
void ImDrawList::Clear()
|
||||||
{
|
{
|
||||||
@ -95,7 +98,8 @@ void ImDrawList::Clear()
|
|||||||
_ClipRectStack.resize(0);
|
_ClipRectStack.resize(0);
|
||||||
_TextureIdStack.resize(0);
|
_TextureIdStack.resize(0);
|
||||||
_Path.resize(0);
|
_Path.resize(0);
|
||||||
_ChannelCurrent = 0;
|
_ChannelsCurrent = 0;
|
||||||
|
_ChannelsCount = 1;
|
||||||
// NB: Do not clear channels so our allocations are re-used after the first frame.
|
// NB: Do not clear channels so our allocations are re-used after the first frame.
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +114,8 @@ void ImDrawList::ClearFreeMemory()
|
|||||||
_ClipRectStack.clear();
|
_ClipRectStack.clear();
|
||||||
_TextureIdStack.clear();
|
_TextureIdStack.clear();
|
||||||
_Path.clear();
|
_Path.clear();
|
||||||
_ChannelCurrent = 0;
|
_ChannelsCurrent = 0;
|
||||||
|
_ChannelsCount = 1;
|
||||||
for (int i = 0; i < _Channels.Size; i++)
|
for (int i = 0; i < _Channels.Size; i++)
|
||||||
{
|
{
|
||||||
if (i == 0) memset(&_Channels[0], 0, sizeof(_Channels[0])); // channel 0 is a copy of CmdBuffer/IdxBuffer, don't destruct again
|
if (i == 0) memset(&_Channels[0], 0, sizeof(_Channels[0])); // channel 0 is a copy of CmdBuffer/IdxBuffer, don't destruct again
|
||||||
@ -123,11 +128,8 @@ void ImDrawList::ClearFreeMemory()
|
|||||||
void ImDrawList::AddDrawCmd()
|
void ImDrawList::AddDrawCmd()
|
||||||
{
|
{
|
||||||
ImDrawCmd draw_cmd;
|
ImDrawCmd draw_cmd;
|
||||||
draw_cmd.ElemCount = 0;
|
|
||||||
draw_cmd.ClipRect = _ClipRectStack.Size ? _ClipRectStack.back() : GNullClipRect;
|
draw_cmd.ClipRect = _ClipRectStack.Size ? _ClipRectStack.back() : GNullClipRect;
|
||||||
draw_cmd.TextureId = _TextureIdStack.Size ? _TextureIdStack.back() : NULL;
|
draw_cmd.TextureId = _TextureIdStack.Size ? _TextureIdStack.back() : NULL;
|
||||||
draw_cmd.UserCallback = NULL;
|
|
||||||
draw_cmd.UserCallbackData = NULL;
|
|
||||||
|
|
||||||
IM_ASSERT(draw_cmd.ClipRect.x <= draw_cmd.ClipRect.z && draw_cmd.ClipRect.y <= draw_cmd.ClipRect.w);
|
IM_ASSERT(draw_cmd.ClipRect.x <= draw_cmd.ClipRect.z && draw_cmd.ClipRect.y <= draw_cmd.ClipRect.w);
|
||||||
CmdBuffer.push_back(draw_cmd);
|
CmdBuffer.push_back(draw_cmd);
|
||||||
@ -148,32 +150,42 @@ void ImDrawList::AddCallback(ImDrawCallback callback, void* callback_data)
|
|||||||
AddDrawCmd();
|
AddDrawCmd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::ChannelsSplit(int channel_count)
|
void ImDrawList::ChannelsSplit(int channels_count)
|
||||||
{
|
{
|
||||||
IM_ASSERT(_ChannelCurrent == 0);
|
IM_ASSERT(_ChannelsCurrent == 0 && _ChannelsCount == 1);
|
||||||
int old_channels_count = _Channels.Size;
|
int old_channels_count = _Channels.Size;
|
||||||
if (old_channels_count < channel_count)
|
if (old_channels_count < channels_count)
|
||||||
_Channels.resize(channel_count);
|
_Channels.resize(channels_count);
|
||||||
for (int i = 0; i < channel_count; i++)
|
_ChannelsCount = channels_count;
|
||||||
|
for (int i = 0; i < channels_count; i++)
|
||||||
|
{
|
||||||
if (i >= old_channels_count)
|
if (i >= old_channels_count)
|
||||||
new(&_Channels[i]) ImDrawChannel();
|
new(&_Channels[i]) ImDrawChannel();
|
||||||
else
|
else if (i > 0)
|
||||||
_Channels[i].CmdBuffer.resize(0), _Channels[i].IdxBuffer.resize(0);
|
_Channels[i].CmdBuffer.resize(0), _Channels[i].IdxBuffer.resize(0);
|
||||||
|
if (_Channels[i].CmdBuffer.Size == 0)
|
||||||
|
{
|
||||||
|
ImDrawCmd draw_cmd;
|
||||||
|
draw_cmd.ClipRect = _ClipRectStack.back();
|
||||||
|
draw_cmd.TextureId = _TextureIdStack.back();
|
||||||
|
_Channels[i].CmdBuffer.push_back(draw_cmd);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::ChannelsMerge(int channel_count)
|
void ImDrawList::ChannelsMerge()
|
||||||
{
|
{
|
||||||
// Note that we never use or rely on channels.Size because it is merely a buffer that we never shrink back to 0 to keep all sub-buffers ready for use.
|
// Note that we never use or rely on channels.Size because it is merely a buffer that we never shrink back to 0 to keep all sub-buffers ready for use.
|
||||||
// This is why this function takes 'channel_count' as a parameter of how many channels to merge (the user knows)
|
// This is why this function takes 'channel_count' as a parameter of how many channels to merge (the user knows)
|
||||||
if (channel_count < 2)
|
if (_ChannelsCount <= 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ChannelsSetCurrent(0);
|
ChannelsSetCurrent(0);
|
||||||
if (CmdBuffer.Size && CmdBuffer.back().ElemCount == 0)
|
if (CmdBuffer.Size && CmdBuffer.back().ElemCount == 0)
|
||||||
CmdBuffer.pop_back();
|
CmdBuffer.pop_back();
|
||||||
|
|
||||||
int new_cmd_buffer_count = 0, new_idx_buffer_count = 0;
|
int new_cmd_buffer_count = 0, new_idx_buffer_count = 0;
|
||||||
for (int i = 1; i < channel_count; i++)
|
for (int i = 1; i < _ChannelsCount; i++)
|
||||||
{
|
{
|
||||||
ImDrawChannel& ch = _Channels[i];
|
ImDrawChannel& ch = _Channels[i];
|
||||||
if (ch.CmdBuffer.Size && ch.CmdBuffer.back().ElemCount == 0)
|
if (ch.CmdBuffer.Size && ch.CmdBuffer.back().ElemCount == 0)
|
||||||
@ -186,23 +198,24 @@ void ImDrawList::ChannelsMerge(int channel_count)
|
|||||||
|
|
||||||
ImDrawCmd* cmd_write = CmdBuffer.Data + CmdBuffer.Size - new_cmd_buffer_count;
|
ImDrawCmd* cmd_write = CmdBuffer.Data + CmdBuffer.Size - new_cmd_buffer_count;
|
||||||
_IdxWritePtr = IdxBuffer.Data + IdxBuffer.Size - new_idx_buffer_count;
|
_IdxWritePtr = IdxBuffer.Data + IdxBuffer.Size - new_idx_buffer_count;
|
||||||
for (int i = 1; i < channel_count; i++)
|
for (int i = 1; i < _ChannelsCount; i++)
|
||||||
{
|
{
|
||||||
ImDrawChannel& ch = _Channels[i];
|
ImDrawChannel& ch = _Channels[i];
|
||||||
if (int sz = ch.CmdBuffer.Size) { memcpy(cmd_write, ch.CmdBuffer.Data, sz * sizeof(ImDrawCmd)); cmd_write += sz; }
|
if (int sz = ch.CmdBuffer.Size) { memcpy(cmd_write, ch.CmdBuffer.Data, sz * sizeof(ImDrawCmd)); cmd_write += sz; }
|
||||||
if (int sz = ch.IdxBuffer.Size) { memcpy(_IdxWritePtr, ch.IdxBuffer.Data, sz * sizeof(ImDrawIdx)); _IdxWritePtr += sz; }
|
if (int sz = ch.IdxBuffer.Size) { memcpy(_IdxWritePtr, ch.IdxBuffer.Data, sz * sizeof(ImDrawIdx)); _IdxWritePtr += sz; }
|
||||||
}
|
}
|
||||||
AddDrawCmd();
|
AddDrawCmd();
|
||||||
|
_ChannelsCount = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::ChannelsSetCurrent(int idx)
|
void ImDrawList::ChannelsSetCurrent(int idx)
|
||||||
{
|
{
|
||||||
if (_ChannelCurrent == idx) return;
|
if (_ChannelsCurrent == idx) return;
|
||||||
memcpy(&_Channels.Data[_ChannelCurrent].CmdBuffer, &CmdBuffer, sizeof(CmdBuffer));
|
memcpy(&_Channels.Data[_ChannelsCurrent].CmdBuffer, &CmdBuffer, sizeof(CmdBuffer)); // copy 12 bytes, four times
|
||||||
memcpy(&_Channels.Data[_ChannelCurrent].IdxBuffer, &IdxBuffer, sizeof(IdxBuffer));
|
memcpy(&_Channels.Data[_ChannelsCurrent].IdxBuffer, &IdxBuffer, sizeof(IdxBuffer));
|
||||||
_ChannelCurrent = idx;
|
_ChannelsCurrent = idx;
|
||||||
memcpy(&CmdBuffer, &_Channels.Data[_ChannelCurrent].CmdBuffer, sizeof(CmdBuffer));
|
memcpy(&CmdBuffer, &_Channels.Data[_ChannelsCurrent].CmdBuffer, sizeof(CmdBuffer));
|
||||||
memcpy(&IdxBuffer, &_Channels.Data[_ChannelCurrent].IdxBuffer, sizeof(IdxBuffer));
|
memcpy(&IdxBuffer, &_Channels.Data[_ChannelsCurrent].IdxBuffer, sizeof(IdxBuffer));
|
||||||
_IdxWritePtr = IdxBuffer.Data + IdxBuffer.Size;
|
_IdxWritePtr = IdxBuffer.Data + IdxBuffer.Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,11 +302,11 @@ void ImDrawList::PrimRect(const ImVec2& a, const ImVec2& c, ImU32 col)
|
|||||||
const ImVec2 uv = GImGui->FontTexUvWhitePixel;
|
const ImVec2 uv = GImGui->FontTexUvWhitePixel;
|
||||||
const ImVec2 b(c.x, a.y);
|
const ImVec2 b(c.x, a.y);
|
||||||
const ImVec2 d(a.x, c.y);
|
const ImVec2 d(a.x, c.y);
|
||||||
_IdxWritePtr[0] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[1] = (ImDrawIdx)(_VtxCurrentIdx+1); _IdxWritePtr[2] = (ImDrawIdx)(_VtxCurrentIdx+2);
|
_IdxWritePtr[0] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[1] = (ImDrawIdx)(_VtxCurrentIdx+1); _IdxWritePtr[2] = (ImDrawIdx)(_VtxCurrentIdx+2);
|
||||||
_IdxWritePtr[3] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[4] = (ImDrawIdx)(_VtxCurrentIdx+2); _IdxWritePtr[5] = (ImDrawIdx)(_VtxCurrentIdx+3);
|
_IdxWritePtr[3] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[4] = (ImDrawIdx)(_VtxCurrentIdx+2); _IdxWritePtr[5] = (ImDrawIdx)(_VtxCurrentIdx+3);
|
||||||
_VtxWritePtr[0].pos = a; _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col;
|
_VtxWritePtr[0].pos = a; _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col;
|
||||||
_VtxWritePtr[1].pos = b; _VtxWritePtr[1].uv = uv; _VtxWritePtr[1].col = col;
|
_VtxWritePtr[1].pos = b; _VtxWritePtr[1].uv = uv; _VtxWritePtr[1].col = col;
|
||||||
_VtxWritePtr[2].pos = c; _VtxWritePtr[2].uv = uv; _VtxWritePtr[2].col = col;
|
_VtxWritePtr[2].pos = c; _VtxWritePtr[2].uv = uv; _VtxWritePtr[2].col = col;
|
||||||
_VtxWritePtr[3].pos = d; _VtxWritePtr[3].uv = uv; _VtxWritePtr[3].col = col;
|
_VtxWritePtr[3].pos = d; _VtxWritePtr[3].uv = uv; _VtxWritePtr[3].col = col;
|
||||||
_VtxWritePtr += 4;
|
_VtxWritePtr += 4;
|
||||||
_VtxCurrentIdx += 4;
|
_VtxCurrentIdx += 4;
|
||||||
@ -306,11 +319,11 @@ void ImDrawList::PrimRectUV(const ImVec2& a, const ImVec2& c, const ImVec2& uv_a
|
|||||||
const ImVec2 d(a.x, c.y);
|
const ImVec2 d(a.x, c.y);
|
||||||
const ImVec2 uv_b(uv_c.x, uv_a.y);
|
const ImVec2 uv_b(uv_c.x, uv_a.y);
|
||||||
const ImVec2 uv_d(uv_a.x, uv_c.y);
|
const ImVec2 uv_d(uv_a.x, uv_c.y);
|
||||||
_IdxWritePtr[0] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[1] = (ImDrawIdx)(_VtxCurrentIdx+1); _IdxWritePtr[2] = (ImDrawIdx)(_VtxCurrentIdx+2);
|
_IdxWritePtr[0] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[1] = (ImDrawIdx)(_VtxCurrentIdx+1); _IdxWritePtr[2] = (ImDrawIdx)(_VtxCurrentIdx+2);
|
||||||
_IdxWritePtr[3] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[4] = (ImDrawIdx)(_VtxCurrentIdx+2); _IdxWritePtr[5] = (ImDrawIdx)(_VtxCurrentIdx+3);
|
_IdxWritePtr[3] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[4] = (ImDrawIdx)(_VtxCurrentIdx+2); _IdxWritePtr[5] = (ImDrawIdx)(_VtxCurrentIdx+3);
|
||||||
_VtxWritePtr[0].pos = a; _VtxWritePtr[0].uv = uv_a; _VtxWritePtr[0].col = col;
|
_VtxWritePtr[0].pos = a; _VtxWritePtr[0].uv = uv_a; _VtxWritePtr[0].col = col;
|
||||||
_VtxWritePtr[1].pos = b; _VtxWritePtr[1].uv = uv_b; _VtxWritePtr[1].col = col;
|
_VtxWritePtr[1].pos = b; _VtxWritePtr[1].uv = uv_b; _VtxWritePtr[1].col = col;
|
||||||
_VtxWritePtr[2].pos = c; _VtxWritePtr[2].uv = uv_c; _VtxWritePtr[2].col = col;
|
_VtxWritePtr[2].pos = c; _VtxWritePtr[2].uv = uv_c; _VtxWritePtr[2].col = col;
|
||||||
_VtxWritePtr[3].pos = d; _VtxWritePtr[3].uv = uv_d; _VtxWritePtr[3].col = col;
|
_VtxWritePtr[3].pos = d; _VtxWritePtr[3].uv = uv_d; _VtxWritePtr[3].col = col;
|
||||||
_VtxWritePtr += 4;
|
_VtxWritePtr += 4;
|
||||||
_VtxCurrentIdx += 4;
|
_VtxCurrentIdx += 4;
|
||||||
@ -348,7 +361,7 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
|
|||||||
|
|
||||||
for (int i1 = 0; i1 < count; i1++)
|
for (int i1 = 0; i1 < count; i1++)
|
||||||
{
|
{
|
||||||
const int i2 = (i1+1) == points_count ? 0 : i1+1;
|
const int i2 = (i1+1) == points_count ? 0 : i1+1;
|
||||||
ImVec2 diff = points[i2] - points[i1];
|
ImVec2 diff = points[i2] - points[i1];
|
||||||
diff *= ImInvLength(diff, 1.0f);
|
diff *= ImInvLength(diff, 1.0f);
|
||||||
temp_normals[i1].x = diff.y;
|
temp_normals[i1].x = diff.y;
|
||||||
@ -425,7 +438,7 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
|
|||||||
unsigned int idx1 = _VtxCurrentIdx;
|
unsigned int idx1 = _VtxCurrentIdx;
|
||||||
for (int i1 = 0; i1 < count; i1++)
|
for (int i1 = 0; i1 < count; i1++)
|
||||||
{
|
{
|
||||||
const int i2 = (i1+1) == points_count ? 0 : i1+1;
|
const int i2 = (i1+1) == points_count ? 0 : i1+1;
|
||||||
unsigned int idx2 = (i1+1) == points_count ? _VtxCurrentIdx : idx1+4;
|
unsigned int idx2 = (i1+1) == points_count ? _VtxCurrentIdx : idx1+4;
|
||||||
|
|
||||||
// Average normals
|
// Average normals
|
||||||
@ -477,7 +490,7 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
|
|||||||
|
|
||||||
for (int i1 = 0; i1 < count; i1++)
|
for (int i1 = 0; i1 < count; i1++)
|
||||||
{
|
{
|
||||||
const int i2 = (i1+1) == points_count ? 0 : i1+1;
|
const int i2 = (i1+1) == points_count ? 0 : i1+1;
|
||||||
const ImVec2& p1 = points[i1];
|
const ImVec2& p1 = points[i1];
|
||||||
const ImVec2& p2 = points[i2];
|
const ImVec2& p2 = points[i2];
|
||||||
ImVec2 diff = p2 - p1;
|
ImVec2 diff = p2 - p1;
|
||||||
@ -491,8 +504,8 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
|
|||||||
_VtxWritePtr[3].pos.x = p1.x - dy; _VtxWritePtr[3].pos.y = p1.y + dx; _VtxWritePtr[3].uv = uv; _VtxWritePtr[3].col = col;
|
_VtxWritePtr[3].pos.x = p1.x - dy; _VtxWritePtr[3].pos.y = p1.y + dx; _VtxWritePtr[3].uv = uv; _VtxWritePtr[3].col = col;
|
||||||
_VtxWritePtr += 4;
|
_VtxWritePtr += 4;
|
||||||
|
|
||||||
_IdxWritePtr[0] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[1] = (ImDrawIdx)(_VtxCurrentIdx+1); _IdxWritePtr[2] = (ImDrawIdx)(_VtxCurrentIdx+2);
|
_IdxWritePtr[0] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[1] = (ImDrawIdx)(_VtxCurrentIdx+1); _IdxWritePtr[2] = (ImDrawIdx)(_VtxCurrentIdx+2);
|
||||||
_IdxWritePtr[3] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[4] = (ImDrawIdx)(_VtxCurrentIdx+2); _IdxWritePtr[5] = (ImDrawIdx)(_VtxCurrentIdx+3);
|
_IdxWritePtr[3] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[4] = (ImDrawIdx)(_VtxCurrentIdx+2); _IdxWritePtr[5] = (ImDrawIdx)(_VtxCurrentIdx+3);
|
||||||
_IdxWritePtr += 6;
|
_IdxWritePtr += 6;
|
||||||
_VtxCurrentIdx += 4;
|
_VtxCurrentIdx += 4;
|
||||||
}
|
}
|
||||||
@ -575,7 +588,7 @@ void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_coun
|
|||||||
}
|
}
|
||||||
for (int i = 2; i < points_count; i++)
|
for (int i = 2; i < points_count; i++)
|
||||||
{
|
{
|
||||||
_IdxWritePtr[0] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[1] = (ImDrawIdx)(_VtxCurrentIdx+i-1); _IdxWritePtr[2] = (ImDrawIdx)(_VtxCurrentIdx+i);
|
_IdxWritePtr[0] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[1] = (ImDrawIdx)(_VtxCurrentIdx+i-1); _IdxWritePtr[2] = (ImDrawIdx)(_VtxCurrentIdx+i);
|
||||||
_IdxWritePtr += 3;
|
_IdxWritePtr += 3;
|
||||||
}
|
}
|
||||||
_VtxCurrentIdx += (ImDrawIdx)vtx_count;
|
_VtxCurrentIdx += (ImDrawIdx)vtx_count;
|
||||||
@ -626,6 +639,56 @@ void ImDrawList::PathArcTo(const ImVec2& centre, float radius, float amin, float
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void PathBezierToCasteljau(ImVector<ImVec2>* path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float tess_tol, int level)
|
||||||
|
{
|
||||||
|
float dx = x4 - x1;
|
||||||
|
float dy = y4 - y1;
|
||||||
|
float d2 = ((x2 - x4) * dy - (y2 - y4) * dx);
|
||||||
|
float d3 = ((x3 - x4) * dy - (y3 - y4) * dx);
|
||||||
|
d2 = (d2 >= 0) ? d2 : -d2;
|
||||||
|
d3 = (d3 >= 0) ? d3 : -d3;
|
||||||
|
if ((d2+d3) * (d2+d3) < tess_tol * (dx*dx + dy*dy))
|
||||||
|
{
|
||||||
|
path->push_back(ImVec2(x4, y4));
|
||||||
|
}
|
||||||
|
else if (level < 10)
|
||||||
|
{
|
||||||
|
float x12 = (x1+x2)*0.5f, y12 = (y1+y2)*0.5f;
|
||||||
|
float x23 = (x2+x3)*0.5f, y23 = (y2+y3)*0.5f;
|
||||||
|
float x34 = (x3+x4)*0.5f, y34 = (y3+y4)*0.5f;
|
||||||
|
float x123 = (x12+x23)*0.5f, y123 = (y12+y23)*0.5f;
|
||||||
|
float x234 = (x23+x34)*0.5f, y234 = (y23+y34)*0.5f;
|
||||||
|
float x1234 = (x123+x234)*0.5f, y1234 = (y123+y234)*0.5f;
|
||||||
|
|
||||||
|
PathBezierToCasteljau(path, x1,y1, x12,y12, x123,y123, x1234,y1234, tess_tol, level+1);
|
||||||
|
PathBezierToCasteljau(path, x1234,y1234, x234,y234, x34,y34, x4,y4, tess_tol, level+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImDrawList::PathBezierCurveTo(const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, int num_segments)
|
||||||
|
{
|
||||||
|
ImVec2 p1 = _Path.back();
|
||||||
|
if (num_segments == 0)
|
||||||
|
{
|
||||||
|
// Auto-tessellated
|
||||||
|
PathBezierToCasteljau(&_Path, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y, GImGui->Style.CurveTessellationTol, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
float t_step = 1.0f / (float)num_segments;
|
||||||
|
for (int i_step = 1; i_step <= num_segments; i_step++)
|
||||||
|
{
|
||||||
|
float t = t_step * i_step;
|
||||||
|
float u = 1.0f - t;
|
||||||
|
float w1 = u*u*u;
|
||||||
|
float w2 = 3*u*u*t;
|
||||||
|
float w3 = 3*u*t*t;
|
||||||
|
float w4 = t*t*t;
|
||||||
|
_Path.push_back(ImVec2(w1*p1.x + w2*p2.x + w3*p3.x + w4*p4.x, w1*p1.y + w2*p2.y + w3*p3.y + w4*p4.y));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ImDrawList::PathRect(const ImVec2& a, const ImVec2& b, float rounding, int rounding_corners)
|
void ImDrawList::PathRect(const ImVec2& a, const ImVec2& b, float rounding, int rounding_corners)
|
||||||
{
|
{
|
||||||
float r = rounding;
|
float r = rounding;
|
||||||
@ -730,6 +793,16 @@ void ImDrawList::AddCircleFilled(const ImVec2& centre, float radius, ImU32 col,
|
|||||||
PathFill(col);
|
PathFill(col);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImDrawList::AddBezierCurve(const ImVec2& pos0, const ImVec2& cp0, const ImVec2& cp1, const ImVec2& pos1, ImU32 col, float thickness, int num_segments)
|
||||||
|
{
|
||||||
|
if ((col >> 24) == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
PathLineTo(pos0);
|
||||||
|
PathBezierCurveTo(cp0, cp1, pos1, num_segments);
|
||||||
|
PathStroke(col, false, thickness);
|
||||||
|
}
|
||||||
|
|
||||||
void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end, float wrap_width, const ImVec4* cpu_fine_clip_rect)
|
void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end, float wrap_width, const ImVec4* cpu_fine_clip_rect)
|
||||||
{
|
{
|
||||||
if ((col >> 24) == 0)
|
if ((col >> 24) == 0)
|
||||||
@ -820,6 +893,20 @@ void ImDrawData::DeIndexAllBuffers()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than ImGui expects, or if there is a difference between your window resolution and framebuffer resolution.
|
||||||
|
void ImDrawData::ScaleClipRects(const ImVec2& scale)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < CmdListsCount; i++)
|
||||||
|
{
|
||||||
|
ImDrawList* cmd_list = CmdLists[i];
|
||||||
|
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
|
||||||
|
{
|
||||||
|
ImDrawCmd* cmd = &cmd_list->CmdBuffer[cmd_i];
|
||||||
|
cmd->ClipRect = ImVec4(cmd->ClipRect.x * scale.x, cmd->ClipRect.y * scale.y, cmd->ClipRect.z * scale.x, cmd->ClipRect.w * scale.y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// ImFontAtlias
|
// ImFontAtlias
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -897,7 +984,7 @@ void ImFontAtlas::ClearFonts()
|
|||||||
|
|
||||||
void ImFontAtlas::Clear()
|
void ImFontAtlas::Clear()
|
||||||
{
|
{
|
||||||
ClearInputData();
|
ClearInputData();
|
||||||
ClearTexData();
|
ClearTexData();
|
||||||
ClearFonts();
|
ClearFonts();
|
||||||
}
|
}
|
||||||
@ -1002,7 +1089,7 @@ ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels,
|
|||||||
ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
|
ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
|
||||||
if (font_cfg.Name[0] == '\0')
|
if (font_cfg.Name[0] == '\0')
|
||||||
{
|
{
|
||||||
const char* p;
|
const char* p;
|
||||||
for (p = filename + strlen(filename); p > filename && p[-1] != '/' && p[-1] != '\\'; p--) {}
|
for (p = filename + strlen(filename); p > filename && p[-1] != '/' && p[-1] != '\\'; p--) {}
|
||||||
snprintf(font_cfg.Name, IM_ARRAYSIZE(font_cfg.Name), "%s", p);
|
snprintf(font_cfg.Name, IM_ARRAYSIZE(font_cfg.Name), "%s", p);
|
||||||
}
|
}
|
||||||
@ -1013,7 +1100,7 @@ ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels,
|
|||||||
ImFont* ImFontAtlas::AddFontFromMemoryTTF(void* ttf_data, int ttf_size, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges)
|
ImFont* ImFontAtlas::AddFontFromMemoryTTF(void* ttf_data, int ttf_size, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges)
|
||||||
{
|
{
|
||||||
ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
|
ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
|
||||||
IM_ASSERT(font_cfg.FontData == NULL);
|
IM_ASSERT(font_cfg.FontData == NULL);
|
||||||
font_cfg.FontData = ttf_data;
|
font_cfg.FontData = ttf_data;
|
||||||
font_cfg.FontDataSize = ttf_size;
|
font_cfg.FontDataSize = ttf_size;
|
||||||
font_cfg.SizePixels = size_pixels;
|
font_cfg.SizePixels = size_pixels;
|
||||||
@ -1029,7 +1116,7 @@ ImFont* ImFontAtlas::AddFontFromMemoryCompressedTTF(const void* compressed_ttf_d
|
|||||||
stb_decompress(buf_decompressed_data, (unsigned char*)compressed_ttf_data, (unsigned int)compressed_ttf_size);
|
stb_decompress(buf_decompressed_data, (unsigned char*)compressed_ttf_data, (unsigned int)compressed_ttf_size);
|
||||||
|
|
||||||
ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
|
ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
|
||||||
IM_ASSERT(font_cfg.FontData == NULL);
|
IM_ASSERT(font_cfg.FontData == NULL);
|
||||||
font_cfg.FontDataOwnedByAtlas = true;
|
font_cfg.FontDataOwnedByAtlas = true;
|
||||||
return AddFontFromMemoryTTF(buf_decompressed_data, (int)buf_decompressed_size, size_pixels, font_cfg_template, glyph_ranges);
|
return AddFontFromMemoryTTF(buf_decompressed_data, (int)buf_decompressed_size, size_pixels, font_cfg_template, glyph_ranges);
|
||||||
}
|
}
|
||||||
@ -1073,7 +1160,7 @@ bool ImFontAtlas::Build()
|
|||||||
IM_ASSERT(cfg.DstFont && (!cfg.DstFont->IsLoaded() || cfg.DstFont->ContainerAtlas == this));
|
IM_ASSERT(cfg.DstFont && (!cfg.DstFont->IsLoaded() || cfg.DstFont->ContainerAtlas == this));
|
||||||
const int font_offset = stbtt_GetFontOffsetForIndex((unsigned char*)cfg.FontData, cfg.FontNo);
|
const int font_offset = stbtt_GetFontOffsetForIndex((unsigned char*)cfg.FontData, cfg.FontNo);
|
||||||
IM_ASSERT(font_offset >= 0);
|
IM_ASSERT(font_offset >= 0);
|
||||||
if (!stbtt_InitFont(&tmp.FontInfo, (unsigned char*)cfg.FontData, font_offset))
|
if (!stbtt_InitFont(&tmp.FontInfo, (unsigned char*)cfg.FontData, font_offset))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!cfg.GlyphRanges)
|
if (!cfg.GlyphRanges)
|
||||||
@ -1223,7 +1310,7 @@ bool ImFontAtlas::Build()
|
|||||||
dst_font->Glyphs.resize(dst_font->Glyphs.Size + 1);
|
dst_font->Glyphs.resize(dst_font->Glyphs.Size + 1);
|
||||||
ImFont::Glyph& glyph = dst_font->Glyphs.back();
|
ImFont::Glyph& glyph = dst_font->Glyphs.back();
|
||||||
glyph.Codepoint = (ImWchar)codepoint;
|
glyph.Codepoint = (ImWchar)codepoint;
|
||||||
glyph.X0 = q.x0; glyph.Y0 = q.y0; glyph.X1 = q.x1; glyph.Y1 = q.y1;
|
glyph.X0 = q.x0; glyph.Y0 = q.y0; glyph.X1 = q.x1; glyph.Y1 = q.y1;
|
||||||
glyph.U0 = q.s0; glyph.V0 = q.t0; glyph.U1 = q.s1; glyph.V1 = q.t1;
|
glyph.U0 = q.s0; glyph.V0 = q.t0; glyph.U1 = q.s1; glyph.V1 = q.t1;
|
||||||
glyph.Y0 += (float)(int)(dst_font->Ascent + off_y + 0.5f);
|
glyph.Y0 += (float)(int)(dst_font->Ascent + off_y + 0.5f);
|
||||||
glyph.Y1 += (float)(int)(dst_font->Ascent + off_y + 0.5f);
|
glyph.Y1 += (float)(int)(dst_font->Ascent + off_y + 0.5f);
|
||||||
@ -1285,6 +1372,7 @@ void ImFontAtlas::RenderCustomTexData(int pass, void* p_rects)
|
|||||||
ImVector<stbrp_rect>& rects = *(ImVector<stbrp_rect>*)p_rects;
|
ImVector<stbrp_rect>& rects = *(ImVector<stbrp_rect>*)p_rects;
|
||||||
if (pass == 0)
|
if (pass == 0)
|
||||||
{
|
{
|
||||||
|
// Request rectangles
|
||||||
stbrp_rect r;
|
stbrp_rect r;
|
||||||
memset(&r, 0, sizeof(r));
|
memset(&r, 0, sizeof(r));
|
||||||
r.w = (TEX_DATA_W*2)+1;
|
r.w = (TEX_DATA_W*2)+1;
|
||||||
@ -1293,7 +1381,7 @@ void ImFontAtlas::RenderCustomTexData(int pass, void* p_rects)
|
|||||||
}
|
}
|
||||||
else if (pass == 1)
|
else if (pass == 1)
|
||||||
{
|
{
|
||||||
// Copy pixels
|
// Render/copy pixels
|
||||||
const stbrp_rect& r = rects[0];
|
const stbrp_rect& r = rects[0];
|
||||||
for (int y = 0, n = 0; y < TEX_DATA_H; y++)
|
for (int y = 0, n = 0; y < TEX_DATA_H; y++)
|
||||||
for (int x = 0; x < TEX_DATA_W; x++, n++)
|
for (int x = 0; x < TEX_DATA_W; x++, n++)
|
||||||
@ -1364,7 +1452,7 @@ const ImWchar* ImFontAtlas::GetGlyphRangesJapanese()
|
|||||||
{
|
{
|
||||||
// Store the 1946 ideograms code points as successive offsets from the initial unicode codepoint 0x4E00. Each offset has an implicit +1.
|
// Store the 1946 ideograms code points as successive offsets from the initial unicode codepoint 0x4E00. Each offset has an implicit +1.
|
||||||
// This encoding helps us reduce the source code size.
|
// This encoding helps us reduce the source code size.
|
||||||
static const short offsets_from_0x4E00[] =
|
static const short offsets_from_0x4E00[] =
|
||||||
{
|
{
|
||||||
-1,0,1,3,0,0,0,0,1,0,5,1,1,0,7,4,6,10,0,1,9,9,7,1,3,19,1,10,7,1,0,1,0,5,1,0,6,4,2,6,0,0,12,6,8,0,3,5,0,1,0,9,0,0,8,1,1,3,4,5,13,0,0,8,2,17,
|
-1,0,1,3,0,0,0,0,1,0,5,1,1,0,7,4,6,10,0,1,9,9,7,1,3,19,1,10,7,1,0,1,0,5,1,0,6,4,2,6,0,0,12,6,8,0,3,5,0,1,0,9,0,0,8,1,1,3,4,5,13,0,0,8,2,17,
|
||||||
4,3,1,1,9,6,0,0,0,2,1,3,2,22,1,9,11,1,13,1,3,12,0,5,9,2,0,6,12,5,3,12,4,1,2,16,1,1,4,6,5,3,0,6,13,15,5,12,8,14,0,0,6,15,3,6,0,18,8,1,6,14,1,
|
4,3,1,1,9,6,0,0,0,2,1,3,2,22,1,9,11,1,13,1,3,12,0,5,9,2,0,6,12,5,3,12,4,1,2,16,1,1,4,6,5,3,0,6,13,15,5,12,8,14,0,0,6,15,3,6,0,18,8,1,6,14,1,
|
||||||
@ -1864,8 +1952,8 @@ void ImFont::RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& clip_re
|
|||||||
// NB: we are not calling PrimRectUV() here because non-inlined causes too much overhead in a debug build.
|
// NB: we are not calling PrimRectUV() here because non-inlined causes too much overhead in a debug build.
|
||||||
// inlined:
|
// inlined:
|
||||||
{
|
{
|
||||||
idx_write[0] = (ImDrawIdx)(vtx_current_idx); idx_write[1] = (ImDrawIdx)(vtx_current_idx+1); idx_write[2] = (ImDrawIdx)(vtx_current_idx+2);
|
idx_write[0] = (ImDrawIdx)(vtx_current_idx); idx_write[1] = (ImDrawIdx)(vtx_current_idx+1); idx_write[2] = (ImDrawIdx)(vtx_current_idx+2);
|
||||||
idx_write[3] = (ImDrawIdx)(vtx_current_idx); idx_write[4] = (ImDrawIdx)(vtx_current_idx+2); idx_write[5] = (ImDrawIdx)(vtx_current_idx+3);
|
idx_write[3] = (ImDrawIdx)(vtx_current_idx); idx_write[4] = (ImDrawIdx)(vtx_current_idx+2); idx_write[5] = (ImDrawIdx)(vtx_current_idx+3);
|
||||||
vtx_write[0].pos.x = x1; vtx_write[0].pos.y = y1; vtx_write[0].col = col; vtx_write[0].uv.x = u1; vtx_write[0].uv.y = v1;
|
vtx_write[0].pos.x = x1; vtx_write[0].pos.y = y1; vtx_write[0].col = col; vtx_write[0].uv.x = u1; vtx_write[0].uv.y = v1;
|
||||||
vtx_write[1].pos.x = x2; vtx_write[1].pos.y = y1; vtx_write[1].col = col; vtx_write[1].uv.x = u2; vtx_write[1].uv.y = v1;
|
vtx_write[1].pos.x = x2; vtx_write[1].pos.y = y1; vtx_write[1].col = col; vtx_write[1].uv.x = u2; vtx_write[1].uv.y = v1;
|
||||||
vtx_write[2].pos.x = x2; vtx_write[2].pos.y = y2; vtx_write[2].col = col; vtx_write[2].uv.x = u2; vtx_write[2].uv.y = v2;
|
vtx_write[2].pos.x = x2; vtx_write[2].pos.y = y2; vtx_write[2].col = col; vtx_write[2].uv.x = u2; vtx_write[2].uv.y = v2;
|
||||||
@ -1999,7 +2087,7 @@ static unsigned int stb_decompress(unsigned char *output, unsigned char *i, unsi
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IM_ASSERT(stb__dout <= output + olen);
|
IM_ASSERT(stb__dout <= output + olen);
|
||||||
if (stb__dout > output + olen)
|
if (stb__dout > output + olen)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -2102,7 +2190,7 @@ static const char proggy_clean_ttf_compressed_data_base85[11980+1] =
|
|||||||
"GT4CPGT4CPGT4CPGT4CPGT4CPGT4CP-qekC`.9kEg^+F$kwViFJTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5o,^<-28ZI'O?;xp"
|
"GT4CPGT4CPGT4CPGT4CPGT4CPGT4CP-qekC`.9kEg^+F$kwViFJTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5o,^<-28ZI'O?;xp"
|
||||||
"O?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xp;7q-#lLYI:xvD=#";
|
"O?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xp;7q-#lLYI:xvD=#";
|
||||||
|
|
||||||
static const char* GetDefaultCompressedFontDataTTFBase85()
|
static const char* GetDefaultCompressedFontDataTTFBase85()
|
||||||
{
|
{
|
||||||
return proggy_clean_ttf_compressed_data_base85;
|
return proggy_clean_ttf_compressed_data_base85;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// ImGui library v1.44
|
// ImGui library v1.45 WIP
|
||||||
// Internals
|
// Internals
|
||||||
// You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility!
|
// You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility!
|
||||||
|
|
||||||
@ -7,6 +7,10 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef IMGUI_VERSION
|
||||||
|
#error Must include imgui.h before imgui_internal.h
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdio.h> // FILE*
|
#include <stdio.h> // FILE*
|
||||||
#include <math.h> // sqrtf()
|
#include <math.h> // sqrtf()
|
||||||
|
|
||||||
@ -29,6 +33,7 @@ struct ImGuiWindow;
|
|||||||
|
|
||||||
typedef int ImGuiLayoutType; // enum ImGuiLayoutType_
|
typedef int ImGuiLayoutType; // enum ImGuiLayoutType_
|
||||||
typedef int ImGuiButtonFlags; // enum ImGuiButtonFlags_
|
typedef int ImGuiButtonFlags; // enum ImGuiButtonFlags_
|
||||||
|
typedef int ImGuiTreeNodeFlags; // enum ImGuiTreeNodeFlags_
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// STB libraries
|
// STB libraries
|
||||||
@ -77,7 +82,7 @@ int ImTextCountCharsFromUtf8(const char* in_text, const char* in
|
|||||||
int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end); // return number of bytes to express string as UTF-8 code-points
|
int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end); // return number of bytes to express string as UTF-8 code-points
|
||||||
|
|
||||||
// Helpers: Misc
|
// Helpers: Misc
|
||||||
ImU32 ImHash(const void* data, int data_size, ImU32 seed);
|
ImU32 ImHash(const void* data, int data_size, ImU32 seed = 0); // Pass data_size==0 for zero-terminated strings
|
||||||
bool ImLoadFileToMemory(const char* filename, const char* file_open_mode, void** out_file_data, int* out_file_size = NULL, int padding_bytes = 0);
|
bool ImLoadFileToMemory(const char* filename, const char* file_open_mode, void** out_file_data, int* out_file_size = NULL, int padding_bytes = 0);
|
||||||
bool ImIsPointInTriangle(const ImVec2& p, const ImVec2& a, const ImVec2& b, const ImVec2& c);
|
bool ImIsPointInTriangle(const ImVec2& p, const ImVec2& a, const ImVec2& b, const ImVec2& c);
|
||||||
static inline bool ImCharIsSpace(int c) { return c == ' ' || c == '\t' || c == 0x3000; }
|
static inline bool ImCharIsSpace(int c) { return c == ' ' || c == '\t' || c == 0x3000; }
|
||||||
@ -89,8 +94,8 @@ int ImStrnicmp(const char* str1, const char* str2, int count);
|
|||||||
char* ImStrdup(const char* str);
|
char* ImStrdup(const char* str);
|
||||||
int ImStrlenW(const ImWchar* str);
|
int ImStrlenW(const ImWchar* str);
|
||||||
const ImWchar* ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin); // Find beginning-of-line
|
const ImWchar* ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin); // Find beginning-of-line
|
||||||
const char* ImStristr(const char* haystack, const char* needle, const char* needle_end);
|
const char* ImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end);
|
||||||
int ImFormatString(char* buf, int buf_size, const char* fmt, ...);
|
int ImFormatString(char* buf, int buf_size, const char* fmt, ...) IM_PRINTFARGS(3);
|
||||||
int ImFormatStringV(char* buf, int buf_size, const char* fmt, va_list args);
|
int ImFormatStringV(char* buf, int buf_size, const char* fmt, va_list args);
|
||||||
|
|
||||||
// Helpers: Math
|
// Helpers: Math
|
||||||
@ -124,6 +129,7 @@ static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, const ImVec2& t)
|
|||||||
static inline float ImLengthSqr(const ImVec2& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y; }
|
static inline float ImLengthSqr(const ImVec2& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y; }
|
||||||
static inline float ImLengthSqr(const ImVec4& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y + lhs.z*lhs.z + lhs.w*lhs.w; }
|
static inline float ImLengthSqr(const ImVec4& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y + lhs.z*lhs.z + lhs.w*lhs.w; }
|
||||||
static inline float ImInvLength(const ImVec2& lhs, float fail_value) { float d = lhs.x*lhs.x + lhs.y*lhs.y; if (d > 0.0f) return 1.0f / sqrtf(d); return fail_value; }
|
static inline float ImInvLength(const ImVec2& lhs, float fail_value) { float d = lhs.x*lhs.x + lhs.y*lhs.y; if (d > 0.0f) return 1.0f / sqrtf(d); return fail_value; }
|
||||||
|
static inline ImVec2 ImRound(ImVec2 v) { return ImVec2((float)(int)v.x, (float)(int)v.y); }
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Types
|
// Types
|
||||||
@ -140,6 +146,12 @@ enum ImGuiButtonFlags_
|
|||||||
ImGuiButtonFlags_AlignTextBaseLine = 1 << 6
|
ImGuiButtonFlags_AlignTextBaseLine = 1 << 6
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ImGuiTreeNodeFlags_
|
||||||
|
{
|
||||||
|
ImGuiTreeNodeFlags_DefaultOpen = 1 << 0,
|
||||||
|
ImGuiTreeNodeFlags_NoAutoExpandOnLog = 1 << 1
|
||||||
|
};
|
||||||
|
|
||||||
enum ImGuiSelectableFlagsPrivate_
|
enum ImGuiSelectableFlagsPrivate_
|
||||||
{
|
{
|
||||||
// NB: need to be in sync with last value of ImGuiSelectableFlags_
|
// NB: need to be in sync with last value of ImGuiSelectableFlags_
|
||||||
@ -197,7 +209,7 @@ struct ImRect
|
|||||||
void Expand(const ImVec2& amount) { Min.x -= amount.x; Min.y -= amount.y; Max.x += amount.x; Max.y += amount.y; }
|
void Expand(const ImVec2& amount) { Min.x -= amount.x; Min.y -= amount.y; Max.x += amount.x; Max.y += amount.y; }
|
||||||
void Reduce(const ImVec2& amount) { Min.x += amount.x; Min.y += amount.y; Max.x -= amount.x; Max.y -= amount.y; }
|
void Reduce(const ImVec2& amount) { Min.x += amount.x; Min.y += amount.y; Max.x -= amount.x; Max.y -= amount.y; }
|
||||||
void Clip(const ImRect& clip) { if (Min.x < clip.Min.x) Min.x = clip.Min.x; if (Min.y < clip.Min.y) Min.y = clip.Min.y; if (Max.x > clip.Max.x) Max.x = clip.Max.x; if (Max.y > clip.Max.y) Max.y = clip.Max.y; }
|
void Clip(const ImRect& clip) { if (Min.x < clip.Min.x) Min.x = clip.Min.x; if (Min.y < clip.Min.y) Min.y = clip.Min.y; if (Max.x > clip.Max.x) Max.x = clip.Max.x; if (Max.y > clip.Max.y) Max.y = clip.Max.y; }
|
||||||
void Round() { Min.x = (float)(int)Min.x; Min.y = (float)(int)Min.y; Max.x = (float)(int)Max.x; Max.y = (float)(int)Max.y; }
|
void Round() { Min.x = (float)(int)Min.x; Min.y = (float)(int)Min.y; Max.x = (float)(int)Max.x; Max.y = (float)(int)Max.y; }
|
||||||
ImVec2 GetClosestPoint(ImVec2 p, bool on_edge) const
|
ImVec2 GetClosestPoint(ImVec2 p, bool on_edge) const
|
||||||
{
|
{
|
||||||
if (!on_edge && Contains(p))
|
if (!on_edge && Contains(p))
|
||||||
@ -301,8 +313,9 @@ struct ImGuiPopupRef
|
|||||||
ImGuiWindow* Window; // Resolved on BeginPopup() - may stay unresolved if user never calls OpenPopup()
|
ImGuiWindow* Window; // Resolved on BeginPopup() - may stay unresolved if user never calls OpenPopup()
|
||||||
ImGuiWindow* ParentWindow; // Set on OpenPopup()
|
ImGuiWindow* ParentWindow; // Set on OpenPopup()
|
||||||
ImGuiID ParentMenuSet; // Set on OpenPopup()
|
ImGuiID ParentMenuSet; // Set on OpenPopup()
|
||||||
|
ImVec2 MousePosOnOpen; // Copy of mouse position at the time of opening popup
|
||||||
|
|
||||||
ImGuiPopupRef(ImGuiID id, ImGuiWindow* parent_window, ImGuiID parent_menu_set) { PopupID = id; Window = NULL; ParentWindow = parent_window; ParentMenuSet = parent_menu_set; }
|
ImGuiPopupRef(ImGuiID id, ImGuiWindow* parent_window, ImGuiID parent_menu_set, const ImVec2& mouse_pos) { PopupID = id; Window = NULL; ParentWindow = parent_window; ParentMenuSet = parent_menu_set; MousePosOnOpen = mouse_pos; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Main state for ImGui
|
// Main state for ImGui
|
||||||
@ -347,9 +360,11 @@ struct ImGuiState
|
|||||||
// Storage for SetNexWindow** and SetNextTreeNode*** functions
|
// Storage for SetNexWindow** and SetNextTreeNode*** functions
|
||||||
ImVec2 SetNextWindowPosVal;
|
ImVec2 SetNextWindowPosVal;
|
||||||
ImVec2 SetNextWindowSizeVal;
|
ImVec2 SetNextWindowSizeVal;
|
||||||
|
ImVec2 SetNextWindowContentSizeVal;
|
||||||
bool SetNextWindowCollapsedVal;
|
bool SetNextWindowCollapsedVal;
|
||||||
ImGuiSetCond SetNextWindowPosCond;
|
ImGuiSetCond SetNextWindowPosCond;
|
||||||
ImGuiSetCond SetNextWindowSizeCond;
|
ImGuiSetCond SetNextWindowSizeCond;
|
||||||
|
ImGuiSetCond SetNextWindowContentSizeCond;
|
||||||
ImGuiSetCond SetNextWindowCollapsedCond;
|
ImGuiSetCond SetNextWindowCollapsedCond;
|
||||||
bool SetNextWindowFocus;
|
bool SetNextWindowFocus;
|
||||||
bool SetNextTreeNodeOpenedVal;
|
bool SetNextTreeNodeOpenedVal;
|
||||||
@ -372,13 +387,13 @@ struct ImGuiState
|
|||||||
float DragSpeedDefaultRatio; // If speed == 0.0f, uses (max-min) * DragSpeedDefaultRatio
|
float DragSpeedDefaultRatio; // If speed == 0.0f, uses (max-min) * DragSpeedDefaultRatio
|
||||||
float DragSpeedScaleSlow;
|
float DragSpeedScaleSlow;
|
||||||
float DragSpeedScaleFast;
|
float DragSpeedScaleFast;
|
||||||
float ScrollbarClickDeltaToGrabCenter; // Distance between mouse and center of grab box, normalized in parent space
|
ImVec2 ScrollbarClickDeltaToGrabCenter; // Distance between mouse and center of grab box, normalized in parent space. Use storage?
|
||||||
char Tooltip[1024];
|
char Tooltip[1024];
|
||||||
char* PrivateClipboard; // If no custom clipboard handler is defined
|
char* PrivateClipboard; // If no custom clipboard handler is defined
|
||||||
|
|
||||||
// Logging
|
// Logging
|
||||||
bool LogEnabled;
|
bool LogEnabled;
|
||||||
FILE* LogFile; // If != NULL log to stdout/ file
|
FILE* LogFile; // If != NULL log to stdout/ file
|
||||||
ImGuiTextBuffer* LogClipboard; // Else log to clipboard. This is pointer so our GImGui static constructor doesn't call heap allocators.
|
ImGuiTextBuffer* LogClipboard; // Else log to clipboard. This is pointer so our GImGui static constructor doesn't call heap allocators.
|
||||||
int LogStartDepth;
|
int LogStartDepth;
|
||||||
int LogAutoExpandMaxDepth;
|
int LogAutoExpandMaxDepth;
|
||||||
@ -434,7 +449,7 @@ struct ImGuiState
|
|||||||
DragSpeedDefaultRatio = 0.01f;
|
DragSpeedDefaultRatio = 0.01f;
|
||||||
DragSpeedScaleSlow = 0.01f;
|
DragSpeedScaleSlow = 0.01f;
|
||||||
DragSpeedScaleFast = 10.0f;
|
DragSpeedScaleFast = 10.0f;
|
||||||
ScrollbarClickDeltaToGrabCenter = 0.0f;
|
ScrollbarClickDeltaToGrabCenter = ImVec2(0.0f, 0.0f);
|
||||||
memset(Tooltip, 0, sizeof(Tooltip));
|
memset(Tooltip, 0, sizeof(Tooltip));
|
||||||
PrivateClipboard = NULL;
|
PrivateClipboard = NULL;
|
||||||
|
|
||||||
@ -546,26 +561,28 @@ struct ImGuiWindow
|
|||||||
ImVec2 Size; // Current size (==SizeFull or collapsed title bar size)
|
ImVec2 Size; // Current size (==SizeFull or collapsed title bar size)
|
||||||
ImVec2 SizeFull; // Size when non collapsed
|
ImVec2 SizeFull; // Size when non collapsed
|
||||||
ImVec2 SizeContents; // Size of contents (== extents reach of the drawing cursor) from previous frame
|
ImVec2 SizeContents; // Size of contents (== extents reach of the drawing cursor) from previous frame
|
||||||
|
ImVec2 SizeContentsExplicit; // Size of contents explicitly set by the user via SetNextWindowContentSize()
|
||||||
ImVec2 WindowPadding; // Window padding at the time of begin. We need to lock it, in particular manipulation of the ShowBorder would have an effect
|
ImVec2 WindowPadding; // Window padding at the time of begin. We need to lock it, in particular manipulation of the ShowBorder would have an effect
|
||||||
ImGuiID MoveID; // == window->GetID("#MOVE")
|
ImGuiID MoveID; // == window->GetID("#MOVE")
|
||||||
float ScrollY;
|
ImVec2 Scroll;
|
||||||
float ScrollTargetRelY; // target scroll position. stored as cursor position with scrolling canceled out, so the highest point is always 0.0f. (FLT_MAX for no change)
|
ImVec2 ScrollTarget; // target scroll position. stored as cursor position with scrolling canceled out, so the highest point is always 0.0f. (FLT_MAX for no change)
|
||||||
float ScrollTargetCenterRatioY; // 0.0f = scroll so that target position is at top, 0.5f = scroll so that target position is centered
|
ImVec2 ScrollTargetCenterRatio; // 0.0f = scroll so that target position is at top, 0.5f = scroll so that target position is centered
|
||||||
bool ScrollbarY;
|
bool ScrollbarX, ScrollbarY;
|
||||||
|
ImVec2 ScrollbarSizes; //
|
||||||
bool Active; // Set to true on Begin()
|
bool Active; // Set to true on Begin()
|
||||||
bool WasActive;
|
bool WasActive;
|
||||||
bool Accessed; // Set to true when any widget access the current window
|
bool Accessed; // Set to true when any widget access the current window
|
||||||
bool Collapsed; // Set when collapsing window to become only title-bar
|
bool Collapsed; // Set when collapsing window to become only title-bar
|
||||||
bool SkipItems; // == Visible && !Collapsed
|
bool SkipItems; // == Visible && !Collapsed
|
||||||
int BeginCount; // Number of Begin() during the current frame (generally 0 or 1, 1+ if appending via multiple Begin/End pairs)
|
int BeginCount; // Number of Begin() during the current frame (generally 0 or 1, 1+ if appending via multiple Begin/End pairs)
|
||||||
ImGuiID PopupID; // ID in the popup stack when this window is used as a popup/menu (because we use generic Name/ID for recycling)
|
ImGuiID PopupID; // ID in the popup stack when this window is used as a popup/menu (because we use generic Name/ID for recycling)
|
||||||
int AutoFitFramesX, AutoFitFramesY;
|
int AutoFitFramesX, AutoFitFramesY;
|
||||||
bool AutoFitOnlyGrows;
|
bool AutoFitOnlyGrows;
|
||||||
int AutoPosLastDirection;
|
int AutoPosLastDirection;
|
||||||
int HiddenFrames;
|
int HiddenFrames;
|
||||||
int SetWindowPosAllowFlags; // bit ImGuiSetCond_*** specify if SetWindowPos() call will succeed with this particular flag.
|
int SetWindowPosAllowFlags; // bit ImGuiSetCond_*** specify if SetWindowPos() call will succeed with this particular flag.
|
||||||
int SetWindowSizeAllowFlags; // bit ImGuiSetCond_*** specify if SetWindowSize() call will succeed with this particular flag.
|
int SetWindowSizeAllowFlags; // bit ImGuiSetCond_*** specify if SetWindowSize() call will succeed with this particular flag.
|
||||||
int SetWindowCollapsedAllowFlags; // bit ImGuiSetCond_*** specify if SetWindowCollapsed() call will succeed with this particular flag.
|
int SetWindowCollapsedAllowFlags; // bit ImGuiSetCond_*** specify if SetWindowCollapsed() call will succeed with this particular flag.
|
||||||
bool SetWindowPosCenterWanted;
|
bool SetWindowPosCenterWanted;
|
||||||
|
|
||||||
ImGuiDrawContext DC; // Temporary per-window data, reset at the beginning of the frame
|
ImGuiDrawContext DC; // Temporary per-window data, reset at the beginning of the frame
|
||||||
@ -602,7 +619,6 @@ public:
|
|||||||
ImRect TitleBarRect() const { return ImRect(Pos, ImVec2(Pos.x + SizeFull.x, Pos.y + TitleBarHeight())); }
|
ImRect TitleBarRect() const { return ImRect(Pos, ImVec2(Pos.x + SizeFull.x, Pos.y + TitleBarHeight())); }
|
||||||
float MenuBarHeight() const { return (Flags & ImGuiWindowFlags_MenuBar) ? CalcFontSize() + GImGui->Style.FramePadding.y * 2.0f : 0.0f; }
|
float MenuBarHeight() const { return (Flags & ImGuiWindowFlags_MenuBar) ? CalcFontSize() + GImGui->Style.FramePadding.y * 2.0f : 0.0f; }
|
||||||
ImRect MenuBarRect() const { float y1 = Pos.y + TitleBarHeight(); return ImRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight()); }
|
ImRect MenuBarRect() const { float y1 = Pos.y + TitleBarHeight(); return ImRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight()); }
|
||||||
float ScrollbarWidth() const { return ScrollbarY ? GImGui->Style.ScrollbarWidth : 0.0f; }
|
|
||||||
ImU32 Color(ImGuiCol idx, float a=1.f) const { ImVec4 c = GImGui->Style.Colors[idx]; c.w *= GImGui->Style.Alpha * a; return ImGui::ColorConvertFloat4ToU32(c); }
|
ImU32 Color(ImGuiCol idx, float a=1.f) const { ImVec4 c = GImGui->Style.Colors[idx]; c.w *= GImGui->Style.Alpha * a; return ImGui::ColorConvertFloat4ToU32(c); }
|
||||||
ImU32 Color(const ImVec4& col) const { ImVec4 c = col; c.w *= GImGui->Style.Alpha; return ImGui::ColorConvertFloat4ToU32(c); }
|
ImU32 Color(const ImVec4& col) const { ImVec4 c = col; c.w *= GImGui->Style.Alpha; return ImGui::ColorConvertFloat4ToU32(c); }
|
||||||
};
|
};
|
||||||
@ -614,7 +630,8 @@ public:
|
|||||||
|
|
||||||
namespace ImGui
|
namespace ImGui
|
||||||
{
|
{
|
||||||
IMGUI_API ImGuiWindow* GetCurrentWindow();
|
inline ImGuiWindow* GetCurrentWindowRead() { ImGuiState& g = *GImGui; return g.CurrentWindow; } // If this ever crash it means that ImGui::NewFrame() has never been called (which is illegal). We should always have a CurrentWindow in the stack (there is an implicit "Debug" window)
|
||||||
|
inline ImGuiWindow* GetCurrentWindow() { ImGuiState& g = *GImGui; g.CurrentWindow->Accessed = true; return g.CurrentWindow; }
|
||||||
IMGUI_API ImGuiWindow* GetParentWindow();
|
IMGUI_API ImGuiWindow* GetParentWindow();
|
||||||
IMGUI_API void FocusWindow(ImGuiWindow* window);
|
IMGUI_API void FocusWindow(ImGuiWindow* window);
|
||||||
|
|
||||||
@ -631,6 +648,7 @@ namespace ImGui
|
|||||||
IMGUI_API ImVec2 CalcItemSize(ImVec2 size, float default_x, float default_y);
|
IMGUI_API ImVec2 CalcItemSize(ImVec2 size, float default_x, float default_y);
|
||||||
IMGUI_API float CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x);
|
IMGUI_API float CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x);
|
||||||
|
|
||||||
|
// NB: All position are in absolute pixels coordinates (not window coordinates)
|
||||||
IMGUI_API void RenderText(ImVec2 pos, const char* text, const char* text_end = NULL, bool hide_text_after_hash = true);
|
IMGUI_API void RenderText(ImVec2 pos, const char* text, const char* text_end = NULL, bool hide_text_after_hash = true);
|
||||||
IMGUI_API void RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end, float wrap_width);
|
IMGUI_API void RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end, float wrap_width);
|
||||||
IMGUI_API void RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, ImGuiAlign align = ImGuiAlign_Default, const ImVec2* clip_min = NULL, const ImVec2* clip_max = NULL);
|
IMGUI_API void RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, ImGuiAlign align = ImGuiAlign_Default, const ImVec2* clip_min = NULL, const ImVec2* clip_max = NULL);
|
||||||
@ -655,6 +673,8 @@ namespace ImGui
|
|||||||
IMGUI_API bool InputScalarEx(const char* label, ImGuiDataType data_type, void* data_ptr, void* step_ptr, void* step_fast_ptr, const char* scalar_format, ImGuiInputTextFlags extra_flags);
|
IMGUI_API bool InputScalarEx(const char* label, ImGuiDataType data_type, void* data_ptr, void* step_ptr, void* step_fast_ptr, const char* scalar_format, ImGuiInputTextFlags extra_flags);
|
||||||
IMGUI_API bool InputScalarAsWidgetReplacement(const ImRect& aabb, const char* label, ImGuiDataType data_type, void* data_ptr, ImGuiID id, int decimal_precision);
|
IMGUI_API bool InputScalarAsWidgetReplacement(const ImRect& aabb, const char* label, ImGuiDataType data_type, void* data_ptr, ImGuiID id, int decimal_precision);
|
||||||
|
|
||||||
|
IMGUI_API bool TreeNodeBehaviorIsOpened(ImGuiID id, ImGuiTreeNodeFlags flags = 0); // Consume previous SetNextTreeNodeOpened() data, if any. May return true when logging
|
||||||
|
|
||||||
IMGUI_API void PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size);
|
IMGUI_API void PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size);
|
||||||
|
|
||||||
IMGUI_API int ParseFormatPrecision(const char* fmt, int default_value);
|
IMGUI_API int ParseFormatPrecision(const char* fmt, int default_value);
|
||||||
|
Reference in New Issue
Block a user