mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-11-04 07:01:04 +01:00 
			
		
		
		
	Merge branch 'master' into docking
# Conflicts: # imgui.cpp # imgui_internal.h # imgui_widgets.cpp
This commit is contained in:
		
							
								
								
									
										30
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,30 @@
 | 
			
		||||
* text=auto
 | 
			
		||||
 | 
			
		||||
*.c text
 | 
			
		||||
*.cpp text
 | 
			
		||||
*.h text
 | 
			
		||||
*.m text
 | 
			
		||||
*.mm text
 | 
			
		||||
*.md text
 | 
			
		||||
*.txt text
 | 
			
		||||
*.html text
 | 
			
		||||
*.bat text
 | 
			
		||||
*.frag text
 | 
			
		||||
*.vert text
 | 
			
		||||
*.mkb text
 | 
			
		||||
*.icf text
 | 
			
		||||
 | 
			
		||||
*.sln text eol=crlf
 | 
			
		||||
*.vcxproj text eol=crlf
 | 
			
		||||
*.vcxproj.filters text eol=crlf
 | 
			
		||||
*.natvis text eol=crlf
 | 
			
		||||
 | 
			
		||||
Makefile text eol=lf
 | 
			
		||||
*.sh text eol=lf
 | 
			
		||||
*.pbxproj text eol=lf
 | 
			
		||||
*.storyboard text eol=lf
 | 
			
		||||
*.plist text eol=lf
 | 
			
		||||
 | 
			
		||||
*.png binary
 | 
			
		||||
*.ttf binary
 | 
			
		||||
*.lib binary
 | 
			
		||||
							
								
								
									
										200
									
								
								.github/workflows/build.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										200
									
								
								.github/workflows/build.yml
									
									
									
									
										vendored
									
									
								
							@@ -1,36 +1,142 @@
 | 
			
		||||
name: build
 | 
			
		||||
 | 
			
		||||
on: [push, pull_request]
 | 
			
		||||
on:
 | 
			
		||||
  push: {}
 | 
			
		||||
  pull_request: {}
 | 
			
		||||
  schedule:
 | 
			
		||||
    - cron:  '0 9 * * *'
 | 
			
		||||
 | 
			
		||||
