mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-20 06:46:36 +00:00
Merge branch 'master' into docking
# Conflicts: # backends/imgui_impl_dx9.cpp # backends/imgui_impl_win32.cpp # docs/CHANGELOG.txt # imgui.cpp
This commit is contained in:
commit
6aee4bcdc5
2
.github/issue_template.md
vendored
2
.github/issue_template.md
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
2. PLEASE CAREFULLY READ: [Issue Submitting Guidelines](https://github.com/ocornut/imgui/issues/2261)
|
||||
|
||||
3. FOR FIRST-TIME USERS ISSUES COMPILING/LINKING/RUNNING/LOADING FONTS, please use the [Discord server](http://discord.dearimgui.org).
|
||||
3. FOR FIRST-TIME USERS ISSUES COMPILING/LINKING/RUNNING/LOADING FONTS, please use [GitHub Discussions](https://github.com/ocornut/imgui/discussions).
|
||||
|
||||
4. PLEASE MAKE SURE that you have: read the FAQ; explored the contents of `ShowDemoWindow()` including the Examples menu; searched among Issues; used your IDE to search for keywords in all sources and text files; and read the link provided in (1) (2).
|
||||
|
||||
|
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@ -68,7 +68,7 @@ jobs:
|
||||
#include "examples/example_null/main.cpp"
|
||||
|
||||
EOF
|
||||
g++ -I. -Wall -Wformat -o example_single_file.exe example_single_file.cpp
|
||||
g++ -I. -Wall -Wformat -o example_single_file.exe example_single_file.cpp -limm32
|
||||
|
||||
- name: Build example_null (with IMGUI_DISABLE_WIN32_FUNCTIONS)
|
||||
shell: bash
|
||||
@ -81,7 +81,7 @@ jobs:
|
||||
#include "examples/example_null/main.cpp"
|
||||
|
||||
EOF
|
||||
g++ -I. -Wall -Wformat -o example_single_file.exe example_single_file.cpp
|
||||
g++ -I. -Wall -Wformat -o example_single_file.exe example_single_file.cpp -limm32
|
||||
|
||||
- name: Build example_null (as DLL)
|
||||
shell: cmd
|
||||
|
@ -13,6 +13,7 @@
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2021-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||
// 2021-03-03: DirectX9: Added support for IMGUI_USE_BGRA_PACKED_COLOR in user's imconfig file.
|
||||
// 2021-02-18: DirectX9: Change blending equation to preserve alpha in output buffer.
|
||||
// 2019-05-29: DirectX9: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
|
||||
// 2019-04-30: DirectX9: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
|
||||
@ -30,8 +31,6 @@
|
||||
|
||||
// DirectX
|
||||
#include <d3d9.h>
|
||||
#define DIRECTINPUT_VERSION 0x0800
|
||||
#include <dinput.h>
|
||||
|
||||
// DirectX data
|
||||
static LPDIRECT3DDEVICE9 g_pd3dDevice = NULL;
|
||||
@ -48,6 +47,12 @@ struct CUSTOMVERTEX
|
||||
};
|
||||
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1)
|
||||
|
||||
#ifdef IMGUI_USE_BGRA_PACKED_COLOR
|
||||
#define IMGUI_COL_TO_DX9_ARGB(_COL) (_COL)
|
||||
#else
|
||||
#define IMGUI_COL_TO_DX9_ARGB(_COL) (((_COL) & 0xFF00FF00) | (((_COL) & 0xFF0000) >> 16) | (((_COL) & 0xFF) << 16))
|
||||
#endif
|
||||
|
||||
// Forward Declarations
|
||||
static void ImGui_ImplDX9_InitPlatformInterface();
|
||||
static void ImGui_ImplDX9_ShutdownPlatformInterface();
|
||||
@ -148,7 +153,7 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data)
|
||||
g_pd3dDevice->GetTransform(D3DTS_PROJECTION, &last_projection);
|
||||
|
||||
// Copy and convert all vertices into a single contiguous buffer, convert colors to DX9 default format.
|
||||
// FIXME-OPT: This is a waste of resource, the ideal is to use imconfig.h and
|
||||
// FIXME-OPT: This is a minor waste of resource, the ideal is to use imconfig.h and
|
||||
// 1) to avoid repacking colors: #define IMGUI_USE_BGRA_PACKED_COLOR
|
||||
// 2) to avoid repacking vertices: #define IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT struct ImDrawVert { ImVec2 pos; float z; ImU32 col; ImVec2 uv; }
|
||||
CUSTOMVERTEX* vtx_dst;
|
||||
@ -166,7 +171,7 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data)
|
||||
vtx_dst->pos[0] = vtx_src->pos.x;
|
||||
vtx_dst->pos[1] = vtx_src->pos.y;
|
||||
vtx_dst->pos[2] = 0.0f;
|
||||
vtx_dst->col = (vtx_src->col & 0xFF00FF00) | ((vtx_src->col & 0xFF0000) >> 16) | ((vtx_src->col & 0xFF) << 16); // RGBA --> ARGB for DirectX9
|
||||
vtx_dst->col = IMGUI_COL_TO_DX9_ARGB(vtx_src->col);
|
||||
vtx_dst->uv[0] = vtx_src->uv.x;
|
||||
vtx_dst->uv[1] = vtx_src->uv.y;
|
||||
vtx_dst++;
|
||||
@ -264,6 +269,13 @@ static bool ImGui_ImplDX9_CreateFontsTexture()
|
||||
int width, height, bytes_per_pixel;
|
||||
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height, &bytes_per_pixel);
|
||||
|
||||
// Convert RGBA32 to BGRA32 as the earlier is not well supported by DX9 devices
|
||||
#ifndef IMGUI_USE_BGRA_PACKED_COLOR
|
||||
if (io.Fonts->TexPixelsUseColors)
|
||||
for (ImU32* p = (ImU32*)pixels, *p_end = p + width * height; p < p_end; p++)
|
||||
*p = IMGUI_COL_TO_DX9_ARGB(*p);
|
||||
#endif
|
||||
|
||||
// Upload texture to graphics system
|
||||
g_FontTexture = NULL;
|
||||
if (g_pd3dDevice->CreateTexture(width, height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &g_FontTexture, NULL) < 0)
|
||||
|
@ -773,7 +773,7 @@ static void ImGui_ImplGlfw_SwapBuffers(ImGuiViewport* viewport, void*)
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
|
||||
// We provide a Win32 implementation because this is such a common issue for IME users
|
||||
#if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS) && !defined(__GNUC__)
|
||||
#if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS)
|
||||
#define HAS_WIN32_IME 1
|
||||
#include <imm.h>
|
||||
#ifdef _MSC_VER
|
||||
|
@ -19,6 +19,10 @@
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include <dwmapi.h>
|
||||
|
||||
// Configuration flags to add in your imconfig.h file:
|
||||
//#define IMGUI_IMPL_WIN32_DISABLE_GAMEPAD // Disable gamepad support (this used to be meaningful before <1.81) but we know load XInput dynamically so the option is less relevant now.
|
||||
|
||||
// Using XInput for gamepad (will load DLL dynamically)
|
||||
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
||||
@ -30,6 +34,7 @@ typedef DWORD (WINAPI *PFN_XInputGetState)(DWORD, XINPUT_STATE*);
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2021-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||
// 2021-02-18: Added ImGui_ImplWin32_EnableAlphaCompositing(). Non Visual Studio users will need to link with dwmapi.lib (MinGW/gcc: use -ldwmapi).
|
||||
// 2021-02-17: Fixed ImGui_ImplWin32_EnableDpiAwareness() attempting to get SetProcessDpiAwareness from shcore.dll on Windows 8 whereas it is only supported on Windows 8.1.
|
||||
// 2021-01-25: Inputs: Dynamically loading XInput DLL.
|
||||
// 2020-12-04: Misc: Fixed setting of io.DisplaySize to invalid/uninitialized data when after hwnd has been closed.
|
||||
@ -547,7 +552,7 @@ void ImGui_ImplWin32_EnableDpiAwareness()
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER) && !defined(NOGDI)
|
||||
#pragma comment(lib, "gdi32") // Link with gdi32.lib for GetDeviceCaps()
|
||||
#pragma comment(lib, "gdi32") // Link with gdi32.lib for GetDeviceCaps(). MinGW will require linking with '-lgdi32'
|
||||
#endif
|
||||
|
||||
float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor)
|
||||
@ -588,7 +593,7 @@ float ImGui_ImplWin32_GetDpiScaleForHwnd(void* hwnd)
|
||||
#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS) && !defined(__GNUC__)
|
||||
#if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS)
|
||||
#define HAS_WIN32_IME 1
|
||||
#include <imm.h>
|
||||
#ifdef _MSC_VER
|
||||
@ -929,3 +934,43 @@ static void ImGui_ImplWin32_ShutdownPlatformInterface()
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------
|
||||
// Transparency related helpers (optional)
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma comment(lib, "dwmapi") // Link with dwmapi.lib. MinGW will require linking with '-ldwmapi'
|
||||
#endif
|
||||
|
||||
// [experimental]
|
||||
// Borrowed from GLFW's function updateFramebufferTransparency() in src/win32_window.c
|
||||
// (the Dwm* functions are Vista era functions but we are borrowing logic from GLFW)
|
||||
void ImGui_ImplWin32_EnableAlphaCompositing(void* hwnd)
|
||||
{
|
||||
if (!IsWindowsVistaOrGreater())
|
||||
return;
|
||||
|
||||
BOOL composition;
|
||||
if (FAILED(::DwmIsCompositionEnabled(&composition)) || !composition)
|
||||
return;
|
||||
|
||||
BOOL opaque;
|
||||
DWORD color;
|
||||
if (IsWindows8OrGreater() || (SUCCEEDED(::DwmGetColorizationColor(&color, &opaque)) && !opaque))
|
||||
{
|
||||
HRGN region = ::CreateRectRgn(0, 0, -1, -1);
|
||||
DWM_BLURBEHIND bb = {};
|
||||
bb.dwFlags = DWM_BB_ENABLE | DWM_BB_BLURREGION;
|
||||
bb.hRgnBlur = region;
|
||||
bb.fEnable = TRUE;
|
||||
::DwmEnableBlurBehindWindow((HWND)hwnd, &bb);
|
||||
::DeleteObject(region);
|
||||
}
|
||||
else
|
||||
{
|
||||
DWM_BLURBEHIND bb = {};
|
||||
bb.dwFlags = DWM_BB_ENABLE;
|
||||
::DwmEnableBlurBehindWindow((HWND)hwnd, &bb);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------
|
||||
|
@ -19,10 +19,6 @@ IMGUI_IMPL_API bool ImGui_ImplWin32_Init(void* hwnd);
|
||||
IMGUI_IMPL_API void ImGui_ImplWin32_Shutdown();
|
||||
IMGUI_IMPL_API void ImGui_ImplWin32_NewFrame();
|
||||
|
||||
// Configuration
|
||||
// - Disable gamepad support
|
||||
//#define IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
||||
|
||||
// Win32 message handler your application need to call.
|
||||
// - Intentionally commented out in a '#if 0' block to avoid dragging dependencies on <windows.h> from this helper.
|
||||
// - You should COPY the line below into your .cpp code to forward declare the function and then you can call it.
|
||||
@ -39,3 +35,8 @@ extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg
|
||||
IMGUI_IMPL_API void ImGui_ImplWin32_EnableDpiAwareness();
|
||||
IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForHwnd(void* hwnd); // HWND hwnd
|
||||
IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor); // HMONITOR monitor
|
||||
|
||||
// Transparency related helpers (optional) [experimental]
|
||||
// - Use to enable alpha compositing transparency with the desktop.
|
||||
// - Use together with e.g. clearing your framebuffer with zero-alpha.
|
||||
IMGUI_IMPL_API void ImGui_ImplWin32_EnableAlphaCompositing(void* hwnd); // HWND hwnd
|
||||
|
@ -5,11 +5,11 @@ This document holds the user-facing changelog that we also use in release notes.
|
||||
We generally fold multiple commits pertaining to the same topic as a single entry.
|
||||
Changes to backends are also included within the individual .cpp files of each backend.
|
||||
|
||||
RELEASE NOTES: https://github.com/ocornut/imgui/releases
|
||||
REPORT ISSUES, ASK QUESTIONS: https://github.com/ocornut/imgui/issues
|
||||
COMMITS HISTORY: https://github.com/ocornut/imgui/commits/master
|
||||
FAQ https://www.dearimgui.org/faq/
|
||||
WIKI https://github.com/ocornut/imgui/wiki
|
||||
RELEASE NOTES: https://github.com/ocornut/imgui/releases
|
||||
REPORT ISSUES: https://github.com/ocornut/imgui/issues
|
||||
DISCUSS, ASK QUESTIONS: https://github.com/ocornut/imgui/discussions
|
||||
FAQ https://www.dearimgui.org/faq/
|
||||
WIKI https://github.com/ocornut/imgui/wiki
|
||||
|
||||
WHEN TO UPDATE?
|
||||
|
||||
@ -107,20 +107,36 @@ Breaking Changes:
|
||||
|
||||
- Style: renamed rarely used style.CircleSegmentMaxError (old default = 1.60f)
|
||||
to style.CircleTessellationMaxError (new default = 0.30f) as its meaning changed. (#3808) [@thedmd]
|
||||
- Win32+MinGW: Re-enabled IME functions by default even under MinGW. In July 2016, issue #738 had me incorrectly
|
||||
disable those default functions for MinGW. MinGW users should: either link with -limm32, either set their
|
||||
imconfig file with '#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS'. (#2590, #738) [@actboy168]
|
||||
- Backends: Win32: Pragma linking with dwmapi.lib (Vista-era, ~9 kb). MinGW users will need to link with -ldwmapi.
|
||||
|
||||
Other Changes:
|
||||
|
||||
- DragScalar: Fixed crash when using DragScalar() directly (not via common wrapper like DragFloat() etc.)
|
||||
with ImGuiSliderFlags_AlwaysClamp + only one of either p_min or p_max set. (#3824) [@harry75369]
|
||||
- Window: Shrink close button hit-testing region when it covers an abnormally high portion of the window visible
|
||||
area (e.g. when window is collapsed + moved in a corner) to facilitate moving the window away. (#3825)
|
||||
- Window, Nav: Fixed crash when calling SetWindowFocus(NULL) as the time a new window appears. (#3865) [@nem0]
|
||||
- Added GetAllocatorFunctions() to facilitate sharing allocators accross DLL boundaries. (#3836)
|
||||
- ImFontAtlas: Added 'bool TexPixelsUseColors' output to help backend decide of underlying texture format. (#3369)
|
||||
This can currently only ever be set by the Freetype renderer.
|
||||
- ImDrawList: AddCircle, AddCircleFilled(): Tweaked default segment count calculation to honor MaxError
|
||||
with more accuracy. Made default segment count always even for better looking result. (#3808) [@thedmd]
|
||||
- ImDrawList: AddCircle, AddCircleFilled(): New default for style.
|
||||
- Backends: Win32: Added ImGui_ImplWin32_EnableAlphaCompositing() to facilitate experimenting with
|
||||
alpha compositing and transparent windows. (#2766, #3447 etc.).
|
||||
- Backends: OpenGL, Vulkan, DX9, DX10, DX11, DX12, Metal, WebGPU, Allegro: Rework blending equation to
|
||||
preserve alpha in output buffer (using SrcBlendAlpha = ONE, DstBlendAlpha = ONE_MINUS_SRC_ALPHA consistently
|
||||
accross all backends), facilitating compositing of the output buffer with another buffer.
|
||||
(#2693, #2764, #2766, #2873, #3447, #3813, #3816) [@ocornut, @thedmd, @ShawnM427, @Ubpa, @aiekick]
|
||||
- Backends: DX9: Fix to support IMGUI_USE_BGRA_PACKED_COLOR. (#3844) [@Xiliusha]
|
||||
- Backends: DX9: Fix to support colored glyphs, using newly introduced 'TexPixelsUseColors' info. (#3844)
|
||||
- Examples: Reworked setup of clear color to be compatible with transparent values.
|
||||
- CI: Use a dedicated "scheduled" workflow to trigger scheduled builds. Forks may disable this workflow if
|
||||
scheduled builds builds are not required. [@rokups]
|
||||
>>>>>>> master
|
||||
- Log/Capture: Added LogTextV, a va_list variant of LogText. [@PathogenDavid]
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
|
37
docs/FAQ.md
37
docs/FAQ.md
@ -48,13 +48,13 @@ or view this file with any Markdown viewer.
|
||||
### Q: Where is the documentation?
|
||||
|
||||
**This library is poorly documented at the moment and expects of the user to be acquainted with C/C++.**
|
||||
- The [Wiki](https://github.com/ocornut/imgui/wiki) is a hub to many resources and links.
|
||||
- Dozens of standalone example applications using e.g. OpenGL/DirectX are provided in the [examples/](https://github.com/ocornut/imgui/blob/master/examples/) folder to explain how to integrate Dear ImGui with your own engine/application. You can run those applications and explore them.
|
||||
- See demo code in [imgui_demo.cpp](https://github.com/ocornut/imgui/blob/master/imgui_demo.cpp) and particularly the `ImGui::ShowDemoWindow()` function. The demo covers most features of Dear ImGui, so you can read the code and see its output.
|
||||
- See documentation: [Backends](https://github.com/ocornut/imgui/blob/master/docs/BACKENDS.md), [Examples](https://github.com/ocornut/imgui/blob/master/docs/EXAMPLES.md), [Fonts](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md).
|
||||
- See documentation and comments at the top of [imgui.cpp](https://github.com/ocornut/imgui/blob/master/imgui.cpp) + general API comments in [imgui.h](https://github.com/ocornut/imgui/blob/master/imgui.h).
|
||||
- The [Wiki](https://github.com/ocornut/imgui/wiki) has many resources and links.
|
||||
- The [Glossary](https://github.com/ocornut/imgui/wiki/Glossary) page may be useful.
|
||||
- The [Issues](https://github.com/ocornut/imgui/issues) section can be searched for past questions and issues.
|
||||
- The [Issues](https://github.com/ocornut/imgui/issues) and [Discussions](https://github.com/ocornut/imgui/discussions) sections can be searched for past questions and issues.
|
||||
- Your programming IDE is your friend, find the type or function declaration to find comments associated to it.
|
||||
- The `ImGui::ShowMetricsWindow()` function exposes lots of internal information and tools. Although it is primary designed as a debugging tool, having access to that information tends to help understands concepts.
|
||||
|
||||
@ -94,7 +94,8 @@ You may merge in the [tables](https://github.com/ocornut/imgui/tree/tables) bran
|
||||
|
||||
Read [EXAMPLES.md](https://github.com/ocornut/imgui/blob/master/docs/EXAMPLES.md). <BR>
|
||||
Read [BACKENDS.md](https://github.com/ocornut/imgui/blob/master/docs/BACKENDS.md). <BR>
|
||||
Read `PROGRAMMER GUIDE` section of [imgui.cpp](https://github.com/ocornut/imgui/blob/master/imgui.cpp).
|
||||
Read `PROGRAMMER GUIDE` section of [imgui.cpp](https://github.com/ocornut/imgui/blob/master/imgui.cpp). <BR>
|
||||
The [Wiki](https://github.com/ocornut/imgui/wiki) is a hub to many resources and links.
|
||||
|
||||
##### [Return to Index](#index)
|
||||
|
||||
@ -103,15 +104,25 @@ Read `PROGRAMMER GUIDE` section of [imgui.cpp](https://github.com/ocornut/imgui/
|
||||
### Q: How can I tell whether to dispatch mouse/keyboard to Dear ImGui or to my application?
|
||||
|
||||
You can read the `io.WantCaptureMouse`, `io.WantCaptureKeyboard` and `io.WantTextInput` flags from the ImGuiIO structure.
|
||||
- When `io.WantCaptureMouse` is set, you need to discard/hide the mouse inputs from your underlying application.
|
||||
- When `io.WantCaptureKeyboard` is set, you need to discard/hide the keyboard inputs from your underlying application.
|
||||
- When `io.WantTextInput` is set, you can notify your OS/engine to popup an on-screen keyboard, if available (e.g. on a mobile phone, or console OS).
|
||||
|
||||
e.g. `if (ImGui::GetIO().WantCaptureMouse) { ... }`
|
||||
Important: you should always pass your mouse/keyboard inputs to Dear ImGui, regardless of the value `io.WantCaptureMouse`/`io.WantCaptureKeyboard`. This is because e.g. we need to detect that you clicked in the void to unfocus its own windows, and other reasons.
|
||||
|
||||
- When `io.WantCaptureMouse` is set, imgui wants to use your mouse state, and you may want to discard/hide the inputs from the rest of your application.
|
||||
- When `io.WantCaptureKeyboard` is set, imgui wants to use your keyboard state, and you may want to discard/hide the inputs from the rest of your application.
|
||||
- When `io.WantTextInput` is set to may want to notify your OS to popup an on-screen keyboard, if available (e.g. on a mobile phone, or console OS).
|
||||
```cpp
|
||||
void MyLowLevelMouseButtonHandler(int button, bool down)
|
||||
{
|
||||
// (1) ALWAYS forward mouse data to ImGui! This is automatic with default backends. With your own backend:
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.MouseDown[button] = down;
|
||||
|
||||
// (2) ONLY forward mouse data to your underlying app/game.
|
||||
if (!io.WantCaptureMouse)
|
||||
my_game->HandleMouseData(...);
|
||||
}
|
||||
```
|
||||
|
||||
**Note:** You should always pass your mouse/keyboard inputs to Dear ImGui, even when the io.WantCaptureXXX flag are set false.
|
||||
This is because imgui needs to detect that you clicked in the void to unfocus its own windows.
|
||||
|
||||
**Note:** The `io.WantCaptureMouse` is more correct that any manual attempt to "check if the mouse is hovering a window" (don't do that!). It handle mouse dragging correctly (both dragging that started over your application or over a Dear ImGui window) and handle e.g. popup and modal windows blocking inputs.
|
||||
|
||||
@ -452,8 +463,9 @@ ImGui::End();
|
||||
- To generate colors: you can use the macro `IM_COL32(255,255,255,255)` to generate them at compile time, or use `ImGui::GetColorU32(IM_COL32(255,255,255,255))` or `ImGui::GetColorU32(ImVec4(1.0f,1.0f,1.0f,1.0f))` to generate a color that is multiplied by the current value of `style.Alpha`.
|
||||
- Math operators: if you have setup `IM_VEC2_CLASS_EXTRA` in `imconfig.h` to bind your own math types, you can use your own math types and their natural operators instead of ImVec2. ImVec2 by default doesn't export any math operators in the public API. You may use `#define IMGUI_DEFINE_MATH_OPERATORS` `#include "imgui_internal.h"` to use the internally defined math operators, but instead prefer using your own math library and set it up in `imconfig.h`.
|
||||
- You can use `ImGui::GetBackgroundDrawList()` or `ImGui::GetForegroundDrawList()` to access draw lists which will be displayed behind and over every other dear imgui windows (one bg/fg drawlist per viewport). This is very convenient if you need to quickly display something on the screen that is not associated to a dear imgui window.
|
||||
- You can also create your own empty window and draw inside it. Call Begin() with the NoBackground | NoDecoration | NoSavedSettings | NoInputs flags (The `ImGuiWindowFlags_NoDecoration` flag itself is a shortcut for NoTitleBar | NoResize | NoScrollbar | NoCollapse). Then you can retrieve the ImDrawList* via GetWindowDrawList() and draw to it in any way you like.
|
||||
- You can create your own ImDrawList instance. You'll need to initialize them with `ImGui::GetDrawListSharedData()`, or create your own instancing ImDrawListSharedData, and then call your renderer function with your own ImDrawList or ImDrawData data.
|
||||
- You can also create your own empty window and draw inside it. Call Begin() with the NoBackground | NoDecoration | NoSavedSettings | NoInputs flags (The `ImGuiWindowFlags_NoDecoration` flag itself is a shortcut for NoTitleBar | NoResize | NoScrollbar | NoCollapse). Then you can retrieve the ImDrawList* via `GetWindowDrawList()` and draw to it in any way you like.
|
||||
`- You can create your own ImDrawList instance. You'll need to initialize them with `ImGui::GetDrawListSharedData()`, or create your own instancing ImDrawListSharedData`, and then call your renderer function with your own ImDrawList or ImDrawData data.
|
||||
- Looking for fun? The [ImDrawList coding party 2020](https://github.com/ocornut/imgui/issues/3606) thread is full of "don't do this at home" extreme uses of the ImDrawList API.
|
||||
|
||||
##### [Return to Index](#index)
|
||||
|
||||
@ -599,6 +611,7 @@ You may take a look at:
|
||||
|
||||
- [Quotes](https://github.com/ocornut/imgui/wiki/Quotes)
|
||||
- [Software using Dear ImGui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui)
|
||||
- [Sponsors](https://github.com/ocornut/imgui/wiki/Sponsors)
|
||||
- [Gallery](https://github.com/ocornut/imgui/issues/3488)
|
||||
|
||||
##### [Return to Index](#index)
|
||||
@ -643,7 +656,7 @@ There is an auto-generated [c-api for Dear ImGui (cimgui)](https://github.com/ci
|
||||
### Q: How can I help?
|
||||
- Businesses: please reach out to `contact AT dearimgui.com` if you work in a place using Dear ImGui! We can discuss ways for your company to fund development via invoiced technical support, maintenance or sponsoring contacts. This is among the most useful thing you can do for Dear ImGui. With increased funding we can hire more people working on this project.
|
||||
- Individuals: you can support continued maintenance and development via PayPal donations. See [README](https://github.com/ocornut/imgui/blob/master/docs/README.md).
|
||||
- If you are experienced with Dear ImGui and C++, look at the [GitHub Issues](https://github.com/ocornut/imgui/issues), look at the [Wiki](https://github.com/ocornut/imgui/wiki), read [docs/TODO.txt](https://github.com/ocornut/imgui/blob/master/docs/TODO.txt) and see how you want to help and can help!
|
||||
- If you are experienced with Dear ImGui and C++, look at [GitHub Issues](https://github.com/ocornut/imgui/issues), [GitHub Discussions](https://github.com/ocornut/imgui/discussions), the [Wiki](https://github.com/ocornut/imgui/wiki), read [docs/TODO.txt](https://github.com/ocornut/imgui/blob/master/docs/TODO.txt) and see how you want to help and can help!
|
||||
- Disclose your usage of Dear ImGui via a dev blog post, a tweet, a screenshot, a mention somewhere etc.
|
||||
You may post screenshot or links in the [gallery threads](https://github.com/ocornut/imgui/issues/3488). Visuals are ideal as they inspire other programmers. Disclosing your use of dear imgui help the library grow credibility, and help other teams and programmers with taking decisions.
|
||||
- If you have issues or if you need to hack into the library, even if you don't expect any support it is useful that you share your issues or sometimes incomplete PR.
|
||||
|
@ -8,9 +8,7 @@ a 13 pixels high, pixel-perfect font used by default. We embed it in the source
|
||||
You may also load external .TTF/.OTF files.
|
||||
In the [misc/fonts/](https://github.com/ocornut/imgui/tree/master/misc/fonts) folder you can find a few suggested fonts, provided as a convenience.
|
||||
|
||||
**Read the FAQ:** https://www.dearimgui.org/faq (there is a Fonts section!)
|
||||
|
||||
**Use the Discord server**: http://discord.dearimgui.org and not the GitHub issue tracker for basic font loading questions.
|
||||
**Also read the FAQ:** https://www.dearimgui.org/faq (there is a Fonts section!)
|
||||
|
||||
## Index
|
||||
- [Readme First](#readme-first)
|
||||
|
@ -116,7 +116,7 @@ On most platforms and when using C++, **you should be able to use a combination
|
||||
Integrating Dear ImGui within your custom engine is a matter of 1) wiring mouse/keyboard/gamepad inputs 2) uploading one texture to your GPU/render engine 3) providing a render function that can bind textures and render textured triangles. The [examples/](https://github.com/ocornut/imgui/tree/master/examples) folder is populated with applications doing just that. If you are an experienced programmer at ease with those concepts, it should take you less than two hours to integrate Dear ImGui in your custom engine. **Make sure to spend time reading the [FAQ](https://www.dearimgui.org/faq), comments, and some of the examples/ application!**
|
||||
|
||||
Officially maintained backends/bindings (in repository):
|
||||
- Renderers: DirectX9, DirectX10, DirectX11, DirectX12, Metal, OpenGL (legacy), OpenGL3/ES/ES2 (modern), Vulkan, WebGPU.
|
||||
- Renderers: DirectX9, DirectX10, DirectX11, DirectX12, Metal, OpenGL/ES/ES2, Vulkan, WebGPU.
|
||||
- Platforms: GLFW, SDL2, Win32, Glut, OSX.
|
||||
- Frameworks: Emscripten, Allegro5, Marmalade.
|
||||
|
||||
@ -162,9 +162,7 @@ See: [Wiki](https://github.com/ocornut/imgui/wiki) for many links, references, a
|
||||
|
||||
See: [Articles about the IMGUI paradigm](https://github.com/ocornut/imgui/wiki#about-the-imgui-paradigm) to read/learn about the Immediate Mode GUI paradigm.
|
||||
|
||||
If you are new to Dear ImGui and have issues with: compiling, linking, adding fonts, wiring inputs, running or displaying Dear ImGui: you can use [Discord server](http://discord.dearimgui.org).
|
||||
|
||||
Otherwise, for any other questions, bug reports, requests, feedback, you may post on https://github.com/ocornut/imgui/issues. Please read and fill the New Issue template carefully.
|
||||
For questions, bug reports, requests, feedback, you may post on [GitHub Issues](https://github.com/ocornut/imgui/issues) or [GitHub Discussions](https://github.com/ocornut/imgui/discussions). Please read and fill the New Issue template carefully.
|
||||
|
||||
Private support is available for paying business customers (E-mail: _contact @ dearimgui dot com_).
|
||||
|
||||
@ -183,7 +181,7 @@ How to help
|
||||
|
||||
**How can I help?**
|
||||
|
||||
- You may participate in the [Discord server](http://discord.dearimgui.org), [GitHub forum/issues](https://github.com/ocornut/imgui/issues).
|
||||
- See [GitHub Forum/issues](https://github.com/ocornut/imgui/issues) and [Github Discussions](https://github.com/ocornut/imgui/discussions).
|
||||
- You may help with development and submit pull requests! Please understand that by submitting a PR you are also submitting a request for the maintainer to review your code and then take over its maintenance forever. PR should be crafted both in the interest in the end-users and also to ease the maintainer into understanding and accepting it.
|
||||
- See [Help wanted](https://github.com/ocornut/imgui/wiki/Help-Wanted) on the [Wiki](https://github.com/ocornut/imgui/wiki/) for some more ideas.
|
||||
- Have your company financially support this project (please reach by e-mail)
|
||||
|
@ -49,7 +49,7 @@ ifeq ($(UNAME_S), Darwin) #APPLE
|
||||
CFLAGS = $(CXXFLAGS)
|
||||
endif
|
||||
|
||||
ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
|
||||
ifeq ($(OS), Windows_NT)
|
||||
ECHO_MESSAGE = "MinGW"
|
||||
LIBS += -lglfw3 -lgdi32 -lopengl32 -limm32
|
||||
|
||||
|
@ -79,7 +79,7 @@ ifeq ($(UNAME_S), Darwin) #APPLE
|
||||
CFLAGS = $(CXXFLAGS)
|
||||
endif
|
||||
|
||||
ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
|
||||
ifeq ($(OS), Windows_NT)
|
||||
ECHO_MESSAGE = "MinGW"
|
||||
LIBS += -lglfw3 -lgdi32 -lopengl32 -limm32
|
||||
|
||||
|
@ -40,7 +40,7 @@ ifeq ($(UNAME_S), Darwin) #APPLE
|
||||
CFLAGS = $(CXXFLAGS)
|
||||
endif
|
||||
|
||||
ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
|
||||
ifeq ($(OS), Windows_NT)
|
||||
ECHO_MESSAGE = "MinGW"
|
||||
LIBS += -lgdi32 -lopengl32 -limm32
|
||||
ifeq ($(shell pkg-config freeglut --exists 2> /dev/null && echo yes || echo no),yes)
|
||||
|
@ -57,11 +57,12 @@ ifeq ($(UNAME_S), Darwin) #APPLE
|
||||
CFLAGS = $(CXXFLAGS)
|
||||
endif
|
||||
|
||||
ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
|
||||
ifeq ($(OS), Windows_NT)
|
||||
ECHO_MESSAGE = "MinGW"
|
||||
ifneq ($(WITH_EXTRA_WARNINGS), 0)
|
||||
CXXFLAGS += -Wextra -Wpedantic
|
||||
endif
|
||||
LIBS += -limm32
|
||||
CFLAGS = $(CXXFLAGS)
|
||||
endif
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
|
||||
mkdir Debug
|
||||
cl /nologo /Zi /MD /I ..\.. %* *.cpp ..\..\*.cpp /FeDebug/example_null.exe /FoDebug/ /link gdi32.lib shell32.lib
|
||||
cl /nologo /Zi /MD /I ..\.. %* *.cpp ..\..\*.cpp /FeDebug/example_null.exe /FoDebug/ /link gdi32.lib shell32.lib imm32.lib
|
||||
|
@ -48,7 +48,7 @@ ifeq ($(UNAME_S), Darwin) #APPLE
|
||||
CFLAGS = $(CXXFLAGS)
|
||||
endif
|
||||
|
||||
ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
|
||||
ifeq ($(OS), Windows_NT)
|
||||
ECHO_MESSAGE = "MinGW"
|
||||
LIBS += -lgdi32 -lopengl32 -limm32 `pkg-config --static --libs sdl2`
|
||||
|
||||
|
@ -78,12 +78,12 @@ ifeq ($(UNAME_S), Darwin) #APPLE
|
||||
CFLAGS = $(CXXFLAGS)
|
||||
endif
|
||||
|
||||
ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
|
||||
ECHO_MESSAGE = "MinGW"
|
||||
LIBS += -lgdi32 -lopengl32 -limm32 `pkg-config --static --libs sdl2`
|
||||
ifeq ($(OS), Windows_NT)
|
||||
ECHO_MESSAGE = "MinGW"
|
||||
LIBS += -lgdi32 -lopengl32 -limm32 `pkg-config --static --libs sdl2`
|
||||
|
||||
CXXFLAGS += `pkg-config --cflags sdl2`
|
||||
CFLAGS = $(CXXFLAGS)
|
||||
CXXFLAGS += `pkg-config --cflags sdl2`
|
||||
CFLAGS = $(CXXFLAGS)
|
||||
endif
|
||||
|
||||
##---------------------------------------------------------------------
|
||||
|
@ -7,8 +7,6 @@
|
||||
#include "imgui_impl_dx10.h"
|
||||
#include <d3d10_1.h>
|
||||
#include <d3d10.h>
|
||||
#define DIRECTINPUT_VERSION 0x0800
|
||||
#include <dinput.h>
|
||||
#include <tchar.h>
|
||||
|
||||
// Data
|
||||
|
@ -6,8 +6,6 @@
|
||||
#include "imgui_impl_win32.h"
|
||||
#include "imgui_impl_dx11.h"
|
||||
#include <d3d11.h>
|
||||
#define DIRECTINPUT_VERSION 0x0800
|
||||
#include <dinput.h>
|
||||
#include <tchar.h>
|
||||
|
||||
// Data
|
||||
|
@ -6,8 +6,6 @@
|
||||
#include "imgui_impl_dx9.h"
|
||||
#include "imgui_impl_win32.h"
|
||||
#include <d3d9.h>
|
||||
#define DIRECTINPUT_VERSION 0x0800
|
||||
#include <dinput.h>
|
||||
#include <tchar.h>
|
||||
|
||||
// Data
|
||||
|
@ -20,7 +20,9 @@
|
||||
//#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts
|
||||
|
||||
//---- Define attributes of all API symbols declarations, e.g. for DLL under Windows
|
||||
// Using dear imgui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility.
|
||||
// Using Dear ImGui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility.
|
||||
// DLL users: heaps and globals are not shared across DLL boundaries! You will need to call SetCurrentContext() + SetAllocatorFunctions()
|
||||
// for each static/DLL boundary you are calling from. Read "Context and Memory Allocators" section of imgui.cpp for more details.
|
||||
//#define IMGUI_API __declspec( dllexport )
|
||||
//#define IMGUI_API __declspec( dllimport )
|
||||
|
||||
@ -34,8 +36,8 @@
|
||||
//#define IMGUI_DISABLE_METRICS_WINDOW // Disable metrics/debugger window: ShowMetricsWindow() will be empty.
|
||||
|
||||
//---- Don't implement some functions to reduce linkage requirements.
|
||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc.
|
||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] Don't implement default IME handler. Won't use and link with ImmGetContext/ImmSetCompositionWindow.
|
||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc. (user32.lib/.a, kernel32.lib/.a)
|
||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] Don't implement default IME handler. Won't use and link with ImmGetContext/ImmSetCompositionWindow. (imm32.lib/.a)
|
||||
//#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, ime).
|
||||
//#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices', this is why this is not the default).
|
||||
//#define IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself (e.g. if you don't want to link with vsnprintf)
|
||||
|
86
imgui.cpp
86
imgui.cpp
@ -15,6 +15,7 @@
|
||||
// - Glossary https://github.com/ocornut/imgui/wiki/Glossary
|
||||
// - Wiki https://github.com/ocornut/imgui/wiki
|
||||
// - Issues & support https://github.com/ocornut/imgui/issues
|
||||
// - Discussions https://github.com/ocornut/imgui/discussions
|
||||
|
||||
// Developed by Omar Cornut and every direct or indirect contributors to the GitHub.
|
||||
// See LICENSE.txt for copyright and licensing details (standard MIT License).
|
||||
@ -385,6 +386,7 @@ CODE
|
||||
- 2021/XX/XX (1.XX) - Moved IME support functions from io.ImeSetInputScreenPosFn, io.ImeWindowHandle to the PlatformIO api.
|
||||
|
||||
|
||||
- 2021/02/22 (1.82) - win32+mingw: Re-enabled IME functions by default even under MinGW. In July 2016, issue #738 had me incorrectly disable those default functions for MinGW. MinGW users should: either link with -limm32, either set their imconfig file with '#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS'.
|
||||
- 2021/02/17 (1.82) - renamed rarely used style.CircleSegmentMaxError (old default = 1.60f) to style.CircleTessellationMaxError (new default = 0.30f) as the meaning of the value changed.
|
||||
- 2021/02/03 (1.81) - renamed ListBoxHeader(const char* label, ImVec2 size) to BeginListBox(). Kept inline redirection function (will obsolete).
|
||||
- removed ListBoxHeader(const char* label, int items_count, int height_in_items = -1) in favor of specifying size. Kept inline redirection function (will obsolete).
|
||||
@ -935,27 +937,33 @@ static void UpdateViewportPlatformMonitor(ImGuiViewportP* viewport);
|
||||
// [SECTION] CONTEXT AND MEMORY ALLOCATORS
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// DLL users:
|
||||
// - Heaps and globals are not shared across DLL boundaries!
|
||||
// - You will need to call SetCurrentContext() + SetAllocatorFunctions() for each static/DLL boundary you are calling from.
|
||||
// - Same apply for hot-reloading mechanisms that are reliant on reloading DLL (note that many hot-reloading mechanism works without DLL).
|
||||
// - Using Dear ImGui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility.
|
||||
// - Confused? In a debugger: add GImGui to your watch window and notice how its value changes depending on your current location (which DLL boundary you are in).
|
||||
|
||||
// Current context pointer. Implicitly used by all Dear ImGui functions. Always assumed to be != NULL.
|
||||
// ImGui::CreateContext() will automatically set this pointer if it is NULL. Change to a different context by calling ImGui::SetCurrentContext().
|
||||
// 1) Important: globals are not shared across DLL boundaries! If you use DLLs or any form of hot-reloading: you will need to call
|
||||
// SetCurrentContext() (with the pointer you got from CreateContext) from each unique static/DLL boundary, and after each hot-reloading.
|
||||
// In your debugger, add GImGui to your watch window and notice how its value changes depending on which location you are currently stepping into.
|
||||
// 2) Important: Dear ImGui functions are not thread-safe because of this pointer.
|
||||
// If you want thread-safety to allow N threads to access N different contexts, you can:
|
||||
// - Change this variable to use thread local storage so each thread can refer to a different context, in imconfig.h:
|
||||
// struct ImGuiContext;
|
||||
// extern thread_local ImGuiContext* MyImGuiTLS;
|
||||
// #define GImGui MyImGuiTLS
|
||||
// And then define MyImGuiTLS in one of your cpp file. Note that thread_local is a C++11 keyword, earlier C++ uses compiler-specific keyword.
|
||||
// - Future development aim to make this context pointer explicit to all calls. Also read https://github.com/ocornut/imgui/issues/586
|
||||
// - If you need a finite number of contexts, you may compile and use multiple instances of the ImGui code from different namespace.
|
||||
// - ImGui::CreateContext() will automatically set this pointer if it is NULL.
|
||||
// Change to a different context by calling ImGui::SetCurrentContext().
|
||||
// - Important: Dear ImGui functions are not thread-safe because of this pointer.
|
||||
// If you want thread-safety to allow N threads to access N different contexts:
|
||||
// - Change this variable to use thread local storage so each thread can refer to a different context, in your imconfig.h:
|
||||
// struct ImGuiContext;
|
||||
// extern thread_local ImGuiContext* MyImGuiTLS;
|
||||
// #define GImGui MyImGuiTLS
|
||||
// And then define MyImGuiTLS in one of your cpp file. Note that thread_local is a C++11 keyword, earlier C++ uses compiler-specific keyword.
|
||||
// - Future development aim to make this context pointer explicit to all calls. Also read https://github.com/ocornut/imgui/issues/586
|
||||
// - If you need a finite number of contexts, you may compile and use multiple instances of the ImGui code from different namespace.
|
||||
// - DLL users: read comments above.
|
||||
#ifndef GImGui
|
||||
ImGuiContext* GImGui = NULL;
|
||||
#endif
|
||||
|
||||
// Memory Allocator functions. Use SetAllocatorFunctions() to change them.
|
||||
// If you use DLL hotreloading you might need to call SetAllocatorFunctions() after reloading code from this file.
|
||||
// Otherwise, you probably don't want to modify them mid-program, and if you use global/static e.g. ImVector<> instances you may need to keep them accessible during program destruction.
|
||||
// - You probably don't want to modify those mid-program, and if you use global/static e.g. ImVector<> instances you may need to keep them accessible during program destruction.
|
||||
// - DLL users: read comments above.
|
||||
#ifndef IMGUI_DISABLE_DEFAULT_ALLOCATORS
|
||||
static void* MallocWrapper(size_t size, void* user_data) { IM_UNUSED(user_data); return malloc(size); }
|
||||
static void FreeWrapper(void* ptr, void* user_data) { IM_UNUSED(user_data); free(ptr); }
|
||||
@ -963,10 +971,9 @@ static void FreeWrapper(void* ptr, void* user_data) { IM_UNUSED(user_d
|
||||
static void* MallocWrapper(size_t size, void* user_data) { IM_UNUSED(user_data); IM_UNUSED(size); IM_ASSERT(0); return NULL; }
|
||||
static void FreeWrapper(void* ptr, void* user_data) { IM_UNUSED(user_data); IM_UNUSED(ptr); IM_ASSERT(0); }
|
||||
#endif
|
||||
|
||||
static void* (*GImAllocatorAllocFunc)(size_t size, void* user_data) = MallocWrapper;
|
||||
static void (*GImAllocatorFreeFunc)(void* ptr, void* user_data) = FreeWrapper;
|
||||
static void* GImAllocatorUserData = NULL;
|
||||
static ImGuiMemAllocFunc* GImAllocatorAllocFunc = MallocWrapper;
|
||||
static ImGuiMemFreeFunc* GImAllocatorFreeFunc = FreeWrapper;
|
||||
static void* GImAllocatorUserData = NULL;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] USER FACING STRUCTURES (ImGuiStyle, ImGuiIO)
|
||||
@ -3381,13 +3388,21 @@ void ImGui::SetCurrentContext(ImGuiContext* ctx)
|
||||
#endif
|
||||
}
|
||||
|
||||
void ImGui::SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* user_data), void (*free_func)(void* ptr, void* user_data), void* user_data)
|
||||
void ImGui::SetAllocatorFunctions(ImGuiMemAllocFunc* alloc_func, ImGuiMemFreeFunc* free_func, void* user_data)
|
||||
{
|
||||
GImAllocatorAllocFunc = alloc_func;
|
||||
GImAllocatorFreeFunc = free_func;
|
||||
GImAllocatorUserData = user_data;
|
||||
}
|
||||
|
||||
// This is provided to facilitate copying allocators from one static/DLL boundary to another (e.g. retrieve default allocator of your executable address space)
|
||||
void ImGui::GetAllocatorFunctions(ImGuiMemAllocFunc** p_alloc_func, ImGuiMemFreeFunc** p_free_func, void** p_user_data)
|
||||
{
|
||||
*p_alloc_func = GImAllocatorAllocFunc;
|
||||
*p_free_func = GImAllocatorFreeFunc;
|
||||
*p_user_data = GImAllocatorUserData;
|
||||
}
|
||||
|
||||
ImGuiContext* ImGui::CreateContext(ImFontAtlas* shared_font_atlas)
|
||||
{
|
||||
ImGuiContext* ctx = IM_NEW(ImGuiContext)(shared_font_atlas);
|
||||
@ -6940,11 +6955,12 @@ void ImGui::FocusWindow(ImGuiWindow* window)
|
||||
g.NavWindow = window;
|
||||
if (window && g.NavDisableMouseHover)
|
||||
g.NavMousePosDirty = true;
|
||||
g.NavInitRequest = false;
|
||||
g.NavId = window ? window->NavLastIds[0] : 0; // Restore NavId
|
||||
g.NavFocusScopeId = 0;
|
||||
g.NavIdIsAlive = false;
|
||||
g.NavLayer = ImGuiNavLayer_Main;
|
||||
g.NavInitRequest = g.NavMoveRequest = false;
|
||||
NavUpdateAnyRequestFlag();
|
||||
//IMGUI_DEBUG_LOG("FocusWindow(\"%s\")\n", window ? window->Name : NULL);
|
||||
}
|
||||
|
||||
@ -10618,14 +10634,8 @@ void ImGui::EndDragDropTarget()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Pass text data straight to log (without being displayed)
|
||||
void ImGui::LogText(const char* fmt, ...)
|
||||
static inline void LogTextV(ImGuiContext& g, const char* fmt, va_list args)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (!g.LogEnabled)
|
||||
return;
|
||||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
if (g.LogFile)
|
||||
{
|
||||
g.LogBuffer.Buf.resize(0);
|
||||
@ -10636,9 +10646,29 @@ void ImGui::LogText(const char* fmt, ...)
|
||||
{
|
||||
g.LogBuffer.appendfv(fmt, args);
|
||||
}
|
||||
}
|
||||
|
||||
void ImGui::LogText(const char* fmt, ...)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (!g.LogEnabled)
|
||||
return;
|
||||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
LogTextV(g, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void ImGui::LogTextV(const char* fmt, va_list args)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (!g.LogEnabled)
|
||||
return;
|
||||
|
||||
LogTextV(g, fmt, args);
|
||||
}
|
||||
|
||||
// Internal version that takes a position to decide on newline placement and pad items according to their depth.
|
||||
// We split text into individual lines to add current tree level padding
|
||||
// FIXME: This code is a little complicated perhaps, considering simplifying the whole system.
|
||||
|
31
imgui.h
31
imgui.h
@ -15,6 +15,7 @@
|
||||
// - Glossary https://github.com/ocornut/imgui/wiki/Glossary
|
||||
// - Wiki https://github.com/ocornut/imgui/wiki
|
||||
// - Issues & support https://github.com/ocornut/imgui/issues
|
||||
// - Discussions https://github.com/ocornut/imgui/discussions
|
||||
|
||||
/*
|
||||
|
||||
@ -200,6 +201,8 @@ typedef void* ImTextureID; // User data for rendering backend to identi
|
||||
typedef unsigned int ImGuiID; // A unique ID used by widgets, typically hashed from a stack of string.
|
||||
typedef int (*ImGuiInputTextCallback)(ImGuiInputTextCallbackData* data); // Callback function for ImGui::InputText()
|
||||
typedef void (*ImGuiSizeCallback)(ImGuiSizeCallbackData* data); // Callback function for ImGui::SetNextWindowSizeConstraints()
|
||||
typedef void* (ImGuiMemAllocFunc)(size_t sz, void* user_data); // Function signature for ImGui::SetAllocatorFunctions()
|
||||
typedef void (ImGuiMemFreeFunc)(void* ptr, void* user_data); // Function signature for ImGui::SetAllocatorFunctions()
|
||||
|
||||
// Character types
|
||||
// (we generally use UTF-8 encoded string in the API. This is storage specifically for a decoded character used for keyboard input and display)
|
||||
@ -262,8 +265,9 @@ struct ImVec4
|
||||
namespace ImGui
|
||||
{
|
||||
// Context creation and access
|
||||
// Each context create its own ImFontAtlas by default. You may instance one yourself and pass it to CreateContext() to share a font atlas between imgui contexts.
|
||||
// None of those functions is reliant on the current context.
|
||||
// - Each context create its own ImFontAtlas by default. You may instance one yourself and pass it to CreateContext() to share a font atlas between contexts.
|
||||
// - DLL users: heaps and globals are not shared across DLL boundaries! You will need to call SetCurrentContext() + SetAllocatorFunctions()
|
||||
// for each static/DLL boundary you are calling from. Read "Context and Memory Allocators" section of imgui.cpp for details.
|
||||
IMGUI_API ImGuiContext* CreateContext(ImFontAtlas* shared_font_atlas = NULL);
|
||||
IMGUI_API void DestroyContext(ImGuiContext* ctx = NULL); // NULL = destroy current context
|
||||
IMGUI_API ImGuiContext* GetCurrentContext();
|
||||
@ -774,6 +778,7 @@ namespace ImGui
|
||||
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 LogText(const char* fmt, ...) IM_FMTARGS(1); // pass text data straight to log (without being displayed)
|
||||
IMGUI_API void LogTextV(const char* fmt, va_list args) IM_FMTLIST(1);
|
||||
|
||||
// Drag and Drop
|
||||
// - If you stop calling BeginDragDropSource() the payload is preserved however it won't have a preview tooltip (we currently display a fallback "..." tooltip as replacement)
|
||||
@ -895,9 +900,11 @@ namespace ImGui
|
||||
IMGUI_API bool DebugCheckVersionAndDataLayout(const char* version_str, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_drawvert, size_t sz_drawidx); // This is called by IMGUI_CHECKVERSION() macro.
|
||||
|
||||
// Memory Allocators
|
||||
// - All those functions are not reliant on the current context.
|
||||
// - If you reload the contents of imgui.cpp at runtime, you may need to call SetCurrentContext() + SetAllocatorFunctions() again because we use global storage for those.
|
||||
IMGUI_API void SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* user_data), void (*free_func)(void* ptr, void* user_data), void* user_data = NULL);
|
||||
// - Those functions are not reliant on the current context.
|
||||
// - DLL users: heaps and globals are not shared across DLL boundaries! You will need to call SetCurrentContext() + SetAllocatorFunctions()
|
||||
// for each static/DLL boundary you are calling from. Read "Context and Memory Allocators" section of imgui.cpp for more details.
|
||||
IMGUI_API void SetAllocatorFunctions(ImGuiMemAllocFunc* alloc_func, ImGuiMemFreeFunc* free_func, void* user_data = NULL);
|
||||
IMGUI_API void GetAllocatorFunctions(ImGuiMemAllocFunc** p_alloc_func, ImGuiMemFreeFunc** p_free_func, void** p_user_data);
|
||||
IMGUI_API void* MemAlloc(size_t size);
|
||||
IMGUI_API void MemFree(void* ptr);
|
||||
|
||||
@ -2735,11 +2742,12 @@ struct ImFontAtlas
|
||||
//-------------------------------------------
|
||||
|
||||
// You can request arbitrary rectangles to be packed into the atlas, for your own purposes.
|
||||
// After calling Build(), you can query the rectangle position and render your pixels.
|
||||
// You can also request your rectangles to be mapped as font glyph (given a font + Unicode point),
|
||||
// so you can render e.g. custom colorful icons and use them as regular glyphs.
|
||||
// Read docs/FONTS.md for more details about using colorful icons.
|
||||
// Note: this API may be redesigned later in order to support multi-monitor varying DPI settings.
|
||||
// - After calling Build(), you can query the rectangle position and render your pixels.
|
||||
// - If you render colored output, set 'atlas->TexPixelsUseColors = true' as this may help some backends decide of prefered texture format.
|
||||
// - You can also request your rectangles to be mapped as font glyph (given a font + Unicode point),
|
||||
// so you can render e.g. custom colorful icons and use them as regular glyphs.
|
||||
// - Read docs/FONTS.md for more details about using colorful icons.
|
||||
// - Note: this API may be redesigned later in order to support multi-monitor varying DPI settings.
|
||||
IMGUI_API int AddCustomRectRegular(int width, int height);
|
||||
IMGUI_API int AddCustomRectFontGlyph(ImFont* font, ImWchar id, int width, int height, float advance_x, const ImVec2& offset = ImVec2(0, 0));
|
||||
ImFontAtlasCustomRect* GetCustomRectByIndex(int index) { IM_ASSERT(index >= 0); return &CustomRects[index]; }
|
||||
@ -2752,14 +2760,15 @@ struct ImFontAtlas
|
||||
// Members
|
||||
//-------------------------------------------
|
||||
|
||||
bool Locked; // Marked as Locked by ImGui::NewFrame() so attempt to modify the atlas will assert.
|
||||
ImFontAtlasFlags Flags; // Build flags (see ImFontAtlasFlags_)
|
||||
ImTextureID TexID; // User data to refer to the texture once it has been uploaded to user's graphic systems. It is passed back to you during rendering via the ImDrawCmd structure.
|
||||
int TexDesiredWidth; // Texture width desired by user before Build(). Must be a power-of-two. If have many glyphs your graphics API have texture size restrictions you may want to increase texture width to decrease height.
|
||||
int TexGlyphPadding; // Padding between glyphs within texture in pixels. Defaults to 1. If your rendering method doesn't rely on bilinear filtering you may set this to 0.
|
||||
bool Locked; // Marked as Locked by ImGui::NewFrame() so attempt to modify the atlas will assert.
|
||||
|
||||
// [Internal]
|
||||
// NB: Access texture data via GetTexData*() calls! Which will setup a default font for you.
|
||||
bool TexPixelsUseColors; // Tell whether our texture data is known to use colors (rather than just alpha channel), in order to help backend select a format.
|
||||
unsigned char* TexPixelsAlpha8; // 1 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight
|
||||
unsigned int* TexPixelsRGBA32; // 4 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight * 4
|
||||
int TexWidth; // Texture width calculated during Build().
|
||||
|
@ -967,7 +967,7 @@ static void ShowDemoWindowWidgets()
|
||||
// so you can safely copy & paste garbled characters into another application.
|
||||
ImGui::TextWrapped(
|
||||
"CJK text will only appears if the font was loaded with the appropriate CJK character ranges. "
|
||||
"Call io.Font->AddFontFromFileTTF() manually to load extra character ranges. "
|
||||
"Call io.Fonts->AddFontFromFileTTF() manually to load extra character ranges. "
|
||||
"Read docs/FONTS.md for details.");
|
||||
ImGui::Text("Hiragana: \xe3\x81\x8b\xe3\x81\x8d\xe3\x81\x8f\xe3\x81\x91\xe3\x81\x93 (kakikukeko)"); // Normally we would use u8"blah blah" with the proper characters directly in the string.
|
||||
ImGui::Text("Kanjis: \xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e (nihongo)");
|
||||
|
@ -1830,6 +1830,7 @@ void ImFontAtlas::ClearTexData()
|
||||
IM_FREE(TexPixelsRGBA32);
|
||||
TexPixelsAlpha8 = NULL;
|
||||
TexPixelsRGBA32 = NULL;
|
||||
TexPixelsUseColors = false;
|
||||
}
|
||||
|
||||
void ImFontAtlas::ClearFonts()
|
||||
|
@ -460,6 +460,7 @@ struct IMGUI_API ImRect
|
||||
ImVec2 GetSize() const { return ImVec2(Max.x - Min.x, Max.y - Min.y); }
|
||||
float GetWidth() const { return Max.x - Min.x; }
|
||||
float GetHeight() const { return Max.y - Min.y; }
|
||||
float GetArea() const { return (Max.x - Min.x) * (Max.y - Min.y); }
|
||||
ImVec2 GetTL() const { return Min; } // Top-left
|
||||
ImVec2 GetTR() const { return ImVec2(Max.x, Min.y); } // Top-right
|
||||
ImVec2 GetBL() const { return ImVec2(Min.x, Max.y); } // Bottom-left
|
||||
@ -2112,7 +2113,7 @@ struct IMGUI_API ImGuiTabBar
|
||||
ImGuiTabBarFlags Flags;
|
||||
ImGuiID ID; // Zero for tab-bars used by docking
|
||||
ImGuiID SelectedTabId; // Selected tab/window
|
||||
ImGuiID NextSelectedTabId;
|
||||
ImGuiID NextSelectedTabId; // Next selected tab/window. Will also trigger a scrolling animation
|
||||
ImGuiID VisibleTabId; // Can occasionally be != SelectedTabId (e.g. when previewing contents for CTRL+TAB preview)
|
||||
int CurrFrameVisible;
|
||||
int PrevFrameVisible;
|
||||
@ -2829,11 +2830,11 @@ IMGUI_API void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||
extern void ImGuiTestEngineHook_ItemAdd(ImGuiContext* ctx, const ImRect& bb, ImGuiID id);
|
||||
extern void ImGuiTestEngineHook_ItemInfo(ImGuiContext* ctx, ImGuiID id, const char* label, ImGuiItemStatusFlags flags);
|
||||
extern void ImGuiTestEngineHook_IdInfo(ImGuiContext* ctx, ImGuiDataType data_type, ImGuiID id, const void* data_id);
|
||||
extern void ImGuiTestEngineHook_IdInfo(ImGuiContext* ctx, ImGuiDataType data_type, ImGuiID id, const void* data_id, const void* data_id_end);
|
||||
extern void ImGuiTestEngineHook_Log(ImGuiContext* ctx, const char* fmt, ...);
|
||||
extern void ImGuiTestEngineHook_ItemAdd(ImGuiContext* ctx, const ImRect& bb, ImGuiID id);
|
||||
extern void ImGuiTestEngineHook_ItemInfo(ImGuiContext* ctx, ImGuiID id, const char* label, ImGuiItemStatusFlags flags);
|
||||
extern void ImGuiTestEngineHook_IdInfo(ImGuiContext* ctx, ImGuiDataType data_type, ImGuiID id, const void* data_id);
|
||||
extern void ImGuiTestEngineHook_IdInfo(ImGuiContext* ctx, ImGuiDataType data_type, ImGuiID id, const void* data_id, const void* data_id_end);
|
||||
extern void ImGuiTestEngineHook_Log(ImGuiContext* ctx, const char* fmt, ...);
|
||||
#define IMGUI_TEST_ENGINE_ITEM_ADD(_BB,_ID) if (g.TestEngineHookItems) ImGuiTestEngineHook_ItemAdd(&g, _BB, _ID) // Register item bounding box
|
||||
#define IMGUI_TEST_ENGINE_ITEM_INFO(_ID,_LABEL,_FLAGS) if (g.TestEngineHookItems) ImGuiTestEngineHook_ItemInfo(&g, _ID, _LABEL, _FLAGS) // Register item label and status flags (optional)
|
||||
#define IMGUI_TEST_ENGINE_LOG(_FMT,...) if (g.TestEngineHookItems) ImGuiTestEngineHook_Log(&g, _FMT, __VA_ARGS__) // Custom log entry from user land into test log
|
||||
|
@ -782,22 +782,30 @@ bool ImGui::ArrowButton(const char* str_id, ImGuiDir dir)
|
||||
}
|
||||
|
||||
// Button to close a window
|
||||
bool ImGui::CloseButton(ImGuiID id, const ImVec2& pos)//, float size)
|
||||
bool ImGui::CloseButton(ImGuiID id, const ImVec2& pos)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
|
||||
// We intentionally allow interaction when clipped so that a mechanical Alt,Right,Validate sequence close a window.
|
||||
// (this isn't the regular behavior of buttons, but it doesn't affect the user much because navigation tends to keep items visible).
|
||||
// Tweak 1: Shrink hit-testing area if button covers an abnormally large proportion of the visible region. That's in order to facilitate moving the window away. (#3825)
|
||||
// This may better be applied as a general hit-rect reduction mechanism for all widgets to ensure the area to move window is always accessible?
|
||||
const ImRect bb(pos, pos + ImVec2(g.FontSize, g.FontSize) + g.Style.FramePadding * 2.0f);
|
||||
bool is_clipped = !ItemAdd(bb, id);
|
||||
ImRect bb_interact = bb;
|
||||
const float area_to_visible_ratio = window->OuterRectClipped.GetArea() / bb.GetArea();
|
||||
if (area_to_visible_ratio < 1.5f)
|
||||
bb_interact.Expand(ImFloor(bb_interact.GetSize() * -0.25f));
|
||||
|
||||
// Tweak 2: We intentionally allow interaction when clipped so that a mechanical Alt,Right,Activate sequence can always close a window.
|
||||
// (this isn't the regular behavior of buttons, but it doesn't affect the user much because navigation tends to keep items visible).
|
||||
bool is_clipped = !ItemAdd(bb_interact, id);
|
||||
|
||||
bool hovered, held;
|
||||
bool pressed = ButtonBehavior(bb, id, &hovered, &held);
|
||||
bool pressed = ButtonBehavior(bb_interact, id, &hovered, &held);
|
||||
if (is_clipped)
|
||||
return pressed;
|
||||
|
||||
// Render
|
||||
// FIXME: Clarify this mess
|
||||
ImU32 col = GetColorU32(held ? ImGuiCol_ButtonActive : ImGuiCol_ButtonHovered);
|
||||
ImVec2 center = bb.GetCenter();
|
||||
if (hovered)
|
||||
@ -3293,7 +3301,7 @@ bool ImGui::TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImG
|
||||
DataTypeApplyOpFromText(data_buf, g.InputTextState.InitialTextA.Data, data_type, p_data, NULL);
|
||||
if (p_clamp_min || p_clamp_max)
|
||||
{
|
||||
if (DataTypeCompare(data_type, p_clamp_min, p_clamp_max) > 0)
|
||||
if (p_clamp_min && p_clamp_max && DataTypeCompare(data_type, p_clamp_min, p_clamp_max) > 0)
|
||||
ImSwap(p_clamp_min, p_clamp_max);
|
||||
DataTypeClamp(data_type, p_data, p_clamp_min, p_clamp_max);
|
||||
}
|
||||
@ -6910,7 +6918,7 @@ namespace ImGui
|
||||
static ImU32 TabBarCalcTabID(ImGuiTabBar* tab_bar, const char* label, ImGuiWindow* docked_window);
|
||||
static float TabBarCalcMaxTabWidth();
|
||||
static float TabBarScrollClamp(ImGuiTabBar* tab_bar, float scrolling);
|
||||
static void TabBarScrollToTab(ImGuiTabBar* tab_bar, ImGuiTabItem* tab, ImGuiTabBarSection* sections);
|
||||
static void TabBarScrollToTab(ImGuiTabBar* tab_bar, ImGuiID tab_id, ImGuiTabBarSection* sections);
|
||||
static ImGuiTabItem* TabBarScrollingButtons(ImGuiTabBar* tab_bar);
|
||||
static ImGuiTabItem* TabBarTabListPopupButton(ImGuiTabBar* tab_bar);
|
||||
}
|
||||
@ -7128,12 +7136,12 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
|
||||
sections[1].Spacing = sections[1].TabCount > 0 && sections[2].TabCount > 0 ? g.Style.ItemInnerSpacing.x : 0.0f;
|
||||
|
||||
// Setup next selected tab
|
||||
ImGuiID scroll_track_selected_tab_id = 0;
|
||||
ImGuiID scroll_to_tab_id = 0;
|
||||
if (tab_bar->NextSelectedTabId)
|
||||
{
|
||||
tab_bar->SelectedTabId = tab_bar->NextSelectedTabId;
|
||||
tab_bar->NextSelectedTabId = 0;
|
||||
scroll_track_selected_tab_id = tab_bar->SelectedTabId;
|
||||
scroll_to_tab_id = tab_bar->SelectedTabId;
|
||||
}
|
||||
|
||||
// Process order change request (we could probably process it when requested but it's just saner to do it in a single spot).
|
||||
@ -7141,7 +7149,7 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
|
||||
{
|
||||
if (TabBarProcessReorder(tab_bar))
|
||||
if (tab_bar->ReorderRequestTabId == tab_bar->SelectedTabId)
|
||||
scroll_track_selected_tab_id = tab_bar->ReorderRequestTabId;
|
||||
scroll_to_tab_id = tab_bar->ReorderRequestTabId;
|
||||
tab_bar->ReorderRequestTabId = 0;
|
||||
}
|
||||
|
||||
@ -7149,7 +7157,7 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
|
||||
const bool tab_list_popup_button = (tab_bar->Flags & ImGuiTabBarFlags_TabListPopupButton) != 0;
|
||||
if (tab_list_popup_button)
|
||||
if (ImGuiTabItem* tab_to_select = TabBarTabListPopupButton(tab_bar)) // NB: Will alter BarRect.Min.x!
|
||||
scroll_track_selected_tab_id = tab_bar->SelectedTabId = tab_to_select->ID;
|
||||
scroll_to_tab_id = tab_bar->SelectedTabId = tab_to_select->ID;
|
||||
|
||||
// Leading/Trailing tabs will be shrink only if central one aren't visible anymore, so layout the shrink data as: leading, trailing, central
|
||||
// (whereas our tabs are stored as: leading, central, trailing)
|
||||
@ -7169,8 +7177,8 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
|
||||
most_recently_selected_tab = tab;
|
||||
if (tab->ID == tab_bar->SelectedTabId)
|
||||
found_selected_tab_id = true;
|
||||
if (scroll_track_selected_tab_id == 0 && g.NavJustMovedToId == tab->ID)
|
||||
scroll_track_selected_tab_id = tab->ID;
|
||||
if (scroll_to_tab_id == 0 && g.NavJustMovedToId == tab->ID)
|
||||
scroll_to_tab_id = tab->ID;
|
||||
|
||||
// Refresh tab width immediately, otherwise changes of style e.g. style.FramePadding.x would noticeably lag in the tab bar.
|
||||
// Additionally, when using TabBarAddTab() to manipulate tab bar order we occasionally insert new tabs that don't have a width yet,
|
||||
@ -7201,11 +7209,11 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
|
||||
// Horizontal scrolling buttons
|
||||
// (note that TabBarScrollButtons() will alter BarRect.Max.x)
|
||||
if ((tab_bar->WidthAllTabsIdeal > tab_bar->BarRect.GetWidth() && tab_bar->Tabs.Size > 1) && !(tab_bar->Flags & ImGuiTabBarFlags_NoTabListScrollingButtons) && (tab_bar->Flags & ImGuiTabBarFlags_FittingPolicyScroll))
|
||||
if (ImGuiTabItem* scroll_track_selected_tab = TabBarScrollingButtons(tab_bar))
|
||||
if (ImGuiTabItem* scroll_and_select_tab = TabBarScrollingButtons(tab_bar))
|
||||
{
|
||||
scroll_track_selected_tab_id = scroll_track_selected_tab->ID;
|
||||
if (!(scroll_track_selected_tab->Flags & ImGuiTabItemFlags_Button))
|
||||
tab_bar->SelectedTabId = scroll_track_selected_tab_id;
|
||||
scroll_to_tab_id = scroll_and_select_tab->ID;
|
||||
if ((scroll_and_select_tab->Flags & ImGuiTabItemFlags_Button) == 0)
|
||||
tab_bar->SelectedTabId = scroll_to_tab_id;
|
||||
}
|
||||
|
||||
// Shrink widths if full tabs don't fit in their allocated space
|
||||
@ -7269,7 +7277,7 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
|
||||
if (found_selected_tab_id == false)
|
||||
tab_bar->SelectedTabId = 0;
|
||||
if (tab_bar->SelectedTabId == 0 && tab_bar->NextSelectedTabId == 0 && most_recently_selected_tab != NULL)
|
||||
scroll_track_selected_tab_id = tab_bar->SelectedTabId = most_recently_selected_tab->ID;
|
||||
scroll_to_tab_id = tab_bar->SelectedTabId = most_recently_selected_tab->ID;
|
||||
|
||||
// Lock in visible tab
|
||||
tab_bar->VisibleTabId = tab_bar->SelectedTabId;
|
||||
@ -7277,12 +7285,11 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
|
||||
|
||||
// CTRL+TAB can override visible tab temporarily
|
||||
if (g.NavWindowingTarget != NULL && g.NavWindowingTarget->DockNode && g.NavWindowingTarget->DockNode->TabBar == tab_bar)
|
||||
tab_bar->VisibleTabId = scroll_track_selected_tab_id = g.NavWindowingTarget->ID;
|
||||
tab_bar->VisibleTabId = scroll_to_tab_id = g.NavWindowingTarget->ID;
|
||||
|
||||
// Update scrolling
|
||||
if (scroll_track_selected_tab_id)
|
||||
if (ImGuiTabItem* scroll_track_selected_tab = TabBarFindTabByID(tab_bar, scroll_track_selected_tab_id))
|
||||
TabBarScrollToTab(tab_bar, scroll_track_selected_tab, sections);
|
||||
if (scroll_to_tab_id != 0)
|
||||
TabBarScrollToTab(tab_bar, scroll_to_tab_id, sections);
|
||||
tab_bar->ScrollingAnim = TabBarScrollClamp(tab_bar, tab_bar->ScrollingAnim);
|
||||
tab_bar->ScrollingTarget = TabBarScrollClamp(tab_bar, tab_bar->ScrollingTarget);
|
||||
if (tab_bar->ScrollingAnim != tab_bar->ScrollingTarget)
|
||||
@ -7412,8 +7419,12 @@ static float ImGui::TabBarScrollClamp(ImGuiTabBar* tab_bar, float scrolling)
|
||||
return ImMax(scrolling, 0.0f);
|
||||
}
|
||||
|
||||
static void ImGui::TabBarScrollToTab(ImGuiTabBar* tab_bar, ImGuiTabItem* tab, ImGuiTabBarSection* sections)
|
||||
// Note: we may scroll to tab that are not selected! e.g. using keyboard arrow keys
|
||||
static void ImGui::TabBarScrollToTab(ImGuiTabBar* tab_bar, ImGuiID tab_id, ImGuiTabBarSection* sections)
|
||||
{
|
||||
ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, tab_id);
|
||||
if (tab == NULL)
|
||||
return;
|
||||
if (tab->Flags & (ImGuiTabItemFlags_Leading | ImGuiTabItemFlags_Trailing))
|
||||
return;
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2021/03/02: set 'atlas->TexPixelsUseColors = true' to help some backends with deciding of a prefered texture format.
|
||||
// 2021/01/28: added support for color-layered glyphs via ImGuiFreeTypeBuilderFlags_LoadColor (require Freetype 2.10+).
|
||||
// 2021/01/26: simplified integration by using '#define IMGUI_ENABLE_FREETYPE'.
|
||||
// renamed ImGuiFreeType::XXX flags to ImGuiFreeTypeBuilderFlags_XXX for consistency with other API. removed ImGuiFreeType::BuildFontAtlas().
|
||||
@ -105,7 +106,7 @@ namespace
|
||||
FT_Int OffsetX; // The distance from the origin ("pen position") to the left of the glyph.
|
||||
FT_Int OffsetY; // The distance from the origin to the top of the glyph. This is usually a value < 0.
|
||||
float AdvanceX; // The distance from the origin to the origin of the next glyph. This is usually a value > 0.
|
||||
bool IsColored;
|
||||
bool IsColored; // The glyph is colored
|
||||
};
|
||||
|
||||
// Font parameters and metrics.
|
||||
@ -605,6 +606,7 @@ bool ImFontAtlasBuildWithFreeTypeEx(FT_Library ft_library, ImFontAtlas* atlas, u
|
||||
|
||||
// 8. Copy rasterized font characters back into the main texture
|
||||
// 9. Setup ImFont and glyphs for runtime
|
||||
bool tex_use_colors = false;
|
||||
for (int src_i = 0; src_i < src_tmp_array.Size; src_i++)
|
||||
{
|
||||
ImFontBuildSrcDataFT& src_tmp = src_tmp_array[src_i];
|
||||
@ -668,13 +670,15 @@ bool ImFontAtlasBuildWithFreeTypeEx(FT_Library ft_library, ImFontAtlas* atlas, u
|
||||
float v1 = (ty + info.Height) / (float)atlas->TexHeight;
|
||||
dst_font->AddGlyph(&cfg, (ImWchar)src_glyph.Codepoint, x0, y0, x1, y1, u0, v0, u1, v1, info.AdvanceX);
|
||||
|
||||
IM_ASSERT(dst_font->Glyphs.back().Codepoint == src_glyph.Codepoint);
|
||||
ImFontGlyph* dst_glyph = &dst_font->Glyphs.back();
|
||||
IM_ASSERT(dst_glyph->Codepoint == src_glyph.Codepoint);
|
||||
if (src_glyph.Info.IsColored)
|
||||
dst_font->Glyphs.back().Colored = true;
|
||||
dst_glyph->Colored = tex_use_colors = true;
|
||||
}
|
||||
|
||||
src_tmp.Rects = NULL;
|
||||
}
|
||||
atlas->TexPixelsUseColors = tex_use_colors;
|
||||
|
||||
// Cleanup
|
||||
for (int buf_i = 0; buf_i < buf_bitmap_buffers.Size; buf_i++)
|
||||
|
Loading…
Reference in New Issue
Block a user