mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-21 15:16:35 +00:00
Merge branch 'master' into docking
# Conflicts: # examples/imgui_impl_dx12.cpp # imgui.cpp # imgui.h # imgui_widgets.cpp
This commit is contained in:
commit
0cbb96895a
108
.github/workflows/build.yml
vendored
Normal file
108
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,108 @@
|
||||
name: build
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
Windows:
|
||||
runs-on: windows-2019
|
||||
env:
|
||||
MSBUILD_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Fix Projects
|
||||
shell: powershell
|
||||
run: |
|
||||
# Replace v110 toolset with v142. Only v141 and v142 toolsets are available on CI workers.
|
||||
# Replace 8.1 platform sdk with 10.0.18362.0. Workers do not contain legacy SDKs.
|
||||
# WARNING: This will need updating if toolset/sdk change in project files!
|
||||
gci -recurse -filter "*.vcxproj" | ForEach-Object {
|
||||
(Get-Content $_.FullName) -Replace "<PlatformToolset>v110</PlatformToolset>","<PlatformToolset>v142</PlatformToolset>" -Replace "<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>","<WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion>" | Set-Content -Path $_.FullName
|
||||
}
|
||||
|
||||
- name: Build x86
|
||||
shell: cmd
|
||||
run: |
|
||||
"%MSBUILD_PATH%\MSBuild.exe" /p:Platform=Win32 /p:Configuration=Release examples/imgui_examples.sln
|
||||
|
||||
- name: Build x64
|
||||
shell: cmd
|
||||
run: |
|
||||
"%MSBUILD_PATH%\MSBuild.exe" /p:Platform=x64 /p:Configuration=Release examples/imgui_examples.sln
|
||||
|
||||
Linux:
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libglfw3-dev libsdl2-dev
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
make -C examples/example_null
|
||||
make -C examples/example_glfw_opengl2
|
||||
make -C examples/example_glfw_opengl3
|
||||
make -C examples/example_sdl_opengl2
|
||||
make -C examples/example_sdl_opengl3
|
||||
|
||||
MacOS:
|
||||
runs-on: macOS-10.14
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
brew install glfw3
|
||||
brew install sdl2
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
make -C examples/example_null
|
||||
make -C examples/example_glfw_opengl2
|
||||
make -C examples/example_glfw_opengl3
|
||||
make -C examples/example_glfw_metal
|
||||
make -C examples/example_sdl_opengl2
|
||||
make -C examples/example_sdl_opengl3
|
||||
xcodebuild -project examples/example_apple_metal/example_apple_metal.xcodeproj -target example_apple_metal_macos
|
||||
xcodebuild -project examples/example_apple_opengl2/example_apple_opengl2.xcodeproj -target example_osx_opengl2
|
||||
|
||||
iOS:
|
||||
runs-on: macOS-10.14
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
# Code signing is required, but we disable it because it is irrelevant for CI builds.
|
||||
xcodebuild -project examples/example_apple_metal/example_apple_metal.xcodeproj -target example_apple_metal_ios CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO
|
||||
|
||||
Emscripten:
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
wget -q https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz
|
||||
tar -xvf emsdk-portable.tar.gz
|
||||
emsdk-portable/emsdk update
|
||||
emsdk-portable/emsdk install latest
|
||||
emsdk-portable/emsdk activate latest
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
source emsdk-portable/emsdk_env.sh
|
||||
make -C examples/example_emscripten
|
34
.travis.yml
34
.travis.yml
@ -1,34 +0,0 @@
|
||||
language: cpp
|
||||
sudo: required
|
||||
dist: trusty
|
||||
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
compiler:
|
||||
- gcc
|
||||
- clang
|
||||
|
||||
before_install:
|
||||
- if [ $TRAVIS_OS_NAME == linux ]; then
|
||||
sudo apt-get update -qq;
|
||||
sudo apt-get install -y --no-install-recommends libxrandr-dev libxi-dev libxxf86vm-dev libsdl2-dev;
|
||||
wget https://github.com/glfw/glfw/releases/download/3.2.1/glfw-3.2.1.zip;
|
||||
unzip glfw-3.2.1.zip && cd glfw-3.2.1;
|
||||
cmake -DBUILD_SHARED_LIBS=true -DGLFW_BUILD_EXAMPLES=false -DGLFW_BUILD_TESTS=false -DGLFW_BUILD_DOCS=false .;
|
||||
sudo make -j $CPU_NUM install && cd ..;
|
||||
fi
|
||||
- if [ $TRAVIS_OS_NAME == osx ]; then
|
||||
brew update;
|
||||
brew install glfw3;
|
||||
brew install sdl2;
|
||||
fi
|
||||
|
||||
script:
|
||||
- make -C examples/example_glfw_opengl2
|
||||
- make -C examples/example_glfw_opengl3
|
||||
- make -C examples/example_sdl_opengl3
|
||||
- if [ $TRAVIS_OS_NAME == osx ]; then
|
||||
xcodebuild -project examples/example_apple_metal/example_apple_metal.xcodeproj -target example_apple_metal_macos;
|
||||
fi
|
@ -103,6 +103,14 @@ Other changes:
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
Breaking Changes:
|
||||
- Removed redirecting functions/enums names that were marked obsolete in 1.52 (October 2017):
|
||||
- Begin() [old 5 args version] -> use Begin() [3 args], use SetNextWindowSize() SetNextWindowBgAlpha() if needed
|
||||
- IsRootWindowOrAnyChildHovered() -> use IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows)
|
||||
- AlignFirstTextHeightToWidgets() -> use AlignTextToFramePadding()
|
||||
- SetNextWindowPosCenter() -> use SetNextWindowPos() with a pivot of (0.5f, 0.5f)
|
||||
- ImFont::Glyph -> use ImFontGlyph
|
||||
If you were still using the old names, read "API Breaking Changes" section of imgui.cpp to find out
|
||||
the new names or equivalent features, or see how they were implemented until 1.73.
|
||||
- Inputs: Fixed a miscalculation in the keyboard/mouse "typematic" repeat delay/rate calculation, used
|
||||
by keys and e.g. repeating mouse buttons as well as the GetKeyPressedAmount() function.
|
||||
If you were using a non-default value for io.KeyRepeatRate (previous default was 0.250), you can
|
||||
@ -111,10 +119,20 @@ Breaking Changes:
|
||||
Effectively it made io.KeyRepeatRate behave like it was set to (io.KeyRepeatRate + io.KeyRepeatDelay).
|
||||
Fixed the code and altered default io.KeyRepeatRate,Delay from 0.250,0.050 to 0.300,0.050 to compensate.
|
||||
If you never altered io.KeyRepeatRate nor used GetKeyPressedAmount() this won't affect you.
|
||||
- Backends: DX12: Added extra ID3D12DescriptorHeap parameter to ImGui_ImplDX12_Init() function.
|
||||
The value is unused in master branch but will be used by the multi-viewport feature. (#2851) [@obfuscate]
|
||||
|
||||
Other Changes:
|
||||
- InputText, Nav: Fixed Home/End key broken when activating Keyboard Navigation. (#787)
|
||||
- InputText: Filter out ASCII 127 (DEL) emitted by low-level OSX layer, as we are using the Key value. (#2578)
|
||||
- Layout: Fixed a couple of subtle bounding box vertical positioning issues relating to the handling of text
|
||||
baseline alignment. The issue would generally manifest when laying out multiple items on a same line,
|
||||
with varying heights and text baseline offsets.
|
||||
Some specific examples, e.g. a button with regular frame padding followed by another item with a
|
||||
multi-line label and no frame padding, such as: multi-line text, small button, tree node item, etc.
|
||||
The second item was correctly offset to match text baseline, and would interact/display correctly,
|
||||
but it wouldn't push the contents area boundary low enough.
|
||||
- ColorPicker: Fixed SV triangle gradient to block (broken in 1.73). (#2864, #2711). [@lewa-j]
|
||||
- TreeNode: Fixed combination of ImGuiTreeNodeFlags_SpanFullWidth and ImGuiTreeNodeFlags_OpenOnArrow
|
||||
incorrectly locating the arrow hit position to the left of the frame. (#2451, #2438, #1897)
|
||||
- DragScalar, SliderScalar, InputScalar: Added p_ prefix to parameter that are pointers to the data
|
||||
@ -122,8 +140,12 @@ Other Changes:
|
||||
- Docs: Improved and moved FAQ to docs/FAQ.md so it can be readable on the web. [@ButternCream, @ocornut]
|
||||
- Docs: Added permanent redirect from https://www.dearimgui.org/faq to FAQ page.
|
||||
- Demo: Added simple item reordering demo in Widgets -> Drag and Drop section. (#2823, #143) [@rokups]
|
||||
- Examples: DX12: Using IDXGIDebug1::ReportLiveObjects() when DX12_ENABLE_DEBUG_LAYER is enabled.
|
||||
- Examples: Emscripten: Removed NO_FILESYSTEM from Makefile, seems to fail on some setup. (#2734) [@Funto]
|
||||
- Backends: OSX: Fix using Backspace key. (#2578, #2817, #2818) [@DiligentGraphics]
|
||||
- Backends: GLFW: Previously installed user callbacks are now restored on shutdown. (#2836) [@malte-v]
|
||||
- CI: Set up a bunch of continuous-integration tests using GitHub Actions. We now compile many of the example
|
||||
applications on Windows, Linux, MacOS, iOS, Emscripten. Removed Travis integration. (#2865) [@rokups]
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
|
@ -1,6 +1,6 @@
|
||||
dear imgui
|
||||
=====
|
||||
[![Build Status](https://api.travis-ci.com/ocornut/imgui.svg?branch=master)](https://travis-ci.com/ocornut/imgui)
|
||||
[![Build Status](https://github.com/ocornut/imgui/workflows/build/badge.svg)](https://github.com/ocornut/imgui/actions?workflow=build)
|
||||
[![Coverity Status](https://scan.coverity.com/projects/4720/badge.svg)](https://scan.coverity.com/projects/4720)
|
||||
|
||||
<sub>(This library is available under a free and permissive license, but needs financial support to sustain its continued improvements. In addition to maintenance and stability there are many desirable features yet to be added. If your company is using dear imgui, please consider reaching out. If you are an individual using dear imgui, please consider supporting the project via Patreon or PayPal.)</sub>
|
||||
@ -29,23 +29,15 @@ Dear ImGui is particularly suited to integration in games engine (for tooling),
|
||||
|
||||
### Usage
|
||||
|
||||
Dear ImGui is self-contained within a few files that you can easily copy and compile into your application/engine:
|
||||
- imgui.cpp
|
||||
- imgui.h
|
||||
- imgui_demo.cpp
|
||||
- imgui_draw.cpp
|
||||
- imgui_widgets.cpp
|
||||
- imgui_internal.h
|
||||
- imconfig.h (empty by default, user-editable)
|
||||
- imstb_rectpack.h
|
||||
- imstb_textedit.h
|
||||
- imstb_truetype.h
|
||||
**The core of Dear ImGui is self-contained within a few platform-agnostic files** which you can easily copy and compile into your application/engine. They are all the files in the root folder of the repository (imgui.cpp, imgui.h, imgui_demo.cpp, imgui_draw.cpp etc.).
|
||||
|
||||
No specific build process is required. You can add the .cpp files to your project or #include them from an existing file.
|
||||
**No specific build process is required**. You can add the .cpp files to your existing project.
|
||||
|
||||
Backends for a variety of graphics api and rendering platforms along with example applications are provided in the [examples/](https://github.com/ocornut/imgui/tree/master/examples) folder.
|
||||
You will need a backend to integrate Dear ImGui in your app. The backend passes mouse/keyboard/gamepad inputs and variety of settings to Dear ImGui, and is in charge of rendering the resulting vertices.
|
||||
|
||||
The backend passes mouse/keyboard/gamepad inputs and variety of settings to Dear ImGui, and is in charge of rendering the resulting vertices. After Dear ImGui is setup in your application, you can use it from \_anywhere\_ in your program loop:
|
||||
**Backends for a variety of graphics api and rendering platforms** are provided in the [examples/](https://github.com/ocornut/imgui/tree/master/examples) folder, along with example applications. See the [Integration](#integration) section of this document for details. You may also create your own backend. Anywhere where you can render textured triangles, you can render Dear ImGui.
|
||||
|
||||
After Dear ImGui is setup in your application, you can use it from \_anywhere\_ in your program loop:
|
||||
|
||||
Code:
|
||||
```cp
|
||||
@ -153,44 +145,11 @@ Custom engine
|
||||
[![screenshot tool](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v160/editor_white_preview.jpg)](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v160/editor_white.png)
|
||||
|
||||
[Tracy Profiler](https://bitbucket.org/wolfpld/tracy)
|
||||
![tracy profiler](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v167/tracy_profiler.png)
|
||||
![tracy profiler](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v173/tracy_profiler.jpg)
|
||||
|
||||
### Support, Frequently Asked Questions (FAQ)
|
||||
|
||||
Most common questions will be answered by the [Frequently Asked Questions (FAQ)](https://github.com/ocornut/imgui/blob/master/docs/FAQ.md) page, e.g.:
|
||||
|
||||
**Basics**
|
||||
- "Where is the documentation?"
|
||||
- "Which version should I get?"
|
||||
- "Why the names "Dear ImGui" vs "ImGui"?"
|
||||
|
||||
**Community**
|
||||
- "How can I help?"
|
||||
|
||||
**Concerns**
|
||||
- "Who uses Dear ImGui?"
|
||||
- "Can you create elaborate/serious tools with Dear ImGui?"
|
||||
- "Can you reskin the look of Dear ImGui?"
|
||||
- "Why using C++ (as opposed to C)?"
|
||||
|
||||
**Integration**
|
||||
- "How can I tell whether to dispatch mouse/keyboard to Dear ImGui or to my application?"
|
||||
- "How can I use this without a mouse, without a keyboard or without a screen? (gamepad, input share, remote display)"
|
||||
- "I integrated Dear ImGui in my engine and the text or lines are blurry.."
|
||||
- "I integrated Dear ImGui in my engine and some elements are clipping or disappearing when I move windows around.."
|
||||
|
||||
**Usage**
|
||||
- "Why are multiple widgets reacting when I interact with a single one? How can I have multiple widgets with the same label or with an empty label?"
|
||||
- "How can I display an image? What is ImTextureID, how does it work?"
|
||||
- "How can I use my own math types instead of ImVec2/ImVec4?"
|
||||
- "How can I interact with standard C++ types (such as std::string and std::vector)?"
|
||||
- "How can I display custom shapes? (using low-level ImDrawList API)"
|
||||
|
||||
**Fonts, Text**
|
||||
- "How can I load a different font than the default?"
|
||||
- "How can I easily use icons in my application?"
|
||||
- "How can I load multiple fonts?"
|
||||
- "How can I display and input non-Latin characters such as Chinese, Japanese, Korean, Cyrillic?"
|
||||
Most common questions will be answered by the [Frequently Asked Questions (FAQ)](https://github.com/ocornut/imgui/blob/master/docs/FAQ.md) page.
|
||||
|
||||
See: [Wiki](https://github.com/ocornut/imgui/wiki) for many links, references, articles.
|
||||
|
||||
|
@ -63,10 +63,10 @@ You can find binaries of some of those example applications at:
|
||||
Most the example bindings are split in 2 parts:
|
||||
|
||||
- The "Platform" bindings, in charge of: mouse/keyboard/gamepad inputs, cursor shape, timing, windowing.
|
||||
Examples: Windows (imgui_impl_win32.cpp), GLFW (imgui_impl_glfw.cpp), SDL2 (imgui_impl_sdl.cpp)
|
||||
Examples: Windows (imgui_impl_win32.cpp), GLFW (imgui_impl_glfw.cpp), SDL2 (imgui_impl_sdl.cpp), etc.
|
||||
|
||||
- The "Renderer" bindings, in charge of: creating the main font texture, rendering imgui draw data.
|
||||
Examples: DirectX11 (imgui_impl_dx11.cpp), GL3 (imgui_impl_opengl3.cpp), Vulkan (imgui_impl_vulkan.cpp)
|
||||
Examples: DirectX11 (imgui_impl_dx11.cpp), GL3 (imgui_impl_opengl3.cpp), Vulkan (imgui_impl_vulkan.cpp), etc.
|
||||
|
||||
- The example _applications_ usually combine 1 platform + 1 renderer binding to create a working program.
|
||||
Examples: the example_win32_directx11/ application combines imgui_impl_win32.cpp + imgui_impl_dx11.cpp.
|
||||
@ -129,16 +129,32 @@ List of high-level Frameworks Bindings in this repository: (combine Platform + R
|
||||
imgui_impl_allegro5.cpp
|
||||
imgui_impl_marmalade.cpp
|
||||
|
||||
Note that Dear ImGui works with Emscripten.
|
||||
The examples_emscripten/ app uses sdl.cpp + opengl3.cpp but other combinations are possible.
|
||||
Note that Dear ImGui works with Emscripten. The examples_emscripten/ app uses imgui_impl_sdl.cpp and
|
||||
imgui_impl_opengl3.cpp, but other combinations are possible.
|
||||
|
||||
Third-party framework, graphics API and languages bindings are listed at:
|
||||
|
||||
https://github.com/ocornut/imgui/wiki/Bindings
|
||||
|
||||
Languages: C, C#, ChaiScript, D, Go, Haxe, Java, Lua, Odin, Pascal, PureBasic, Python, Rust, Swift...
|
||||
Frameworks: Cinder, Cocoa (OSX), Cocos2d-x, SFML, GML/GameMaker Studio, Irrlicht, Ogre, OpenSceneGraph,
|
||||
openFrameworks, LOVE, NanoRT, Nim Game Lib, Qt3d, SFML, Unreal Engine 4...
|
||||
Miscellaneous: Software Renderer, RemoteImgui, etc.
|
||||
Languages:
|
||||
C, C#, ChaiScript, CovScript, D, Go, Haxe/hxcpp, Java, JavaScript, Julia, Lua, Nim,
|
||||
Odin, Pascal, PureBasic, Python, Ruby, Rust, Swift...
|
||||
|
||||
Frameworks:
|
||||
Amethyst, bsf, Cinder, Cocoa2d-x, Diligent Engine, Flexium, GML/GameMaker Studio,
|
||||
GTK3 + OpenGL, Irrlicht, Ogre, OpenSceneGraph/OSG, openFrameworks, Orx, LÖVE+LUA,
|
||||
Magnum, NanoRT, Nim Game Lib, px_render, Qt, Qt3d, SFML, Sokol, Unreal Engine 4, vtk...
|
||||
|
||||
Miscellaneous: Software Renderer, RemoteImgui, imgui-ws, etc.
|
||||
|
||||
Not sure which to use?
|
||||
Recommended platform/frameworks:
|
||||
|
||||
GLFW https://github.com/glfw/glfw Use imgui_impl_glfw.cpp
|
||||
SDL2 https://www.libsdl.org Use imgui_impl_sdl.cp
|
||||
Sokol https://github.com/floooh/sokol Use util/sokol_imgui.h in Sokol repository.
|
||||
|
||||
Those will allow you to create portable applications and will solve and abstract away many issues.
|
||||
|
||||
|
||||
---------------------------------------
|
||||
|
@ -24,7 +24,8 @@ UNAME_S := $(shell uname -s)
|
||||
EMS = -s USE_SDL=2 -s WASM=1
|
||||
EMS += -s ALLOW_MEMORY_GROWTH=1 -s BINARYEN_TRAP_MODE=clamp
|
||||
EMS += -s DISABLE_EXCEPTION_CATCHING=1 -s NO_EXIT_RUNTIME=0
|
||||
EMS += -s ASSERTIONS=1 -s NO_FILESYSTEM=1
|
||||
EMS += -s ASSERTIONS=1
|
||||
#EMS += -s NO_FILESYSTEM=1 ## Getting "error: undefined symbol: $FS" if filesystem is removed
|
||||
#EMS += -s SAFE_HEAP=1 ## Adds overhead
|
||||
|
||||
CPPFLAGS = -I../ -I../../
|
||||
|
@ -9,7 +9,12 @@
|
||||
#include <dxgi1_4.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#define DX12_ENABLE_DEBUG_LAYER 0
|
||||
//#define DX12_ENABLE_DEBUG_LAYER
|
||||
|
||||
#ifdef DX12_ENABLE_DEBUG_LAYER
|
||||
#include <dxgidebug.h>
|
||||
#pragma comment(lib, "dxguid.lib")
|
||||
#endif
|
||||
|
||||
struct FrameContext
|
||||
{
|
||||
@ -252,15 +257,14 @@ bool CreateDeviceD3D(HWND hWnd)
|
||||
sd.Stereo = FALSE;
|
||||
}
|
||||
|
||||
if (DX12_ENABLE_DEBUG_LAYER)
|
||||
#ifdef DX12_ENABLE_DEBUG_LAYER
|
||||
ID3D12Debug* pdx12Debug = NULL;
|
||||
if (SUCCEEDED(D3D12GetDebugInterface(IID_PPV_ARGS(&pdx12Debug))))
|
||||
{
|
||||
ID3D12Debug* dx12Debug = NULL;
|
||||
if (SUCCEEDED(D3D12GetDebugInterface(IID_PPV_ARGS(&dx12Debug))))
|
||||
{
|
||||
dx12Debug->EnableDebugLayer();
|
||||
dx12Debug->Release();
|
||||
}
|
||||
pdx12Debug->EnableDebugLayer();
|
||||
pdx12Debug->Release();
|
||||
}
|
||||
#endif
|
||||
|
||||
D3D_FEATURE_LEVEL featureLevel = D3D_FEATURE_LEVEL_11_0;
|
||||
if (D3D12CreateDevice(NULL, featureLevel, IID_PPV_ARGS(&g_pd3dDevice)) != S_OK)
|
||||
@ -348,6 +352,15 @@ void CleanupDeviceD3D()
|
||||
if (g_fence) { g_fence->Release(); g_fence = NULL; }
|
||||
if (g_fenceEvent) { CloseHandle(g_fenceEvent); g_fenceEvent = NULL; }
|
||||
if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; }
|
||||
|
||||
#ifdef DX12_ENABLE_DEBUG_LAYER
|
||||
IDXGIDebug1* pDebug = NULL;
|
||||
if (SUCCEEDED(DXGIGetDebugInterface1(0, IID_PPV_ARGS(&pDebug))))
|
||||
{
|
||||
pDebug->ReportLiveObjects(DXGI_DEBUG_ALL, DXGI_DEBUG_RLO_SUMMARY);
|
||||
pDebug->Release();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void CreateRenderTarget()
|
||||
|
@ -15,6 +15,8 @@
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2019-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||
// 2019-10-18: DirectX12: *BREAKING CHANGE* Added extra ID3D12DescriptorHeap parameter to ImGui_ImplDX12_Init() function.
|
||||
// 2019-05-29: DirectX12: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
|
||||
// 2019-04-30: DirectX12: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
|
||||
// 2019-03-29: Misc: Various minor tidying up.
|
||||
|
37
imgui.cpp
37
imgui.cpp
@ -362,13 +362,14 @@ CODE
|
||||
- 2019/XX/XX (1.XX) - Moved IME support functions from io.ImeSetInputScreenPosFn, io.ImeWindowHandle to the PlatformIO api.
|
||||
|
||||
|
||||
- 2019/10/22 (1.74) - removed redirecting functions/enums that were marked obsolete in 1.52 (October 2017): Begin() (5 arguments signature), IsRootWindowOrAnyChildHovered(), AlignFirstTextHeightToWidgets(), SetNextWindowPosCenter(), ImFont::Glyph. Grep this log for details and new names, or see how they were implemented until 1.73.
|
||||
- 2019/10/14 (1.74) - inputs: Fixed a miscalculation in the keyboard/mouse "typematic" repeat delay/rate calculation, used by keys and e.g. repeating mouse buttons as well as the GetKeyPressedAmount() function.
|
||||
if you were using a non-default value for io.KeyRepeatRate (previous default was 0.250), you can add +io.KeyRepeatDelay to it to compensate for the fix.
|
||||
The function was triggering on: 0.0 and (delay+rate*N) where (N>=1). Fixed formula responds to (N>=0). Effectively it made io.KeyRepeatRate behave like it was set to (io.KeyRepeatRate + io.KeyRepeatDelay).
|
||||
If you never altered io.KeyRepeatRate nor used GetKeyPressedAmount() this won't affect you.
|
||||
- 2019/07/15 (1.72) - removed TreeAdvanceToLabelPos() which is rarely used and only does SetCursorPosX(GetCursorPosX() + GetTreeNodeToLabelSpacing()). Kept redirection function (will obsolete).
|
||||
- 2019/07/12 (1.72) - renamed ImFontAtlas::CustomRect to ImFontAtlasCustomRect. Kept redirection typedef (will obsolete).
|
||||
- 2019/06/14 (1.72) - removed redirecting functions/enums names that were marked obsolete in 1.51 (June 2017): ImGuiCol_Column*, ImGuiSetCond_*, IsItemHoveredRect(), IsPosHoveringAnyWindow(), IsMouseHoveringAnyWindow(), IsMouseHoveringWindow(), IMGUI_ONCE_UPON_A_FRAME. Grep this log for details and new names.
|
||||
- 2019/06/14 (1.72) - removed redirecting functions/enums names that were marked obsolete in 1.51 (June 2017): ImGuiCol_Column*, ImGuiSetCond_*, IsItemHoveredRect(), IsPosHoveringAnyWindow(), IsMouseHoveringAnyWindow(), IsMouseHoveringWindow(), IMGUI_ONCE_UPON_A_FRAME. Grep this log for details and new names, or see how they were implemented until 1.71.
|
||||
- 2019/06/07 (1.71) - rendering of child window outer decorations (bg color, border, scrollbars) is now performed as part of the parent window. If you have
|
||||
overlapping child windows in a same parent, and relied on their relative z-order to be mapped to their submission order, this will affect your rendering.
|
||||
This optimization is disabled if the parent window has no visual output, because it appears to be the most common situation leading to the creation of overlapping child windows.
|
||||
@ -2839,8 +2840,13 @@ void ImGui::ItemSize(const ImVec2& size, float text_baseline_y)
|
||||
if (window->SkipItems)
|
||||
return;
|
||||
|
||||
// We increase the height in this function to accommodate for baseline offset.
|
||||
// In theory we should be offsetting the starting position (window->DC.CursorPos), that will be the topic of a larger refactor,
|
||||
// but since ItemSize() is not yet an API that moves the cursor (to handle e.g. wrapping) enlarging the height has the same effect.
|
||||
const float offset_to_match_baseline_y = (text_baseline_y >= 0) ? ImMax(0.0f, window->DC.CurrLineTextBaseOffset - text_baseline_y) : 0.0f;
|
||||
const float line_height = ImMax(window->DC.CurrLineSize.y, size.y + offset_to_match_baseline_y);
|
||||
|
||||
// Always align ourselves on pixel boundaries
|
||||
const float line_height = ImMax(window->DC.CurrLineSize.y, size.y);
|
||||
//if (g.IO.KeyAlt) window->DrawList->AddRect(window->DC.CursorPos, window->DC.CursorPos + ImVec2(size.x, line_height), IM_COL32(255,0,0,200)); // [DEBUG]
|
||||
window->DC.CursorPosPrevLine.x = window->DC.CursorPos.x + size.x;
|
||||
window->DC.CursorPosPrevLine.y = window->DC.CursorPos.y;
|
||||
@ -6468,22 +6474,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
return !skip_items;
|
||||
}
|
||||
|
||||
// Old Begin() API with 5 parameters, avoid calling this version directly! Use SetNextWindowSize()/SetNextWindowBgAlpha() + Begin() instead.
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_first_use, float bg_alpha_override, ImGuiWindowFlags flags)
|
||||
{
|
||||
// Old API feature: we could pass the initial window size as a parameter. This was misleading because it only had an effect if the window didn't have data in the .ini file.
|
||||
if (size_first_use.x != 0.0f || size_first_use.y != 0.0f)
|
||||
SetNextWindowSize(size_first_use, ImGuiCond_FirstUseEver);
|
||||
|
||||
// Old API feature: override the window background alpha with a parameter.
|
||||
if (bg_alpha_override >= 0.0f)
|
||||
SetNextWindowBgAlpha(bg_alpha_override);
|
||||
|
||||
return Begin(name, p_open, flags);
|
||||
}
|
||||
#endif // IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
|
||||
void ImGui::End()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
@ -7248,15 +7238,6 @@ void ImGui::SetNextWindowPos(const ImVec2& pos, ImGuiCond cond, const ImVec2& pi
|
||||
g.NextWindowData.PosUndock = true;
|
||||
}
|
||||
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
void ImGui::SetNextWindowPosCenter(ImGuiCond cond)
|
||||
{
|
||||
ImGuiViewport* viewport = ImGui::GetMainViewport();
|
||||
SetNextWindowPos(viewport->Pos + viewport->Size * 0.5f, cond, ImVec2(0.5f, 0.5f));
|
||||
SetNextWindowViewport(viewport->ID);
|
||||
}
|
||||
#endif
|
||||
|
||||
void ImGui::SetNextWindowSize(const ImVec2& size, ImGuiCond cond)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
@ -7667,7 +7648,7 @@ void ImGui::EndGroup()
|
||||
}
|
||||
|
||||
window->DC.CurrLineTextBaseOffset = ImMax(window->DC.PrevLineTextBaseOffset, group_data.BackupCurrLineTextBaseOffset); // FIXME: Incorrect, we should grab the base offset from the *first line* of the group but it is hard to obtain now.
|
||||
ItemSize(group_bb.GetSize(), 0.0f);
|
||||
ItemSize(group_bb.GetSize());
|
||||
ItemAdd(group_bb, 0);
|
||||
|
||||
// If the current ActiveId was declared within the boundary of our group, we copy it to LastItemId so IsItemActive(), IsItemDeactivated() etc. will be functional on the entire group.
|
||||
|
70
imgui.h
70
imgui.h
@ -28,7 +28,7 @@ Index of this file:
|
||||
|
||||
#pragma once
|
||||
|
||||
// Configuration file with compile-time options (edit imconfig.h or define IMGUI_USER_CONFIG to your own filename)
|
||||
// Configuration file with compile-time options (edit imconfig.h or #define IMGUI_USER_CONFIG to your own filename)
|
||||
#ifdef IMGUI_USER_CONFIG
|
||||
#include IMGUI_USER_CONFIG
|
||||
#endif
|
||||
@ -40,8 +40,9 @@ Index of this file:
|
||||
// Header mess
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <float.h> // FLT_MAX
|
||||
#include <stdarg.h> // va_list
|
||||
// Includes
|
||||
#include <float.h> // FLT_MIN, FLT_MAX
|
||||
#include <stdarg.h> // va_list, va_start, va_end
|
||||
#include <stddef.h> // ptrdiff_t, NULL
|
||||
#include <string.h> // memset, memmove, memcpy, strlen, strchr, strcpy, strcmp
|
||||
|
||||
@ -69,13 +70,13 @@ Index of this file:
|
||||
#define IM_ASSERT(_EXPR) assert(_EXPR) // You can override the default assert handler by editing imconfig.h
|
||||
#endif
|
||||
#if defined(__clang__) || defined(__GNUC__)
|
||||
#define IM_FMTARGS(FMT) __attribute__((format(printf, FMT, FMT+1))) // Apply printf-style warnings to user functions.
|
||||
#define IM_FMTARGS(FMT) __attribute__((format(printf, FMT, FMT+1))) // To apply printf-style warnings to our functions.
|
||||
#define IM_FMTLIST(FMT) __attribute__((format(printf, FMT, 0)))
|
||||
#else
|
||||
#define IM_FMTARGS(FMT)
|
||||
#define IM_FMTLIST(FMT)
|
||||
#endif
|
||||
#define IM_ARRAYSIZE(_ARR) ((int)(sizeof(_ARR)/sizeof(*_ARR))) // Size of a static C-style array. Don't use on pointers!
|
||||
#define IM_ARRAYSIZE(_ARR) ((int)(sizeof(_ARR) / sizeof(*_ARR))) // Size of a static C-style array. Don't use on pointers!
|
||||
#define IM_UNUSED(_VAR) ((void)_VAR) // Used to silence "unused variable warnings". Often useful as asserts may be stripped out from final builds.
|
||||
#if (__cplusplus >= 201100)
|
||||
#define IM_OFFSETOF(_TYPE,_MEMBER) offsetof(_TYPE, _MEMBER) // Offset of _MEMBER within _TYPE. Standardized as offsetof() in C++11
|
||||
@ -130,7 +131,7 @@ struct ImGuiViewport; // Viewport (generally ~1 per window to outp
|
||||
struct ImGuiWindowClass; // Window class (rare/advanced uses: provide hints to the platform back-end via altered viewport flags and parent/child info)
|
||||
|
||||
// Typedefs and Enums/Flags (declared as int for compatibility with old C++, to allow using as flags and to not pollute the top of this file)
|
||||
// Use your programming IDE "Go to definition" facility on the names of the center columns to find the actual flags/enum lists.
|
||||
// Use your programming IDE "Go to definition" facility on the names in the central column below to find the actual flags/enum lists.
|
||||
#ifndef ImTextureID
|
||||
typedef void* ImTextureID; // User data to identify a texture (this is whatever to you want it to be! read the FAQ about ImTextureID in imgui.cpp)
|
||||
#endif
|
||||
@ -166,7 +167,7 @@ typedef int (*ImGuiInputTextCallback)(ImGuiInputTextCallbackData *data);
|
||||
typedef void (*ImGuiSizeCallback)(ImGuiSizeCallbackData* data);
|
||||
|
||||
// Scalar data types
|
||||
typedef signed char ImS8; // 8-bit signed integer == char
|
||||
typedef signed char ImS8; // 8-bit signed integer
|
||||
typedef unsigned char ImU8; // 8-bit unsigned integer
|
||||
typedef signed short ImS16; // 16-bit signed integer
|
||||
typedef unsigned short ImU16; // 16-bit unsigned integer
|
||||
@ -210,14 +211,14 @@ struct ImVec4
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ImGui: Dear ImGui end-user API
|
||||
// (Inside a namespace so you can add extra functions in your own separate file. Please don't modify imgui.cpp/.h!)
|
||||
// (Inside a namespace so you can add extra functions in your own separate file. Please don't modify imgui source files!)
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
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.
|
||||
// All those functions are not reliant on the current context.
|
||||
// None of those functions is reliant on the current context.
|
||||
IMGUI_API ImGuiContext* CreateContext(ImFontAtlas* shared_font_atlas = NULL);
|
||||
IMGUI_API void DestroyContext(ImGuiContext* ctx = NULL); // NULL = destroy current context
|
||||
IMGUI_API ImGuiContext* GetCurrentContext();
|
||||
@ -254,8 +255,9 @@ namespace ImGui
|
||||
// which clicking will set the boolean to false when clicked.
|
||||
// - Begin() return false to indicate the window is collapsed or fully clipped, so you may early out and omit submitting
|
||||
// anything to the window. Always call a matching End() for each Begin() call, regardless of its return value!
|
||||
// [this is due to legacy reason and is inconsistent with most other functions such as BeginMenu/EndMenu, BeginPopup/EndPopup, etc.
|
||||
// where the EndXXX call should only be called if the corresponding BeginXXX function returned true.]
|
||||
// [Important: due to legacy reason, this is inconsistent with most other functions such as BeginMenu/EndMenu,
|
||||
// BeginPopup/EndPopup, etc. where the EndXXX call should only be called if the corresponding BeginXXX function
|
||||
// returned true. Begin and BeginChild are the only odd ones out. Will be fixed in a future update.]
|
||||
// - Note that the bottom of window stack always contains a window called "Debug".
|
||||
IMGUI_API bool Begin(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0);
|
||||
IMGUI_API void End();
|
||||
@ -264,13 +266,13 @@ namespace ImGui
|
||||
// - Use child windows to begin into a self-contained independent scrolling/clipping regions within a host window. Child windows can embed their own child.
|
||||
// - For each independent axis of 'size': ==0.0f: use remaining host window size / >0.0f: fixed size / <0.0f: use remaining window size minus abs(size) / Each axis can use a different mode, e.g. ImVec2(0,400).
|
||||
// - BeginChild() returns false to indicate the window is collapsed or fully clipped, so you may early out and omit submitting anything to the window.
|
||||
// Always call a matching EndChild() for each BeginChild() call, regardless of its return value [this is due to legacy reason and is inconsistent with most other functions such as BeginMenu/EndMenu, BeginPopup/EndPopup, etc. where the EndXXX call should only be called if the corresponding BeginXXX function returned true.]
|
||||
// Always call a matching EndChild() for each BeginChild() call, regardless of its return value [as with Begin: this is due to legacy reason and inconsistent with most BeginXXX functions apart from the regular Begin() which behaves like BeginChild().]
|
||||
IMGUI_API bool BeginChild(const char* str_id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags flags = 0);
|
||||
IMGUI_API bool BeginChild(ImGuiID id, const ImVec2& size = ImVec2(0,0), bool border = false, ImGuiWindowFlags flags = 0);
|
||||
IMGUI_API void EndChild();
|
||||
|
||||
// Windows Utilities
|
||||
// - "current window" = the window we are appending into while inside a Begin()/End() block. "next window" = next window we will Begin() into.
|
||||
// - 'current window' = the window we are appending into while inside a Begin()/End() block. 'next window' = next window we will Begin() into.
|
||||
IMGUI_API bool IsWindowAppearing();
|
||||
IMGUI_API bool IsWindowCollapsed();
|
||||
IMGUI_API bool IsWindowFocused(ImGuiFocusedFlags flags=0); // is current window focused? or its root/child, depending on flags. see flags for options.
|
||||
@ -354,6 +356,7 @@ namespace ImGui
|
||||
// Cursor / Layout
|
||||
// - By "cursor" we mean the current output position.
|
||||
// - The typical widget behavior is to output themselves at the current cursor position, then move the cursor one line down.
|
||||
// - You can call SameLine() between widgets to undo the last carriage return and output at the right of the preceeding widget.
|
||||
IMGUI_API void Separator(); // separator, generally horizontal. inside a menu bar or in horizontal layout mode, this becomes a vertical separator.
|
||||
IMGUI_API void SameLine(float offset_from_start_x=0.0f, float spacing=-1.0f); // call between widgets or groups to layout them horizontally. X position given in window coordinates.
|
||||
IMGUI_API void NewLine(); // undo a SameLine() or force a new line when in an horizontal-layout context.
|
||||
@ -395,8 +398,8 @@ namespace ImGui
|
||||
IMGUI_API ImGuiID GetID(const void* ptr_id);
|
||||
|
||||
// Widgets: Text
|
||||
IMGUI_API void TextUnformatted(const char* text, const char* text_end = NULL); // raw text without formatting. Roughly equivalent to Text("%s", text) but: A) doesn't require null terminated string if 'text_end' is specified, B) it's faster, no memory copy is done, no buffer size limits, recommended for long chunks of text.
|
||||
IMGUI_API void Text(const char* fmt, ...) IM_FMTARGS(1); // simple formatted text
|
||||
IMGUI_API void TextUnformatted(const char* text, const char* text_end = NULL); // raw text without formatting. Roughly equivalent to Text("%s", text) but: A) doesn't require null terminated string if 'text_end' is specified, B) it's faster, no memory copy is done, no buffer size limits, recommended for long chunks of text.
|
||||
IMGUI_API void Text(const char* fmt, ...) IM_FMTARGS(1); // formatted text
|
||||
IMGUI_API void TextV(const char* fmt, va_list args) IM_FMTLIST(1);
|
||||
IMGUI_API void TextColored(const ImVec4& col, const char* fmt, ...) IM_FMTARGS(2); // shortcut for PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor();
|
||||
IMGUI_API void TextColoredV(const ImVec4& col, const char* fmt, va_list args) IM_FMTLIST(2);
|
||||
@ -411,6 +414,7 @@ namespace ImGui
|
||||
|
||||
// Widgets: Main
|
||||
// - Most widgets return true when the value has been changed or when pressed/selected
|
||||
// - You may also use one of the many IsItemXXX functions (e.g. IsItemActive, IsItemHovered, etc.) to query widget state.
|
||||
IMGUI_API bool Button(const char* label, const ImVec2& size = ImVec2(0,0)); // button
|
||||
IMGUI_API bool SmallButton(const char* label); // button with FramePadding=(0,0) to easily embed within text
|
||||
IMGUI_API bool InvisibleButton(const char* str_id, const ImVec2& size); // button behavior without the visuals, frequently useful to build custom behaviors using the public api (along with IsItemActive, IsItemHovered, etc.)
|
||||
@ -425,7 +429,7 @@ namespace ImGui
|
||||
IMGUI_API void Bullet(); // draw a small circle and keep the cursor on the same line. advance cursor x position by GetTreeNodeToLabelSpacing(), same distance that TreeNode() uses
|
||||
|
||||
// Widgets: Combo Box
|
||||
// - The new BeginCombo()/EndCombo() api allows you to manage your contents and selection state however you want it, by creating e.g. Selectable() items.
|
||||
// - The BeginCombo()/EndCombo() api allows you to manage your contents and selection state however you want it, by creating e.g. Selectable() items.
|
||||
// - The old Combo() api are helpers over BeginCombo()/EndCombo() which are kept available for convenience purpose.
|
||||
IMGUI_API bool BeginCombo(const char* label, const char* preview_value, ImGuiComboFlags flags = 0);
|
||||
IMGUI_API void EndCombo(); // only call EndCombo() if BeginCombo() returns true!
|
||||
@ -521,7 +525,7 @@ namespace ImGui
|
||||
|
||||
// Widgets: Selectables
|
||||
// - A selectable highlights when hovered, and can display another color when selected.
|
||||
// - Neighbors selectable extend their highlight bounds in order to leave no gap between them.
|
||||
// - Neighbors selectable extend their highlight bounds in order to leave no gap between them. This is so a series of selected Selectable appear contiguous.
|
||||
IMGUI_API bool Selectable(const char* label, bool selected = false, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0,0)); // "bool selected" carry the selection state (read-only). Selectable() is clicked is returns true so you can modify your selection state. 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)); // "bool* p_selected" point to the selection state (read-write), as a convenient helper.
|
||||
|
||||
@ -547,16 +551,19 @@ namespace ImGui
|
||||
IMGUI_API void Value(const char* prefix, float v, const char* float_format = NULL);
|
||||
|
||||
// Widgets: Menus
|
||||
IMGUI_API bool BeginMainMenuBar(); // create and append to a full screen menu-bar.
|
||||
IMGUI_API void EndMainMenuBar(); // only call EndMainMenuBar() if BeginMainMenuBar() returns true!
|
||||
// - Use BeginMenuBar() on a window ImGuiWindowFlags_MenuBar to append to its menu bar.
|
||||
// - Use BeginMainMenuBar() to create a menu bar at the top of the screen.
|
||||
IMGUI_API bool BeginMenuBar(); // append to menu-bar of current window (requires ImGuiWindowFlags_MenuBar flag set on parent window).
|
||||
IMGUI_API void EndMenuBar(); // only call EndMenuBar() if BeginMenuBar() returns true!
|
||||
IMGUI_API bool BeginMainMenuBar(); // create and append to a full screen menu-bar.
|
||||
IMGUI_API void EndMainMenuBar(); // only call EndMainMenuBar() if BeginMainMenuBar() returns true!
|
||||
IMGUI_API bool BeginMenu(const char* label, bool enabled = true); // create a sub-menu entry. only call EndMenu() if this returns true!
|
||||
IMGUI_API void EndMenu(); // only call EndMenu() if BeginMenu() returns true!
|
||||
IMGUI_API bool MenuItem(const char* label, const char* shortcut = NULL, bool selected = false, bool enabled = true); // return true when activated. shortcuts are displayed for convenience but not processed by ImGui at the moment
|
||||
IMGUI_API bool MenuItem(const char* label, const char* shortcut, bool* p_selected, bool enabled = true); // return true when activated + toggle (*p_selected) if p_selected != NULL
|
||||
|
||||
// Tooltips
|
||||
// - Tooltip are windows following the mouse which do not take focus away.
|
||||
IMGUI_API void BeginTooltip(); // begin/append a tooltip window. to create full-featured tooltip (with any kind of items).
|
||||
IMGUI_API void EndTooltip();
|
||||
IMGUI_API void SetTooltip(const char* fmt, ...) IM_FMTARGS(1); // set a text-only tooltip, typically use with ImGui::IsItemHovered(). override any previous call to SetTooltip().
|
||||
@ -568,7 +575,7 @@ namespace ImGui
|
||||
// - Unless modal, they can be closed by clicking anywhere outside them, or by pressing ESCAPE.
|
||||
// - Their visibility state (~bool) is held internally by imgui instead of being held by the programmer as we are used to with regular Begin() calls.
|
||||
// User can manipulate the visibility state by calling OpenPopup().
|
||||
// (*) One can use IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup) to bypass it and detect hovering even when normally blocked by a popup.
|
||||
// (*) You can use IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup) to bypass it and detect hovering even when normally blocked by a popup.
|
||||
// Those three properties are connected. The library needs to hold their visibility state because it can close popups at any time.
|
||||
IMGUI_API void OpenPopup(const char* str_id); // call to mark popup as open (don't call every frame!). popups are closed when user click outside, or if CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block. By default, Selectable()/MenuItem() are calling CloseCurrentPopup(). Popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level).
|
||||
IMGUI_API bool BeginPopup(const char* str_id, ImGuiWindowFlags flags = 0); // return true if the popup is open, and you can start outputting to it. only call EndPopup() if BeginPopup() returns true!
|
||||
@ -584,6 +591,7 @@ namespace ImGui
|
||||
// Columns
|
||||
// - You can also use SameLine(pos_x) to mimic simplified columns.
|
||||
// - The columns API is work-in-progress and rather lacking (columns are arguably the worst part of dear imgui at the moment!)
|
||||
// - By end of the 2019 we will expose a new 'Table' api which will replace columns.
|
||||
IMGUI_API void Columns(int count = 1, const char* id = NULL, bool border = true);
|
||||
IMGUI_API void NextColumn(); // next column, defaults to current row or next row if the current row is finished
|
||||
IMGUI_API int GetColumnIndex(); // get current column index
|
||||
@ -594,7 +602,6 @@ namespace ImGui
|
||||
IMGUI_API int GetColumnsCount();
|
||||
|
||||
// Tab Bars, Tabs
|
||||
// [BETA API] API may evolve!
|
||||
// Note: Tabs are automatically created by the docking system. Use this to create tab bars/tabs yourself without docking being involved.
|
||||
IMGUI_API bool BeginTabBar(const char* str_id, ImGuiTabBarFlags flags = 0); // create and append into a TabBar
|
||||
IMGUI_API void EndTabBar(); // only call EndTabBar() if BeginTabBar() returns true!
|
||||
@ -1006,12 +1013,12 @@ enum ImGuiKey_
|
||||
ImGuiKey_Enter,
|
||||
ImGuiKey_Escape,
|
||||
ImGuiKey_KeyPadEnter,
|
||||
ImGuiKey_A, // for text edit CTRL+A: select all
|
||||
ImGuiKey_C, // for text edit CTRL+C: copy
|
||||
ImGuiKey_V, // for text edit CTRL+V: paste
|
||||
ImGuiKey_X, // for text edit CTRL+X: cut
|
||||
ImGuiKey_Y, // for text edit CTRL+Y: redo
|
||||
ImGuiKey_Z, // for text edit CTRL+Z: undo
|
||||
ImGuiKey_A, // for text edit CTRL+A: select all
|
||||
ImGuiKey_C, // for text edit CTRL+C: copy
|
||||
ImGuiKey_V, // for text edit CTRL+V: paste
|
||||
ImGuiKey_X, // for text edit CTRL+X: cut
|
||||
ImGuiKey_Y, // for text edit CTRL+Y: redo
|
||||
ImGuiKey_Z, // for text edit CTRL+Z: undo
|
||||
ImGuiKey_COUNT
|
||||
};
|
||||
|
||||
@ -1665,11 +1672,6 @@ namespace ImGui
|
||||
static inline bool IsRootWindowOrAnyChildFocused() { return IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows); }
|
||||
static inline void SetNextWindowContentWidth(float w) { SetNextWindowContentSize(ImVec2(w, 0.0f)); }
|
||||
static inline float GetItemsLineHeightWithSpacing() { return GetFrameHeightWithSpacing(); }
|
||||
// OBSOLETED in 1.52 (between Aug 2017 and Oct 2017)
|
||||
IMGUI_API bool Begin(const char* name, bool* p_open, const ImVec2& size_on_first_use, float bg_alpha_override = -1.0f, ImGuiWindowFlags flags = 0); // Use SetNextWindowSize(size, ImGuiCond_FirstUseEver) + SetNextWindowBgAlpha() instead.
|
||||
static inline bool IsRootWindowOrAnyChildHovered() { return IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows); }
|
||||
static inline void AlignFirstTextHeightToWidgets() { AlignTextToFramePadding(); }
|
||||
void SetNextWindowPosCenter(ImGuiCond cond);
|
||||
}
|
||||
typedef ImGuiInputTextCallback ImGuiTextEditCallback; // OBSOLETED in 1.63 (from Aug 2018): made the names consistent
|
||||
typedef ImGuiInputTextCallbackData ImGuiTextEditCallbackData;
|
||||
@ -2318,10 +2320,6 @@ struct ImFont
|
||||
IMGUI_API void AddGlyph(ImWchar c, float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, float advance_x);
|
||||
IMGUI_API void AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst = true); // Makes 'dst' character/glyph points to 'src' character/glyph. Currently needs to be called AFTER fonts have been built.
|
||||
IMGUI_API void SetFallbackChar(ImWchar c);
|
||||
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
typedef ImFontGlyph Glyph; // OBSOLETED in 1.52+
|
||||
#endif
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -3342,7 +3342,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
||||
if (ImGui::Button("Revert Ref"))
|
||||
style = *ref;
|
||||
ImGui::SameLine();
|
||||
HelpMarker("Save/Revert in local non-persistent storage. Default Colors definition are not affected. Use \"Export Colors\" below to save them somewhere.");
|
||||
HelpMarker("Save/Revert in local non-persistent storage. Default Colors definition are not affected. Use \"Export\" below to save them somewhere.");
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
@ -3390,7 +3390,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
||||
{
|
||||
static int output_dest = 0;
|
||||
static bool output_only_modified = true;
|
||||
if (ImGui::Button("Export Unsaved"))
|
||||
if (ImGui::Button("Export"))
|
||||
{
|
||||
if (output_dest == 0)
|
||||
ImGui::LogToClipboard();
|
||||
|
@ -1745,8 +1745,8 @@ namespace ImGui
|
||||
IMGUI_API void PushOverrideID(ImGuiID id);
|
||||
|
||||
// Basic Helpers for widget code
|
||||
IMGUI_API void ItemSize(const ImVec2& size, float text_baseline_y = 0.0f);
|
||||
IMGUI_API void ItemSize(const ImRect& bb, float text_baseline_y = 0.0f);
|
||||
IMGUI_API void ItemSize(const ImVec2& size, float text_baseline_y = -1.0f);
|
||||
IMGUI_API void ItemSize(const ImRect& bb, float text_baseline_y = -1.0f);
|
||||
IMGUI_API bool ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb = NULL);
|
||||
IMGUI_API bool ItemHoverable(const ImRect& bb, ImGuiID id);
|
||||
IMGUI_API bool IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged);
|
||||
|
@ -213,7 +213,7 @@ void ImGui::TextEx(const char* text, const char* text_end, ImGuiTextFlags flags)
|
||||
text_size.y = (pos - text_pos).y;
|
||||
|
||||
ImRect bb(text_pos, text_pos + text_size);
|
||||
ItemSize(text_size);
|
||||
ItemSize(text_size, 0.0f);
|
||||
ItemAdd(bb, 0);
|
||||
}
|
||||
else
|
||||
@ -222,7 +222,7 @@ void ImGui::TextEx(const char* text, const char* text_end, ImGuiTextFlags flags)
|
||||
const ImVec2 text_size = CalcTextSize(text_begin, text_end, false, wrap_width);
|
||||
|
||||
ImRect bb(text_pos, text_pos + text_size);
|
||||
ItemSize(text_size);
|
||||
ItemSize(text_size, 0.0f);
|
||||
if (!ItemAdd(bb, 0))
|
||||
return;
|
||||
|
||||
@ -359,17 +359,18 @@ void ImGui::BulletTextV(const char* fmt, va_list args)
|
||||
const char* text_begin = g.TempBuffer;
|
||||
const char* text_end = text_begin + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args);
|
||||
const ImVec2 label_size = CalcTextSize(text_begin, text_end, false);
|
||||
const float text_base_offset_y = ImMax(0.0f, window->DC.CurrLineTextBaseOffset); // Latch before ItemSize changes it
|
||||
const float line_height = ImMax(ImMin(window->DC.CurrLineSize.y, g.FontSize + g.Style.FramePadding.y*2), g.FontSize);
|
||||
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(g.FontSize + (label_size.x > 0.0f ? (label_size.x + style.FramePadding.x*2) : 0.0f), ImMax(line_height, label_size.y))); // Empty text doesn't add padding
|
||||
ItemSize(bb);
|
||||
const ImVec2 total_size = ImVec2(g.FontSize + (label_size.x > 0.0f ? (label_size.x + style.FramePadding.x * 2) : 0.0f), label_size.y); // Empty text doesn't add padding
|
||||
ImVec2 pos = window->DC.CursorPos;
|
||||
pos.y += window->DC.CurrLineTextBaseOffset;
|
||||
ItemSize(total_size, 0.0f);
|
||||
const ImRect bb(pos, pos + total_size);
|
||||
if (!ItemAdd(bb, 0))
|
||||
return;
|
||||
|
||||
// Render
|
||||
ImU32 text_col = GetColorU32(ImGuiCol_Text);
|
||||
RenderBullet(window->DrawList, bb.Min + ImVec2(style.FramePadding.x + g.FontSize*0.5f, line_height*0.5f), text_col);
|
||||
RenderText(bb.Min+ImVec2(g.FontSize + style.FramePadding.x*2, text_base_offset_y), text_begin, text_end, false);
|
||||
RenderBullet(window->DrawList, bb.Min + ImVec2(style.FramePadding.x + g.FontSize*0.5f, g.FontSize*0.5f), text_col);
|
||||
RenderText(bb.Min + ImVec2(g.FontSize + style.FramePadding.x * 2, 0.0f), text_begin, text_end, false);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
@ -691,7 +692,7 @@ bool ImGui::ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size, ImGuiBu
|
||||
const ImGuiID id = window->GetID(str_id);
|
||||
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
|
||||
const float default_size = GetFrameHeight();
|
||||
ItemSize(size, (size.y >= default_size) ? g.Style.FramePadding.y : 0.0f);
|
||||
ItemSize(size, (size.y >= default_size) ? g.Style.FramePadding.y : -1.0f);
|
||||
if (!ItemAdd(bb, id))
|
||||
return false;
|
||||
|
||||
@ -4794,7 +4795,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
||||
draw_list->PrimVtx(trb, uv_white, hue_color32);
|
||||
draw_list->PrimVtx(trc, uv_white, col_white);
|
||||
draw_list->PrimVtx(tra, uv_white, 0);
|
||||
draw_list->PrimVtx(trb, uv_white, col_white);
|
||||
draw_list->PrimVtx(trb, uv_white, col_black);
|
||||
draw_list->PrimVtx(trc, uv_white, 0);
|
||||
draw_list->AddTriangle(tra, trb, trc, col_midgrey, 1.5f);
|
||||
sv_cursor_pos = ImLerp(ImLerp(trc, tra, ImSaturate(S)), trb, ImSaturate(1 - V));
|
||||
@ -5221,7 +5222,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
||||
ImGuiContext& g = *GImGui;
|
||||
const ImGuiStyle& style = g.Style;
|
||||
const bool display_frame = (flags & ImGuiTreeNodeFlags_Framed) != 0;
|
||||
const ImVec2 padding = (display_frame || (flags & ImGuiTreeNodeFlags_FramePadding)) ? style.FramePadding : ImVec2(style.FramePadding.x, 0.0f);
|
||||
const ImVec2 padding = (display_frame || (flags & ImGuiTreeNodeFlags_FramePadding)) ? style.FramePadding : ImVec2(style.FramePadding.x, ImMin(window->DC.CurrLineTextBaseOffset, style.FramePadding.y));
|
||||
|
||||
if (!label_end)
|
||||
label_end = FindRenderedTextEnd(label);
|
||||
@ -5246,7 +5247,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
||||
const float text_offset_y = ImMax(padding.y, window->DC.CurrLineTextBaseOffset); // Latch before ItemSize changes it
|
||||
const float text_width = g.FontSize + (label_size.x > 0.0f ? label_size.x + padding.x*2 : 0.0f); // Include collapser
|
||||
ImVec2 text_pos(window->DC.CursorPos.x + text_offset_x, window->DC.CursorPos.y + text_offset_y);
|
||||
ItemSize(ImVec2(text_width, frame_height), text_offset_y);
|
||||
ItemSize(ImVec2(text_width, frame_height), padding.y);
|
||||
|
||||
// For regular tree nodes, we arbitrary allow to click past 2 worth of ItemSpacing
|
||||
ImRect interact_bb = frame_bb;
|
||||
@ -5517,7 +5518,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
|
||||
ImVec2 pos = window->DC.CursorPos;
|
||||
pos.y += window->DC.CurrLineTextBaseOffset;
|
||||
ImRect bb_inner(pos, pos + size);
|
||||
ItemSize(size);
|
||||
ItemSize(size, 0.0f);
|
||||
|
||||
// Fill horizontal space.
|
||||
ImVec2 window_padding = window->WindowPadding;
|
||||
@ -5953,10 +5954,10 @@ void ImGui::Value(const char* prefix, float v, const char* float_format)
|
||||
// [SECTION] MenuItem, BeginMenu, EndMenu, etc.
|
||||
//-------------------------------------------------------------------------
|
||||
// - ImGuiMenuColumns [Internal]
|
||||
// - BeginMainMenuBar()
|
||||
// - EndMainMenuBar()
|
||||
// - BeginMenuBar()
|
||||
// - EndMenuBar()
|
||||
// - BeginMainMenuBar()
|
||||
// - EndMainMenuBar()
|
||||
// - BeginMenu()
|
||||
// - EndMenu()
|
||||
// - MenuItem()
|
||||
@ -6004,42 +6005,6 @@ float ImGuiMenuColumns::CalcExtraSpace(float avail_w)
|
||||
return ImMax(0.0f, avail_w - Width);
|
||||
}
|
||||
|
||||
// For the main menu bar, which cannot be moved, we honor g.Style.DisplaySafeAreaPadding to ensure text can be visible on a TV set.
|
||||
bool ImGui::BeginMainMenuBar()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiViewport* viewport = g.Viewports[0];
|
||||
g.NextWindowData.MenuBarOffsetMinVal = ImVec2(g.Style.DisplaySafeAreaPadding.x, ImMax(g.Style.DisplaySafeAreaPadding.y - g.Style.FramePadding.y, 0.0f));
|
||||
SetNextWindowPos(viewport->Pos);
|
||||
SetNextWindowSize(ImVec2(viewport->Size.x, g.NextWindowData.MenuBarOffsetMinVal.y + g.FontBaseSize + g.Style.FramePadding.y));
|
||||
SetNextWindowViewport(viewport->ID); // Enforce viewport so we don't create our onw viewport when ImGuiConfigFlags_ViewportsNoMerge is set.
|
||||
PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||
PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(0,0));
|
||||
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_MenuBar;
|
||||
bool is_open = Begin("##MainMenuBar", NULL, window_flags) && BeginMenuBar();
|
||||
PopStyleVar(2);
|
||||
g.NextWindowData.MenuBarOffsetMinVal = ImVec2(0.0f, 0.0f);
|
||||
if (!is_open)
|
||||
{
|
||||
End();
|
||||
return false;
|
||||
}
|
||||
return true; //-V1020
|
||||
}
|
||||
|
||||
void ImGui::EndMainMenuBar()
|
||||
{
|
||||
EndMenuBar();
|
||||
|
||||
// When the user has left the menu layer (typically: closed menus through activation of an item), we restore focus to the previous window
|
||||
// FIXME: With this strategy we won't be able to restore a NULL focus.
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.CurrentWindow == g.NavWindow && g.NavLayer == 0 && !g.NavAnyRequest)
|
||||
FocusTopMostWindowUnderOne(g.NavWindow, NULL);
|
||||
|
||||
End();
|
||||
}
|
||||
|
||||
// FIXME: Provided a rectangle perhaps e.g. a BeginMenuBarEx() could be used anywhere..
|
||||
// Currently the main responsibility of this function being to setup clip-rect + horizontal layout + menu navigation layer.
|
||||
// Ideally we also want this to be responsible for claiming space out of the main window scrolling rectangle, in which case ImGuiWindowFlags_MenuBar will become unnecessary.
|
||||
@ -6113,6 +6078,42 @@ void ImGui::EndMenuBar()
|
||||
window->DC.MenuBarAppending = false;
|
||||
}
|
||||
|
||||
// For the main menu bar, which cannot be moved, we honor g.Style.DisplaySafeAreaPadding to ensure text can be visible on a TV set.
|
||||
bool ImGui::BeginMainMenuBar()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiViewport* viewport = g.Viewports[0];
|
||||
g.NextWindowData.MenuBarOffsetMinVal = ImVec2(g.Style.DisplaySafeAreaPadding.x, ImMax(g.Style.DisplaySafeAreaPadding.y - g.Style.FramePadding.y, 0.0f));
|
||||
SetNextWindowPos(viewport->Pos);
|
||||
SetNextWindowSize(ImVec2(viewport->Size.x, g.NextWindowData.MenuBarOffsetMinVal.y + g.FontBaseSize + g.Style.FramePadding.y));
|
||||
SetNextWindowViewport(viewport->ID); // Enforce viewport so we don't create our onw viewport when ImGuiConfigFlags_ViewportsNoMerge is set.
|
||||
PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||
PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(0, 0));
|
||||
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_MenuBar;
|
||||
bool is_open = Begin("##MainMenuBar", NULL, window_flags) && BeginMenuBar();
|
||||
PopStyleVar(2);
|
||||
g.NextWindowData.MenuBarOffsetMinVal = ImVec2(0.0f, 0.0f);
|
||||
if (!is_open)
|
||||
{
|
||||
End();
|
||||
return false;
|
||||
}
|
||||
return true; //-V1020
|
||||
}
|
||||
|
||||
void ImGui::EndMainMenuBar()
|
||||
{
|
||||
EndMenuBar();
|
||||
|
||||
// When the user has left the menu layer (typically: closed menus through activation of an item), we restore focus to the previous window
|
||||
// FIXME: With this strategy we won't be able to restore a NULL focus.
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.CurrentWindow == g.NavWindow && g.NavLayer == 0 && !g.NavAnyRequest)
|
||||
FocusTopMostWindowUnderOne(g.NavWindow, NULL);
|
||||
|
||||
End();
|
||||
}
|
||||
|
||||
bool ImGui::BeginMenu(const char* label, bool enabled)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
@ -6450,7 +6451,7 @@ bool ImGui::BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& tab_bar_bb, ImG
|
||||
tab_bar->FramePadding = g.Style.FramePadding;
|
||||
|
||||
// Layout
|
||||
ItemSize(ImVec2(tab_bar->OffsetMaxIdeal, tab_bar->BarRect.GetHeight()));
|
||||
ItemSize(ImVec2(tab_bar->OffsetMaxIdeal, tab_bar->BarRect.GetHeight()), tab_bar->FramePadding.y);
|
||||
window->DC.CursorPos.x = tab_bar->BarRect.Min.x;
|
||||
|
||||
// Draw separator
|
||||
|
@ -1,4 +1,4 @@
|
||||
// [DEAR IMGUI]
|
||||
// [DEAR IMGUI]
|
||||
// This is a slightly modified version of stb_textedit.h 1.13.
|
||||
// Those changes would need to be pushed into nothings/stb:
|
||||
// - Fix in stb_textedit_discard_redo (see https://github.com/nothings/stb/issues/321)
|
||||
|
@ -1,4 +1,4 @@
|
||||
// [DEAR IMGUI]
|
||||
// [DEAR IMGUI]
|
||||
// This is a slightly modified version of stb_truetype.h 1.20.
|
||||
// Mostly fixing for compiler and static analyzer warnings.
|
||||
// Grep for [DEAR IMGUI] to find the changes.
|
||||
|
Loading…
Reference in New Issue
Block a user