jobs:
 | 
			
		||||
  Windows:
 | 
			
		||||
    runs-on: windows-2019
 | 
			
		||||
    env:
 | 
			
		||||
      MSBUILD_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\
 | 
			
		||||
      # Until gh-actions allow us to use env variables inside other env variables (because we need %GITHUB_WORKSPACE%) we have to use relative path to imgui/examples/example_name directory.
 | 
			
		||||
      SDL2_DIR: ..\..\SDL2-devel-2.0.10-VC\SDL2-2.0.10\
 | 
			
		||||
      VULKAN_SDK: ..\..\vulkan-sdk-1.1.121.2\
 | 
			
		||||
    steps:
 | 
			
		||||
      - uses: actions/checkout@v1
 | 
			
		||||
        with:
 | 
			
		||||
          fetch-depth: 1
 | 
			
		||||
 | 
			
		||||
      - name: Install Dependencies
 | 
			
		||||
        shell: powershell
 | 
			
		||||
        run: |
 | 
			
		||||
          Invoke-WebRequest -Uri "https://www.libsdl.org/release/SDL2-devel-2.0.10-VC.zip" -OutFile "SDL2-devel-2.0.10-VC.zip"
 | 
			
		||||
          Expand-Archive -Path SDL2-devel-2.0.10-VC.zip
 | 
			
		||||
          Invoke-WebRequest -Uri "https://github.com/ocornut/imgui/files/3789205/vulkan-sdk-1.1.121.2.zip" -OutFile vulkan-sdk-1.1.121.2.zip
 | 
			
		||||
          Expand-Archive -Path vulkan-sdk-1.1.121.2.zip
 | 
			
		||||
 | 
			
		||||
      - 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
 | 
			
		||||
            # Fix SDK and toolset for most samples.
 | 
			
		||||
            (Get-Content $_.FullName) -Replace "<PlatformToolset>v110</PlatformToolset>","<PlatformToolset>v142</PlatformToolset>" | Set-Content -Path $_.FullName
 | 
			
		||||
            (Get-Content $_.FullName) -Replace "<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>","<WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion>" | Set-Content -Path $_.FullName
 | 
			
		||||
            # Fix SDK and toolset for samples that require newer SDK/toolset. At the moment it is only dx12.
 | 
			
		||||
            (Get-Content $_.FullName) -Replace "<PlatformToolset>v140</PlatformToolset>","<PlatformToolset>v142</PlatformToolset>" | Set-Content -Path $_.FullName
 | 
			
		||||
            (Get-Content $_.FullName) -Replace "<WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>","<WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion>" | Set-Content -Path $_.FullName
 | 
			
		||||
          }
 | 
			
		||||
 | 
			
		||||
      - name: Build x86
 | 
			
		||||
      # Not using matrix here because it would inflate job count too much. Check out and setup is done for every job and that makes build times way too long.
 | 
			
		||||
      - name: Build Win32 example_glfw_opengl2
 | 
			
		||||
        shell: cmd
 | 
			
		||||
        run: |
 | 
			
		||||
          "%MSBUILD_PATH%\MSBuild.exe" /p:Platform=Win32 /p:Configuration=Release examples/imgui_examples.sln
 | 
			
		||||
        run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj /p:Platform=Win32 /p:Configuration=Release'
 | 
			
		||||
 | 
			
		||||
      - name: Build x64
 | 
			
		||||
      - name: Build Win32 example_glfw_opengl3
 | 
			
		||||
        shell: cmd
 | 
			
		||||
        run: |
 | 
			
		||||
          "%MSBUILD_PATH%\MSBuild.exe" /p:Platform=x64 /p:Configuration=Release examples/imgui_examples.sln
 | 
			
		||||
        run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj /p:Platform=Win32 /p:Configuration=Release'
 | 
			
		||||
        if: github.event_name == 'schedule'
 | 
			
		||||
 | 
			
		||||
      - name: Build Win32 example_glfw_vulkan
 | 
			
		||||
        shell: cmd
 | 
			
		||||
        run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj /p:Platform=Win32 /p:Configuration=Release'
 | 
			
		||||
        if: github.event_name == 'schedule'
 | 
			
		||||
 | 
			
		||||
      - name: Build Win32 example_sdl_vulkan
 | 
			
		||||
        shell: cmd
 | 
			
		||||
        run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj /p:Platform=Win32 /p:Configuration=Release'
 | 
			
		||||
        if: github.event_name == 'schedule'
 | 
			
		||||
 | 
			
		||||
      - name: Build Win32 example_sdl_opengl2
 | 
			
		||||
        shell: cmd
 | 
			
		||||
        run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj /p:Platform=Win32 /p:Configuration=Release'
 | 
			
		||||
        if: github.event_name == 'schedule'
 | 
			
		||||
 | 
			
		||||
      - name: Build Win32 example_sdl_opengl3
 | 
			
		||||
        shell: cmd
 | 
			
		||||
        run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj /p:Platform=Win32 /p:Configuration=Release'
 | 
			
		||||
 | 
			
		||||
      - name: Build Win32 example_sdl_directx11
 | 
			
		||||
        shell: cmd
 | 
			
		||||
        run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl_directx11/example_sdl_directx11.vcxproj /p:Platform=Win32 /p:Configuration=Release'
 | 
			
		||||
        if: github.event_name == 'schedule'
 | 
			
		||||
 | 
			
		||||
      - name: Build Win32 example_win32_directx9
 | 
			
		||||
        shell: cmd
 | 
			
		||||
        run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx9/example_win32_directx9.vcxproj /p:Platform=Win32 /p:Configuration=Release'
 | 
			
		||||
 | 
			
		||||
      - name: Build Win32 example_win32_directx10
 | 
			
		||||
        shell: cmd
 | 
			
		||||
        run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx10/example_win32_directx10.vcxproj /p:Platform=Win32 /p:Configuration=Release'
 | 
			
		||||
 | 
			
		||||
      - name: Build Win32 example_win32_directx11
 | 
			
		||||
        shell: cmd
 | 
			
		||||
        run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx11/example_win32_directx11.vcxproj /p:Platform=Win32 /p:Configuration=Release'
 | 
			
		||||
        if: github.event_name == 'schedule'
 | 
			
		||||
 | 
			
		||||
      - name: Build x64 example_glfw_opengl2
 | 
			
		||||
        shell: cmd
 | 
			
		||||
        run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj /p:Platform=x64 /p:Configuration=Release'
 | 
			
		||||
        if: github.event_name == 'schedule'
 | 
			
		||||
 | 
			
		||||
      - name: Build x64 example_glfw_opengl3
 | 
			
		||||
        shell: cmd
 | 
			
		||||
        run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj /p:Platform=x64 /p:Configuration=Release'
 | 
			
		||||
 | 
			
		||||
      - name: Build x64 example_glfw_vulkan
 | 
			
		||||
        shell: cmd
 | 
			
		||||
        run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj /p:Platform=x64 /p:Configuration=Release'
 | 
			
		||||
 | 
			
		||||
      - name: Build x64 example_sdl_vulkan
 | 
			
		||||
        shell: cmd
 | 
			
		||||
        run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj /p:Platform=x64 /p:Configuration=Release'
 | 
			
		||||
        if: github.event_name == 'schedule'
 | 
			
		||||
 | 
			
		||||
      - name: Build x64 example_sdl_opengl2
 | 
			
		||||
        shell: cmd
 | 
			
		||||
        run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj /p:Platform=x64 /p:Configuration=Release'
 | 
			
		||||
        if: github.event_name == 'schedule'
 | 
			
		||||
 | 
			
		||||
      - name: Build x64 example_sdl_opengl3
 | 
			
		||||
        shell: cmd
 | 
			
		||||
        run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj /p:Platform=x64 /p:Configuration=Release'
 | 
			
		||||
        if: github.event_name == 'schedule'
 | 
			
		||||
 | 
			
		||||
      - name: Build x64 example_sdl_directx11
 | 
			
		||||
        shell: cmd
 | 
			
		||||
        run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl_directx11/example_sdl_directx11.vcxproj /p:Platform=x64 /p:Configuration=Release'
 | 
			
		||||
 | 
			
		||||
      - name: Build x64 example_win32_directx9
 | 
			
		||||
        shell: cmd
 | 
			
		||||
        run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx9/example_win32_directx9.vcxproj /p:Platform=x64 /p:Configuration=Release'
 | 
			
		||||
        if: github.event_name == 'schedule'
 | 
			
		||||
 | 
			
		||||
      - name: Build x64 example_win32_directx10
 | 
			
		||||
        shell: cmd
 | 
			
		||||
        run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx10/example_win32_directx10.vcxproj /p:Platform=x64 /p:Configuration=Release'
 | 
			
		||||
        if: github.event_name == 'schedule'
 | 
			
		||||
 | 
			
		||||
      - name: Build x64 example_win32_directx11
 | 
			
		||||
        shell: cmd
 | 
			
		||||
        run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx11/example_win32_directx11.vcxproj /p:Platform=x64 /p:Configuration=Release'
 | 
			
		||||
        if: github.event_name == 'schedule'
 | 
			
		||||
 | 
			
		||||
      - name: Build x64 example_win32_directx12
 | 
			
		||||
        shell: cmd
 | 
			
		||||
        run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx12/example_win32_directx12.vcxproj /p:Platform=x64 /p:Configuration=Release'
 | 
			
		||||
 | 
			
		||||
  Linux:
 | 
			
		||||
    runs-on: ubuntu-18.04
 | 
			
		||||
@@ -44,13 +150,22 @@ jobs:
 | 
			
		||||
        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
 | 
			
		||||
    - name: Build example_null
 | 
			
		||||
      run: make -C examples/example_null
 | 
			
		||||
 | 
			
		||||
    - name: Build example_glfw_opengl2
 | 
			
		||||
      run: make -C examples/example_glfw_opengl2
 | 
			
		||||
 | 
			
		||||
    - name: Build example_glfw_opengl3
 | 
			
		||||
      run: make -C examples/example_glfw_opengl3
 | 
			
		||||
      if: github.event_name == 'schedule'
 | 
			
		||||
 | 
			
		||||
    - name: Build example_sdl_opengl2
 | 
			
		||||
      run: make -C examples/example_sdl_opengl2
 | 
			
		||||
      if: github.event_name == 'schedule'
 | 
			
		||||
 | 
			
		||||
    - name: Build example_sdl_opengl3
 | 
			
		||||
      run: make -C examples/example_sdl_opengl3
 | 
			
		||||
 | 
			
		||||
  MacOS:
 | 
			
		||||
    runs-on: macOS-10.14
 | 
			
		||||
@@ -64,16 +179,31 @@ jobs:
 | 
			
		||||
        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
 | 
			
		||||
    - name: Build example_null
 | 
			
		||||
      run: make -C examples/example_null
 | 
			
		||||
 | 
			
		||||
    - name: Build example_glfw_opengl2
 | 
			
		||||
      run: make -C examples/example_glfw_opengl2
 | 
			
		||||
 | 
			
		||||
    - name: Build example_glfw_opengl3
 | 
			
		||||
      run: make -C examples/example_glfw_opengl3
 | 
			
		||||
      if: github.event_name == 'schedule'
 | 
			
		||||
 | 
			
		||||
    - name: Build example_glfw_metal
 | 
			
		||||
      run: make -C examples/example_glfw_metal
 | 
			
		||||
 | 
			
		||||
    - name: Build example_sdl_opengl2
 | 
			
		||||
      run: make -C examples/example_sdl_opengl2
 | 
			
		||||
      if: github.event_name == 'schedule'
 | 
			
		||||
 | 
			
		||||
    - name: Build example_sdl_opengl3
 | 
			
		||||
      run: make -C examples/example_sdl_opengl3
 | 
			
		||||
 | 
			
		||||
    - name: Build example_apple_metal
 | 
			
		||||
      run: xcodebuild -project examples/example_apple_metal/example_apple_metal.xcodeproj -target example_apple_metal_macos
 | 
			
		||||
 | 
			
		||||
    - name: Build example_apple_opengl2
 | 
			
		||||
      run: xcodebuild -project examples/example_apple_opengl2/example_apple_opengl2.xcodeproj -target example_osx_opengl2
 | 
			
		||||
 | 
			
		||||
  iOS:
 | 
			
		||||
    runs-on: macOS-10.14
 | 
			
		||||
@@ -82,7 +212,7 @@ jobs:
 | 
			
		||||
      with:
 | 
			
		||||
        fetch-depth: 1
 | 
			
		||||
 | 
			
		||||
    - name: Build
 | 
			
		||||
    - name: Build example_apple_metal
 | 
			
		||||
      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
 | 
			
		||||
@@ -96,13 +226,13 @@ jobs:
 | 
			
		||||
 | 
			
		||||
    - 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
 | 
			
		||||
        wget -q https://github.com/emscripten-core/emsdk/archive/master.tar.gz
 | 
			
		||||
        tar -xvf master.tar.gz
 | 
			
		||||
        emsdk-master/emsdk update
 | 
			
		||||
        emsdk-master/emsdk install latest-fastcomp
 | 
			
		||||
        emsdk-master/emsdk activate latest-fastcomp
 | 
			
		||||
 | 
			
		||||
    - name: Build
 | 
			
		||||
    - name: Build example_emscripten
 | 
			
		||||
      run: |
 | 
			
		||||
        source emsdk-portable/emsdk_env.sh
 | 
			
		||||
        source emsdk-master/emsdk_env.sh
 | 
			
		||||
        make -C examples/example_emscripten
 | 
			
		||||
 
 | 
			
		||||
@@ -137,9 +137,11 @@ Other Changes:
 | 
			
		||||
  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
 | 
			
		||||
  to clarify how they are used, and more comments redirecting to the demo code. (#2844)
 | 
			
		||||
- Misc: Windows: Do not use _wfopen() if IMGUI_DISABLE_WIN32_FUNCTIONS is defined. (#2815)
 | 
			
		||||
- 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]
 | 
			
		||||
- Metrics: Expose basic details of each window key/value state storage.
 | 
			
		||||
- 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: OpenGL3: Fix building with pre-3.2 GL loaders which do not expose glDrawElementsBaseVertex(),
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										46
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										46
									
								
								imgui.cpp
									
									
									
									
									
								
							@@ -1407,7 +1407,7 @@ ImU32 ImHashStr(const char* data_p, size_t data_size, ImU32 seed)
 | 
			
		||||
 | 
			
		||||
FILE* ImFileOpen(const char* filename, const char* mode)
 | 
			
		||||
{
 | 
			
		||||
#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__GNUC__)
 | 
			
		||||
#if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(__CYGWIN__) && !defined(__GNUC__)
 | 
			
		||||
    // We need a fopen() wrapper because MSVC/Windows fopen doesn't handle UTF-8 filenames. Converting both strings from UTF-8 to wchar format (using a single allocation, because we can)
 | 
			
		||||
    const int filename_wsize = ImTextCountCharsFromUtf8(filename, NULL) + 1;
 | 
			
		||||
    const int mode_wsize = ImTextCountCharsFromUtf8(mode, NULL) + 1;
 | 
			
		||||
@@ -6289,14 +6289,14 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
 | 
			
		||||
        window->WorkRect.Max.x = window->WorkRect.Min.x + work_rect_size_x;
 | 
			
		||||
        window->WorkRect.Max.y = window->WorkRect.Min.y + work_rect_size_y;
 | 
			
		||||
 | 
			
		||||
        // [LEGACY] Contents Region
 | 
			
		||||
        // FIXME-OBSOLETE: window->ContentsRegionRect.Max is currently very misleading / partly faulty, but some BeginChild() patterns relies on it.
 | 
			
		||||
        // [LEGACY] Content Region
 | 
			
		||||
        // FIXME-OBSOLETE: window->ContentRegionRect.Max is currently very misleading / partly faulty, but some BeginChild() patterns relies on it.
 | 
			
		||||
        // Used by:
 | 
			
		||||
        // - Mouse wheel scrolling + many other things
 | 
			
		||||
        window->ContentsRegionRect.Min.x = window->Pos.x - window->Scroll.x + window->WindowPadding.x;
 | 
			
		||||
        window->ContentsRegionRect.Min.y = window->Pos.y - window->Scroll.y + window->WindowPadding.y + decoration_up_height;
 | 
			
		||||
        window->ContentsRegionRect.Max.x = window->ContentsRegionRect.Min.x + (window->ContentSizeExplicit.x != 0.0f ? window->ContentSizeExplicit.x : (window->Size.x - window->WindowPadding.x * 2.0f - window->ScrollbarSizes.x));
 | 
			
		||||
        window->ContentsRegionRect.Max.y = window->ContentsRegionRect.Min.y + (window->ContentSizeExplicit.y != 0.0f ? window->ContentSizeExplicit.y : (window->Size.y - window->WindowPadding.y * 2.0f - decoration_up_height - window->ScrollbarSizes.y));
 | 
			
		||||
        window->ContentRegionRect.Min.x = window->Pos.x - window->Scroll.x + window->WindowPadding.x;
 | 
			
		||||
        window->ContentRegionRect.Min.y = window->Pos.y - window->Scroll.y + window->WindowPadding.y + decoration_up_height;
 | 
			
		||||
        window->ContentRegionRect.Max.x = window->ContentRegionRect.Min.x + (window->ContentSizeExplicit.x != 0.0f ? window->ContentSizeExplicit.x : (window->Size.x - window->WindowPadding.x * 2.0f - window->ScrollbarSizes.x));
 | 
			
		||||
        window->ContentRegionRect.Max.y = window->ContentRegionRect.Min.y + (window->ContentSizeExplicit.y != 0.0f ? window->ContentSizeExplicit.y : (window->Size.y - window->WindowPadding.y * 2.0f - decoration_up_height - window->ScrollbarSizes.y));
 | 
			
		||||
 | 
			
		||||
        // Setup drawing context
 | 
			
		||||
        // (NB: That term "drawing context / DC" lost its meaning a long time ago. Initially was meant to hold transient data only. Nowadays difference between window-> and window->DC-> is dubious.)
 | 
			
		||||
@@ -7316,7 +7316,7 @@ ImVec2 ImGui::GetContentRegionMax()
 | 
			
		||||
{
 | 
			
		||||
    ImGuiContext& g = *GImGui;
 | 
			
		||||
    ImGuiWindow* window = g.CurrentWindow;
 | 
			
		||||
    ImVec2 mx = window->ContentsRegionRect.Max - window->Pos;
 | 
			
		||||
    ImVec2 mx = window->ContentRegionRect.Max - window->Pos;
 | 
			
		||||
    if (window->DC.CurrentColumns)
 | 
			
		||||
        mx.x = window->WorkRect.Max.x - window->Pos.x;
 | 
			
		||||
    return mx;
 | 
			
		||||
@@ -7327,7 +7327,7 @@ ImVec2 ImGui::GetContentRegionMaxAbs()
 | 
			
		||||
{
 | 
			
		||||
    ImGuiContext& g = *GImGui;
 | 
			
		||||
    ImGuiWindow* window = g.CurrentWindow;
 | 
			
		||||
    ImVec2 mx = window->ContentsRegionRect.Max;
 | 
			
		||||
    ImVec2 mx = window->ContentRegionRect.Max;
 | 
			
		||||
    if (window->DC.CurrentColumns)
 | 
			
		||||
        mx.x = window->WorkRect.Max.x;
 | 
			
		||||
    return mx;
 | 
			
		||||
@@ -7343,19 +7343,19 @@ ImVec2 ImGui::GetContentRegionAvail()
 | 
			
		||||
ImVec2 ImGui::GetWindowContentRegionMin()
 | 
			
		||||
{
 | 
			
		||||
    ImGuiWindow* window = GImGui->CurrentWindow;
 | 
			
		||||
    return window->ContentsRegionRect.Min - window->Pos;
 | 
			
		||||
    return window->ContentRegionRect.Min - window->Pos;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ImVec2 ImGui::GetWindowContentRegionMax()
 | 
			
		||||
{
 | 
			
		||||
    ImGuiWindow* window = GImGui->CurrentWindow;
 | 
			
		||||
    return window->ContentsRegionRect.Max - window->Pos;
 | 
			
		||||
    return window->ContentRegionRect.Max - window->Pos;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
float ImGui::GetWindowContentRegionWidth()
 | 
			
		||||
{
 | 
			
		||||
    ImGuiWindow* window = GImGui->CurrentWindow;
 | 
			
		||||
    return window->ContentsRegionRect.GetWidth();
 | 
			
		||||
    return window->ContentRegionRect.GetWidth();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
float ImGui::GetTextLineHeight()
 | 
			
		||||
@@ -14677,8 +14677,8 @@ void ImGui::ShowMetricsWindow(bool* p_open)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // State
 | 
			
		||||
    enum { WRT_OuterRect, WRT_OuterRectClipped, WRT_InnerRect, WRT_InnerClipRect, WRT_WorkRect, WRT_Contents, WRT_ContentsRegionRect, WRT_Count }; // Windows Rect Type
 | 
			
		||||
    const char* wrt_rects_names[WRT_Count] = { "OuterRect", "OuterRectClipped", "InnerRect", "InnerClipRect", "WorkRect", "Contents", "ContentsRegionRect" };
 | 
			
		||||
    enum { WRT_OuterRect, WRT_OuterRectClipped, WRT_InnerRect, WRT_InnerClipRect, WRT_WorkRect, WRT_Content, WRT_ContentRegionRect, WRT_Count }; // Windows Rect Type
 | 
			
		||||
    const char* wrt_rects_names[WRT_Count] = { "OuterRect", "OuterRectClipped", "InnerRect", "InnerClipRect", "WorkRect", "Content", "ContentRegionRect" };
 | 
			
		||||
    static bool show_windows_rects = false;
 | 
			
		||||
    static int  show_windows_rect_type = WRT_WorkRect;
 | 
			
		||||
    static bool show_windows_begin_order = false;
 | 
			
		||||
@@ -14712,8 +14712,8 @@ void ImGui::ShowMetricsWindow(bool* p_open)
 | 
			
		||||
            else if (rect_type == WRT_InnerRect)            { return window->InnerRect; }
 | 
			
		||||
            else if (rect_type == WRT_InnerClipRect)        { return window->InnerClipRect; }
 | 
			
		||||
            else if (rect_type == WRT_WorkRect)             { return window->WorkRect; }
 | 
			
		||||
            else if (rect_type == WRT_Contents)             { ImVec2 min = window->InnerRect.Min - window->Scroll + window->WindowPadding; return ImRect(min, min + window->ContentSize); }
 | 
			
		||||
            else if (rect_type == WRT_ContentsRegionRect)   { return window->ContentsRegionRect; }
 | 
			
		||||
            else if (rect_type == WRT_Content)              { ImVec2 min = window->InnerRect.Min - window->Scroll + window->WindowPadding; return ImRect(min, min + window->ContentSize); }
 | 
			
		||||
            else if (rect_type == WRT_ContentRegionRect)    { return window->ContentRegionRect; }
 | 
			
		||||
            IM_ASSERT(0);
 | 
			
		||||
            return ImRect();
 | 
			
		||||
        }
 | 
			
		||||
@@ -14846,7 +14846,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
 | 
			
		||||
                    NodeColumns(&window->ColumnsStorage[n]);
 | 
			
		||||
                ImGui::TreePop();
 | 
			
		||||
            }
 | 
			
		||||
            ImGui::BulletText("Storage: %d bytes", window->StateStorage.Data.size_in_bytes());
 | 
			
		||||
            NodeStorage(&window->StateStorage, "Storage");
 | 
			
		||||
            ImGui::TreePop();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -14949,6 +14949,18 @@ void ImGui::ShowMetricsWindow(bool* p_open)
 | 
			
		||||
                ImGui::TreePop();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        static void NodeStorage(ImGuiStorage* storage, const char* label)
 | 
			
		||||
        {
 | 
			
		||||
            if (!ImGui::TreeNode(label, "%s: %d entries, %d bytes", label, storage->Data.Size, storage->Data.size_in_bytes()))
 | 
			
		||||
                return;
 | 
			
		||||
            for (int n = 0; n < storage->Data.Size; n++)
 | 
			
		||||
            {
 | 
			
		||||
                const ImGuiStorage::ImGuiStoragePair& p = storage->Data[n];
 | 
			
		||||
                ImGui::BulletText("Key 0x%08X Value { i: %d }", p.key, p.val_i); // Important: we currently don't store a type, real value may not be integer.
 | 
			
		||||
            }
 | 
			
		||||
            ImGui::TreePop();
 | 
			
		||||
        }
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    Funcs::NodeWindows(g.Windows, "Windows");
 | 
			
		||||
 
 | 
			
		||||
@@ -1515,9 +1515,9 @@ struct IMGUI_API ImGuiWindow
 | 
			
		||||
    ImRect                  OuterRectClipped;                   // == Window->Rect() just after setup in Begin(). == window->Rect() for root window.
 | 
			
		||||
    ImRect                  InnerRect;                          // Inner rectangle (omit title bar, menu bar, scroll bar)
 | 
			
		||||
    ImRect                  InnerClipRect;                      // == InnerRect shrunk by WindowPadding*0.5f on each side, clipped within viewport or parent clip rect.
 | 
			
		||||
    ImRect                  WorkRect;                           // Cover the whole scrolling region, shrunk by WindowPadding*1.0f on each side. This is meant to replace ContentsRegionRect over time (from 1.71+ onward).
 | 
			
		||||
    ImRect                  WorkRect;                           // Cover the whole scrolling region, shrunk by WindowPadding*1.0f on each side. This is meant to replace ContentRegionRect over time (from 1.71+ onward).
 | 
			
		||||
    ImRect                  ClipRect;                           // Current clipping/scissoring rectangle, evolve as we are using PushClipRect(), etc. == DrawList->clip_rect_stack.back().
 | 
			
		||||
    ImRect                  ContentsRegionRect;                 // FIXME: This is currently confusing/misleading. It is essentially WorkRect but not handling of scrolling. We currently rely on it as right/bottom aligned sizing operation need some size to rely on.
 | 
			
		||||
    ImRect                  ContentRegionRect;                  // FIXME: This is currently confusing/misleading. It is essentially WorkRect but not handling of scrolling. We currently rely on it as right/bottom aligned sizing operation need some size to rely on.
 | 
			
		||||
    ImVec2ih                HitTestHoleSize, HitTestHoleOffset;
 | 
			
		||||
 | 
			
		||||
    int                     LastFrameActive;                    // Last frame number the window was Active.
 | 
			
		||||
@@ -1607,7 +1607,7 @@ enum ImGuiTabBarFlagsPrivate_
 | 
			
		||||
// Extend ImGuiTabItemFlags_
 | 
			
		||||
enum ImGuiTabItemFlagsPrivate_
 | 
			
		||||
{
 | 
			
		||||
    ImGuiTabItemFlags_NoCloseButton             = 1 << 20,  // Store whether p_open is set or not, which we need to recompute WidthContents during layout.
 | 
			
		||||
    ImGuiTabItemFlags_NoCloseButton             = 1 << 20,  // Store whether p_open is set or not, which we need to recompute ContentWidth during layout.
 | 
			
		||||
    ImGuiTabItemFlags_Unsorted                  = 1 << 21,  // [Docking] Trailing tabs with the _Unsorted flag will be sorted based on the DockOrder of their Window.
 | 
			
		||||
    ImGuiTabItemFlags_Preview                   = 1 << 22   // [Docking] Display tab shape for docking preview (height is adjusted slightly to compensate for the yet missing tab bar)
 | 
			
		||||
};
 | 
			
		||||
@@ -1623,9 +1623,9 @@ struct ImGuiTabItem
 | 
			
		||||
    int                 NameOffset;             // When Window==NULL, offset to name within parent ImGuiTabBar::TabsNames
 | 
			
		||||
    float               Offset;                 // Position relative to beginning of tab
 | 
			
		||||
    float               Width;                  // Width currently displayed
 | 
			
		||||
    float               WidthContents;          // Width of actual contents, stored during BeginTabItem() call
 | 
			
		||||
    float               ContentWidth;           // Width of actual contents, stored during BeginTabItem() call
 | 
			
		||||
 | 
			
		||||
    ImGuiTabItem()      { ID = Flags = 0; Window = NULL; LastFrameVisible = LastFrameSelected = -1; NameOffset = -1; Offset = Width = WidthContents = 0.0f; }
 | 
			
		||||
    ImGuiTabItem()      { ID = Flags = 0; Window = NULL; LastFrameVisible = LastFrameSelected = -1; NameOffset = -1; Offset = Width = ContentWidth = 0.0f; }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// Storage for a tab bar (sizeof() 92~96 bytes)
 | 
			
		||||
 
 | 
			
		||||
@@ -6585,13 +6585,13 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
 | 
			
		||||
        // and we cannot wait for the next BeginTabItem() call. We cannot compute this width within TabBarAddTab() because font size depends on the active window.
 | 
			
		||||
        const char* tab_name = tab_bar->GetTabName(tab);
 | 
			
		||||
        const bool has_close_button = tab->Window ? tab->Window->HasCloseButton : ((tab->Flags & ImGuiTabItemFlags_NoCloseButton) == 0);
 | 
			
		||||
        tab->WidthContents = TabItemCalcSize(tab_name, has_close_button).x;
 | 
			
		||||
        tab->ContentWidth = TabItemCalcSize(tab_name, has_close_button).x;
 | 
			
		||||
 | 
			
		||||
        width_total_contents += (tab_n > 0 ? g.Style.ItemInnerSpacing.x : 0.0f) + tab->WidthContents;
 | 
			
		||||
        width_total_contents += (tab_n > 0 ? g.Style.ItemInnerSpacing.x : 0.0f) + tab->ContentWidth;
 | 
			
		||||
 | 
			
		||||
        // Store data so we can build an array sorted by width if we need to shrink tabs down
 | 
			
		||||
        g.ShrinkWidthBuffer[tab_n].Index = tab_n;
 | 
			
		||||
        g.ShrinkWidthBuffer[tab_n].Width = tab->WidthContents;
 | 
			
		||||
        g.ShrinkWidthBuffer[tab_n].Width = tab->ContentWidth;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Compute width
 | 
			
		||||
@@ -6611,7 +6611,7 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
 | 
			
		||||
        for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++)
 | 
			
		||||
        {
 | 
			
		||||
            ImGuiTabItem* tab = &tab_bar->Tabs[tab_n];
 | 
			
		||||
            tab->Width = ImMin(tab->WidthContents, tab_max_width);
 | 
			
		||||
            tab->Width = ImMin(tab->ContentWidth, tab_max_width);
 | 
			
		||||
            IM_ASSERT(tab->Width > 0.0f);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@@ -6627,7 +6627,7 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
 | 
			
		||||
        if (scroll_track_selected_tab_id == 0 && g.NavJustMovedToId == tab->ID)
 | 
			
		||||
            scroll_track_selected_tab_id = tab->ID;
 | 
			
		||||
        offset_x += tab->Width + g.Style.ItemInnerSpacing.x;
 | 
			
		||||
        offset_x_ideal += tab->WidthContents + g.Style.ItemInnerSpacing.x;
 | 
			
		||||
        offset_x_ideal += tab->ContentWidth + g.Style.ItemInnerSpacing.x;
 | 
			
		||||
    }
 | 
			
		||||
    tab_bar->OffsetMax = ImMax(offset_x - g.Style.ItemInnerSpacing.x, 0.0f);
 | 
			
		||||
    tab_bar->OffsetMaxIdeal = ImMax(offset_x_ideal - g.Style.ItemInnerSpacing.x, 0.0f);
 | 
			
		||||
@@ -6983,7 +6983,7 @@ bool    ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
 | 
			
		||||
        tab_is_new = true;
 | 
			
		||||
    }
 | 
			
		||||
    tab_bar->LastTabItemIdx = (short)tab_bar->Tabs.index_from_ptr(tab);
 | 
			
		||||
    tab->WidthContents = size.x;
 | 
			
		||||
    tab->ContentWidth = size.x;
 | 
			
		||||
 | 
			
		||||
    if (p_open == NULL)
 | 
			
		||||
        flags |= ImGuiTabItemFlags_NoCloseButton;
 | 
			
		||||
@@ -7147,10 +7147,10 @@ bool    ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
    if (hovered && g.HoveredIdNotActiveTimer > 0.50f && bb.GetWidth() < tab->WidthContents)
 | 
			
		||||
    if (hovered && g.HoveredIdNotActiveTimer > 0.50f && bb.GetWidth() < tab->ContentWidth)
 | 
			
		||||
    {
 | 
			
		||||
        // Enlarge tab display when hovering
 | 
			
		||||
        bb.Max.x = bb.Min.x + IM_FLOOR(ImLerp(bb.GetWidth(), tab->WidthContents, ImSaturate((g.HoveredIdNotActiveTimer - 0.40f) * 6.0f)));
 | 
			
		||||
        bb.Max.x = bb.Min.x + IM_FLOOR(ImLerp(bb.GetWidth(), tab->ContentWidth, ImSaturate((g.HoveredIdNotActiveTimer - 0.40f) * 6.0f)));
 | 
			
		||||
        display_draw_list = GetForegroundDrawList(window);
 | 
			
		||||
        TabItemBackground(display_draw_list, bb, flags, GetColorU32(ImGuiCol_TitleBgActive));
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user