forked from Green-Sky/tomato
Compare commits
1 Commits
master
...
tracypatch
Author | SHA1 | Date | |
---|---|---|---|
f784f91798 |
66
.github/workflows/cd.yml
vendored
66
.github/workflows/cd.yml
vendored
@ -7,28 +7,28 @@ on:
|
|||||||
branches: [ master ]
|
branches: [ master ]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
BUILD_TYPE: RelWithDebInfo
|
BUILD_TYPE: Release
|
||||||
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
|
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
linux-ubuntu:
|
linux-ubuntu:
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-20.04
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: sudo apt update && sudo apt -y install libsodium-dev cmake
|
run: sudo apt update && sudo apt -y install libsodium-dev
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||||
|
|
||||||
- name: Determine tag name
|
- name: Determine tag name
|
||||||
id: tag
|
id: tag
|
||||||
@ -37,10 +37,10 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
|
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
|
||||||
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
|
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
|
||||||
echo "name=dev-${SHORT_HASH}" >> $GITHUB_OUTPUT
|
echo "name=${SHORT_HASH}" >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
|
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
|
||||||
echo "name=dev-${SAFE_NAME}-${SHORT_HASH}" >> $GITHUB_OUTPUT
|
echo "name=${SAFE_NAME}-${SHORT_HASH}" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Compress artifacts
|
- name: Compress artifacts
|
||||||
@ -63,32 +63,23 @@ jobs:
|
|||||||
runs-on: windows-2019
|
runs-on: windows-2019
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
- name: update vcpkg
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
cd C:/vcpkg
|
|
||||||
git pull
|
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: vcpkg install libsodium:x64-windows-static pthreads:x64-windows-static pkgconf:x64-windows
|
run: vcpkg install libsodium:x64-windows-static pthreads:x64-windows-static
|
||||||
|
|
||||||
# setup vs env
|
# setup vs env
|
||||||
- uses: ilammy/msvc-dev-cmd@v1
|
- uses: ilammy/msvc-dev-cmd@v1
|
||||||
with:
|
with:
|
||||||
arch: amd64
|
arch: amd64
|
||||||
|
|
||||||
## sdl_image vendored needs nasm for dav1d
|
|
||||||
#- uses: ilammy/setup-nasm@v1
|
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DSDL3IMAGE_VENDORED=ON -DSDL3IMAGE_DEPS_SHARED=ON -DSDL3IMAGE_JXL=OFF -DSDL3IMAGE_AVIF=OFF -DPKG_CONFIG_EXECUTABLE=C:/vcpkg/installed/x64-windows/tools/pkgconf/pkgconf.exe
|
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -t tomato
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
||||||
|
|
||||||
- name: Determine tag name
|
- name: Determine tag name
|
||||||
id: tag
|
id: tag
|
||||||
@ -97,10 +88,10 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
|
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
|
||||||
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
|
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
|
||||||
echo "name=dev-${SHORT_HASH}" >> $GITHUB_OUTPUT
|
echo "name=${SHORT_HASH}" >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
|
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
|
||||||
echo "name=dev-${SAFE_NAME}-${SHORT_HASH}" >> $GITHUB_OUTPUT
|
echo "name=${SAFE_NAME}-${SHORT_HASH}" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Compress artifacts
|
- name: Compress artifacts
|
||||||
@ -123,32 +114,23 @@ jobs:
|
|||||||
runs-on: windows-2019
|
runs-on: windows-2019
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
- name: update vcpkg
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
cd C:/vcpkg
|
|
||||||
git pull
|
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: vcpkg install libsodium:x64-windows-static pthreads:x64-windows-static pkgconf:x64-windows
|
run: vcpkg install libsodium:x64-windows-static pthreads:x64-windows-static
|
||||||
|
|
||||||
# setup vs env
|
# setup vs env
|
||||||
- uses: ilammy/msvc-dev-cmd@v1
|
- uses: ilammy/msvc-dev-cmd@v1
|
||||||
with:
|
with:
|
||||||
arch: amd64
|
arch: amd64
|
||||||
|
|
||||||
## sdl_image vendored needs nasm for dav1d
|
|
||||||
#- uses: ilammy/setup-nasm@v1
|
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DTOMATO_ASAN=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DSDL3IMAGE_VENDORED=ON -DSDL3IMAGE_DEPS_SHARED=ON -DSDL3IMAGE_JXL=OFF -DSDL3IMAGE_AVIF=OFF -DPKG_CONFIG_EXECUTABLE=C:/vcpkg/installed/x64-windows/tools/pkgconf/pkgconf.exe
|
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DTOMATO_ASAN=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||||
|
|
||||||
- name: Determine tag name
|
- name: Determine tag name
|
||||||
id: tag
|
id: tag
|
||||||
@ -157,10 +139,10 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
|
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
|
||||||
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
|
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
|
||||||
echo "name=dev-${SHORT_HASH}" >> $GITHUB_OUTPUT
|
echo "name=${SHORT_HASH}" >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
|
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
|
||||||
echo "name=dev-${SAFE_NAME}-${SHORT_HASH}" >> $GITHUB_OUTPUT
|
echo "name=${SAFE_NAME}-${SHORT_HASH}" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Compress artifacts
|
- name: Compress artifacts
|
||||||
@ -190,7 +172,7 @@ jobs:
|
|||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
@ -201,10 +183,10 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
|
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
|
||||||
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
|
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
|
||||||
echo "name=dev-${SHORT_HASH}" >> $GITHUB_OUTPUT
|
echo "name=${SHORT_HASH}" >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
|
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
|
||||||
echo "name=dev-${SAFE_NAME}-${SHORT_HASH}" >> $GITHUB_OUTPUT
|
echo "name=${SAFE_NAME}-${SHORT_HASH}" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Download artifacts
|
- name: Download artifacts
|
||||||
@ -221,8 +203,8 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
gh release create "$tag" \
|
gh release create "$tag" \
|
||||||
--repo="$GITHUB_REPOSITORY" \
|
--repo="$GITHUB_REPOSITORY" \
|
||||||
--title="${tag#v}" \
|
--title="nightly ${tag#v}" \
|
||||||
--notes="preview build of the latest commit" \
|
--notes="nightly build" \
|
||||||
--prerelease
|
--prerelease
|
||||||
|
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
|
30
.github/workflows/ci.yml
vendored
30
.github/workflows/ci.yml
vendored
@ -16,18 +16,18 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: sudo apt update && sudo apt -y install libsodium-dev cmake
|
run: sudo apt update && sudo apt -y install libsodium-dev
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||||
|
|
||||||
macos:
|
macos:
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
@ -35,7 +35,7 @@ jobs:
|
|||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
@ -46,39 +46,29 @@ jobs:
|
|||||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||||
|
|
||||||
windows:
|
windows:
|
||||||
timeout-minutes: 15
|
timeout-minutes: 10
|
||||||
|
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
- name: update vcpkg
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
cd C:/vcpkg
|
|
||||||
git pull
|
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: vcpkg install libsodium:x64-windows-static pthreads:x64-windows-static pkgconf:x64-windows
|
run: vcpkg install libsodium:x64-windows-static pthreads:x64-windows-static
|
||||||
|
|
||||||
# setup vs env
|
# setup vs env
|
||||||
- uses: ilammy/msvc-dev-cmd@v1
|
- uses: ilammy/msvc-dev-cmd@v1
|
||||||
with:
|
with:
|
||||||
arch: amd64
|
arch: amd64
|
||||||
|
|
||||||
## sdl_image vendored needs nasm for dav1d
|
|
||||||
#- uses: ilammy/setup-nasm@v1
|
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DSDL3IMAGE_VENDORED=ON -DSDL3IMAGE_DEPS_SHARED=ON -DSDL3IMAGE_JXL=OFF -DSDL3IMAGE_AVIF=OFF -DPKG_CONFIG_EXECUTABLE=C:/vcpkg/installed/x64-windows/tools/pkgconf/pkgconf.exe
|
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4 -t tomato
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j 4
|
||||||
|
|
||||||
|
|
||||||
|
6
.gitmodules
vendored
6
.gitmodules
vendored
@ -20,9 +20,3 @@
|
|||||||
[submodule "external/solanaceae_plugin"]
|
[submodule "external/solanaceae_plugin"]
|
||||||
path = external/solanaceae_plugin
|
path = external/solanaceae_plugin
|
||||||
url = https://github.com/Green-Sky/solanaceae_plugin.git
|
url = https://github.com/Green-Sky/solanaceae_plugin.git
|
||||||
[submodule "external/solanaceae_object_store"]
|
|
||||||
path = external/solanaceae_object_store
|
|
||||||
url = https://github.com/Green-Sky/solanaceae_object_store.git
|
|
||||||
[submodule "external/solanaceae_message_serializer"]
|
|
||||||
path = external/solanaceae_message_serializer
|
|
||||||
url = https://github.com/Green-Sky/solanaceae_message_serializer.git
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
cmake_minimum_required(VERSION 3.14...3.24 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.14...3.24 FATAL_ERROR)
|
||||||
|
|
||||||
#pingpong
|
|
||||||
|
|
||||||
# cmake setup begin
|
# cmake setup begin
|
||||||
project(tomato)
|
project(tomato)
|
||||||
|
|
||||||
@ -25,8 +23,8 @@ option(TOMATO_ASAN "Build tomato with asan (gcc/clang/msvc)" OFF)
|
|||||||
if (TOMATO_ASAN)
|
if (TOMATO_ASAN)
|
||||||
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
|
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
|
||||||
if (NOT WIN32) # exclude mingw
|
if (NOT WIN32) # exclude mingw
|
||||||
#link_libraries(-fsanitize=address)
|
link_libraries(-fsanitize=address)
|
||||||
link_libraries(-fsanitize=address,undefined)
|
#link_libraries(-fsanitize=address,undefined)
|
||||||
#link_libraries(-fsanitize=undefined)
|
#link_libraries(-fsanitize=undefined)
|
||||||
message("II enabled ASAN")
|
message("II enabled ASAN")
|
||||||
else()
|
else()
|
||||||
@ -40,10 +38,6 @@ if (TOMATO_ASAN)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# uggly, but it needs to be defined for all of tomato.
|
|
||||||
# but this also means that we can not compile tomato in the same cmake as plugins
|
|
||||||
add_compile_definitions(ENTT_API_EXPORT)
|
|
||||||
|
|
||||||
# external libs
|
# external libs
|
||||||
add_subdirectory(./external) # before increasing warn levels, sad :(
|
add_subdirectory(./external) # before increasing warn levels, sad :(
|
||||||
|
|
||||||
|
8
external/CMakeLists.txt
vendored
8
external/CMakeLists.txt
vendored
@ -1,11 +1,12 @@
|
|||||||
cmake_minimum_required(VERSION 3.14...3.24 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
||||||
|
|
||||||
|
add_subdirectory(./tracy)
|
||||||
|
|
||||||
add_subdirectory(./entt)
|
add_subdirectory(./entt)
|
||||||
|
|
||||||
add_subdirectory(./solanaceae_util)
|
add_subdirectory(./solanaceae_util)
|
||||||
add_subdirectory(./solanaceae_contact)
|
add_subdirectory(./solanaceae_contact)
|
||||||
add_subdirectory(./solanaceae_message3)
|
add_subdirectory(./solanaceae_message3)
|
||||||
add_subdirectory(./solanaceae_message_serializer)
|
|
||||||
|
|
||||||
add_subdirectory(./solanaceae_plugin)
|
add_subdirectory(./solanaceae_plugin)
|
||||||
|
|
||||||
@ -13,13 +14,10 @@ add_subdirectory(./toxcore)
|
|||||||
add_subdirectory(./solanaceae_toxcore)
|
add_subdirectory(./solanaceae_toxcore)
|
||||||
add_subdirectory(./solanaceae_tox)
|
add_subdirectory(./solanaceae_tox)
|
||||||
|
|
||||||
add_subdirectory(./solanaceae_object_store)
|
|
||||||
|
|
||||||
add_subdirectory(./sdl)
|
add_subdirectory(./sdl)
|
||||||
add_subdirectory(./imgui)
|
add_subdirectory(./imgui)
|
||||||
|
|
||||||
add_subdirectory(./stb)
|
add_subdirectory(./stb)
|
||||||
add_subdirectory(./libwebp)
|
add_subdirectory(./libwebp)
|
||||||
add_subdirectory(./qoi)
|
add_subdirectory(./qoi)
|
||||||
add_subdirectory(./sdl_image)
|
|
||||||
|
|
||||||
|
16
external/imgui/imgui/.github/workflows/build.yml
vendored
16
external/imgui/imgui/.github/workflows/build.yml
vendored
@ -21,7 +21,7 @@ jobs:
|
|||||||
VS_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\
|
VS_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\
|
||||||
MSBUILD_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\
|
MSBUILD_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
shell: powershell
|
shell: powershell
|
||||||
@ -209,7 +209,7 @@ jobs:
|
|||||||
Linux:
|
Linux:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: |
|
run: |
|
||||||
@ -402,7 +402,7 @@ jobs:
|
|||||||
MacOS:
|
MacOS:
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: |
|
run: |
|
||||||
@ -462,7 +462,7 @@ jobs:
|
|||||||
iOS:
|
iOS:
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Build example_apple_metal
|
- name: Build example_apple_metal
|
||||||
run: |
|
run: |
|
||||||
@ -472,7 +472,7 @@ jobs:
|
|||||||
Emscripten:
|
Emscripten:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: |
|
run: |
|
||||||
@ -489,17 +489,17 @@ jobs:
|
|||||||
popd
|
popd
|
||||||
make -C examples/example_sdl2_opengl3 -f Makefile.emscripten
|
make -C examples/example_sdl2_opengl3 -f Makefile.emscripten
|
||||||
|
|
||||||
- name: Build example_glfw_wgpu
|
- name: Build example_emscripten_wgpu
|
||||||
run: |
|
run: |
|
||||||
pushd emsdk-master
|
pushd emsdk-master
|
||||||
source ./emsdk_env.sh
|
source ./emsdk_env.sh
|
||||||
popd
|
popd
|
||||||
make -C examples/example_glfw_wgpu -f Makefile.emscripten
|
make -C examples/example_emscripten_wgpu
|
||||||
|
|
||||||
Android:
|
Android:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Build example_android_opengl3
|
- name: Build example_android_opengl3
|
||||||
run: |
|
run: |
|
||||||
|
@ -12,7 +12,7 @@ jobs:
|
|||||||
PVS-Studio:
|
PVS-Studio:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
fetch-depth: 1
|
fetch-depth: 1
|
||||||
|
|
||||||
|
3
external/imgui/imgui/.gitignore
vendored
3
external/imgui/imgui/.gitignore
vendored
@ -40,9 +40,8 @@ examples/*.o.tmp
|
|||||||
examples/*.out.js
|
examples/*.out.js
|
||||||
examples/*.out.wasm
|
examples/*.out.wasm
|
||||||
examples/example_glfw_opengl3/web/*
|
examples/example_glfw_opengl3/web/*
|
||||||
examples/example_glfw_wgpu/web/*
|
|
||||||
examples/example_glfw_wgpu/external/*
|
|
||||||
examples/example_sdl2_opengl3/web/*
|
examples/example_sdl2_opengl3/web/*
|
||||||
|
examples/example_emscripten_wgpu/web/*
|
||||||
|
|
||||||
## JetBrains IDE artifacts
|
## JetBrains IDE artifacts
|
||||||
.idea
|
.idea
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
// 2022-01-17: Inputs: calling new io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() API (1.87+).
|
// 2022-01-17: Inputs: calling new io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() API (1.87+).
|
||||||
// 2022-01-17: Inputs: always calling io.AddKeyModsEvent() next and before key event (not in NewFrame) to fix input queue with very low framerates.
|
// 2022-01-17: Inputs: always calling io.AddKeyModsEvent() next and before key event (not in NewFrame) to fix input queue with very low framerates.
|
||||||
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
|
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
|
||||||
// 2021-12-08: Renderer: Fixed mishandling of the ImDrawCmd::IdxOffset field! This is an old bug but it never had an effect until some internal rendering changes in 1.86.
|
// 2021-12-08: Renderer: Fixed mishandling of the the ImDrawCmd::IdxOffset field! This is an old bug but it never had an effect until some internal rendering changes in 1.86.
|
||||||
// 2021-08-17: Calling io.AddFocusEvent() on ALLEGRO_EVENT_DISPLAY_SWITCH_OUT/ALLEGRO_EVENT_DISPLAY_SWITCH_IN events.
|
// 2021-08-17: Calling io.AddFocusEvent() on ALLEGRO_EVENT_DISPLAY_SWITCH_OUT/ALLEGRO_EVENT_DISPLAY_SWITCH_IN events.
|
||||||
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
||||||
// 2021-05-19: Renderer: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
|
// 2021-05-19: Renderer: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
|
||||||
@ -423,7 +423,6 @@ static ImGuiKey ImGui_ImplAllegro5_KeyCodeToImGuiKey(int key_code)
|
|||||||
bool ImGui_ImplAllegro5_Init(ALLEGRO_DISPLAY* display)
|
bool ImGui_ImplAllegro5_Init(ALLEGRO_DISPLAY* display)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
IMGUI_CHECKVERSION();
|
|
||||||
IM_ASSERT(io.BackendPlatformUserData == nullptr && "Already initialized a platform backend!");
|
IM_ASSERT(io.BackendPlatformUserData == nullptr && "Already initialized a platform backend!");
|
||||||
|
|
||||||
// Setup backend capabilities flags
|
// Setup backend capabilities flags
|
||||||
@ -491,9 +490,8 @@ static void ImGui_ImplAllegro5_UpdateKeyModifiers()
|
|||||||
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
|
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
|
||||||
bool ImGui_ImplAllegro5_ProcessEvent(ALLEGRO_EVENT* ev)
|
bool ImGui_ImplAllegro5_ProcessEvent(ALLEGRO_EVENT* ev)
|
||||||
{
|
{
|
||||||
ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData();
|
|
||||||
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplAllegro5_Init()?");
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData();
|
||||||
|
|
||||||
switch (ev->type)
|
switch (ev->type)
|
||||||
{
|
{
|
||||||
@ -588,7 +586,7 @@ static void ImGui_ImplAllegro5_UpdateMouseCursor()
|
|||||||
void ImGui_ImplAllegro5_NewFrame()
|
void ImGui_ImplAllegro5_NewFrame()
|
||||||
{
|
{
|
||||||
ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData();
|
ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData();
|
||||||
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplAllegro5_Init()?");
|
IM_ASSERT(bd != nullptr && "Did you call ImGui_ImplAllegro5_Init()?");
|
||||||
|
|
||||||
if (!bd->Texture)
|
if (!bd->Texture)
|
||||||
ImGui_ImplAllegro5_CreateDeviceObjects();
|
ImGui_ImplAllegro5_CreateDeviceObjects();
|
||||||
|
@ -263,8 +263,6 @@ int32_t ImGui_ImplAndroid_HandleInputEvent(const AInputEvent* input_event)
|
|||||||
|
|
||||||
bool ImGui_ImplAndroid_Init(ANativeWindow* window)
|
bool ImGui_ImplAndroid_Init(ANativeWindow* window)
|
||||||
{
|
{
|
||||||
IMGUI_CHECKVERSION();
|
|
||||||
|
|
||||||
g_Window = window;
|
g_Window = window;
|
||||||
g_Time = 0.0;
|
g_Time = 0.0;
|
||||||
|
|
||||||
|
@ -534,7 +534,6 @@ void ImGui_ImplDX10_InvalidateDeviceObjects()
|
|||||||
bool ImGui_ImplDX10_Init(ID3D10Device* device)
|
bool ImGui_ImplDX10_Init(ID3D10Device* device)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
IMGUI_CHECKVERSION();
|
|
||||||
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
||||||
|
|
||||||
// Setup backend capabilities flags
|
// Setup backend capabilities flags
|
||||||
@ -579,7 +578,7 @@ void ImGui_ImplDX10_Shutdown()
|
|||||||
void ImGui_ImplDX10_NewFrame()
|
void ImGui_ImplDX10_NewFrame()
|
||||||
{
|
{
|
||||||
ImGui_ImplDX10_Data* bd = ImGui_ImplDX10_GetBackendData();
|
ImGui_ImplDX10_Data* bd = ImGui_ImplDX10_GetBackendData();
|
||||||
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplDX10_Init()?");
|
IM_ASSERT(bd != nullptr && "Did you call ImGui_ImplDX10_Init()?");
|
||||||
|
|
||||||
if (!bd->pFontSampler)
|
if (!bd->pFontSampler)
|
||||||
ImGui_ImplDX10_CreateDeviceObjects();
|
ImGui_ImplDX10_CreateDeviceObjects();
|
||||||
|
@ -546,7 +546,6 @@ void ImGui_ImplDX11_InvalidateDeviceObjects()
|
|||||||
bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_context)
|
bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_context)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
IMGUI_CHECKVERSION();
|
|
||||||
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
||||||
|
|
||||||
// Setup backend capabilities flags
|
// Setup backend capabilities flags
|
||||||
@ -595,7 +594,7 @@ void ImGui_ImplDX11_Shutdown()
|
|||||||
void ImGui_ImplDX11_NewFrame()
|
void ImGui_ImplDX11_NewFrame()
|
||||||
{
|
{
|
||||||
ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData();
|
ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData();
|
||||||
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplDX11_Init()?");
|
IM_ASSERT(bd != nullptr && "Did you call ImGui_ImplDX11_Init()?");
|
||||||
|
|
||||||
if (!bd->pFontSampler)
|
if (!bd->pFontSampler)
|
||||||
ImGui_ImplDX11_CreateDeviceObjects();
|
ImGui_ImplDX11_CreateDeviceObjects();
|
||||||
|
@ -702,7 +702,6 @@ bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FO
|
|||||||
D3D12_CPU_DESCRIPTOR_HANDLE font_srv_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE font_srv_gpu_desc_handle)
|
D3D12_CPU_DESCRIPTOR_HANDLE font_srv_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE font_srv_gpu_desc_handle)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
IMGUI_CHECKVERSION();
|
|
||||||
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
||||||
|
|
||||||
// Setup backend capabilities flags
|
// Setup backend capabilities flags
|
||||||
@ -751,7 +750,7 @@ void ImGui_ImplDX12_Shutdown()
|
|||||||
void ImGui_ImplDX12_NewFrame()
|
void ImGui_ImplDX12_NewFrame()
|
||||||
{
|
{
|
||||||
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
|
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
|
||||||
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplDX12_Init()?");
|
IM_ASSERT(bd != nullptr && "Did you call ImGui_ImplDX12_Init()?");
|
||||||
|
|
||||||
if (!bd->pPipelineState)
|
if (!bd->pPipelineState)
|
||||||
ImGui_ImplDX12_CreateDeviceObjects();
|
ImGui_ImplDX12_CreateDeviceObjects();
|
||||||
|
31
external/imgui/imgui/backends/imgui_impl_dx9.cpp
vendored
31
external/imgui/imgui/backends/imgui_impl_dx9.cpp
vendored
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2024-02-12: DirectX9: Using RGBA format when supported by the driver to avoid CPU side conversion. (#6575)
|
|
||||||
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
||||||
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
||||||
// 2021-06-25: DirectX9: Explicitly disable texture state stages after >= 1.
|
// 2021-06-25: DirectX9: Explicitly disable texture state stages after >= 1.
|
||||||
@ -285,7 +284,6 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data)
|
|||||||
bool ImGui_ImplDX9_Init(IDirect3DDevice9* device)
|
bool ImGui_ImplDX9_Init(IDirect3DDevice9* device)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
IMGUI_CHECKVERSION();
|
|
||||||
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
||||||
|
|
||||||
// Setup backend capabilities flags
|
// Setup backend capabilities flags
|
||||||
@ -314,24 +312,6 @@ void ImGui_ImplDX9_Shutdown()
|
|||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ImGui_ImplDX9_CheckFormatSupport(IDirect3DDevice9* pDevice, D3DFORMAT format)
|
|
||||||
{
|
|
||||||
IDirect3D9* pd3d = nullptr;
|
|
||||||
if (pDevice->GetDirect3D(&pd3d) != D3D_OK)
|
|
||||||
return false;
|
|
||||||
D3DDEVICE_CREATION_PARAMETERS param = {};
|
|
||||||
D3DDISPLAYMODE mode = {};
|
|
||||||
if (pDevice->GetCreationParameters(¶m) != D3D_OK || pDevice->GetDisplayMode(0, &mode) != D3D_OK)
|
|
||||||
{
|
|
||||||
pd3d->Release();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// Font texture should support linear filter, color blend and write to render-target
|
|
||||||
bool support = (pd3d->CheckDeviceFormat(param.AdapterOrdinal, param.DeviceType, mode.Format, D3DUSAGE_DYNAMIC | D3DUSAGE_QUERY_FILTER | D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING, D3DRTYPE_TEXTURE, format)) == D3D_OK;
|
|
||||||
pd3d->Release();
|
|
||||||
return support;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool ImGui_ImplDX9_CreateFontsTexture()
|
static bool ImGui_ImplDX9_CreateFontsTexture()
|
||||||
{
|
{
|
||||||
// Build texture atlas
|
// Build texture atlas
|
||||||
@ -343,21 +323,18 @@ static bool ImGui_ImplDX9_CreateFontsTexture()
|
|||||||
|
|
||||||
// Convert RGBA32 to BGRA32 (because RGBA32 is not well supported by DX9 devices)
|
// Convert RGBA32 to BGRA32 (because RGBA32 is not well supported by DX9 devices)
|
||||||
#ifndef IMGUI_USE_BGRA_PACKED_COLOR
|
#ifndef IMGUI_USE_BGRA_PACKED_COLOR
|
||||||
const bool rgba_support = ImGui_ImplDX9_CheckFormatSupport(bd->pd3dDevice, D3DFMT_A8B8G8R8);
|
if (io.Fonts->TexPixelsUseColors)
|
||||||
if (!rgba_support && io.Fonts->TexPixelsUseColors)
|
|
||||||
{
|
{
|
||||||
ImU32* dst_start = (ImU32*)ImGui::MemAlloc((size_t)width * height * bytes_per_pixel);
|
ImU32* dst_start = (ImU32*)ImGui::MemAlloc((size_t)width * height * bytes_per_pixel);
|
||||||
for (ImU32* src = (ImU32*)pixels, *dst = dst_start, *dst_end = dst_start + (size_t)width * height; dst < dst_end; src++, dst++)
|
for (ImU32* src = (ImU32*)pixels, *dst = dst_start, *dst_end = dst_start + (size_t)width * height; dst < dst_end; src++, dst++)
|
||||||
*dst = IMGUI_COL_TO_DX9_ARGB(*src);
|
*dst = IMGUI_COL_TO_DX9_ARGB(*src);
|
||||||
pixels = (unsigned char*)dst_start;
|
pixels = (unsigned char*)dst_start;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
const bool rgba_support = false;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Upload texture to graphics system
|
// Upload texture to graphics system
|
||||||
bd->FontTexture = nullptr;
|
bd->FontTexture = nullptr;
|
||||||
if (bd->pd3dDevice->CreateTexture(width, height, 1, D3DUSAGE_DYNAMIC, rgba_support ? D3DFMT_A8B8G8R8 : D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &bd->FontTexture, nullptr) < 0)
|
if (bd->pd3dDevice->CreateTexture(width, height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &bd->FontTexture, nullptr) < 0)
|
||||||
return false;
|
return false;
|
||||||
D3DLOCKED_RECT tex_locked_rect;
|
D3DLOCKED_RECT tex_locked_rect;
|
||||||
if (bd->FontTexture->LockRect(0, &tex_locked_rect, nullptr, 0) != D3D_OK)
|
if (bd->FontTexture->LockRect(0, &tex_locked_rect, nullptr, 0) != D3D_OK)
|
||||||
@ -370,7 +347,7 @@ static bool ImGui_ImplDX9_CreateFontsTexture()
|
|||||||
io.Fonts->SetTexID((ImTextureID)bd->FontTexture);
|
io.Fonts->SetTexID((ImTextureID)bd->FontTexture);
|
||||||
|
|
||||||
#ifndef IMGUI_USE_BGRA_PACKED_COLOR
|
#ifndef IMGUI_USE_BGRA_PACKED_COLOR
|
||||||
if (!rgba_support && io.Fonts->TexPixelsUseColors)
|
if (io.Fonts->TexPixelsUseColors)
|
||||||
ImGui::MemFree(pixels);
|
ImGui::MemFree(pixels);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -400,7 +377,7 @@ void ImGui_ImplDX9_InvalidateDeviceObjects()
|
|||||||
void ImGui_ImplDX9_NewFrame()
|
void ImGui_ImplDX9_NewFrame()
|
||||||
{
|
{
|
||||||
ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData();
|
ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData();
|
||||||
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplDX9_Init()?");
|
IM_ASSERT(bd != nullptr && "Did you call ImGui_ImplDX9_Init()?");
|
||||||
|
|
||||||
if (!bd->FontTexture)
|
if (!bd->FontTexture)
|
||||||
ImGui_ImplDX9_CreateDeviceObjects();
|
ImGui_ImplDX9_CreateDeviceObjects();
|
||||||
|
@ -85,15 +85,11 @@
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#undef APIENTRY
|
#undef APIENTRY
|
||||||
#ifndef GLFW_EXPOSE_NATIVE_WIN32
|
|
||||||
#define GLFW_EXPOSE_NATIVE_WIN32
|
#define GLFW_EXPOSE_NATIVE_WIN32
|
||||||
#endif
|
|
||||||
#include <GLFW/glfw3native.h> // for glfwGetWin32Window()
|
#include <GLFW/glfw3native.h> // for glfwGetWin32Window()
|
||||||
#endif
|
#endif
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#ifndef GLFW_EXPOSE_NATIVE_COCOA
|
|
||||||
#define GLFW_EXPOSE_NATIVE_COCOA
|
#define GLFW_EXPOSE_NATIVE_COCOA
|
||||||
#endif
|
|
||||||
#include <GLFW/glfw3native.h> // for glfwGetCocoaWindow()
|
#include <GLFW/glfw3native.h> // for glfwGetCocoaWindow()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -118,7 +114,7 @@ enum GlfwClientApi
|
|||||||
{
|
{
|
||||||
GlfwClientApi_Unknown,
|
GlfwClientApi_Unknown,
|
||||||
GlfwClientApi_OpenGL,
|
GlfwClientApi_OpenGL,
|
||||||
GlfwClientApi_Vulkan,
|
GlfwClientApi_Vulkan
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ImGui_ImplGlfw_Data
|
struct ImGui_ImplGlfw_Data
|
||||||
@ -556,7 +552,6 @@ void ImGui_ImplGlfw_SetCallbacksChainForAllWindows(bool chain_for_all_windows)
|
|||||||
static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, GlfwClientApi client_api)
|
static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, GlfwClientApi client_api)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
IMGUI_CHECKVERSION();
|
|
||||||
IM_ASSERT(io.BackendPlatformUserData == nullptr && "Already initialized a platform backend!");
|
IM_ASSERT(io.BackendPlatformUserData == nullptr && "Already initialized a platform backend!");
|
||||||
//printf("GLFW_VERSION: %d.%d.%d (%d)", GLFW_VERSION_MAJOR, GLFW_VERSION_MINOR, GLFW_VERSION_REVISION, GLFW_VERSION_COMBINED);
|
//printf("GLFW_VERSION: %d.%d.%d (%d)", GLFW_VERSION_MAJOR, GLFW_VERSION_MINOR, GLFW_VERSION_REVISION, GLFW_VERSION_COMBINED);
|
||||||
|
|
||||||
@ -679,9 +674,11 @@ static void ImGui_ImplGlfw_UpdateMouseData()
|
|||||||
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
|
||||||
// (those braces are here to reduce diff with multi-viewports support in 'docking' branch)
|
// (those braces are here to reduce diff with multi-viewports support in 'docking' branch)
|
||||||
{
|
{
|
||||||
GLFWwindow* window = bd->Window;
|
GLFWwindow* window = bd->Window;
|
||||||
|
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
const bool is_window_focused = true;
|
const bool is_window_focused = true;
|
||||||
#else
|
#else
|
||||||
@ -788,7 +785,7 @@ void ImGui_ImplGlfw_NewFrame()
|
|||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplGlfw_InitForXXX()?");
|
IM_ASSERT(bd != nullptr && "Did you call ImGui_ImplGlfw_InitForXXX()?");
|
||||||
|
|
||||||
// Setup display size (every frame to accommodate for window resizing)
|
// Setup display size (every frame to accommodate for window resizing)
|
||||||
int w, h;
|
int w, h;
|
||||||
@ -839,7 +836,7 @@ void ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback(const char* canvas_sel
|
|||||||
{
|
{
|
||||||
IM_ASSERT(canvas_selector != nullptr);
|
IM_ASSERT(canvas_selector != nullptr);
|
||||||
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplGlfw_InitForXXX()?");
|
IM_ASSERT(bd != nullptr && "Did you call ImGui_ImplGlfw_InitForXXX()?");
|
||||||
|
|
||||||
bd->CanvasSelector = canvas_selector;
|
bd->CanvasSelector = canvas_selector;
|
||||||
emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, bd, false, ImGui_ImplGlfw_OnCanvasSizeChange);
|
emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, bd, false, ImGui_ImplGlfw_OnCanvasSizeChange);
|
||||||
|
@ -167,7 +167,6 @@ static ImGuiKey ImGui_ImplGLUT_KeyToImGuiKey(int key)
|
|||||||
bool ImGui_ImplGLUT_Init()
|
bool ImGui_ImplGLUT_Init()
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
IMGUI_CHECKVERSION();
|
|
||||||
|
|
||||||
#ifdef FREEGLUT
|
#ifdef FREEGLUT
|
||||||
io.BackendPlatformName = "imgui_impl_glut (freeglut)";
|
io.BackendPlatformName = "imgui_impl_glut (freeglut)";
|
||||||
|
@ -79,6 +79,7 @@ struct ImGui_ImplMetal_Data
|
|||||||
ImGui_ImplMetal_Data() { memset(this, 0, sizeof(*this)); }
|
ImGui_ImplMetal_Data() { memset(this, 0, sizeof(*this)); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static ImGui_ImplMetal_Data* ImGui_ImplMetal_CreateBackendData() { return IM_NEW(ImGui_ImplMetal_Data)(); }
|
||||||
static ImGui_ImplMetal_Data* ImGui_ImplMetal_GetBackendData() { return ImGui::GetCurrentContext() ? (ImGui_ImplMetal_Data*)ImGui::GetIO().BackendRendererUserData : nullptr; }
|
static ImGui_ImplMetal_Data* ImGui_ImplMetal_GetBackendData() { return ImGui::GetCurrentContext() ? (ImGui_ImplMetal_Data*)ImGui::GetIO().BackendRendererUserData : nullptr; }
|
||||||
static void ImGui_ImplMetal_DestroyBackendData(){ IM_DELETE(ImGui_ImplMetal_GetBackendData()); }
|
static void ImGui_ImplMetal_DestroyBackendData(){ IM_DELETE(ImGui_ImplMetal_GetBackendData()); }
|
||||||
|
|
||||||
@ -124,11 +125,8 @@ bool ImGui_ImplMetal_CreateDeviceObjects(MTL::Device* device)
|
|||||||
|
|
||||||
bool ImGui_ImplMetal_Init(id<MTLDevice> device)
|
bool ImGui_ImplMetal_Init(id<MTLDevice> device)
|
||||||
{
|
{
|
||||||
|
ImGui_ImplMetal_Data* bd = ImGui_ImplMetal_CreateBackendData();
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
IMGUI_CHECKVERSION();
|
|
||||||
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
|
||||||
|
|
||||||
ImGui_ImplMetal_Data* bd = IM_NEW(ImGui_ImplMetal_Data)();
|
|
||||||
io.BackendRendererUserData = (void*)bd;
|
io.BackendRendererUserData = (void*)bd;
|
||||||
io.BackendRendererName = "imgui_impl_metal";
|
io.BackendRendererName = "imgui_impl_metal";
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
@ -155,7 +153,7 @@ void ImGui_ImplMetal_Shutdown()
|
|||||||
void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor* renderPassDescriptor)
|
void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor* renderPassDescriptor)
|
||||||
{
|
{
|
||||||
ImGui_ImplMetal_Data* bd = ImGui_ImplMetal_GetBackendData();
|
ImGui_ImplMetal_Data* bd = ImGui_ImplMetal_GetBackendData();
|
||||||
IM_ASSERT(bd != nil && "Context or backend not initialized! Did you call ImGui_ImplMetal_Init()?");
|
IM_ASSERT(bd->SharedMetalContext != nil && "No Metal context. Did you call ImGui_ImplMetal_Init() ?");
|
||||||
bd->SharedMetalContext.framebufferDescriptor = [[FramebufferDescriptor alloc] initWithRenderPassDescriptor:renderPassDescriptor];
|
bd->SharedMetalContext.framebufferDescriptor = [[FramebufferDescriptor alloc] initWithRenderPassDescriptor:renderPassDescriptor];
|
||||||
|
|
||||||
if (bd->SharedMetalContext.depthStencilState == nil)
|
if (bd->SharedMetalContext.depthStencilState == nil)
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
||||||
// 2021-12-08: OpenGL: Fixed mishandling of the ImDrawCmd::IdxOffset field! This is an old bug but it never had an effect until some internal rendering changes in 1.86.
|
// 2021-12-08: OpenGL: Fixed mishandling of the the ImDrawCmd::IdxOffset field! This is an old bug but it never had an effect until some internal rendering changes in 1.86.
|
||||||
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
||||||
// 2021-05-19: OpenGL: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
|
// 2021-05-19: OpenGL: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement)
|
||||||
// 2021-01-03: OpenGL: Backup, setup and restore GL_SHADE_MODEL state, disable GL_STENCIL_TEST and disable GL_NORMAL_ARRAY client state to increase compatibility with legacy OpenGL applications.
|
// 2021-01-03: OpenGL: Backup, setup and restore GL_SHADE_MODEL state, disable GL_STENCIL_TEST and disable GL_NORMAL_ARRAY client state to increase compatibility with legacy OpenGL applications.
|
||||||
@ -83,7 +83,6 @@ static ImGui_ImplOpenGL2_Data* ImGui_ImplOpenGL2_GetBackendData()
|
|||||||
bool ImGui_ImplOpenGL2_Init()
|
bool ImGui_ImplOpenGL2_Init()
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
IMGUI_CHECKVERSION();
|
|
||||||
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
||||||
|
|
||||||
// Setup backend capabilities flags
|
// Setup backend capabilities flags
|
||||||
@ -109,7 +108,7 @@ void ImGui_ImplOpenGL2_Shutdown()
|
|||||||
void ImGui_ImplOpenGL2_NewFrame()
|
void ImGui_ImplOpenGL2_NewFrame()
|
||||||
{
|
{
|
||||||
ImGui_ImplOpenGL2_Data* bd = ImGui_ImplOpenGL2_GetBackendData();
|
ImGui_ImplOpenGL2_Data* bd = ImGui_ImplOpenGL2_GetBackendData();
|
||||||
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplOpenGL2_Init()?");
|
IM_ASSERT(bd != nullptr && "Did you call ImGui_ImplOpenGL2_Init()?");
|
||||||
|
|
||||||
if (!bd->FontTexture)
|
if (!bd->FontTexture)
|
||||||
ImGui_ImplOpenGL2_CreateDeviceObjects();
|
ImGui_ImplOpenGL2_CreateDeviceObjects();
|
||||||
|
@ -22,8 +22,6 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2024-05-07: OpenGL: Update loader for Linux to support EGL/GLVND. (#7562)
|
|
||||||
// 2024-04-16: OpenGL: Detect ES3 contexts on desktop based on version string, to e.g. avoid calling glPolygonMode() on them. (#7447)
|
|
||||||
// 2024-01-09: OpenGL: Update GL3W based imgui_impl_opengl3_loader.h to load "libGL.so" and variants, fixing regression on distros missing a symlink.
|
// 2024-01-09: OpenGL: Update GL3W based imgui_impl_opengl3_loader.h to load "libGL.so" and variants, fixing regression on distros missing a symlink.
|
||||||
// 2023-11-08: OpenGL: Update GL3W based imgui_impl_opengl3_loader.h to load "libGL.so" instead of "libGL.so.1", accommodating for NetBSD systems having only "libGL.so.3" available. (#6983)
|
// 2023-11-08: OpenGL: Update GL3W based imgui_impl_opengl3_loader.h to load "libGL.so" instead of "libGL.so.1", accommodating for NetBSD systems having only "libGL.so.3" available. (#6983)
|
||||||
// 2023-10-05: OpenGL: Rename symbols in our internal loader so that LTO compilation with another copy of gl3w is possible. (#6875, #6668, #4445)
|
// 2023-10-05: OpenGL: Rename symbols in our internal loader so that LTO compilation with another copy of gl3w is possible. (#6875, #6668, #4445)
|
||||||
@ -178,21 +176,9 @@
|
|||||||
#define GL_VERTEX_ARRAY_BINDING GL_VERTEX_ARRAY_BINDING_OES
|
#define GL_VERTEX_ARRAY_BINDING GL_VERTEX_ARRAY_BINDING_OES
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Desktop GL 2.0+ has extension and glPolygonMode() which GL ES and WebGL don't have..
|
// Desktop GL 2.0+ has glPolygonMode() which GL ES and WebGL don't have.
|
||||||
// A desktop ES context can technically compile fine with our loader, so we also perform a runtime checks
|
#ifdef GL_POLYGON_MODE
|
||||||
#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3)
|
#define IMGUI_IMPL_HAS_POLYGON_MODE
|
||||||
#define IMGUI_IMPL_OPENGL_HAS_EXTENSIONS // has glGetIntegerv(GL_NUM_EXTENSIONS)
|
|
||||||
#define IMGUI_IMPL_OPENGL_MAY_HAVE_POLYGON_MODE // may have glPolygonMode()
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Desktop GL 2.1+ and GL ES 3.0+ have glBindBuffer() with GL_PIXEL_UNPACK_BUFFER target.
|
|
||||||
#if !defined(IMGUI_IMPL_OPENGL_ES2)
|
|
||||||
#define IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_BUFFER_PIXEL_UNPACK
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Desktop GL 3.1+ has GL_PRIMITIVE_RESTART state
|
|
||||||
#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3) && defined(GL_VERSION_3_1)
|
|
||||||
#define IMGUI_IMPL_OPENGL_MAY_HAVE_PRIMITIVE_RESTART
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Desktop GL 3.2+ has glDrawElementsBaseVertex() which GL ES and WebGL don't have.
|
// Desktop GL 3.2+ has glDrawElementsBaseVertex() which GL ES and WebGL don't have.
|
||||||
@ -205,6 +191,16 @@
|
|||||||
#define IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
#define IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Desktop GL 3.1+ has GL_PRIMITIVE_RESTART state
|
||||||
|
#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3) && defined(GL_VERSION_3_1)
|
||||||
|
#define IMGUI_IMPL_OPENGL_MAY_HAVE_PRIMITIVE_RESTART
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Desktop GL use extension detection
|
||||||
|
#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3)
|
||||||
|
#define IMGUI_IMPL_OPENGL_MAY_HAVE_EXTENSIONS
|
||||||
|
#endif
|
||||||
|
|
||||||
// [Debugging]
|
// [Debugging]
|
||||||
//#define IMGUI_IMPL_OPENGL_DEBUG
|
//#define IMGUI_IMPL_OPENGL_DEBUG
|
||||||
#ifdef IMGUI_IMPL_OPENGL_DEBUG
|
#ifdef IMGUI_IMPL_OPENGL_DEBUG
|
||||||
@ -233,7 +229,6 @@ struct ImGui_ImplOpenGL3_Data
|
|||||||
unsigned int VboHandle, ElementsHandle;
|
unsigned int VboHandle, ElementsHandle;
|
||||||
GLsizeiptr VertexBufferSize;
|
GLsizeiptr VertexBufferSize;
|
||||||
GLsizeiptr IndexBufferSize;
|
GLsizeiptr IndexBufferSize;
|
||||||
bool HasPolygonMode;
|
|
||||||
bool HasClipOrigin;
|
bool HasClipOrigin;
|
||||||
bool UseBufferSubData;
|
bool UseBufferSubData;
|
||||||
|
|
||||||
@ -275,7 +270,6 @@ struct ImGui_ImplOpenGL3_VtxAttribState
|
|||||||
bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
IMGUI_CHECKVERSION();
|
|
||||||
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
||||||
|
|
||||||
// Initialize our loader
|
// Initialize our loader
|
||||||
@ -299,13 +293,16 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
|||||||
bd->GlProfileIsES2 = true;
|
bd->GlProfileIsES2 = true;
|
||||||
#else
|
#else
|
||||||
// Desktop or GLES 3
|
// Desktop or GLES 3
|
||||||
const char* gl_version_str = (const char*)glGetString(GL_VERSION);
|
|
||||||
GLint major = 0;
|
GLint major = 0;
|
||||||
GLint minor = 0;
|
GLint minor = 0;
|
||||||
glGetIntegerv(GL_MAJOR_VERSION, &major);
|
glGetIntegerv(GL_MAJOR_VERSION, &major);
|
||||||
glGetIntegerv(GL_MINOR_VERSION, &minor);
|
glGetIntegerv(GL_MINOR_VERSION, &minor);
|
||||||
if (major == 0 && minor == 0)
|
if (major == 0 && minor == 0)
|
||||||
sscanf(gl_version_str, "%d.%d", &major, &minor); // Query GL_VERSION in desktop GL 2.x, the string will start with "<major>.<minor>"
|
{
|
||||||
|
// Query GL_VERSION in desktop GL 2.x, the string will start with "<major>.<minor>"
|
||||||
|
const char* gl_version = (const char*)glGetString(GL_VERSION);
|
||||||
|
sscanf(gl_version, "%d.%d", &major, &minor);
|
||||||
|
}
|
||||||
bd->GlVersion = (GLuint)(major * 100 + minor * 10);
|
bd->GlVersion = (GLuint)(major * 100 + minor * 10);
|
||||||
#if defined(GL_CONTEXT_PROFILE_MASK)
|
#if defined(GL_CONTEXT_PROFILE_MASK)
|
||||||
if (bd->GlVersion >= 320)
|
if (bd->GlVersion >= 320)
|
||||||
@ -315,9 +312,6 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
|||||||
|
|
||||||
#if defined(IMGUI_IMPL_OPENGL_ES3)
|
#if defined(IMGUI_IMPL_OPENGL_ES3)
|
||||||
bd->GlProfileIsES3 = true;
|
bd->GlProfileIsES3 = true;
|
||||||
#else
|
|
||||||
if (strncmp(gl_version_str, "OpenGL ES 3", 11) == 0)
|
|
||||||
bd->GlProfileIsES3 = true;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bd->UseBufferSubData = false;
|
bd->UseBufferSubData = false;
|
||||||
@ -332,7 +326,7 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef IMGUI_IMPL_OPENGL_DEBUG
|
#ifdef IMGUI_IMPL_OPENGL_DEBUG
|
||||||
printf("GlVersion = %d, \"%s\"\nGlProfileIsCompat = %d\nGlProfileMask = 0x%X\nGlProfileIsES2 = %d, GlProfileIsES3 = %d\nGL_VENDOR = '%s'\nGL_RENDERER = '%s'\n", bd->GlVersion, gl_version_str, bd->GlProfileIsCompat, bd->GlProfileMask, bd->GlProfileIsES2, bd->GlProfileIsES3, (const char*)glGetString(GL_VENDOR), (const char*)glGetString(GL_RENDERER)); // [DEBUG]
|
printf("GlVersion = %d\nGlProfileIsCompat = %d\nGlProfileMask = 0x%X\nGlProfileIsES2 = %d, GlProfileIsES3 = %d\nGL_VENDOR = '%s'\nGL_RENDERER = '%s'\n", bd->GlVersion, bd->GlProfileIsCompat, bd->GlProfileMask, bd->GlProfileIsES2, bd->GlProfileIsES3, (const char*)glGetString(GL_VENDOR), (const char*)glGetString(GL_RENDERER)); // [DEBUG]
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
||||||
@ -364,11 +358,8 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
|||||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤t_texture);
|
glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤t_texture);
|
||||||
|
|
||||||
// Detect extensions we support
|
// Detect extensions we support
|
||||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_POLYGON_MODE
|
|
||||||
bd->HasPolygonMode = (!bd->GlProfileIsES2 && !bd->GlProfileIsES3);
|
|
||||||
#endif
|
|
||||||
bd->HasClipOrigin = (bd->GlVersion >= 450);
|
bd->HasClipOrigin = (bd->GlVersion >= 450);
|
||||||
#ifdef IMGUI_IMPL_OPENGL_HAS_EXTENSIONS
|
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_EXTENSIONS
|
||||||
GLint num_extensions = 0;
|
GLint num_extensions = 0;
|
||||||
glGetIntegerv(GL_NUM_EXTENSIONS, &num_extensions);
|
glGetIntegerv(GL_NUM_EXTENSIONS, &num_extensions);
|
||||||
for (GLint i = 0; i < num_extensions; i++)
|
for (GLint i = 0; i < num_extensions; i++)
|
||||||
@ -398,7 +389,7 @@ void ImGui_ImplOpenGL3_Shutdown()
|
|||||||
void ImGui_ImplOpenGL3_NewFrame()
|
void ImGui_ImplOpenGL3_NewFrame()
|
||||||
{
|
{
|
||||||
ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData();
|
ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData();
|
||||||
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplOpenGL3_Init()?");
|
IM_ASSERT(bd != nullptr && "Did you call ImGui_ImplOpenGL3_Init()?");
|
||||||
|
|
||||||
if (!bd->ShaderHandle)
|
if (!bd->ShaderHandle)
|
||||||
ImGui_ImplOpenGL3_CreateDeviceObjects();
|
ImGui_ImplOpenGL3_CreateDeviceObjects();
|
||||||
@ -420,8 +411,7 @@ static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_wid
|
|||||||
if (bd->GlVersion >= 310)
|
if (bd->GlVersion >= 310)
|
||||||
glDisable(GL_PRIMITIVE_RESTART);
|
glDisable(GL_PRIMITIVE_RESTART);
|
||||||
#endif
|
#endif
|
||||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_POLYGON_MODE
|
#ifdef IMGUI_IMPL_HAS_POLYGON_MODE
|
||||||
if (bd->HasPolygonMode)
|
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -510,8 +500,8 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|||||||
#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
||||||
GLuint last_vertex_array_object; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, (GLint*)&last_vertex_array_object);
|
GLuint last_vertex_array_object; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, (GLint*)&last_vertex_array_object);
|
||||||
#endif
|
#endif
|
||||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_POLYGON_MODE
|
#ifdef IMGUI_IMPL_HAS_POLYGON_MODE
|
||||||
GLint last_polygon_mode[2]; if (bd->HasPolygonMode) { glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode); }
|
GLint last_polygon_mode[2]; glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode);
|
||||||
#endif
|
#endif
|
||||||
GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
|
GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
|
||||||
GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
|
GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
|
||||||
@ -649,10 +639,18 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|||||||
if (bd->GlVersion >= 310) { if (last_enable_primitive_restart) glEnable(GL_PRIMITIVE_RESTART); else glDisable(GL_PRIMITIVE_RESTART); }
|
if (bd->GlVersion >= 310) { if (last_enable_primitive_restart) glEnable(GL_PRIMITIVE_RESTART); else glDisable(GL_PRIMITIVE_RESTART); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_POLYGON_MODE
|
#ifdef IMGUI_IMPL_HAS_POLYGON_MODE
|
||||||
// Desktop OpenGL 3.0 and OpenGL 3.1 had separate polygon draw modes for front-facing and back-facing faces of polygons
|
// Desktop OpenGL 3.0 and OpenGL 3.1 had separate polygon draw modes for front-facing and back-facing faces of polygons
|
||||||
if (bd->HasPolygonMode) { if (bd->GlVersion <= 310 || bd->GlProfileIsCompat) { glPolygonMode(GL_FRONT, (GLenum)last_polygon_mode[0]); glPolygonMode(GL_BACK, (GLenum)last_polygon_mode[1]); } else { glPolygonMode(GL_FRONT_AND_BACK, (GLenum)last_polygon_mode[0]); } }
|
if (bd->GlVersion <= 310 || bd->GlProfileIsCompat)
|
||||||
#endif // IMGUI_IMPL_OPENGL_MAY_HAVE_POLYGON_MODE
|
{
|
||||||
|
glPolygonMode(GL_FRONT, (GLenum)last_polygon_mode[0]);
|
||||||
|
glPolygonMode(GL_BACK, (GLenum)last_polygon_mode[1]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
glPolygonMode(GL_FRONT_AND_BACK, (GLenum)last_polygon_mode[0]);
|
||||||
|
}
|
||||||
|
#endif // IMGUI_IMPL_HAS_POLYGON_MODE
|
||||||
|
|
||||||
glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
|
glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
|
||||||
glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
|
glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
|
||||||
@ -749,10 +747,6 @@ bool ImGui_ImplOpenGL3_CreateDeviceObjects()
|
|||||||
GLint last_texture, last_array_buffer;
|
GLint last_texture, last_array_buffer;
|
||||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
||||||
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
|
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
|
||||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_BUFFER_PIXEL_UNPACK
|
|
||||||
GLint last_pixel_unpack_buffer = 0;
|
|
||||||
if (bd->GlVersion >= 210) { glGetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING, &last_pixel_unpack_buffer); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); }
|
|
||||||
#endif
|
|
||||||
#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
||||||
GLint last_vertex_array;
|
GLint last_vertex_array;
|
||||||
glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array);
|
glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array);
|
||||||
@ -926,9 +920,6 @@ bool ImGui_ImplOpenGL3_CreateDeviceObjects()
|
|||||||
// Restore modified GL state
|
// Restore modified GL state
|
||||||
glBindTexture(GL_TEXTURE_2D, last_texture);
|
glBindTexture(GL_TEXTURE_2D, last_texture);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
|
glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
|
||||||
#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_BUFFER_PIXEL_UNPACK
|
|
||||||
if (bd->GlVersion >= 210) { glBindBuffer(GL_PIXEL_UNPACK_BUFFER, last_pixel_unpack_buffer); }
|
|
||||||
#endif
|
|
||||||
#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY
|
||||||
glBindVertexArray(last_vertex_array);
|
glBindVertexArray(last_vertex_array);
|
||||||
#endif
|
#endif
|
||||||
|
@ -41,9 +41,9 @@ IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyFontsTexture();
|
|||||||
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateDeviceObjects();
|
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateDeviceObjects();
|
||||||
IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects();
|
IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects();
|
||||||
|
|
||||||
// Configuration flags to add in your imconfig file:
|
// Specific OpenGL ES versions
|
||||||
//#define IMGUI_IMPL_OPENGL_ES2 // Enable ES 2 (Auto-detected on Emscripten)
|
//#define IMGUI_IMPL_OPENGL_ES2 // Auto-detected on Emscripten
|
||||||
//#define IMGUI_IMPL_OPENGL_ES3 // Enable ES 3 (Auto-detected on iOS/Android)
|
//#define IMGUI_IMPL_OPENGL_ES3 // Auto-detected on iOS/Android
|
||||||
|
|
||||||
// You can explicitly select GLES2 or GLES3 API by using one of the '#define IMGUI_IMPL_OPENGL_LOADER_XXX' in imconfig.h or compiler command-line.
|
// You can explicitly select GLES2 or GLES3 API by using one of the '#define IMGUI_IMPL_OPENGL_LOADER_XXX' in imconfig.h or compiler command-line.
|
||||||
#if !defined(IMGUI_IMPL_OPENGL_ES2) \
|
#if !defined(IMGUI_IMPL_OPENGL_ES2) \
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
// THE REST OF YOUR APP SHOULD USE A DIFFERENT GL LOADER: ANY GL LOADER OF YOUR CHOICE.
|
// THE REST OF YOUR APP SHOULD USE A DIFFERENT GL LOADER: ANY GL LOADER OF YOUR CHOICE.
|
||||||
//
|
//
|
||||||
// IF YOU GET BUILD ERRORS IN THIS FILE (commonly macro redefinitions or function redefinitions):
|
// IF YOU GET BUILD ERRORS IN THIS FILE (commonly macro redefinitions or function redefinitions):
|
||||||
// IT LIKELY MEANS THAT YOU ARE BUILDING 'imgui_impl_opengl3.cpp' OR INCLUDING 'imgui_impl_opengl3_loader.h'
|
// IT LIKELY MEANS THAT YOU ARE BUILDING 'imgui_impl_opengl3.cpp' OR INCUDING 'imgui_impl_opengl3_loader.h'
|
||||||
// IN THE SAME COMPILATION UNIT AS ONE OF YOUR FILE WHICH IS USING A THIRD-PARTY OPENGL LOADER.
|
// IN THE SAME COMPILATION UNIT AS ONE OF YOUR FILE WHICH IS USING A THIRD-PARTY OPENGL LOADER.
|
||||||
// (e.g. COULD HAPPEN IF YOU ARE DOING A UNITY/JUMBO BUILD, OR INCLUDING .CPP FILES FROM OTHERS)
|
// (e.g. COULD HAPPEN IF YOU ARE DOING A UNITY/JUMBO BUILD, OR INCLUDING .CPP FILES FROM OTHERS)
|
||||||
// YOU SHOULD NOT BUILD BOTH IN THE SAME COMPILATION UNIT.
|
// YOU SHOULD NOT BUILD BOTH IN THE SAME COMPILATION UNIT.
|
||||||
@ -18,7 +18,7 @@
|
|||||||
// WILL NOT BE USING OUR LOADER, AND INSTEAD EXPECT ANOTHER/YOUR LOADER TO BE AVAILABLE IN THE COMPILATION UNIT.
|
// WILL NOT BE USING OUR LOADER, AND INSTEAD EXPECT ANOTHER/YOUR LOADER TO BE AVAILABLE IN THE COMPILATION UNIT.
|
||||||
//
|
//
|
||||||
// Regenerate with:
|
// Regenerate with:
|
||||||
// python3 gl3w_gen.py --output ../imgui/backends/imgui_impl_opengl3_loader.h --ref ../imgui/backends/imgui_impl_opengl3.cpp ./extra_symbols.txt
|
// python gl3w_gen.py --output ../imgui/backends/imgui_impl_opengl3_loader.h --ref ../imgui/backends/imgui_impl_opengl3.cpp ./extra_symbols.txt
|
||||||
//
|
//
|
||||||
// More info:
|
// More info:
|
||||||
// https://github.com/dearimgui/gl3w_stripped
|
// https://github.com/dearimgui/gl3w_stripped
|
||||||
@ -346,10 +346,6 @@ GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean
|
|||||||
GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer);
|
GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer);
|
||||||
#endif
|
#endif
|
||||||
#endif /* GL_VERSION_2_0 */
|
#endif /* GL_VERSION_2_0 */
|
||||||
#ifndef GL_VERSION_2_1
|
|
||||||
#define GL_PIXEL_UNPACK_BUFFER 0x88EC
|
|
||||||
#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF
|
|
||||||
#endif /* GL_VERSION_2_1 */
|
|
||||||
#ifndef GL_VERSION_3_0
|
#ifndef GL_VERSION_3_0
|
||||||
typedef khronos_uint16_t GLhalf;
|
typedef khronos_uint16_t GLhalf;
|
||||||
#define GL_MAJOR_VERSION 0x821B
|
#define GL_MAJOR_VERSION 0x821B
|
||||||
@ -665,123 +661,31 @@ static GL3WglProc get_proc(const char *proc)
|
|||||||
#else
|
#else
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
|
||||||
static void* libgl; // OpenGL library
|
static void *libgl;
|
||||||
static void* libglx; // GLX library
|
static GL3WglProc (*glx_get_proc_address)(const GLubyte *);
|
||||||
static void* libegl; // EGL library
|
|
||||||
static GL3WGetProcAddressProc gl_get_proc_address;
|
|
||||||
|
|
||||||
static void close_libgl(void)
|
static int open_libgl(void)
|
||||||
{
|
{
|
||||||
if (libgl) {
|
|
||||||
dlclose(libgl);
|
|
||||||
libgl = NULL;
|
|
||||||
}
|
|
||||||
if (libegl) {
|
|
||||||
dlclose(libegl);
|
|
||||||
libegl = NULL;
|
|
||||||
}
|
|
||||||
if (libglx) {
|
|
||||||
dlclose(libglx);
|
|
||||||
libglx = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int is_library_loaded(const char* name, void** lib)
|
|
||||||
{
|
|
||||||
*lib = dlopen(name, RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD);
|
|
||||||
return *lib != NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int open_libs(void)
|
|
||||||
{
|
|
||||||
// On Linux we have two APIs to get process addresses: EGL and GLX.
|
|
||||||
// EGL is supported under both X11 and Wayland, whereas GLX is X11-specific.
|
|
||||||
|
|
||||||
libgl = NULL;
|
|
||||||
libegl = NULL;
|
|
||||||
libglx = NULL;
|
|
||||||
|
|
||||||
// First check what's already loaded, the windowing library might have
|
|
||||||
// already loaded either EGL or GLX and we want to use the same one.
|
|
||||||
|
|
||||||
if (is_library_loaded("libEGL.so.1", &libegl) ||
|
|
||||||
is_library_loaded("libGLX.so.0", &libglx)) {
|
|
||||||
libgl = dlopen("libOpenGL.so.0", RTLD_LAZY | RTLD_LOCAL);
|
|
||||||
if (libgl)
|
|
||||||
return GL3W_OK;
|
|
||||||
else
|
|
||||||
close_libgl();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_library_loaded("libGL.so", &libgl))
|
|
||||||
return GL3W_OK;
|
|
||||||
if (is_library_loaded("libGL.so.1", &libgl))
|
|
||||||
return GL3W_OK;
|
|
||||||
if (is_library_loaded("libGL.so.3", &libgl))
|
|
||||||
return GL3W_OK;
|
|
||||||
|
|
||||||
// Neither is already loaded, so we have to load one. Try EGL first
|
|
||||||
// because it is supported under both X11 and Wayland.
|
|
||||||
|
|
||||||
// Load OpenGL + EGL
|
|
||||||
libgl = dlopen("libOpenGL.so.0", RTLD_LAZY | RTLD_LOCAL);
|
|
||||||
libegl = dlopen("libEGL.so.1", RTLD_LAZY | RTLD_LOCAL);
|
|
||||||
if (libgl && libegl)
|
|
||||||
return GL3W_OK;
|
|
||||||
else
|
|
||||||
close_libgl();
|
|
||||||
|
|
||||||
// Fall back to legacy libGL, which includes GLX
|
|
||||||
// While most systems use libGL.so.1, NetBSD seems to use that libGL.so.3. See https://github.com/ocornut/imgui/issues/6983
|
// While most systems use libGL.so.1, NetBSD seems to use that libGL.so.3. See https://github.com/ocornut/imgui/issues/6983
|
||||||
libgl = dlopen("libGL.so", RTLD_LAZY | RTLD_LOCAL);
|
libgl = dlopen("libGL.so", RTLD_LAZY | RTLD_LOCAL);
|
||||||
if (!libgl)
|
if (!libgl)
|
||||||
libgl = dlopen("libGL.so.1", RTLD_LAZY | RTLD_LOCAL);
|
libgl = dlopen("libGL.so.1", RTLD_LAZY | RTLD_LOCAL);
|
||||||
if (!libgl)
|
if (!libgl)
|
||||||
libgl = dlopen("libGL.so.3", RTLD_LAZY | RTLD_LOCAL);
|
libgl = dlopen("libGL.so.3", RTLD_LAZY | RTLD_LOCAL);
|
||||||
|
if (!libgl)
|
||||||
if (libgl)
|
|
||||||
return GL3W_OK;
|
|
||||||
|
|
||||||
return GL3W_ERROR_LIBRARY_OPEN;
|
return GL3W_ERROR_LIBRARY_OPEN;
|
||||||
}
|
*(void **)(&glx_get_proc_address) = dlsym(libgl, "glXGetProcAddressARB");
|
||||||
|
|
||||||
static int open_libgl(void)
|
|
||||||
{
|
|
||||||
int res = open_libs();
|
|
||||||
if (res)
|
|
||||||
return res;
|
|
||||||
|
|
||||||
if (libegl)
|
|
||||||
*(void**)(&gl_get_proc_address) = dlsym(libegl, "eglGetProcAddress");
|
|
||||||
else if (libglx)
|
|
||||||
*(void**)(&gl_get_proc_address) = dlsym(libglx, "glXGetProcAddressARB");
|
|
||||||
else
|
|
||||||
*(void**)(&gl_get_proc_address) = dlsym(libgl, "glXGetProcAddressARB");
|
|
||||||
|
|
||||||
if (!gl_get_proc_address) {
|
|
||||||
close_libgl();
|
|
||||||
return GL3W_ERROR_LIBRARY_OPEN;
|
|
||||||
}
|
|
||||||
|
|
||||||
return GL3W_OK;
|
return GL3W_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void close_libgl(void) { dlclose(libgl); }
|
||||||
|
|
||||||
static GL3WglProc get_proc(const char *proc)
|
static GL3WglProc get_proc(const char *proc)
|
||||||
{
|
{
|
||||||
GL3WglProc res = NULL;
|
GL3WglProc res;
|
||||||
|
res = glx_get_proc_address((const GLubyte *)proc);
|
||||||
// Before EGL version 1.5, eglGetProcAddress doesn't support querying core
|
|
||||||
// functions and may return a dummy function if we try, so try to load the
|
|
||||||
// function from the GL library directly first.
|
|
||||||
if (libegl)
|
|
||||||
*(void**)(&res) = dlsym(libgl, proc);
|
|
||||||
|
|
||||||
if (!res)
|
if (!res)
|
||||||
res = gl_get_proc_address(proc);
|
|
||||||
|
|
||||||
if (!libegl && !res)
|
|
||||||
*(void **)(&res) = dlsym(libgl, proc);
|
*(void **)(&res) = dlsym(libgl, proc);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
11
external/imgui/imgui/backends/imgui_impl_osx.mm
vendored
11
external/imgui/imgui/backends/imgui_impl_osx.mm
vendored
@ -84,6 +84,7 @@ struct ImGui_ImplOSX_Data
|
|||||||
ImGui_ImplOSX_Data() { memset(this, 0, sizeof(*this)); }
|
ImGui_ImplOSX_Data() { memset(this, 0, sizeof(*this)); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static ImGui_ImplOSX_Data* ImGui_ImplOSX_CreateBackendData() { return IM_NEW(ImGui_ImplOSX_Data)(); }
|
||||||
static ImGui_ImplOSX_Data* ImGui_ImplOSX_GetBackendData() { return (ImGui_ImplOSX_Data*)ImGui::GetIO().BackendPlatformUserData; }
|
static ImGui_ImplOSX_Data* ImGui_ImplOSX_GetBackendData() { return (ImGui_ImplOSX_Data*)ImGui::GetIO().BackendPlatformUserData; }
|
||||||
static void ImGui_ImplOSX_DestroyBackendData() { IM_DELETE(ImGui_ImplOSX_GetBackendData()); }
|
static void ImGui_ImplOSX_DestroyBackendData() { IM_DELETE(ImGui_ImplOSX_GetBackendData()); }
|
||||||
|
|
||||||
@ -391,15 +392,13 @@ IMGUI_IMPL_API void ImGui_ImplOSX_NewFrame(void* _Nullable view) {
|
|||||||
bool ImGui_ImplOSX_Init(NSView* view)
|
bool ImGui_ImplOSX_Init(NSView* view)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
IMGUI_CHECKVERSION();
|
ImGui_ImplOSX_Data* bd = ImGui_ImplOSX_CreateBackendData();
|
||||||
IM_ASSERT(io.BackendPlatformUserData == nullptr && "Already initialized a platform backend!");
|
io.BackendPlatformUserData = (void*)bd;
|
||||||
|
|
||||||
// Setup backend capabilities flags
|
// Setup backend capabilities flags
|
||||||
ImGui_ImplOSX_Data* bd = IM_NEW(ImGui_ImplOSX_Data)();
|
|
||||||
io.BackendPlatformUserData = (void*)bd;
|
|
||||||
io.BackendPlatformName = "imgui_impl_osx";
|
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
||||||
//io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
//io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
||||||
|
io.BackendPlatformName = "imgui_impl_osx";
|
||||||
|
|
||||||
bd->Observer = [ImGuiObserver new];
|
bd->Observer = [ImGuiObserver new];
|
||||||
|
|
||||||
@ -535,6 +534,7 @@ static void ImGui_ImplOSX_UpdateMouseCursor()
|
|||||||
static void ImGui_ImplOSX_UpdateGamepads()
|
static void ImGui_ImplOSX_UpdateGamepads()
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
memset(io.NavInputs, 0, sizeof(io.NavInputs));
|
||||||
if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0) // FIXME: Technically feeding gamepad shouldn't depend on this now that they are regular inputs.
|
if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0) // FIXME: Technically feeding gamepad shouldn't depend on this now that they are regular inputs.
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -601,7 +601,6 @@ static void ImGui_ImplOSX_UpdateImePosWithView(NSView* view)
|
|||||||
void ImGui_ImplOSX_NewFrame(NSView* view)
|
void ImGui_ImplOSX_NewFrame(NSView* view)
|
||||||
{
|
{
|
||||||
ImGui_ImplOSX_Data* bd = ImGui_ImplOSX_GetBackendData();
|
ImGui_ImplOSX_Data* bd = ImGui_ImplOSX_GetBackendData();
|
||||||
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplOSX_Init()?");
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
// Setup display size
|
// Setup display size
|
||||||
|
173
external/imgui/imgui/backends/imgui_impl_sdl2.cpp
vendored
173
external/imgui/imgui/backends/imgui_impl_sdl2.cpp
vendored
@ -21,7 +21,6 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2024-02-14: Inputs: Handle gamepad disconnection. Added ImGui_ImplSDL2_SetGamepadMode().
|
|
||||||
// 2023-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F24 function keys, app back/forward keys.
|
// 2023-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F24 function keys, app back/forward keys.
|
||||||
// 2023-04-06: Inputs: Avoid calling SDL_StartTextInput()/SDL_StopTextInput() as they don't only pertain to IME. It's unclear exactly what their relation is to IME. (#6306)
|
// 2023-04-06: Inputs: Avoid calling SDL_StartTextInput()/SDL_StopTextInput() as they don't only pertain to IME. It's unclear exactly what their relation is to IME. (#6306)
|
||||||
// 2023-04-04: Inputs: Added support for io.AddMouseSourceEvent() to discriminate ImGuiMouseSource_Mouse/ImGuiMouseSource_TouchScreen. (#2702)
|
// 2023-04-04: Inputs: Added support for io.AddMouseSourceEvent() to discriminate ImGuiMouseSource_Mouse/ImGuiMouseSource_TouchScreen. (#2702)
|
||||||
@ -107,21 +106,14 @@ struct ImGui_ImplSDL2_Data
|
|||||||
SDL_Window* Window;
|
SDL_Window* Window;
|
||||||
SDL_Renderer* Renderer;
|
SDL_Renderer* Renderer;
|
||||||
Uint64 Time;
|
Uint64 Time;
|
||||||
char* ClipboardTextData;
|
|
||||||
|
|
||||||
// Mouse handling
|
|
||||||
Uint32 MouseWindowID;
|
Uint32 MouseWindowID;
|
||||||
int MouseButtonsDown;
|
int MouseButtonsDown;
|
||||||
SDL_Cursor* MouseCursors[ImGuiMouseCursor_COUNT];
|
SDL_Cursor* MouseCursors[ImGuiMouseCursor_COUNT];
|
||||||
SDL_Cursor* MouseLastCursor;
|
SDL_Cursor* LastMouseCursor;
|
||||||
int MouseLastLeaveFrame;
|
int PendingMouseLeaveFrame;
|
||||||
|
char* ClipboardTextData;
|
||||||
bool MouseCanUseGlobalState;
|
bool MouseCanUseGlobalState;
|
||||||
|
|
||||||
// Gamepad handling
|
|
||||||
ImVector<SDL_GameController*> Gamepads;
|
|
||||||
ImGui_ImplSDL2_GamepadMode GamepadMode;
|
|
||||||
bool WantUpdateGamepadsList;
|
|
||||||
|
|
||||||
ImGui_ImplSDL2_Data() { memset((void*)this, 0, sizeof(*this)); }
|
ImGui_ImplSDL2_Data() { memset((void*)this, 0, sizeof(*this)); }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -306,9 +298,8 @@ static void ImGui_ImplSDL2_UpdateKeyModifiers(SDL_Keymod sdl_key_mods)
|
|||||||
// If you have multiple SDL events and some of them are not meant to be used by dear imgui, you may need to filter events based on their windowID field.
|
// If you have multiple SDL events and some of them are not meant to be used by dear imgui, you may need to filter events based on their windowID field.
|
||||||
bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
|
bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
|
||||||
{
|
{
|
||||||
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
|
||||||
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplSDL2_Init()?");
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
||||||
|
|
||||||
switch (event->type)
|
switch (event->type)
|
||||||
{
|
{
|
||||||
@ -377,22 +368,16 @@ bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
|
|||||||
if (window_event == SDL_WINDOWEVENT_ENTER)
|
if (window_event == SDL_WINDOWEVENT_ENTER)
|
||||||
{
|
{
|
||||||
bd->MouseWindowID = event->window.windowID;
|
bd->MouseWindowID = event->window.windowID;
|
||||||
bd->MouseLastLeaveFrame = 0;
|
bd->PendingMouseLeaveFrame = 0;
|
||||||
}
|
}
|
||||||
if (window_event == SDL_WINDOWEVENT_LEAVE)
|
if (window_event == SDL_WINDOWEVENT_LEAVE)
|
||||||
bd->MouseLastLeaveFrame = ImGui::GetFrameCount() + 1;
|
bd->PendingMouseLeaveFrame = ImGui::GetFrameCount() + 1;
|
||||||
if (window_event == SDL_WINDOWEVENT_FOCUS_GAINED)
|
if (window_event == SDL_WINDOWEVENT_FOCUS_GAINED)
|
||||||
io.AddFocusEvent(true);
|
io.AddFocusEvent(true);
|
||||||
else if (event->window.event == SDL_WINDOWEVENT_FOCUS_LOST)
|
else if (event->window.event == SDL_WINDOWEVENT_FOCUS_LOST)
|
||||||
io.AddFocusEvent(false);
|
io.AddFocusEvent(false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case SDL_CONTROLLERDEVICEADDED:
|
|
||||||
case SDL_CONTROLLERDEVICEREMOVED:
|
|
||||||
{
|
|
||||||
bd->WantUpdateGamepadsList = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -400,7 +385,6 @@ bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
|
|||||||
static bool ImGui_ImplSDL2_Init(SDL_Window* window, SDL_Renderer* renderer)
|
static bool ImGui_ImplSDL2_Init(SDL_Window* window, SDL_Renderer* renderer)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
IMGUI_CHECKVERSION();
|
|
||||||
IM_ASSERT(io.BackendPlatformUserData == nullptr && "Already initialized a platform backend!");
|
IM_ASSERT(io.BackendPlatformUserData == nullptr && "Already initialized a platform backend!");
|
||||||
|
|
||||||
// Check and store if we are on a SDL backend that supports global mouse position
|
// Check and store if we are on a SDL backend that supports global mouse position
|
||||||
@ -430,10 +414,6 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window, SDL_Renderer* renderer)
|
|||||||
io.ClipboardUserData = nullptr;
|
io.ClipboardUserData = nullptr;
|
||||||
io.SetPlatformImeDataFn = ImGui_ImplSDL2_SetPlatformImeData;
|
io.SetPlatformImeDataFn = ImGui_ImplSDL2_SetPlatformImeData;
|
||||||
|
|
||||||
// Gamepad handling
|
|
||||||
bd->GamepadMode = ImGui_ImplSDL2_GamepadMode_AutoFirst;
|
|
||||||
bd->WantUpdateGamepadsList = true;
|
|
||||||
|
|
||||||
// Load mouse cursors
|
// Load mouse cursors
|
||||||
bd->MouseCursors[ImGuiMouseCursor_Arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
|
bd->MouseCursors[ImGuiMouseCursor_Arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
|
||||||
bd->MouseCursors[ImGuiMouseCursor_TextInput] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
|
bd->MouseCursors[ImGuiMouseCursor_TextInput] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
|
||||||
@ -521,8 +501,6 @@ bool ImGui_ImplSDL2_InitForOther(SDL_Window* window)
|
|||||||
return ImGui_ImplSDL2_Init(window, nullptr);
|
return ImGui_ImplSDL2_Init(window, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplSDL2_CloseGamepads();
|
|
||||||
|
|
||||||
void ImGui_ImplSDL2_Shutdown()
|
void ImGui_ImplSDL2_Shutdown()
|
||||||
{
|
{
|
||||||
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
||||||
@ -533,7 +511,7 @@ void ImGui_ImplSDL2_Shutdown()
|
|||||||
SDL_free(bd->ClipboardTextData);
|
SDL_free(bd->ClipboardTextData);
|
||||||
for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++)
|
for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++)
|
||||||
SDL_FreeCursor(bd->MouseCursors[cursor_n]);
|
SDL_FreeCursor(bd->MouseCursors[cursor_n]);
|
||||||
ImGui_ImplSDL2_CloseGamepads();
|
bd->LastMouseCursor = nullptr;
|
||||||
|
|
||||||
io.BackendPlatformName = nullptr;
|
io.BackendPlatformName = nullptr;
|
||||||
io.BackendPlatformUserData = nullptr;
|
io.BackendPlatformUserData = nullptr;
|
||||||
@ -589,124 +567,65 @@ static void ImGui_ImplSDL2_UpdateMouseCursor()
|
|||||||
{
|
{
|
||||||
// Show OS mouse cursor
|
// Show OS mouse cursor
|
||||||
SDL_Cursor* expected_cursor = bd->MouseCursors[imgui_cursor] ? bd->MouseCursors[imgui_cursor] : bd->MouseCursors[ImGuiMouseCursor_Arrow];
|
SDL_Cursor* expected_cursor = bd->MouseCursors[imgui_cursor] ? bd->MouseCursors[imgui_cursor] : bd->MouseCursors[ImGuiMouseCursor_Arrow];
|
||||||
if (bd->MouseLastCursor != expected_cursor)
|
if (bd->LastMouseCursor != expected_cursor)
|
||||||
{
|
{
|
||||||
SDL_SetCursor(expected_cursor); // SDL function doesn't have an early out (see #6113)
|
SDL_SetCursor(expected_cursor); // SDL function doesn't have an early out (see #6113)
|
||||||
bd->MouseLastCursor = expected_cursor;
|
bd->LastMouseCursor = expected_cursor;
|
||||||
}
|
}
|
||||||
SDL_ShowCursor(SDL_TRUE);
|
SDL_ShowCursor(SDL_TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplSDL2_CloseGamepads()
|
|
||||||
{
|
|
||||||
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
|
||||||
if (bd->GamepadMode != ImGui_ImplSDL2_GamepadMode_Manual)
|
|
||||||
for (SDL_GameController* gamepad : bd->Gamepads)
|
|
||||||
SDL_GameControllerClose(gamepad);
|
|
||||||
bd->Gamepads.resize(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImGui_ImplSDL2_SetGamepadMode(ImGui_ImplSDL2_GamepadMode mode, struct _SDL_GameController** manual_gamepads_array, int manual_gamepads_count)
|
|
||||||
{
|
|
||||||
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
|
||||||
ImGui_ImplSDL2_CloseGamepads();
|
|
||||||
if (mode == ImGui_ImplSDL2_GamepadMode_Manual)
|
|
||||||
{
|
|
||||||
IM_ASSERT(manual_gamepads_array != nullptr && manual_gamepads_count > 0);
|
|
||||||
for (int n = 0; n < manual_gamepads_count; n++)
|
|
||||||
bd->Gamepads.push_back(manual_gamepads_array[n]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
IM_ASSERT(manual_gamepads_array == nullptr && manual_gamepads_count <= 0);
|
|
||||||
bd->WantUpdateGamepadsList = true;
|
|
||||||
}
|
|
||||||
bd->GamepadMode = mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ImGui_ImplSDL2_UpdateGamepadButton(ImGui_ImplSDL2_Data* bd, ImGuiIO& io, ImGuiKey key, SDL_GameControllerButton button_no)
|
|
||||||
{
|
|
||||||
bool merged_value = false;
|
|
||||||
for (SDL_GameController* gamepad : bd->Gamepads)
|
|
||||||
merged_value |= SDL_GameControllerGetButton(gamepad, button_no) != 0;
|
|
||||||
io.AddKeyEvent(key, merged_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline float Saturate(float v) { return v < 0.0f ? 0.0f : v > 1.0f ? 1.0f : v; }
|
|
||||||
static void ImGui_ImplSDL2_UpdateGamepadAnalog(ImGui_ImplSDL2_Data* bd, ImGuiIO& io, ImGuiKey key, SDL_GameControllerAxis axis_no, float v0, float v1)
|
|
||||||
{
|
|
||||||
float merged_value = 0.0f;
|
|
||||||
for (SDL_GameController* gamepad : bd->Gamepads)
|
|
||||||
{
|
|
||||||
float vn = Saturate((float)(SDL_GameControllerGetAxis(gamepad, axis_no) - v0) / (float)(v1 - v0));
|
|
||||||
if (merged_value < vn)
|
|
||||||
merged_value = vn;
|
|
||||||
}
|
|
||||||
io.AddKeyAnalogEvent(key, merged_value > 0.1f, merged_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ImGui_ImplSDL2_UpdateGamepads()
|
static void ImGui_ImplSDL2_UpdateGamepads()
|
||||||
{
|
{
|
||||||
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0) // FIXME: Technically feeding gamepad shouldn't depend on this now that they are regular inputs.
|
||||||
// Update list of controller(s) to use
|
|
||||||
if (bd->WantUpdateGamepadsList && bd->GamepadMode != ImGui_ImplSDL2_GamepadMode_Manual)
|
|
||||||
{
|
|
||||||
ImGui_ImplSDL2_CloseGamepads();
|
|
||||||
int joystick_count = SDL_NumJoysticks();
|
|
||||||
for (int n = 0; n < joystick_count; n++)
|
|
||||||
if (SDL_IsGameController(n))
|
|
||||||
if (SDL_GameController* gamepad = SDL_GameControllerOpen(n))
|
|
||||||
{
|
|
||||||
bd->Gamepads.push_back(gamepad);
|
|
||||||
if (bd->GamepadMode == ImGui_ImplSDL2_GamepadMode_AutoFirst)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
bd->WantUpdateGamepadsList = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: Technically feeding gamepad shouldn't depend on this now that they are regular inputs.
|
|
||||||
if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Get gamepad
|
||||||
io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
|
io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
|
||||||
if (bd->Gamepads.Size == 0)
|
SDL_GameController* game_controller = SDL_GameControllerOpen(0);
|
||||||
|
if (!game_controller)
|
||||||
return;
|
return;
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
|
io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
|
||||||
|
|
||||||
// Update gamepad inputs
|
// Update gamepad inputs
|
||||||
|
#define IM_SATURATE(V) (V < 0.0f ? 0.0f : V > 1.0f ? 1.0f : V)
|
||||||
|
#define MAP_BUTTON(KEY_NO, BUTTON_NO) { io.AddKeyEvent(KEY_NO, SDL_GameControllerGetButton(game_controller, BUTTON_NO) != 0); }
|
||||||
|
#define MAP_ANALOG(KEY_NO, AXIS_NO, V0, V1) { float vn = (float)(SDL_GameControllerGetAxis(game_controller, AXIS_NO) - V0) / (float)(V1 - V0); vn = IM_SATURATE(vn); io.AddKeyAnalogEvent(KEY_NO, vn > 0.1f, vn); }
|
||||||
const int thumb_dead_zone = 8000; // SDL_gamecontroller.h suggests using this value.
|
const int thumb_dead_zone = 8000; // SDL_gamecontroller.h suggests using this value.
|
||||||
ImGui_ImplSDL2_UpdateGamepadButton(bd, io, ImGuiKey_GamepadStart, SDL_CONTROLLER_BUTTON_START);
|
MAP_BUTTON(ImGuiKey_GamepadStart, SDL_CONTROLLER_BUTTON_START);
|
||||||
ImGui_ImplSDL2_UpdateGamepadButton(bd, io, ImGuiKey_GamepadBack, SDL_CONTROLLER_BUTTON_BACK);
|
MAP_BUTTON(ImGuiKey_GamepadBack, SDL_CONTROLLER_BUTTON_BACK);
|
||||||
ImGui_ImplSDL2_UpdateGamepadButton(bd, io, ImGuiKey_GamepadFaceLeft, SDL_CONTROLLER_BUTTON_X); // Xbox X, PS Square
|
MAP_BUTTON(ImGuiKey_GamepadFaceLeft, SDL_CONTROLLER_BUTTON_X); // Xbox X, PS Square
|
||||||
ImGui_ImplSDL2_UpdateGamepadButton(bd, io, ImGuiKey_GamepadFaceRight, SDL_CONTROLLER_BUTTON_B); // Xbox B, PS Circle
|
MAP_BUTTON(ImGuiKey_GamepadFaceRight, SDL_CONTROLLER_BUTTON_B); // Xbox B, PS Circle
|
||||||
ImGui_ImplSDL2_UpdateGamepadButton(bd, io, ImGuiKey_GamepadFaceUp, SDL_CONTROLLER_BUTTON_Y); // Xbox Y, PS Triangle
|
MAP_BUTTON(ImGuiKey_GamepadFaceUp, SDL_CONTROLLER_BUTTON_Y); // Xbox Y, PS Triangle
|
||||||
ImGui_ImplSDL2_UpdateGamepadButton(bd, io, ImGuiKey_GamepadFaceDown, SDL_CONTROLLER_BUTTON_A); // Xbox A, PS Cross
|
MAP_BUTTON(ImGuiKey_GamepadFaceDown, SDL_CONTROLLER_BUTTON_A); // Xbox A, PS Cross
|
||||||
ImGui_ImplSDL2_UpdateGamepadButton(bd, io, ImGuiKey_GamepadDpadLeft, SDL_CONTROLLER_BUTTON_DPAD_LEFT);
|
MAP_BUTTON(ImGuiKey_GamepadDpadLeft, SDL_CONTROLLER_BUTTON_DPAD_LEFT);
|
||||||
ImGui_ImplSDL2_UpdateGamepadButton(bd, io, ImGuiKey_GamepadDpadRight, SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
|
MAP_BUTTON(ImGuiKey_GamepadDpadRight, SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
|
||||||
ImGui_ImplSDL2_UpdateGamepadButton(bd, io, ImGuiKey_GamepadDpadUp, SDL_CONTROLLER_BUTTON_DPAD_UP);
|
MAP_BUTTON(ImGuiKey_GamepadDpadUp, SDL_CONTROLLER_BUTTON_DPAD_UP);
|
||||||
ImGui_ImplSDL2_UpdateGamepadButton(bd, io, ImGuiKey_GamepadDpadDown, SDL_CONTROLLER_BUTTON_DPAD_DOWN);
|
MAP_BUTTON(ImGuiKey_GamepadDpadDown, SDL_CONTROLLER_BUTTON_DPAD_DOWN);
|
||||||
ImGui_ImplSDL2_UpdateGamepadButton(bd, io, ImGuiKey_GamepadL1, SDL_CONTROLLER_BUTTON_LEFTSHOULDER);
|
MAP_BUTTON(ImGuiKey_GamepadL1, SDL_CONTROLLER_BUTTON_LEFTSHOULDER);
|
||||||
ImGui_ImplSDL2_UpdateGamepadButton(bd, io, ImGuiKey_GamepadR1, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER);
|
MAP_BUTTON(ImGuiKey_GamepadR1, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER);
|
||||||
ImGui_ImplSDL2_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadL2, SDL_CONTROLLER_AXIS_TRIGGERLEFT, 0.0f, 32767);
|
MAP_ANALOG(ImGuiKey_GamepadL2, SDL_CONTROLLER_AXIS_TRIGGERLEFT, 0.0f, 32767);
|
||||||
ImGui_ImplSDL2_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadR2, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, 0.0f, 32767);
|
MAP_ANALOG(ImGuiKey_GamepadR2, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, 0.0f, 32767);
|
||||||
ImGui_ImplSDL2_UpdateGamepadButton(bd, io, ImGuiKey_GamepadL3, SDL_CONTROLLER_BUTTON_LEFTSTICK);
|
MAP_BUTTON(ImGuiKey_GamepadL3, SDL_CONTROLLER_BUTTON_LEFTSTICK);
|
||||||
ImGui_ImplSDL2_UpdateGamepadButton(bd, io, ImGuiKey_GamepadR3, SDL_CONTROLLER_BUTTON_RIGHTSTICK);
|
MAP_BUTTON(ImGuiKey_GamepadR3, SDL_CONTROLLER_BUTTON_RIGHTSTICK);
|
||||||
ImGui_ImplSDL2_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadLStickLeft, SDL_CONTROLLER_AXIS_LEFTX, -thumb_dead_zone, -32768);
|
MAP_ANALOG(ImGuiKey_GamepadLStickLeft, SDL_CONTROLLER_AXIS_LEFTX, -thumb_dead_zone, -32768);
|
||||||
ImGui_ImplSDL2_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadLStickRight, SDL_CONTROLLER_AXIS_LEFTX, +thumb_dead_zone, +32767);
|
MAP_ANALOG(ImGuiKey_GamepadLStickRight, SDL_CONTROLLER_AXIS_LEFTX, +thumb_dead_zone, +32767);
|
||||||
ImGui_ImplSDL2_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadLStickUp, SDL_CONTROLLER_AXIS_LEFTY, -thumb_dead_zone, -32768);
|
MAP_ANALOG(ImGuiKey_GamepadLStickUp, SDL_CONTROLLER_AXIS_LEFTY, -thumb_dead_zone, -32768);
|
||||||
ImGui_ImplSDL2_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadLStickDown, SDL_CONTROLLER_AXIS_LEFTY, +thumb_dead_zone, +32767);
|
MAP_ANALOG(ImGuiKey_GamepadLStickDown, SDL_CONTROLLER_AXIS_LEFTY, +thumb_dead_zone, +32767);
|
||||||
ImGui_ImplSDL2_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadRStickLeft, SDL_CONTROLLER_AXIS_RIGHTX, -thumb_dead_zone, -32768);
|
MAP_ANALOG(ImGuiKey_GamepadRStickLeft, SDL_CONTROLLER_AXIS_RIGHTX, -thumb_dead_zone, -32768);
|
||||||
ImGui_ImplSDL2_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadRStickRight, SDL_CONTROLLER_AXIS_RIGHTX, +thumb_dead_zone, +32767);
|
MAP_ANALOG(ImGuiKey_GamepadRStickRight, SDL_CONTROLLER_AXIS_RIGHTX, +thumb_dead_zone, +32767);
|
||||||
ImGui_ImplSDL2_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadRStickUp, SDL_CONTROLLER_AXIS_RIGHTY, -thumb_dead_zone, -32768);
|
MAP_ANALOG(ImGuiKey_GamepadRStickUp, SDL_CONTROLLER_AXIS_RIGHTY, -thumb_dead_zone, -32768);
|
||||||
ImGui_ImplSDL2_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadRStickDown, SDL_CONTROLLER_AXIS_RIGHTY, +thumb_dead_zone, +32767);
|
MAP_ANALOG(ImGuiKey_GamepadRStickDown, SDL_CONTROLLER_AXIS_RIGHTY, +thumb_dead_zone, +32767);
|
||||||
|
#undef MAP_BUTTON
|
||||||
|
#undef MAP_ANALOG
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplSDL2_NewFrame()
|
void ImGui_ImplSDL2_NewFrame()
|
||||||
{
|
{
|
||||||
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
||||||
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplSDL2_Init()?");
|
IM_ASSERT(bd != nullptr && "Did you call ImGui_ImplSDL2_Init()?");
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
// Setup display size (every frame to accommodate for window resizing)
|
// Setup display size (every frame to accommodate for window resizing)
|
||||||
@ -732,10 +651,10 @@ void ImGui_ImplSDL2_NewFrame()
|
|||||||
io.DeltaTime = bd->Time > 0 ? (float)((double)(current_time - bd->Time) / frequency) : (float)(1.0f / 60.0f);
|
io.DeltaTime = bd->Time > 0 ? (float)((double)(current_time - bd->Time) / frequency) : (float)(1.0f / 60.0f);
|
||||||
bd->Time = current_time;
|
bd->Time = current_time;
|
||||||
|
|
||||||
if (bd->MouseLastLeaveFrame && bd->MouseLastLeaveFrame >= ImGui::GetFrameCount() && bd->MouseButtonsDown == 0)
|
if (bd->PendingMouseLeaveFrame && bd->PendingMouseLeaveFrame >= ImGui::GetFrameCount() && bd->MouseButtonsDown == 0)
|
||||||
{
|
{
|
||||||
bd->MouseWindowID = 0;
|
bd->MouseWindowID = 0;
|
||||||
bd->MouseLastLeaveFrame = 0;
|
bd->PendingMouseLeaveFrame = 0;
|
||||||
io.AddMousePosEvent(-FLT_MAX, -FLT_MAX);
|
io.AddMousePosEvent(-FLT_MAX, -FLT_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
struct SDL_Window;
|
struct SDL_Window;
|
||||||
struct SDL_Renderer;
|
struct SDL_Renderer;
|
||||||
struct _SDL_GameController;
|
|
||||||
typedef union SDL_Event SDL_Event;
|
typedef union SDL_Event SDL_Event;
|
||||||
|
|
||||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context);
|
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context);
|
||||||
@ -37,9 +36,8 @@ IMGUI_IMPL_API void ImGui_ImplSDL2_Shutdown();
|
|||||||
IMGUI_IMPL_API void ImGui_ImplSDL2_NewFrame();
|
IMGUI_IMPL_API void ImGui_ImplSDL2_NewFrame();
|
||||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event);
|
IMGUI_IMPL_API bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event);
|
||||||
|
|
||||||
// Gamepad selection automatically starts in AutoFirst mode, picking first available SDL_Gamepad. You may override this.
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
// When using manual mode, caller is responsible for opening/closing gamepad.
|
static inline void ImGui_ImplSDL2_NewFrame(SDL_Window*) { ImGui_ImplSDL2_NewFrame(); } // 1.84: removed unnecessary parameter
|
||||||
enum ImGui_ImplSDL2_GamepadMode { ImGui_ImplSDL2_GamepadMode_AutoFirst, ImGui_ImplSDL2_GamepadMode_AutoAll, ImGui_ImplSDL2_GamepadMode_Manual };
|
#endif
|
||||||
IMGUI_IMPL_API void ImGui_ImplSDL2_SetGamepadMode(ImGui_ImplSDL2_GamepadMode mode, struct _SDL_GameController** manual_gamepads_array = NULL, int manual_gamepads_count = -1);
|
|
||||||
|
|
||||||
#endif // #ifndef IMGUI_DISABLE
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
196
external/imgui/imgui/backends/imgui_impl_sdl3.cpp
vendored
196
external/imgui/imgui/backends/imgui_impl_sdl3.cpp
vendored
@ -10,7 +10,7 @@
|
|||||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
// Missing features:
|
// Missing features:
|
||||||
// [ ] Platform: IME SUPPORT IS BROKEN IN SDL3 BECAUSE INPUTS GETS SENT TO BOTH APP AND IME + app needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!.
|
// [x] Platform: Basic IME support. Position somehow broken in SDL3 + app needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
@ -22,8 +22,6 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2024-04-15: Inputs: Re-enable calling SDL_StartTextInput()/SDL_StopTextInput() as SDL3 no longer enables it by default and should play nicer with IME.
|
|
||||||
// 2024-02-13: Inputs: Fixed gamepad support. Handle gamepad disconnection. Added ImGui_ImplSDL3_SetGamepadMode().
|
|
||||||
// 2023-11-13: Updated for recent SDL3 API changes.
|
// 2023-11-13: Updated for recent SDL3 API changes.
|
||||||
// 2023-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F24 function keys, app back/forward keys.
|
// 2023-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F24 function keys, app back/forward keys.
|
||||||
// 2023-05-04: Fixed build on Emscripten/iOS/Android. (#6391)
|
// 2023-05-04: Fixed build on Emscripten/iOS/Android. (#6391)
|
||||||
@ -60,35 +58,20 @@
|
|||||||
#define SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE 0
|
#define SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// FIXME-LEGACY: remove when SDL 3.1.3 preview is released.
|
|
||||||
#ifndef SDLK_APOSTROPHE
|
|
||||||
#define SDLK_APOSTROPHE SDLK_QUOTE
|
|
||||||
#endif
|
|
||||||
#ifndef SDLK_GRAVE
|
|
||||||
#define SDLK_GRAVE SDLK_BACKQUOTE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// SDL Data
|
// SDL Data
|
||||||
struct ImGui_ImplSDL3_Data
|
struct ImGui_ImplSDL3_Data
|
||||||
{
|
{
|
||||||
SDL_Window* Window;
|
SDL_Window* Window;
|
||||||
SDL_Renderer* Renderer;
|
SDL_Renderer* Renderer;
|
||||||
Uint64 Time;
|
Uint64 Time;
|
||||||
char* ClipboardTextData;
|
|
||||||
|
|
||||||
// Mouse handling
|
|
||||||
Uint32 MouseWindowID;
|
Uint32 MouseWindowID;
|
||||||
int MouseButtonsDown;
|
int MouseButtonsDown;
|
||||||
SDL_Cursor* MouseCursors[ImGuiMouseCursor_COUNT];
|
SDL_Cursor* MouseCursors[ImGuiMouseCursor_COUNT];
|
||||||
SDL_Cursor* MouseLastCursor;
|
SDL_Cursor* LastMouseCursor;
|
||||||
int MousePendingLeaveFrame;
|
int PendingMouseLeaveFrame;
|
||||||
|
char* ClipboardTextData;
|
||||||
bool MouseCanUseGlobalState;
|
bool MouseCanUseGlobalState;
|
||||||
|
|
||||||
// Gamepad handling
|
|
||||||
ImVector<SDL_Gamepad*> Gamepads;
|
|
||||||
ImGui_ImplSDL3_GamepadMode GamepadMode;
|
|
||||||
bool WantUpdateGamepadsList;
|
|
||||||
|
|
||||||
ImGui_ImplSDL3_Data() { memset((void*)this, 0, sizeof(*this)); }
|
ImGui_ImplSDL3_Data() { memset((void*)this, 0, sizeof(*this)); }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -126,11 +109,6 @@ static void ImGui_ImplSDL3_SetPlatformImeData(ImGuiViewport*, ImGuiPlatformImeDa
|
|||||||
r.w = 1;
|
r.w = 1;
|
||||||
r.h = (int)data->InputLineHeight;
|
r.h = (int)data->InputLineHeight;
|
||||||
SDL_SetTextInputRect(&r);
|
SDL_SetTextInputRect(&r);
|
||||||
SDL_StartTextInput();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SDL_StopTextInput();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,7 +131,7 @@ static ImGuiKey ImGui_ImplSDL3_KeycodeToImGuiKey(int keycode)
|
|||||||
case SDLK_SPACE: return ImGuiKey_Space;
|
case SDLK_SPACE: return ImGuiKey_Space;
|
||||||
case SDLK_RETURN: return ImGuiKey_Enter;
|
case SDLK_RETURN: return ImGuiKey_Enter;
|
||||||
case SDLK_ESCAPE: return ImGuiKey_Escape;
|
case SDLK_ESCAPE: return ImGuiKey_Escape;
|
||||||
case SDLK_APOSTROPHE: return ImGuiKey_Apostrophe;
|
case SDLK_QUOTE: return ImGuiKey_Apostrophe;
|
||||||
case SDLK_COMMA: return ImGuiKey_Comma;
|
case SDLK_COMMA: return ImGuiKey_Comma;
|
||||||
case SDLK_MINUS: return ImGuiKey_Minus;
|
case SDLK_MINUS: return ImGuiKey_Minus;
|
||||||
case SDLK_PERIOD: return ImGuiKey_Period;
|
case SDLK_PERIOD: return ImGuiKey_Period;
|
||||||
@ -163,7 +141,7 @@ static ImGuiKey ImGui_ImplSDL3_KeycodeToImGuiKey(int keycode)
|
|||||||
case SDLK_LEFTBRACKET: return ImGuiKey_LeftBracket;
|
case SDLK_LEFTBRACKET: return ImGuiKey_LeftBracket;
|
||||||
case SDLK_BACKSLASH: return ImGuiKey_Backslash;
|
case SDLK_BACKSLASH: return ImGuiKey_Backslash;
|
||||||
case SDLK_RIGHTBRACKET: return ImGuiKey_RightBracket;
|
case SDLK_RIGHTBRACKET: return ImGuiKey_RightBracket;
|
||||||
case SDLK_GRAVE: return ImGuiKey_GraveAccent;
|
case SDLK_BACKQUOTE: return ImGuiKey_GraveAccent;
|
||||||
case SDLK_CAPSLOCK: return ImGuiKey_CapsLock;
|
case SDLK_CAPSLOCK: return ImGuiKey_CapsLock;
|
||||||
case SDLK_SCROLLLOCK: return ImGuiKey_ScrollLock;
|
case SDLK_SCROLLLOCK: return ImGuiKey_ScrollLock;
|
||||||
case SDLK_NUMLOCKCLEAR: return ImGuiKey_NumLock;
|
case SDLK_NUMLOCKCLEAR: return ImGuiKey_NumLock;
|
||||||
@ -277,9 +255,8 @@ static void ImGui_ImplSDL3_UpdateKeyModifiers(SDL_Keymod sdl_key_mods)
|
|||||||
// If you have multiple SDL events and some of them are not meant to be used by dear imgui, you may need to filter events based on their windowID field.
|
// If you have multiple SDL events and some of them are not meant to be used by dear imgui, you may need to filter events based on their windowID field.
|
||||||
bool ImGui_ImplSDL3_ProcessEvent(const SDL_Event* event)
|
bool ImGui_ImplSDL3_ProcessEvent(const SDL_Event* event)
|
||||||
{
|
{
|
||||||
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
|
||||||
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplSDL3_Init()?");
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
||||||
|
|
||||||
switch (event->type)
|
switch (event->type)
|
||||||
{
|
{
|
||||||
@ -335,7 +312,7 @@ bool ImGui_ImplSDL3_ProcessEvent(const SDL_Event* event)
|
|||||||
case SDL_EVENT_WINDOW_MOUSE_ENTER:
|
case SDL_EVENT_WINDOW_MOUSE_ENTER:
|
||||||
{
|
{
|
||||||
bd->MouseWindowID = event->window.windowID;
|
bd->MouseWindowID = event->window.windowID;
|
||||||
bd->MousePendingLeaveFrame = 0;
|
bd->PendingMouseLeaveFrame = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// - In some cases, when detaching a window from main viewport SDL may send SDL_WINDOWEVENT_ENTER one frame too late,
|
// - In some cases, when detaching a window from main viewport SDL may send SDL_WINDOWEVENT_ENTER one frame too late,
|
||||||
@ -344,7 +321,7 @@ bool ImGui_ImplSDL3_ProcessEvent(const SDL_Event* event)
|
|||||||
// FIXME: Unconfirmed whether this is still needed with SDL3.
|
// FIXME: Unconfirmed whether this is still needed with SDL3.
|
||||||
case SDL_EVENT_WINDOW_MOUSE_LEAVE:
|
case SDL_EVENT_WINDOW_MOUSE_LEAVE:
|
||||||
{
|
{
|
||||||
bd->MousePendingLeaveFrame = ImGui::GetFrameCount() + 1;
|
bd->PendingMouseLeaveFrame = ImGui::GetFrameCount() + 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case SDL_EVENT_WINDOW_FOCUS_GAINED:
|
case SDL_EVENT_WINDOW_FOCUS_GAINED:
|
||||||
@ -353,12 +330,6 @@ bool ImGui_ImplSDL3_ProcessEvent(const SDL_Event* event)
|
|||||||
case SDL_EVENT_WINDOW_FOCUS_LOST:
|
case SDL_EVENT_WINDOW_FOCUS_LOST:
|
||||||
io.AddFocusEvent(false);
|
io.AddFocusEvent(false);
|
||||||
return true;
|
return true;
|
||||||
case SDL_EVENT_GAMEPAD_ADDED:
|
|
||||||
case SDL_EVENT_GAMEPAD_REMOVED:
|
|
||||||
{
|
|
||||||
bd->WantUpdateGamepadsList = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -377,7 +348,6 @@ static void ImGui_ImplSDL3_SetupPlatformHandles(ImGuiViewport* viewport, SDL_Win
|
|||||||
static bool ImGui_ImplSDL3_Init(SDL_Window* window, SDL_Renderer* renderer, void* sdl_gl_context)
|
static bool ImGui_ImplSDL3_Init(SDL_Window* window, SDL_Renderer* renderer, void* sdl_gl_context)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
IMGUI_CHECKVERSION();
|
|
||||||
IM_ASSERT(io.BackendPlatformUserData == nullptr && "Already initialized a platform backend!");
|
IM_ASSERT(io.BackendPlatformUserData == nullptr && "Already initialized a platform backend!");
|
||||||
IM_UNUSED(sdl_gl_context); // Unused in this branch
|
IM_UNUSED(sdl_gl_context); // Unused in this branch
|
||||||
|
|
||||||
@ -408,10 +378,6 @@ static bool ImGui_ImplSDL3_Init(SDL_Window* window, SDL_Renderer* renderer, void
|
|||||||
io.ClipboardUserData = nullptr;
|
io.ClipboardUserData = nullptr;
|
||||||
io.SetPlatformImeDataFn = ImGui_ImplSDL3_SetPlatformImeData;
|
io.SetPlatformImeDataFn = ImGui_ImplSDL3_SetPlatformImeData;
|
||||||
|
|
||||||
// Gamepad handling
|
|
||||||
bd->GamepadMode = ImGui_ImplSDL3_GamepadMode_AutoFirst;
|
|
||||||
bd->WantUpdateGamepadsList = true;
|
|
||||||
|
|
||||||
// Load mouse cursors
|
// Load mouse cursors
|
||||||
bd->MouseCursors[ImGuiMouseCursor_Arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
|
bd->MouseCursors[ImGuiMouseCursor_Arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
|
||||||
bd->MouseCursors[ImGuiMouseCursor_TextInput] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
|
bd->MouseCursors[ImGuiMouseCursor_TextInput] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
|
||||||
@ -479,8 +445,6 @@ bool ImGui_ImplSDL3_InitForOther(SDL_Window* window)
|
|||||||
return ImGui_ImplSDL3_Init(window, nullptr, nullptr);
|
return ImGui_ImplSDL3_Init(window, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplSDL3_CloseGamepads();
|
|
||||||
|
|
||||||
void ImGui_ImplSDL3_Shutdown()
|
void ImGui_ImplSDL3_Shutdown()
|
||||||
{
|
{
|
||||||
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
||||||
@ -491,7 +455,7 @@ void ImGui_ImplSDL3_Shutdown()
|
|||||||
SDL_free(bd->ClipboardTextData);
|
SDL_free(bd->ClipboardTextData);
|
||||||
for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++)
|
for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++)
|
||||||
SDL_DestroyCursor(bd->MouseCursors[cursor_n]);
|
SDL_DestroyCursor(bd->MouseCursors[cursor_n]);
|
||||||
ImGui_ImplSDL3_CloseGamepads();
|
bd->LastMouseCursor = nullptr;
|
||||||
|
|
||||||
io.BackendPlatformName = nullptr;
|
io.BackendPlatformName = nullptr;
|
||||||
io.BackendPlatformUserData = nullptr;
|
io.BackendPlatformUserData = nullptr;
|
||||||
@ -550,125 +514,65 @@ static void ImGui_ImplSDL3_UpdateMouseCursor()
|
|||||||
{
|
{
|
||||||
// Show OS mouse cursor
|
// Show OS mouse cursor
|
||||||
SDL_Cursor* expected_cursor = bd->MouseCursors[imgui_cursor] ? bd->MouseCursors[imgui_cursor] : bd->MouseCursors[ImGuiMouseCursor_Arrow];
|
SDL_Cursor* expected_cursor = bd->MouseCursors[imgui_cursor] ? bd->MouseCursors[imgui_cursor] : bd->MouseCursors[ImGuiMouseCursor_Arrow];
|
||||||
if (bd->MouseLastCursor != expected_cursor)
|
if (bd->LastMouseCursor != expected_cursor)
|
||||||
{
|
{
|
||||||
SDL_SetCursor(expected_cursor); // SDL function doesn't have an early out (see #6113)
|
SDL_SetCursor(expected_cursor); // SDL function doesn't have an early out (see #6113)
|
||||||
bd->MouseLastCursor = expected_cursor;
|
bd->LastMouseCursor = expected_cursor;
|
||||||
}
|
}
|
||||||
SDL_ShowCursor();
|
SDL_ShowCursor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplSDL3_CloseGamepads()
|
|
||||||
{
|
|
||||||
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
|
||||||
if (bd->GamepadMode != ImGui_ImplSDL3_GamepadMode_Manual)
|
|
||||||
for (SDL_Gamepad* gamepad : bd->Gamepads)
|
|
||||||
SDL_CloseGamepad(gamepad);
|
|
||||||
bd->Gamepads.resize(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImGui_ImplSDL3_SetGamepadMode(ImGui_ImplSDL3_GamepadMode mode, SDL_Gamepad** manual_gamepads_array, int manual_gamepads_count)
|
|
||||||
{
|
|
||||||
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
|
||||||
ImGui_ImplSDL3_CloseGamepads();
|
|
||||||
if (mode == ImGui_ImplSDL3_GamepadMode_Manual)
|
|
||||||
{
|
|
||||||
IM_ASSERT(manual_gamepads_array != nullptr && manual_gamepads_count > 0);
|
|
||||||
for (int n = 0; n < manual_gamepads_count; n++)
|
|
||||||
bd->Gamepads.push_back(manual_gamepads_array[n]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
IM_ASSERT(manual_gamepads_array == nullptr && manual_gamepads_count <= 0);
|
|
||||||
bd->WantUpdateGamepadsList = true;
|
|
||||||
}
|
|
||||||
bd->GamepadMode = mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ImGui_ImplSDL3_UpdateGamepadButton(ImGui_ImplSDL3_Data* bd, ImGuiIO& io, ImGuiKey key, SDL_GamepadButton button_no)
|
|
||||||
{
|
|
||||||
bool merged_value = false;
|
|
||||||
for (SDL_Gamepad* gamepad : bd->Gamepads)
|
|
||||||
merged_value |= SDL_GetGamepadButton(gamepad, button_no) != 0;
|
|
||||||
io.AddKeyEvent(key, merged_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline float Saturate(float v) { return v < 0.0f ? 0.0f : v > 1.0f ? 1.0f : v; }
|
|
||||||
static void ImGui_ImplSDL3_UpdateGamepadAnalog(ImGui_ImplSDL3_Data* bd, ImGuiIO& io, ImGuiKey key, SDL_GamepadAxis axis_no, float v0, float v1)
|
|
||||||
{
|
|
||||||
float merged_value = 0.0f;
|
|
||||||
for (SDL_Gamepad* gamepad : bd->Gamepads)
|
|
||||||
{
|
|
||||||
float vn = Saturate((float)(SDL_GetGamepadAxis(gamepad, axis_no) - v0) / (float)(v1 - v0));
|
|
||||||
if (merged_value < vn)
|
|
||||||
merged_value = vn;
|
|
||||||
}
|
|
||||||
io.AddKeyAnalogEvent(key, merged_value > 0.1f, merged_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ImGui_ImplSDL3_UpdateGamepads()
|
static void ImGui_ImplSDL3_UpdateGamepads()
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0) // FIXME: Technically feeding gamepad shouldn't depend on this now that they are regular inputs.
|
||||||
|
|
||||||
// Update list of gamepads to use
|
|
||||||
if (bd->WantUpdateGamepadsList && bd->GamepadMode != ImGui_ImplSDL3_GamepadMode_Manual)
|
|
||||||
{
|
|
||||||
ImGui_ImplSDL3_CloseGamepads();
|
|
||||||
int sdl_gamepads_count = 0;
|
|
||||||
SDL_JoystickID* sdl_gamepads = SDL_GetGamepads(&sdl_gamepads_count);
|
|
||||||
for (int n = 0; n < sdl_gamepads_count; n++)
|
|
||||||
if (SDL_Gamepad* gamepad = SDL_OpenGamepad(sdl_gamepads[n]))
|
|
||||||
{
|
|
||||||
bd->Gamepads.push_back(gamepad);
|
|
||||||
if (bd->GamepadMode == ImGui_ImplSDL3_GamepadMode_AutoFirst)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
SDL_free(sdl_gamepads);
|
|
||||||
bd->WantUpdateGamepadsList = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: Technically feeding gamepad shouldn't depend on this now that they are regular inputs.
|
|
||||||
if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Get gamepad
|
||||||
io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
|
io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
|
||||||
if (bd->Gamepads.Size == 0)
|
SDL_Gamepad* gamepad = SDL_OpenGamepad(0);
|
||||||
|
if (!gamepad)
|
||||||
return;
|
return;
|
||||||
io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
|
io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
|
||||||
|
|
||||||
// Update gamepad inputs
|
// Update gamepad inputs
|
||||||
const int thumb_dead_zone = 8000; // SDL_gamepad.h suggests using this value.
|
#define IM_SATURATE(V) (V < 0.0f ? 0.0f : V > 1.0f ? 1.0f : V)
|
||||||
ImGui_ImplSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadStart, SDL_GAMEPAD_BUTTON_START);
|
#define MAP_BUTTON(KEY_NO, BUTTON_NO) { io.AddKeyEvent(KEY_NO, SDL_GetGamepadButton(gamepad, BUTTON_NO) != 0); }
|
||||||
ImGui_ImplSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadBack, SDL_GAMEPAD_BUTTON_BACK);
|
#define MAP_ANALOG(KEY_NO, AXIS_NO, V0, V1) { float vn = (float)(SDL_GetGamepadAxis(gamepad, AXIS_NO) - V0) / (float)(V1 - V0); vn = IM_SATURATE(vn); io.AddKeyAnalogEvent(KEY_NO, vn > 0.1f, vn); }
|
||||||
ImGui_ImplSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadFaceLeft, SDL_GAMEPAD_BUTTON_WEST); // Xbox X, PS Square
|
const int thumb_dead_zone = 8000; // SDL_gamecontroller.h suggests using this value.
|
||||||
ImGui_ImplSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadFaceRight, SDL_GAMEPAD_BUTTON_EAST); // Xbox B, PS Circle
|
MAP_BUTTON(ImGuiKey_GamepadStart, SDL_GAMEPAD_BUTTON_START);
|
||||||
ImGui_ImplSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadFaceUp, SDL_GAMEPAD_BUTTON_NORTH); // Xbox Y, PS Triangle
|
MAP_BUTTON(ImGuiKey_GamepadBack, SDL_GAMEPAD_BUTTON_BACK);
|
||||||
ImGui_ImplSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadFaceDown, SDL_GAMEPAD_BUTTON_SOUTH); // Xbox A, PS Cross
|
MAP_BUTTON(ImGuiKey_GamepadFaceLeft, SDL_GAMEPAD_BUTTON_WEST); // Xbox X, PS Square
|
||||||
ImGui_ImplSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadDpadLeft, SDL_GAMEPAD_BUTTON_DPAD_LEFT);
|
MAP_BUTTON(ImGuiKey_GamepadFaceRight, SDL_GAMEPAD_BUTTON_EAST); // Xbox B, PS Circle
|
||||||
ImGui_ImplSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadDpadRight, SDL_GAMEPAD_BUTTON_DPAD_RIGHT);
|
MAP_BUTTON(ImGuiKey_GamepadFaceUp, SDL_GAMEPAD_BUTTON_NORTH); // Xbox Y, PS Triangle
|
||||||
ImGui_ImplSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadDpadUp, SDL_GAMEPAD_BUTTON_DPAD_UP);
|
MAP_BUTTON(ImGuiKey_GamepadFaceDown, SDL_GAMEPAD_BUTTON_SOUTH); // Xbox A, PS Cross
|
||||||
ImGui_ImplSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadDpadDown, SDL_GAMEPAD_BUTTON_DPAD_DOWN);
|
MAP_BUTTON(ImGuiKey_GamepadDpadLeft, SDL_GAMEPAD_BUTTON_DPAD_LEFT);
|
||||||
ImGui_ImplSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadL1, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER);
|
MAP_BUTTON(ImGuiKey_GamepadDpadRight, SDL_GAMEPAD_BUTTON_DPAD_RIGHT);
|
||||||
ImGui_ImplSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadR1, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER);
|
MAP_BUTTON(ImGuiKey_GamepadDpadUp, SDL_GAMEPAD_BUTTON_DPAD_UP);
|
||||||
ImGui_ImplSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadL2, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, 0.0f, 32767);
|
MAP_BUTTON(ImGuiKey_GamepadDpadDown, SDL_GAMEPAD_BUTTON_DPAD_DOWN);
|
||||||
ImGui_ImplSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadR2, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, 0.0f, 32767);
|
MAP_BUTTON(ImGuiKey_GamepadL1, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER);
|
||||||
ImGui_ImplSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadL3, SDL_GAMEPAD_BUTTON_LEFT_STICK);
|
MAP_BUTTON(ImGuiKey_GamepadR1, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER);
|
||||||
ImGui_ImplSDL3_UpdateGamepadButton(bd, io, ImGuiKey_GamepadR3, SDL_GAMEPAD_BUTTON_RIGHT_STICK);
|
MAP_ANALOG(ImGuiKey_GamepadL2, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, 0.0f, 32767);
|
||||||
ImGui_ImplSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadLStickLeft, SDL_GAMEPAD_AXIS_LEFTX, -thumb_dead_zone, -32768);
|
MAP_ANALOG(ImGuiKey_GamepadR2, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, 0.0f, 32767);
|
||||||
ImGui_ImplSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadLStickRight, SDL_GAMEPAD_AXIS_LEFTX, +thumb_dead_zone, +32767);
|
MAP_BUTTON(ImGuiKey_GamepadL3, SDL_GAMEPAD_BUTTON_LEFT_STICK);
|
||||||
ImGui_ImplSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadLStickUp, SDL_GAMEPAD_AXIS_LEFTY, -thumb_dead_zone, -32768);
|
MAP_BUTTON(ImGuiKey_GamepadR3, SDL_GAMEPAD_BUTTON_RIGHT_STICK);
|
||||||
ImGui_ImplSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadLStickDown, SDL_GAMEPAD_AXIS_LEFTY, +thumb_dead_zone, +32767);
|
MAP_ANALOG(ImGuiKey_GamepadLStickLeft, SDL_GAMEPAD_AXIS_LEFTX, -thumb_dead_zone, -32768);
|
||||||
ImGui_ImplSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadRStickLeft, SDL_GAMEPAD_AXIS_RIGHTX, -thumb_dead_zone, -32768);
|
MAP_ANALOG(ImGuiKey_GamepadLStickRight, SDL_GAMEPAD_AXIS_LEFTX, +thumb_dead_zone, +32767);
|
||||||
ImGui_ImplSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadRStickRight, SDL_GAMEPAD_AXIS_RIGHTX, +thumb_dead_zone, +32767);
|
MAP_ANALOG(ImGuiKey_GamepadLStickUp, SDL_GAMEPAD_AXIS_LEFTY, -thumb_dead_zone, -32768);
|
||||||
ImGui_ImplSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadRStickUp, SDL_GAMEPAD_AXIS_RIGHTY, -thumb_dead_zone, -32768);
|
MAP_ANALOG(ImGuiKey_GamepadLStickDown, SDL_GAMEPAD_AXIS_LEFTY, +thumb_dead_zone, +32767);
|
||||||
ImGui_ImplSDL3_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadRStickDown, SDL_GAMEPAD_AXIS_RIGHTY, +thumb_dead_zone, +32767);
|
MAP_ANALOG(ImGuiKey_GamepadRStickLeft, SDL_GAMEPAD_AXIS_RIGHTX, -thumb_dead_zone, -32768);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadRStickRight, SDL_GAMEPAD_AXIS_RIGHTX, +thumb_dead_zone, +32767);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadRStickUp, SDL_GAMEPAD_AXIS_RIGHTY, -thumb_dead_zone, -32768);
|
||||||
|
MAP_ANALOG(ImGuiKey_GamepadRStickDown, SDL_GAMEPAD_AXIS_RIGHTY, +thumb_dead_zone, +32767);
|
||||||
|
#undef MAP_BUTTON
|
||||||
|
#undef MAP_ANALOG
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplSDL3_NewFrame()
|
void ImGui_ImplSDL3_NewFrame()
|
||||||
{
|
{
|
||||||
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
||||||
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplSDL3_Init()?");
|
IM_ASSERT(bd != nullptr && "Did you call ImGui_ImplSDL3_Init()?");
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
// Setup display size (every frame to accommodate for window resizing)
|
// Setup display size (every frame to accommodate for window resizing)
|
||||||
@ -691,10 +595,10 @@ void ImGui_ImplSDL3_NewFrame()
|
|||||||
io.DeltaTime = bd->Time > 0 ? (float)((double)(current_time - bd->Time) / frequency) : (float)(1.0f / 60.0f);
|
io.DeltaTime = bd->Time > 0 ? (float)((double)(current_time - bd->Time) / frequency) : (float)(1.0f / 60.0f);
|
||||||
bd->Time = current_time;
|
bd->Time = current_time;
|
||||||
|
|
||||||
if (bd->MousePendingLeaveFrame && bd->MousePendingLeaveFrame >= ImGui::GetFrameCount() && bd->MouseButtonsDown == 0)
|
if (bd->PendingMouseLeaveFrame && bd->PendingMouseLeaveFrame >= ImGui::GetFrameCount() && bd->MouseButtonsDown == 0)
|
||||||
{
|
{
|
||||||
bd->MouseWindowID = 0;
|
bd->MouseWindowID = 0;
|
||||||
bd->MousePendingLeaveFrame = 0;
|
bd->PendingMouseLeaveFrame = 0;
|
||||||
io.AddMousePosEvent(-FLT_MAX, -FLT_MAX);
|
io.AddMousePosEvent(-FLT_MAX, -FLT_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
// Missing features:
|
// Missing features:
|
||||||
// [ ] Platform: IME SUPPORT IS BROKEN IN SDL3 BECAUSE INPUTS GETS SENT TO BOTH APP AND IME + app needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!.
|
// [x] Platform: Basic IME support. Position somehow broken in SDL3 + app needs to call 'SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");' before SDL_CreateWindow()!.
|
||||||
|
|
||||||
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
|
||||||
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
|
||||||
@ -26,7 +26,6 @@
|
|||||||
|
|
||||||
struct SDL_Window;
|
struct SDL_Window;
|
||||||
struct SDL_Renderer;
|
struct SDL_Renderer;
|
||||||
struct SDL_Gamepad;
|
|
||||||
typedef union SDL_Event SDL_Event;
|
typedef union SDL_Event SDL_Event;
|
||||||
|
|
||||||
IMGUI_IMPL_API bool ImGui_ImplSDL3_InitForOpenGL(SDL_Window* window, void* sdl_gl_context);
|
IMGUI_IMPL_API bool ImGui_ImplSDL3_InitForOpenGL(SDL_Window* window, void* sdl_gl_context);
|
||||||
@ -39,9 +38,4 @@ IMGUI_IMPL_API void ImGui_ImplSDL3_Shutdown();
|
|||||||
IMGUI_IMPL_API void ImGui_ImplSDL3_NewFrame();
|
IMGUI_IMPL_API void ImGui_ImplSDL3_NewFrame();
|
||||||
IMGUI_IMPL_API bool ImGui_ImplSDL3_ProcessEvent(const SDL_Event* event);
|
IMGUI_IMPL_API bool ImGui_ImplSDL3_ProcessEvent(const SDL_Event* event);
|
||||||
|
|
||||||
// Gamepad selection automatically starts in AutoFirst mode, picking first available SDL_Gamepad. You may override this.
|
|
||||||
// When using manual mode, caller is responsible for opening/closing gamepad.
|
|
||||||
enum ImGui_ImplSDL3_GamepadMode { ImGui_ImplSDL3_GamepadMode_AutoFirst, ImGui_ImplSDL3_GamepadMode_AutoAll, ImGui_ImplSDL3_GamepadMode_Manual };
|
|
||||||
IMGUI_IMPL_API void ImGui_ImplSDL3_SetGamepadMode(ImGui_ImplSDL3_GamepadMode mode, SDL_Gamepad** manual_gamepads_array = NULL, int manual_gamepads_count = -1);
|
|
||||||
|
|
||||||
#endif // #ifndef IMGUI_DISABLE
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
// - Introduction, links and more at the top of imgui.cpp
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// 2024-05-14: *BREAKING CHANGE* ImGui_ImplSDLRenderer3_RenderDrawData() requires SDL_Renderer* passed as parameter.
|
|
||||||
// 2023-05-30: Renamed imgui_impl_sdlrenderer.h/.cpp to imgui_impl_sdlrenderer2.h/.cpp to accommodate for upcoming SDL3.
|
// 2023-05-30: Renamed imgui_impl_sdlrenderer.h/.cpp to imgui_impl_sdlrenderer2.h/.cpp to accommodate for upcoming SDL3.
|
||||||
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
||||||
// 2021-12-21: Update SDL_RenderGeometryRaw() format to work with SDL 2.0.19.
|
// 2021-12-21: Update SDL_RenderGeometryRaw() format to work with SDL 2.0.19.
|
||||||
@ -48,7 +47,7 @@
|
|||||||
// SDL_Renderer data
|
// SDL_Renderer data
|
||||||
struct ImGui_ImplSDLRenderer2_Data
|
struct ImGui_ImplSDLRenderer2_Data
|
||||||
{
|
{
|
||||||
SDL_Renderer* Renderer; // Main viewport's renderer
|
SDL_Renderer* SDLRenderer;
|
||||||
SDL_Texture* FontTexture;
|
SDL_Texture* FontTexture;
|
||||||
ImGui_ImplSDLRenderer2_Data() { memset((void*)this, 0, sizeof(*this)); }
|
ImGui_ImplSDLRenderer2_Data() { memset((void*)this, 0, sizeof(*this)); }
|
||||||
};
|
};
|
||||||
@ -64,7 +63,6 @@ static ImGui_ImplSDLRenderer2_Data* ImGui_ImplSDLRenderer2_GetBackendData()
|
|||||||
bool ImGui_ImplSDLRenderer2_Init(SDL_Renderer* renderer)
|
bool ImGui_ImplSDLRenderer2_Init(SDL_Renderer* renderer)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
IMGUI_CHECKVERSION();
|
|
||||||
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
||||||
IM_ASSERT(renderer != nullptr && "SDL_Renderer not initialized!");
|
IM_ASSERT(renderer != nullptr && "SDL_Renderer not initialized!");
|
||||||
|
|
||||||
@ -74,7 +72,7 @@ bool ImGui_ImplSDLRenderer2_Init(SDL_Renderer* renderer)
|
|||||||
io.BackendRendererName = "imgui_impl_sdlrenderer2";
|
io.BackendRendererName = "imgui_impl_sdlrenderer2";
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
|
|
||||||
bd->Renderer = renderer;
|
bd->SDLRenderer = renderer;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -93,31 +91,35 @@ void ImGui_ImplSDLRenderer2_Shutdown()
|
|||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplSDLRenderer2_SetupRenderState(SDL_Renderer* renderer)
|
static void ImGui_ImplSDLRenderer2_SetupRenderState()
|
||||||
{
|
{
|
||||||
|
ImGui_ImplSDLRenderer2_Data* bd = ImGui_ImplSDLRenderer2_GetBackendData();
|
||||||
|
|
||||||
// Clear out any viewports and cliprect set by the user
|
// Clear out any viewports and cliprect set by the user
|
||||||
// FIXME: Technically speaking there are lots of other things we could backup/setup/restore during our render process.
|
// FIXME: Technically speaking there are lots of other things we could backup/setup/restore during our render process.
|
||||||
SDL_RenderSetViewport(renderer, nullptr);
|
SDL_RenderSetViewport(bd->SDLRenderer, nullptr);
|
||||||
SDL_RenderSetClipRect(renderer, nullptr);
|
SDL_RenderSetClipRect(bd->SDLRenderer, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplSDLRenderer2_NewFrame()
|
void ImGui_ImplSDLRenderer2_NewFrame()
|
||||||
{
|
{
|
||||||
ImGui_ImplSDLRenderer2_Data* bd = ImGui_ImplSDLRenderer2_GetBackendData();
|
ImGui_ImplSDLRenderer2_Data* bd = ImGui_ImplSDLRenderer2_GetBackendData();
|
||||||
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplSDLRenderer2_Init()?");
|
IM_ASSERT(bd != nullptr && "Did you call ImGui_ImplSDLRenderer2_Init()?");
|
||||||
|
|
||||||
if (!bd->FontTexture)
|
if (!bd->FontTexture)
|
||||||
ImGui_ImplSDLRenderer2_CreateDeviceObjects();
|
ImGui_ImplSDLRenderer2_CreateDeviceObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplSDLRenderer2_RenderDrawData(ImDrawData* draw_data, SDL_Renderer* renderer)
|
void ImGui_ImplSDLRenderer2_RenderDrawData(ImDrawData* draw_data)
|
||||||
{
|
{
|
||||||
|
ImGui_ImplSDLRenderer2_Data* bd = ImGui_ImplSDLRenderer2_GetBackendData();
|
||||||
|
|
||||||
// If there's a scale factor set by the user, use that instead
|
// If there's a scale factor set by the user, use that instead
|
||||||
// If the user has specified a scale factor to SDL_Renderer already via SDL_RenderSetScale(), SDL will scale whatever we pass
|
// If the user has specified a scale factor to SDL_Renderer already via SDL_RenderSetScale(), SDL will scale whatever we pass
|
||||||
// to SDL_RenderGeometryRaw() by that scale factor. In that case we don't want to be also scaling it ourselves here.
|
// to SDL_RenderGeometryRaw() by that scale factor. In that case we don't want to be also scaling it ourselves here.
|
||||||
float rsx = 1.0f;
|
float rsx = 1.0f;
|
||||||
float rsy = 1.0f;
|
float rsy = 1.0f;
|
||||||
SDL_RenderGetScale(renderer, &rsx, &rsy);
|
SDL_RenderGetScale(bd->SDLRenderer, &rsx, &rsy);
|
||||||
ImVec2 render_scale;
|
ImVec2 render_scale;
|
||||||
render_scale.x = (rsx == 1.0f) ? draw_data->FramebufferScale.x : 1.0f;
|
render_scale.x = (rsx == 1.0f) ? draw_data->FramebufferScale.x : 1.0f;
|
||||||
render_scale.y = (rsy == 1.0f) ? draw_data->FramebufferScale.y : 1.0f;
|
render_scale.y = (rsy == 1.0f) ? draw_data->FramebufferScale.y : 1.0f;
|
||||||
@ -136,16 +138,16 @@ void ImGui_ImplSDLRenderer2_RenderDrawData(ImDrawData* draw_data, SDL_Renderer*
|
|||||||
SDL_Rect ClipRect;
|
SDL_Rect ClipRect;
|
||||||
};
|
};
|
||||||
BackupSDLRendererState old = {};
|
BackupSDLRendererState old = {};
|
||||||
old.ClipEnabled = SDL_RenderIsClipEnabled(renderer) == SDL_TRUE;
|
old.ClipEnabled = SDL_RenderIsClipEnabled(bd->SDLRenderer) == SDL_TRUE;
|
||||||
SDL_RenderGetViewport(renderer, &old.Viewport);
|
SDL_RenderGetViewport(bd->SDLRenderer, &old.Viewport);
|
||||||
SDL_RenderGetClipRect(renderer, &old.ClipRect);
|
SDL_RenderGetClipRect(bd->SDLRenderer, &old.ClipRect);
|
||||||
|
|
||||||
// Will project scissor/clipping rectangles into framebuffer space
|
// Will project scissor/clipping rectangles into framebuffer space
|
||||||
ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports
|
ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports
|
||||||
ImVec2 clip_scale = render_scale;
|
ImVec2 clip_scale = render_scale;
|
||||||
|
|
||||||
// Render command lists
|
// Render command lists
|
||||||
ImGui_ImplSDLRenderer2_SetupRenderState(renderer);
|
ImGui_ImplSDLRenderer2_SetupRenderState();
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||||
{
|
{
|
||||||
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||||
@ -160,7 +162,7 @@ void ImGui_ImplSDLRenderer2_RenderDrawData(ImDrawData* draw_data, SDL_Renderer*
|
|||||||
// User callback, registered via ImDrawList::AddCallback()
|
// User callback, registered via ImDrawList::AddCallback()
|
||||||
// (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
|
// (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
|
||||||
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
|
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
|
||||||
ImGui_ImplSDLRenderer2_SetupRenderState(renderer);
|
ImGui_ImplSDLRenderer2_SetupRenderState();
|
||||||
else
|
else
|
||||||
pcmd->UserCallback(cmd_list, pcmd);
|
pcmd->UserCallback(cmd_list, pcmd);
|
||||||
}
|
}
|
||||||
@ -177,7 +179,7 @@ void ImGui_ImplSDLRenderer2_RenderDrawData(ImDrawData* draw_data, SDL_Renderer*
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
SDL_Rect r = { (int)(clip_min.x), (int)(clip_min.y), (int)(clip_max.x - clip_min.x), (int)(clip_max.y - clip_min.y) };
|
SDL_Rect r = { (int)(clip_min.x), (int)(clip_min.y), (int)(clip_max.x - clip_min.x), (int)(clip_max.y - clip_min.y) };
|
||||||
SDL_RenderSetClipRect(renderer, &r);
|
SDL_RenderSetClipRect(bd->SDLRenderer, &r);
|
||||||
|
|
||||||
const float* xy = (const float*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, pos));
|
const float* xy = (const float*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, pos));
|
||||||
const float* uv = (const float*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, uv));
|
const float* uv = (const float*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, uv));
|
||||||
@ -189,7 +191,7 @@ void ImGui_ImplSDLRenderer2_RenderDrawData(ImDrawData* draw_data, SDL_Renderer*
|
|||||||
|
|
||||||
// Bind texture, Draw
|
// Bind texture, Draw
|
||||||
SDL_Texture* tex = (SDL_Texture*)pcmd->GetTexID();
|
SDL_Texture* tex = (SDL_Texture*)pcmd->GetTexID();
|
||||||
SDL_RenderGeometryRaw(renderer, tex,
|
SDL_RenderGeometryRaw(bd->SDLRenderer, tex,
|
||||||
xy, (int)sizeof(ImDrawVert),
|
xy, (int)sizeof(ImDrawVert),
|
||||||
color, (int)sizeof(ImDrawVert),
|
color, (int)sizeof(ImDrawVert),
|
||||||
uv, (int)sizeof(ImDrawVert),
|
uv, (int)sizeof(ImDrawVert),
|
||||||
@ -200,8 +202,8 @@ void ImGui_ImplSDLRenderer2_RenderDrawData(ImDrawData* draw_data, SDL_Renderer*
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Restore modified SDL_Renderer state
|
// Restore modified SDL_Renderer state
|
||||||
SDL_RenderSetViewport(renderer, &old.Viewport);
|
SDL_RenderSetViewport(bd->SDLRenderer, &old.Viewport);
|
||||||
SDL_RenderSetClipRect(renderer, old.ClipEnabled ? &old.ClipRect : nullptr);
|
SDL_RenderSetClipRect(bd->SDLRenderer, old.ClipEnabled ? &old.ClipRect : nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called by Init/NewFrame/Shutdown
|
// Called by Init/NewFrame/Shutdown
|
||||||
@ -217,7 +219,7 @@ bool ImGui_ImplSDLRenderer2_CreateFontsTexture()
|
|||||||
|
|
||||||
// Upload texture to graphics system
|
// Upload texture to graphics system
|
||||||
// (Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling)
|
// (Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling)
|
||||||
bd->FontTexture = SDL_CreateTexture(bd->Renderer, SDL_PIXELFORMAT_ABGR8888, SDL_TEXTUREACCESS_STATIC, width, height);
|
bd->FontTexture = SDL_CreateTexture(bd->SDLRenderer, SDL_PIXELFORMAT_ABGR8888, SDL_TEXTUREACCESS_STATIC, width, height);
|
||||||
if (bd->FontTexture == nullptr)
|
if (bd->FontTexture == nullptr)
|
||||||
{
|
{
|
||||||
SDL_Log("error creating texture");
|
SDL_Log("error creating texture");
|
||||||
|
@ -28,7 +28,7 @@ struct SDL_Renderer;
|
|||||||
IMGUI_IMPL_API bool ImGui_ImplSDLRenderer2_Init(SDL_Renderer* renderer);
|
IMGUI_IMPL_API bool ImGui_ImplSDLRenderer2_Init(SDL_Renderer* renderer);
|
||||||
IMGUI_IMPL_API void ImGui_ImplSDLRenderer2_Shutdown();
|
IMGUI_IMPL_API void ImGui_ImplSDLRenderer2_Shutdown();
|
||||||
IMGUI_IMPL_API void ImGui_ImplSDLRenderer2_NewFrame();
|
IMGUI_IMPL_API void ImGui_ImplSDLRenderer2_NewFrame();
|
||||||
IMGUI_IMPL_API void ImGui_ImplSDLRenderer2_RenderDrawData(ImDrawData* draw_data, SDL_Renderer* renderer);
|
IMGUI_IMPL_API void ImGui_ImplSDLRenderer2_RenderDrawData(ImDrawData* draw_data);
|
||||||
|
|
||||||
// Called by Init/NewFrame/Shutdown
|
// Called by Init/NewFrame/Shutdown
|
||||||
IMGUI_IMPL_API bool ImGui_ImplSDLRenderer2_CreateFontsTexture();
|
IMGUI_IMPL_API bool ImGui_ImplSDLRenderer2_CreateFontsTexture();
|
||||||
|
@ -20,8 +20,6 @@
|
|||||||
// - Introduction, links and more at the top of imgui.cpp
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// 2024-05-14: *BREAKING CHANGE* ImGui_ImplSDLRenderer3_RenderDrawData() requires SDL_Renderer* passed as parameter.
|
|
||||||
// 2024-02-12: Amend to query SDL_RenderViewportSet() and restore viewport accordingly.
|
|
||||||
// 2023-05-30: Initial version.
|
// 2023-05-30: Initial version.
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
@ -44,7 +42,7 @@
|
|||||||
// SDL_Renderer data
|
// SDL_Renderer data
|
||||||
struct ImGui_ImplSDLRenderer3_Data
|
struct ImGui_ImplSDLRenderer3_Data
|
||||||
{
|
{
|
||||||
SDL_Renderer* Renderer; // Main viewport's renderer
|
SDL_Renderer* SDLRenderer;
|
||||||
SDL_Texture* FontTexture;
|
SDL_Texture* FontTexture;
|
||||||
ImGui_ImplSDLRenderer3_Data() { memset((void*)this, 0, sizeof(*this)); }
|
ImGui_ImplSDLRenderer3_Data() { memset((void*)this, 0, sizeof(*this)); }
|
||||||
};
|
};
|
||||||
@ -60,7 +58,6 @@ static ImGui_ImplSDLRenderer3_Data* ImGui_ImplSDLRenderer3_GetBackendData()
|
|||||||
bool ImGui_ImplSDLRenderer3_Init(SDL_Renderer* renderer)
|
bool ImGui_ImplSDLRenderer3_Init(SDL_Renderer* renderer)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
IMGUI_CHECKVERSION();
|
|
||||||
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
||||||
IM_ASSERT(renderer != nullptr && "SDL_Renderer not initialized!");
|
IM_ASSERT(renderer != nullptr && "SDL_Renderer not initialized!");
|
||||||
|
|
||||||
@ -70,7 +67,7 @@ bool ImGui_ImplSDLRenderer3_Init(SDL_Renderer* renderer)
|
|||||||
io.BackendRendererName = "imgui_impl_sdlrenderer3";
|
io.BackendRendererName = "imgui_impl_sdlrenderer3";
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
|
|
||||||
bd->Renderer = renderer;
|
bd->SDLRenderer = renderer;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -89,31 +86,35 @@ void ImGui_ImplSDLRenderer3_Shutdown()
|
|||||||
IM_DELETE(bd);
|
IM_DELETE(bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplSDLRenderer3_SetupRenderState(SDL_Renderer* renderer)
|
static void ImGui_ImplSDLRenderer3_SetupRenderState()
|
||||||
{
|
{
|
||||||
|
ImGui_ImplSDLRenderer3_Data* bd = ImGui_ImplSDLRenderer3_GetBackendData();
|
||||||
|
|
||||||
// Clear out any viewports and cliprect set by the user
|
// Clear out any viewports and cliprect set by the user
|
||||||
// FIXME: Technically speaking there are lots of other things we could backup/setup/restore during our render process.
|
// FIXME: Technically speaking there are lots of other things we could backup/setup/restore during our render process.
|
||||||
SDL_SetRenderViewport(renderer, nullptr);
|
SDL_SetRenderViewport(bd->SDLRenderer, nullptr);
|
||||||
SDL_SetRenderClipRect(renderer, nullptr);
|
SDL_SetRenderClipRect(bd->SDLRenderer, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplSDLRenderer3_NewFrame()
|
void ImGui_ImplSDLRenderer3_NewFrame()
|
||||||
{
|
{
|
||||||
ImGui_ImplSDLRenderer3_Data* bd = ImGui_ImplSDLRenderer3_GetBackendData();
|
ImGui_ImplSDLRenderer3_Data* bd = ImGui_ImplSDLRenderer3_GetBackendData();
|
||||||
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplSDLRenderer3_Init()?");
|
IM_ASSERT(bd != nullptr && "Did you call ImGui_ImplSDLRenderer3_Init()?");
|
||||||
|
|
||||||
if (!bd->FontTexture)
|
if (!bd->FontTexture)
|
||||||
ImGui_ImplSDLRenderer3_CreateDeviceObjects();
|
ImGui_ImplSDLRenderer3_CreateDeviceObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplSDLRenderer3_RenderDrawData(ImDrawData* draw_data, SDL_Renderer* renderer)
|
void ImGui_ImplSDLRenderer3_RenderDrawData(ImDrawData* draw_data)
|
||||||
{
|
{
|
||||||
|
ImGui_ImplSDLRenderer3_Data* bd = ImGui_ImplSDLRenderer3_GetBackendData();
|
||||||
|
|
||||||
// If there's a scale factor set by the user, use that instead
|
// If there's a scale factor set by the user, use that instead
|
||||||
// If the user has specified a scale factor to SDL_Renderer already via SDL_RenderSetScale(), SDL will scale whatever we pass
|
// If the user has specified a scale factor to SDL_Renderer already via SDL_RenderSetScale(), SDL will scale whatever we pass
|
||||||
// to SDL_RenderGeometryRaw() by that scale factor. In that case we don't want to be also scaling it ourselves here.
|
// to SDL_RenderGeometryRaw() by that scale factor. In that case we don't want to be also scaling it ourselves here.
|
||||||
float rsx = 1.0f;
|
float rsx = 1.0f;
|
||||||
float rsy = 1.0f;
|
float rsy = 1.0f;
|
||||||
SDL_GetRenderScale(renderer, &rsx, &rsy);
|
SDL_GetRenderScale(bd->SDLRenderer, &rsx, &rsy);
|
||||||
ImVec2 render_scale;
|
ImVec2 render_scale;
|
||||||
render_scale.x = (rsx == 1.0f) ? draw_data->FramebufferScale.x : 1.0f;
|
render_scale.x = (rsx == 1.0f) ? draw_data->FramebufferScale.x : 1.0f;
|
||||||
render_scale.y = (rsy == 1.0f) ? draw_data->FramebufferScale.y : 1.0f;
|
render_scale.y = (rsy == 1.0f) ? draw_data->FramebufferScale.y : 1.0f;
|
||||||
@ -128,22 +129,20 @@ void ImGui_ImplSDLRenderer3_RenderDrawData(ImDrawData* draw_data, SDL_Renderer*
|
|||||||
struct BackupSDLRendererState
|
struct BackupSDLRendererState
|
||||||
{
|
{
|
||||||
SDL_Rect Viewport;
|
SDL_Rect Viewport;
|
||||||
bool ViewportEnabled;
|
|
||||||
bool ClipEnabled;
|
bool ClipEnabled;
|
||||||
SDL_Rect ClipRect;
|
SDL_Rect ClipRect;
|
||||||
};
|
};
|
||||||
BackupSDLRendererState old = {};
|
BackupSDLRendererState old = {};
|
||||||
old.ViewportEnabled = SDL_RenderViewportSet(renderer) == SDL_TRUE;
|
old.ClipEnabled = SDL_RenderClipEnabled(bd->SDLRenderer) == SDL_TRUE;
|
||||||
old.ClipEnabled = SDL_RenderClipEnabled(renderer) == SDL_TRUE;
|
SDL_GetRenderViewport(bd->SDLRenderer, &old.Viewport);
|
||||||
SDL_GetRenderViewport(renderer, &old.Viewport);
|
SDL_GetRenderClipRect(bd->SDLRenderer, &old.ClipRect);
|
||||||
SDL_GetRenderClipRect(renderer, &old.ClipRect);
|
|
||||||
|
|
||||||
// Will project scissor/clipping rectangles into framebuffer space
|
// Will project scissor/clipping rectangles into framebuffer space
|
||||||
ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports
|
ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports
|
||||||
ImVec2 clip_scale = render_scale;
|
ImVec2 clip_scale = render_scale;
|
||||||
|
|
||||||
// Render command lists
|
// Render command lists
|
||||||
ImGui_ImplSDLRenderer3_SetupRenderState(renderer);
|
ImGui_ImplSDLRenderer3_SetupRenderState();
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||||
{
|
{
|
||||||
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||||
@ -158,7 +157,7 @@ void ImGui_ImplSDLRenderer3_RenderDrawData(ImDrawData* draw_data, SDL_Renderer*
|
|||||||
// User callback, registered via ImDrawList::AddCallback()
|
// User callback, registered via ImDrawList::AddCallback()
|
||||||
// (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
|
// (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
|
||||||
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
|
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
|
||||||
ImGui_ImplSDLRenderer3_SetupRenderState(renderer);
|
ImGui_ImplSDLRenderer3_SetupRenderState();
|
||||||
else
|
else
|
||||||
pcmd->UserCallback(cmd_list, pcmd);
|
pcmd->UserCallback(cmd_list, pcmd);
|
||||||
}
|
}
|
||||||
@ -175,15 +174,19 @@ void ImGui_ImplSDLRenderer3_RenderDrawData(ImDrawData* draw_data, SDL_Renderer*
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
SDL_Rect r = { (int)(clip_min.x), (int)(clip_min.y), (int)(clip_max.x - clip_min.x), (int)(clip_max.y - clip_min.y) };
|
SDL_Rect r = { (int)(clip_min.x), (int)(clip_min.y), (int)(clip_max.x - clip_min.x), (int)(clip_max.y - clip_min.y) };
|
||||||
SDL_SetRenderClipRect(renderer, &r);
|
SDL_SetRenderClipRect(bd->SDLRenderer, &r);
|
||||||
|
|
||||||
const float* xy = (const float*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, pos));
|
const float* xy = (const float*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, pos));
|
||||||
const float* uv = (const float*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, uv));
|
const float* uv = (const float*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, uv));
|
||||||
|
#if SDL_VERSION_ATLEAST(2,0,19)
|
||||||
const SDL_Color* color = (const SDL_Color*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, col)); // SDL 2.0.19+
|
const SDL_Color* color = (const SDL_Color*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, col)); // SDL 2.0.19+
|
||||||
|
#else
|
||||||
|
const int* color = (const int*)(const void*)((const char*)(vtx_buffer + pcmd->VtxOffset) + offsetof(ImDrawVert, col)); // SDL 2.0.17 and 2.0.18
|
||||||
|
#endif
|
||||||
|
|
||||||
// Bind texture, Draw
|
// Bind texture, Draw
|
||||||
SDL_Texture* tex = (SDL_Texture*)pcmd->GetTexID();
|
SDL_Texture* tex = (SDL_Texture*)pcmd->GetTexID();
|
||||||
SDL_RenderGeometryRaw(renderer, tex,
|
SDL_RenderGeometryRaw(bd->SDLRenderer, tex,
|
||||||
xy, (int)sizeof(ImDrawVert),
|
xy, (int)sizeof(ImDrawVert),
|
||||||
color, (int)sizeof(ImDrawVert),
|
color, (int)sizeof(ImDrawVert),
|
||||||
uv, (int)sizeof(ImDrawVert),
|
uv, (int)sizeof(ImDrawVert),
|
||||||
@ -194,8 +197,8 @@ void ImGui_ImplSDLRenderer3_RenderDrawData(ImDrawData* draw_data, SDL_Renderer*
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Restore modified SDL_Renderer state
|
// Restore modified SDL_Renderer state
|
||||||
SDL_SetRenderViewport(renderer, old.ViewportEnabled ? &old.Viewport : nullptr);
|
SDL_SetRenderViewport(bd->SDLRenderer, &old.Viewport);
|
||||||
SDL_SetRenderClipRect(renderer, old.ClipEnabled ? &old.ClipRect : nullptr);
|
SDL_SetRenderClipRect(bd->SDLRenderer, old.ClipEnabled ? &old.ClipRect : nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called by Init/NewFrame/Shutdown
|
// Called by Init/NewFrame/Shutdown
|
||||||
@ -211,7 +214,7 @@ bool ImGui_ImplSDLRenderer3_CreateFontsTexture()
|
|||||||
|
|
||||||
// Upload texture to graphics system
|
// Upload texture to graphics system
|
||||||
// (Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling)
|
// (Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling)
|
||||||
bd->FontTexture = SDL_CreateTexture(bd->Renderer, SDL_PIXELFORMAT_ABGR8888, SDL_TEXTUREACCESS_STATIC, width, height);
|
bd->FontTexture = SDL_CreateTexture(bd->SDLRenderer, SDL_PIXELFORMAT_ABGR8888, SDL_TEXTUREACCESS_STATIC, width, height);
|
||||||
if (bd->FontTexture == nullptr)
|
if (bd->FontTexture == nullptr)
|
||||||
{
|
{
|
||||||
SDL_Log("error creating texture");
|
SDL_Log("error creating texture");
|
||||||
|
@ -28,7 +28,7 @@ struct SDL_Renderer;
|
|||||||
IMGUI_IMPL_API bool ImGui_ImplSDLRenderer3_Init(SDL_Renderer* renderer);
|
IMGUI_IMPL_API bool ImGui_ImplSDLRenderer3_Init(SDL_Renderer* renderer);
|
||||||
IMGUI_IMPL_API void ImGui_ImplSDLRenderer3_Shutdown();
|
IMGUI_IMPL_API void ImGui_ImplSDLRenderer3_Shutdown();
|
||||||
IMGUI_IMPL_API void ImGui_ImplSDLRenderer3_NewFrame();
|
IMGUI_IMPL_API void ImGui_ImplSDLRenderer3_NewFrame();
|
||||||
IMGUI_IMPL_API void ImGui_ImplSDLRenderer3_RenderDrawData(ImDrawData* draw_data, SDL_Renderer* renderer);
|
IMGUI_IMPL_API void ImGui_ImplSDLRenderer3_RenderDrawData(ImDrawData* draw_data);
|
||||||
|
|
||||||
// Called by Init/NewFrame/Shutdown
|
// Called by Init/NewFrame/Shutdown
|
||||||
IMGUI_IMPL_API bool ImGui_ImplSDLRenderer3_CreateFontsTexture();
|
IMGUI_IMPL_API bool ImGui_ImplSDLRenderer3_CreateFontsTexture();
|
||||||
|
167
external/imgui/imgui/backends/imgui_impl_vulkan.cpp
vendored
167
external/imgui/imgui/backends/imgui_impl_vulkan.cpp
vendored
@ -33,23 +33,18 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2024-04-19: Vulkan: Added convenience support for Volk via IMGUI_IMPL_VULKAN_USE_VOLK define (you can also use IMGUI_IMPL_VULKAN_NO_PROTOTYPES + wrap Volk via ImGui_ImplVulkan_LoadFunctions().)
|
|
||||||
// 2024-02-14: *BREAKING CHANGE*: Moved RenderPass parameter from ImGui_ImplVulkan_Init() function to ImGui_ImplVulkan_InitInfo structure. Not required when using dynamic rendering.
|
|
||||||
// 2024-02-12: *BREAKING CHANGE*: Dynamic rendering now require filling PipelineRenderingCreateInfo structure.
|
|
||||||
// 2024-01-19: Vulkan: Fixed vkAcquireNextImageKHR() validation errors in VulkanSDK 1.3.275 by allocating one extra semaphore than in-flight frames. (#7236)
|
|
||||||
// 2024-01-11: Vulkan: Fixed vkMapMemory() calls unnecessarily using full buffer size (#3957). Fixed MinAllocationSize handing (#7189).
|
|
||||||
// 2024-01-03: Vulkan: Added MinAllocationSize field in ImGui_ImplVulkan_InitInfo to workaround zealous "best practice" validation layer. (#7189, #4238)
|
// 2024-01-03: Vulkan: Added MinAllocationSize field in ImGui_ImplVulkan_InitInfo to workaround zealous "best practice" validation layer. (#7189, #4238)
|
||||||
// 2024-01-03: Vulkan: Stopped creating command pools with VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT as we don't reset them.
|
// 2024-01-03: Vulkan: Stoped creating command pools with VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT as we don't reset them.
|
||||||
// 2023-11-29: Vulkan: Fixed mismatching allocator passed to vkCreateCommandPool() vs vkDestroyCommandPool(). (#7075)
|
// 2023-11-29: Vulkan: Fixed mismatching allocator passed to vkCreateCommandPool() vs vkDestroyCommandPool(). (#7075)
|
||||||
// 2023-11-10: *BREAKING CHANGE*: Removed parameter from ImGui_ImplVulkan_CreateFontsTexture(): backend now creates its own command-buffer to upload fonts.
|
// 2023-11-10: *BREAKING CHANGE*: Removed parameter from ImGui_ImplVulkan_CreateFontsTexture(): backend now creates its own command-buffer to upload fonts.
|
||||||
// *BREAKING CHANGE*: Removed ImGui_ImplVulkan_DestroyFontUploadObjects() which is now unnecessary as we create and destroy those objects in the backend.
|
// *BREAKING CHANGE*: Removed ImGui_ImplVulkan_DestroyFontUploadObjects() which is now unecessary as we create and destroy those objects in the backend.
|
||||||
// ImGui_ImplVulkan_CreateFontsTexture() is automatically called by NewFrame() the first time.
|
// ImGui_ImplVulkan_CreateFontsTexture() is automatically called by NewFrame() the first time.
|
||||||
// You can call ImGui_ImplVulkan_CreateFontsTexture() again to recreate the font atlas texture.
|
// You can call ImGui_ImplVulkan_CreateFontsTexture() again to recreate the font atlas texture.
|
||||||
// Added ImGui_ImplVulkan_DestroyFontsTexture() but you probably never need to call this.
|
// Added ImGui_ImplVulkan_DestroyFontsTexture() but you probably never need to call this.
|
||||||
// 2023-07-04: Vulkan: Added optional support for VK_KHR_dynamic_rendering. User needs to set init_info->UseDynamicRendering = true and init_info->ColorAttachmentFormat.
|
// 2023-07-04: Vulkan: Added optional support for VK_KHR_dynamic_rendering. User needs to set init_info->UseDynamicRendering = true and init_info->ColorAttachmentFormat.
|
||||||
// 2023-01-02: Vulkan: Fixed sampler passed to ImGui_ImplVulkan_AddTexture() not being honored + removed a bunch of duplicate code.
|
// 2023-01-02: Vulkan: Fixed sampler passed to ImGui_ImplVulkan_AddTexture() not being honored + removed a bunch of duplicate code.
|
||||||
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
||||||
// 2022-10-04: Vulkan: Added experimental ImGui_ImplVulkan_RemoveTexture() for api symmetry. (#914, #5738).
|
// 2022-10-04: Vulkan: Added experimental ImGui_ImplVulkan_RemoveTexture() for api symetry. (#914, #5738).
|
||||||
// 2022-01-20: Vulkan: Added support for ImTextureID as VkDescriptorSet. User need to call ImGui_ImplVulkan_AddTexture(). Building for 32-bit targets requires '#define ImTextureID ImU64'. (#914).
|
// 2022-01-20: Vulkan: Added support for ImTextureID as VkDescriptorSet. User need to call ImGui_ImplVulkan_AddTexture(). Building for 32-bit targets requires '#define ImTextureID ImU64'. (#914).
|
||||||
// 2021-10-15: Vulkan: Call vkCmdSetScissor() at the end of render a full-viewport to reduce likehood of issues with people using VK_DYNAMIC_STATE_SCISSOR in their app without calling vkCmdSetScissor() explicitly every frame.
|
// 2021-10-15: Vulkan: Call vkCmdSetScissor() at the end of render a full-viewport to reduce likehood of issues with people using VK_DYNAMIC_STATE_SCISSOR in their app without calling vkCmdSetScissor() explicitly every frame.
|
||||||
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
||||||
@ -96,26 +91,25 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Forward Declarations
|
// Forward Declarations
|
||||||
struct ImGui_ImplVulkan_FrameRenderBuffers;
|
struct ImGui_ImplVulkanH_FrameRenderBuffers;
|
||||||
struct ImGui_ImplVulkan_WindowRenderBuffers;
|
struct ImGui_ImplVulkanH_WindowRenderBuffers;
|
||||||
bool ImGui_ImplVulkan_CreateDeviceObjects();
|
bool ImGui_ImplVulkan_CreateDeviceObjects();
|
||||||
void ImGui_ImplVulkan_DestroyDeviceObjects();
|
void ImGui_ImplVulkan_DestroyDeviceObjects();
|
||||||
void ImGui_ImplVulkan_DestroyFrameRenderBuffers(VkDevice device, ImGui_ImplVulkan_FrameRenderBuffers* buffers, const VkAllocationCallbacks* allocator);
|
|
||||||
void ImGui_ImplVulkan_DestroyWindowRenderBuffers(VkDevice device, ImGui_ImplVulkan_WindowRenderBuffers* buffers, const VkAllocationCallbacks* allocator);
|
|
||||||
void ImGui_ImplVulkanH_DestroyFrame(VkDevice device, ImGui_ImplVulkanH_Frame* fd, const VkAllocationCallbacks* allocator);
|
void ImGui_ImplVulkanH_DestroyFrame(VkDevice device, ImGui_ImplVulkanH_Frame* fd, const VkAllocationCallbacks* allocator);
|
||||||
void ImGui_ImplVulkanH_DestroyFrameSemaphores(VkDevice device, ImGui_ImplVulkanH_FrameSemaphores* fsd, const VkAllocationCallbacks* allocator);
|
void ImGui_ImplVulkanH_DestroyFrameSemaphores(VkDevice device, ImGui_ImplVulkanH_FrameSemaphores* fsd, const VkAllocationCallbacks* allocator);
|
||||||
|
void ImGui_ImplVulkanH_DestroyFrameRenderBuffers(VkDevice device, ImGui_ImplVulkanH_FrameRenderBuffers* buffers, const VkAllocationCallbacks* allocator);
|
||||||
|
void ImGui_ImplVulkanH_DestroyWindowRenderBuffers(VkDevice device, ImGui_ImplVulkanH_WindowRenderBuffers* buffers, const VkAllocationCallbacks* allocator);
|
||||||
void ImGui_ImplVulkanH_CreateWindowSwapChain(VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wd, const VkAllocationCallbacks* allocator, int w, int h, uint32_t min_image_count);
|
void ImGui_ImplVulkanH_CreateWindowSwapChain(VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wd, const VkAllocationCallbacks* allocator, int w, int h, uint32_t min_image_count);
|
||||||
void ImGui_ImplVulkanH_CreateWindowCommandBuffers(VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wd, uint32_t queue_family, const VkAllocationCallbacks* allocator);
|
void ImGui_ImplVulkanH_CreateWindowCommandBuffers(VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wd, uint32_t queue_family, const VkAllocationCallbacks* allocator);
|
||||||
|
|
||||||
// Vulkan prototypes for use with custom loaders
|
// Vulkan prototypes for use with custom loaders
|
||||||
// (see description of IMGUI_IMPL_VULKAN_NO_PROTOTYPES in imgui_impl_vulkan.h
|
// (see description of IMGUI_IMPL_VULKAN_NO_PROTOTYPES in imgui_impl_vulkan.h
|
||||||
#if defined(VK_NO_PROTOTYPES) && !defined(VOLK_H_)
|
#ifdef VK_NO_PROTOTYPES
|
||||||
#define IMGUI_IMPL_VULKAN_USE_LOADER
|
|
||||||
static bool g_FunctionsLoaded = false;
|
static bool g_FunctionsLoaded = false;
|
||||||
#else
|
#else
|
||||||
static bool g_FunctionsLoaded = true;
|
static bool g_FunctionsLoaded = true;
|
||||||
#endif
|
#endif
|
||||||
#ifdef IMGUI_IMPL_VULKAN_USE_LOADER
|
#ifdef VK_NO_PROTOTYPES
|
||||||
#define IMGUI_VULKAN_FUNC_MAP(IMGUI_VULKAN_FUNC_MAP_MACRO) \
|
#define IMGUI_VULKAN_FUNC_MAP(IMGUI_VULKAN_FUNC_MAP_MACRO) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkAllocateCommandBuffers) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkAllocateCommandBuffers) \
|
||||||
IMGUI_VULKAN_FUNC_MAP_MACRO(vkAllocateDescriptorSets) \
|
IMGUI_VULKAN_FUNC_MAP_MACRO(vkAllocateDescriptorSets) \
|
||||||
@ -186,16 +180,17 @@ static bool g_FunctionsLoaded = true;
|
|||||||
#define IMGUI_VULKAN_FUNC_DEF(func) static PFN_##func func;
|
#define IMGUI_VULKAN_FUNC_DEF(func) static PFN_##func func;
|
||||||
IMGUI_VULKAN_FUNC_MAP(IMGUI_VULKAN_FUNC_DEF)
|
IMGUI_VULKAN_FUNC_MAP(IMGUI_VULKAN_FUNC_DEF)
|
||||||
#undef IMGUI_VULKAN_FUNC_DEF
|
#undef IMGUI_VULKAN_FUNC_DEF
|
||||||
#endif // IMGUI_IMPL_VULKAN_USE_LOADER
|
#endif // VK_NO_PROTOTYPES
|
||||||
|
|
||||||
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
#if defined(VK_VERSION_1_3) || defined(VK_KHR_dynamic_rendering)
|
||||||
|
#define IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
static PFN_vkCmdBeginRenderingKHR ImGuiImplVulkanFuncs_vkCmdBeginRenderingKHR;
|
static PFN_vkCmdBeginRenderingKHR ImGuiImplVulkanFuncs_vkCmdBeginRenderingKHR;
|
||||||
static PFN_vkCmdEndRenderingKHR ImGuiImplVulkanFuncs_vkCmdEndRenderingKHR;
|
static PFN_vkCmdEndRenderingKHR ImGuiImplVulkanFuncs_vkCmdEndRenderingKHR;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Reusable buffers used for rendering 1 current in-flight frame, for ImGui_ImplVulkan_RenderDrawData()
|
// Reusable buffers used for rendering 1 current in-flight frame, for ImGui_ImplVulkan_RenderDrawData()
|
||||||
// [Please zero-clear before use!]
|
// [Please zero-clear before use!]
|
||||||
struct ImGui_ImplVulkan_FrameRenderBuffers
|
struct ImGui_ImplVulkanH_FrameRenderBuffers
|
||||||
{
|
{
|
||||||
VkDeviceMemory VertexBufferMemory;
|
VkDeviceMemory VertexBufferMemory;
|
||||||
VkDeviceMemory IndexBufferMemory;
|
VkDeviceMemory IndexBufferMemory;
|
||||||
@ -207,22 +202,24 @@ struct ImGui_ImplVulkan_FrameRenderBuffers
|
|||||||
|
|
||||||
// Each viewport will hold 1 ImGui_ImplVulkanH_WindowRenderBuffers
|
// Each viewport will hold 1 ImGui_ImplVulkanH_WindowRenderBuffers
|
||||||
// [Please zero-clear before use!]
|
// [Please zero-clear before use!]
|
||||||
struct ImGui_ImplVulkan_WindowRenderBuffers
|
struct ImGui_ImplVulkanH_WindowRenderBuffers
|
||||||
{
|
{
|
||||||
uint32_t Index;
|
uint32_t Index;
|
||||||
uint32_t Count;
|
uint32_t Count;
|
||||||
ImGui_ImplVulkan_FrameRenderBuffers* FrameRenderBuffers;
|
ImGui_ImplVulkanH_FrameRenderBuffers* FrameRenderBuffers;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Vulkan data
|
// Vulkan data
|
||||||
struct ImGui_ImplVulkan_Data
|
struct ImGui_ImplVulkan_Data
|
||||||
{
|
{
|
||||||
ImGui_ImplVulkan_InitInfo VulkanInitInfo;
|
ImGui_ImplVulkan_InitInfo VulkanInitInfo;
|
||||||
|
VkRenderPass RenderPass;
|
||||||
VkDeviceSize BufferMemoryAlignment;
|
VkDeviceSize BufferMemoryAlignment;
|
||||||
VkPipelineCreateFlags PipelineCreateFlags;
|
VkPipelineCreateFlags PipelineCreateFlags;
|
||||||
VkDescriptorSetLayout DescriptorSetLayout;
|
VkDescriptorSetLayout DescriptorSetLayout;
|
||||||
VkPipelineLayout PipelineLayout;
|
VkPipelineLayout PipelineLayout;
|
||||||
VkPipeline Pipeline;
|
VkPipeline Pipeline;
|
||||||
|
uint32_t Subpass;
|
||||||
VkShaderModule ShaderModuleVert;
|
VkShaderModule ShaderModuleVert;
|
||||||
VkShaderModule ShaderModuleFrag;
|
VkShaderModule ShaderModuleFrag;
|
||||||
|
|
||||||
@ -236,7 +233,7 @@ struct ImGui_ImplVulkan_Data
|
|||||||
VkCommandBuffer FontCommandBuffer;
|
VkCommandBuffer FontCommandBuffer;
|
||||||
|
|
||||||
// Render buffers for main window
|
// Render buffers for main window
|
||||||
ImGui_ImplVulkan_WindowRenderBuffers MainWindowRenderBuffers;
|
ImGui_ImplVulkanH_WindowRenderBuffers MainWindowRenderBuffers;
|
||||||
|
|
||||||
ImGui_ImplVulkan_Data()
|
ImGui_ImplVulkan_Data()
|
||||||
{
|
{
|
||||||
@ -388,13 +385,7 @@ static void check_vk_result(VkResult err)
|
|||||||
v->CheckVkResultFn(err);
|
v->CheckVkResultFn(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Same as IM_MEMALIGN(). 'alignment' must be a power of two.
|
static void CreateOrResizeBuffer(VkBuffer& buffer, VkDeviceMemory& buffer_memory, VkDeviceSize& p_buffer_size, size_t new_size, VkBufferUsageFlagBits usage)
|
||||||
static inline VkDeviceSize AlignBufferSize(VkDeviceSize size, VkDeviceSize alignment)
|
|
||||||
{
|
|
||||||
return (size + alignment - 1) & ~(alignment - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void CreateOrResizeBuffer(VkBuffer& buffer, VkDeviceMemory& buffer_memory, VkDeviceSize& buffer_size, size_t new_size, VkBufferUsageFlagBits usage)
|
|
||||||
{
|
{
|
||||||
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
||||||
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
||||||
@ -404,10 +395,10 @@ static void CreateOrResizeBuffer(VkBuffer& buffer, VkDeviceMemory& buffer_memory
|
|||||||
if (buffer_memory != VK_NULL_HANDLE)
|
if (buffer_memory != VK_NULL_HANDLE)
|
||||||
vkFreeMemory(v->Device, buffer_memory, v->Allocator);
|
vkFreeMemory(v->Device, buffer_memory, v->Allocator);
|
||||||
|
|
||||||
VkDeviceSize buffer_size_aligned = AlignBufferSize(IM_MAX(v->MinAllocationSize, new_size), bd->BufferMemoryAlignment);
|
VkDeviceSize vertex_buffer_size_aligned = ((new_size - 1) / bd->BufferMemoryAlignment + 1) * bd->BufferMemoryAlignment;
|
||||||
VkBufferCreateInfo buffer_info = {};
|
VkBufferCreateInfo buffer_info = {};
|
||||||
buffer_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
|
buffer_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
|
||||||
buffer_info.size = buffer_size_aligned;
|
buffer_info.size = vertex_buffer_size_aligned;
|
||||||
buffer_info.usage = usage;
|
buffer_info.usage = usage;
|
||||||
buffer_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
buffer_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
||||||
err = vkCreateBuffer(v->Device, &buffer_info, v->Allocator, &buffer);
|
err = vkCreateBuffer(v->Device, &buffer_info, v->Allocator, &buffer);
|
||||||
@ -416,19 +407,20 @@ static void CreateOrResizeBuffer(VkBuffer& buffer, VkDeviceMemory& buffer_memory
|
|||||||
VkMemoryRequirements req;
|
VkMemoryRequirements req;
|
||||||
vkGetBufferMemoryRequirements(v->Device, buffer, &req);
|
vkGetBufferMemoryRequirements(v->Device, buffer, &req);
|
||||||
bd->BufferMemoryAlignment = (bd->BufferMemoryAlignment > req.alignment) ? bd->BufferMemoryAlignment : req.alignment;
|
bd->BufferMemoryAlignment = (bd->BufferMemoryAlignment > req.alignment) ? bd->BufferMemoryAlignment : req.alignment;
|
||||||
|
VkDeviceSize size = IM_MAX(v->MinAllocationSize, req.size);
|
||||||
VkMemoryAllocateInfo alloc_info = {};
|
VkMemoryAllocateInfo alloc_info = {};
|
||||||
alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
||||||
alloc_info.allocationSize = req.size;
|
alloc_info.allocationSize = size;
|
||||||
alloc_info.memoryTypeIndex = ImGui_ImplVulkan_MemoryType(VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, req.memoryTypeBits);
|
alloc_info.memoryTypeIndex = ImGui_ImplVulkan_MemoryType(VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, req.memoryTypeBits);
|
||||||
err = vkAllocateMemory(v->Device, &alloc_info, v->Allocator, &buffer_memory);
|
err = vkAllocateMemory(v->Device, &alloc_info, v->Allocator, &buffer_memory);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
|
|
||||||
err = vkBindBufferMemory(v->Device, buffer, buffer_memory, 0);
|
err = vkBindBufferMemory(v->Device, buffer, buffer_memory, 0);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
buffer_size = buffer_size_aligned;
|
p_buffer_size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplVulkan_SetupRenderState(ImDrawData* draw_data, VkPipeline pipeline, VkCommandBuffer command_buffer, ImGui_ImplVulkan_FrameRenderBuffers* rb, int fb_width, int fb_height)
|
static void ImGui_ImplVulkan_SetupRenderState(ImDrawData* draw_data, VkPipeline pipeline, VkCommandBuffer command_buffer, ImGui_ImplVulkanH_FrameRenderBuffers* rb, int fb_width, int fb_height)
|
||||||
{
|
{
|
||||||
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
||||||
|
|
||||||
@ -487,23 +479,23 @@ void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer comm
|
|||||||
pipeline = bd->Pipeline;
|
pipeline = bd->Pipeline;
|
||||||
|
|
||||||
// Allocate array to store enough vertex/index buffers
|
// Allocate array to store enough vertex/index buffers
|
||||||
ImGui_ImplVulkan_WindowRenderBuffers* wrb = &bd->MainWindowRenderBuffers;
|
ImGui_ImplVulkanH_WindowRenderBuffers* wrb = &bd->MainWindowRenderBuffers;
|
||||||
if (wrb->FrameRenderBuffers == nullptr)
|
if (wrb->FrameRenderBuffers == nullptr)
|
||||||
{
|
{
|
||||||
wrb->Index = 0;
|
wrb->Index = 0;
|
||||||
wrb->Count = v->ImageCount;
|
wrb->Count = v->ImageCount;
|
||||||
wrb->FrameRenderBuffers = (ImGui_ImplVulkan_FrameRenderBuffers*)IM_ALLOC(sizeof(ImGui_ImplVulkan_FrameRenderBuffers) * wrb->Count);
|
wrb->FrameRenderBuffers = (ImGui_ImplVulkanH_FrameRenderBuffers*)IM_ALLOC(sizeof(ImGui_ImplVulkanH_FrameRenderBuffers) * wrb->Count);
|
||||||
memset(wrb->FrameRenderBuffers, 0, sizeof(ImGui_ImplVulkan_FrameRenderBuffers) * wrb->Count);
|
memset(wrb->FrameRenderBuffers, 0, sizeof(ImGui_ImplVulkanH_FrameRenderBuffers) * wrb->Count);
|
||||||
}
|
}
|
||||||
IM_ASSERT(wrb->Count == v->ImageCount);
|
IM_ASSERT(wrb->Count == v->ImageCount);
|
||||||
wrb->Index = (wrb->Index + 1) % wrb->Count;
|
wrb->Index = (wrb->Index + 1) % wrb->Count;
|
||||||
ImGui_ImplVulkan_FrameRenderBuffers* rb = &wrb->FrameRenderBuffers[wrb->Index];
|
ImGui_ImplVulkanH_FrameRenderBuffers* rb = &wrb->FrameRenderBuffers[wrb->Index];
|
||||||
|
|
||||||
if (draw_data->TotalVtxCount > 0)
|
if (draw_data->TotalVtxCount > 0)
|
||||||
{
|
{
|
||||||
// Create or resize the vertex/index buffers
|
// Create or resize the vertex/index buffers
|
||||||
size_t vertex_size = AlignBufferSize(draw_data->TotalVtxCount * sizeof(ImDrawVert), bd->BufferMemoryAlignment);
|
size_t vertex_size = draw_data->TotalVtxCount * sizeof(ImDrawVert);
|
||||||
size_t index_size = AlignBufferSize(draw_data->TotalIdxCount * sizeof(ImDrawIdx), bd->BufferMemoryAlignment);
|
size_t index_size = draw_data->TotalIdxCount * sizeof(ImDrawIdx);
|
||||||
if (rb->VertexBuffer == VK_NULL_HANDLE || rb->VertexBufferSize < vertex_size)
|
if (rb->VertexBuffer == VK_NULL_HANDLE || rb->VertexBufferSize < vertex_size)
|
||||||
CreateOrResizeBuffer(rb->VertexBuffer, rb->VertexBufferMemory, rb->VertexBufferSize, vertex_size, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT);
|
CreateOrResizeBuffer(rb->VertexBuffer, rb->VertexBufferMemory, rb->VertexBufferSize, vertex_size, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT);
|
||||||
if (rb->IndexBuffer == VK_NULL_HANDLE || rb->IndexBufferSize < index_size)
|
if (rb->IndexBuffer == VK_NULL_HANDLE || rb->IndexBufferSize < index_size)
|
||||||
@ -512,9 +504,9 @@ void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer comm
|
|||||||
// Upload vertex/index data into a single contiguous GPU buffer
|
// Upload vertex/index data into a single contiguous GPU buffer
|
||||||
ImDrawVert* vtx_dst = nullptr;
|
ImDrawVert* vtx_dst = nullptr;
|
||||||
ImDrawIdx* idx_dst = nullptr;
|
ImDrawIdx* idx_dst = nullptr;
|
||||||
VkResult err = vkMapMemory(v->Device, rb->VertexBufferMemory, 0, vertex_size, 0, (void**)&vtx_dst);
|
VkResult err = vkMapMemory(v->Device, rb->VertexBufferMemory, 0, rb->VertexBufferSize, 0, (void**)&vtx_dst);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
err = vkMapMemory(v->Device, rb->IndexBufferMemory, 0, index_size, 0, (void**)&idx_dst);
|
err = vkMapMemory(v->Device, rb->IndexBufferMemory, 0, rb->IndexBufferSize, 0, (void**)&idx_dst);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||||
{
|
{
|
||||||
@ -954,11 +946,13 @@ static void ImGui_ImplVulkan_CreatePipeline(VkDevice device, const VkAllocationC
|
|||||||
info.subpass = subpass;
|
info.subpass = subpass;
|
||||||
|
|
||||||
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
|
VkPipelineRenderingCreateInfoKHR pipelineRenderingCreateInfo = {};
|
||||||
|
pipelineRenderingCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR;
|
||||||
|
pipelineRenderingCreateInfo.colorAttachmentCount = 1;
|
||||||
|
pipelineRenderingCreateInfo.pColorAttachmentFormats = &bd->VulkanInitInfo.ColorAttachmentFormat;
|
||||||
if (bd->VulkanInitInfo.UseDynamicRendering)
|
if (bd->VulkanInitInfo.UseDynamicRendering)
|
||||||
{
|
{
|
||||||
IM_ASSERT(bd->VulkanInitInfo.PipelineRenderingCreateInfo.sType == VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR && "PipelineRenderingCreateInfo sType must be VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR");
|
info.pNext = &pipelineRenderingCreateInfo;
|
||||||
IM_ASSERT(bd->VulkanInitInfo.PipelineRenderingCreateInfo.pNext == nullptr && "PipelineRenderingCreateInfo pNext must be NULL");
|
|
||||||
info.pNext = &bd->VulkanInitInfo.PipelineRenderingCreateInfo;
|
|
||||||
info.renderPass = VK_NULL_HANDLE; // Just make sure it's actually nullptr.
|
info.renderPass = VK_NULL_HANDLE; // Just make sure it's actually nullptr.
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1023,7 +1017,7 @@ bool ImGui_ImplVulkan_CreateDeviceObjects()
|
|||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui_ImplVulkan_CreatePipeline(v->Device, v->Allocator, v->PipelineCache, v->RenderPass, v->MSAASamples, &bd->Pipeline, v->Subpass);
|
ImGui_ImplVulkan_CreatePipeline(v->Device, v->Allocator, v->PipelineCache, bd->RenderPass, v->MSAASamples, &bd->Pipeline, bd->Subpass);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1032,7 +1026,7 @@ void ImGui_ImplVulkan_DestroyDeviceObjects()
|
|||||||
{
|
{
|
||||||
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
||||||
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
||||||
ImGui_ImplVulkan_DestroyWindowRenderBuffers(v->Device, &bd->MainWindowRenderBuffers, v->Allocator);
|
ImGui_ImplVulkanH_DestroyWindowRenderBuffers(v->Device, &bd->MainWindowRenderBuffers, v->Allocator);
|
||||||
ImGui_ImplVulkan_DestroyFontsTexture();
|
ImGui_ImplVulkan_DestroyFontsTexture();
|
||||||
|
|
||||||
if (bd->FontCommandBuffer) { vkFreeCommandBuffers(v->Device, bd->FontCommandPool, 1, &bd->FontCommandBuffer); bd->FontCommandBuffer = VK_NULL_HANDLE; }
|
if (bd->FontCommandBuffer) { vkFreeCommandBuffers(v->Device, bd->FontCommandPool, 1, &bd->FontCommandBuffer); bd->FontCommandBuffer = VK_NULL_HANDLE; }
|
||||||
@ -1050,8 +1044,8 @@ bool ImGui_ImplVulkan_LoadFunctions(PFN_vkVoidFunction(*loader_func)(const ch
|
|||||||
// Load function pointers
|
// Load function pointers
|
||||||
// You can use the default Vulkan loader using:
|
// You can use the default Vulkan loader using:
|
||||||
// ImGui_ImplVulkan_LoadFunctions([](const char* function_name, void*) { return vkGetInstanceProcAddr(your_vk_isntance, function_name); });
|
// ImGui_ImplVulkan_LoadFunctions([](const char* function_name, void*) { return vkGetInstanceProcAddr(your_vk_isntance, function_name); });
|
||||||
// But this would be roughly equivalent to not setting VK_NO_PROTOTYPES.
|
// But this would be equivalent to not setting VK_NO_PROTOTYPES.
|
||||||
#ifdef IMGUI_IMPL_VULKAN_USE_LOADER
|
#ifdef VK_NO_PROTOTYPES
|
||||||
#define IMGUI_VULKAN_FUNC_LOAD(func) \
|
#define IMGUI_VULKAN_FUNC_LOAD(func) \
|
||||||
func = reinterpret_cast<decltype(func)>(loader_func(#func, user_data)); \
|
func = reinterpret_cast<decltype(func)>(loader_func(#func, user_data)); \
|
||||||
if (func == nullptr) \
|
if (func == nullptr) \
|
||||||
@ -1073,14 +1067,14 @@ bool ImGui_ImplVulkan_LoadFunctions(PFN_vkVoidFunction(*loader_func)(const ch
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info)
|
bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info, VkRenderPass render_pass)
|
||||||
{
|
{
|
||||||
IM_ASSERT(g_FunctionsLoaded && "Need to call ImGui_ImplVulkan_LoadFunctions() if IMGUI_IMPL_VULKAN_NO_PROTOTYPES or VK_NO_PROTOTYPES are set!");
|
IM_ASSERT(g_FunctionsLoaded && "Need to call ImGui_ImplVulkan_LoadFunctions() if IMGUI_IMPL_VULKAN_NO_PROTOTYPES or VK_NO_PROTOTYPES are set!");
|
||||||
|
|
||||||
if (info->UseDynamicRendering)
|
if (info->UseDynamicRendering)
|
||||||
{
|
{
|
||||||
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
||||||
#ifndef IMGUI_IMPL_VULKAN_USE_LOADER
|
#ifndef VK_NO_PROTOTYPES
|
||||||
ImGuiImplVulkanFuncs_vkCmdBeginRenderingKHR = reinterpret_cast<PFN_vkCmdBeginRenderingKHR>(vkGetInstanceProcAddr(info->Instance, "vkCmdBeginRenderingKHR"));
|
ImGuiImplVulkanFuncs_vkCmdBeginRenderingKHR = reinterpret_cast<PFN_vkCmdBeginRenderingKHR>(vkGetInstanceProcAddr(info->Instance, "vkCmdBeginRenderingKHR"));
|
||||||
ImGuiImplVulkanFuncs_vkCmdEndRenderingKHR = reinterpret_cast<PFN_vkCmdEndRenderingKHR>(vkGetInstanceProcAddr(info->Instance, "vkCmdEndRenderingKHR"));
|
ImGuiImplVulkanFuncs_vkCmdEndRenderingKHR = reinterpret_cast<PFN_vkCmdEndRenderingKHR>(vkGetInstanceProcAddr(info->Instance, "vkCmdEndRenderingKHR"));
|
||||||
#endif
|
#endif
|
||||||
@ -1092,7 +1086,6 @@ bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
IMGUI_CHECKVERSION();
|
|
||||||
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
||||||
|
|
||||||
// Setup backend capabilities flags
|
// Setup backend capabilities flags
|
||||||
@ -1109,9 +1102,11 @@ bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info)
|
|||||||
IM_ASSERT(info->MinImageCount >= 2);
|
IM_ASSERT(info->MinImageCount >= 2);
|
||||||
IM_ASSERT(info->ImageCount >= info->MinImageCount);
|
IM_ASSERT(info->ImageCount >= info->MinImageCount);
|
||||||
if (info->UseDynamicRendering == false)
|
if (info->UseDynamicRendering == false)
|
||||||
IM_ASSERT(info->RenderPass != VK_NULL_HANDLE);
|
IM_ASSERT(render_pass != VK_NULL_HANDLE);
|
||||||
|
|
||||||
bd->VulkanInitInfo = *info;
|
bd->VulkanInitInfo = *info;
|
||||||
|
bd->RenderPass = render_pass;
|
||||||
|
bd->Subpass = info->Subpass;
|
||||||
|
|
||||||
ImGui_ImplVulkan_CreateDeviceObjects();
|
ImGui_ImplVulkan_CreateDeviceObjects();
|
||||||
|
|
||||||
@ -1134,7 +1129,7 @@ void ImGui_ImplVulkan_Shutdown()
|
|||||||
void ImGui_ImplVulkan_NewFrame()
|
void ImGui_ImplVulkan_NewFrame()
|
||||||
{
|
{
|
||||||
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
|
||||||
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplVulkan_Init()?");
|
IM_ASSERT(bd != nullptr && "Did you call ImGui_ImplVulkan_Init()?");
|
||||||
|
|
||||||
if (!bd->FontDescriptorSet)
|
if (!bd->FontDescriptorSet)
|
||||||
ImGui_ImplVulkan_CreateFontsTexture();
|
ImGui_ImplVulkan_CreateFontsTexture();
|
||||||
@ -1150,7 +1145,7 @@ void ImGui_ImplVulkan_SetMinImageCount(uint32_t min_image_count)
|
|||||||
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo;
|
||||||
VkResult err = vkDeviceWaitIdle(v->Device);
|
VkResult err = vkDeviceWaitIdle(v->Device);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
ImGui_ImplVulkan_DestroyWindowRenderBuffers(v->Device, &bd->MainWindowRenderBuffers, v->Allocator);
|
ImGui_ImplVulkanH_DestroyWindowRenderBuffers(v->Device, &bd->MainWindowRenderBuffers, v->Allocator);
|
||||||
bd->VulkanInitInfo.MinImageCount = min_image_count;
|
bd->VulkanInitInfo.MinImageCount = min_image_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1197,26 +1192,6 @@ void ImGui_ImplVulkan_RemoveTexture(VkDescriptorSet descriptor_set)
|
|||||||
vkFreeDescriptorSets(v->Device, v->DescriptorPool, 1, &descriptor_set);
|
vkFreeDescriptorSets(v->Device, v->DescriptorPool, 1, &descriptor_set);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplVulkan_DestroyFrameRenderBuffers(VkDevice device, ImGui_ImplVulkan_FrameRenderBuffers* buffers, const VkAllocationCallbacks* allocator)
|
|
||||||
{
|
|
||||||
if (buffers->VertexBuffer) { vkDestroyBuffer(device, buffers->VertexBuffer, allocator); buffers->VertexBuffer = VK_NULL_HANDLE; }
|
|
||||||
if (buffers->VertexBufferMemory) { vkFreeMemory(device, buffers->VertexBufferMemory, allocator); buffers->VertexBufferMemory = VK_NULL_HANDLE; }
|
|
||||||
if (buffers->IndexBuffer) { vkDestroyBuffer(device, buffers->IndexBuffer, allocator); buffers->IndexBuffer = VK_NULL_HANDLE; }
|
|
||||||
if (buffers->IndexBufferMemory) { vkFreeMemory(device, buffers->IndexBufferMemory, allocator); buffers->IndexBufferMemory = VK_NULL_HANDLE; }
|
|
||||||
buffers->VertexBufferSize = 0;
|
|
||||||
buffers->IndexBufferSize = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImGui_ImplVulkan_DestroyWindowRenderBuffers(VkDevice device, ImGui_ImplVulkan_WindowRenderBuffers* buffers, const VkAllocationCallbacks* allocator)
|
|
||||||
{
|
|
||||||
for (uint32_t n = 0; n < buffers->Count; n++)
|
|
||||||
ImGui_ImplVulkan_DestroyFrameRenderBuffers(device, &buffers->FrameRenderBuffers[n], allocator);
|
|
||||||
IM_FREE(buffers->FrameRenderBuffers);
|
|
||||||
buffers->FrameRenderBuffers = nullptr;
|
|
||||||
buffers->Index = 0;
|
|
||||||
buffers->Count = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// Internal / Miscellaneous Vulkan Helpers
|
// Internal / Miscellaneous Vulkan Helpers
|
||||||
// (Used by example's main.cpp. Used by multi-viewport features. PROBABLY NOT used by your own app.)
|
// (Used by example's main.cpp. Used by multi-viewport features. PROBABLY NOT used by your own app.)
|
||||||
@ -1304,13 +1279,15 @@ VkPresentModeKHR ImGui_ImplVulkanH_SelectPresentMode(VkPhysicalDevice physical_d
|
|||||||
void ImGui_ImplVulkanH_CreateWindowCommandBuffers(VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wd, uint32_t queue_family, const VkAllocationCallbacks* allocator)
|
void ImGui_ImplVulkanH_CreateWindowCommandBuffers(VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wd, uint32_t queue_family, const VkAllocationCallbacks* allocator)
|
||||||
{
|
{
|
||||||
IM_ASSERT(physical_device != VK_NULL_HANDLE && device != VK_NULL_HANDLE);
|
IM_ASSERT(physical_device != VK_NULL_HANDLE && device != VK_NULL_HANDLE);
|
||||||
IM_UNUSED(physical_device);
|
(void)physical_device;
|
||||||
|
(void)allocator;
|
||||||
|
|
||||||
// Create Command Buffers
|
// Create Command Buffers
|
||||||
VkResult err;
|
VkResult err;
|
||||||
for (uint32_t i = 0; i < wd->ImageCount; i++)
|
for (uint32_t i = 0; i < wd->ImageCount; i++)
|
||||||
{
|
{
|
||||||
ImGui_ImplVulkanH_Frame* fd = &wd->Frames[i];
|
ImGui_ImplVulkanH_Frame* fd = &wd->Frames[i];
|
||||||
|
ImGui_ImplVulkanH_FrameSemaphores* fsd = &wd->FrameSemaphores[i];
|
||||||
{
|
{
|
||||||
VkCommandPoolCreateInfo info = {};
|
VkCommandPoolCreateInfo info = {};
|
||||||
info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
|
info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
|
||||||
@ -1335,11 +1312,6 @@ void ImGui_ImplVulkanH_CreateWindowCommandBuffers(VkPhysicalDevice physical_devi
|
|||||||
err = vkCreateFence(device, &info, allocator, &fd->Fence);
|
err = vkCreateFence(device, &info, allocator, &fd->Fence);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < wd->SemaphoreCount; i++)
|
|
||||||
{
|
|
||||||
ImGui_ImplVulkanH_FrameSemaphores* fsd = &wd->FrameSemaphores[i];
|
|
||||||
{
|
{
|
||||||
VkSemaphoreCreateInfo info = {};
|
VkSemaphoreCreateInfo info = {};
|
||||||
info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
|
info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
|
||||||
@ -1375,9 +1347,10 @@ void ImGui_ImplVulkanH_CreateWindowSwapChain(VkPhysicalDevice physical_device, V
|
|||||||
// We don't use ImGui_ImplVulkanH_DestroyWindow() because we want to preserve the old swapchain to create the new one.
|
// We don't use ImGui_ImplVulkanH_DestroyWindow() because we want to preserve the old swapchain to create the new one.
|
||||||
// Destroy old Framebuffer
|
// Destroy old Framebuffer
|
||||||
for (uint32_t i = 0; i < wd->ImageCount; i++)
|
for (uint32_t i = 0; i < wd->ImageCount; i++)
|
||||||
|
{
|
||||||
ImGui_ImplVulkanH_DestroyFrame(device, &wd->Frames[i], allocator);
|
ImGui_ImplVulkanH_DestroyFrame(device, &wd->Frames[i], allocator);
|
||||||
for (uint32_t i = 0; i < wd->SemaphoreCount; i++)
|
|
||||||
ImGui_ImplVulkanH_DestroyFrameSemaphores(device, &wd->FrameSemaphores[i], allocator);
|
ImGui_ImplVulkanH_DestroyFrameSemaphores(device, &wd->FrameSemaphores[i], allocator);
|
||||||
|
}
|
||||||
IM_FREE(wd->Frames);
|
IM_FREE(wd->Frames);
|
||||||
IM_FREE(wd->FrameSemaphores);
|
IM_FREE(wd->FrameSemaphores);
|
||||||
wd->Frames = nullptr;
|
wd->Frames = nullptr;
|
||||||
@ -1436,12 +1409,11 @@ void ImGui_ImplVulkanH_CreateWindowSwapChain(VkPhysicalDevice physical_device, V
|
|||||||
err = vkGetSwapchainImagesKHR(device, wd->Swapchain, &wd->ImageCount, backbuffers);
|
err = vkGetSwapchainImagesKHR(device, wd->Swapchain, &wd->ImageCount, backbuffers);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
|
|
||||||
IM_ASSERT(wd->Frames == nullptr && wd->FrameSemaphores == nullptr);
|
IM_ASSERT(wd->Frames == nullptr);
|
||||||
wd->SemaphoreCount = wd->ImageCount + 1;
|
|
||||||
wd->Frames = (ImGui_ImplVulkanH_Frame*)IM_ALLOC(sizeof(ImGui_ImplVulkanH_Frame) * wd->ImageCount);
|
wd->Frames = (ImGui_ImplVulkanH_Frame*)IM_ALLOC(sizeof(ImGui_ImplVulkanH_Frame) * wd->ImageCount);
|
||||||
wd->FrameSemaphores = (ImGui_ImplVulkanH_FrameSemaphores*)IM_ALLOC(sizeof(ImGui_ImplVulkanH_FrameSemaphores) * wd->SemaphoreCount);
|
wd->FrameSemaphores = (ImGui_ImplVulkanH_FrameSemaphores*)IM_ALLOC(sizeof(ImGui_ImplVulkanH_FrameSemaphores) * wd->ImageCount);
|
||||||
memset(wd->Frames, 0, sizeof(wd->Frames[0]) * wd->ImageCount);
|
memset(wd->Frames, 0, sizeof(wd->Frames[0]) * wd->ImageCount);
|
||||||
memset(wd->FrameSemaphores, 0, sizeof(wd->FrameSemaphores[0]) * wd->SemaphoreCount);
|
memset(wd->FrameSemaphores, 0, sizeof(wd->FrameSemaphores[0]) * wd->ImageCount);
|
||||||
for (uint32_t i = 0; i < wd->ImageCount; i++)
|
for (uint32_t i = 0; i < wd->ImageCount; i++)
|
||||||
wd->Frames[i].Backbuffer = backbuffers[i];
|
wd->Frames[i].Backbuffer = backbuffers[i];
|
||||||
}
|
}
|
||||||
@ -1487,7 +1459,7 @@ void ImGui_ImplVulkanH_CreateWindowSwapChain(VkPhysicalDevice physical_device, V
|
|||||||
|
|
||||||
// We do not create a pipeline by default as this is also used by examples' main.cpp,
|
// We do not create a pipeline by default as this is also used by examples' main.cpp,
|
||||||
// but secondary viewport in multi-viewport mode may want to create one with:
|
// but secondary viewport in multi-viewport mode may want to create one with:
|
||||||
//ImGui_ImplVulkan_CreatePipeline(device, allocator, VK_NULL_HANDLE, wd->RenderPass, VK_SAMPLE_COUNT_1_BIT, &wd->Pipeline, v->Subpass);
|
//ImGui_ImplVulkan_CreatePipeline(device, allocator, VK_NULL_HANDLE, wd->RenderPass, VK_SAMPLE_COUNT_1_BIT, &wd->Pipeline, bd->Subpass);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create The Image Views
|
// Create The Image Views
|
||||||
@ -1548,9 +1520,10 @@ void ImGui_ImplVulkanH_DestroyWindow(VkInstance instance, VkDevice device, ImGui
|
|||||||
//vkQueueWaitIdle(bd->Queue);
|
//vkQueueWaitIdle(bd->Queue);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < wd->ImageCount; i++)
|
for (uint32_t i = 0; i < wd->ImageCount; i++)
|
||||||
|
{
|
||||||
ImGui_ImplVulkanH_DestroyFrame(device, &wd->Frames[i], allocator);
|
ImGui_ImplVulkanH_DestroyFrame(device, &wd->Frames[i], allocator);
|
||||||
for (uint32_t i = 0; i < wd->SemaphoreCount; i++)
|
|
||||||
ImGui_ImplVulkanH_DestroyFrameSemaphores(device, &wd->FrameSemaphores[i], allocator);
|
ImGui_ImplVulkanH_DestroyFrameSemaphores(device, &wd->FrameSemaphores[i], allocator);
|
||||||
|
}
|
||||||
IM_FREE(wd->Frames);
|
IM_FREE(wd->Frames);
|
||||||
IM_FREE(wd->FrameSemaphores);
|
IM_FREE(wd->FrameSemaphores);
|
||||||
wd->Frames = nullptr;
|
wd->Frames = nullptr;
|
||||||
@ -1583,6 +1556,26 @@ void ImGui_ImplVulkanH_DestroyFrameSemaphores(VkDevice device, ImGui_ImplVulkanH
|
|||||||
fsd->ImageAcquiredSemaphore = fsd->RenderCompleteSemaphore = VK_NULL_HANDLE;
|
fsd->ImageAcquiredSemaphore = fsd->RenderCompleteSemaphore = VK_NULL_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplVulkanH_DestroyFrameRenderBuffers(VkDevice device, ImGui_ImplVulkanH_FrameRenderBuffers* buffers, const VkAllocationCallbacks* allocator)
|
||||||
|
{
|
||||||
|
if (buffers->VertexBuffer) { vkDestroyBuffer(device, buffers->VertexBuffer, allocator); buffers->VertexBuffer = VK_NULL_HANDLE; }
|
||||||
|
if (buffers->VertexBufferMemory) { vkFreeMemory(device, buffers->VertexBufferMemory, allocator); buffers->VertexBufferMemory = VK_NULL_HANDLE; }
|
||||||
|
if (buffers->IndexBuffer) { vkDestroyBuffer(device, buffers->IndexBuffer, allocator); buffers->IndexBuffer = VK_NULL_HANDLE; }
|
||||||
|
if (buffers->IndexBufferMemory) { vkFreeMemory(device, buffers->IndexBufferMemory, allocator); buffers->IndexBufferMemory = VK_NULL_HANDLE; }
|
||||||
|
buffers->VertexBufferSize = 0;
|
||||||
|
buffers->IndexBufferSize = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui_ImplVulkanH_DestroyWindowRenderBuffers(VkDevice device, ImGui_ImplVulkanH_WindowRenderBuffers* buffers, const VkAllocationCallbacks* allocator)
|
||||||
|
{
|
||||||
|
for (uint32_t n = 0; n < buffers->Count; n++)
|
||||||
|
ImGui_ImplVulkanH_DestroyFrameRenderBuffers(device, &buffers->FrameRenderBuffers[n], allocator);
|
||||||
|
IM_FREE(buffers->FrameRenderBuffers);
|
||||||
|
buffers->FrameRenderBuffers = nullptr;
|
||||||
|
buffers->Index = 0;
|
||||||
|
buffers->Count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#endif // #ifndef IMGUI_DISABLE
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
@ -42,31 +42,13 @@
|
|||||||
// If you have no idea what this is, leave it alone!
|
// If you have no idea what this is, leave it alone!
|
||||||
//#define IMGUI_IMPL_VULKAN_NO_PROTOTYPES
|
//#define IMGUI_IMPL_VULKAN_NO_PROTOTYPES
|
||||||
|
|
||||||
// Convenience support for Volk
|
// Vulkan includes
|
||||||
// (you can also technically use IMGUI_IMPL_VULKAN_NO_PROTOTYPES + wrap Volk via ImGui_ImplVulkan_LoadFunctions().)
|
|
||||||
//#define IMGUI_IMPL_VULKAN_USE_VOLK
|
|
||||||
|
|
||||||
#if defined(IMGUI_IMPL_VULKAN_NO_PROTOTYPES) && !defined(VK_NO_PROTOTYPES)
|
#if defined(IMGUI_IMPL_VULKAN_NO_PROTOTYPES) && !defined(VK_NO_PROTOTYPES)
|
||||||
#define VK_NO_PROTOTYPES
|
#define VK_NO_PROTOTYPES
|
||||||
#endif
|
#endif
|
||||||
#if defined(VK_USE_PLATFORM_WIN32_KHR) && !defined(NOMINMAX)
|
|
||||||
#define NOMINMAX
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Vulkan includes
|
|
||||||
#ifdef IMGUI_IMPL_VULKAN_USE_VOLK
|
|
||||||
#include <Volk/volk.h>
|
|
||||||
#else
|
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#endif
|
|
||||||
#if defined(VK_VERSION_1_3) || defined(VK_KHR_dynamic_rendering)
|
|
||||||
#define IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Initialization data, for ImGui_ImplVulkan_Init()
|
// Initialization data, for ImGui_ImplVulkan_Init()
|
||||||
// - VkDescriptorPool should be created with VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT,
|
|
||||||
// and must contain a pool size large enough to hold an ImGui VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER descriptor.
|
|
||||||
// - When using dynamic rendering, set UseDynamicRendering=true and fill PipelineRenderingCreateInfo structure.
|
|
||||||
// [Please zero-clear before use!]
|
// [Please zero-clear before use!]
|
||||||
struct ImGui_ImplVulkan_InitInfo
|
struct ImGui_ImplVulkan_InitInfo
|
||||||
{
|
{
|
||||||
@ -75,31 +57,25 @@ struct ImGui_ImplVulkan_InitInfo
|
|||||||
VkDevice Device;
|
VkDevice Device;
|
||||||
uint32_t QueueFamily;
|
uint32_t QueueFamily;
|
||||||
VkQueue Queue;
|
VkQueue Queue;
|
||||||
VkDescriptorPool DescriptorPool; // See requirements in note above
|
VkPipelineCache PipelineCache;
|
||||||
VkRenderPass RenderPass; // Ignored if using dynamic rendering
|
VkDescriptorPool DescriptorPool;
|
||||||
|
uint32_t Subpass;
|
||||||
uint32_t MinImageCount; // >= 2
|
uint32_t MinImageCount; // >= 2
|
||||||
uint32_t ImageCount; // >= MinImageCount
|
uint32_t ImageCount; // >= MinImageCount
|
||||||
VkSampleCountFlagBits MSAASamples; // 0 defaults to VK_SAMPLE_COUNT_1_BIT
|
VkSampleCountFlagBits MSAASamples; // >= VK_SAMPLE_COUNT_1_BIT (0 -> default to VK_SAMPLE_COUNT_1_BIT)
|
||||||
|
|
||||||
// (Optional)
|
// Dynamic Rendering (Optional)
|
||||||
VkPipelineCache PipelineCache;
|
bool UseDynamicRendering; // Need to explicitly enable VK_KHR_dynamic_rendering extension to use this, even for Vulkan 1.3.
|
||||||
uint32_t Subpass;
|
VkFormat ColorAttachmentFormat; // Required for dynamic rendering
|
||||||
|
|
||||||
// (Optional) Dynamic Rendering
|
// Allocation, Debugging
|
||||||
// Need to explicitly enable VK_KHR_dynamic_rendering extension to use this, even for Vulkan 1.3.
|
|
||||||
bool UseDynamicRendering;
|
|
||||||
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
|
|
||||||
VkPipelineRenderingCreateInfoKHR PipelineRenderingCreateInfo;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// (Optional) Allocation, Debugging
|
|
||||||
const VkAllocationCallbacks* Allocator;
|
const VkAllocationCallbacks* Allocator;
|
||||||
void (*CheckVkResultFn)(VkResult err);
|
void (*CheckVkResultFn)(VkResult err);
|
||||||
VkDeviceSize MinAllocationSize; // Minimum allocation size. Set to 1024*1024 to satisfy zealous best practices validation layer and waste a little memory.
|
VkDeviceSize MinAllocationSize; // Minimum allocation size. Set to 1024*1024 to satisfy zealous best practices validation layer and waste a little memory.
|
||||||
};
|
};
|
||||||
|
|
||||||
// Called by user code
|
// Called by user code
|
||||||
IMGUI_IMPL_API bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info);
|
IMGUI_IMPL_API bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info, VkRenderPass render_pass);
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_Shutdown();
|
IMGUI_IMPL_API void ImGui_ImplVulkan_Shutdown();
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_NewFrame();
|
IMGUI_IMPL_API void ImGui_ImplVulkan_NewFrame();
|
||||||
IMGUI_IMPL_API void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer command_buffer, VkPipeline pipeline = VK_NULL_HANDLE);
|
IMGUI_IMPL_API void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer command_buffer, VkPipeline pipeline = VK_NULL_HANDLE);
|
||||||
@ -179,7 +155,6 @@ struct ImGui_ImplVulkanH_Window
|
|||||||
VkClearValue ClearValue;
|
VkClearValue ClearValue;
|
||||||
uint32_t FrameIndex; // Current frame being rendered to (0 <= FrameIndex < FrameInFlightCount)
|
uint32_t FrameIndex; // Current frame being rendered to (0 <= FrameIndex < FrameInFlightCount)
|
||||||
uint32_t ImageCount; // Number of simultaneous in-flight frames (returned by vkGetSwapchainImagesKHR, usually derived from min_image_count)
|
uint32_t ImageCount; // Number of simultaneous in-flight frames (returned by vkGetSwapchainImagesKHR, usually derived from min_image_count)
|
||||||
uint32_t SemaphoreCount; // Number of simultaneous in-flight frames + 1, to be able to use it in vkAcquireNextImageKHR
|
|
||||||
uint32_t SemaphoreIndex; // Current set of swapchain wait semaphores we're using (needs to be distinct from per frame data)
|
uint32_t SemaphoreIndex; // Current set of swapchain wait semaphores we're using (needs to be distinct from per frame data)
|
||||||
ImGui_ImplVulkanH_Frame* Frames;
|
ImGui_ImplVulkanH_Frame* Frames;
|
||||||
ImGui_ImplVulkanH_FrameSemaphores* FrameSemaphores;
|
ImGui_ImplVulkanH_FrameSemaphores* FrameSemaphores;
|
||||||
|
@ -16,10 +16,6 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2024-01-22: Added configurable PipelineMultisampleState struct. (#7240)
|
|
||||||
// 2024-01-22: (Breaking) ImGui_ImplWGPU_Init() now takes a ImGui_ImplWGPU_InitInfo structure instead of variety of parameters, allowing for easier further changes.
|
|
||||||
// 2024-01-22: Fixed pipeline layout leak. (#7245)
|
|
||||||
// 2024-01-17: Explicitly fill all of WGPUDepthStencilState since standard removed defaults.
|
|
||||||
// 2023-07-13: Use WGPUShaderModuleWGSLDescriptor's code instead of source. use WGPUMipmapFilterMode_Linear instead of WGPUFilterMode_Linear. (#6602)
|
// 2023-07-13: Use WGPUShaderModuleWGSLDescriptor's code instead of source. use WGPUMipmapFilterMode_Linear instead of WGPUFilterMode_Linear. (#6602)
|
||||||
// 2023-04-11: Align buffer sizes. Use WGSL shaders instead of precompiled SPIR-V.
|
// 2023-04-11: Align buffer sizes. Use WGSL shaders instead of precompiled SPIR-V.
|
||||||
// 2023-04-11: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
// 2023-04-11: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
|
||||||
@ -76,7 +72,6 @@ struct Uniforms
|
|||||||
|
|
||||||
struct ImGui_ImplWGPU_Data
|
struct ImGui_ImplWGPU_Data
|
||||||
{
|
{
|
||||||
ImGui_ImplWGPU_InitInfo initInfo;
|
|
||||||
WGPUDevice wgpuDevice = nullptr;
|
WGPUDevice wgpuDevice = nullptr;
|
||||||
WGPUQueue defaultQueue = nullptr;
|
WGPUQueue defaultQueue = nullptr;
|
||||||
WGPUTextureFormat renderTargetFormat = WGPUTextureFormat_Undefined;
|
WGPUTextureFormat renderTargetFormat = WGPUTextureFormat_Undefined;
|
||||||
@ -184,12 +179,6 @@ static void SafeRelease(WGPUBuffer& res)
|
|||||||
wgpuBufferRelease(res);
|
wgpuBufferRelease(res);
|
||||||
res = nullptr;
|
res = nullptr;
|
||||||
}
|
}
|
||||||
static void SafeRelease(WGPUPipelineLayout& res)
|
|
||||||
{
|
|
||||||
if (res)
|
|
||||||
wgpuPipelineLayoutRelease(res);
|
|
||||||
res = nullptr;
|
|
||||||
}
|
|
||||||
static void SafeRelease(WGPURenderPipeline& res)
|
static void SafeRelease(WGPURenderPipeline& res)
|
||||||
{
|
{
|
||||||
if (res)
|
if (res)
|
||||||
@ -576,7 +565,9 @@ bool ImGui_ImplWGPU_CreateDeviceObjects()
|
|||||||
graphics_pipeline_desc.primitive.stripIndexFormat = WGPUIndexFormat_Undefined;
|
graphics_pipeline_desc.primitive.stripIndexFormat = WGPUIndexFormat_Undefined;
|
||||||
graphics_pipeline_desc.primitive.frontFace = WGPUFrontFace_CW;
|
graphics_pipeline_desc.primitive.frontFace = WGPUFrontFace_CW;
|
||||||
graphics_pipeline_desc.primitive.cullMode = WGPUCullMode_None;
|
graphics_pipeline_desc.primitive.cullMode = WGPUCullMode_None;
|
||||||
graphics_pipeline_desc.multisample = bd->initInfo.PipelineMultisampleState;
|
graphics_pipeline_desc.multisample.count = 1;
|
||||||
|
graphics_pipeline_desc.multisample.mask = UINT_MAX;
|
||||||
|
graphics_pipeline_desc.multisample.alphaToCoverageEnabled = false;
|
||||||
|
|
||||||
// Bind group layouts
|
// Bind group layouts
|
||||||
WGPUBindGroupLayoutEntry common_bg_layout_entries[2] = {};
|
WGPUBindGroupLayoutEntry common_bg_layout_entries[2] = {};
|
||||||
@ -663,13 +654,7 @@ bool ImGui_ImplWGPU_CreateDeviceObjects()
|
|||||||
depth_stencil_state.depthWriteEnabled = false;
|
depth_stencil_state.depthWriteEnabled = false;
|
||||||
depth_stencil_state.depthCompare = WGPUCompareFunction_Always;
|
depth_stencil_state.depthCompare = WGPUCompareFunction_Always;
|
||||||
depth_stencil_state.stencilFront.compare = WGPUCompareFunction_Always;
|
depth_stencil_state.stencilFront.compare = WGPUCompareFunction_Always;
|
||||||
depth_stencil_state.stencilFront.failOp = WGPUStencilOperation_Keep;
|
|
||||||
depth_stencil_state.stencilFront.depthFailOp = WGPUStencilOperation_Keep;
|
|
||||||
depth_stencil_state.stencilFront.passOp = WGPUStencilOperation_Keep;
|
|
||||||
depth_stencil_state.stencilBack.compare = WGPUCompareFunction_Always;
|
depth_stencil_state.stencilBack.compare = WGPUCompareFunction_Always;
|
||||||
depth_stencil_state.stencilBack.failOp = WGPUStencilOperation_Keep;
|
|
||||||
depth_stencil_state.stencilBack.depthFailOp = WGPUStencilOperation_Keep;
|
|
||||||
depth_stencil_state.stencilBack.passOp = WGPUStencilOperation_Keep;
|
|
||||||
|
|
||||||
// Configure disabled depth-stencil state
|
// Configure disabled depth-stencil state
|
||||||
graphics_pipeline_desc.depthStencil = (bd->depthStencilFormat == WGPUTextureFormat_Undefined) ? nullptr : &depth_stencil_state;
|
graphics_pipeline_desc.depthStencil = (bd->depthStencilFormat == WGPUTextureFormat_Undefined) ? nullptr : &depth_stencil_state;
|
||||||
@ -699,7 +684,6 @@ bool ImGui_ImplWGPU_CreateDeviceObjects()
|
|||||||
|
|
||||||
SafeRelease(vertex_shader_desc.module);
|
SafeRelease(vertex_shader_desc.module);
|
||||||
SafeRelease(pixel_shader_desc.module);
|
SafeRelease(pixel_shader_desc.module);
|
||||||
SafeRelease(graphics_pipeline_desc.layout);
|
|
||||||
SafeRelease(bg_layouts[0]);
|
SafeRelease(bg_layouts[0]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -721,10 +705,9 @@ void ImGui_ImplWGPU_InvalidateDeviceObjects()
|
|||||||
SafeRelease(bd->pFrameResources[i]);
|
SafeRelease(bd->pFrameResources[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplWGPU_Init(ImGui_ImplWGPU_InitInfo* init_info)
|
bool ImGui_ImplWGPU_Init(WGPUDevice device, int num_frames_in_flight, WGPUTextureFormat rt_format, WGPUTextureFormat depth_format)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
IMGUI_CHECKVERSION();
|
|
||||||
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
IM_ASSERT(io.BackendRendererUserData == nullptr && "Already initialized a renderer backend!");
|
||||||
|
|
||||||
// Setup backend capabilities flags
|
// Setup backend capabilities flags
|
||||||
@ -733,12 +716,11 @@ bool ImGui_ImplWGPU_Init(ImGui_ImplWGPU_InitInfo* init_info)
|
|||||||
io.BackendRendererName = "imgui_impl_webgpu";
|
io.BackendRendererName = "imgui_impl_webgpu";
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
|
|
||||||
bd->initInfo = *init_info;
|
bd->wgpuDevice = device;
|
||||||
bd->wgpuDevice = init_info->Device;
|
|
||||||
bd->defaultQueue = wgpuDeviceGetQueue(bd->wgpuDevice);
|
bd->defaultQueue = wgpuDeviceGetQueue(bd->wgpuDevice);
|
||||||
bd->renderTargetFormat = init_info->RenderTargetFormat;
|
bd->renderTargetFormat = rt_format;
|
||||||
bd->depthStencilFormat = init_info->DepthStencilFormat;
|
bd->depthStencilFormat = depth_format;
|
||||||
bd->numFramesInFlight = init_info->NumFramesInFlight;
|
bd->numFramesInFlight = num_frames_in_flight;
|
||||||
bd->frameIndex = UINT_MAX;
|
bd->frameIndex = UINT_MAX;
|
||||||
|
|
||||||
bd->renderResources.FontTexture = nullptr;
|
bd->renderResources.FontTexture = nullptr;
|
||||||
@ -751,8 +733,8 @@ bool ImGui_ImplWGPU_Init(ImGui_ImplWGPU_InitInfo* init_info)
|
|||||||
bd->renderResources.ImageBindGroupLayout = nullptr;
|
bd->renderResources.ImageBindGroupLayout = nullptr;
|
||||||
|
|
||||||
// Create buffers with a default size (they will later be grown as needed)
|
// Create buffers with a default size (they will later be grown as needed)
|
||||||
bd->pFrameResources = new FrameResources[bd->numFramesInFlight];
|
bd->pFrameResources = new FrameResources[num_frames_in_flight];
|
||||||
for (unsigned int i = 0; i < bd->numFramesInFlight; i++)
|
for (int i = 0; i < num_frames_in_flight; i++)
|
||||||
{
|
{
|
||||||
FrameResources* fr = &bd->pFrameResources[i];
|
FrameResources* fr = &bd->pFrameResources[i];
|
||||||
fr->IndexBuffer = nullptr;
|
fr->IndexBuffer = nullptr;
|
||||||
|
19
external/imgui/imgui/backends/imgui_impl_wgpu.h
vendored
19
external/imgui/imgui/backends/imgui_impl_wgpu.h
vendored
@ -20,24 +20,7 @@
|
|||||||
|
|
||||||
#include <webgpu/webgpu.h>
|
#include <webgpu/webgpu.h>
|
||||||
|
|
||||||
// Initialization data, for ImGui_ImplWGPU_Init()
|
IMGUI_IMPL_API bool ImGui_ImplWGPU_Init(WGPUDevice device, int num_frames_in_flight, WGPUTextureFormat rt_format, WGPUTextureFormat depth_format = WGPUTextureFormat_Undefined);
|
||||||
struct ImGui_ImplWGPU_InitInfo
|
|
||||||
{
|
|
||||||
WGPUDevice Device;
|
|
||||||
int NumFramesInFlight = 3;
|
|
||||||
WGPUTextureFormat RenderTargetFormat = WGPUTextureFormat_Undefined;
|
|
||||||
WGPUTextureFormat DepthStencilFormat = WGPUTextureFormat_Undefined;
|
|
||||||
WGPUMultisampleState PipelineMultisampleState = {};
|
|
||||||
|
|
||||||
ImGui_ImplWGPU_InitInfo()
|
|
||||||
{
|
|
||||||
PipelineMultisampleState.count = 1;
|
|
||||||
PipelineMultisampleState.mask = UINT32_MAX;
|
|
||||||
PipelineMultisampleState.alphaToCoverageEnabled = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
IMGUI_IMPL_API bool ImGui_ImplWGPU_Init(ImGui_ImplWGPU_InitInfo* init_info);
|
|
||||||
IMGUI_IMPL_API void ImGui_ImplWGPU_Shutdown();
|
IMGUI_IMPL_API void ImGui_ImplWGPU_Shutdown();
|
||||||
IMGUI_IMPL_API void ImGui_ImplWGPU_NewFrame();
|
IMGUI_IMPL_API void ImGui_ImplWGPU_NewFrame();
|
||||||
IMGUI_IMPL_API void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder pass_encoder);
|
IMGUI_IMPL_API void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder pass_encoder);
|
||||||
|
@ -16,9 +16,27 @@
|
|||||||
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
// - Introduction, links and more at the top of imgui.cpp
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
// Configuration flags to add in your imconfig file:
|
#include "imgui.h"
|
||||||
|
#ifndef IMGUI_DISABLE
|
||||||
|
#include "imgui_impl_win32.h"
|
||||||
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#endif
|
||||||
|
#include <windows.h>
|
||||||
|
#include <windowsx.h> // GET_X_LPARAM(), GET_Y_LPARAM()
|
||||||
|
#include <tchar.h>
|
||||||
|
#include <dwmapi.h>
|
||||||
|
|
||||||
|
// Configuration flags to add in your imconfig.h file:
|
||||||
//#define IMGUI_IMPL_WIN32_DISABLE_GAMEPAD // Disable gamepad support. This was meaningful before <1.81 but we now load XInput dynamically so the option is now less relevant.
|
//#define IMGUI_IMPL_WIN32_DISABLE_GAMEPAD // Disable gamepad support. This was meaningful before <1.81 but we now load XInput dynamically so the option is now less relevant.
|
||||||
|
|
||||||
|
// Using XInput for gamepad (will load DLL dynamically)
|
||||||
|
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
||||||
|
#include <xinput.h>
|
||||||
|
typedef DWORD (WINAPI *PFN_XInputGetCapabilities)(DWORD, DWORD, XINPUT_CAPABILITIES*);
|
||||||
|
typedef DWORD (WINAPI *PFN_XInputGetState)(DWORD, XINPUT_STATE*);
|
||||||
|
#endif
|
||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2023-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F24 function keys, app back/forward keys.
|
// 2023-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F24 function keys, app back/forward keys.
|
||||||
@ -73,34 +91,6 @@
|
|||||||
// 2017-10-23: Inputs: Using Win32 ::SetCapture/::GetCapture() to retrieve mouse positions outside the client area when dragging.
|
// 2017-10-23: Inputs: Using Win32 ::SetCapture/::GetCapture() to retrieve mouse positions outside the client area when dragging.
|
||||||
// 2016-11-12: Inputs: Only call Win32 ::SetCursor(nullptr) when io.MouseDrawCursor is set.
|
// 2016-11-12: Inputs: Only call Win32 ::SetCursor(nullptr) when io.MouseDrawCursor is set.
|
||||||
|
|
||||||
#include "imgui.h"
|
|
||||||
#ifndef IMGUI_DISABLE
|
|
||||||
#include "imgui_impl_win32.h"
|
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#endif
|
|
||||||
#include <windows.h>
|
|
||||||
#include <windowsx.h> // GET_X_LPARAM(), GET_Y_LPARAM()
|
|
||||||
#include <tchar.h>
|
|
||||||
#include <dwmapi.h>
|
|
||||||
|
|
||||||
// Using XInput for gamepad (will load DLL dynamically)
|
|
||||||
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
|
||||||
#include <xinput.h>
|
|
||||||
typedef DWORD(WINAPI* PFN_XInputGetCapabilities)(DWORD, DWORD, XINPUT_CAPABILITIES*);
|
|
||||||
typedef DWORD(WINAPI* PFN_XInputGetState)(DWORD, XINPUT_STATE*);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Clang/GCC warnings with -Weverything
|
|
||||||
#if defined(__clang__)
|
|
||||||
#pragma clang diagnostic push
|
|
||||||
#pragma clang diagnostic ignored "-Wcast-function-type" // warning: cast between incompatible function types (for loader)
|
|
||||||
#endif
|
|
||||||
#if defined(__GNUC__)
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Wcast-function-type" // warning: cast between incompatible function types (for loader)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct ImGui_ImplWin32_Data
|
struct ImGui_ImplWin32_Data
|
||||||
{
|
{
|
||||||
HWND hWnd;
|
HWND hWnd;
|
||||||
@ -146,7 +136,6 @@ static void ImGui_ImplWin32_UpdateKeyboardCodePage()
|
|||||||
static bool ImGui_ImplWin32_InitEx(void* hwnd, bool platform_has_own_dc)
|
static bool ImGui_ImplWin32_InitEx(void* hwnd, bool platform_has_own_dc)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
IMGUI_CHECKVERSION();
|
|
||||||
IM_ASSERT(io.BackendPlatformUserData == nullptr && "Already initialized a platform backend!");
|
IM_ASSERT(io.BackendPlatformUserData == nullptr && "Already initialized a platform backend!");
|
||||||
|
|
||||||
INT64 perf_frequency, perf_counter;
|
INT64 perf_frequency, perf_counter;
|
||||||
@ -383,9 +372,9 @@ static void ImGui_ImplWin32_UpdateGamepads()
|
|||||||
|
|
||||||
void ImGui_ImplWin32_NewFrame()
|
void ImGui_ImplWin32_NewFrame()
|
||||||
{
|
{
|
||||||
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
|
|
||||||
IM_ASSERT(bd != nullptr && "Context or backend not initialized? Did you call ImGui_ImplWin32_Init()?");
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
|
||||||
|
IM_ASSERT(bd != nullptr && "Did you call ImGui_ImplWin32_Init()?");
|
||||||
|
|
||||||
// Setup display size (every frame to accommodate for window resizing)
|
// Setup display size (every frame to accommodate for window resizing)
|
||||||
RECT rect = { 0, 0, 0, 0 };
|
RECT rect = { 0, 0, 0, 0 };
|
||||||
@ -581,12 +570,11 @@ static ImGuiMouseSource GetMouseSourceFromMessageExtraInfo()
|
|||||||
|
|
||||||
IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
// Most backends don't have silent checks like this one, but we need it because WndProc are called early in CreateWindow().
|
if (ImGui::GetCurrentContext() == nullptr)
|
||||||
// We silently allow both context or just only backend data to be nullptr.
|
|
||||||
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
|
|
||||||
if (bd == nullptr)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData();
|
||||||
|
|
||||||
switch (msg)
|
switch (msg)
|
||||||
{
|
{
|
||||||
@ -608,10 +596,10 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARA
|
|||||||
}
|
}
|
||||||
POINT mouse_pos = { (LONG)GET_X_LPARAM(lParam), (LONG)GET_Y_LPARAM(lParam) };
|
POINT mouse_pos = { (LONG)GET_X_LPARAM(lParam), (LONG)GET_Y_LPARAM(lParam) };
|
||||||
if (msg == WM_NCMOUSEMOVE && ::ScreenToClient(hwnd, &mouse_pos) == FALSE) // WM_NCMOUSEMOVE are provided in absolute coordinates.
|
if (msg == WM_NCMOUSEMOVE && ::ScreenToClient(hwnd, &mouse_pos) == FALSE) // WM_NCMOUSEMOVE are provided in absolute coordinates.
|
||||||
return 0;
|
break;
|
||||||
io.AddMouseSourceEvent(mouse_source);
|
io.AddMouseSourceEvent(mouse_source);
|
||||||
io.AddMousePosEvent((float)mouse_pos.x, (float)mouse_pos.y);
|
io.AddMousePosEvent((float)mouse_pos.x, (float)mouse_pos.y);
|
||||||
return 0;
|
break;
|
||||||
}
|
}
|
||||||
case WM_MOUSELEAVE:
|
case WM_MOUSELEAVE:
|
||||||
case WM_NCMOUSELEAVE:
|
case WM_NCMOUSELEAVE:
|
||||||
@ -624,7 +612,7 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARA
|
|||||||
bd->MouseTrackedArea = 0;
|
bd->MouseTrackedArea = 0;
|
||||||
io.AddMousePosEvent(-FLT_MAX, -FLT_MAX);
|
io.AddMousePosEvent(-FLT_MAX, -FLT_MAX);
|
||||||
}
|
}
|
||||||
return 0;
|
break;
|
||||||
}
|
}
|
||||||
case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK:
|
case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK:
|
||||||
case WM_RBUTTONDOWN: case WM_RBUTTONDBLCLK:
|
case WM_RBUTTONDOWN: case WM_RBUTTONDBLCLK:
|
||||||
@ -912,11 +900,4 @@ void ImGui_ImplWin32_EnableAlphaCompositing(void* hwnd)
|
|||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
#endif
|
|
||||||
#if defined(__clang__)
|
|
||||||
#pragma clang diagnostic pop
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // #ifndef IMGUI_DISABLE
|
#endif // #ifndef IMGUI_DISABLE
|
||||||
|
4
external/imgui/imgui/docs/BACKENDS.md
vendored
4
external/imgui/imgui/docs/BACKENDS.md
vendored
@ -79,14 +79,14 @@ List of Renderer Backends:
|
|||||||
imgui_impl_sdlrenderer2.cpp ; SDL_Renderer (optional component of SDL2 available from SDL 2.0.18+)
|
imgui_impl_sdlrenderer2.cpp ; SDL_Renderer (optional component of SDL2 available from SDL 2.0.18+)
|
||||||
imgui_impl_sdlrenderer3.cpp ; SDL_Renderer (optional component of SDL3 available from SDL 3.0.0+)
|
imgui_impl_sdlrenderer3.cpp ; SDL_Renderer (optional component of SDL3 available from SDL 3.0.0+)
|
||||||
imgui_impl_vulkan.cpp ; Vulkan
|
imgui_impl_vulkan.cpp ; Vulkan
|
||||||
imgui_impl_wgpu.cpp ; WebGPU (web and desktop)
|
imgui_impl_wgpu.cpp ; WebGPU
|
||||||
|
|
||||||
List of high-level Frameworks Backends (combining Platform + Renderer):
|
List of high-level Frameworks Backends (combining Platform + Renderer):
|
||||||
|
|
||||||
imgui_impl_allegro5.cpp
|
imgui_impl_allegro5.cpp
|
||||||
|
|
||||||
Emscripten is also supported!
|
Emscripten is also supported!
|
||||||
The SDL+GL, GLFW+GL and GLFW+WebGPU examples are all ready to build and run with Emscripten.
|
The SDL+GL, GLFW+GL and SDL+WebGPU examples are all ready to build and run with Emscripten.
|
||||||
|
|
||||||
### Backends for third-party frameworks, graphics API or other languages
|
### Backends for third-party frameworks, graphics API or other languages
|
||||||
|
|
||||||
|
355
external/imgui/imgui/docs/CHANGELOG.txt
vendored
355
external/imgui/imgui/docs/CHANGELOG.txt
vendored
@ -35,346 +35,6 @@ HOW TO UPDATE?
|
|||||||
and API updates have been a little more frequent lately. They are documented below and in imgui.cpp and should not affect all users.
|
and API updates have been a little more frequent lately. They are documented below and in imgui.cpp and should not affect all users.
|
||||||
- Please report any issue!
|
- Please report any issue!
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
VERSION 1.90.7 (Released 2024-05-27)
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.90.7
|
|
||||||
|
|
||||||
Breaking changes:
|
|
||||||
|
|
||||||
- Inputs: on macOS X, Cmd and Ctrl keys are now automatically swapped by io.AddKeyEvent(),
|
|
||||||
as this naturally align with how macOS X uses those keys. (#2343, #4084, #5923, #456)
|
|
||||||
- Effectively it means that e.g. ImGuiMod_Ctrl | ImGuiKey_C is a valid idiomatic shortcut
|
|
||||||
for both Windows and Mac style users.
|
|
||||||
- It shouldn't really affect your code unless you had explicit/custom shortcut swapping in
|
|
||||||
place for macOS X apps in your input logic.
|
|
||||||
- Removed ImGuiMod_Shortcut which was previously dynamically remapping to Ctrl or Cmd/Super.
|
|
||||||
It is now unnecessary to specific cross-platform idiomatic shortcuts.
|
|
||||||
Kept symbols redirecting ImGuiMod_Shortcut to ImGuiMod_Ctrl (will obsolete).
|
|
||||||
- Commented out obsolete symbols renamed in 1.88 (May 2022):
|
|
||||||
CaptureKeyboardFromApp() -> SetNextFrameWantCaptureKeyboard()
|
|
||||||
CaptureMouseFromApp() -> SetNextFrameWantCaptureMouse()
|
|
||||||
- Backends: SDL_Renderer2/SDL_Renderer3: ImGui_ImplSDLRenderer2_RenderDrawData() and
|
|
||||||
ImGui_ImplSDLRenderer3_RenderDrawData() now takes a SDL_Renderer* parameter. This was previously
|
|
||||||
overlooked from the API but it will allow eventual support for multi-viewports.
|
|
||||||
|
|
||||||
Other changes:
|
|
||||||
|
|
||||||
- Windows: BeginChild(): fixed visibility of fully clipped child windows and tables to Test Engine.
|
|
||||||
- Windows: BeginChild(): fixed auto-fit calculation when using either (not both) ResizeX/ResizeY
|
|
||||||
and double-clicking on a border. Calculation incorrectly didn't always account for scrollbar as
|
|
||||||
it assumed the other axis would also be auto-fit. (#1710)
|
|
||||||
- Inputs: added shortcut and routing system in public API. (#456, #2637) [BETA]
|
|
||||||
- The general idea is that several callers may register interest in a shortcut, and only one owner gets it.
|
|
||||||
- in Parent: call Shortcut(Ctrl+S) // When Parent is focused, Parent gets the shortcut.
|
|
||||||
- in Child1: call Shortcut(Ctrl+S) // When Child1 is focused, Child1 gets the shortcut (Child1 overrides Parent shortcuts)
|
|
||||||
- in Child2: no call // When Child2 is focused, Parent gets the shortcut.
|
|
||||||
The whole system is order independent, so if Child1 makes its calls before Parent, results will be identical.
|
|
||||||
This is an important property as it facilitate working with foreign code or larger codebase.
|
|
||||||
- Added Shortcut() function:
|
|
||||||
e.g. Using ImGui::Shortcut(ImGuiMod_Ctrl | ImGuiKey_C); with default policy:
|
|
||||||
- checks that CTRL+C is pressed,
|
|
||||||
- and that current window is in focus stack,
|
|
||||||
- and that no other requests for CTRL+C have been made from higher priority locations
|
|
||||||
(e.g. deeper in the window/item stack).
|
|
||||||
- Added SetNextItemShortcut() to set a shortcut to locally or remotely press or activate
|
|
||||||
an item (depending on specified routing policy: using ImGuiInputFlags_RouteGlobal the item
|
|
||||||
shortcut may be executed even if its window is not in focus stack).
|
|
||||||
Items like buttons are not fully activated, in the sense that they get pressed but another
|
|
||||||
active item, e.g. InputText() won't be deactivated.
|
|
||||||
- Added routing policies for Shortcut(), SetNextItemShortcut(): (#456, #2637)
|
|
||||||
- ImGuiInputFlags_RouteFocused: focus stack route (default)
|
|
||||||
- ImGuiInputFlags_RouteActive: only route to active item
|
|
||||||
- ImGuiInputFlags_RouteGlobal: route globally, unless a focus route claim shame shortcut.
|
|
||||||
- ImGuiInputFlags_RouteAlways: no routing submission, no routing check.
|
|
||||||
- Added other shortcut/routing options: (#456, #2637)
|
|
||||||
- ImGuiInputFlags_Repeat: for use by Shortcut() and by upcoming rework of various
|
|
||||||
input functions (which are still internal for now).
|
|
||||||
- ImGuiInputFlags_Tooltip: for SetNextItemShortcut() to show a tooltip when hovering item.
|
|
||||||
- ImGuiInputFlags_RouteOverFocused: global route takes priority over focus route.
|
|
||||||
- ImGuiInputFlags_RouteOverActive: global route takes priority over active item.
|
|
||||||
- ImGuiInputFlags_RouteUnlessBgFocused: global route disabled if no imgui window focused.
|
|
||||||
- ImGuiInputFlags_RouteFromRootWindow: route evaluated from the point of view of root window rather than current window.
|
|
||||||
- Inputs: (OSX) Fixes variety of code which inconsistently required using Ctrl instead of Cmd.
|
|
||||||
- e.g. Drags/Sliders now use Cmd+Click to input a value. (#4084)
|
|
||||||
- Some shortcuts still uses Ctrl on Mac: e.g. Ctrl+Tab to switch windows. (#4828)
|
|
||||||
- Inputs: (OSX) Ctrl+Left Click alias as a Right click. (#2343) [@haldean, @ocornut]
|
|
||||||
- Inputs: Fixed ImGui::GetKeyName(ImGuiKey_None) from returning "N/A" or "None" depending
|
|
||||||
on value of IMGUI_DISABLE_OBSOLETE_KEYIO. It always returns "None".
|
|
||||||
- Nav: fixed holding Ctrl or gamepad L1 from not slowing down keyboard/gamepad tweak speed.
|
|
||||||
Broken during a refactor refactor for 1.89. Holding Shift/R1 to speed up wasn't broken.
|
|
||||||
- Tables: fixed cell background of fully clipped row overlapping with header. (#7575, #7041) [@prabuinet]
|
|
||||||
- Demo: Added "Inputs & Focus -> Shortcuts" section. (#456, #2637)
|
|
||||||
- Demo: Documents: Added shortcuts and renaming tabs/documents. (#7233)
|
|
||||||
- Examples: Win32+DX9,DX10,DX11,DX12: rework main loop to handle minimization and screen
|
|
||||||
locking without burning resources by running unthrottled code. (#2496, #3907, #6308, #7615)
|
|
||||||
- Backends: all backends + demo now call IMGUI_CHECKVERSION() to verify ABI compatibility between caller
|
|
||||||
code and compiled version of Dear ImGui. If you get an assert it most likely mean you have a build issue,
|
|
||||||
read comments near the assert. (#7568)
|
|
||||||
- Backends: Win32: undo an assert introduced in 1.90.6 which didn't allow WndProc
|
|
||||||
handler to be called before backend initialization. Because of how ::CreateWindow()
|
|
||||||
calls in WndProc this is facilitating. (#6275) [@MennoVink]
|
|
||||||
- Backends, Examples: SDL3: updates for latest SDL3 API changes. (#7580) [@kuvaus, @ocornut]
|
|
||||||
|
|
||||||
Breaking changes IF you were using imgui_internal.h versions of Shortcut() or owner-aware
|
|
||||||
versions of IsKeyPressed(), IsKeyChordPressed(), IsMouseClicked() prior to this version:
|
|
||||||
|
|
||||||
- Inputs (Internals): Renamed ImGuiKeyOwner_None to ImGuiKeyOwner_NoOwner, to make use more
|
|
||||||
explicit and reduce confusion with the fact it is a non-zero value and cannot be a default.
|
|
||||||
- Inputs (Internals): Renamed symbols global routes:
|
|
||||||
Renamed ImGuiInputFlags_RouteGlobalLow -> ImGuiInputFlags_RouteGlobal (this is the suggested global route)
|
|
||||||
Renamed ImGuiInputFlags_RouteGlobal -> ImGuiInputFlags_RouteGlobal | ImGuiInputFlags_RouteOverFocused
|
|
||||||
Renamed ImGuiInputFlags_RouteGlobalHigh -> ImGuiInputFlags_RouteGlobal | ImGuiInputFlags_RouteOverFocused | ImGuiInputFlags_RouteOverActive
|
|
||||||
- Inputs (Internals): Shortcut(), SetShortcutRouting(): swapped last two parameters order
|
|
||||||
in function signatures:
|
|
||||||
Before: Shortcut(ImGuiKeyChord key_chord, ImGuiID owner_id = 0, ImGuiInputFlags flags = 0);
|
|
||||||
After: Shortcut(ImGuiKeyChord key_chord, ImGuiInputFlags flags = 0, ImGuiID owner_id = 0);
|
|
||||||
- Inputs (Internals): owner-aware versions of IsKeyPressed(), IsKeyChordPressed(), IsMouseClicked():
|
|
||||||
swapped last two parameters order in function signatures:
|
|
||||||
Before: IsKeyPressed(ImGuiKey key, ImGuiID owner_id, ImGuiInputFlags flags = 0);
|
|
||||||
After: IsKeyPressed(ImGuiKey key, ImGuiInputFlags flags, ImGuiID owner_id = 0);
|
|
||||||
Before: IsMouseClicked(ImGuiMouseButton button, ImGuiID owner_id, ImGuiInputFlags flags = 0);
|
|
||||||
After: IsMouseClicked(ImGuiMouseButton button, ImGuiInputFlags flags, ImGuiID owner_id = 0);
|
|
||||||
- For several reasons those changes makes sense. They were all made before making some of
|
|
||||||
those API public. Only past users of imgui_internal.h with the extra parameters will be affected.
|
|
||||||
Added asserts for valid flags in various functions to detect _some_ misuses, BUT NOT ALL.
|
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
VERSION 1.90.6 (Released 2024-05-08)
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.90.6
|
|
||||||
|
|
||||||
Breaking changes:
|
|
||||||
|
|
||||||
- TreeNode: Fixed a layout inconsistency when using a empty/hidden label followed
|
|
||||||
by a SameLine() call. (#7505, #282)
|
|
||||||
Before: TreeNode("##Hidden"); SameLine(); Text("Hello");
|
|
||||||
// This was actually incorrect! BUT appeared to look ok with the default style
|
|
||||||
// where ItemSpacing.x == FramePadding.x * 2 (it didn't look aligned otherwise).
|
|
||||||
After: TreeNode("##Hidden"); SameLine(0, 0); Text("Hello");
|
|
||||||
// This is correct for all values in style.
|
|
||||||
With the fix, IF you were successfully using TreeNode("")+SameLine(); you will now
|
|
||||||
have extra spacing between your TreeNode and the following item. You'll need to change
|
|
||||||
the SameLine() call to SameLine(0,0) to remove this extraneous spacing.
|
|
||||||
This seemed like the more sensible fix that's not making things less consistent.
|
|
||||||
(Note: when using this idiom you are likely to also use ImGuiTreeNodeFlags_SpanAvailWidth).
|
|
||||||
|
|
||||||
Other changes:
|
|
||||||
|
|
||||||
- Windows: Changed default ClipRect to extend to windows' left and right borders,
|
|
||||||
instead of adding arbitrary WindowPadding.x * 0.5f space on left and right.
|
|
||||||
That ClipRect half-padding was arbitrary/confusing and inconsistent with Y axis.
|
|
||||||
It also made it harder to draw items covering whole window without pushing an
|
|
||||||
extended ClipRect. Some items near windows left and right edge that used to be clipped
|
|
||||||
may be partly more visible. (#3312, #7540, #3756, #6170, #6365)
|
|
||||||
- Windows: Fixed subsequent Begin() append calls from setting last item information
|
|
||||||
for title bar, making it impossible to use IsItemHovered() on a Begin()-to-append,
|
|
||||||
and causing issue bypassing hover detection on collapsed windows. (#7506, #823)
|
|
||||||
- Fonts: Fixed font ascent and descent calculation when a font hits exact integer values.
|
|
||||||
It is possible that some prior manual use of ImFontConfig::GlyphOffset may become
|
|
||||||
duplicate with this fix. (#7399, #7404) [@GamingMinds-DanielC]
|
|
||||||
- TreeNode: Added ImGuiTreeNodeFlags_SpanTextWidth to make hitbox and highlight only
|
|
||||||
cover the label. (#6937) [@dimateos]
|
|
||||||
- Tables: Angled headers: fixed multi-line label display when angle is flipped. (#6917)
|
|
||||||
- Tables: Angled headers: added style.TableAngledHeadersTextAlign and corresponding
|
|
||||||
ImGuiStyleVar_TableAngledHeadersTextAlign variable. Default to horizontal center. (#6917)
|
|
||||||
[@thedmd, @ocornut]
|
|
||||||
- ProgressBar: Added support for indeterminate progress bar by passing an animated
|
|
||||||
negative fraction, e.g. ProgressBar(-1.0f * GetTime()). (#5316, #5370, #1901)[@gan74]
|
|
||||||
- Text, DrawList: Improved handling of long single-line wrapped text. Faster and
|
|
||||||
mitigate issues with reading vertex indexing limits with 16-bit indices. (#7496, #5720)
|
|
||||||
- Backends: OpenGL3: Detect ES3 contexts on desktop based on version string,
|
|
||||||
to e.g. avoid calling glPolygonMode() on them. (#7447) [@afraidofdark, @ocornut]
|
|
||||||
- Backends: OpenGL3: Update loader for Linux to support EGL/GLVND. (#7562) [@ShadowNinja, @vanfanel]
|
|
||||||
- Backends: Vulkan: Added convenience support for Volk via IMGUI_IMPL_VULKAN_USE_VOLK define.
|
|
||||||
(you could always use IMGUI_IMPL_VULKAN_NO_PROTOTYPES + ImGui_ImplVulkan_LoadFunctions() as well).
|
|
||||||
(#6582, #4854) [@adalsteinnh, @kennyalive, @ocornut]
|
|
||||||
- Backends: SDL3: Fixed text inputs. Re-enable calling SDL_StartTextInput()/SDL_StopTextInput()
|
|
||||||
as SDL3 no longer enables it by default. (#7452, #6306, #6071, #1953) [@Green-Sky]
|
|
||||||
- Examples: GLFW+Vulkan, SDL+Vulkan: Added optional support for Volk. (#6582, #4854)
|
|
||||||
- Examples: GLFW+WebGPU: Added support for WebGPU-native/Dawn (#7435, #7132) [@eliasdaler, @Zelif]
|
|
||||||
- Examples: GLFW+WebGPU: Renamed example_emscripten_wgpu/ to example_glfw_wgpu/. (#7435, #7132)
|
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
VERSION 1.90.5 (Released 2024-04-11)
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.90.5
|
|
||||||
|
|
||||||
Breaking changes:
|
|
||||||
|
|
||||||
- More formally obsoleted GetKeyIndex() when IMGUI_DISABLE_OBSOLETE_FUNCTIONS is set.
|
|
||||||
It has been unnecessary and a no-op since 1.87 (it returns the same value as passed
|
|
||||||
when used with a 1.87+ backend using io.AddKeyEvent() function). (#4921)
|
|
||||||
- IsKeyPressed(GetKeyIndex(ImGuiKey_XXX)) --> IsKeyPressed(ImGuiKey_XXX)
|
|
||||||
- ImDrawList: Merged the radius_x/radius_y parameters in AddEllipse(), AddEllipseFilled()
|
|
||||||
and PathEllipticalArcTo() into a single ImVec2 parameter. Exceptionally, because those
|
|
||||||
functions were added recently in 1.90, we are not adding inline redirection functions.
|
|
||||||
The transition is easy and should affect few users. (#2743, #7417) [@cfillion]
|
|
||||||
|
|
||||||
Other changes:
|
|
||||||
|
|
||||||
- Windows: Scrollbar visibility decision uses current size when both size and contents
|
|
||||||
size are submitted by API. (#7252)
|
|
||||||
- Windows: Double-click to collapse may be disabled via key-ownership mechanism. (#7369)
|
|
||||||
- Windows: BeginChild(): Extend outer resize borders to the edges when there are no corner
|
|
||||||
grips. Essentially affects resizable child windows. (#7440, #1710) [@cfillion]
|
|
||||||
- Windows: BeginChild(): Resizing logic for child windows evaluates whether per-axis clamping
|
|
||||||
should be applied based on parent scrollbars, not child scrollbars. (#7440, #1710) [@cfillion]
|
|
||||||
Adjust those resizing limits to match window padding rather than inner clipping rectangle.
|
|
||||||
- Tables: Fixed auto-width columns when using synced-instances of same table, width of
|
|
||||||
one instance would bleed into next one instead of sharing their widths. (#7218)
|
|
||||||
- Tables: Angled headers: fixed border hit box extending beyond when used within
|
|
||||||
non-scrollable tables. (#7416) [@cfillion]
|
|
||||||
- Tables: Angled headers: fixed borders not moving back up after TableAngleHeadersRow()
|
|
||||||
stops being called. (#7416) [@cfillion]
|
|
||||||
- Tables: Angled headers: rounding header size to nearest integers, fixes some issues
|
|
||||||
when using clipper.
|
|
||||||
- Menus, Popups: Fixed an issue where sibling menu popups re-opening in successive
|
|
||||||
frames would erroneously close the window. While it is technically a popup issue
|
|
||||||
it would generally manifest when fast moving the mouse bottom to top in a sub-menu.
|
|
||||||
(#7325, #7287, #7063)
|
|
||||||
- ProgressBar: Fixed passing fraction==NaN from leading to a crash. (#7451)
|
|
||||||
- ListBox: Fixed text-baseline offset when using SameLine()+Text() after a labeled ListBox().
|
|
||||||
- Drags, Sliders, Inputs: Fixed io.PlatformLocaleDecimalPoint decimal point localization
|
|
||||||
feature not working regression from 1.90.1. (#7389, #6719, #2278) [@GamingMinds-DanielC]
|
|
||||||
- Style: Added ImGuiStyleVar_TabBorderSize, ImGuiStyleVar_TableAngledHeadersAngle for
|
|
||||||
consistency. (#7411) [@cfillion]
|
|
||||||
- DrawList: Added AddConcavePolyFilled(), PathFillConcave() concave filling. (#760) [@thedmd]
|
|
||||||
Note that only simple polygons (no self-intersections, no holes) are supported.
|
|
||||||
- DrawList: Allow AddText() to accept null ranges. (#3615, 7391)
|
|
||||||
- Docs: added more wiki links to headers of imgui.h/imgui.cpp to facilitate discovery
|
|
||||||
of interesting resources, because github doesn't allow Wiki to be crawled by search engines.
|
|
||||||
- This is the main wiki: https://github.com/ocornut/imgui/wiki
|
|
||||||
- This is the crawlable version: https://github-wiki-see.page/m/ocornut/imgui/wiki
|
|
||||||
Adding a link to the crawlable version, even though it is not intended for humans,
|
|
||||||
to increase its search rank.
|
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
VERSION 1.90.4 (Released 2024-02-22)
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.90.4
|
|
||||||
|
|
||||||
Other changes:
|
|
||||||
|
|
||||||
- Nav: Fixed SetKeyboardFocusHere() or programmatic tabbing API from not working on
|
|
||||||
windows with the ImGuiWindowFlags_NoNavInputs flag (regression in 1.90.2, which
|
|
||||||
among other things broke imgui_memory_editor).
|
|
||||||
- Menus, Popups: Fixed an issue where hovering a parent-menu upward would
|
|
||||||
erroneously close the window. (#7325, #7287, #7063)
|
|
||||||
- Popups: Fixed resizable popup minimum size being too small. Standardized minimum
|
|
||||||
size logic. (#7329).
|
|
||||||
- Modals: Temporary changes of ImGuiCol_ModalWindowDimBg are properly handled by
|
|
||||||
BeginPopupModal(). (#7340)
|
|
||||||
- Tables: Angled headers: fixed support for multi-line labels. (#6917)
|
|
||||||
- Tables: Angled headers: various fixes to accurately handle CellPadding changes. (#6917)
|
|
||||||
- Tables: Angled headers: properly registers horizontal component of angled headers
|
|
||||||
for auto-resizing of columns. (#6917)
|
|
||||||
- Tables: Angled headers: fixed TableAngledHeadersRow() incorrect background fill
|
|
||||||
drawn too low, particularly visible with tables that have no scrolling. (#6917)
|
|
||||||
- ProgressBar: Fixed a minor tessellation issue when rendering rounded progress bars,
|
|
||||||
where in some situations the rounded section wouldn't follow regular tessellation rules.
|
|
||||||
- Debug Tools: Item Picker: Promoted ImGui::DebugStartItemPicker() to public API. (#2673)
|
|
||||||
- Debug Tools: Item Picker: Menu entry visible in Demo->Tools but greyed out unless
|
|
||||||
io.ConfigDebugIsDebuggerPresent is set. (#2673)
|
|
||||||
- Misc: Added optional alpha multiplier parameter to GetColorU32(ImU32) variant.
|
|
||||||
- Demo: Custom Rendering: better demonstrate PathArcTo(), PathBezierQuadraticCurveTo(),
|
|
||||||
PathBezierCubicCurveTo(), PathStroke(), PathFillConvex() functions.
|
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
VERSION 1.90.3 (Released 2024-02-14)
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.90.3
|
|
||||||
|
|
||||||
Breaking changes:
|
|
||||||
|
|
||||||
- Backends: SDL2: Removed obsolete ImGui_ImplSDL2_NewFrame(SDL_Window*) signature which
|
|
||||||
was obsoleted in 1.84. Calling ImGui_ImplSDL2_NewFrame() is fine.
|
|
||||||
- Backends: Vulkan: Moved RenderPass parameter from ImGui_ImplVulkan_Init() function to
|
|
||||||
ImGui_ImplVulkan_InitInfo structure. Not required when using dynamic rendering. (#7308) [@shawnhatori]
|
|
||||||
- Backends: Vulkan: Using dynamic rendering now require filling the PipelineRenderingCreateInfo
|
|
||||||
structure in ImGui_ImplVulkan_InitInfo, allowing to configure color/depth/stencil formats.
|
|
||||||
Removed ColorAttachmentFormat field previously provided for dynamic rendering.
|
|
||||||
(#7166, #6855, #5446, #5037) [@shawnhatori]
|
|
||||||
|
|
||||||
Other changes:
|
|
||||||
|
|
||||||
- Menus, Popups: Fixed menus and popups with ChildWindow flag erroneously not displaying
|
|
||||||
a scrollbar when contents is over parent viewport size. (#7287, #7063) [@ZingBallyhoo]
|
|
||||||
- Backends: SDL2, SDL3: Handle gamepad disconnection + fixed increasing gamepad reference
|
|
||||||
counter continuously. Added support for multiple simultaneous gamepads.
|
|
||||||
Added ImGui_ImplSDL2_SetGamepadMode()) function to select whether to automatically pick
|
|
||||||
first available gamepad, all gamepads, or specific gamepads.
|
|
||||||
(#3884, #6559, #6890, #7180) [@ocornut, @lethal-guitar, @wn2000, @bog-dan-ro]
|
|
||||||
- Backends: SDL3: Fixed gamepad handling. (#7180) [@bog-dan-ro]
|
|
||||||
- Backends: SDLRenderer3: query newly added SDL_RenderViewportSet() to not restore
|
|
||||||
a wrong viewport if none was initially set.
|
|
||||||
- Backends: DirectX9: Using RGBA format when allowed by the driver to avoid CPU side
|
|
||||||
conversion. (#6575) [@Demonese]
|
|
||||||
- Internals: Fixed ImFileOpen not working before context is created, preventing creation
|
|
||||||
of a font atlas before main context creation. (#7314, #7315) [@PathogenDavid, @ocornut]
|
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
VERSION 1.90.2 (Released 2024-02-09)
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
|
|
||||||
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.90.2
|
|
||||||
|
|
||||||
Breaking changes:
|
|
||||||
|
|
||||||
- Commented out ImGuiIO::ImeWindowHandle obsoleted in 1.87 in favor of writing
|
|
||||||
to 'void* ImGuiViewport::PlatformHandleRaw'.
|
|
||||||
- Backends: WebGPU: ImGui_ImplWGPU_Init() now takes a ImGui_ImplWGPU_InitInfo structure
|
|
||||||
instead of variety of parameters, allowing for easier further changes. (#7240)
|
|
||||||
|
|
||||||
Other changes:
|
|
||||||
|
|
||||||
- Nav: keyboard/gamepad activation mark widgets as held to give better visual feedback.
|
|
||||||
- Nav: tweak to logic marking navigated item as hovered when using keyboard, allowing
|
|
||||||
the hover highlight to stay even while another item is activated.
|
|
||||||
- Nav: Fixed SetKeyboardFocusHere() not working when current nav focus is in different scope,
|
|
||||||
regression from 1.90.1 related to code scoping Tab presses to local scope. (#7226) [@bratpilz]
|
|
||||||
- Nav: Fixed pressing Escape while in a child window with _NavFlattened flag. (#7237)
|
|
||||||
- Nav: Improve handling of Alt key to toggle menu so that key ownership may be claimed on
|
|
||||||
individual left/right alt key without interfering with the other.
|
|
||||||
- Nav, Menus: Fixed click on a BeginMenu() followed by right-arrow from making the child menu
|
|
||||||
reopen and flicker (using ImGuiPopupFlags_NoReopen).
|
|
||||||
- Nav: ImGuiWindowFlags_NoNavInputs is tested during scoring so NavFlattened windows can use it.
|
|
||||||
- Popups: OpenPopup(): added ImGuiPopupFlags_NoReopen flag to specifically not close and reopen
|
|
||||||
a popup when it is already open. (#1497, #1533)
|
|
||||||
(Note that this differs from specific handling we already have in place for the case of calling
|
|
||||||
OpenPopup() repeatedly every frame: we already didn't reopen in that specific situation, otherwise
|
|
||||||
the effect would be very disastrous in term of confusion, as reopening would steal focus).
|
|
||||||
- Popups: Slight change to popup closing logic (e.g. after focusing another window) which skipped
|
|
||||||
over popups that are also child windows.
|
|
||||||
- Combo: Fixed not reusing windows optimally when used inside a popup stack.
|
|
||||||
- Debug Tools: Metrics: Fixed debug break in SetShortcutRouting() not handling ImGuiMod_Shortcut redirect.
|
|
||||||
- Debug Tools: Metrics: Improved Monitors and Viewports minimap display. Highlight on hover.
|
|
||||||
- Debug Tools: Debug Log: Added "Input Routing" logging.
|
|
||||||
- Debug Tools: Added "nop" to IM_DEBUG_BREAK macro on GCC to work around GDB bug (#7266) [@Peter0x44]
|
|
||||||
- Backends: Vulkan: Fixed vkAcquireNextImageKHR() validation errors in VulkanSDK 1.3.275 by
|
|
||||||
allocating one extra semaphore than in-flight frames. (#7236) [@mklefrancois]
|
|
||||||
- Backends: Vulkan: Fixed vkMapMemory() calls unnecessarily using full buffer size. (#3957)
|
|
||||||
- Backends: Vulkan: Fixed handling of ImGui_ImplVulkan_InitInfo::MinAllocationSize field. (#7189, #4238)
|
|
||||||
- Backends: WebGPU: Added ImGui_ImplWGPU_InitInfo::PipelineMultisampleState. (#7240)
|
|
||||||
- Backends: WebGPU: Filling all WGPUDepthStencilState fields explicitly as a recent Dawn
|
|
||||||
update stopped setting default values. (#7232) [@GrigoryGraborenko]
|
|
||||||
- Backends: WebGPU: Fixed pipeline layout leak. (#7245) [@rajveermalviya]
|
|
||||||
- Backends: OpenGL3: Backup and restore GL_PIXEL_UNPACK_BUFFER. (#7253)
|
|
||||||
- Internals: Many improvements related to yet unpublicized shortcut routing and input ownership systems.
|
|
||||||
- Internals: InputText: Added internal helpers to force reload of user-buf when active. (#2890) [@kudaba, @ocornut]
|
|
||||||
Often requested in some form (#6962, #5219, #3290, #4627, #5054, #3878, #2881, #1506, #1216, #968),
|
|
||||||
and useful for interactive completion/suggestions popups (#2057, #718)
|
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.90.1 (Released 2024-01-10)
|
VERSION 1.90.1 (Released 2024-01-10)
|
||||||
@ -430,9 +90,6 @@ Other changes:
|
|||||||
- Color Editors:
|
- Color Editors:
|
||||||
- ColorEdit: Layout tweaks for very small sizes. (#7120, #7121)
|
- ColorEdit: Layout tweaks for very small sizes. (#7120, #7121)
|
||||||
- ColorPicker: Fixed saturation/value cursor radius not scaling properly.
|
- ColorPicker: Fixed saturation/value cursor radius not scaling properly.
|
||||||
- Tabs: Added ImGuiTabItemFlags_NoAssumedClosure to enable app to react on closure attempt,
|
|
||||||
without having to draw an unsaved document marker (ImGuiTabItemFlags_UnsavedDocument sets
|
|
||||||
_NoAssumedClosure automatically). (#7084)
|
|
||||||
- Debug Tools:
|
- Debug Tools:
|
||||||
- Added io.ConfigDebugIsDebuggerPresent option. When enabled, this adds buttons in various
|
- Added io.ConfigDebugIsDebuggerPresent option. When enabled, this adds buttons in various
|
||||||
locations of Metrics/Debugger to manually request a debugger break:
|
locations of Metrics/Debugger to manually request a debugger break:
|
||||||
@ -599,7 +256,7 @@ Other changes:
|
|||||||
with ImGuiDragDropFlags_AcceptNoPreviewTooltip and submitting a tooltip manually.
|
with ImGuiDragDropFlags_AcceptNoPreviewTooltip and submitting a tooltip manually.
|
||||||
- Tables:
|
- Tables:
|
||||||
- Added angled headers support. You need to set ImGuiTableColumnFlags_AngledHeader on selected
|
- Added angled headers support. You need to set ImGuiTableColumnFlags_AngledHeader on selected
|
||||||
columns and call TableAngledHeadersRow(). Added style.TableAngledHeadersAngle style option. (#6917)
|
columns and call TableAngledHeadersRow(). Added style.TableAngledHeadersAngle style option.
|
||||||
- Added ImGuiTableFlags_HighlightHoveredColumn flag, currently highlighting column header.
|
- Added ImGuiTableFlags_HighlightHoveredColumn flag, currently highlighting column header.
|
||||||
- Fixed an edge-case when no columns are visible + table scrollbar is visible + user
|
- Fixed an edge-case when no columns are visible + table scrollbar is visible + user
|
||||||
code is always testing return value of TableSetColumnIndex() to coarse clip. With an active
|
code is always testing return value of TableSetColumnIndex() to coarse clip. With an active
|
||||||
@ -926,7 +583,7 @@ Breaking changes:
|
|||||||
- ListBoxFooter() -> use EndListBox()
|
- ListBoxFooter() -> use EndListBox()
|
||||||
- Note how two variants of ListBoxHeader() existed. Check commented versions in imgui.h for refeence.
|
- Note how two variants of ListBoxHeader() existed. Check commented versions in imgui.h for refeence.
|
||||||
- Backends: SDL_Renderer: Renamed 'imgui_impl_sdlrenderer.h/cpp' to 'imgui_impl_sdlrenderer2.h/cpp',
|
- Backends: SDL_Renderer: Renamed 'imgui_impl_sdlrenderer.h/cpp' to 'imgui_impl_sdlrenderer2.h/cpp',
|
||||||
in order to accommodate for upcoming SDL3 and change in its SDL_Renderer API. (#6286)
|
in order to accomodate for upcoming SDL3 and change in its SDL_Renderer API. (#6286)
|
||||||
- Backends: GLUT: Removed call to ImGui::NewFrame() from ImGui_ImplGLUT_NewFrame().
|
- Backends: GLUT: Removed call to ImGui::NewFrame() from ImGui_ImplGLUT_NewFrame().
|
||||||
It needs to be called from the main app loop, like with every other backends. (#6337) [@GereonV]
|
It needs to be called from the main app loop, like with every other backends. (#6337) [@GereonV]
|
||||||
|
|
||||||
@ -1489,7 +1146,7 @@ Other Changes:
|
|||||||
- Backends: Metal: Use __bridge for ARC based systems. (#5403) [@stack]
|
- Backends: Metal: Use __bridge for ARC based systems. (#5403) [@stack]
|
||||||
- Backends: Metal: Add dispatch synchronization. (#5447) [@luigifcruz]
|
- Backends: Metal: Add dispatch synchronization. (#5447) [@luigifcruz]
|
||||||
- Backends: Metal: Update deprecated property 'sampleCount'->'rasterSampleCount'. (#5603) [@dcvz]
|
- Backends: Metal: Update deprecated property 'sampleCount'->'rasterSampleCount'. (#5603) [@dcvz]
|
||||||
- Backends: Vulkan: Added experimental ImGui_ImplVulkan_RemoveTexture() for api symmetry. (#914, #5738).
|
- Backends: Vulkan: Added experimental ImGui_ImplVulkan_RemoveTexture() for api symetry. (#914, #5738).
|
||||||
- Backends: WebGPU: fixed rendering when a depth buffer is enabled. (#5869) [@brainlag]
|
- Backends: WebGPU: fixed rendering when a depth buffer is enabled. (#5869) [@brainlag]
|
||||||
|
|
||||||
|
|
||||||
@ -2262,7 +1919,7 @@ Other Changes:
|
|||||||
alpha compositing and transparent windows. (#2766, #3447 etc.).
|
alpha compositing and transparent windows. (#2766, #3447 etc.).
|
||||||
- Backends: OpenGL, Vulkan, DX9, DX10, DX11, DX12, Metal, WebGPU, Allegro: Rework blending equation to
|
- Backends: OpenGL, Vulkan, DX9, DX10, DX11, DX12, Metal, WebGPU, Allegro: Rework blending equation to
|
||||||
preserve alpha in output buffer (using SrcBlendAlpha = ONE, DstBlendAlpha = ONE_MINUS_SRC_ALPHA consistently
|
preserve alpha in output buffer (using SrcBlendAlpha = ONE, DstBlendAlpha = ONE_MINUS_SRC_ALPHA consistently
|
||||||
across all backends), facilitating compositing of the output buffer with another buffer.
|
accross all backends), facilitating compositing of the output buffer with another buffer.
|
||||||
(#2693, #2764, #2766, #2873, #3447, #3813, #3816) [@ocornut, @thedmd, @ShawnM427, @Ubpa, @aiekick]
|
(#2693, #2764, #2766, #2873, #3447, #3813, #3816) [@ocornut, @thedmd, @ShawnM427, @Ubpa, @aiekick]
|
||||||
- Backends: DX9: Fix to support IMGUI_USE_BGRA_PACKED_COLOR. (#3844) [@Xiliusha]
|
- Backends: DX9: Fix to support IMGUI_USE_BGRA_PACKED_COLOR. (#3844) [@Xiliusha]
|
||||||
- Backends: DX9: Fix to support colored glyphs, using newly introduced 'TexPixelsUseColors' info. (#3844)
|
- Backends: DX9: Fix to support colored glyphs, using newly introduced 'TexPixelsUseColors' info. (#3844)
|
||||||
@ -3873,6 +3530,8 @@ Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v
|
|||||||
|
|
||||||
Breaking Changes:
|
Breaking Changes:
|
||||||
|
|
||||||
|
- Tabs: Added ImGuiTabItemFlags_NoAssumedClosure to enable app to react on closure attempt, without having to draw
|
||||||
|
an unsaved document marker (ImGuiTabItemFlags_UnsavedDocument sets _NoAssumedClosure automatically). (#7084)
|
||||||
- DragInt(): The default compile-time format string has been changed from "%.0f" to "%d", as we are not using integers internally
|
- DragInt(): The default compile-time format string has been changed from "%.0f" to "%d", as we are not using integers internally
|
||||||
any more. If you used DragInt() with custom format strings, make sure you change them to use %d or an integer-compatible format.
|
any more. If you used DragInt() with custom format strings, make sure you change them to use %d or an integer-compatible format.
|
||||||
To honor backward-compatibility, the DragInt() code will currently parse and modify format strings to replace %*f with %d,
|
To honor backward-compatibility, the DragInt() code will currently parse and modify format strings to replace %*f with %d,
|
||||||
@ -5671,7 +5330,7 @@ Other Changes:
|
|||||||
VERSION 1.08 (2014-08-25)
|
VERSION 1.08 (2014-08-25)
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.08
|
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.09
|
||||||
|
|
||||||
- Fixed ImGuiTextFilter trimming of leading/trailing blanks.
|
- Fixed ImGuiTextFilter trimming of leading/trailing blanks.
|
||||||
- Fixed file descriptor leak on LoadSettings() failure.
|
- Fixed file descriptor leak on LoadSettings() failure.
|
||||||
|
2
external/imgui/imgui/docs/CONTRIBUTING.md
vendored
2
external/imgui/imgui/docs/CONTRIBUTING.md
vendored
@ -58,7 +58,7 @@ Steps:
|
|||||||
- Be mindful that messages are being sent to the mailbox of "Watching" users. Try to proofread your messages before sending them. Edits are not seen by those users unless they browse the site.
|
- Be mindful that messages are being sent to the mailbox of "Watching" users. Try to proofread your messages before sending them. Edits are not seen by those users unless they browse the site.
|
||||||
|
|
||||||
**Some unfortunate words of warning**
|
**Some unfortunate words of warning**
|
||||||
- If you are involved in cheating schemes (e.g. DLL injection) for competitive online multiplayer games, please don't post here. We won't answer and you will be blocked. It doesn't matter if your question relates to said project. We've had too many of you and need to protect our time and sanity.
|
- If you are involved in cheating schemes (e.g. DLL injection) for competitive online multiplayer games, please don't post here. We won't answer and you will be blocked. It doesn't matter if your question relates to said project. We've had too many of you and need to project our time and sanity.
|
||||||
- Due to frequent abuse of this service from the aforementioned users, if your GitHub account is anonymous and was created five minutes ago please understand that your post will receive more scrutiny and incomplete questions will be harshly dismissed.
|
- Due to frequent abuse of this service from the aforementioned users, if your GitHub account is anonymous and was created five minutes ago please understand that your post will receive more scrutiny and incomplete questions will be harshly dismissed.
|
||||||
|
|
||||||
If you have been using Dear ImGui for a while or have been using C/C++ for several years or have demonstrated good behavior here, it is ok to not fulfill every item to the letter. Those are guidelines and experienced users or members of the community will know which information is useful in a given context.
|
If you have been using Dear ImGui for a while or have been using C/C++ for several years or have demonstrated good behavior here, it is ok to not fulfill every item to the letter. Those are guidelines and experienced users or members of the community will know which information is useful in a given context.
|
||||||
|
8
external/imgui/imgui/docs/EXAMPLES.md
vendored
8
external/imgui/imgui/docs/EXAMPLES.md
vendored
@ -104,8 +104,8 @@ OSX + OpenGL2 example. <BR>
|
|||||||
(NB: imgui_impl_osx.mm is currently not as feature complete as other platforms backends.
|
(NB: imgui_impl_osx.mm is currently not as feature complete as other platforms backends.
|
||||||
You may prefer to use the GLFW Or SDL backends, which will also support Windows and Linux.)
|
You may prefer to use the GLFW Or SDL backends, which will also support Windows and Linux.)
|
||||||
|
|
||||||
[example_glfw_wgpu/](https://github.com/ocornut/imgui/blob/master/examples/example_glfw_wgpu/) <BR>
|
[example_emscripten_wgpu/](https://github.com/ocornut/imgui/blob/master/examples/example_emscripten_wgpu/) <BR>
|
||||||
GLFW + WebGPU example. Supports Emscripten (web) or Dawn (desktop) <BR>
|
Emcripten + GLFW + WebGPU example. <BR>
|
||||||
= main.cpp + imgui_impl_glfw.cpp + imgui_impl_wgpu.cpp
|
= main.cpp + imgui_impl_glfw.cpp + imgui_impl_wgpu.cpp
|
||||||
Note that the 'example_glfw_opengl3' and 'example_sdl2_opengl3' examples also supports Emscripten!
|
Note that the 'example_glfw_opengl3' and 'example_sdl2_opengl3' examples also supports Emscripten!
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ state, and might confuse your GPU driver. One star, not recommended.
|
|||||||
GLFW (Win32, Mac, Linux) + OpenGL3+/ES2/ES3 example (modern, programmable pipeline). <BR>
|
GLFW (Win32, Mac, Linux) + OpenGL3+/ES2/ES3 example (modern, programmable pipeline). <BR>
|
||||||
= main.cpp + imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp <BR>
|
= main.cpp + imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp <BR>
|
||||||
This uses more modern GL calls and custom shaders.<BR>
|
This uses more modern GL calls and custom shaders.<BR>
|
||||||
This support building with Emscripten and targeting WebGL.<BR>
|
This support building with Emscripten and targetting WebGL.<BR>
|
||||||
Prefer using that if you are using modern GL or WebGL in your application.
|
Prefer using that if you are using modern GL or WebGL in your application.
|
||||||
|
|
||||||
[example_glfw_vulkan/](https://github.com/ocornut/imgui/blob/master/examples/example_glfw_vulkan/) <BR>
|
[example_glfw_vulkan/](https://github.com/ocornut/imgui/blob/master/examples/example_glfw_vulkan/) <BR>
|
||||||
@ -168,7 +168,7 @@ state, and might confuse your GPU driver. One star, not recommended.
|
|||||||
SDL2 (Win32, Mac, Linux, etc.) + OpenGL3+/ES2/ES3 example. <BR>
|
SDL2 (Win32, Mac, Linux, etc.) + OpenGL3+/ES2/ES3 example. <BR>
|
||||||
= main.cpp + imgui_impl_sdl2.cpp + imgui_impl_opengl3.cpp <BR>
|
= main.cpp + imgui_impl_sdl2.cpp + imgui_impl_opengl3.cpp <BR>
|
||||||
This uses more modern GL calls and custom shaders. <BR>
|
This uses more modern GL calls and custom shaders. <BR>
|
||||||
This support building with Emscripten and targeting WebGL.<BR>
|
This support building with Emscripten and targetting WebGL.<BR>
|
||||||
Prefer using that if you are using modern GL or WebGL in your application.
|
Prefer using that if you are using modern GL or WebGL in your application.
|
||||||
|
|
||||||
[example_sdl2_sdlrenderer2/](https://github.com/ocornut/imgui/blob/master/examples/example_sdl2_sdlrenderer2/) <BR>
|
[example_sdl2_sdlrenderer2/](https://github.com/ocornut/imgui/blob/master/examples/example_sdl2_sdlrenderer2/) <BR>
|
||||||
|
42
external/imgui/imgui/docs/FAQ.md
vendored
42
external/imgui/imgui/docs/FAQ.md
vendored
@ -23,7 +23,7 @@ or view this file with any Markdown viewer.
|
|||||||
| [I integrated Dear ImGui in my engine and some elements are clipping or disappearing when I move windows around...](#q-i-integrated-dear-imgui-in-my-engine-and-some-elements-are-clipping-or-disappearing-when-i-move-windows-around) |
|
| [I integrated Dear ImGui in my engine and some elements are clipping or disappearing when I move windows around...](#q-i-integrated-dear-imgui-in-my-engine-and-some-elements-are-clipping-or-disappearing-when-i-move-windows-around) |
|
||||||
| [I integrated Dear ImGui in my engine and some elements are displaying outside their expected windows boundaries...](#q-i-integrated-dear-imgui-in-my-engine-and-some-elements-are-displaying-outside-their-expected-windows-boundaries) |
|
| [I integrated Dear ImGui in my engine and some elements are displaying outside their expected windows boundaries...](#q-i-integrated-dear-imgui-in-my-engine-and-some-elements-are-displaying-outside-their-expected-windows-boundaries) |
|
||||||
| **Q&A: Usage** |
|
| **Q&A: Usage** |
|
||||||
| **[About the ID Stack system..<br>Why is my widget not reacting when I click on it?<br>Why is the wrong widget reacting when I click on one?<br>How can I have widgets with an empty label?<br>How can I have multiple widgets with the same label?<br>How can I have multiple windows with the same label?](#q-about-the-id-stack-system)** |
|
| **[About the ID Stack system..<br>Why is my widget not reacting when I click on it?<br>How can I have widgets with an empty label?<br>How can I have multiple widgets with the same label?<br>How can I have multiple windows with the same label?](#q-about-the-id-stack-system)** |
|
||||||
| [How can I display an image? What is ImTextureID, how does it work?](#q-how-can-i-display-an-image-what-is-imtextureid-how-does-it-work)|
|
| [How can I display an image? What is ImTextureID, how does it work?](#q-how-can-i-display-an-image-what-is-imtextureid-how-does-it-work)|
|
||||||
| [How can I use maths operators with ImVec2?](#q-how-can-i-use-maths-operators-with-imvec2) |
|
| [How can I use maths operators with ImVec2?](#q-how-can-i-use-maths-operators-with-imvec2) |
|
||||||
| [How can I use my own maths types instead of ImVec2/ImVec4?](#q-how-can-i-use-my-own-maths-types-instead-of-imvec2imvec4) |
|
| [How can I use my own maths types instead of ImVec2/ImVec4?](#q-how-can-i-use-my-own-maths-types-instead-of-imvec2imvec4) |
|
||||||
@ -199,42 +199,10 @@ ctx->RSSetScissorRects(1, &r);
|
|||||||
|
|
||||||
### Q: About the ID Stack system...
|
### Q: About the ID Stack system...
|
||||||
### Q: Why is my widget not reacting when I click on it?
|
### Q: Why is my widget not reacting when I click on it?
|
||||||
### Q: Why is the wrong widget reacting when I click on one?
|
|
||||||
### Q: How can I have widgets with an empty label?
|
### Q: How can I have widgets with an empty label?
|
||||||
### Q: How can I have multiple widgets with the same label?
|
### Q: How can I have multiple widgets with the same label?
|
||||||
### Q: How can I have multiple windows with the same label?
|
### Q: How can I have multiple windows with the same label?
|
||||||
|
|
||||||
**USING THE SAME LABEL+ID IS THE MOST COMMON USER MISTAKE:**
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td><img src="https://github.com/ocornut/imgui/assets/8225057/76eb9467-74d1-4e95-9f56-be81c6dd029d"></td>
|
|
||||||
<td>
|
|
||||||
<pre lang="cpp">
|
|
||||||
ImGui::Begin("Incorrect!");
|
|
||||||
ImGui::DragFloat2("My value", &objects[0]->pos.x);
|
|
||||||
ImGui::DragFloat2("My value", &objects[1]->pos.x);
|
|
||||||
ImGui::DragFloat2("My value", &objects[2]->pos.x);
|
|
||||||
ImGui::End();
|
|
||||||
|
|
||||||
ImGui::Begin("Correct!");
|
|
||||||
ImGui::DragFloat2("My value", &objects[0]->pos.x);
|
|
||||||
ImGui::DragFloat2("My value##2", &objects[1]->pos.x);
|
|
||||||
ImGui::DragFloat2("My value##3", &objects[2]->pos.x);
|
|
||||||
ImGui::End();
|
|
||||||
|
|
||||||
ImGui::Begin("Also Correct!");
|
|
||||||
for (int n = 0; n < 3; n++)
|
|
||||||
{
|
|
||||||
ImGui::PushID(n);
|
|
||||||
ImGui::DragFloat2("My value", &objects[n]->pos.x);
|
|
||||||
ImGui::PopID();
|
|
||||||
}
|
|
||||||
ImGui::End();
|
|
||||||
</pre>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
A primer on labels and the ID Stack...
|
A primer on labels and the ID Stack...
|
||||||
|
|
||||||
Dear ImGui internally needs to uniquely identify UI elements.
|
Dear ImGui internally needs to uniquely identify UI elements.
|
||||||
@ -653,8 +621,8 @@ You may take a look at:
|
|||||||
|
|
||||||
- [Quotes](https://github.com/ocornut/imgui/wiki/Quotes)
|
- [Quotes](https://github.com/ocornut/imgui/wiki/Quotes)
|
||||||
- [Software using Dear ImGui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui)
|
- [Software using Dear ImGui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui)
|
||||||
- [Funding & Sponsors](https://github.com/ocornut/imgui/wiki/Funding)
|
- [Sponsors](https://github.com/ocornut/imgui/wiki/Sponsors)
|
||||||
- [Gallery](https://github.com/ocornut/imgui/issues/7503)
|
- [Gallery](https://github.com/ocornut/imgui/issues/6897)
|
||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
@ -696,11 +664,11 @@ There is an auto-generated [c-api for Dear ImGui (cimgui)](https://github.com/ci
|
|||||||
# Q&A: Community
|
# Q&A: Community
|
||||||
|
|
||||||
### Q: How can I help?
|
### Q: How can I help?
|
||||||
- Businesses: please reach out to `omar AT dearimgui.com` if you work in a place using Dear ImGui! We can discuss ways for your company to fund development via invoiced technical support, maintenance, or sponsoring contacts. This is among the most useful thing you can do for Dear ImGui. With increased funding, we can hire more people to work on this project. Please see [Funding](https://github.com/ocornut/imgui/wiki/Funding) page.
|
- Businesses: please reach out to `omar AT dearimgui.com` if you work in a place using Dear ImGui! We can discuss ways for your company to fund development via invoiced technical support, maintenance, or sponsoring contacts. This is among the most useful thing you can do for Dear ImGui. With increased funding, we can hire more people to work on this project.
|
||||||
- Individuals: you can support continued maintenance and development via PayPal donations. See [README](https://github.com/ocornut/imgui/blob/master/docs/README.md).
|
- Individuals: you can support continued maintenance and development via PayPal donations. See [README](https://github.com/ocornut/imgui/blob/master/docs/README.md).
|
||||||
- If you are experienced with Dear ImGui and C++, look at [GitHub Issues](https://github.com/ocornut/imgui/issues), [GitHub Discussions](https://github.com/ocornut/imgui/discussions), the [Wiki](https://github.com/ocornut/imgui/wiki), read [docs/TODO.txt](https://github.com/ocornut/imgui/blob/master/docs/TODO.txt), and see how you want to help and can help!
|
- If you are experienced with Dear ImGui and C++, look at [GitHub Issues](https://github.com/ocornut/imgui/issues), [GitHub Discussions](https://github.com/ocornut/imgui/discussions), the [Wiki](https://github.com/ocornut/imgui/wiki), read [docs/TODO.txt](https://github.com/ocornut/imgui/blob/master/docs/TODO.txt), and see how you want to help and can help!
|
||||||
- Disclose your usage of Dear ImGui via a dev blog post, a tweet, a screenshot, a mention somewhere, etc.
|
- Disclose your usage of Dear ImGui via a dev blog post, a tweet, a screenshot, a mention somewhere, etc.
|
||||||
You may post screenshots or links in the [gallery threads](https://github.com/ocornut/imgui/issues/7503). Visuals are ideal as they inspire other programmers. Disclosing your use of Dear ImGui helps the library grow credibility, and helps other teams and programmers with taking decisions.
|
You may post screenshots or links in the [gallery threads](https://github.com/ocornut/imgui/issues/6897). Visuals are ideal as they inspire other programmers. Disclosing your use of Dear ImGui helps the library grow credibility, and helps other teams and programmers with taking decisions.
|
||||||
- If you have issues or if you need to hack into the library, even if you don't expect any support it is useful that you share your issues or sometimes incomplete PR.
|
- If you have issues or if you need to hack into the library, even if you don't expect any support it is useful that you share your issues or sometimes incomplete PR.
|
||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
|
2
external/imgui/imgui/docs/FONTS.md
vendored
2
external/imgui/imgui/docs/FONTS.md
vendored
@ -53,7 +53,7 @@ All loaded fonts glyphs are rendered into a single texture atlas ahead of time.
|
|||||||
This is often of byproduct of point 3. If you have large number of glyphs or multiple fonts, the texture may become too big for your graphics API. **The typical result of failing to upload a texture is if every glyph or everything appears as empty black or white rectangle.** Mind the fact that some graphics drivers have texture size limitation. If you are building a PC application, mind the fact that your users may use hardware with lower limitations than yours.
|
This is often of byproduct of point 3. If you have large number of glyphs or multiple fonts, the texture may become too big for your graphics API. **The typical result of failing to upload a texture is if every glyph or everything appears as empty black or white rectangle.** Mind the fact that some graphics drivers have texture size limitation. If you are building a PC application, mind the fact that your users may use hardware with lower limitations than yours.
|
||||||
|
|
||||||
Some solutions:
|
Some solutions:
|
||||||
- You may reduce oversampling, e.g. `font_config.OversampleH = 1`, this will half your texture size for a quality loss.
|
- You may reduce oversampling, e.g. `font_config.OversampleH = 1`, this will half your texture size for a quality looss.
|
||||||
Note that while OversampleH = 2 looks visibly very close to 3 in most situations, with OversampleH = 1 the quality drop will be noticeable. Read about oversampling [here](https://github.com/nothings/stb/blob/master/tests/oversample).
|
Note that while OversampleH = 2 looks visibly very close to 3 in most situations, with OversampleH = 1 the quality drop will be noticeable. Read about oversampling [here](https://github.com/nothings/stb/blob/master/tests/oversample).
|
||||||
- Reduce glyphs ranges by calculating them from source localization data.
|
- Reduce glyphs ranges by calculating them from source localization data.
|
||||||
You can use the `ImFontGlyphRangesBuilder` for this purpose and rebuilding your atlas between frames when new characters are needed. This will be the biggest win!
|
You can use the `ImFontGlyphRangesBuilder` for this purpose and rebuilding your atlas between frames when new characters are needed. This will be the biggest win!
|
||||||
|
20
external/imgui/imgui/docs/README.md
vendored
20
external/imgui/imgui/docs/README.md
vendored
@ -11,12 +11,12 @@ Dear ImGui
|
|||||||
|
|
||||||
Businesses: support continued development and maintenance via invoiced sponsoring/support contracts:
|
Businesses: support continued development and maintenance via invoiced sponsoring/support contracts:
|
||||||
<br> _E-mail: contact @ dearimgui dot com_
|
<br> _E-mail: contact @ dearimgui dot com_
|
||||||
<br>Individuals: support continued development and maintenance [here](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WGHNC6MBFLZ2S). Also see [Funding](https://github.com/ocornut/imgui/wiki/Funding) page.
|
<br>Individuals: support continued development and maintenance [here](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WGHNC6MBFLZ2S). Also see [Sponsors](https://github.com/ocornut/imgui/wiki/Sponsors) page.
|
||||||
|
|
||||||
| [The Pitch](#the-pitch) - [Usage](#usage) - [How it works](#how-it-works) - [Releases & Changelogs](#releases--changelogs) - [Demo](#demo) - [Integration](#integration) |
|
| [The Pitch](#the-pitch) - [Usage](#usage) - [How it works](#how-it-works) - [Releases & Changelogs](#releases--changelogs) - [Demo](#demo) - [Integration](#integration) |
|
||||||
:----------------------------------------------------------: |
|
:----------------------------------------------------------: |
|
||||||
| [Gallery](#gallery) - [Support, FAQ](#support-frequently-asked-questions-faq) - [How to help](#how-to-help) - **[Funding & Sponsors](https://github.com/ocornut/imgui/wiki/Funding)** - [Credits](#credits) - [License](#license) |
|
| [Gallery](#gallery) - [Support, FAQ](#support-frequently-asked-questions-faq) - [How to help](#how-to-help) - [Sponsors](https://github.com/ocornut/imgui/wiki/Sponsors) - [Credits](#credits) - [License](#license) |
|
||||||
| [Wiki](https://github.com/ocornut/imgui/wiki) - [Extensions](https://github.com/ocornut/imgui/wiki/Useful-Extensions) - [Languages bindings & frameworks backends](https://github.com/ocornut/imgui/wiki/Bindings) - [Software using Dear ImGui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) - [User quotes](https://github.com/ocornut/imgui/wiki/Quotes) |
|
| [Wiki](https://github.com/ocornut/imgui/wiki) - [Languages & frameworks backends/bindings](https://github.com/ocornut/imgui/wiki/Bindings) - [Software using Dear ImGui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) - [User quotes](https://github.com/ocornut/imgui/wiki/Quotes) |
|
||||||
|
|
||||||
### The Pitch
|
### The Pitch
|
||||||
|
|
||||||
@ -139,9 +139,7 @@ Also see [Wiki](https://github.com/ocornut/imgui/wiki) for more links and ideas.
|
|||||||
|
|
||||||
### Gallery
|
### Gallery
|
||||||
|
|
||||||
Examples projects using Dear ImGui: [Tracy](https://github.com/wolfpld/tracy) (profiler), [ImHex](https://github.com/WerWolv/ImHex) (hex editor/data analysis), [RemedyBG](https://remedybg.itch.io/remedybg) (debugger) and [hundreds of others](https://github.com/ocornut/imgui/wiki/Software-using-Dear-ImGui).
|
For more user-submitted screenshots of projects using Dear ImGui, check out the [Gallery Threads](https://github.com/ocornut/imgui/issues/6897)!
|
||||||
|
|
||||||
For more user-submitted screenshots of projects using Dear ImGui, check out the [Gallery Threads](https://github.com/ocornut/imgui/issues/7503)!
|
|
||||||
|
|
||||||
For a list of third-party widgets and extensions, check out the [Useful Extensions/Widgets](https://github.com/ocornut/imgui/wiki/Useful-Extensions) wiki page.
|
For a list of third-party widgets and extensions, check out the [Useful Extensions/Widgets](https://github.com/ocornut/imgui/wiki/Useful-Extensions) wiki page.
|
||||||
|
|
||||||
@ -162,8 +160,6 @@ See: [Upcoming Changes](https://github.com/ocornut/imgui/wiki/Upcoming-Changes).
|
|||||||
|
|
||||||
See: [Dear ImGui Test Engine + Test Suite](https://github.com/ocornut/imgui_test_engine) for Automation & Testing.
|
See: [Dear ImGui Test Engine + Test Suite](https://github.com/ocornut/imgui_test_engine) for Automation & Testing.
|
||||||
|
|
||||||
For the purposes of getting search engines to crawl the wiki, here's a link to the [Crawable Wiki](https://github-wiki-see.page/m/ocornut/imgui/wiki) (not for humans, [here's why](https://github-wiki-see.page/)).
|
|
||||||
|
|
||||||
Getting started? For first-time users having issues compiling/linking/running or issues loading fonts, please use [GitHub Discussions](https://github.com/ocornut/imgui/discussions). For ANY other questions, bug reports, requests, feedback, please post on [GitHub Issues](https://github.com/ocornut/imgui/issues). Please read and fill the New Issue template carefully.
|
Getting started? For first-time users having issues compiling/linking/running or issues loading fonts, please use [GitHub Discussions](https://github.com/ocornut/imgui/discussions). For ANY other questions, bug reports, requests, feedback, please post on [GitHub Issues](https://github.com/ocornut/imgui/issues). Please read and fill the New Issue template carefully.
|
||||||
|
|
||||||
Private support is available for paying business customers (E-mail: _contact @ dearimgui dot com_).
|
Private support is available for paying business customers (E-mail: _contact @ dearimgui dot com_).
|
||||||
@ -174,7 +170,7 @@ We occasionally tag [Releases](https://github.com/ocornut/imgui/releases) (with
|
|||||||
|
|
||||||
**Who uses Dear ImGui?**
|
**Who uses Dear ImGui?**
|
||||||
|
|
||||||
See the [Quotes](https://github.com/ocornut/imgui/wiki/Quotes), [Funding & Sponsors](https://github.com/ocornut/imgui/wiki/Funding), and [Software using Dear ImGui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) Wiki pages for an idea of who is using Dear ImGui. Please add your game/software if you can! Also, see the [Gallery Threads](https://github.com/ocornut/imgui/issues/7503)!
|
See the [Quotes](https://github.com/ocornut/imgui/wiki/Quotes), [Sponsors](https://github.com/ocornut/imgui/wiki/Sponsors), and [Software using Dear ImGui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) Wiki pages for an idea of who is using Dear ImGui. Please add your game/software if you can! Also, see the [Gallery Threads](https://github.com/ocornut/imgui/issues/6897)!
|
||||||
|
|
||||||
How to help
|
How to help
|
||||||
-----------
|
-----------
|
||||||
@ -184,13 +180,13 @@ How to help
|
|||||||
- See [GitHub Forum/Issues](https://github.com/ocornut/imgui/issues).
|
- See [GitHub Forum/Issues](https://github.com/ocornut/imgui/issues).
|
||||||
- You may help with development and submit pull requests! Please understand that by submitting a PR you are also submitting a request for the maintainer to review your code and then take over its maintenance forever. PR should be crafted both in the interest of the end-users and also to ease the maintainer into understanding and accepting it.
|
- You may help with development and submit pull requests! Please understand that by submitting a PR you are also submitting a request for the maintainer to review your code and then take over its maintenance forever. PR should be crafted both in the interest of the end-users and also to ease the maintainer into understanding and accepting it.
|
||||||
- See [Help wanted](https://github.com/ocornut/imgui/wiki/Help-Wanted) on the [Wiki](https://github.com/ocornut/imgui/wiki/) for some more ideas.
|
- See [Help wanted](https://github.com/ocornut/imgui/wiki/Help-Wanted) on the [Wiki](https://github.com/ocornut/imgui/wiki/) for some more ideas.
|
||||||
- Be a [Funding Supporter](https://github.com/ocornut/imgui/wiki/Funding)! Have your company financially support this project via invoiced sponsors/maintenance or by buying a license for [Dear ImGui Test Engine](https://github.com/ocornut/imgui_test_engine) (please reach out: omar AT dearimgui DOT com).
|
- Be a [sponsor](https://github.com/ocornut/imgui/wiki/Sponsors)! Have your company financially support this project via invoiced sponsors/maintenance or by buying a license for [Dear ImGui Test Engine](https://github.com/ocornut/imgui_test_engine) (please reach out: omar AT dearimgui DOT com).
|
||||||
|
|
||||||
Sponsors
|
Sponsors
|
||||||
--------
|
--------
|
||||||
|
|
||||||
Ongoing Dear ImGui development is and has been financially supported by users and private sponsors.
|
Ongoing Dear ImGui development is and has been financially supported by users and private sponsors.
|
||||||
<BR>Please see the **[detailed list of current and past Dear ImGui funding supporters and sponsors](https://github.com/ocornut/imgui/wiki/Funding)** for details.
|
<BR>Please see the **[detailed list of current and past Dear ImGui supporters](https://github.com/ocornut/imgui/wiki/Sponsors)** for details.
|
||||||
<BR>From November 2014 to December 2019, ongoing development has also been financially supported by its users on Patreon and through individual donations.
|
<BR>From November 2014 to December 2019, ongoing development has also been financially supported by its users on Patreon and through individual donations.
|
||||||
|
|
||||||
**THANK YOU to all past and present supporters for helping to keep this project alive and thriving!**
|
**THANK YOU to all past and present supporters for helping to keep this project alive and thriving!**
|
||||||
@ -207,7 +203,7 @@ Developed by [Omar Cornut](https://www.miracleworld.net) and every direct or ind
|
|||||||
|
|
||||||
Recurring contributors include Rokas Kupstys [@rokups](https://github.com/rokups) (2020-2022): a good portion of work on automation system and regression tests now available in [Dear ImGui Test Engine](https://github.com/ocornut/imgui_test_engine).
|
Recurring contributors include Rokas Kupstys [@rokups](https://github.com/rokups) (2020-2022): a good portion of work on automation system and regression tests now available in [Dear ImGui Test Engine](https://github.com/ocornut/imgui_test_engine).
|
||||||
|
|
||||||
Maintenance/support contracts, sponsoring invoices and other B2B transactions are hosted and handled by [Disco Hello](https://www.discohello.com).
|
Sponsoring, maintenance/support contracts and other B2B transactions are hosted and handled by [Disco Hello](https://www.discohello.com).
|
||||||
|
|
||||||
Omar: "I first discovered the IMGUI paradigm at [Q-Games](https://www.q-games.com) where Atman Binstock had dropped his own simple implementation in the codebase, which I spent quite some time improving and thinking about. It turned out that Atman was exposed to the concept directly by working with Casey. When I moved to Media Molecule I rewrote a new library trying to overcome the flaws and limitations of the first one I've worked with. It became this library and since then I have spent an unreasonable amount of time iterating and improving it."
|
Omar: "I first discovered the IMGUI paradigm at [Q-Games](https://www.q-games.com) where Atman Binstock had dropped his own simple implementation in the codebase, which I spent quite some time improving and thinking about. It turned out that Atman was exposed to the concept directly by working with Casey. When I moved to Media Molecule I rewrote a new library trying to overcome the flaws and limitations of the first one I've worked with. It became this library and since then I have spent an unreasonable amount of time iterating and improving it."
|
||||||
|
|
||||||
|
2
external/imgui/imgui/docs/TODO.txt
vendored
2
external/imgui/imgui/docs/TODO.txt
vendored
@ -175,8 +175,6 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
|||||||
- tooltip: drag tooltip hovering over source widget with IsItemHovered/SetTooltip flickers (WIP branch)
|
- tooltip: drag tooltip hovering over source widget with IsItemHovered/SetTooltip flickers (WIP branch)
|
||||||
|
|
||||||
- status-bar: add a per-window status bar helper similar to what menu-bar does. generalize concept of layer0 rect in window (can make _MenuBar window flag obsolete too).
|
- status-bar: add a per-window status bar helper similar to what menu-bar does. generalize concept of layer0 rect in window (can make _MenuBar window flag obsolete too).
|
||||||
- shortcuts: store multiple keychords in ImGuiKeyChord
|
|
||||||
- shortcuts: Hovered route (lower than Focused, higher than Global)
|
|
||||||
- shortcuts: local-style shortcut api, e.g. parse "&Save"
|
- shortcuts: local-style shortcut api, e.g. parse "&Save"
|
||||||
- shortcuts,menus: global-style shortcut api e.g. "Save (CTRL+S)" -> explicit flag for recursing into closed menu
|
- shortcuts,menus: global-style shortcut api e.g. "Save (CTRL+S)" -> explicit flag for recursing into closed menu
|
||||||
- shortcuts: programmatically access shortcuts "Focus("&Save"))
|
- shortcuts: programmatically access shortcuts "Focus("&Save"))
|
||||||
|
@ -161,7 +161,7 @@ void Init(struct android_app* app)
|
|||||||
|
|
||||||
// We load the default font with increased size to improve readability on many devices with "high" DPI.
|
// We load the default font with increased size to improve readability on many devices with "high" DPI.
|
||||||
// FIXME: Put some effort into DPI awareness.
|
// FIXME: Put some effort into DPI awareness.
|
||||||
// Important: when calling AddFontFromMemoryTTF(), ownership of font_data is transferred by Dear ImGui by default (deleted is handled by Dear ImGui), unless we set FontDataOwnedByAtlas=false in ImFontConfig
|
// Important: when calling AddFontFromMemoryTTF(), ownership of font_data is transfered by Dear ImGui by default (deleted is handled by Dear ImGui), unless we set FontDataOwnedByAtlas=false in ImFontConfig
|
||||||
ImFontConfig font_cfg;
|
ImFontConfig font_cfg;
|
||||||
font_cfg.SizePixels = 22.0f;
|
font_cfg.SizePixels = 22.0f;
|
||||||
io.Fonts->AddFontDefault(&font_cfg);
|
io.Fonts->AddFontDefault(&font_cfg);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
- You may also refer to our [Continuous Integration setup](https://github.com/ocornut/imgui/tree/master/.github/workflows) for Emscripten setup.
|
- You may also refer to our [Continuous Integration setup](https://github.com/ocornut/imgui/tree/master/.github/workflows) for Emscripten setup.
|
||||||
|
|
||||||
- Then build using `make -f Makefile.emscripten` while in the `example_glfw_wgpu/` directory.
|
- Then build using `make` while in the `example_emscripten_wgpu/` directory.
|
||||||
|
|
||||||
- Requires recent Emscripten as WGPU is still a work-in-progress API.
|
- Requires recent Emscripten as WGPU is still a work-in-progress API.
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ To run on a local machine:
|
|||||||
- Otherwise, generally you will need a local webserver:
|
- Otherwise, generally you will need a local webserver:
|
||||||
- Quoting [https://emscripten.org/docs/getting_started](https://emscripten.org/docs/getting_started/Tutorial.html#generating-html):<br>
|
- Quoting [https://emscripten.org/docs/getting_started](https://emscripten.org/docs/getting_started/Tutorial.html#generating-html):<br>
|
||||||
_"Unfortunately several browsers (including Chrome, Safari, and Internet Explorer) do not support file:// [XHR](https://emscripten.org/docs/site/glossary.html#term-xhr) requests, and can’t load extra files needed by the HTML (like a .wasm file, or packaged file data as mentioned lower down). For these browsers you’ll need to serve the files using a [local webserver](https://emscripten.org/docs/getting_started/FAQ.html#faq-local-webserver) and then open http://localhost:8000/hello.html."_
|
_"Unfortunately several browsers (including Chrome, Safari, and Internet Explorer) do not support file:// [XHR](https://emscripten.org/docs/site/glossary.html#term-xhr) requests, and can’t load extra files needed by the HTML (like a .wasm file, or packaged file data as mentioned lower down). For these browsers you’ll need to serve the files using a [local webserver](https://emscripten.org/docs/getting_started/FAQ.html#faq-local-webserver) and then open http://localhost:8000/hello.html."_
|
||||||
- Emscripten SDK has a handy `emrun` command: `emrun web/example_glfw_wgpu.html --browser firefox` which will spawn a temporary local webserver (in Firefox). See https://emscripten.org/docs/compiling/Running-html-files-with-emrun.html for details.
|
- Emscripten SDK has a handy `emrun` command: `emrun web/example_emscripten_opengl3.html --browser firefox` which will spawn a temporary local webserver (in Firefox). See https://emscripten.org/docs/compiling/Running-html-files-with-emrun.html for details.
|
||||||
- You may use Python 3 builtin webserver: `python -m http.server -d web` (this is what `make serve` uses).
|
- You may use Python 3 builtin webserver: `python -m http.server -d web` (this is what `make serve` uses).
|
||||||
- You may use Python 2 builtin webserver: `cd web && python -m SimpleHTTPServer`.
|
- You may use Python 2 builtin webserver: `cd web && python -m SimpleHTTPServer`.
|
||||||
- If you are accessing the files over a network, certain browsers, such as Firefox, will restrict Gamepad API access to secure contexts only (e.g. https only).
|
- If you are accessing the files over a network, certain browsers, such as Firefox, will restrict Gamepad API access to secure contexts only (e.g. https only).
|
254
external/imgui/imgui/examples/example_emscripten_wgpu/main.cpp
vendored
Normal file
254
external/imgui/imgui/examples/example_emscripten_wgpu/main.cpp
vendored
Normal file
@ -0,0 +1,254 @@
|
|||||||
|
// Dear ImGui: standalone example application for Emscripten, using GLFW + WebGPU
|
||||||
|
// (Emscripten is a C++-to-javascript compiler, used to publish executables for the web. See https://emscripten.org/)
|
||||||
|
|
||||||
|
// Learn about Dear ImGui:
|
||||||
|
// - FAQ https://dearimgui.com/faq
|
||||||
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
|
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
||||||
|
// - Introduction, links and more at the top of imgui.cpp
|
||||||
|
|
||||||
|
#include "imgui.h"
|
||||||
|
#include "imgui_impl_glfw.h"
|
||||||
|
#include "imgui_impl_wgpu.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <emscripten.h>
|
||||||
|
#include <emscripten/html5.h>
|
||||||
|
#include <emscripten/html5_webgpu.h>
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
#include <webgpu/webgpu.h>
|
||||||
|
#include <webgpu/webgpu_cpp.h>
|
||||||
|
|
||||||
|
// Global WebGPU required states
|
||||||
|
static WGPUDevice wgpu_device = nullptr;
|
||||||
|
static WGPUSurface wgpu_surface = nullptr;
|
||||||
|
static WGPUTextureFormat wgpu_preferred_fmt = WGPUTextureFormat_RGBA8Unorm;
|
||||||
|
static WGPUSwapChain wgpu_swap_chain = nullptr;
|
||||||
|
static int wgpu_swap_chain_width = 0;
|
||||||
|
static int wgpu_swap_chain_height = 0;
|
||||||
|
|
||||||
|
// Forward declarations
|
||||||
|
static void MainLoopStep(void* window);
|
||||||
|
static bool InitWGPU();
|
||||||
|
static void print_glfw_error(int error, const char* description);
|
||||||
|
static void print_wgpu_error(WGPUErrorType error_type, const char* message, void*);
|
||||||
|
|
||||||
|
// Main code
|
||||||
|
int main(int, char**)
|
||||||
|
{
|
||||||
|
glfwSetErrorCallback(print_glfw_error);
|
||||||
|
if (!glfwInit())
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
// Make sure GLFW does not initialize any graphics context.
|
||||||
|
// This needs to be done explicitly later.
|
||||||
|
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||||
|
GLFWwindow* window = glfwCreateWindow(1280, 720, "Dear ImGui GLFW+WebGPU example", nullptr, nullptr);
|
||||||
|
if (!window)
|
||||||
|
{
|
||||||
|
glfwTerminate();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize the WebGPU environment
|
||||||
|
if (!InitWGPU())
|
||||||
|
{
|
||||||
|
if (window)
|
||||||
|
glfwDestroyWindow(window);
|
||||||
|
glfwTerminate();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
glfwShowWindow(window);
|
||||||
|
|
||||||
|
// Setup Dear ImGui context
|
||||||
|
IMGUI_CHECKVERSION();
|
||||||
|
ImGui::CreateContext();
|
||||||
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
|
||||||
|
// For an Emscripten build we are disabling file-system access, so let's not attempt to do a fopen() of the imgui.ini file.
|
||||||
|
// You may manually call LoadIniSettingsFromMemory() to load settings from your own storage.
|
||||||
|
io.IniFilename = nullptr;
|
||||||
|
|
||||||
|
// Setup Dear ImGui style
|
||||||
|
ImGui::StyleColorsDark();
|
||||||
|
//ImGui::StyleColorsLight();
|
||||||
|
|
||||||
|
// Setup Platform/Renderer backends
|
||||||
|
ImGui_ImplGlfw_InitForOther(window, true);
|
||||||
|
ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback("#canvas");
|
||||||
|
ImGui_ImplWGPU_Init(wgpu_device, 3, wgpu_preferred_fmt, WGPUTextureFormat_Undefined);
|
||||||
|
|
||||||
|
// Load Fonts
|
||||||
|
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
||||||
|
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
||||||
|
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
|
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
||||||
|
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
||||||
|
// - Read 'docs/FONTS.md' for more instructions and details.
|
||||||
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
|
// - Emscripten allows preloading a file or folder to be accessible at runtime. See Makefile for details.
|
||||||
|
//io.Fonts->AddFontDefault();
|
||||||
|
#ifndef IMGUI_DISABLE_FILE_FUNCTIONS
|
||||||
|
//io.Fonts->AddFontFromFileTTF("fonts/segoeui.ttf", 18.0f);
|
||||||
|
io.Fonts->AddFontFromFileTTF("fonts/DroidSans.ttf", 16.0f);
|
||||||
|
//io.Fonts->AddFontFromFileTTF("fonts/Roboto-Medium.ttf", 16.0f);
|
||||||
|
//io.Fonts->AddFontFromFileTTF("fonts/Cousine-Regular.ttf", 15.0f);
|
||||||
|
//io.Fonts->AddFontFromFileTTF("fonts/ProggyTiny.ttf", 10.0f);
|
||||||
|
//ImFont* font = io.Fonts->AddFontFromFileTTF("fonts/ArialUni.ttf", 18.0f, nullptr, io.Fonts->GetGlyphRangesJapanese());
|
||||||
|
//IM_ASSERT(font != nullptr);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// This function will directly return and exit the main function.
|
||||||
|
// Make sure that no required objects get cleaned up.
|
||||||
|
// This way we can use the browsers 'requestAnimationFrame' to control the rendering.
|
||||||
|
emscripten_set_main_loop_arg(MainLoopStep, window, 0, false);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool InitWGPU()
|
||||||
|
{
|
||||||
|
wgpu_device = emscripten_webgpu_get_device();
|
||||||
|
if (!wgpu_device)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
wgpuDeviceSetUncapturedErrorCallback(wgpu_device, print_wgpu_error, nullptr);
|
||||||
|
|
||||||
|
// Use C++ wrapper due to misbehavior in Emscripten.
|
||||||
|
// Some offset computation for wgpuInstanceCreateSurface in JavaScript
|
||||||
|
// seem to be inline with struct alignments in the C++ structure
|
||||||
|
wgpu::SurfaceDescriptorFromCanvasHTMLSelector html_surface_desc = {};
|
||||||
|
html_surface_desc.selector = "#canvas";
|
||||||
|
|
||||||
|
wgpu::SurfaceDescriptor surface_desc = {};
|
||||||
|
surface_desc.nextInChain = &html_surface_desc;
|
||||||
|
|
||||||
|
wgpu::Instance instance = wgpuCreateInstance(nullptr);
|
||||||
|
wgpu::Surface surface = instance.CreateSurface(&surface_desc);
|
||||||
|
wgpu::Adapter adapter = {};
|
||||||
|
wgpu_preferred_fmt = (WGPUTextureFormat)surface.GetPreferredFormat(adapter);
|
||||||
|
wgpu_surface = surface.Release();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MainLoopStep(void* window)
|
||||||
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
glfwPollEvents();
|
||||||
|
|
||||||
|
int width, height;
|
||||||
|
glfwGetFramebufferSize((GLFWwindow*)window, &width, &height);
|
||||||
|
|
||||||
|
// React to changes in screen size
|
||||||
|
if (width != wgpu_swap_chain_width && height != wgpu_swap_chain_height)
|
||||||
|
{
|
||||||
|
ImGui_ImplWGPU_InvalidateDeviceObjects();
|
||||||
|
if (wgpu_swap_chain)
|
||||||
|
wgpuSwapChainRelease(wgpu_swap_chain);
|
||||||
|
wgpu_swap_chain_width = width;
|
||||||
|
wgpu_swap_chain_height = height;
|
||||||
|
WGPUSwapChainDescriptor swap_chain_desc = {};
|
||||||
|
swap_chain_desc.usage = WGPUTextureUsage_RenderAttachment;
|
||||||
|
swap_chain_desc.format = wgpu_preferred_fmt;
|
||||||
|
swap_chain_desc.width = width;
|
||||||
|
swap_chain_desc.height = height;
|
||||||
|
swap_chain_desc.presentMode = WGPUPresentMode_Fifo;
|
||||||
|
wgpu_swap_chain = wgpuDeviceCreateSwapChain(wgpu_device, wgpu_surface, &swap_chain_desc);
|
||||||
|
ImGui_ImplWGPU_CreateDeviceObjects();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start the Dear ImGui frame
|
||||||
|
ImGui_ImplWGPU_NewFrame();
|
||||||
|
ImGui_ImplGlfw_NewFrame();
|
||||||
|
ImGui::NewFrame();
|
||||||
|
|
||||||
|
// Our state
|
||||||
|
// (we use static, which essentially makes the variable globals, as a convenience to keep the example code easy to follow)
|
||||||
|
static bool show_demo_window = true;
|
||||||
|
static bool show_another_window = false;
|
||||||
|
static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
||||||
|
|
||||||
|
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
|
||||||
|
if (show_demo_window)
|
||||||
|
ImGui::ShowDemoWindow(&show_demo_window);
|
||||||
|
|
||||||
|
// 2. Show a simple window that we create ourselves. We use a Begin/End pair to create a named window.
|
||||||
|
{
|
||||||
|
static float f = 0.0f;
|
||||||
|
static int counter = 0;
|
||||||
|
|
||||||
|
ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
|
||||||
|
|
||||||
|
ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
|
||||||
|
ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
|
||||||
|
ImGui::Checkbox("Another Window", &show_another_window);
|
||||||
|
|
||||||
|
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
|
||||||
|
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
|
||||||
|
|
||||||
|
if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
|
||||||
|
counter++;
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::Text("counter = %d", counter);
|
||||||
|
|
||||||
|
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Show another simple window.
|
||||||
|
if (show_another_window)
|
||||||
|
{
|
||||||
|
ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
|
||||||
|
ImGui::Text("Hello from another window!");
|
||||||
|
if (ImGui::Button("Close Me"))
|
||||||
|
show_another_window = false;
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rendering
|
||||||
|
ImGui::Render();
|
||||||
|
|
||||||
|
WGPURenderPassColorAttachment color_attachments = {};
|
||||||
|
color_attachments.loadOp = WGPULoadOp_Clear;
|
||||||
|
color_attachments.storeOp = WGPUStoreOp_Store;
|
||||||
|
color_attachments.clearValue = { clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w };
|
||||||
|
color_attachments.view = wgpuSwapChainGetCurrentTextureView(wgpu_swap_chain);
|
||||||
|
WGPURenderPassDescriptor render_pass_desc = {};
|
||||||
|
render_pass_desc.colorAttachmentCount = 1;
|
||||||
|
render_pass_desc.colorAttachments = &color_attachments;
|
||||||
|
render_pass_desc.depthStencilAttachment = nullptr;
|
||||||
|
|
||||||
|
WGPUCommandEncoderDescriptor enc_desc = {};
|
||||||
|
WGPUCommandEncoder encoder = wgpuDeviceCreateCommandEncoder(wgpu_device, &enc_desc);
|
||||||
|
|
||||||
|
WGPURenderPassEncoder pass = wgpuCommandEncoderBeginRenderPass(encoder, &render_pass_desc);
|
||||||
|
ImGui_ImplWGPU_RenderDrawData(ImGui::GetDrawData(), pass);
|
||||||
|
wgpuRenderPassEncoderEnd(pass);
|
||||||
|
|
||||||
|
WGPUCommandBufferDescriptor cmd_buffer_desc = {};
|
||||||
|
WGPUCommandBuffer cmd_buffer = wgpuCommandEncoderFinish(encoder, &cmd_buffer_desc);
|
||||||
|
WGPUQueue queue = wgpuDeviceGetQueue(wgpu_device);
|
||||||
|
wgpuQueueSubmit(queue, 1, &cmd_buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void print_glfw_error(int error, const char* description)
|
||||||
|
{
|
||||||
|
printf("GLFW Error %d: %s\n", error, description);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void print_wgpu_error(WGPUErrorType error_type, const char* message, void*)
|
||||||
|
{
|
||||||
|
const char* error_type_lbl = "";
|
||||||
|
switch (error_type)
|
||||||
|
{
|
||||||
|
case WGPUErrorType_Validation: error_type_lbl = "Validation"; break;
|
||||||
|
case WGPUErrorType_OutOfMemory: error_type_lbl = "Out of memory"; break;
|
||||||
|
case WGPUErrorType_Unknown: error_type_lbl = "Unknown"; break;
|
||||||
|
case WGPUErrorType_DeviceLost: error_type_lbl = "Device lost"; break;
|
||||||
|
default: error_type_lbl = "Unknown";
|
||||||
|
}
|
||||||
|
printf("%s error: %s\n", error_type_lbl, message);
|
||||||
|
}
|
@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"/>
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"/>
|
||||||
<title>Dear ImGui Emscripten+GLFW+WebGPU example</title>
|
<title>Dear ImGui Emscripten+WebGPU example</title>
|
||||||
<style>
|
<style>
|
||||||
body { margin: 0; background-color: black }
|
body { margin: 0; background-color: black }
|
||||||
.emscripten {
|
.emscripten {
|
||||||
@ -63,10 +63,6 @@
|
|||||||
|
|
||||||
// Initialize the graphics adapter
|
// Initialize the graphics adapter
|
||||||
{
|
{
|
||||||
if (!navigator.gpu) {
|
|
||||||
throw Error("WebGPU not supported.");
|
|
||||||
}
|
|
||||||
|
|
||||||
const adapter = await navigator.gpu.requestAdapter();
|
const adapter = await navigator.gpu.requestAdapter();
|
||||||
const device = await adapter.requestDevice();
|
const device = await adapter.requestDevice();
|
||||||
Module.preinitializedWebGPUDevice = device;
|
Module.preinitializedWebGPUDevice = device;
|
@ -14,10 +14,10 @@ SOURCES += $(IMGUI_DIR)/backends/imgui_impl_glfw.cpp $(IMGUI_DIR)/backends/imgui
|
|||||||
OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
|
OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
|
||||||
|
|
||||||
LIBS = -framework Metal -framework MetalKit -framework Cocoa -framework IOKit -framework CoreVideo -framework QuartzCore
|
LIBS = -framework Metal -framework MetalKit -framework Cocoa -framework IOKit -framework CoreVideo -framework QuartzCore
|
||||||
LIBS += -L/usr/local/lib -L/opt/homebrew/lib -L/opt/local/lib
|
LIBS += -L/usr/local/lib -L/opt/homebrew/lib
|
||||||
LIBS += -lglfw
|
LIBS += -lglfw
|
||||||
|
|
||||||
CXXFLAGS = -std=c++11 -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends -I/usr/local/include -I/opt/homebrew/include -I/opt/local/include
|
CXXFLAGS = -std=c++11 -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends -I/usr/local/include -I/opt/homebrew/include
|
||||||
CXXFLAGS += -Wall -Wformat
|
CXXFLAGS += -Wall -Wformat
|
||||||
CFLAGS = $(CXXFLAGS)
|
CFLAGS = $(CXXFLAGS)
|
||||||
|
|
||||||
|
@ -21,12 +21,8 @@
|
|||||||
#define GLFW_INCLUDE_NONE
|
#define GLFW_INCLUDE_NONE
|
||||||
#define GLFW_INCLUDE_VULKAN
|
#define GLFW_INCLUDE_VULKAN
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
#include <vulkan/vulkan.h>
|
||||||
// Volk headers
|
//#include <vulkan/vulkan_beta.h>
|
||||||
#ifdef IMGUI_IMPL_VULKAN_USE_VOLK
|
|
||||||
#define VOLK_IMPLEMENTATION
|
|
||||||
#include <Volk/volk.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// [Win32] Our example includes a copy of glfw3.lib pre-compiled with VS2010 to maximize ease of testing and compatibility with old VS compilers.
|
// [Win32] Our example includes a copy of glfw3.lib pre-compiled with VS2010 to maximize ease of testing and compatibility with old VS compilers.
|
||||||
// To link with VS2010-era libraries, VS2015+ requires linking with legacy_stdio_definitions.lib, which we do using this pragma.
|
// To link with VS2010-era libraries, VS2015+ requires linking with legacy_stdio_definitions.lib, which we do using this pragma.
|
||||||
@ -35,9 +31,9 @@
|
|||||||
#pragma comment(lib, "legacy_stdio_definitions")
|
#pragma comment(lib, "legacy_stdio_definitions")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//#define APP_USE_UNLIMITED_FRAME_RATE
|
//#define IMGUI_UNLIMITED_FRAME_RATE
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#define APP_USE_VULKAN_DEBUG_REPORT
|
#define IMGUI_VULKAN_DEBUG_REPORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Data
|
// Data
|
||||||
@ -68,14 +64,14 @@ static void check_vk_result(VkResult err)
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef APP_USE_VULKAN_DEBUG_REPORT
|
#ifdef IMGUI_VULKAN_DEBUG_REPORT
|
||||||
static VKAPI_ATTR VkBool32 VKAPI_CALL debug_report(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage, void* pUserData)
|
static VKAPI_ATTR VkBool32 VKAPI_CALL debug_report(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage, void* pUserData)
|
||||||
{
|
{
|
||||||
(void)flags; (void)object; (void)location; (void)messageCode; (void)pUserData; (void)pLayerPrefix; // Unused arguments
|
(void)flags; (void)object; (void)location; (void)messageCode; (void)pUserData; (void)pLayerPrefix; // Unused arguments
|
||||||
fprintf(stderr, "[vulkan] Debug report from ObjectType: %i\nMessage: %s\n\n", objectType, pMessage);
|
fprintf(stderr, "[vulkan] Debug report from ObjectType: %i\nMessage: %s\n\n", objectType, pMessage);
|
||||||
return VK_FALSE;
|
return VK_FALSE;
|
||||||
}
|
}
|
||||||
#endif // APP_USE_VULKAN_DEBUG_REPORT
|
#endif // IMGUI_VULKAN_DEBUG_REPORT
|
||||||
|
|
||||||
static bool IsExtensionAvailable(const ImVector<VkExtensionProperties>& properties, const char* extension)
|
static bool IsExtensionAvailable(const ImVector<VkExtensionProperties>& properties, const char* extension)
|
||||||
{
|
{
|
||||||
@ -117,9 +113,6 @@ static VkPhysicalDevice SetupVulkan_SelectPhysicalDevice()
|
|||||||
static void SetupVulkan(ImVector<const char*> instance_extensions)
|
static void SetupVulkan(ImVector<const char*> instance_extensions)
|
||||||
{
|
{
|
||||||
VkResult err;
|
VkResult err;
|
||||||
#ifdef IMGUI_IMPL_VULKAN_USE_VOLK
|
|
||||||
volkInitialize();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Create Vulkan Instance
|
// Create Vulkan Instance
|
||||||
{
|
{
|
||||||
@ -146,7 +139,7 @@ static void SetupVulkan(ImVector<const char*> instance_extensions)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Enabling validation layers
|
// Enabling validation layers
|
||||||
#ifdef APP_USE_VULKAN_DEBUG_REPORT
|
#ifdef IMGUI_VULKAN_DEBUG_REPORT
|
||||||
const char* layers[] = { "VK_LAYER_KHRONOS_validation" };
|
const char* layers[] = { "VK_LAYER_KHRONOS_validation" };
|
||||||
create_info.enabledLayerCount = 1;
|
create_info.enabledLayerCount = 1;
|
||||||
create_info.ppEnabledLayerNames = layers;
|
create_info.ppEnabledLayerNames = layers;
|
||||||
@ -158,20 +151,17 @@ static void SetupVulkan(ImVector<const char*> instance_extensions)
|
|||||||
create_info.ppEnabledExtensionNames = instance_extensions.Data;
|
create_info.ppEnabledExtensionNames = instance_extensions.Data;
|
||||||
err = vkCreateInstance(&create_info, g_Allocator, &g_Instance);
|
err = vkCreateInstance(&create_info, g_Allocator, &g_Instance);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
#ifdef IMGUI_IMPL_VULKAN_USE_VOLK
|
|
||||||
volkLoadInstance(g_Instance);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Setup the debug report callback
|
// Setup the debug report callback
|
||||||
#ifdef APP_USE_VULKAN_DEBUG_REPORT
|
#ifdef IMGUI_VULKAN_DEBUG_REPORT
|
||||||
auto f_vkCreateDebugReportCallbackEXT = (PFN_vkCreateDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkCreateDebugReportCallbackEXT");
|
auto vkCreateDebugReportCallbackEXT = (PFN_vkCreateDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkCreateDebugReportCallbackEXT");
|
||||||
IM_ASSERT(f_vkCreateDebugReportCallbackEXT != nullptr);
|
IM_ASSERT(vkCreateDebugReportCallbackEXT != nullptr);
|
||||||
VkDebugReportCallbackCreateInfoEXT debug_report_ci = {};
|
VkDebugReportCallbackCreateInfoEXT debug_report_ci = {};
|
||||||
debug_report_ci.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT;
|
debug_report_ci.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT;
|
||||||
debug_report_ci.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT;
|
debug_report_ci.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT;
|
||||||
debug_report_ci.pfnCallback = debug_report;
|
debug_report_ci.pfnCallback = debug_report;
|
||||||
debug_report_ci.pUserData = nullptr;
|
debug_report_ci.pUserData = nullptr;
|
||||||
err = f_vkCreateDebugReportCallbackEXT(g_Instance, &debug_report_ci, g_Allocator, &g_DebugReport);
|
err = vkCreateDebugReportCallbackEXT(g_Instance, &debug_report_ci, g_Allocator, &g_DebugReport);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -268,7 +258,7 @@ static void SetupVulkanWindow(ImGui_ImplVulkanH_Window* wd, VkSurfaceKHR surface
|
|||||||
wd->SurfaceFormat = ImGui_ImplVulkanH_SelectSurfaceFormat(g_PhysicalDevice, wd->Surface, requestSurfaceImageFormat, (size_t)IM_ARRAYSIZE(requestSurfaceImageFormat), requestSurfaceColorSpace);
|
wd->SurfaceFormat = ImGui_ImplVulkanH_SelectSurfaceFormat(g_PhysicalDevice, wd->Surface, requestSurfaceImageFormat, (size_t)IM_ARRAYSIZE(requestSurfaceImageFormat), requestSurfaceColorSpace);
|
||||||
|
|
||||||
// Select Present Mode
|
// Select Present Mode
|
||||||
#ifdef APP_USE_UNLIMITED_FRAME_RATE
|
#ifdef IMGUI_UNLIMITED_FRAME_RATE
|
||||||
VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_MAILBOX_KHR, VK_PRESENT_MODE_IMMEDIATE_KHR, VK_PRESENT_MODE_FIFO_KHR };
|
VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_MAILBOX_KHR, VK_PRESENT_MODE_IMMEDIATE_KHR, VK_PRESENT_MODE_FIFO_KHR };
|
||||||
#else
|
#else
|
||||||
VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_FIFO_KHR };
|
VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_FIFO_KHR };
|
||||||
@ -285,11 +275,11 @@ static void CleanupVulkan()
|
|||||||
{
|
{
|
||||||
vkDestroyDescriptorPool(g_Device, g_DescriptorPool, g_Allocator);
|
vkDestroyDescriptorPool(g_Device, g_DescriptorPool, g_Allocator);
|
||||||
|
|
||||||
#ifdef APP_USE_VULKAN_DEBUG_REPORT
|
#ifdef IMGUI_VULKAN_DEBUG_REPORT
|
||||||
// Remove the debug report callback
|
// Remove the debug report callback
|
||||||
auto f_vkDestroyDebugReportCallbackEXT = (PFN_vkDestroyDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkDestroyDebugReportCallbackEXT");
|
auto vkDestroyDebugReportCallbackEXT = (PFN_vkDestroyDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkDestroyDebugReportCallbackEXT");
|
||||||
f_vkDestroyDebugReportCallbackEXT(g_Instance, g_DebugReport, g_Allocator);
|
vkDestroyDebugReportCallbackEXT(g_Instance, g_DebugReport, g_Allocator);
|
||||||
#endif // APP_USE_VULKAN_DEBUG_REPORT
|
#endif // IMGUI_VULKAN_DEBUG_REPORT
|
||||||
|
|
||||||
vkDestroyDevice(g_Device, g_Allocator);
|
vkDestroyDevice(g_Device, g_Allocator);
|
||||||
vkDestroyInstance(g_Instance, g_Allocator);
|
vkDestroyInstance(g_Instance, g_Allocator);
|
||||||
@ -386,7 +376,7 @@ static void FramePresent(ImGui_ImplVulkanH_Window* wd)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
wd->SemaphoreIndex = (wd->SemaphoreIndex + 1) % wd->SemaphoreCount; // Now we can use the next set of semaphores
|
wd->SemaphoreIndex = (wd->SemaphoreIndex + 1) % wd->ImageCount; // Now we can use the next set of semaphores
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main code
|
// Main code
|
||||||
@ -444,14 +434,13 @@ int main(int, char**)
|
|||||||
init_info.Queue = g_Queue;
|
init_info.Queue = g_Queue;
|
||||||
init_info.PipelineCache = g_PipelineCache;
|
init_info.PipelineCache = g_PipelineCache;
|
||||||
init_info.DescriptorPool = g_DescriptorPool;
|
init_info.DescriptorPool = g_DescriptorPool;
|
||||||
init_info.RenderPass = wd->RenderPass;
|
|
||||||
init_info.Subpass = 0;
|
init_info.Subpass = 0;
|
||||||
init_info.MinImageCount = g_MinImageCount;
|
init_info.MinImageCount = g_MinImageCount;
|
||||||
init_info.ImageCount = wd->ImageCount;
|
init_info.ImageCount = wd->ImageCount;
|
||||||
init_info.MSAASamples = VK_SAMPLE_COUNT_1_BIT;
|
init_info.MSAASamples = VK_SAMPLE_COUNT_1_BIT;
|
||||||
init_info.Allocator = g_Allocator;
|
init_info.Allocator = g_Allocator;
|
||||||
init_info.CheckVkResultFn = check_vk_result;
|
init_info.CheckVkResultFn = check_vk_result;
|
||||||
ImGui_ImplVulkan_Init(&init_info);
|
ImGui_ImplVulkan_Init(&init_info, wd->RenderPass);
|
||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
||||||
|
@ -1,100 +0,0 @@
|
|||||||
# Building for desktop (WebGPU-native) with Dawn:
|
|
||||||
# 1. git clone https://github.com/google/dawn dawn
|
|
||||||
# 2. cmake -B build -DIMGUI_DAWN_DIR=dawn
|
|
||||||
# 3. cmake --build build
|
|
||||||
# The resulting binary will be found at one of the following locations:
|
|
||||||
# * build/Debug/example_glfw_wgpu[.exe]
|
|
||||||
# * build/example_glfw_wgpu[.exe]
|
|
||||||
|
|
||||||
# Building for Emscripten:
|
|
||||||
# 1. Install Emscripten SDK following the instructions: https://emscripten.org/docs/getting_started/downloads.html
|
|
||||||
# 2. Install Ninja build system
|
|
||||||
# 3. emcmake cmake -G Ninja -B build
|
|
||||||
# 3. cmake --build build
|
|
||||||
# 4. emrun build/index.html
|
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.10.2)
|
|
||||||
project(imgui_example_glfw_wgpu C CXX)
|
|
||||||
|
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
|
||||||
set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17) # Dawn requires C++17
|
|
||||||
|
|
||||||
# Dear ImGui
|
|
||||||
set(IMGUI_DIR ../../)
|
|
||||||
|
|
||||||
# Libraries
|
|
||||||
if(EMSCRIPTEN)
|
|
||||||
set(LIBRARIES glfw)
|
|
||||||
add_compile_options(-sDISABLE_EXCEPTION_CATCHING=1 -DIMGUI_DISABLE_FILE_FUNCTIONS=1)
|
|
||||||
else()
|
|
||||||
# Dawn wgpu desktop
|
|
||||||
set(DAWN_FETCH_DEPENDENCIES ON)
|
|
||||||
set(IMGUI_DAWN_DIR CACHE PATH "Path to Dawn repository")
|
|
||||||
if (NOT IMGUI_DAWN_DIR)
|
|
||||||
message(FATAL_ERROR "Please specify the Dawn repository by setting IMGUI_DAWN_DIR")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
option(DAWN_FETCH_DEPENDENCIES "Use fetch_dawn_dependencies.py as an alternative to using depot_tools" ON)
|
|
||||||
|
|
||||||
# Dawn builds many things by default - disable things we don't need
|
|
||||||
option(DAWN_BUILD_SAMPLES "Enables building Dawn's samples" OFF)
|
|
||||||
option(TINT_BUILD_CMD_TOOLS "Build the Tint command line tools" OFF)
|
|
||||||
option(TINT_BUILD_DOCS "Build documentation" OFF)
|
|
||||||
option(TINT_BUILD_TESTS "Build tests" OFF)
|
|
||||||
if (NOT APPLE)
|
|
||||||
option(TINT_BUILD_MSL_WRITER "Build the MSL output writer" OFF)
|
|
||||||
endif()
|
|
||||||
if(WIN32)
|
|
||||||
option(TINT_BUILD_SPV_READER "Build the SPIR-V input reader" OFF)
|
|
||||||
option(TINT_BUILD_WGSL_READER "Build the WGSL input reader" ON)
|
|
||||||
option(TINT_BUILD_GLSL_WRITER "Build the GLSL output writer" OFF)
|
|
||||||
option(TINT_BUILD_GLSL_VALIDATOR "Build the GLSL output validator" OFF)
|
|
||||||
option(TINT_BUILD_SPV_WRITER "Build the SPIR-V output writer" OFF)
|
|
||||||
option(TINT_BUILD_WGSL_WRITER "Build the WGSL output writer" ON)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_subdirectory("${IMGUI_DAWN_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/dawn" EXCLUDE_FROM_ALL)
|
|
||||||
|
|
||||||
set(LIBRARIES webgpu_dawn webgpu_cpp webgpu_glfw glfw)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_executable(example_glfw_wgpu
|
|
||||||
main.cpp
|
|
||||||
# backend files
|
|
||||||
${IMGUI_DIR}/backends/imgui_impl_glfw.cpp
|
|
||||||
${IMGUI_DIR}/backends/imgui_impl_wgpu.cpp
|
|
||||||
# Dear ImGui files
|
|
||||||
${IMGUI_DIR}/imgui.cpp
|
|
||||||
${IMGUI_DIR}/imgui_draw.cpp
|
|
||||||
${IMGUI_DIR}/imgui_demo.cpp
|
|
||||||
${IMGUI_DIR}/imgui_tables.cpp
|
|
||||||
${IMGUI_DIR}/imgui_widgets.cpp
|
|
||||||
)
|
|
||||||
target_include_directories(example_glfw_wgpu PUBLIC
|
|
||||||
${IMGUI_DIR}
|
|
||||||
${IMGUI_DIR}/backends
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(example_glfw_wgpu PUBLIC ${LIBRARIES})
|
|
||||||
|
|
||||||
# Emscripten settings
|
|
||||||
if(EMSCRIPTEN)
|
|
||||||
target_link_options(example_glfw_wgpu PRIVATE
|
|
||||||
"-sUSE_WEBGPU=1"
|
|
||||||
"-sUSE_GLFW=3"
|
|
||||||
"-sWASM=1"
|
|
||||||
"-sALLOW_MEMORY_GROWTH=1"
|
|
||||||
"-sNO_EXIT_RUNTIME=0"
|
|
||||||
"-sASSERTIONS=1"
|
|
||||||
"-sDISABLE_EXCEPTION_CATCHING=1"
|
|
||||||
"-sNO_FILESYSTEM=1"
|
|
||||||
)
|
|
||||||
set_target_properties(example_glfw_wgpu PROPERTIES OUTPUT_NAME "index")
|
|
||||||
# copy our custom index.html to build directory
|
|
||||||
add_custom_command(TARGET example_glfw_wgpu POST_BUILD
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_LIST_DIR}/web/index.html" $<TARGET_FILE_DIR:example_glfw_wgpu>
|
|
||||||
)
|
|
||||||
endif()
|
|
@ -1,345 +0,0 @@
|
|||||||
// Dear ImGui: standalone example application for using GLFW + WebGPU
|
|
||||||
// - Emscripten is supported for publishing on web. See https://emscripten.org.
|
|
||||||
// - Dawn is used as a WebGPU implementation on desktop.
|
|
||||||
|
|
||||||
// Learn about Dear ImGui:
|
|
||||||
// - FAQ https://dearimgui.com/faq
|
|
||||||
// - Getting Started https://dearimgui.com/getting-started
|
|
||||||
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
|
|
||||||
// - Introduction, links and more at the top of imgui.cpp
|
|
||||||
|
|
||||||
#include "imgui.h"
|
|
||||||
#include "imgui_impl_glfw.h"
|
|
||||||
#include "imgui_impl_wgpu.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#ifdef __EMSCRIPTEN__
|
|
||||||
#include <emscripten.h>
|
|
||||||
#include <emscripten/html5.h>
|
|
||||||
#include <emscripten/html5_webgpu.h>
|
|
||||||
#else
|
|
||||||
#include <webgpu/webgpu_glfw.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <GLFW/glfw3.h>
|
|
||||||
#include <webgpu/webgpu.h>
|
|
||||||
#include <webgpu/webgpu_cpp.h>
|
|
||||||
|
|
||||||
// This example can also compile and run with Emscripten! See 'Makefile.emscripten' for details.
|
|
||||||
#ifdef __EMSCRIPTEN__
|
|
||||||
#include "../libs/emscripten/emscripten_mainloop_stub.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Global WebGPU required states
|
|
||||||
static WGPUInstance wgpu_instance = nullptr;
|
|
||||||
static WGPUDevice wgpu_device = nullptr;
|
|
||||||
static WGPUSurface wgpu_surface = nullptr;
|
|
||||||
static WGPUTextureFormat wgpu_preferred_fmt = WGPUTextureFormat_RGBA8Unorm;
|
|
||||||
static WGPUSwapChain wgpu_swap_chain = nullptr;
|
|
||||||
static int wgpu_swap_chain_width = 1280;
|
|
||||||
static int wgpu_swap_chain_height = 720;
|
|
||||||
|
|
||||||
// Forward declarations
|
|
||||||
static bool InitWGPU(GLFWwindow* window);
|
|
||||||
static void CreateSwapChain(int width, int height);
|
|
||||||
|
|
||||||
static void glfw_error_callback(int error, const char* description)
|
|
||||||
{
|
|
||||||
printf("GLFW Error %d: %s\n", error, description);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void wgpu_error_callback(WGPUErrorType error_type, const char* message, void*)
|
|
||||||
{
|
|
||||||
const char* error_type_lbl = "";
|
|
||||||
switch (error_type)
|
|
||||||
{
|
|
||||||
case WGPUErrorType_Validation: error_type_lbl = "Validation"; break;
|
|
||||||
case WGPUErrorType_OutOfMemory: error_type_lbl = "Out of memory"; break;
|
|
||||||
case WGPUErrorType_Unknown: error_type_lbl = "Unknown"; break;
|
|
||||||
case WGPUErrorType_DeviceLost: error_type_lbl = "Device lost"; break;
|
|
||||||
default: error_type_lbl = "Unknown";
|
|
||||||
}
|
|
||||||
printf("%s error: %s\n", error_type_lbl, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Main code
|
|
||||||
int main(int, char**)
|
|
||||||
{
|
|
||||||
glfwSetErrorCallback(glfw_error_callback);
|
|
||||||
if (!glfwInit())
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
// Make sure GLFW does not initialize any graphics context.
|
|
||||||
// This needs to be done explicitly later.
|
|
||||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
|
||||||
GLFWwindow* window = glfwCreateWindow(wgpu_swap_chain_width, wgpu_swap_chain_height, "Dear ImGui GLFW+WebGPU example", nullptr, nullptr);
|
|
||||||
if (window == nullptr)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
// Initialize the WebGPU environment
|
|
||||||
if (!InitWGPU(window))
|
|
||||||
{
|
|
||||||
if (window)
|
|
||||||
glfwDestroyWindow(window);
|
|
||||||
glfwTerminate();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
CreateSwapChain(wgpu_swap_chain_width, wgpu_swap_chain_height);
|
|
||||||
glfwShowWindow(window);
|
|
||||||
|
|
||||||
// Setup Dear ImGui context
|
|
||||||
IMGUI_CHECKVERSION();
|
|
||||||
ImGui::CreateContext();
|
|
||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
|
||||||
|
|
||||||
// Setup Dear ImGui style
|
|
||||||
ImGui::StyleColorsDark();
|
|
||||||
//ImGui::StyleColorsLight();
|
|
||||||
|
|
||||||
// Setup Platform/Renderer backends
|
|
||||||
ImGui_ImplGlfw_InitForOther(window, true);
|
|
||||||
#ifdef __EMSCRIPTEN__
|
|
||||||
ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback("#canvas");
|
|
||||||
#endif
|
|
||||||
ImGui_ImplWGPU_InitInfo init_info;
|
|
||||||
init_info.Device = wgpu_device;
|
|
||||||
init_info.NumFramesInFlight = 3;
|
|
||||||
init_info.RenderTargetFormat = wgpu_preferred_fmt;
|
|
||||||
init_info.DepthStencilFormat = WGPUTextureFormat_Undefined;
|
|
||||||
ImGui_ImplWGPU_Init(&init_info);
|
|
||||||
|
|
||||||
// Load Fonts
|
|
||||||
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
|
||||||
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
|
||||||
// - If the file cannot be loaded, the function will return a nullptr. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
|
||||||
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
|
||||||
// - Use '#define IMGUI_ENABLE_FREETYPE' in your imconfig file to use Freetype for higher quality font rendering.
|
|
||||||
// - Read 'docs/FONTS.md' for more instructions and details.
|
|
||||||
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
|
||||||
// - Emscripten allows preloading a file or folder to be accessible at runtime. See Makefile for details.
|
|
||||||
//io.Fonts->AddFontDefault();
|
|
||||||
#ifndef IMGUI_DISABLE_FILE_FUNCTIONS
|
|
||||||
//io.Fonts->AddFontFromFileTTF("fonts/segoeui.ttf", 18.0f);
|
|
||||||
//io.Fonts->AddFontFromFileTTF("fonts/DroidSans.ttf", 16.0f);
|
|
||||||
//io.Fonts->AddFontFromFileTTF("fonts/Roboto-Medium.ttf", 16.0f);
|
|
||||||
//io.Fonts->AddFontFromFileTTF("fonts/Cousine-Regular.ttf", 15.0f);
|
|
||||||
//io.Fonts->AddFontFromFileTTF("fonts/ProggyTiny.ttf", 10.0f);
|
|
||||||
//ImFont* font = io.Fonts->AddFontFromFileTTF("fonts/ArialUni.ttf", 18.0f, nullptr, io.Fonts->GetGlyphRangesJapanese());
|
|
||||||
//IM_ASSERT(font != nullptr);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Our state
|
|
||||||
bool show_demo_window = true;
|
|
||||||
bool show_another_window = false;
|
|
||||||
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
|
||||||
|
|
||||||
// Main loop
|
|
||||||
#ifdef __EMSCRIPTEN__
|
|
||||||
// For an Emscripten build we are disabling file-system access, so let's not attempt to do a fopen() of the imgui.ini file.
|
|
||||||
// You may manually call LoadIniSettingsFromMemory() to load settings from your own storage.
|
|
||||||
io.IniFilename = nullptr;
|
|
||||||
EMSCRIPTEN_MAINLOOP_BEGIN
|
|
||||||
#else
|
|
||||||
while (!glfwWindowShouldClose(window))
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
// Poll and handle events (inputs, window resize, etc.)
|
|
||||||
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
|
||||||
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application, or clear/overwrite your copy of the mouse data.
|
|
||||||
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data.
|
|
||||||
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
|
|
||||||
glfwPollEvents();
|
|
||||||
|
|
||||||
// React to changes in screen size
|
|
||||||
int width, height;
|
|
||||||
glfwGetFramebufferSize((GLFWwindow*)window, &width, &height);
|
|
||||||
if (width != wgpu_swap_chain_width || height != wgpu_swap_chain_height)
|
|
||||||
{
|
|
||||||
ImGui_ImplWGPU_InvalidateDeviceObjects();
|
|
||||||
CreateSwapChain(width, height);
|
|
||||||
ImGui_ImplWGPU_CreateDeviceObjects();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start the Dear ImGui frame
|
|
||||||
ImGui_ImplWGPU_NewFrame();
|
|
||||||
ImGui_ImplGlfw_NewFrame();
|
|
||||||
ImGui::NewFrame();
|
|
||||||
|
|
||||||
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
|
|
||||||
if (show_demo_window)
|
|
||||||
ImGui::ShowDemoWindow(&show_demo_window);
|
|
||||||
|
|
||||||
// 2. Show a simple window that we create ourselves. We use a Begin/End pair to create a named window.
|
|
||||||
{
|
|
||||||
static float f = 0.0f;
|
|
||||||
static int counter = 0;
|
|
||||||
|
|
||||||
ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
|
|
||||||
|
|
||||||
ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
|
|
||||||
ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
|
|
||||||
ImGui::Checkbox("Another Window", &show_another_window);
|
|
||||||
|
|
||||||
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
|
|
||||||
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
|
|
||||||
|
|
||||||
if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
|
|
||||||
counter++;
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::Text("counter = %d", counter);
|
|
||||||
|
|
||||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
|
|
||||||
ImGui::End();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. Show another simple window.
|
|
||||||
if (show_another_window)
|
|
||||||
{
|
|
||||||
ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
|
|
||||||
ImGui::Text("Hello from another window!");
|
|
||||||
if (ImGui::Button("Close Me"))
|
|
||||||
show_another_window = false;
|
|
||||||
ImGui::End();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rendering
|
|
||||||
ImGui::Render();
|
|
||||||
|
|
||||||
#ifndef __EMSCRIPTEN__
|
|
||||||
// Tick needs to be called in Dawn to display validation errors
|
|
||||||
wgpuDeviceTick(wgpu_device);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
WGPURenderPassColorAttachment color_attachments = {};
|
|
||||||
color_attachments.depthSlice = WGPU_DEPTH_SLICE_UNDEFINED;
|
|
||||||
color_attachments.loadOp = WGPULoadOp_Clear;
|
|
||||||
color_attachments.storeOp = WGPUStoreOp_Store;
|
|
||||||
color_attachments.clearValue = { clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w };
|
|
||||||
color_attachments.view = wgpuSwapChainGetCurrentTextureView(wgpu_swap_chain);
|
|
||||||
|
|
||||||
WGPURenderPassDescriptor render_pass_desc = {};
|
|
||||||
render_pass_desc.colorAttachmentCount = 1;
|
|
||||||
render_pass_desc.colorAttachments = &color_attachments;
|
|
||||||
render_pass_desc.depthStencilAttachment = nullptr;
|
|
||||||
|
|
||||||
WGPUCommandEncoderDescriptor enc_desc = {};
|
|
||||||
WGPUCommandEncoder encoder = wgpuDeviceCreateCommandEncoder(wgpu_device, &enc_desc);
|
|
||||||
|
|
||||||
WGPURenderPassEncoder pass = wgpuCommandEncoderBeginRenderPass(encoder, &render_pass_desc);
|
|
||||||
ImGui_ImplWGPU_RenderDrawData(ImGui::GetDrawData(), pass);
|
|
||||||
wgpuRenderPassEncoderEnd(pass);
|
|
||||||
|
|
||||||
WGPUCommandBufferDescriptor cmd_buffer_desc = {};
|
|
||||||
WGPUCommandBuffer cmd_buffer = wgpuCommandEncoderFinish(encoder, &cmd_buffer_desc);
|
|
||||||
WGPUQueue queue = wgpuDeviceGetQueue(wgpu_device);
|
|
||||||
wgpuQueueSubmit(queue, 1, &cmd_buffer);
|
|
||||||
|
|
||||||
#ifndef __EMSCRIPTEN__
|
|
||||||
wgpuSwapChainPresent(wgpu_swap_chain);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
wgpuTextureViewRelease(color_attachments.view);
|
|
||||||
wgpuRenderPassEncoderRelease(pass);
|
|
||||||
wgpuCommandEncoderRelease(encoder);
|
|
||||||
wgpuCommandBufferRelease(cmd_buffer);
|
|
||||||
}
|
|
||||||
#ifdef __EMSCRIPTEN__
|
|
||||||
EMSCRIPTEN_MAINLOOP_END;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Cleanup
|
|
||||||
ImGui_ImplWGPU_Shutdown();
|
|
||||||
ImGui_ImplGlfw_Shutdown();
|
|
||||||
ImGui::DestroyContext();
|
|
||||||
|
|
||||||
glfwDestroyWindow(window);
|
|
||||||
glfwTerminate();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef __EMSCRIPTEN__
|
|
||||||
static WGPUAdapter RequestAdapter(WGPUInstance instance)
|
|
||||||
{
|
|
||||||
auto onAdapterRequestEnded = [](WGPURequestAdapterStatus status, WGPUAdapter adapter, const char* message, void* pUserData)
|
|
||||||
{
|
|
||||||
if (status == WGPURequestAdapterStatus_Success)
|
|
||||||
*(WGPUAdapter*)(pUserData) = adapter;
|
|
||||||
else
|
|
||||||
printf("Could not get WebGPU adapter: %s\n", message);
|
|
||||||
};
|
|
||||||
WGPUAdapter adapter;
|
|
||||||
wgpuInstanceRequestAdapter(instance, nullptr, onAdapterRequestEnded, (void*)&adapter);
|
|
||||||
return adapter;
|
|
||||||
}
|
|
||||||
|
|
||||||
static WGPUDevice RequestDevice(WGPUAdapter& adapter)
|
|
||||||
{
|
|
||||||
auto onDeviceRequestEnded = [](WGPURequestDeviceStatus status, WGPUDevice device, const char* message, void* pUserData)
|
|
||||||
{
|
|
||||||
if (status == WGPURequestDeviceStatus_Success)
|
|
||||||
*(WGPUDevice*)(pUserData) = device;
|
|
||||||
else
|
|
||||||
printf("Could not get WebGPU device: %s\n", message);
|
|
||||||
};
|
|
||||||
WGPUDevice device;
|
|
||||||
wgpuAdapterRequestDevice(adapter, nullptr, onDeviceRequestEnded, (void*)&device);
|
|
||||||
return device;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static bool InitWGPU(GLFWwindow* window)
|
|
||||||
{
|
|
||||||
wgpu::Instance instance = wgpuCreateInstance(nullptr);
|
|
||||||
|
|
||||||
#ifdef __EMSCRIPTEN__
|
|
||||||
wgpu_device = emscripten_webgpu_get_device();
|
|
||||||
if (!wgpu_device)
|
|
||||||
return false;
|
|
||||||
#else
|
|
||||||
WGPUAdapter adapter = RequestAdapter(instance.Get());
|
|
||||||
if (!adapter)
|
|
||||||
return false;
|
|
||||||
wgpu_device = RequestDevice(adapter);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __EMSCRIPTEN__
|
|
||||||
wgpu::SurfaceDescriptorFromCanvasHTMLSelector html_surface_desc = {};
|
|
||||||
html_surface_desc.selector = "#canvas";
|
|
||||||
wgpu::SurfaceDescriptor surface_desc = {};
|
|
||||||
surface_desc.nextInChain = &html_surface_desc;
|
|
||||||
wgpu::Surface surface = instance.CreateSurface(&surface_desc);
|
|
||||||
|
|
||||||
wgpu::Adapter adapter = {};
|
|
||||||
wgpu_preferred_fmt = (WGPUTextureFormat)surface.GetPreferredFormat(adapter);
|
|
||||||
#else
|
|
||||||
wgpu::Surface surface = wgpu::glfw::CreateSurfaceForWindow(instance, window);
|
|
||||||
if (!surface)
|
|
||||||
return false;
|
|
||||||
wgpu_preferred_fmt = WGPUTextureFormat_BGRA8Unorm;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
wgpu_instance = instance.MoveToCHandle();
|
|
||||||
wgpu_surface = surface.MoveToCHandle();
|
|
||||||
|
|
||||||
wgpuDeviceSetUncapturedErrorCallback(wgpu_device, wgpu_error_callback, nullptr);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void CreateSwapChain(int width, int height)
|
|
||||||
{
|
|
||||||
if (wgpu_swap_chain)
|
|
||||||
wgpuSwapChainRelease(wgpu_swap_chain);
|
|
||||||
wgpu_swap_chain_width = width;
|
|
||||||
wgpu_swap_chain_height = height;
|
|
||||||
WGPUSwapChainDescriptor swap_chain_desc = {};
|
|
||||||
swap_chain_desc.usage = WGPUTextureUsage_RenderAttachment;
|
|
||||||
swap_chain_desc.format = wgpu_preferred_fmt;
|
|
||||||
swap_chain_desc.width = width;
|
|
||||||
swap_chain_desc.height = height;
|
|
||||||
swap_chain_desc.presentMode = WGPUPresentMode_Fifo;
|
|
||||||
wgpu_swap_chain = wgpuDeviceCreateSwapChain(wgpu_device, wgpu_surface, &swap_chain_desc);
|
|
||||||
}
|
|
@ -155,7 +155,7 @@ int main(int, char**)
|
|||||||
SDL_RenderSetScale(renderer, io.DisplayFramebufferScale.x, io.DisplayFramebufferScale.y);
|
SDL_RenderSetScale(renderer, io.DisplayFramebufferScale.x, io.DisplayFramebufferScale.y);
|
||||||
SDL_SetRenderDrawColor(renderer, (Uint8)(clear_color.x * 255), (Uint8)(clear_color.y * 255), (Uint8)(clear_color.z * 255), (Uint8)(clear_color.w * 255));
|
SDL_SetRenderDrawColor(renderer, (Uint8)(clear_color.x * 255), (Uint8)(clear_color.y * 255), (Uint8)(clear_color.z * 255), (Uint8)(clear_color.w * 255));
|
||||||
SDL_RenderClear(renderer);
|
SDL_RenderClear(renderer);
|
||||||
ImGui_ImplSDLRenderer2_RenderDrawData(ImGui::GetDrawData(), renderer);
|
ImGui_ImplSDLRenderer2_RenderDrawData(ImGui::GetDrawData());
|
||||||
SDL_RenderPresent(renderer);
|
SDL_RenderPresent(renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,16 +20,12 @@
|
|||||||
#include <stdlib.h> // abort
|
#include <stdlib.h> // abort
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <SDL_vulkan.h>
|
#include <SDL_vulkan.h>
|
||||||
|
#include <vulkan/vulkan.h>
|
||||||
|
//#include <vulkan/vulkan_beta.h>
|
||||||
|
|
||||||
// Volk headers
|
//#define IMGUI_UNLIMITED_FRAME_RATE
|
||||||
#ifdef IMGUI_IMPL_VULKAN_USE_VOLK
|
|
||||||
#define VOLK_IMPLEMENTATION
|
|
||||||
#include <Volk/volk.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//#define APP_USE_UNLIMITED_FRAME_RATE
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#define APP_USE_VULKAN_DEBUG_REPORT
|
#define IMGUI_VULKAN_DEBUG_REPORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Data
|
// Data
|
||||||
@ -56,14 +52,14 @@ static void check_vk_result(VkResult err)
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef APP_USE_VULKAN_DEBUG_REPORT
|
#ifdef IMGUI_VULKAN_DEBUG_REPORT
|
||||||
static VKAPI_ATTR VkBool32 VKAPI_CALL debug_report(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage, void* pUserData)
|
static VKAPI_ATTR VkBool32 VKAPI_CALL debug_report(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage, void* pUserData)
|
||||||
{
|
{
|
||||||
(void)flags; (void)object; (void)location; (void)messageCode; (void)pUserData; (void)pLayerPrefix; // Unused arguments
|
(void)flags; (void)object; (void)location; (void)messageCode; (void)pUserData; (void)pLayerPrefix; // Unused arguments
|
||||||
fprintf(stderr, "[vulkan] Debug report from ObjectType: %i\nMessage: %s\n\n", objectType, pMessage);
|
fprintf(stderr, "[vulkan] Debug report from ObjectType: %i\nMessage: %s\n\n", objectType, pMessage);
|
||||||
return VK_FALSE;
|
return VK_FALSE;
|
||||||
}
|
}
|
||||||
#endif // APP_USE_VULKAN_DEBUG_REPORT
|
#endif // IMGUI_VULKAN_DEBUG_REPORT
|
||||||
|
|
||||||
static bool IsExtensionAvailable(const ImVector<VkExtensionProperties>& properties, const char* extension)
|
static bool IsExtensionAvailable(const ImVector<VkExtensionProperties>& properties, const char* extension)
|
||||||
{
|
{
|
||||||
@ -105,9 +101,6 @@ static VkPhysicalDevice SetupVulkan_SelectPhysicalDevice()
|
|||||||
static void SetupVulkan(ImVector<const char*> instance_extensions)
|
static void SetupVulkan(ImVector<const char*> instance_extensions)
|
||||||
{
|
{
|
||||||
VkResult err;
|
VkResult err;
|
||||||
#ifdef IMGUI_IMPL_VULKAN_USE_VOLK
|
|
||||||
volkInitialize();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Create Vulkan Instance
|
// Create Vulkan Instance
|
||||||
{
|
{
|
||||||
@ -134,7 +127,7 @@ static void SetupVulkan(ImVector<const char*> instance_extensions)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Enabling validation layers
|
// Enabling validation layers
|
||||||
#ifdef APP_USE_VULKAN_DEBUG_REPORT
|
#ifdef IMGUI_VULKAN_DEBUG_REPORT
|
||||||
const char* layers[] = { "VK_LAYER_KHRONOS_validation" };
|
const char* layers[] = { "VK_LAYER_KHRONOS_validation" };
|
||||||
create_info.enabledLayerCount = 1;
|
create_info.enabledLayerCount = 1;
|
||||||
create_info.ppEnabledLayerNames = layers;
|
create_info.ppEnabledLayerNames = layers;
|
||||||
@ -146,20 +139,17 @@ static void SetupVulkan(ImVector<const char*> instance_extensions)
|
|||||||
create_info.ppEnabledExtensionNames = instance_extensions.Data;
|
create_info.ppEnabledExtensionNames = instance_extensions.Data;
|
||||||
err = vkCreateInstance(&create_info, g_Allocator, &g_Instance);
|
err = vkCreateInstance(&create_info, g_Allocator, &g_Instance);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
#ifdef IMGUI_IMPL_VULKAN_USE_VOLK
|
|
||||||
volkLoadInstance(g_Instance);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Setup the debug report callback
|
// Setup the debug report callback
|
||||||
#ifdef APP_USE_VULKAN_DEBUG_REPORT
|
#ifdef IMGUI_VULKAN_DEBUG_REPORT
|
||||||
auto f_vkCreateDebugReportCallbackEXT = (PFN_vkCreateDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkCreateDebugReportCallbackEXT");
|
auto vkCreateDebugReportCallbackEXT = (PFN_vkCreateDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkCreateDebugReportCallbackEXT");
|
||||||
IM_ASSERT(f_vkCreateDebugReportCallbackEXT != nullptr);
|
IM_ASSERT(vkCreateDebugReportCallbackEXT != nullptr);
|
||||||
VkDebugReportCallbackCreateInfoEXT debug_report_ci = {};
|
VkDebugReportCallbackCreateInfoEXT debug_report_ci = {};
|
||||||
debug_report_ci.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT;
|
debug_report_ci.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT;
|
||||||
debug_report_ci.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT;
|
debug_report_ci.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT;
|
||||||
debug_report_ci.pfnCallback = debug_report;
|
debug_report_ci.pfnCallback = debug_report;
|
||||||
debug_report_ci.pUserData = nullptr;
|
debug_report_ci.pUserData = nullptr;
|
||||||
err = f_vkCreateDebugReportCallbackEXT(g_Instance, &debug_report_ci, g_Allocator, &g_DebugReport);
|
err = vkCreateDebugReportCallbackEXT(g_Instance, &debug_report_ci, g_Allocator, &g_DebugReport);
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -256,7 +246,7 @@ static void SetupVulkanWindow(ImGui_ImplVulkanH_Window* wd, VkSurfaceKHR surface
|
|||||||
wd->SurfaceFormat = ImGui_ImplVulkanH_SelectSurfaceFormat(g_PhysicalDevice, wd->Surface, requestSurfaceImageFormat, (size_t)IM_ARRAYSIZE(requestSurfaceImageFormat), requestSurfaceColorSpace);
|
wd->SurfaceFormat = ImGui_ImplVulkanH_SelectSurfaceFormat(g_PhysicalDevice, wd->Surface, requestSurfaceImageFormat, (size_t)IM_ARRAYSIZE(requestSurfaceImageFormat), requestSurfaceColorSpace);
|
||||||
|
|
||||||
// Select Present Mode
|
// Select Present Mode
|
||||||
#ifdef APP_UNLIMITED_FRAME_RATE
|
#ifdef IMGUI_UNLIMITED_FRAME_RATE
|
||||||
VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_MAILBOX_KHR, VK_PRESENT_MODE_IMMEDIATE_KHR, VK_PRESENT_MODE_FIFO_KHR };
|
VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_MAILBOX_KHR, VK_PRESENT_MODE_IMMEDIATE_KHR, VK_PRESENT_MODE_FIFO_KHR };
|
||||||
#else
|
#else
|
||||||
VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_FIFO_KHR };
|
VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_FIFO_KHR };
|
||||||
@ -273,11 +263,11 @@ static void CleanupVulkan()
|
|||||||
{
|
{
|
||||||
vkDestroyDescriptorPool(g_Device, g_DescriptorPool, g_Allocator);
|
vkDestroyDescriptorPool(g_Device, g_DescriptorPool, g_Allocator);
|
||||||
|
|
||||||
#ifdef APP_USE_VULKAN_DEBUG_REPORT
|
#ifdef IMGUI_VULKAN_DEBUG_REPORT
|
||||||
// Remove the debug report callback
|
// Remove the debug report callback
|
||||||
auto f_vkDestroyDebugReportCallbackEXT = (PFN_vkDestroyDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkDestroyDebugReportCallbackEXT");
|
auto vkDestroyDebugReportCallbackEXT = (PFN_vkDestroyDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkDestroyDebugReportCallbackEXT");
|
||||||
f_vkDestroyDebugReportCallbackEXT(g_Instance, g_DebugReport, g_Allocator);
|
vkDestroyDebugReportCallbackEXT(g_Instance, g_DebugReport, g_Allocator);
|
||||||
#endif // APP_USE_VULKAN_DEBUG_REPORT
|
#endif // IMGUI_VULKAN_DEBUG_REPORT
|
||||||
|
|
||||||
vkDestroyDevice(g_Device, g_Allocator);
|
vkDestroyDevice(g_Device, g_Allocator);
|
||||||
vkDestroyInstance(g_Instance, g_Allocator);
|
vkDestroyInstance(g_Instance, g_Allocator);
|
||||||
@ -374,7 +364,7 @@ static void FramePresent(ImGui_ImplVulkanH_Window* wd)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
wd->SemaphoreIndex = (wd->SemaphoreIndex + 1) % wd->SemaphoreCount; // Now we can use the next set of semaphores
|
wd->SemaphoreIndex = (wd->SemaphoreIndex + 1) % wd->ImageCount; // Now we can use the next set of semaphores
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main code
|
// Main code
|
||||||
@ -444,14 +434,13 @@ int main(int, char**)
|
|||||||
init_info.Queue = g_Queue;
|
init_info.Queue = g_Queue;
|
||||||
init_info.PipelineCache = g_PipelineCache;
|
init_info.PipelineCache = g_PipelineCache;
|
||||||
init_info.DescriptorPool = g_DescriptorPool;
|
init_info.DescriptorPool = g_DescriptorPool;
|
||||||
init_info.RenderPass = wd->RenderPass;
|
|
||||||
init_info.Subpass = 0;
|
init_info.Subpass = 0;
|
||||||
init_info.MinImageCount = g_MinImageCount;
|
init_info.MinImageCount = g_MinImageCount;
|
||||||
init_info.ImageCount = wd->ImageCount;
|
init_info.ImageCount = wd->ImageCount;
|
||||||
init_info.MSAASamples = VK_SAMPLE_COUNT_1_BIT;
|
init_info.MSAASamples = VK_SAMPLE_COUNT_1_BIT;
|
||||||
init_info.Allocator = g_Allocator;
|
init_info.Allocator = g_Allocator;
|
||||||
init_info.CheckVkResultFn = check_vk_result;
|
init_info.CheckVkResultFn = check_vk_result;
|
||||||
ImGui_ImplVulkan_Init(&init_info);
|
ImGui_ImplVulkan_Init(&init_info, wd->RenderPass);
|
||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
||||||
|
@ -42,8 +42,7 @@ int main(int, char**)
|
|||||||
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
printf("Error: SDL_CreateWindow(): %s\n", SDL_GetError());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
SDL_Renderer* renderer = SDL_CreateRenderer(window, nullptr);
|
SDL_Renderer* renderer = SDL_CreateRenderer(window, nullptr, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
|
||||||
SDL_SetRenderVSync(renderer, 1);
|
|
||||||
if (renderer == nullptr)
|
if (renderer == nullptr)
|
||||||
{
|
{
|
||||||
SDL_Log("Error: SDL_CreateRenderer(): %s\n", SDL_GetError());
|
SDL_Log("Error: SDL_CreateRenderer(): %s\n", SDL_GetError());
|
||||||
@ -162,7 +161,7 @@ int main(int, char**)
|
|||||||
//SDL_RenderSetScale(renderer, io.DisplayFramebufferScale.x, io.DisplayFramebufferScale.y);
|
//SDL_RenderSetScale(renderer, io.DisplayFramebufferScale.x, io.DisplayFramebufferScale.y);
|
||||||
SDL_SetRenderDrawColor(renderer, (Uint8)(clear_color.x * 255), (Uint8)(clear_color.y * 255), (Uint8)(clear_color.z * 255), (Uint8)(clear_color.w * 255));
|
SDL_SetRenderDrawColor(renderer, (Uint8)(clear_color.x * 255), (Uint8)(clear_color.y * 255), (Uint8)(clear_color.z * 255), (Uint8)(clear_color.w * 255));
|
||||||
SDL_RenderClear(renderer);
|
SDL_RenderClear(renderer);
|
||||||
ImGui_ImplSDLRenderer3_RenderDrawData(ImGui::GetDrawData(), renderer);
|
ImGui_ImplSDLRenderer3_RenderDrawData(ImGui::GetDrawData());
|
||||||
SDL_RenderPresent(renderer);
|
SDL_RenderPresent(renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
// Data
|
// Data
|
||||||
static ID3D10Device* g_pd3dDevice = nullptr;
|
static ID3D10Device* g_pd3dDevice = nullptr;
|
||||||
static IDXGISwapChain* g_pSwapChain = nullptr;
|
static IDXGISwapChain* g_pSwapChain = nullptr;
|
||||||
static bool g_SwapChainOccluded = false;
|
|
||||||
static UINT g_ResizeWidth = 0, g_ResizeHeight = 0;
|
static UINT g_ResizeWidth = 0, g_ResizeHeight = 0;
|
||||||
static ID3D10RenderTargetView* g_mainRenderTargetView = nullptr;
|
static ID3D10RenderTargetView* g_mainRenderTargetView = nullptr;
|
||||||
|
|
||||||
@ -101,14 +100,6 @@ int main(int, char**)
|
|||||||
if (done)
|
if (done)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Handle window being minimized or screen locked
|
|
||||||
if (g_SwapChainOccluded && g_pSwapChain->Present(0, DXGI_PRESENT_TEST) == DXGI_STATUS_OCCLUDED)
|
|
||||||
{
|
|
||||||
::Sleep(10);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
g_SwapChainOccluded = false;
|
|
||||||
|
|
||||||
// Handle window resize (we don't resize directly in the WM_SIZE handler)
|
// Handle window resize (we don't resize directly in the WM_SIZE handler)
|
||||||
if (g_ResizeWidth != 0 && g_ResizeHeight != 0)
|
if (g_ResizeWidth != 0 && g_ResizeHeight != 0)
|
||||||
{
|
{
|
||||||
@ -167,13 +158,10 @@ int main(int, char**)
|
|||||||
g_pd3dDevice->ClearRenderTargetView(g_mainRenderTargetView, clear_color_with_alpha);
|
g_pd3dDevice->ClearRenderTargetView(g_mainRenderTargetView, clear_color_with_alpha);
|
||||||
ImGui_ImplDX10_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplDX10_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
|
||||||
// Present
|
g_pSwapChain->Present(1, 0); // Present with vsync
|
||||||
HRESULT hr = g_pSwapChain->Present(1, 0); // Present with vsync
|
//g_pSwapChain->Present(0, 0); // Present without vsync
|
||||||
//HRESULT hr = g_pSwapChain->Present(0, 0); // Present without vsync
|
|
||||||
g_SwapChainOccluded = (hr == DXGI_STATUS_OCCLUDED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup
|
|
||||||
ImGui_ImplDX10_Shutdown();
|
ImGui_ImplDX10_Shutdown();
|
||||||
ImGui_ImplWin32_Shutdown();
|
ImGui_ImplWin32_Shutdown();
|
||||||
ImGui::DestroyContext();
|
ImGui::DestroyContext();
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
static ID3D11Device* g_pd3dDevice = nullptr;
|
static ID3D11Device* g_pd3dDevice = nullptr;
|
||||||
static ID3D11DeviceContext* g_pd3dDeviceContext = nullptr;
|
static ID3D11DeviceContext* g_pd3dDeviceContext = nullptr;
|
||||||
static IDXGISwapChain* g_pSwapChain = nullptr;
|
static IDXGISwapChain* g_pSwapChain = nullptr;
|
||||||
static bool g_SwapChainOccluded = false;
|
|
||||||
static UINT g_ResizeWidth = 0, g_ResizeHeight = 0;
|
static UINT g_ResizeWidth = 0, g_ResizeHeight = 0;
|
||||||
static ID3D11RenderTargetView* g_mainRenderTargetView = nullptr;
|
static ID3D11RenderTargetView* g_mainRenderTargetView = nullptr;
|
||||||
|
|
||||||
@ -101,14 +100,6 @@ int main(int, char**)
|
|||||||
if (done)
|
if (done)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Handle window being minimized or screen locked
|
|
||||||
if (g_SwapChainOccluded && g_pSwapChain->Present(0, DXGI_PRESENT_TEST) == DXGI_STATUS_OCCLUDED)
|
|
||||||
{
|
|
||||||
::Sleep(10);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
g_SwapChainOccluded = false;
|
|
||||||
|
|
||||||
// Handle window resize (we don't resize directly in the WM_SIZE handler)
|
// Handle window resize (we don't resize directly in the WM_SIZE handler)
|
||||||
if (g_ResizeWidth != 0 && g_ResizeHeight != 0)
|
if (g_ResizeWidth != 0 && g_ResizeHeight != 0)
|
||||||
{
|
{
|
||||||
@ -167,10 +158,8 @@ int main(int, char**)
|
|||||||
g_pd3dDeviceContext->ClearRenderTargetView(g_mainRenderTargetView, clear_color_with_alpha);
|
g_pd3dDeviceContext->ClearRenderTargetView(g_mainRenderTargetView, clear_color_with_alpha);
|
||||||
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
|
||||||
// Present
|
g_pSwapChain->Present(1, 0); // Present with vsync
|
||||||
HRESULT hr = g_pSwapChain->Present(1, 0); // Present with vsync
|
//g_pSwapChain->Present(0, 0); // Present without vsync
|
||||||
//HRESULT hr = g_pSwapChain->Present(0, 0); // Present without vsync
|
|
||||||
g_SwapChainOccluded = (hr == DXGI_STATUS_OCCLUDED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
|
@ -26,8 +26,6 @@
|
|||||||
#pragma comment(lib, "dxguid.lib")
|
#pragma comment(lib, "dxguid.lib")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "imgui_internal.h"
|
|
||||||
|
|
||||||
struct FrameContext
|
struct FrameContext
|
||||||
{
|
{
|
||||||
ID3D12CommandAllocator* CommandAllocator;
|
ID3D12CommandAllocator* CommandAllocator;
|
||||||
@ -49,7 +47,6 @@ static ID3D12Fence* g_fence = nullptr;
|
|||||||
static HANDLE g_fenceEvent = nullptr;
|
static HANDLE g_fenceEvent = nullptr;
|
||||||
static UINT64 g_fenceLastSignaledValue = 0;
|
static UINT64 g_fenceLastSignaledValue = 0;
|
||||||
static IDXGISwapChain3* g_pSwapChain = nullptr;
|
static IDXGISwapChain3* g_pSwapChain = nullptr;
|
||||||
static bool g_SwapChainOccluded = false;
|
|
||||||
static HANDLE g_hSwapChainWaitableObject = nullptr;
|
static HANDLE g_hSwapChainWaitableObject = nullptr;
|
||||||
static ID3D12Resource* g_mainRenderTargetResource[NUM_BACK_BUFFERS] = {};
|
static ID3D12Resource* g_mainRenderTargetResource[NUM_BACK_BUFFERS] = {};
|
||||||
static D3D12_CPU_DESCRIPTOR_HANDLE g_mainRenderTargetDescriptor[NUM_BACK_BUFFERS] = {};
|
static D3D12_CPU_DESCRIPTOR_HANDLE g_mainRenderTargetDescriptor[NUM_BACK_BUFFERS] = {};
|
||||||
@ -140,14 +137,6 @@ int main(int, char**)
|
|||||||
if (done)
|
if (done)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Handle window screen locked
|
|
||||||
if (g_SwapChainOccluded && g_pSwapChain->Present(0, DXGI_PRESENT_TEST) == DXGI_STATUS_OCCLUDED)
|
|
||||||
{
|
|
||||||
::Sleep(10);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
g_SwapChainOccluded = false;
|
|
||||||
|
|
||||||
// Start the Dear ImGui frame
|
// Start the Dear ImGui frame
|
||||||
ImGui_ImplDX12_NewFrame();
|
ImGui_ImplDX12_NewFrame();
|
||||||
ImGui_ImplWin32_NewFrame();
|
ImGui_ImplWin32_NewFrame();
|
||||||
@ -220,10 +209,8 @@ int main(int, char**)
|
|||||||
|
|
||||||
g_pd3dCommandQueue->ExecuteCommandLists(1, (ID3D12CommandList* const*)&g_pd3dCommandList);
|
g_pd3dCommandQueue->ExecuteCommandLists(1, (ID3D12CommandList* const*)&g_pd3dCommandList);
|
||||||
|
|
||||||
// Present
|
g_pSwapChain->Present(1, 0); // Present with vsync
|
||||||
HRESULT hr = g_pSwapChain->Present(1, 0); // Present with vsync
|
//g_pSwapChain->Present(0, 0); // Present without vsync
|
||||||
//HRESULT hr = g_pSwapChain->Present(0, 0); // Present without vsync
|
|
||||||
g_SwapChainOccluded = (hr == DXGI_STATUS_OCCLUDED);
|
|
||||||
|
|
||||||
UINT64 fenceValue = g_fenceLastSignaledValue + 1;
|
UINT64 fenceValue = g_fenceLastSignaledValue + 1;
|
||||||
g_pd3dCommandQueue->Signal(g_fence, fenceValue);
|
g_pd3dCommandQueue->Signal(g_fence, fenceValue);
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
// Data
|
// Data
|
||||||
static LPDIRECT3D9 g_pD3D = nullptr;
|
static LPDIRECT3D9 g_pD3D = nullptr;
|
||||||
static LPDIRECT3DDEVICE9 g_pd3dDevice = nullptr;
|
static LPDIRECT3DDEVICE9 g_pd3dDevice = nullptr;
|
||||||
static bool g_DeviceLost = false;
|
|
||||||
static UINT g_ResizeWidth = 0, g_ResizeHeight = 0;
|
static UINT g_ResizeWidth = 0, g_ResizeHeight = 0;
|
||||||
static D3DPRESENT_PARAMETERS g_d3dpp = {};
|
static D3DPRESENT_PARAMETERS g_d3dpp = {};
|
||||||
|
|
||||||
@ -99,20 +98,6 @@ int main(int, char**)
|
|||||||
if (done)
|
if (done)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Handle lost D3D9 device
|
|
||||||
if (g_DeviceLost)
|
|
||||||
{
|
|
||||||
HRESULT hr = g_pd3dDevice->TestCooperativeLevel();
|
|
||||||
if (hr == D3DERR_DEVICELOST)
|
|
||||||
{
|
|
||||||
::Sleep(10);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (hr == D3DERR_DEVICENOTRESET)
|
|
||||||
ResetDevice();
|
|
||||||
g_DeviceLost = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle window resize (we don't resize directly in the WM_SIZE handler)
|
// Handle window resize (we don't resize directly in the WM_SIZE handler)
|
||||||
if (g_ResizeWidth != 0 && g_ResizeHeight != 0)
|
if (g_ResizeWidth != 0 && g_ResizeHeight != 0)
|
||||||
{
|
{
|
||||||
@ -178,11 +163,12 @@ int main(int, char**)
|
|||||||
g_pd3dDevice->EndScene();
|
g_pd3dDevice->EndScene();
|
||||||
}
|
}
|
||||||
HRESULT result = g_pd3dDevice->Present(nullptr, nullptr, nullptr, nullptr);
|
HRESULT result = g_pd3dDevice->Present(nullptr, nullptr, nullptr, nullptr);
|
||||||
if (result == D3DERR_DEVICELOST)
|
|
||||||
g_DeviceLost = true;
|
// Handle loss of D3D9 device
|
||||||
|
if (result == D3DERR_DEVICELOST && g_pd3dDevice->TestCooperativeLevel() == D3DERR_DEVICENOTRESET)
|
||||||
|
ResetDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup
|
|
||||||
ImGui_ImplDX9_Shutdown();
|
ImGui_ImplDX9_Shutdown();
|
||||||
ImGui_ImplWin32_Shutdown();
|
ImGui_ImplWin32_Shutdown();
|
||||||
ImGui::DestroyContext();
|
ImGui::DestroyContext();
|
||||||
|
@ -200,7 +200,7 @@ typedef void (*uSynergySleepFunc)(uSynergyCookie cookie, int timeMs);
|
|||||||
@brief Get time function
|
@brief Get time function
|
||||||
|
|
||||||
This function is called when uSynergy needs to know the current time. This is used to determine when timeouts
|
This function is called when uSynergy needs to know the current time. This is used to determine when timeouts
|
||||||
have occurred. The time base should be a cyclic millisecond time value.
|
have occured. The time base should be a cyclic millisecond time value.
|
||||||
|
|
||||||
@returns Time value in milliseconds
|
@returns Time value in milliseconds
|
||||||
**/
|
**/
|
||||||
|
1418
external/imgui/imgui/imgui.cpp
vendored
1418
external/imgui/imgui/imgui.cpp
vendored
File diff suppressed because it is too large
Load Diff
233
external/imgui/imgui/imgui.h
vendored
233
external/imgui/imgui/imgui.h
vendored
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.90.7
|
// dear imgui, v1.90.1
|
||||||
// (headers)
|
// (headers)
|
||||||
|
|
||||||
// Help:
|
// Help:
|
||||||
@ -7,19 +7,15 @@
|
|||||||
// - Read top of imgui.cpp for more details, links and comments.
|
// - Read top of imgui.cpp for more details, links and comments.
|
||||||
|
|
||||||
// Resources:
|
// Resources:
|
||||||
// - FAQ ........................ https://dearimgui.com/faq (in repository as docs/FAQ.md)
|
// - FAQ https://dearimgui.com/faq
|
||||||
// - Homepage ................... https://github.com/ocornut/imgui
|
// - Getting Started https://dearimgui.com/getting-started
|
||||||
// - Releases & changelog ....... https://github.com/ocornut/imgui/releases
|
// - Homepage https://github.com/ocornut/imgui
|
||||||
// - Gallery .................... https://github.com/ocornut/imgui/issues/7503 (please post your screenshots/video there!)
|
// - Releases & changelog https://github.com/ocornut/imgui/releases
|
||||||
// - Wiki ....................... https://github.com/ocornut/imgui/wiki (lots of good stuff there)
|
// - Gallery https://github.com/ocornut/imgui/issues/6897 (please post your screenshots/video there!)
|
||||||
// - Getting Started https://github.com/ocornut/imgui/wiki/Getting-Started (how to integrate in an existing app by adding ~25 lines of code)
|
// - Wiki https://github.com/ocornut/imgui/wiki (lots of good stuff there)
|
||||||
// - Third-party Extensions https://github.com/ocornut/imgui/wiki/Useful-Extensions (ImPlot & many more)
|
|
||||||
// - Bindings/Backends https://github.com/ocornut/imgui/wiki/Bindings (language bindings, backends for various tech/engines)
|
|
||||||
// - Glossary https://github.com/ocornut/imgui/wiki/Glossary
|
// - Glossary https://github.com/ocornut/imgui/wiki/Glossary
|
||||||
// - Debug Tools https://github.com/ocornut/imgui/wiki/Debug-Tools
|
// - Issues & support https://github.com/ocornut/imgui/issues
|
||||||
// - Software using Dear ImGui https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui
|
// - Tests & Automation https://github.com/ocornut/imgui_test_engine
|
||||||
// - Issues & support ........... https://github.com/ocornut/imgui/issues
|
|
||||||
// - Test Engine & Automation ... https://github.com/ocornut/imgui_test_engine (test suite, test engine to automate your apps)
|
|
||||||
|
|
||||||
// For first-time users having issues compiling/linking/running/loading fonts:
|
// For first-time users having issues compiling/linking/running/loading fonts:
|
||||||
// please post in https://github.com/ocornut/imgui/discussions if you cannot find a solution in resources above.
|
// please post in https://github.com/ocornut/imgui/discussions if you cannot find a solution in resources above.
|
||||||
@ -27,8 +23,8 @@
|
|||||||
|
|
||||||
// Library Version
|
// Library Version
|
||||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
|
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
|
||||||
#define IMGUI_VERSION "1.90.7"
|
#define IMGUI_VERSION "1.90.1"
|
||||||
#define IMGUI_VERSION_NUM 19070
|
#define IMGUI_VERSION_NUM 19010
|
||||||
#define IMGUI_HAS_TABLE
|
#define IMGUI_HAS_TABLE
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -90,13 +86,9 @@ Index of this file:
|
|||||||
#endif
|
#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.
|
#define IM_UNUSED(_VAR) ((void)(_VAR)) // Used to silence "unused variable warnings". Often useful as asserts may be stripped out from final builds.
|
||||||
|
|
||||||
// Check that version and structures layouts are matching between compiled imgui code and caller. Read comments above DebugCheckVersionAndDataLayout() for details.
|
|
||||||
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
|
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
|
||||||
|
|
||||||
// Helper Macros - IM_FMTARGS, IM_FMTLIST: Apply printf-style warnings to our formatting functions.
|
// Helper Macros - IM_FMTARGS, IM_FMTLIST: Apply printf-style warnings to our formatting functions.
|
||||||
// (MSVC provides an equivalent mechanism via SAL Annotations but it would require the macros in a different
|
|
||||||
// location. e.g. #include <sal.h> + void myprintf(_Printf_format_string_ const char* format, ...))
|
|
||||||
#if !defined(IMGUI_USE_STB_SPRINTF) && defined(__MINGW32__) && !defined(__clang__)
|
#if !defined(IMGUI_USE_STB_SPRINTF) && defined(__MINGW32__) && !defined(__clang__)
|
||||||
#define IM_FMTARGS(FMT) __attribute__((format(gnu_printf, FMT, FMT+1)))
|
#define IM_FMTARGS(FMT) __attribute__((format(gnu_printf, FMT, FMT+1)))
|
||||||
#define IM_FMTLIST(FMT) __attribute__((format(gnu_printf, FMT, 0)))
|
#define IM_FMTLIST(FMT) __attribute__((format(gnu_printf, FMT, 0)))
|
||||||
@ -132,7 +124,6 @@ Index of this file:
|
|||||||
#pragma clang diagnostic ignored "-Wfloat-equal" // warning: comparing floating point with == or != is unsafe
|
#pragma clang diagnostic ignored "-Wfloat-equal" // warning: comparing floating point with == or != is unsafe
|
||||||
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
|
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
|
||||||
#pragma clang diagnostic ignored "-Wreserved-identifier" // warning: identifier '_Xxx' is reserved because it starts with '_' followed by a capital letter
|
#pragma clang diagnostic ignored "-Wreserved-identifier" // warning: identifier '_Xxx' is reserved because it starts with '_' followed by a capital letter
|
||||||
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" // warning: 'xxx' is an unsafe pointer used for buffer access
|
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
||||||
@ -178,9 +169,8 @@ struct ImGuiViewport; // A Platform Window (always only one in 'ma
|
|||||||
// Enumerations
|
// Enumerations
|
||||||
// - We don't use strongly typed enums much because they add constraints (can't extend in private code, can't store typed in bit fields, extra casting on iteration)
|
// - We don't use strongly typed enums much because they add constraints (can't extend in private code, can't store typed in bit fields, extra casting on iteration)
|
||||||
// - Tip: Use your programming IDE navigation facilities on the names in the _central column_ below to find the actual flags/enum lists!
|
// - Tip: Use your programming IDE navigation facilities on the names in the _central column_ below to find the actual flags/enum lists!
|
||||||
// - In Visual Studio: CTRL+comma ("Edit.GoToAll") can follow symbols inside comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot.
|
// In Visual Studio IDE: CTRL+comma ("Edit.GoToAll") can follow symbols in comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot.
|
||||||
// - In Visual Studio w/ Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols inside comments.
|
// With Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols in comments.
|
||||||
// - In VS Code, CLion, etc.: CTRL+click can follow symbols inside comments.
|
|
||||||
enum ImGuiKey : int; // -> enum ImGuiKey // Enum: A key identifier (ImGuiKey_XXX or ImGuiMod_XXX value)
|
enum ImGuiKey : int; // -> enum ImGuiKey // Enum: A key identifier (ImGuiKey_XXX or ImGuiMod_XXX value)
|
||||||
enum ImGuiMouseSource : int; // -> enum ImGuiMouseSource // Enum; A mouse input source identifier (Mouse, TouchScreen, Pen)
|
enum ImGuiMouseSource : int; // -> enum ImGuiMouseSource // Enum; A mouse input source identifier (Mouse, TouchScreen, Pen)
|
||||||
typedef int ImGuiCol; // -> enum ImGuiCol_ // Enum: A color identifier for styling
|
typedef int ImGuiCol; // -> enum ImGuiCol_ // Enum: A color identifier for styling
|
||||||
@ -195,9 +185,8 @@ typedef int ImGuiTableBgTarget; // -> enum ImGuiTableBgTarget_ // Enum: A
|
|||||||
|
|
||||||
// Flags (declared as int to allow using as flags without overhead, and to not pollute the top of this file)
|
// Flags (declared as int to allow using as flags without overhead, and to not pollute the top of this file)
|
||||||
// - Tip: Use your programming IDE navigation facilities on the names in the _central column_ below to find the actual flags/enum lists!
|
// - Tip: Use your programming IDE navigation facilities on the names in the _central column_ below to find the actual flags/enum lists!
|
||||||
// - In Visual Studio: CTRL+comma ("Edit.GoToAll") can follow symbols inside comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot.
|
// In Visual Studio IDE: CTRL+comma ("Edit.GoToAll") can follow symbols in comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot.
|
||||||
// - In Visual Studio w/ Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols inside comments.
|
// With Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols in comments.
|
||||||
// - In VS Code, CLion, etc.: CTRL+click can follow symbols inside comments.
|
|
||||||
typedef int ImDrawFlags; // -> enum ImDrawFlags_ // Flags: for ImDrawList functions
|
typedef int ImDrawFlags; // -> enum ImDrawFlags_ // Flags: for ImDrawList functions
|
||||||
typedef int ImDrawListFlags; // -> enum ImDrawListFlags_ // Flags: for ImDrawList instance
|
typedef int ImDrawListFlags; // -> enum ImDrawListFlags_ // Flags: for ImDrawList instance
|
||||||
typedef int ImFontAtlasFlags; // -> enum ImFontAtlasFlags_ // Flags: for ImFontAtlas build
|
typedef int ImFontAtlasFlags; // -> enum ImFontAtlasFlags_ // Flags: for ImFontAtlas build
|
||||||
@ -210,7 +199,6 @@ typedef int ImGuiComboFlags; // -> enum ImGuiComboFlags_ // Flags: f
|
|||||||
typedef int ImGuiDragDropFlags; // -> enum ImGuiDragDropFlags_ // Flags: for BeginDragDropSource(), AcceptDragDropPayload()
|
typedef int ImGuiDragDropFlags; // -> enum ImGuiDragDropFlags_ // Flags: for BeginDragDropSource(), AcceptDragDropPayload()
|
||||||
typedef int ImGuiFocusedFlags; // -> enum ImGuiFocusedFlags_ // Flags: for IsWindowFocused()
|
typedef int ImGuiFocusedFlags; // -> enum ImGuiFocusedFlags_ // Flags: for IsWindowFocused()
|
||||||
typedef int ImGuiHoveredFlags; // -> enum ImGuiHoveredFlags_ // Flags: for IsItemHovered(), IsWindowHovered() etc.
|
typedef int ImGuiHoveredFlags; // -> enum ImGuiHoveredFlags_ // Flags: for IsItemHovered(), IsWindowHovered() etc.
|
||||||
typedef int ImGuiInputFlags; // -> enum ImGuiInputFlags_ // Flags: for Shortcut(), SetNextItemShortcut()
|
|
||||||
typedef int ImGuiInputTextFlags; // -> enum ImGuiInputTextFlags_ // Flags: for InputText(), InputTextMultiline()
|
typedef int ImGuiInputTextFlags; // -> enum ImGuiInputTextFlags_ // Flags: for InputText(), InputTextMultiline()
|
||||||
typedef int ImGuiKeyChord; // -> ImGuiKey | ImGuiMod_XXX // Flags: for IsKeyChordPressed(), Shortcut() etc. an ImGuiKey optionally OR-ed with one or more ImGuiMod_XXX values.
|
typedef int ImGuiKeyChord; // -> ImGuiKey | ImGuiMod_XXX // Flags: for IsKeyChordPressed(), Shortcut() etc. an ImGuiKey optionally OR-ed with one or more ImGuiMod_XXX values.
|
||||||
typedef int ImGuiPopupFlags; // -> enum ImGuiPopupFlags_ // Flags: for OpenPopup*(), BeginPopupContext*(), IsPopupOpen()
|
typedef int ImGuiPopupFlags; // -> enum ImGuiPopupFlags_ // Flags: for OpenPopup*(), BeginPopupContext*(), IsPopupOpen()
|
||||||
@ -354,7 +342,7 @@ 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.
|
// - Use child windows to begin into a self-contained independent scrolling/clipping regions within a host window. Child windows can embed their own child.
|
||||||
// - Before 1.90 (November 2023), the "ImGuiChildFlags child_flags = 0" parameter was "bool border = false".
|
// - Before 1.90 (November 2023), the "ImGuiChildFlags child_flags = 0" parameter was "bool border = false".
|
||||||
// This API is backward compatible with old code, as we guarantee that ImGuiChildFlags_Border == true.
|
// This API is backward compatible with old code, as we guarantee that ImGuiChildFlags_Border == true.
|
||||||
// Consider updating your old code:
|
// Consider updating your old call sites:
|
||||||
// BeginChild("Name", size, false) -> Begin("Name", size, 0); or Begin("Name", size, ImGuiChildFlags_None);
|
// BeginChild("Name", size, false) -> Begin("Name", size, 0); or Begin("Name", size, ImGuiChildFlags_None);
|
||||||
// BeginChild("Name", size, true) -> Begin("Name", size, ImGuiChildFlags_Border);
|
// BeginChild("Name", size, true) -> Begin("Name", size, ImGuiChildFlags_Border);
|
||||||
// - Manual sizing (each axis can use a different setting e.g. ImVec2(0.0f, 400.0f)):
|
// - Manual sizing (each axis can use a different setting e.g. ImVec2(0.0f, 400.0f)):
|
||||||
@ -455,7 +443,7 @@ namespace ImGui
|
|||||||
IMGUI_API ImVec2 GetFontTexUvWhitePixel(); // get UV coordinate for a while pixel, useful to draw custom shapes via the ImDrawList API
|
IMGUI_API ImVec2 GetFontTexUvWhitePixel(); // get UV coordinate for a while pixel, useful to draw custom shapes via the ImDrawList API
|
||||||
IMGUI_API ImU32 GetColorU32(ImGuiCol idx, float alpha_mul = 1.0f); // retrieve given style color with style alpha applied and optional extra alpha multiplier, packed as a 32-bit value suitable for ImDrawList
|
IMGUI_API ImU32 GetColorU32(ImGuiCol idx, float alpha_mul = 1.0f); // retrieve given style color with style alpha applied and optional extra alpha multiplier, packed as a 32-bit value suitable for ImDrawList
|
||||||
IMGUI_API ImU32 GetColorU32(const ImVec4& col); // retrieve given color with style alpha applied, packed as a 32-bit value suitable for ImDrawList
|
IMGUI_API ImU32 GetColorU32(const ImVec4& col); // retrieve given color with style alpha applied, packed as a 32-bit value suitable for ImDrawList
|
||||||
IMGUI_API ImU32 GetColorU32(ImU32 col, float alpha_mul = 1.0f); // retrieve given color with style alpha applied, packed as a 32-bit value suitable for ImDrawList
|
IMGUI_API ImU32 GetColorU32(ImU32 col); // retrieve given color with style alpha applied, packed as a 32-bit value suitable for ImDrawList
|
||||||
IMGUI_API const ImVec4& GetStyleColorVec4(ImGuiCol idx); // retrieve style color as stored in ImGuiStyle structure. use to feed back into PushStyleColor(), otherwise use GetColorU32() to get style color with style alpha baked in.
|
IMGUI_API const ImVec4& GetStyleColorVec4(ImGuiCol idx); // retrieve style color as stored in ImGuiStyle structure. use to feed back into PushStyleColor(), otherwise use GetColorU32() to get style color with style alpha baked in.
|
||||||
|
|
||||||
// Layout cursor positioning
|
// Layout cursor positioning
|
||||||
@ -700,8 +688,7 @@ namespace ImGui
|
|||||||
|
|
||||||
// Tooltips
|
// Tooltips
|
||||||
// - Tooltips are windows following the mouse. They do not take focus away.
|
// - Tooltips are windows following the mouse. They do not take focus away.
|
||||||
// - A tooltip window can contain items of any types.
|
// - A tooltip window can contain items of any types. SetTooltip() is a shortcut for the 'if (BeginTooltip()) { Text(...); EndTooltip(); }' idiom.
|
||||||
// - SetTooltip() is more or less a shortcut for the 'if (BeginTooltip()) { Text(...); EndTooltip(); }' idiom (with a subtlety that it discard any previously submitted tooltip)
|
|
||||||
IMGUI_API bool BeginTooltip(); // begin/append a tooltip window.
|
IMGUI_API bool BeginTooltip(); // begin/append a tooltip window.
|
||||||
IMGUI_API void EndTooltip(); // only call EndTooltip() if BeginTooltip()/BeginItemTooltip() returns true!
|
IMGUI_API void EndTooltip(); // only call EndTooltip() if BeginTooltip()/BeginItemTooltip() returns true!
|
||||||
IMGUI_API void SetTooltip(const char* fmt, ...) IM_FMTARGS(1); // set a text-only tooltip. Often used after a ImGui::IsItemHovered() check. Override any previous call to SetTooltip().
|
IMGUI_API void SetTooltip(const char* fmt, ...) IM_FMTARGS(1); // set a text-only tooltip. Often used after a ImGui::IsItemHovered() check. Override any previous call to SetTooltip().
|
||||||
@ -712,7 +699,7 @@ namespace ImGui
|
|||||||
// - SetItemTooltip() is a shortcut for the 'if (IsItemHovered(ImGuiHoveredFlags_ForTooltip)) { SetTooltip(...); }' idiom.
|
// - SetItemTooltip() is a shortcut for the 'if (IsItemHovered(ImGuiHoveredFlags_ForTooltip)) { SetTooltip(...); }' idiom.
|
||||||
// - Where 'ImGuiHoveredFlags_ForTooltip' itself is a shortcut to use 'style.HoverFlagsForTooltipMouse' or 'style.HoverFlagsForTooltipNav' depending on active input type. For mouse it defaults to 'ImGuiHoveredFlags_Stationary | ImGuiHoveredFlags_DelayShort'.
|
// - Where 'ImGuiHoveredFlags_ForTooltip' itself is a shortcut to use 'style.HoverFlagsForTooltipMouse' or 'style.HoverFlagsForTooltipNav' depending on active input type. For mouse it defaults to 'ImGuiHoveredFlags_Stationary | ImGuiHoveredFlags_DelayShort'.
|
||||||
IMGUI_API bool BeginItemTooltip(); // begin/append a tooltip window if preceding item was hovered.
|
IMGUI_API bool BeginItemTooltip(); // begin/append a tooltip window if preceding item was hovered.
|
||||||
IMGUI_API void SetItemTooltip(const char* fmt, ...) IM_FMTARGS(1); // set a text-only tooltip if preceding item was hovered. override any previous call to SetTooltip().
|
IMGUI_API void SetItemTooltip(const char* fmt, ...) IM_FMTARGS(1); // set a text-only tooltip if preceeding item was hovered. override any previous call to SetTooltip().
|
||||||
IMGUI_API void SetItemTooltipV(const char* fmt, va_list args) IM_FMTLIST(1);
|
IMGUI_API void SetItemTooltipV(const char* fmt, va_list args) IM_FMTLIST(1);
|
||||||
|
|
||||||
// Popups, Modals
|
// Popups, Modals
|
||||||
@ -939,24 +926,6 @@ namespace ImGui
|
|||||||
IMGUI_API const char* GetKeyName(ImGuiKey key); // [DEBUG] returns English name of the key. Those names a provided for debugging purpose and are not meant to be saved persistently not compared.
|
IMGUI_API const char* GetKeyName(ImGuiKey key); // [DEBUG] returns English name of the key. Those names a provided for debugging purpose and are not meant to be saved persistently not compared.
|
||||||
IMGUI_API void SetNextFrameWantCaptureKeyboard(bool want_capture_keyboard); // Override io.WantCaptureKeyboard flag next frame (said flag is left for your application to handle, typically when true it instructs your app to ignore inputs). e.g. force capture keyboard when your widget is being hovered. This is equivalent to setting "io.WantCaptureKeyboard = want_capture_keyboard"; after the next NewFrame() call.
|
IMGUI_API void SetNextFrameWantCaptureKeyboard(bool want_capture_keyboard); // Override io.WantCaptureKeyboard flag next frame (said flag is left for your application to handle, typically when true it instructs your app to ignore inputs). e.g. force capture keyboard when your widget is being hovered. This is equivalent to setting "io.WantCaptureKeyboard = want_capture_keyboard"; after the next NewFrame() call.
|
||||||
|
|
||||||
// Inputs Utilities: Shortcut Testing & Routing [BETA]
|
|
||||||
// - ImGuiKeyChord = a ImGuiKey + optional ImGuiMod_Alt/ImGuiMod_Ctrl/ImGuiMod_Shift/ImGuiMod_Super.
|
|
||||||
// ImGuiKey_C // Accepted by functions taking ImGuiKey or ImGuiKeyChord arguments)
|
|
||||||
// ImGuiMod_Ctrl | ImGuiKey_C // Accepted by functions taking ImGuiKeyChord arguments)
|
|
||||||
// only ImGuiMod_XXX values are legal to combine with an ImGuiKey. You CANNOT combine two ImGuiKey values.
|
|
||||||
// - The general idea is that several callers may register interest in a shortcut, and only one owner gets it.
|
|
||||||
// Parent -> call Shortcut(Ctrl+S) // When Parent is focused, Parent gets the shortcut.
|
|
||||||
// Child1 -> call Shortcut(Ctrl+S) // When Child1 is focused, Child1 gets the shortcut (Child1 overrides Parent shortcuts)
|
|
||||||
// Child2 -> no call // When Child2 is focused, Parent gets the shortcut.
|
|
||||||
// The whole system is order independent, so if Child1 makes its calls before Parent, results will be identical.
|
|
||||||
// This is an important property as it facilitate working with foreign code or larger codebase.
|
|
||||||
// - To understand the difference:
|
|
||||||
// - IsKeyChordPressed() compares mods and call IsKeyPressed() -> function has no side-effect.
|
|
||||||
// - Shortcut() submits a route, routes are resolved, if it currently can be routed it calls IsKeyChordPressed() -> function has (desirable) side-effects as it can prevents another call from getting the route.
|
|
||||||
// - Visualize registered routes in 'Metrics/Debugger->Inputs'.
|
|
||||||
IMGUI_API bool Shortcut(ImGuiKeyChord key_chord, ImGuiInputFlags flags = 0);
|
|
||||||
IMGUI_API void SetNextItemShortcut(ImGuiKeyChord key_chord, ImGuiInputFlags flags = 0);
|
|
||||||
|
|
||||||
// Inputs Utilities: Mouse specific
|
// Inputs Utilities: Mouse specific
|
||||||
// - To refer to a mouse button, you may use named enums in your code e.g. ImGuiMouseButton_Left, ImGuiMouseButton_Right.
|
// - To refer to a mouse button, you may use named enums in your code e.g. ImGuiMouseButton_Left, ImGuiMouseButton_Right.
|
||||||
// - You can also use regular integer: it is forever guaranteed that 0=Left, 1=Right, 2=Middle.
|
// - You can also use regular integer: it is forever guaranteed that 0=Left, 1=Right, 2=Middle.
|
||||||
@ -971,8 +940,8 @@ namespace ImGui
|
|||||||
IMGUI_API bool IsAnyMouseDown(); // [WILL OBSOLETE] is any mouse button held? This was designed for backends, but prefer having backend maintain a mask of held mouse buttons, because upcoming input queue system will make this invalid.
|
IMGUI_API bool IsAnyMouseDown(); // [WILL OBSOLETE] is any mouse button held? This was designed for backends, but prefer having backend maintain a mask of held mouse buttons, because upcoming input queue system will make this invalid.
|
||||||
IMGUI_API ImVec2 GetMousePos(); // shortcut to ImGui::GetIO().MousePos provided by user, to be consistent with other calls
|
IMGUI_API ImVec2 GetMousePos(); // shortcut to ImGui::GetIO().MousePos provided by user, to be consistent with other calls
|
||||||
IMGUI_API ImVec2 GetMousePosOnOpeningCurrentPopup(); // retrieve mouse position at the time of opening popup we have BeginPopup() into (helper to avoid user backing that value themselves)
|
IMGUI_API ImVec2 GetMousePosOnOpeningCurrentPopup(); // retrieve mouse position at the time of opening popup we have BeginPopup() into (helper to avoid user backing that value themselves)
|
||||||
IMGUI_API bool IsMouseDragging(ImGuiMouseButton button, float lock_threshold = -1.0f); // is mouse dragging? (uses io.MouseDraggingThreshold if lock_threshold < 0.0f)
|
IMGUI_API bool IsMouseDragging(ImGuiMouseButton button, float lock_threshold = -1.0f); // is mouse dragging? (if lock_threshold < -1.0f, uses io.MouseDraggingThreshold)
|
||||||
IMGUI_API ImVec2 GetMouseDragDelta(ImGuiMouseButton button = 0, float lock_threshold = -1.0f); // return the delta from the initial clicking position while the mouse button is pressed or was just released. This is locked and return 0.0f until the mouse moves past a distance threshold at least once (uses io.MouseDraggingThreshold if lock_threshold < 0.0f)
|
IMGUI_API ImVec2 GetMouseDragDelta(ImGuiMouseButton button = 0, float lock_threshold = -1.0f); // return the delta from the initial clicking position while the mouse button is pressed or was just released. This is locked and return 0.0f until the mouse moves past a distance threshold at least once (if lock_threshold < -1.0f, uses io.MouseDraggingThreshold)
|
||||||
IMGUI_API void ResetMouseDragDelta(ImGuiMouseButton button = 0); //
|
IMGUI_API void ResetMouseDragDelta(ImGuiMouseButton button = 0); //
|
||||||
IMGUI_API ImGuiMouseCursor GetMouseCursor(); // get desired mouse cursor shape. Important: reset in ImGui::NewFrame(), this is updated during the frame. valid before Render(). If you use software rendering by setting io.MouseDrawCursor ImGui will render those for you
|
IMGUI_API ImGuiMouseCursor GetMouseCursor(); // get desired mouse cursor shape. Important: reset in ImGui::NewFrame(), this is updated during the frame. valid before Render(). If you use software rendering by setting io.MouseDrawCursor ImGui will render those for you
|
||||||
IMGUI_API void SetMouseCursor(ImGuiMouseCursor cursor_type); // set desired mouse cursor shape
|
IMGUI_API void SetMouseCursor(ImGuiMouseCursor cursor_type); // set desired mouse cursor shape
|
||||||
@ -996,7 +965,6 @@ namespace ImGui
|
|||||||
// - Your main debugging friend is the ShowMetricsWindow() function, which is also accessible from Demo->Tools->Metrics Debugger
|
// - Your main debugging friend is the ShowMetricsWindow() function, which is also accessible from Demo->Tools->Metrics Debugger
|
||||||
IMGUI_API void DebugTextEncoding(const char* text);
|
IMGUI_API void DebugTextEncoding(const char* text);
|
||||||
IMGUI_API void DebugFlashStyleColor(ImGuiCol idx);
|
IMGUI_API void DebugFlashStyleColor(ImGuiCol idx);
|
||||||
IMGUI_API void DebugStartItemPicker();
|
|
||||||
IMGUI_API bool DebugCheckVersionAndDataLayout(const char* version_str, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_drawvert, size_t sz_drawidx); // This is called by IMGUI_CHECKVERSION() macro.
|
IMGUI_API bool DebugCheckVersionAndDataLayout(const char* version_str, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_drawvert, size_t sz_drawidx); // This is called by IMGUI_CHECKVERSION() macro.
|
||||||
|
|
||||||
// Memory Allocators
|
// Memory Allocators
|
||||||
@ -1057,7 +1025,7 @@ enum ImGuiWindowFlags_
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Flags for ImGui::BeginChild()
|
// Flags for ImGui::BeginChild()
|
||||||
// (Legacy: bit 0 must always correspond to ImGuiChildFlags_Border to be backward compatible with old API using 'bool border = false'.
|
// (Legacy: bot 0 must always correspond to ImGuiChildFlags_Border to be backward compatible with old API using 'bool border = false'.
|
||||||
// About using AutoResizeX/AutoResizeY flags:
|
// About using AutoResizeX/AutoResizeY flags:
|
||||||
// - May be combined with SetNextWindowSizeConstraints() to set a min/max size for each axis (see "Demo->Child->Auto-resize with Constraints").
|
// - May be combined with SetNextWindowSizeConstraints() to set a min/max size for each axis (see "Demo->Child->Auto-resize with Constraints").
|
||||||
// - Size measurement for a given axis is only performed when the child window is within visible boundaries, or is just appearing.
|
// - Size measurement for a given axis is only performed when the child window is within visible boundaries, or is just appearing.
|
||||||
@ -1068,7 +1036,7 @@ enum ImGuiWindowFlags_
|
|||||||
enum ImGuiChildFlags_
|
enum ImGuiChildFlags_
|
||||||
{
|
{
|
||||||
ImGuiChildFlags_None = 0,
|
ImGuiChildFlags_None = 0,
|
||||||
ImGuiChildFlags_Border = 1 << 0, // Show an outer border and enable WindowPadding. (IMPORTANT: this is always == 1 == true for legacy reason)
|
ImGuiChildFlags_Border = 1 << 0, // Show an outer border and enable WindowPadding. (Important: this is always == 1 == true for legacy reason)
|
||||||
ImGuiChildFlags_AlwaysUseWindowPadding = 1 << 1, // Pad with style.WindowPadding even if no border are drawn (no padding by default for non-bordered child windows because it makes more sense)
|
ImGuiChildFlags_AlwaysUseWindowPadding = 1 << 1, // Pad with style.WindowPadding even if no border are drawn (no padding by default for non-bordered child windows because it makes more sense)
|
||||||
ImGuiChildFlags_ResizeX = 1 << 2, // Allow resize from right border (layout direction). Enable .ini saving (unless ImGuiWindowFlags_NoSavedSettings passed to window flags)
|
ImGuiChildFlags_ResizeX = 1 << 2, // Allow resize from right border (layout direction). Enable .ini saving (unless ImGuiWindowFlags_NoSavedSettings passed to window flags)
|
||||||
ImGuiChildFlags_ResizeY = 1 << 3, // Allow resize from bottom border (layout direction). "
|
ImGuiChildFlags_ResizeY = 1 << 3, // Allow resize from bottom border (layout direction). "
|
||||||
@ -1124,12 +1092,11 @@ enum ImGuiTreeNodeFlags_
|
|||||||
ImGuiTreeNodeFlags_Leaf = 1 << 8, // No collapsing, no arrow (use as a convenience for leaf nodes).
|
ImGuiTreeNodeFlags_Leaf = 1 << 8, // No collapsing, no arrow (use as a convenience for leaf nodes).
|
||||||
ImGuiTreeNodeFlags_Bullet = 1 << 9, // Display a bullet instead of arrow. IMPORTANT: node can still be marked open/close if you don't set the _Leaf flag!
|
ImGuiTreeNodeFlags_Bullet = 1 << 9, // Display a bullet instead of arrow. IMPORTANT: node can still be marked open/close if you don't set the _Leaf flag!
|
||||||
ImGuiTreeNodeFlags_FramePadding = 1 << 10, // Use FramePadding (even for an unframed text node) to vertically align text baseline to regular widget height. Equivalent to calling AlignTextToFramePadding().
|
ImGuiTreeNodeFlags_FramePadding = 1 << 10, // Use FramePadding (even for an unframed text node) to vertically align text baseline to regular widget height. Equivalent to calling AlignTextToFramePadding().
|
||||||
ImGuiTreeNodeFlags_SpanAvailWidth = 1 << 11, // Extend hit box to the right-most edge, even if not framed. This is not the default in order to allow adding other items on the same line without using AllowOverlap mode.
|
ImGuiTreeNodeFlags_SpanAvailWidth = 1 << 11, // Extend hit box to the right-most edge, even if not framed. This is not the default in order to allow adding other items on the same line. In the future we may refactor the hit system to be front-to-back, allowing natural overlaps and then this can become the default.
|
||||||
ImGuiTreeNodeFlags_SpanFullWidth = 1 << 12, // Extend hit box to the left-most and right-most edges (cover the indent area).
|
ImGuiTreeNodeFlags_SpanFullWidth = 1 << 12, // Extend hit box to the left-most and right-most edges (bypass the indented area).
|
||||||
ImGuiTreeNodeFlags_SpanTextWidth = 1 << 13, // Narrow hit box + narrow hovering highlight, will only cover the label text.
|
ImGuiTreeNodeFlags_SpanAllColumns = 1 << 13, // Frame will span all columns of its container table (text will still fit in current column)
|
||||||
ImGuiTreeNodeFlags_SpanAllColumns = 1 << 14, // Frame will span all columns of its container table (text will still fit in current column)
|
ImGuiTreeNodeFlags_NavLeftJumpsBackHere = 1 << 14, // (WIP) Nav: left direction may move to this TreeNode() from any of its child (items submitted between TreeNode and TreePop)
|
||||||
ImGuiTreeNodeFlags_NavLeftJumpsBackHere = 1 << 15, // (WIP) Nav: left direction may move to this TreeNode() from any of its child (items submitted between TreeNode and TreePop)
|
//ImGuiTreeNodeFlags_NoScrollOnOpen = 1 << 15, // FIXME: TODO: Disable automatic scroll on TreePop() if node got just open and contents is not visible
|
||||||
//ImGuiTreeNodeFlags_NoScrollOnOpen = 1 << 16, // FIXME: TODO: Disable automatic scroll on TreePop() if node got just open and contents is not visible
|
|
||||||
ImGuiTreeNodeFlags_CollapsingHeader = ImGuiTreeNodeFlags_Framed | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_NoAutoOpenOnLog,
|
ImGuiTreeNodeFlags_CollapsingHeader = ImGuiTreeNodeFlags_Framed | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_NoAutoOpenOnLog,
|
||||||
|
|
||||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
@ -1138,8 +1105,8 @@ enum ImGuiTreeNodeFlags_
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Flags for OpenPopup*(), BeginPopupContext*(), IsPopupOpen() functions.
|
// Flags for OpenPopup*(), BeginPopupContext*(), IsPopupOpen() functions.
|
||||||
// - To be backward compatible with older API which took an 'int mouse_button = 1' argument instead of 'ImGuiPopupFlags flags',
|
// - To be backward compatible with older API which took an 'int mouse_button = 1' argument, we need to treat
|
||||||
// we need to treat small flags values as a mouse button index, so we encode the mouse button in the first few bits of the flags.
|
// small flags values as a mouse button index, so we encode the mouse button in the first few bits of the flags.
|
||||||
// It is therefore guaranteed to be legal to pass a mouse button index in ImGuiPopupFlags.
|
// It is therefore guaranteed to be legal to pass a mouse button index in ImGuiPopupFlags.
|
||||||
// - For the same reason, we exceptionally default the ImGuiPopupFlags argument of BeginPopupContextXXX functions to 1 instead of 0.
|
// - For the same reason, we exceptionally default the ImGuiPopupFlags argument of BeginPopupContextXXX functions to 1 instead of 0.
|
||||||
// IMPORTANT: because the default parameter is 1 (==ImGuiPopupFlags_MouseButtonRight), if you rely on the default parameter
|
// IMPORTANT: because the default parameter is 1 (==ImGuiPopupFlags_MouseButtonRight), if you rely on the default parameter
|
||||||
@ -1153,12 +1120,10 @@ enum ImGuiPopupFlags_
|
|||||||
ImGuiPopupFlags_MouseButtonMiddle = 2, // For BeginPopupContext*(): open on Middle Mouse release. Guaranteed to always be == 2 (same as ImGuiMouseButton_Middle)
|
ImGuiPopupFlags_MouseButtonMiddle = 2, // For BeginPopupContext*(): open on Middle Mouse release. Guaranteed to always be == 2 (same as ImGuiMouseButton_Middle)
|
||||||
ImGuiPopupFlags_MouseButtonMask_ = 0x1F,
|
ImGuiPopupFlags_MouseButtonMask_ = 0x1F,
|
||||||
ImGuiPopupFlags_MouseButtonDefault_ = 1,
|
ImGuiPopupFlags_MouseButtonDefault_ = 1,
|
||||||
ImGuiPopupFlags_NoReopen = 1 << 5, // For OpenPopup*(), BeginPopupContext*(): don't reopen same popup if already open (won't reposition, won't reinitialize navigation)
|
ImGuiPopupFlags_NoOpenOverExistingPopup = 1 << 5, // For OpenPopup*(), BeginPopupContext*(): don't open if there's already a popup at the same level of the popup stack
|
||||||
//ImGuiPopupFlags_NoReopenAlwaysNavInit = 1 << 6, // For OpenPopup*(), BeginPopupContext*(): focus and initialize navigation even when not reopening.
|
ImGuiPopupFlags_NoOpenOverItems = 1 << 6, // For BeginPopupContextWindow(): don't return true when hovering items, only when hovering empty space
|
||||||
ImGuiPopupFlags_NoOpenOverExistingPopup = 1 << 7, // For OpenPopup*(), BeginPopupContext*(): don't open if there's already a popup at the same level of the popup stack
|
ImGuiPopupFlags_AnyPopupId = 1 << 7, // For IsPopupOpen(): ignore the ImGuiID parameter and test for any popup.
|
||||||
ImGuiPopupFlags_NoOpenOverItems = 1 << 8, // For BeginPopupContextWindow(): don't return true when hovering items, only when hovering empty space
|
ImGuiPopupFlags_AnyPopupLevel = 1 << 8, // For IsPopupOpen(): search/test at any level of the popup stack (default test in the current level)
|
||||||
ImGuiPopupFlags_AnyPopupId = 1 << 10, // For IsPopupOpen(): ignore the ImGuiID parameter and test for any popup.
|
|
||||||
ImGuiPopupFlags_AnyPopupLevel = 1 << 11, // For IsPopupOpen(): search/test at any level of the popup stack (default test in the current level)
|
|
||||||
ImGuiPopupFlags_AnyPopup = ImGuiPopupFlags_AnyPopupId | ImGuiPopupFlags_AnyPopupLevel,
|
ImGuiPopupFlags_AnyPopup = ImGuiPopupFlags_AnyPopupId | ImGuiPopupFlags_AnyPopupLevel,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1444,13 +1409,13 @@ enum ImGuiKey : int
|
|||||||
// - In theory the value of keyboard modifiers should be roughly equivalent to a logical or of the equivalent left/right keys.
|
// - In theory the value of keyboard modifiers should be roughly equivalent to a logical or of the equivalent left/right keys.
|
||||||
// In practice: it's complicated; mods are often provided from different sources. Keyboard layout, IME, sticky keys and
|
// In practice: it's complicated; mods are often provided from different sources. Keyboard layout, IME, sticky keys and
|
||||||
// backends tend to interfere and break that equivalence. The safer decision is to relay that ambiguity down to the end-user...
|
// backends tend to interfere and break that equivalence. The safer decision is to relay that ambiguity down to the end-user...
|
||||||
// - On macOS, we swap Cmd(Super) and Ctrl keys at the time of the io.AddKeyEvent() call.
|
|
||||||
ImGuiMod_None = 0,
|
ImGuiMod_None = 0,
|
||||||
ImGuiMod_Ctrl = 1 << 12, // Ctrl (non-macOS), Cmd (macOS)
|
ImGuiMod_Ctrl = 1 << 12, // Ctrl
|
||||||
ImGuiMod_Shift = 1 << 13, // Shift
|
ImGuiMod_Shift = 1 << 13, // Shift
|
||||||
ImGuiMod_Alt = 1 << 14, // Option/Menu
|
ImGuiMod_Alt = 1 << 14, // Option/Menu
|
||||||
ImGuiMod_Super = 1 << 15, // Windows/Super (non-macOS), Ctrl (macOS)
|
ImGuiMod_Super = 1 << 15, // Cmd/Super/Windows
|
||||||
ImGuiMod_Mask_ = 0xF000, // 4-bits
|
ImGuiMod_Shortcut = 1 << 11, // Alias for Ctrl (non-macOS) _or_ Super (macOS).
|
||||||
|
ImGuiMod_Mask_ = 0xF800, // 5-bits
|
||||||
|
|
||||||
// [Internal] Prior to 1.87 we required user to fill io.KeysDown[512] using their own native index + the io.KeyMap[] array.
|
// [Internal] Prior to 1.87 we required user to fill io.KeysDown[512] using their own native index + the io.KeyMap[] array.
|
||||||
// We are ditching this method but keeping a legacy path for user code doing e.g. IsKeyPressed(MY_NATIVE_KEY_CODE)
|
// We are ditching this method but keeping a legacy path for user code doing e.g. IsKeyPressed(MY_NATIVE_KEY_CODE)
|
||||||
@ -1467,37 +1432,11 @@ enum ImGuiKey : int
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
ImGuiMod_Shortcut = ImGuiMod_Ctrl, // Removed in 1.90.7, you can now simply use ImGuiMod_Ctrl
|
|
||||||
ImGuiKey_ModCtrl = ImGuiMod_Ctrl, ImGuiKey_ModShift = ImGuiMod_Shift, ImGuiKey_ModAlt = ImGuiMod_Alt, ImGuiKey_ModSuper = ImGuiMod_Super, // Renamed in 1.89
|
ImGuiKey_ModCtrl = ImGuiMod_Ctrl, ImGuiKey_ModShift = ImGuiMod_Shift, ImGuiKey_ModAlt = ImGuiMod_Alt, ImGuiKey_ModSuper = ImGuiMod_Super, // Renamed in 1.89
|
||||||
//ImGuiKey_KeyPadEnter = ImGuiKey_KeypadEnter, // Renamed in 1.87
|
//ImGuiKey_KeyPadEnter = ImGuiKey_KeypadEnter, // Renamed in 1.87
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
// Flags for Shortcut(), SetNextItemShortcut(),
|
|
||||||
// (and for upcoming extended versions of IsKeyPressed(), IsMouseClicked(), Shortcut(), SetKeyOwner(), SetItemKeyOwner() that are still in imgui_internal.h)
|
|
||||||
// Don't mistake with ImGuiInputTextFlags! (which is for ImGui::InputText() function)
|
|
||||||
enum ImGuiInputFlags_
|
|
||||||
{
|
|
||||||
ImGuiInputFlags_None = 0,
|
|
||||||
ImGuiInputFlags_Repeat = 1 << 0, // Enable repeat. Return true on successive repeats. Default for legacy IsKeyPressed(). NOT Default for legacy IsMouseClicked(). MUST BE == 1.
|
|
||||||
|
|
||||||
// Flags for Shortcut(), SetNextItemShortcut()
|
|
||||||
// - Routing policies: RouteGlobal+OverActive >> RouteActive or RouteFocused (if owner is active item) >> RouteGlobal+OverFocused >> RouteFocused (if in focused window stack) >> RouteGlobal.
|
|
||||||
// - Default policy is RouteFocused. Can select only 1 policy among all available.
|
|
||||||
ImGuiInputFlags_RouteActive = 1 << 10, // Route to active item only.
|
|
||||||
ImGuiInputFlags_RouteFocused = 1 << 11, // Route to windows in the focus stack (DEFAULT). Deep-most focused window takes inputs. Active item takes inputs over deep-most focused window.
|
|
||||||
ImGuiInputFlags_RouteGlobal = 1 << 12, // Global route (unless a focused window or active item registered the route).
|
|
||||||
ImGuiInputFlags_RouteAlways = 1 << 13, // Do not register route, poll keys directly.
|
|
||||||
// - Routing options
|
|
||||||
ImGuiInputFlags_RouteOverFocused = 1 << 14, // Option: global route: higher priority than focused route (unless active item in focused route).
|
|
||||||
ImGuiInputFlags_RouteOverActive = 1 << 15, // Option: global route: higher priority than active item. Unlikely you need to use that: will interfere with every active items, e.g. CTRL+A registered by InputText will be overridden by this. May not be fully honored as user/internal code is likely to always assume they can access keys when active.
|
|
||||||
ImGuiInputFlags_RouteUnlessBgFocused = 1 << 16, // Option: global route: will not be applied if underlying background/void is focused (== no Dear ImGui windows are focused). Useful for overlay applications.
|
|
||||||
ImGuiInputFlags_RouteFromRootWindow = 1 << 17, // Option: route evaluated from the point of view of root window rather than current window.
|
|
||||||
|
|
||||||
// Flags for SetNextItemShortcut()
|
|
||||||
ImGuiInputFlags_Tooltip = 1 << 18, // Automatically display a tooltip when hovering item [BETA] Unsure of right api (opt-in/opt-out)
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
|
#ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
|
||||||
// OBSOLETED in 1.88 (from July 2022): ImGuiNavInput and io.NavInputs[].
|
// OBSOLETED in 1.88 (from July 2022): ImGuiNavInput and io.NavInputs[].
|
||||||
// Official backends between 1.60 and 1.86: will keep working and feed gamepad inputs as long as IMGUI_DISABLE_OBSOLETE_KEYIO is not set.
|
// Official backends between 1.60 and 1.86: will keep working and feed gamepad inputs as long as IMGUI_DISABLE_OBSOLETE_KEYIO is not set.
|
||||||
@ -1599,13 +1538,12 @@ enum ImGuiCol_
|
|||||||
// - The enum only refers to fields of ImGuiStyle which makes sense to be pushed/popped inside UI code.
|
// - The enum only refers to fields of ImGuiStyle which makes sense to be pushed/popped inside UI code.
|
||||||
// During initialization or between frames, feel free to just poke into ImGuiStyle directly.
|
// During initialization or between frames, feel free to just poke into ImGuiStyle directly.
|
||||||
// - Tip: Use your programming IDE navigation facilities on the names in the _second column_ below to find the actual members and their description.
|
// - Tip: Use your programming IDE navigation facilities on the names in the _second column_ below to find the actual members and their description.
|
||||||
// - In Visual Studio: CTRL+comma ("Edit.GoToAll") can follow symbols inside comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot.
|
// In Visual Studio IDE: CTRL+comma ("Edit.GoToAll") can follow symbols in comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot.
|
||||||
// - In Visual Studio w/ Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols inside comments.
|
// With Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols in comments.
|
||||||
// - In VS Code, CLion, etc.: CTRL+click can follow symbols inside comments.
|
|
||||||
// - When changing this enum, you need to update the associated internal table GStyleVarInfo[] accordingly. This is where we link enum values to members offset/type.
|
// - When changing this enum, you need to update the associated internal table GStyleVarInfo[] accordingly. This is where we link enum values to members offset/type.
|
||||||
enum ImGuiStyleVar_
|
enum ImGuiStyleVar_
|
||||||
{
|
{
|
||||||
// Enum name -------------------------- // Member in ImGuiStyle structure (see ImGuiStyle for descriptions)
|
// Enum name --------------------- // Member in ImGuiStyle structure (see ImGuiStyle for descriptions)
|
||||||
ImGuiStyleVar_Alpha, // float Alpha
|
ImGuiStyleVar_Alpha, // float Alpha
|
||||||
ImGuiStyleVar_DisabledAlpha, // float DisabledAlpha
|
ImGuiStyleVar_DisabledAlpha, // float DisabledAlpha
|
||||||
ImGuiStyleVar_WindowPadding, // ImVec2 WindowPadding
|
ImGuiStyleVar_WindowPadding, // ImVec2 WindowPadding
|
||||||
@ -1629,10 +1567,7 @@ enum ImGuiStyleVar_
|
|||||||
ImGuiStyleVar_GrabMinSize, // float GrabMinSize
|
ImGuiStyleVar_GrabMinSize, // float GrabMinSize
|
||||||
ImGuiStyleVar_GrabRounding, // float GrabRounding
|
ImGuiStyleVar_GrabRounding, // float GrabRounding
|
||||||
ImGuiStyleVar_TabRounding, // float TabRounding
|
ImGuiStyleVar_TabRounding, // float TabRounding
|
||||||
ImGuiStyleVar_TabBorderSize, // float TabBorderSize
|
|
||||||
ImGuiStyleVar_TabBarBorderSize, // float TabBarBorderSize
|
ImGuiStyleVar_TabBarBorderSize, // float TabBarBorderSize
|
||||||
ImGuiStyleVar_TableAngledHeadersAngle, // float TableAngledHeadersAngle
|
|
||||||
ImGuiStyleVar_TableAngledHeadersTextAlign,// ImVec2 TableAngledHeadersTextAlign
|
|
||||||
ImGuiStyleVar_ButtonTextAlign, // ImVec2 ButtonTextAlign
|
ImGuiStyleVar_ButtonTextAlign, // ImVec2 ButtonTextAlign
|
||||||
ImGuiStyleVar_SelectableTextAlign, // ImVec2 SelectableTextAlign
|
ImGuiStyleVar_SelectableTextAlign, // ImVec2 SelectableTextAlign
|
||||||
ImGuiStyleVar_SeparatorTextBorderSize,// float SeparatorTextBorderSize
|
ImGuiStyleVar_SeparatorTextBorderSize,// float SeparatorTextBorderSize
|
||||||
@ -2052,7 +1987,7 @@ struct ImGuiStyle
|
|||||||
float FrameBorderSize; // Thickness of border around frames. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly).
|
float FrameBorderSize; // Thickness of border around frames. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly).
|
||||||
ImVec2 ItemSpacing; // Horizontal and vertical spacing between widgets/lines.
|
ImVec2 ItemSpacing; // Horizontal and vertical spacing between widgets/lines.
|
||||||
ImVec2 ItemInnerSpacing; // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label).
|
ImVec2 ItemInnerSpacing; // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label).
|
||||||
ImVec2 CellPadding; // Padding within a table cell. Cellpadding.x is locked for entire table. CellPadding.y may be altered between different rows.
|
ImVec2 CellPadding; // Padding within a table cell. CellPadding.y may be altered between different rows.
|
||||||
ImVec2 TouchExtraPadding; // Expand reactive bounding box for touch-based system where touch position is not accurate enough. Unfortunately we don't sort widgets so priority on overlap will always be given to the first widget. So don't grow this too much!
|
ImVec2 TouchExtraPadding; // Expand reactive bounding box for touch-based system where touch position is not accurate enough. Unfortunately we don't sort widgets so priority on overlap will always be given to the first widget. So don't grow this too much!
|
||||||
float IndentSpacing; // Horizontal indentation when e.g. entering a tree node. Generally == (FontSize + FramePadding.x*2).
|
float IndentSpacing; // Horizontal indentation when e.g. entering a tree node. Generally == (FontSize + FramePadding.x*2).
|
||||||
float ColumnsMinSpacing; // Minimum horizontal spacing between two columns. Preferably > (FramePadding.x + 1).
|
float ColumnsMinSpacing; // Minimum horizontal spacing between two columns. Preferably > (FramePadding.x + 1).
|
||||||
@ -2066,7 +2001,6 @@ struct ImGuiStyle
|
|||||||
float TabMinWidthForCloseButton; // Minimum width for close button to appear on an unselected tab when hovered. Set to 0.0f to always show when hovering, set to FLT_MAX to never show close button unless selected.
|
float TabMinWidthForCloseButton; // Minimum width for close button to appear on an unselected tab when hovered. Set to 0.0f to always show when hovering, set to FLT_MAX to never show close button unless selected.
|
||||||
float TabBarBorderSize; // Thickness of tab-bar separator, which takes on the tab active color to denote focus.
|
float TabBarBorderSize; // Thickness of tab-bar separator, which takes on the tab active color to denote focus.
|
||||||
float TableAngledHeadersAngle; // Angle of angled headers (supported values range from -50.0f degrees to +50.0f degrees).
|
float TableAngledHeadersAngle; // Angle of angled headers (supported values range from -50.0f degrees to +50.0f degrees).
|
||||||
ImVec2 TableAngledHeadersTextAlign;// Alignment of angled headers within the cell
|
|
||||||
ImGuiDir ColorButtonPosition; // Side of the color button in the ColorEdit4 widget (left/right). Defaults to ImGuiDir_Right.
|
ImGuiDir ColorButtonPosition; // Side of the color button in the ColorEdit4 widget (left/right). Defaults to ImGuiDir_Right.
|
||||||
ImVec2 ButtonTextAlign; // Alignment of button text when button is larger than text. Defaults to (0.5f, 0.5f) (centered).
|
ImVec2 ButtonTextAlign; // Alignment of button text when button is larger than text. Defaults to (0.5f, 0.5f) (centered).
|
||||||
ImVec2 SelectableTextAlign; // Alignment of selectable text. Defaults to (0.0f, 0.0f) (top-left aligned). It's generally important to keep this left-aligned if you want to lay multiple items on a same line.
|
ImVec2 SelectableTextAlign; // Alignment of selectable text. Defaults to (0.0f, 0.0f) (top-left aligned). It's generally important to keep this left-aligned if you want to lay multiple items on a same line.
|
||||||
@ -2100,9 +2034,6 @@ struct ImGuiStyle
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Communicate most settings and inputs/outputs to Dear ImGui using this structure.
|
// Communicate most settings and inputs/outputs to Dear ImGui using this structure.
|
||||||
// Access via ImGui::GetIO(). Read 'Programmer guide' section in .cpp file for general usage.
|
// Access via ImGui::GetIO(). Read 'Programmer guide' section in .cpp file for general usage.
|
||||||
// It is generally expected that:
|
|
||||||
// - initialization: backends and user code writes to ImGuiIO.
|
|
||||||
// - main loop: backends writes to ImGuiIO, user code and imgui code reads from ImGuiIO.
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// [Internal] Storage used by IsKeyDown(), IsKeyPressed() etc functions.
|
// [Internal] Storage used by IsKeyDown(), IsKeyPressed() etc functions.
|
||||||
@ -2138,7 +2069,7 @@ struct ImGuiIO
|
|||||||
|
|
||||||
// Miscellaneous options
|
// Miscellaneous options
|
||||||
bool MouseDrawCursor; // = false // Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor). Cannot be easily renamed to 'io.ConfigXXX' because this is frequently used by backend implementations.
|
bool MouseDrawCursor; // = false // Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor). Cannot be easily renamed to 'io.ConfigXXX' because this is frequently used by backend implementations.
|
||||||
bool ConfigMacOSXBehaviors; // = defined(__APPLE__) // Swap Cmd<>Ctrl keys + OS X style text editing cursor movement using Alt instead of Ctrl, Shortcuts using Cmd/Super instead of Ctrl, Line/Text Start and End using Cmd+Arrows instead of Home/End, Double click selects by word instead of selecting whole text, Multi-selection in lists uses Cmd/Super instead of Ctrl.
|
bool ConfigMacOSXBehaviors; // = defined(__APPLE__) // OS X style: Text editing cursor movement using Alt instead of Ctrl, Shortcuts using Cmd/Super instead of Ctrl, Line/Text Start and End using Cmd+Arrows instead of Home/End, Double click selects by word instead of selecting whole text, Multi-selection in lists uses Cmd/Super instead of Ctrl.
|
||||||
bool ConfigInputTrickleEventQueue; // = true // Enable input queue trickling: some types of events submitted during the same frame (e.g. button down + up) will be spread over multiple frames, improving interactions with low framerates.
|
bool ConfigInputTrickleEventQueue; // = true // Enable input queue trickling: some types of events submitted during the same frame (e.g. button down + up) will be spread over multiple frames, improving interactions with low framerates.
|
||||||
bool ConfigInputTextCursorBlink; // = true // Enable blinking cursor (optional as some users consider it to be distracting).
|
bool ConfigInputTextCursorBlink; // = true // Enable blinking cursor (optional as some users consider it to be distracting).
|
||||||
bool ConfigInputTextEnterKeepActive; // = false // [BETA] Pressing Enter will keep item active and select contents (single-line only).
|
bool ConfigInputTextEnterKeepActive; // = false // [BETA] Pressing Enter will keep item active and select contents (single-line only).
|
||||||
@ -2249,6 +2180,20 @@ struct ImGuiIO
|
|||||||
int MetricsActiveWindows; // Number of active windows
|
int MetricsActiveWindows; // Number of active windows
|
||||||
ImVec2 MouseDelta; // Mouse delta. Note that this is zero if either current or previous position are invalid (-FLT_MAX,-FLT_MAX), so a disappearing/reappearing mouse won't have a huge delta.
|
ImVec2 MouseDelta; // Mouse delta. Note that this is zero if either current or previous position are invalid (-FLT_MAX,-FLT_MAX), so a disappearing/reappearing mouse won't have a huge delta.
|
||||||
|
|
||||||
|
// Legacy: before 1.87, we required backend to fill io.KeyMap[] (imgui->native map) during initialization and io.KeysDown[] (native indices) every frame.
|
||||||
|
// This is still temporarily supported as a legacy feature. However the new preferred scheme is for backend to call io.AddKeyEvent().
|
||||||
|
// Old (<1.87): ImGui::IsKeyPressed(ImGui::GetIO().KeyMap[ImGuiKey_Space]) --> New (1.87+) ImGui::IsKeyPressed(ImGuiKey_Space)
|
||||||
|
#ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
|
||||||
|
int KeyMap[ImGuiKey_COUNT]; // [LEGACY] Input: map of indices into the KeysDown[512] entries array which represent your "native" keyboard state. The first 512 are now unused and should be kept zero. Legacy backend will write into KeyMap[] using ImGuiKey_ indices which are always >512.
|
||||||
|
bool KeysDown[ImGuiKey_COUNT]; // [LEGACY] Input: Keyboard keys that are pressed (ideally left in the "native" order your engine has access to keyboard keys, so you can use your own defines/enums for keys). This used to be [512] sized. It is now ImGuiKey_COUNT to allow legacy io.KeysDown[GetKeyIndex(...)] to work without an overflow.
|
||||||
|
float NavInputs[ImGuiNavInput_COUNT]; // [LEGACY] Since 1.88, NavInputs[] was removed. Backends from 1.60 to 1.86 won't build. Feed gamepad inputs via io.AddKeyEvent() and ImGuiKey_GamepadXXX enums.
|
||||||
|
#endif
|
||||||
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
|
void* ImeWindowHandle; // = NULL // [Obsoleted in 1.87] Set ImGuiViewport::PlatformHandleRaw instead. Set this to your HWND to get automatic IME cursor positioning.
|
||||||
|
#else
|
||||||
|
void* _UnusedPadding;
|
||||||
|
#endif
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// [Internal] Dear ImGui will maintain those fields. Forward compatibility not guaranteed!
|
// [Internal] Dear ImGui will maintain those fields. Forward compatibility not guaranteed!
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
@ -2269,7 +2214,7 @@ struct ImGuiIO
|
|||||||
bool KeySuper; // Keyboard modifier down: Cmd/Super/Windows
|
bool KeySuper; // Keyboard modifier down: Cmd/Super/Windows
|
||||||
|
|
||||||
// Other state maintained from data above + IO function calls
|
// Other state maintained from data above + IO function calls
|
||||||
ImGuiKeyChord KeyMods; // Key mods flags (any of ImGuiMod_Ctrl/ImGuiMod_Shift/ImGuiMod_Alt/ImGuiMod_Super flags, same as io.KeyCtrl/KeyShift/KeyAlt/KeySuper but merged into flags. Read-only, updated by NewFrame()
|
ImGuiKeyChord KeyMods; // Key mods flags (any of ImGuiMod_Ctrl/ImGuiMod_Shift/ImGuiMod_Alt/ImGuiMod_Super flags, same as io.KeyCtrl/KeyShift/KeyAlt/KeySuper but merged into flags. DOES NOT CONTAINS ImGuiMod_Shortcut which is pretranslated). Read-only, updated by NewFrame()
|
||||||
ImGuiKeyData KeysData[ImGuiKey_KeysData_SIZE]; // Key state for all known keys. Use IsKeyXXX() functions to access this.
|
ImGuiKeyData KeysData[ImGuiKey_KeysData_SIZE]; // Key state for all known keys. Use IsKeyXXX() functions to access this.
|
||||||
bool WantCaptureMouseUnlessPopupClose; // Alternative to WantCaptureMouse: (WantCaptureMouse == true && WantCaptureMouseUnlessPopupClose == false) when a click over void is expected to close a popup.
|
bool WantCaptureMouseUnlessPopupClose; // Alternative to WantCaptureMouse: (WantCaptureMouse == true && WantCaptureMouseUnlessPopupClose == false) when a click over void is expected to close a popup.
|
||||||
ImVec2 MousePosPrev; // Previous mouse position (note that MouseDelta is not necessary == MousePos-MousePosPrev, in case either position is invalid)
|
ImVec2 MousePosPrev; // Previous mouse position (note that MouseDelta is not necessary == MousePos-MousePosPrev, in case either position is invalid)
|
||||||
@ -2283,7 +2228,6 @@ struct ImGuiIO
|
|||||||
bool MouseDownOwned[5]; // Track if button was clicked inside a dear imgui window or over void blocked by a popup. We don't request mouse capture from the application if click started outside ImGui bounds.
|
bool MouseDownOwned[5]; // Track if button was clicked inside a dear imgui window or over void blocked by a popup. We don't request mouse capture from the application if click started outside ImGui bounds.
|
||||||
bool MouseDownOwnedUnlessPopupClose[5]; // Track if button was clicked inside a dear imgui window.
|
bool MouseDownOwnedUnlessPopupClose[5]; // Track if button was clicked inside a dear imgui window.
|
||||||
bool MouseWheelRequestAxisSwap; // On a non-Mac system, holding SHIFT requests WheelY to perform the equivalent of a WheelX event. On a Mac system this is already enforced by the system.
|
bool MouseWheelRequestAxisSwap; // On a non-Mac system, holding SHIFT requests WheelY to perform the equivalent of a WheelX event. On a Mac system this is already enforced by the system.
|
||||||
bool MouseCtrlLeftAsRightClick; // (OSX) Set to true when the current click was a ctrl-click that spawned a simulated right click
|
|
||||||
float MouseDownDuration[5]; // Duration the mouse button has been down (0.0f == just clicked)
|
float MouseDownDuration[5]; // Duration the mouse button has been down (0.0f == just clicked)
|
||||||
float MouseDownDurationPrev[5]; // Previous time the mouse button has been down
|
float MouseDownDurationPrev[5]; // Previous time the mouse button has been down
|
||||||
float MouseDragMaxDistanceSqr[5]; // Squared maximum distance of how much mouse has traveled from the clicking point (used for moving thresholds)
|
float MouseDragMaxDistanceSqr[5]; // Squared maximum distance of how much mouse has traveled from the clicking point (used for moving thresholds)
|
||||||
@ -2295,16 +2239,6 @@ struct ImGuiIO
|
|||||||
ImWchar16 InputQueueSurrogate; // For AddInputCharacterUTF16()
|
ImWchar16 InputQueueSurrogate; // For AddInputCharacterUTF16()
|
||||||
ImVector<ImWchar> InputQueueCharacters; // Queue of _characters_ input (obtained by platform backend). Fill using AddInputCharacter() helper.
|
ImVector<ImWchar> InputQueueCharacters; // Queue of _characters_ input (obtained by platform backend). Fill using AddInputCharacter() helper.
|
||||||
|
|
||||||
// Legacy: before 1.87, we required backend to fill io.KeyMap[] (imgui->native map) during initialization and io.KeysDown[] (native indices) every frame.
|
|
||||||
// This is still temporarily supported as a legacy feature. However the new preferred scheme is for backend to call io.AddKeyEvent().
|
|
||||||
// Old (<1.87): ImGui::IsKeyPressed(ImGui::GetIO().KeyMap[ImGuiKey_Space]) --> New (1.87+) ImGui::IsKeyPressed(ImGuiKey_Space)
|
|
||||||
#ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
|
|
||||||
int KeyMap[ImGuiKey_COUNT]; // [LEGACY] Input: map of indices into the KeysDown[512] entries array which represent your "native" keyboard state. The first 512 are now unused and should be kept zero. Legacy backend will write into KeyMap[] using ImGuiKey_ indices which are always >512.
|
|
||||||
bool KeysDown[ImGuiKey_COUNT]; // [LEGACY] Input: Keyboard keys that are pressed (ideally left in the "native" order your engine has access to keyboard keys, so you can use your own defines/enums for keys). This used to be [512] sized. It is now ImGuiKey_COUNT to allow legacy io.KeysDown[GetKeyIndex(...)] to work without an overflow.
|
|
||||||
float NavInputs[ImGuiNavInput_COUNT]; // [LEGACY] Since 1.88, NavInputs[] was removed. Backends from 1.60 to 1.86 won't build. Feed gamepad inputs via io.AddKeyEvent() and ImGuiKey_GamepadXXX enums.
|
|
||||||
//void* ImeWindowHandle; // [Obsoleted in 1.87] Set ImGuiViewport::PlatformHandleRaw instead. Set this to your HWND to get automatic IME cursor positioning.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
IMGUI_API ImGuiIO();
|
IMGUI_API ImGuiIO();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2329,8 +2263,6 @@ struct ImGuiInputTextCallbackData
|
|||||||
void* UserData; // What user passed to InputText() // Read-only
|
void* UserData; // What user passed to InputText() // Read-only
|
||||||
|
|
||||||
// Arguments for the different callback events
|
// Arguments for the different callback events
|
||||||
// - During Resize callback, Buf will be same as your input buffer.
|
|
||||||
// - However, during Completion/History/Always callback, Buf always points to our own internal data (it is not the same as your buffer)! Changes to it will be reflected into your own buffer shortly after the callback.
|
|
||||||
// - To modify the text buffer in a callback, prefer using the InsertChars() / DeleteChars() function. InsertChars() will take care of calling the resize callback if necessary.
|
// - To modify the text buffer in a callback, prefer using the InsertChars() / DeleteChars() function. InsertChars() will take care of calling the resize callback if necessary.
|
||||||
// - If you know your edits are not going to resize the underlying buffer allocation, you may modify the contents of 'Buf[]' directly. You need to update 'BufTextLen' accordingly (0 <= BufTextLen < BufSize) and set 'BufDirty'' to true so InputText can update its internal state.
|
// - If you know your edits are not going to resize the underlying buffer allocation, you may modify the contents of 'Buf[]' directly. You need to update 'BufTextLen' accordingly (0 <= BufTextLen < BufSize) and set 'BufDirty'' to true so InputText can update its internal state.
|
||||||
ImWchar EventChar; // Character input // Read-write // [CharFilter] Replace character with another one, or set to zero to drop. return 1 is equivalent to setting EventChar=0;
|
ImWchar EventChar; // Character input // Read-write // [CharFilter] Replace character with another one, or set to zero to drop. return 1 is equivalent to setting EventChar=0;
|
||||||
@ -2774,15 +2706,15 @@ struct ImDrawList
|
|||||||
// [Internal, used while building lists]
|
// [Internal, used while building lists]
|
||||||
unsigned int _VtxCurrentIdx; // [Internal] generally == VtxBuffer.Size unless we are past 64K vertices, in which case this gets reset to 0.
|
unsigned int _VtxCurrentIdx; // [Internal] generally == VtxBuffer.Size unless we are past 64K vertices, in which case this gets reset to 0.
|
||||||
ImDrawListSharedData* _Data; // Pointer to shared draw data (you can use ImGui::GetDrawListSharedData() to get the one from current ImGui context)
|
ImDrawListSharedData* _Data; // Pointer to shared draw data (you can use ImGui::GetDrawListSharedData() to get the one from current ImGui context)
|
||||||
|
const char* _OwnerName; // Pointer to owner window's name for debugging
|
||||||
ImDrawVert* _VtxWritePtr; // [Internal] point within VtxBuffer.Data after each add command (to avoid using the ImVector<> operators too much)
|
ImDrawVert* _VtxWritePtr; // [Internal] point within VtxBuffer.Data after each add command (to avoid using the ImVector<> operators too much)
|
||||||
ImDrawIdx* _IdxWritePtr; // [Internal] point within IdxBuffer.Data after each add command (to avoid using the ImVector<> operators too much)
|
ImDrawIdx* _IdxWritePtr; // [Internal] point within IdxBuffer.Data after each add command (to avoid using the ImVector<> operators too much)
|
||||||
|
ImVector<ImVec4> _ClipRectStack; // [Internal]
|
||||||
|
ImVector<ImTextureID> _TextureIdStack; // [Internal]
|
||||||
ImVector<ImVec2> _Path; // [Internal] current path building
|
ImVector<ImVec2> _Path; // [Internal] current path building
|
||||||
ImDrawCmdHeader _CmdHeader; // [Internal] template of active commands. Fields should match those of CmdBuffer.back().
|
ImDrawCmdHeader _CmdHeader; // [Internal] template of active commands. Fields should match those of CmdBuffer.back().
|
||||||
ImDrawListSplitter _Splitter; // [Internal] for channels api (note: prefer using your own persistent instance of ImDrawListSplitter!)
|
ImDrawListSplitter _Splitter; // [Internal] for channels api (note: prefer using your own persistent instance of ImDrawListSplitter!)
|
||||||
ImVector<ImVec4> _ClipRectStack; // [Internal]
|
|
||||||
ImVector<ImTextureID> _TextureIdStack; // [Internal]
|
|
||||||
float _FringeScale; // [Internal] anti-alias fringe is scaled by this value, this helps to keep things sharp while zooming at vertex buffer content
|
float _FringeScale; // [Internal] anti-alias fringe is scaled by this value, this helps to keep things sharp while zooming at vertex buffer content
|
||||||
const char* _OwnerName; // Pointer to owner window's name for debugging
|
|
||||||
|
|
||||||
// If you want to create ImDrawList instances, pass them ImGui::GetDrawListSharedData() or create and use your own ImDrawListSharedData (so you can use ImDrawList without ImGui)
|
// If you want to create ImDrawList instances, pass them ImGui::GetDrawListSharedData() or create and use your own ImDrawListSharedData (so you can use ImDrawList without ImGui)
|
||||||
ImDrawList(ImDrawListSharedData* shared_data) { memset(this, 0, sizeof(*this)); _Data = shared_data; }
|
ImDrawList(ImDrawListSharedData* shared_data) { memset(this, 0, sizeof(*this)); _Data = shared_data; }
|
||||||
@ -2815,19 +2747,14 @@ struct ImDrawList
|
|||||||
IMGUI_API void AddCircleFilled(const ImVec2& center, float radius, ImU32 col, int num_segments = 0);
|
IMGUI_API void AddCircleFilled(const ImVec2& center, float radius, ImU32 col, int num_segments = 0);
|
||||||
IMGUI_API void AddNgon(const ImVec2& center, float radius, ImU32 col, int num_segments, float thickness = 1.0f);
|
IMGUI_API void AddNgon(const ImVec2& center, float radius, ImU32 col, int num_segments, float thickness = 1.0f);
|
||||||
IMGUI_API void AddNgonFilled(const ImVec2& center, float radius, ImU32 col, int num_segments);
|
IMGUI_API void AddNgonFilled(const ImVec2& center, float radius, ImU32 col, int num_segments);
|
||||||
IMGUI_API void AddEllipse(const ImVec2& center, const ImVec2& radius, ImU32 col, float rot = 0.0f, int num_segments = 0, float thickness = 1.0f);
|
IMGUI_API void AddEllipse(const ImVec2& center, float radius_x, float radius_y, ImU32 col, float rot = 0.0f, int num_segments = 0, float thickness = 1.0f);
|
||||||
IMGUI_API void AddEllipseFilled(const ImVec2& center, const ImVec2& radius, ImU32 col, float rot = 0.0f, int num_segments = 0);
|
IMGUI_API void AddEllipseFilled(const ImVec2& center, float radius_x, float radius_y, ImU32 col, float rot = 0.0f, int num_segments = 0);
|
||||||
IMGUI_API void AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL);
|
IMGUI_API void AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL);
|
||||||
IMGUI_API void AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL, float wrap_width = 0.0f, const ImVec4* cpu_fine_clip_rect = NULL);
|
IMGUI_API void AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL, float wrap_width = 0.0f, const ImVec4* cpu_fine_clip_rect = NULL);
|
||||||
IMGUI_API void AddBezierCubic(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness, int num_segments = 0); // Cubic Bezier (4 control points)
|
|
||||||
IMGUI_API void AddBezierQuadratic(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col, float thickness, int num_segments = 0); // Quadratic Bezier (3 control points)
|
|
||||||
|
|
||||||
// General polygon
|
|
||||||
// - Only simple polygons are supported by filling functions (no self-intersections, no holes).
|
|
||||||
// - Concave polygon fill is more expensive than convex one: it has O(N^2) complexity. Provided as a convenience fo user but not used by main library.
|
|
||||||
IMGUI_API void AddPolyline(const ImVec2* points, int num_points, ImU32 col, ImDrawFlags flags, float thickness);
|
IMGUI_API void AddPolyline(const ImVec2* points, int num_points, ImU32 col, ImDrawFlags flags, float thickness);
|
||||||
IMGUI_API void AddConvexPolyFilled(const ImVec2* points, int num_points, ImU32 col);
|
IMGUI_API void AddConvexPolyFilled(const ImVec2* points, int num_points, ImU32 col);
|
||||||
IMGUI_API void AddConcavePolyFilled(const ImVec2* points, int num_points, ImU32 col);
|
IMGUI_API void AddBezierCubic(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness, int num_segments = 0); // Cubic Bezier (4 control points)
|
||||||
|
IMGUI_API void AddBezierQuadratic(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col, float thickness, int num_segments = 0); // Quadratic Bezier (3 control points)
|
||||||
|
|
||||||
// Image primitives
|
// Image primitives
|
||||||
// - Read FAQ to understand what ImTextureID is.
|
// - Read FAQ to understand what ImTextureID is.
|
||||||
@ -2838,17 +2765,15 @@ struct ImDrawList
|
|||||||
IMGUI_API void AddImageRounded(ImTextureID user_texture_id, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min, const ImVec2& uv_max, ImU32 col, float rounding, ImDrawFlags flags = 0);
|
IMGUI_API void AddImageRounded(ImTextureID user_texture_id, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min, const ImVec2& uv_max, ImU32 col, float rounding, ImDrawFlags flags = 0);
|
||||||
|
|
||||||
// Stateful path API, add points then finish with PathFillConvex() or PathStroke()
|
// Stateful path API, add points then finish with PathFillConvex() or PathStroke()
|
||||||
// - Important: filled shapes must always use clockwise winding order! The anti-aliasing fringe depends on it. Counter-clockwise shapes will have "inward" anti-aliasing.
|
// - Filled shapes must always use clockwise winding order. The anti-aliasing fringe depends on it. Counter-clockwise shapes will have "inward" anti-aliasing.
|
||||||
// so e.g. 'PathArcTo(center, radius, PI * -0.5f, PI)' is ok, whereas 'PathArcTo(center, radius, PI, PI * -0.5f)' won't have correct anti-aliasing when followed by PathFillConvex().
|
|
||||||
inline void PathClear() { _Path.Size = 0; }
|
inline void PathClear() { _Path.Size = 0; }
|
||||||
inline void PathLineTo(const ImVec2& pos) { _Path.push_back(pos); }
|
inline void PathLineTo(const ImVec2& pos) { _Path.push_back(pos); }
|
||||||
inline void PathLineToMergeDuplicate(const ImVec2& pos) { if (_Path.Size == 0 || memcmp(&_Path.Data[_Path.Size - 1], &pos, 8) != 0) _Path.push_back(pos); }
|
inline void PathLineToMergeDuplicate(const ImVec2& pos) { if (_Path.Size == 0 || memcmp(&_Path.Data[_Path.Size - 1], &pos, 8) != 0) _Path.push_back(pos); }
|
||||||
inline void PathFillConvex(ImU32 col) { AddConvexPolyFilled(_Path.Data, _Path.Size, col); _Path.Size = 0; }
|
inline void PathFillConvex(ImU32 col) { AddConvexPolyFilled(_Path.Data, _Path.Size, col); _Path.Size = 0; }
|
||||||
inline void PathFillConcave(ImU32 col) { AddConcavePolyFilled(_Path.Data, _Path.Size, col); _Path.Size = 0; }
|
|
||||||
inline void PathStroke(ImU32 col, ImDrawFlags flags = 0, float thickness = 1.0f) { AddPolyline(_Path.Data, _Path.Size, col, flags, thickness); _Path.Size = 0; }
|
inline void PathStroke(ImU32 col, ImDrawFlags flags = 0, float thickness = 1.0f) { AddPolyline(_Path.Data, _Path.Size, col, flags, thickness); _Path.Size = 0; }
|
||||||
IMGUI_API void PathArcTo(const ImVec2& center, float radius, float a_min, float a_max, int num_segments = 0);
|
IMGUI_API void PathArcTo(const ImVec2& center, float radius, float a_min, float a_max, int num_segments = 0);
|
||||||
IMGUI_API void PathArcToFast(const ImVec2& center, float radius, int a_min_of_12, int a_max_of_12); // Use precomputed angles for a 12 steps circle
|
IMGUI_API void PathArcToFast(const ImVec2& center, float radius, int a_min_of_12, int a_max_of_12); // Use precomputed angles for a 12 steps circle
|
||||||
IMGUI_API void PathEllipticalArcTo(const ImVec2& center, const ImVec2& radius, float rot, float a_min, float a_max, int num_segments = 0); // Ellipse
|
IMGUI_API void PathEllipticalArcTo(const ImVec2& center, float radius_x, float radius_y, float rot, float a_min, float a_max, int num_segments = 0); // Ellipse
|
||||||
IMGUI_API void PathBezierCubicCurveTo(const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, int num_segments = 0); // Cubic Bezier (4 control points)
|
IMGUI_API void PathBezierCubicCurveTo(const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, int num_segments = 0); // Cubic Bezier (4 control points)
|
||||||
IMGUI_API void PathBezierQuadraticCurveTo(const ImVec2& p2, const ImVec2& p3, int num_segments = 0); // Quadratic Bezier (3 control points)
|
IMGUI_API void PathBezierQuadraticCurveTo(const ImVec2& p2, const ImVec2& p3, int num_segments = 0); // Quadratic Bezier (3 control points)
|
||||||
IMGUI_API void PathRect(const ImVec2& rect_min, const ImVec2& rect_max, float rounding = 0.0f, ImDrawFlags flags = 0);
|
IMGUI_API void PathRect(const ImVec2& rect_min, const ImVec2& rect_max, float rounding = 0.0f, ImDrawFlags flags = 0);
|
||||||
@ -2881,9 +2806,6 @@ struct ImDrawList
|
|||||||
inline void PrimVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col) { PrimWriteIdx((ImDrawIdx)_VtxCurrentIdx); PrimWriteVtx(pos, uv, col); } // Write vertex with unique index
|
inline void PrimVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col) { PrimWriteIdx((ImDrawIdx)_VtxCurrentIdx); PrimWriteVtx(pos, uv, col); } // Write vertex with unique index
|
||||||
|
|
||||||
// Obsolete names
|
// Obsolete names
|
||||||
//inline void AddEllipse(const ImVec2& center, float radius_x, float radius_y, ImU32 col, float rot = 0.0f, int num_segments = 0, float thickness = 1.0f) { AddEllipse(center, ImVec2(radius_x, radius_y), col, rot, num_segments, thickness); } // OBSOLETED in 1.90.5 (Mar 2024)
|
|
||||||
//inline void AddEllipseFilled(const ImVec2& center, float radius_x, float radius_y, ImU32 col, float rot = 0.0f, int num_segments = 0) { AddEllipseFilled(center, ImVec2(radius_x, radius_y), col, rot, num_segments); } // OBSOLETED in 1.90.5 (Mar 2024)
|
|
||||||
//inline void PathEllipticalArcTo(const ImVec2& center, float radius_x, float radius_y, float rot, float a_min, float a_max, int num_segments = 0) { PathEllipticalArcTo(center, ImVec2(radius_x, radius_y), rot, a_min, a_max, num_segments); } // OBSOLETED in 1.90.5 (Mar 2024)
|
|
||||||
//inline void AddBezierCurve(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness, int num_segments = 0) { AddBezierCubic(p1, p2, p3, p4, col, thickness, num_segments); } // OBSOLETED in 1.80 (Jan 2021)
|
//inline void AddBezierCurve(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness, int num_segments = 0) { AddBezierCubic(p1, p2, p3, p4, col, thickness, num_segments); } // OBSOLETED in 1.80 (Jan 2021)
|
||||||
//inline void PathBezierCurveTo(const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, int num_segments = 0) { PathBezierCubicCurveTo(p2, p3, p4, num_segments); } // OBSOLETED in 1.80 (Jan 2021)
|
//inline void PathBezierCurveTo(const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, int num_segments = 0) { PathBezierCubicCurveTo(p2, p3, p4, num_segments); } // OBSOLETED in 1.80 (Jan 2021)
|
||||||
|
|
||||||
@ -3072,7 +2994,7 @@ struct ImFontAtlas
|
|||||||
|
|
||||||
// You can request arbitrary rectangles to be packed into the atlas, for your own purposes.
|
// You can request arbitrary rectangles to be packed into the atlas, for your own purposes.
|
||||||
// - After calling Build(), you can query the rectangle position and render your pixels.
|
// - After calling Build(), you can query the rectangle position and render your pixels.
|
||||||
// - If you render colored output, set 'atlas->TexPixelsUseColors = true' as this may help some backends decide of preferred texture format.
|
// - If you render colored output, set 'atlas->TexPixelsUseColors = true' as this may help some backends decide of prefered texture format.
|
||||||
// - You can also request your rectangles to be mapped as font glyph (given a font + Unicode point),
|
// - You can also request your rectangles to be mapped as font glyph (given a font + Unicode point),
|
||||||
// so you can render e.g. custom colorful icons and use them as regular glyphs.
|
// so you can render e.g. custom colorful icons and use them as regular glyphs.
|
||||||
// - Read docs/FONTS.md for more details about using colorful icons.
|
// - Read docs/FONTS.md for more details about using colorful icons.
|
||||||
@ -3201,7 +3123,6 @@ enum ImGuiViewportFlags_
|
|||||||
// - Windows are generally trying to stay within the Work Area of their host viewport.
|
// - Windows are generally trying to stay within the Work Area of their host viewport.
|
||||||
struct ImGuiViewport
|
struct ImGuiViewport
|
||||||
{
|
{
|
||||||
ImGuiID ID; // Unique identifier for the viewport
|
|
||||||
ImGuiViewportFlags Flags; // See ImGuiViewportFlags_
|
ImGuiViewportFlags Flags; // See ImGuiViewportFlags_
|
||||||
ImVec2 Pos; // Main Area: Position of the viewport (Dear ImGui coordinates are the same as OS desktop/native coordinates)
|
ImVec2 Pos; // Main Area: Position of the viewport (Dear ImGui coordinates are the same as OS desktop/native coordinates)
|
||||||
ImVec2 Size; // Main Area: Size of the viewport.
|
ImVec2 Size; // Main Area: Size of the viewport.
|
||||||
@ -3238,6 +3159,15 @@ struct ImGuiPlatformImeData
|
|||||||
// Please keep your copy of dear imgui up to date! Occasionally set '#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS' in imconfig.h to stay ahead.
|
// Please keep your copy of dear imgui up to date! Occasionally set '#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS' in imconfig.h to stay ahead.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace ImGui
|
||||||
|
{
|
||||||
|
#ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
|
||||||
|
IMGUI_API ImGuiKey GetKeyIndex(ImGuiKey key); // map ImGuiKey_* values into legacy native key index. == io.KeyMap[key]
|
||||||
|
#else
|
||||||
|
static inline ImGuiKey GetKeyIndex(ImGuiKey key) { IM_ASSERT(key >= ImGuiKey_NamedKey_BEGIN && key < ImGuiKey_NamedKey_END && "ImGuiKey and native_index was merged together and native_index is disabled by IMGUI_DISABLE_OBSOLETE_KEYIO. Please switch to ImGuiKey."); return key; }
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
namespace ImGui
|
namespace ImGui
|
||||||
{
|
{
|
||||||
@ -3256,14 +3186,11 @@ namespace ImGui
|
|||||||
static inline void PopAllowKeyboardFocus() { PopTabStop(); }
|
static inline void PopAllowKeyboardFocus() { PopTabStop(); }
|
||||||
// OBSOLETED in 1.89 (from August 2022)
|
// OBSOLETED in 1.89 (from August 2022)
|
||||||
IMGUI_API bool ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1, 1), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0, 0, 0, 0), const ImVec4& tint_col = ImVec4(1, 1, 1, 1)); // Use new ImageButton() signature (explicit item id, regular FramePadding)
|
IMGUI_API bool ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1, 1), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0, 0, 0, 0), const ImVec4& tint_col = ImVec4(1, 1, 1, 1)); // Use new ImageButton() signature (explicit item id, regular FramePadding)
|
||||||
// OBSOLETED in 1.87 (from February 2022)
|
// OBSOLETED in 1.88 (from May 2022)
|
||||||
IMGUI_API ImGuiKey GetKeyIndex(ImGuiKey key); // Map ImGuiKey_* values into legacy native key index. == io.KeyMap[key]. When using a 1.87+ backend using io.AddKeyEvent(), calling GetKeyIndex() with ANY ImGuiKey_XXXX values will return the same value!
|
static inline void CaptureKeyboardFromApp(bool want_capture_keyboard = true) { SetNextFrameWantCaptureKeyboard(want_capture_keyboard); } // Renamed as name was misleading + removed default value.
|
||||||
//static inline ImGuiKey GetKeyIndex(ImGuiKey key) { IM_ASSERT(key >= ImGuiKey_NamedKey_BEGIN && key < ImGuiKey_NamedKey_END); return key; }
|
static inline void CaptureMouseFromApp(bool want_capture_mouse = true) { SetNextFrameWantCaptureMouse(want_capture_mouse); } // Renamed as name was misleading + removed default value.
|
||||||
|
|
||||||
// Some of the older obsolete names along with their replacement (commented out so they are not reported in IDE)
|
// Some of the older obsolete names along with their replacement (commented out so they are not reported in IDE)
|
||||||
//-- OBSOLETED in 1.88 (from May 2022)
|
|
||||||
//static inline void CaptureKeyboardFromApp(bool want_capture_keyboard = true) { SetNextFrameWantCaptureKeyboard(want_capture_keyboard); } // Renamed as name was misleading + removed default value.
|
|
||||||
//static inline void CaptureMouseFromApp(bool want_capture_mouse = true) { SetNextFrameWantCaptureMouse(want_capture_mouse); } // Renamed as name was misleading + removed default value.
|
|
||||||
//-- OBSOLETED in 1.86 (from November 2021)
|
//-- OBSOLETED in 1.86 (from November 2021)
|
||||||
//IMGUI_API void CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end); // Code removed, see 1.90 for last version of the code. Calculate range of visible items for large list of evenly sized items. Prefer using ImGuiListClipper.
|
//IMGUI_API void CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end); // Code removed, see 1.90 for last version of the code. Calculate range of visible items for large list of evenly sized items. Prefer using ImGuiListClipper.
|
||||||
//-- OBSOLETED in 1.85 (from August 2021)
|
//-- OBSOLETED in 1.85 (from August 2021)
|
||||||
|
425
external/imgui/imgui/imgui_demo.cpp
vendored
425
external/imgui/imgui/imgui_demo.cpp
vendored
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.90.7
|
// dear imgui, v1.90.1
|
||||||
// (demo code)
|
// (demo code)
|
||||||
|
|
||||||
// Help:
|
// Help:
|
||||||
@ -7,14 +7,9 @@
|
|||||||
// - Need help integrating Dear ImGui in your codebase?
|
// - Need help integrating Dear ImGui in your codebase?
|
||||||
// - Read Getting Started https://github.com/ocornut/imgui/wiki/Getting-Started
|
// - Read Getting Started https://github.com/ocornut/imgui/wiki/Getting-Started
|
||||||
// - Read 'Programmer guide' in imgui.cpp for notes on how to setup Dear ImGui in your codebase.
|
// - Read 'Programmer guide' in imgui.cpp for notes on how to setup Dear ImGui in your codebase.
|
||||||
// Read top of imgui.cpp and imgui.h for many details, documentation, comments, links.
|
// Read imgui.cpp for more details, documentation and comments.
|
||||||
// Get the latest version at https://github.com/ocornut/imgui
|
// Get the latest version at https://github.com/ocornut/imgui
|
||||||
|
|
||||||
// How to easily locate code?
|
|
||||||
// - Use the Item Picker to debug break in code by clicking any widgets: https://github.com/ocornut/imgui/wiki/Debug-Tools
|
|
||||||
// - Browse an online version the demo with code linked to hovered widgets: https://pthom.github.io/imgui_manual_online/manual/imgui_manual.html
|
|
||||||
// - Find a visible string and search for it in the code!
|
|
||||||
|
|
||||||
//---------------------------------------------------
|
//---------------------------------------------------
|
||||||
// PLEASE DO NOT REMOVE THIS FILE FROM YOUR PROJECT!
|
// PLEASE DO NOT REMOVE THIS FILE FROM YOUR PROJECT!
|
||||||
//---------------------------------------------------
|
//---------------------------------------------------
|
||||||
@ -59,9 +54,8 @@
|
|||||||
// Because we can't assume anything about your support of maths operators, we cannot use them in imgui_demo.cpp.
|
// Because we can't assume anything about your support of maths operators, we cannot use them in imgui_demo.cpp.
|
||||||
|
|
||||||
// Navigating this file:
|
// Navigating this file:
|
||||||
// - In Visual Studio: CTRL+comma ("Edit.GoToAll") can follow symbols inside comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot.
|
// - In Visual Studio: CTRL+comma ("Edit.GoToAll") can follow symbols in comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot.
|
||||||
// - In Visual Studio w/ Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols inside comments.
|
// - With Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols in comments.
|
||||||
// - In VS Code, CLion, etc.: CTRL+click can follow symbols inside comments.
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
@ -136,7 +130,6 @@ Index of this file:
|
|||||||
#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double.
|
#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double.
|
||||||
#pragma clang diagnostic ignored "-Wreserved-id-macro" // warning: macro name is a reserved identifier
|
#pragma clang diagnostic ignored "-Wreserved-id-macro" // warning: macro name is a reserved identifier
|
||||||
#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision
|
#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision
|
||||||
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" // warning: 'xxx' is an unsafe pointer used for buffer access
|
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
||||||
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast" // warning: cast to pointer from integer of different size
|
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast" // warning: cast to pointer from integer of different size
|
||||||
@ -266,9 +259,6 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
// Most functions would normally just assert/crash if the context is missing.
|
// Most functions would normally just assert/crash if the context is missing.
|
||||||
IM_ASSERT(ImGui::GetCurrentContext() != NULL && "Missing Dear ImGui context. Refer to examples app!");
|
IM_ASSERT(ImGui::GetCurrentContext() != NULL && "Missing Dear ImGui context. Refer to examples app!");
|
||||||
|
|
||||||
// Verify ABI compatibility between caller code and compiled version of Dear ImGui. This helps detects some build issues.
|
|
||||||
IMGUI_CHECKVERSION();
|
|
||||||
|
|
||||||
// Examples Apps (accessible from the "Examples" menu)
|
// Examples Apps (accessible from the "Examples" menu)
|
||||||
static bool show_app_main_menu_bar = false;
|
static bool show_app_main_menu_bar = false;
|
||||||
static bool show_app_console = false;
|
static bool show_app_console = false;
|
||||||
@ -411,12 +401,6 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
ImGui::MenuItem("Debug Log", NULL, &show_tool_debug_log, has_debug_tools);
|
ImGui::MenuItem("Debug Log", NULL, &show_tool_debug_log, has_debug_tools);
|
||||||
ImGui::MenuItem("ID Stack Tool", NULL, &show_tool_id_stack_tool, has_debug_tools);
|
ImGui::MenuItem("ID Stack Tool", NULL, &show_tool_id_stack_tool, has_debug_tools);
|
||||||
ImGui::MenuItem("Style Editor", NULL, &show_tool_style_editor);
|
ImGui::MenuItem("Style Editor", NULL, &show_tool_style_editor);
|
||||||
bool is_debugger_present = ImGui::GetIO().ConfigDebugIsDebuggerPresent;
|
|
||||||
if (ImGui::MenuItem("Item Picker", NULL, false, has_debug_tools && is_debugger_present))
|
|
||||||
ImGui::DebugStartItemPicker();
|
|
||||||
if (!is_debugger_present)
|
|
||||||
ImGui::SetItemTooltip("Requires io.ConfigDebugIsDebuggerPresent=true to be set.\n\nWe otherwise disable the menu option to avoid casual users crashing the application.\n\nYou can however always access the Item Picker in Metrics->Tools.");
|
|
||||||
ImGui::Separator();
|
|
||||||
ImGui::MenuItem("About Dear ImGui", NULL, &show_tool_about);
|
ImGui::MenuItem("About Dear ImGui", NULL, &show_tool_about);
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
@ -491,7 +475,6 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
ImGui::SameLine(); HelpMarker("Enable resizing of windows from their edges and from the lower-left corner.\nThis requires (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) because it needs mouse cursor feedback.");
|
ImGui::SameLine(); HelpMarker("Enable resizing of windows from their edges and from the lower-left corner.\nThis requires (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) because it needs mouse cursor feedback.");
|
||||||
ImGui::Checkbox("io.ConfigWindowsMoveFromTitleBarOnly", &io.ConfigWindowsMoveFromTitleBarOnly);
|
ImGui::Checkbox("io.ConfigWindowsMoveFromTitleBarOnly", &io.ConfigWindowsMoveFromTitleBarOnly);
|
||||||
ImGui::Checkbox("io.ConfigMacOSXBehaviors", &io.ConfigMacOSXBehaviors);
|
ImGui::Checkbox("io.ConfigMacOSXBehaviors", &io.ConfigMacOSXBehaviors);
|
||||||
ImGui::SameLine(); HelpMarker("Swap Cmd<>Ctrl keys, enable various MacOS style behaviors.");
|
|
||||||
ImGui::Text("Also see Style->Rendering for rendering options.");
|
ImGui::Text("Also see Style->Rendering for rendering options.");
|
||||||
|
|
||||||
ImGui::SeparatorText("Debug");
|
ImGui::SeparatorText("Debug");
|
||||||
@ -910,18 +893,13 @@ static void ShowDemoWindowWidgets()
|
|||||||
if (i == 0)
|
if (i == 0)
|
||||||
ImGui::SetNextItemOpen(true, ImGuiCond_Once);
|
ImGui::SetNextItemOpen(true, ImGuiCond_Once);
|
||||||
|
|
||||||
// Here we use PushID() to generate a unique base ID, and then the "" used as TreeNode id won't conflict.
|
if (ImGui::TreeNode((void*)(intptr_t)i, "Child %d", i))
|
||||||
// An alternative to using 'PushID() + TreeNode("", ...)' to generate a unique ID is to use 'TreeNode((void*)(intptr_t)i, ...)',
|
|
||||||
// aka generate a dummy pointer-sized value to be hashed. The demo below uses that technique. Both are fine.
|
|
||||||
ImGui::PushID(i);
|
|
||||||
if (ImGui::TreeNode("", "Child %d", i))
|
|
||||||
{
|
{
|
||||||
ImGui::Text("blah blah");
|
ImGui::Text("blah blah");
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::SmallButton("button")) {}
|
if (ImGui::SmallButton("button")) {}
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
ImGui::PopID();
|
|
||||||
}
|
}
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
@ -939,10 +917,7 @@ static void ShowDemoWindowWidgets()
|
|||||||
ImGui::CheckboxFlags("ImGuiTreeNodeFlags_OpenOnDoubleClick", &base_flags, ImGuiTreeNodeFlags_OpenOnDoubleClick);
|
ImGui::CheckboxFlags("ImGuiTreeNodeFlags_OpenOnDoubleClick", &base_flags, ImGuiTreeNodeFlags_OpenOnDoubleClick);
|
||||||
ImGui::CheckboxFlags("ImGuiTreeNodeFlags_SpanAvailWidth", &base_flags, ImGuiTreeNodeFlags_SpanAvailWidth); ImGui::SameLine(); HelpMarker("Extend hit area to all available width instead of allowing more items to be laid out after the node.");
|
ImGui::CheckboxFlags("ImGuiTreeNodeFlags_SpanAvailWidth", &base_flags, ImGuiTreeNodeFlags_SpanAvailWidth); ImGui::SameLine(); HelpMarker("Extend hit area to all available width instead of allowing more items to be laid out after the node.");
|
||||||
ImGui::CheckboxFlags("ImGuiTreeNodeFlags_SpanFullWidth", &base_flags, ImGuiTreeNodeFlags_SpanFullWidth);
|
ImGui::CheckboxFlags("ImGuiTreeNodeFlags_SpanFullWidth", &base_flags, ImGuiTreeNodeFlags_SpanFullWidth);
|
||||||
ImGui::CheckboxFlags("ImGuiTreeNodeFlags_SpanTextWidth", &base_flags, ImGuiTreeNodeFlags_SpanTextWidth); ImGui::SameLine(); HelpMarker("Reduce hit area to the text label and a bit of margin.");
|
|
||||||
ImGui::CheckboxFlags("ImGuiTreeNodeFlags_SpanAllColumns", &base_flags, ImGuiTreeNodeFlags_SpanAllColumns); ImGui::SameLine(); HelpMarker("For use in Tables only.");
|
ImGui::CheckboxFlags("ImGuiTreeNodeFlags_SpanAllColumns", &base_flags, ImGuiTreeNodeFlags_SpanAllColumns); ImGui::SameLine(); HelpMarker("For use in Tables only.");
|
||||||
ImGui::CheckboxFlags("ImGuiTreeNodeFlags_AllowOverlap", &base_flags, ImGuiTreeNodeFlags_AllowOverlap);
|
|
||||||
ImGui::CheckboxFlags("ImGuiTreeNodeFlags_Framed", &base_flags, ImGuiTreeNodeFlags_Framed); ImGui::SameLine(); HelpMarker("Draw frame with background (e.g. for CollapsingHeader)");
|
|
||||||
ImGui::Checkbox("Align label with current X position", &align_label_with_current_x_position);
|
ImGui::Checkbox("Align label with current X position", &align_label_with_current_x_position);
|
||||||
ImGui::Checkbox("Test tree node as drag source", &test_drag_and_drop);
|
ImGui::Checkbox("Test tree node as drag source", &test_drag_and_drop);
|
||||||
ImGui::Text("Hello!");
|
ImGui::Text("Hello!");
|
||||||
@ -975,12 +950,6 @@ static void ShowDemoWindowWidgets()
|
|||||||
ImGui::Text("This is a drag and drop source");
|
ImGui::Text("This is a drag and drop source");
|
||||||
ImGui::EndDragDropSource();
|
ImGui::EndDragDropSource();
|
||||||
}
|
}
|
||||||
if (i == 2)
|
|
||||||
{
|
|
||||||
// Item 2 has an additional inline button to help demonstrate SpanTextWidth.
|
|
||||||
ImGui::SameLine();
|
|
||||||
if (ImGui::SmallButton("button")) {}
|
|
||||||
}
|
|
||||||
if (node_open)
|
if (node_open)
|
||||||
{
|
{
|
||||||
ImGui::BulletText("Blah blah\nBlah Blah");
|
ImGui::BulletText("Blah blah\nBlah Blah");
|
||||||
@ -1313,7 +1282,6 @@ static void ShowDemoWindowWidgets()
|
|||||||
}
|
}
|
||||||
ImGui::EndListBox();
|
ImGui::EndListBox();
|
||||||
}
|
}
|
||||||
ImGui::SameLine(); HelpMarker("Here we are sharing selection state between both boxes.");
|
|
||||||
|
|
||||||
// Custom size: use all width, 5 items tall
|
// Custom size: use all width, 5 items tall
|
||||||
ImGui::Text("Full-width:");
|
ImGui::Text("Full-width:");
|
||||||
@ -1844,10 +1812,10 @@ static void ShowDemoWindowWidgets()
|
|||||||
ImGui::Checkbox("Animate", &animate);
|
ImGui::Checkbox("Animate", &animate);
|
||||||
|
|
||||||
// Plot as lines and plot as histogram
|
// Plot as lines and plot as histogram
|
||||||
|
IMGUI_DEMO_MARKER("Widgets/Plotting/PlotLines, PlotHistogram");
|
||||||
static float arr[] = { 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f };
|
static float arr[] = { 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f };
|
||||||
ImGui::PlotLines("Frame Times", arr, IM_ARRAYSIZE(arr));
|
ImGui::PlotLines("Frame Times", arr, IM_ARRAYSIZE(arr));
|
||||||
ImGui::PlotHistogram("Histogram", arr, IM_ARRAYSIZE(arr), 0, NULL, 0.0f, 1.0f, ImVec2(0, 80.0f));
|
ImGui::PlotHistogram("Histogram", arr, IM_ARRAYSIZE(arr), 0, NULL, 0.0f, 1.0f, ImVec2(0, 80.0f));
|
||||||
//ImGui::SameLine(); HelpMarker("Consider using ImPlot instead!");
|
|
||||||
|
|
||||||
// Fill an array of contiguous float values to plot
|
// Fill an array of contiguous float values to plot
|
||||||
// Tip: If your float aren't contiguous but part of a structure, you can pass a pointer to your first float
|
// Tip: If your float aren't contiguous but part of a structure, you can pass a pointer to your first float
|
||||||
@ -1897,17 +1865,15 @@ static void ShowDemoWindowWidgets()
|
|||||||
ImGui::PlotHistogram("Histogram", func, NULL, display_count, 0, NULL, -1.0f, 1.0f, ImVec2(0, 80));
|
ImGui::PlotHistogram("Histogram", func, NULL, display_count, 0, NULL, -1.0f, 1.0f, ImVec2(0, 80));
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
ImGui::TreePop();
|
|
||||||
}
|
|
||||||
|
|
||||||
IMGUI_DEMO_MARKER("Widgets/Progress Bars");
|
|
||||||
if (ImGui::TreeNode("Progress Bars"))
|
|
||||||
{
|
|
||||||
// Animate a simple progress bar
|
// Animate a simple progress bar
|
||||||
|
IMGUI_DEMO_MARKER("Widgets/Plotting/ProgressBar");
|
||||||
static float progress = 0.0f, progress_dir = 1.0f;
|
static float progress = 0.0f, progress_dir = 1.0f;
|
||||||
|
if (animate)
|
||||||
|
{
|
||||||
progress += progress_dir * 0.4f * ImGui::GetIO().DeltaTime;
|
progress += progress_dir * 0.4f * ImGui::GetIO().DeltaTime;
|
||||||
if (progress >= +1.1f) { progress = +1.1f; progress_dir *= -1.0f; }
|
if (progress >= +1.1f) { progress = +1.1f; progress_dir *= -1.0f; }
|
||||||
if (progress <= -0.1f) { progress = -0.1f; progress_dir *= -1.0f; }
|
if (progress <= -0.1f) { progress = -0.1f; progress_dir *= -1.0f; }
|
||||||
|
}
|
||||||
|
|
||||||
// Typically we would use ImVec2(-1.0f,0.0f) or ImVec2(-FLT_MIN,0.0f) to use all available width,
|
// Typically we would use ImVec2(-1.0f,0.0f) or ImVec2(-FLT_MIN,0.0f) to use all available width,
|
||||||
// or ImVec2(width,0.0f) for a specified width. ImVec2(0.0f,0.0f) uses ItemWidth.
|
// or ImVec2(width,0.0f) for a specified width. ImVec2(0.0f,0.0f) uses ItemWidth.
|
||||||
@ -1919,13 +1885,6 @@ static void ShowDemoWindowWidgets()
|
|||||||
char buf[32];
|
char buf[32];
|
||||||
sprintf(buf, "%d/%d", (int)(progress_saturated * 1753), 1753);
|
sprintf(buf, "%d/%d", (int)(progress_saturated * 1753), 1753);
|
||||||
ImGui::ProgressBar(progress, ImVec2(0.f, 0.f), buf);
|
ImGui::ProgressBar(progress, ImVec2(0.f, 0.f), buf);
|
||||||
|
|
||||||
// Pass an animated negative value, e.g. -1.0f * (float)ImGui::GetTime() is the recommended value.
|
|
||||||
// Adjust the factor if you want to adjust the animation speed.
|
|
||||||
ImGui::ProgressBar(-1.0f * (float)ImGui::GetTime(), ImVec2(0.0f, 0.0f), "Searching..");
|
|
||||||
ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x);
|
|
||||||
ImGui::Text("Indeterminate");
|
|
||||||
|
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2516,7 +2475,9 @@ static void ShowDemoWindowWidgets()
|
|||||||
{
|
{
|
||||||
IM_UNUSED(payload);
|
IM_UNUSED(payload);
|
||||||
ImGui::SetMouseCursor(ImGuiMouseCursor_NotAllowed);
|
ImGui::SetMouseCursor(ImGuiMouseCursor_NotAllowed);
|
||||||
ImGui::SetTooltip("Cannot drop here!");
|
ImGui::BeginTooltip();
|
||||||
|
ImGui::Text("Cannot drop here!");
|
||||||
|
ImGui::EndTooltip();
|
||||||
}
|
}
|
||||||
ImGui::EndDragDropTarget();
|
ImGui::EndDragDropTarget();
|
||||||
}
|
}
|
||||||
@ -5173,7 +5134,6 @@ static void ShowDemoWindowTables()
|
|||||||
|
|
||||||
static ImGuiTreeNodeFlags tree_node_flags = ImGuiTreeNodeFlags_SpanAllColumns;
|
static ImGuiTreeNodeFlags tree_node_flags = ImGuiTreeNodeFlags_SpanAllColumns;
|
||||||
ImGui::CheckboxFlags("ImGuiTreeNodeFlags_SpanFullWidth", &tree_node_flags, ImGuiTreeNodeFlags_SpanFullWidth);
|
ImGui::CheckboxFlags("ImGuiTreeNodeFlags_SpanFullWidth", &tree_node_flags, ImGuiTreeNodeFlags_SpanFullWidth);
|
||||||
ImGui::CheckboxFlags("ImGuiTreeNodeFlags_SpanTextWidth", &tree_node_flags, ImGuiTreeNodeFlags_SpanTextWidth);
|
|
||||||
ImGui::CheckboxFlags("ImGuiTreeNodeFlags_SpanAllColumns", &tree_node_flags, ImGuiTreeNodeFlags_SpanAllColumns);
|
ImGui::CheckboxFlags("ImGuiTreeNodeFlags_SpanAllColumns", &tree_node_flags, ImGuiTreeNodeFlags_SpanAllColumns);
|
||||||
|
|
||||||
HelpMarker("See \"Columns flags\" section to configure how indentation is applied to individual columns.");
|
HelpMarker("See \"Columns flags\" section to configure how indentation is applied to individual columns.");
|
||||||
@ -5347,37 +5307,23 @@ static void ShowDemoWindowTables()
|
|||||||
const int rows_count = 12;
|
const int rows_count = 12;
|
||||||
|
|
||||||
static ImGuiTableFlags table_flags = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersInnerH | ImGuiTableFlags_Hideable | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_HighlightHoveredColumn;
|
static ImGuiTableFlags table_flags = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersInnerH | ImGuiTableFlags_Hideable | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_HighlightHoveredColumn;
|
||||||
static ImGuiTableColumnFlags column_flags = ImGuiTableColumnFlags_AngledHeader | ImGuiTableColumnFlags_WidthFixed;
|
|
||||||
static bool bools[columns_count * rows_count] = {}; // Dummy storage selection storage
|
static bool bools[columns_count * rows_count] = {}; // Dummy storage selection storage
|
||||||
static int frozen_cols = 1;
|
static int frozen_cols = 1;
|
||||||
static int frozen_rows = 2;
|
static int frozen_rows = 2;
|
||||||
ImGui::CheckboxFlags("_ScrollX", &table_flags, ImGuiTableFlags_ScrollX);
|
ImGui::CheckboxFlags("_ScrollX", &table_flags, ImGuiTableFlags_ScrollX);
|
||||||
ImGui::CheckboxFlags("_ScrollY", &table_flags, ImGuiTableFlags_ScrollY);
|
ImGui::CheckboxFlags("_ScrollY", &table_flags, ImGuiTableFlags_ScrollY);
|
||||||
ImGui::CheckboxFlags("_Resizable", &table_flags, ImGuiTableFlags_Resizable);
|
|
||||||
ImGui::CheckboxFlags("_NoBordersInBody", &table_flags, ImGuiTableFlags_NoBordersInBody);
|
ImGui::CheckboxFlags("_NoBordersInBody", &table_flags, ImGuiTableFlags_NoBordersInBody);
|
||||||
ImGui::CheckboxFlags("_HighlightHoveredColumn", &table_flags, ImGuiTableFlags_HighlightHoveredColumn);
|
ImGui::CheckboxFlags("_HighlightHoveredColumn", &table_flags, ImGuiTableFlags_HighlightHoveredColumn);
|
||||||
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 8);
|
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 8);
|
||||||
ImGui::SliderInt("Frozen columns", &frozen_cols, 0, 2);
|
ImGui::SliderInt("Frozen columns", &frozen_cols, 0, 2);
|
||||||
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 8);
|
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 8);
|
||||||
ImGui::SliderInt("Frozen rows", &frozen_rows, 0, 2);
|
ImGui::SliderInt("Frozen rows", &frozen_rows, 0, 2);
|
||||||
ImGui::CheckboxFlags("Disable header contributing to column width", &column_flags, ImGuiTableColumnFlags_NoHeaderWidth);
|
|
||||||
|
|
||||||
if (ImGui::TreeNode("Style settings"))
|
|
||||||
{
|
|
||||||
ImGui::SameLine();
|
|
||||||
HelpMarker("Giving access to some ImGuiStyle value in this demo for convenience.");
|
|
||||||
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 8);
|
|
||||||
ImGui::SliderAngle("style.TableAngledHeadersAngle", &ImGui::GetStyle().TableAngledHeadersAngle, -50.0f, +50.0f);
|
|
||||||
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 8);
|
|
||||||
ImGui::SliderFloat2("style.TableAngledHeadersTextAlign", (float*)&ImGui::GetStyle().TableAngledHeadersTextAlign, 0.0f, 1.0f, "%.2f");
|
|
||||||
ImGui::TreePop();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ImGui::BeginTable("table_angled_headers", columns_count, table_flags, ImVec2(0.0f, TEXT_BASE_HEIGHT * 12)))
|
if (ImGui::BeginTable("table_angled_headers", columns_count, table_flags, ImVec2(0.0f, TEXT_BASE_HEIGHT * 12)))
|
||||||
{
|
{
|
||||||
ImGui::TableSetupColumn(column_names[0], ImGuiTableColumnFlags_NoHide | ImGuiTableColumnFlags_NoReorder);
|
ImGui::TableSetupColumn(column_names[0], ImGuiTableColumnFlags_NoHide | ImGuiTableColumnFlags_NoReorder);
|
||||||
for (int n = 1; n < columns_count; n++)
|
for (int n = 1; n < columns_count; n++)
|
||||||
ImGui::TableSetupColumn(column_names[n], column_flags);
|
ImGui::TableSetupColumn(column_names[n], ImGuiTableColumnFlags_AngledHeader | ImGuiTableColumnFlags_WidthFixed);
|
||||||
ImGui::TableSetupScrollFreeze(frozen_cols, frozen_rows);
|
ImGui::TableSetupScrollFreeze(frozen_cols, frozen_rows);
|
||||||
|
|
||||||
ImGui::TableAngledHeadersRow(); // Draw angled headers for all columns with the ImGuiTableColumnFlags_AngledHeader flag.
|
ImGui::TableAngledHeadersRow(); // Draw angled headers for all columns with the ImGuiTableColumnFlags_AngledHeader flag.
|
||||||
@ -5524,7 +5470,6 @@ static void ShowDemoWindowTables()
|
|||||||
HelpMarker("Multiple tables with the same identifier will share their settings, width, visibility, order etc.");
|
HelpMarker("Multiple tables with the same identifier will share their settings, width, visibility, order etc.");
|
||||||
|
|
||||||
static ImGuiTableFlags flags = ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Borders | ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_NoSavedSettings;
|
static ImGuiTableFlags flags = ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Borders | ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_NoSavedSettings;
|
||||||
ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags, ImGuiTableFlags_Resizable);
|
|
||||||
ImGui::CheckboxFlags("ImGuiTableFlags_ScrollY", &flags, ImGuiTableFlags_ScrollY);
|
ImGui::CheckboxFlags("ImGuiTableFlags_ScrollY", &flags, ImGuiTableFlags_ScrollY);
|
||||||
ImGui::CheckboxFlags("ImGuiTableFlags_SizingFixedFit", &flags, ImGuiTableFlags_SizingFixedFit);
|
ImGui::CheckboxFlags("ImGuiTableFlags_SizingFixedFit", &flags, ImGuiTableFlags_SizingFixedFit);
|
||||||
ImGui::CheckboxFlags("ImGuiTableFlags_HighlightHoveredColumn", &flags, ImGuiTableFlags_HighlightHoveredColumn);
|
ImGui::CheckboxFlags("ImGuiTableFlags_HighlightHoveredColumn", &flags, ImGuiTableFlags_HighlightHoveredColumn);
|
||||||
@ -6184,14 +6129,12 @@ static void ShowDemoWindowInputs()
|
|||||||
// Display inputs submitted to ImGuiIO
|
// Display inputs submitted to ImGuiIO
|
||||||
IMGUI_DEMO_MARKER("Inputs & Focus/Inputs");
|
IMGUI_DEMO_MARKER("Inputs & Focus/Inputs");
|
||||||
ImGui::SetNextItemOpen(true, ImGuiCond_Once);
|
ImGui::SetNextItemOpen(true, ImGuiCond_Once);
|
||||||
bool inputs_opened = ImGui::TreeNode("Inputs");
|
if (ImGui::TreeNode("Inputs"))
|
||||||
ImGui::SameLine();
|
{
|
||||||
HelpMarker(
|
HelpMarker(
|
||||||
"This is a simplified view. See more detailed input state:\n"
|
"This is a simplified view. See more detailed input state:\n"
|
||||||
"- in 'Tools->Metrics/Debugger->Inputs'.\n"
|
"- in 'Tools->Metrics/Debugger->Inputs'.\n"
|
||||||
"- in 'Tools->Debug Log->IO'.");
|
"- in 'Tools->Debug Log->IO'.");
|
||||||
if (inputs_opened)
|
|
||||||
{
|
|
||||||
if (ImGui::IsMousePosValid())
|
if (ImGui::IsMousePosValid())
|
||||||
ImGui::Text("Mouse pos: (%g, %g)", io.MousePos.x, io.MousePos.y);
|
ImGui::Text("Mouse pos: (%g, %g)", io.MousePos.x, io.MousePos.y);
|
||||||
else
|
else
|
||||||
@ -6222,8 +6165,8 @@ static void ShowDemoWindowInputs()
|
|||||||
// Display ImGuiIO output flags
|
// Display ImGuiIO output flags
|
||||||
IMGUI_DEMO_MARKER("Inputs & Focus/Outputs");
|
IMGUI_DEMO_MARKER("Inputs & Focus/Outputs");
|
||||||
ImGui::SetNextItemOpen(true, ImGuiCond_Once);
|
ImGui::SetNextItemOpen(true, ImGuiCond_Once);
|
||||||
bool outputs_opened = ImGui::TreeNode("Outputs");
|
if (ImGui::TreeNode("Outputs"))
|
||||||
ImGui::SameLine();
|
{
|
||||||
HelpMarker(
|
HelpMarker(
|
||||||
"The value of io.WantCaptureMouse and io.WantCaptureKeyboard are normally set by Dear ImGui "
|
"The value of io.WantCaptureMouse and io.WantCaptureKeyboard are normally set by Dear ImGui "
|
||||||
"to instruct your application of how to route inputs. Typically, when a value is true, it means "
|
"to instruct your application of how to route inputs. Typically, when a value is true, it means "
|
||||||
@ -6231,8 +6174,6 @@ static void ShowDemoWindowInputs()
|
|||||||
"The most typical case is: when hovering a window, Dear ImGui set io.WantCaptureMouse to true, "
|
"The most typical case is: when hovering a window, Dear ImGui set io.WantCaptureMouse to true, "
|
||||||
"and underlying application should ignore mouse inputs (in practice there are many and more subtle "
|
"and underlying application should ignore mouse inputs (in practice there are many and more subtle "
|
||||||
"rules leading to how those flags are set).");
|
"rules leading to how those flags are set).");
|
||||||
if (outputs_opened)
|
|
||||||
{
|
|
||||||
ImGui::Text("io.WantCaptureMouse: %d", io.WantCaptureMouse);
|
ImGui::Text("io.WantCaptureMouse: %d", io.WantCaptureMouse);
|
||||||
ImGui::Text("io.WantCaptureMouseUnlessPopupClose: %d", io.WantCaptureMouseUnlessPopupClose);
|
ImGui::Text("io.WantCaptureMouseUnlessPopupClose: %d", io.WantCaptureMouseUnlessPopupClose);
|
||||||
ImGui::Text("io.WantCaptureKeyboard: %d", io.WantCaptureKeyboard);
|
ImGui::Text("io.WantCaptureKeyboard: %d", io.WantCaptureKeyboard);
|
||||||
@ -6266,102 +6207,6 @@ static void ShowDemoWindowInputs()
|
|||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Demonstrate using Shortcut() and Routing Policies.
|
|
||||||
// The general flow is:
|
|
||||||
// - Code interested in a chord (e.g. "Ctrl+A") declares their intent.
|
|
||||||
// - Multiple locations may be interested in same chord! Routing helps find a winner.
|
|
||||||
// - Every frame, we resolve all claims and assign one owner if the modifiers are matching.
|
|
||||||
// - The lower-level function is 'bool SetShortcutRouting()', returns true when caller got the route.
|
|
||||||
// - Most of the times, SetShortcutRouting() is not called directly. User mostly calls Shortcut() with routing flags.
|
|
||||||
// - If you call Shortcut() WITHOUT any routing option, it uses ImGuiInputFlags_RouteFocused.
|
|
||||||
// TL;DR: Most uses will simply be:
|
|
||||||
// - Shortcut(ImGuiMod_Ctrl | ImGuiKey_A); // Use ImGuiInputFlags_RouteFocused policy.
|
|
||||||
IMGUI_DEMO_MARKER("Inputs & Focus/Shortcuts");
|
|
||||||
if (ImGui::TreeNode("Shortcuts"))
|
|
||||||
{
|
|
||||||
static ImGuiInputFlags route_options = ImGuiInputFlags_Repeat;
|
|
||||||
static ImGuiInputFlags route_type = ImGuiInputFlags_RouteFocused;
|
|
||||||
ImGui::CheckboxFlags("ImGuiInputFlags_Repeat", &route_options, ImGuiInputFlags_Repeat);
|
|
||||||
ImGui::RadioButton("ImGuiInputFlags_RouteActive", &route_type, ImGuiInputFlags_RouteActive);
|
|
||||||
ImGui::RadioButton("ImGuiInputFlags_RouteFocused (default)", &route_type, ImGuiInputFlags_RouteFocused);
|
|
||||||
ImGui::RadioButton("ImGuiInputFlags_RouteGlobal", &route_type, ImGuiInputFlags_RouteGlobal);
|
|
||||||
ImGui::Indent();
|
|
||||||
ImGui::BeginDisabled(route_type != ImGuiInputFlags_RouteGlobal);
|
|
||||||
ImGui::CheckboxFlags("ImGuiInputFlags_RouteOverFocused", &route_options, ImGuiInputFlags_RouteOverFocused);
|
|
||||||
ImGui::CheckboxFlags("ImGuiInputFlags_RouteOverActive", &route_options, ImGuiInputFlags_RouteOverActive);
|
|
||||||
ImGui::CheckboxFlags("ImGuiInputFlags_RouteUnlessBgFocused", &route_options, ImGuiInputFlags_RouteUnlessBgFocused);
|
|
||||||
ImGui::EndDisabled();
|
|
||||||
ImGui::Unindent();
|
|
||||||
ImGui::RadioButton("ImGuiInputFlags_RouteAlways", &route_type, ImGuiInputFlags_RouteAlways);
|
|
||||||
ImGuiInputFlags flags = route_type | route_options; // Merged flags
|
|
||||||
if (route_type != ImGuiInputFlags_RouteGlobal)
|
|
||||||
route_options &= ~(ImGuiInputFlags_RouteOverFocused | ImGuiInputFlags_RouteOverActive | ImGuiInputFlags_RouteUnlessBgFocused);
|
|
||||||
|
|
||||||
ImGui::SeparatorText("Using SetNextItemShortcut()");
|
|
||||||
ImGui::Text("Ctrl+S");
|
|
||||||
ImGui::SetNextItemShortcut(ImGuiMod_Ctrl | ImGuiKey_S, flags | ImGuiInputFlags_Tooltip);
|
|
||||||
ImGui::Button("Save");
|
|
||||||
ImGui::Text("Alt+F");
|
|
||||||
ImGui::SetNextItemShortcut(ImGuiMod_Alt | ImGuiKey_F, flags | ImGuiInputFlags_Tooltip);
|
|
||||||
static float f = 0.5f;
|
|
||||||
ImGui::SliderFloat("Factor", &f, 0.0f, 1.0f);
|
|
||||||
|
|
||||||
ImGui::SeparatorText("Using Shortcut()");
|
|
||||||
const float line_height = ImGui::GetTextLineHeightWithSpacing();
|
|
||||||
const ImGuiKeyChord key_chord = ImGuiMod_Ctrl | ImGuiKey_A;
|
|
||||||
|
|
||||||
ImGui::Text("Ctrl+A");
|
|
||||||
ImGui::Text("IsWindowFocused: %d, Shortcut: %s", ImGui::IsWindowFocused(), ImGui::Shortcut(key_chord, flags) ? "PRESSED" : "...");
|
|
||||||
|
|
||||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(1.0f, 0.0f, 1.0f, 0.1f));
|
|
||||||
|
|
||||||
ImGui::BeginChild("WindowA", ImVec2(-FLT_MIN, line_height * 14), true);
|
|
||||||
ImGui::Text("Press CTRL+A and see who receives it!");
|
|
||||||
ImGui::Separator();
|
|
||||||
|
|
||||||
// 1: Window polling for CTRL+A
|
|
||||||
ImGui::Text("(in WindowA)");
|
|
||||||
ImGui::Text("IsWindowFocused: %d, Shortcut: %s", ImGui::IsWindowFocused(), ImGui::Shortcut(key_chord, flags) ? "PRESSED" : "...");
|
|
||||||
|
|
||||||
// 2: InputText also polling for CTRL+A: it always uses _RouteFocused internally (gets priority when active)
|
|
||||||
// (Commmented because the owner-aware version of Shortcut() is still in imgui_internal.h)
|
|
||||||
//char str[16] = "Press CTRL+A";
|
|
||||||
//ImGui::Spacing();
|
|
||||||
//ImGui::InputText("InputTextB", str, IM_ARRAYSIZE(str), ImGuiInputTextFlags_ReadOnly);
|
|
||||||
//ImGuiID item_id = ImGui::GetItemID();
|
|
||||||
//ImGui::SameLine(); HelpMarker("Internal widgets always use _RouteFocused");
|
|
||||||
//ImGui::Text("IsWindowFocused: %d, Shortcut: %s", ImGui::IsWindowFocused(), ImGui::Shortcut(key_chord, flags, item_id) ? "PRESSED" : "...");
|
|
||||||
|
|
||||||
// 3: Dummy child is not claiming the route: focusing them shouldn't steal route away from WindowA
|
|
||||||
ImGui::BeginChild("ChildD", ImVec2(-FLT_MIN, line_height * 4), true);
|
|
||||||
ImGui::Text("(in ChildD: not using same Shortcut)");
|
|
||||||
ImGui::Text("IsWindowFocused: %d", ImGui::IsWindowFocused());
|
|
||||||
ImGui::EndChild();
|
|
||||||
|
|
||||||
// 4: Child window polling for CTRL+A. It is deeper than WindowA and gets priority when focused.
|
|
||||||
ImGui::BeginChild("ChildE", ImVec2(-FLT_MIN, line_height * 4), true);
|
|
||||||
ImGui::Text("(in ChildE: using same Shortcut)");
|
|
||||||
ImGui::Text("IsWindowFocused: %d, Shortcut: %s", ImGui::IsWindowFocused(), ImGui::Shortcut(key_chord, flags) ? "PRESSED" : "...");
|
|
||||||
ImGui::EndChild();
|
|
||||||
|
|
||||||
// 5: In a popup
|
|
||||||
if (ImGui::Button("Open Popup"))
|
|
||||||
ImGui::OpenPopup("PopupF");
|
|
||||||
if (ImGui::BeginPopup("PopupF"))
|
|
||||||
{
|
|
||||||
ImGui::Text("(in PopupF)");
|
|
||||||
ImGui::Text("IsWindowFocused: %d, Shortcut: %s", ImGui::IsWindowFocused(), ImGui::Shortcut(key_chord, flags) ? "PRESSED" : "...");
|
|
||||||
// (Commmented because the owner-aware version of Shortcut() is still in imgui_internal.h)
|
|
||||||
//ImGui::InputText("InputTextG", str, IM_ARRAYSIZE(str), ImGuiInputTextFlags_ReadOnly);
|
|
||||||
//ImGui::Text("IsWindowFocused: %d, Shortcut: %s", ImGui::IsWindowFocused(), ImGui::Shortcut(key_chord, flags, ImGui::GetItemID()) ? "PRESSED" : "...");
|
|
||||||
ImGui::EndPopup();
|
|
||||||
}
|
|
||||||
ImGui::EndChild();
|
|
||||||
ImGui::PopStyleColor();
|
|
||||||
|
|
||||||
ImGui::TreePop();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Display mouse cursors
|
// Display mouse cursors
|
||||||
IMGUI_DEMO_MARKER("Inputs & Focus/Mouse Cursors");
|
IMGUI_DEMO_MARKER("Inputs & Focus/Mouse Cursors");
|
||||||
if (ImGui::TreeNode("Mouse Cursors"))
|
if (ImGui::TreeNode("Mouse Cursors"))
|
||||||
@ -6497,7 +6342,7 @@ void ImGui::ShowAboutWindow(bool* p_open)
|
|||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
ImGui::Text("By Omar Cornut and all Dear ImGui contributors.");
|
ImGui::Text("By Omar Cornut and all Dear ImGui contributors.");
|
||||||
ImGui::Text("Dear ImGui is licensed under the MIT License, see LICENSE for more information.");
|
ImGui::Text("Dear ImGui is licensed under the MIT License, see LICENSE for more information.");
|
||||||
ImGui::Text("If your company uses this, please consider funding the project.");
|
ImGui::Text("If your company uses this, please consider sponsoring the project!");
|
||||||
|
|
||||||
static bool show_config_info = false;
|
static bool show_config_info = false;
|
||||||
ImGui::Checkbox("Config/Build Information", &show_config_info);
|
ImGui::Checkbox("Config/Build Information", &show_config_info);
|
||||||
@ -6762,7 +6607,6 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
|||||||
ImGui::SeparatorText("Tables");
|
ImGui::SeparatorText("Tables");
|
||||||
ImGui::SliderFloat2("CellPadding", (float*)&style.CellPadding, 0.0f, 20.0f, "%.0f");
|
ImGui::SliderFloat2("CellPadding", (float*)&style.CellPadding, 0.0f, 20.0f, "%.0f");
|
||||||
ImGui::SliderAngle("TableAngledHeadersAngle", &style.TableAngledHeadersAngle, -50.0f, +50.0f);
|
ImGui::SliderAngle("TableAngledHeadersAngle", &style.TableAngledHeadersAngle, -50.0f, +50.0f);
|
||||||
ImGui::SliderFloat2("TableAngledHeadersTextAlign", (float*)&style.TableAngledHeadersTextAlign, 0.0f, 1.0f, "%.2f");
|
|
||||||
|
|
||||||
ImGui::SeparatorText("Widgets");
|
ImGui::SeparatorText("Widgets");
|
||||||
ImGui::SliderFloat2("WindowTitleAlign", (float*)&style.WindowTitleAlign, 0.0f, 1.0f, "%.2f");
|
ImGui::SliderFloat2("WindowTitleAlign", (float*)&style.WindowTitleAlign, 0.0f, 1.0f, "%.2f");
|
||||||
@ -7153,19 +6997,19 @@ struct ExampleAppConsole
|
|||||||
{
|
{
|
||||||
ClearLog();
|
ClearLog();
|
||||||
for (int i = 0; i < History.Size; i++)
|
for (int i = 0; i < History.Size; i++)
|
||||||
ImGui::MemFree(History[i]);
|
free(History[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Portable helpers
|
// Portable helpers
|
||||||
static int Stricmp(const char* s1, const char* s2) { int d; while ((d = toupper(*s2) - toupper(*s1)) == 0 && *s1) { s1++; s2++; } return d; }
|
static int Stricmp(const char* s1, const char* s2) { int d; while ((d = toupper(*s2) - toupper(*s1)) == 0 && *s1) { s1++; s2++; } return d; }
|
||||||
static int Strnicmp(const char* s1, const char* s2, int n) { int d = 0; while (n > 0 && (d = toupper(*s2) - toupper(*s1)) == 0 && *s1) { s1++; s2++; n--; } return d; }
|
static int Strnicmp(const char* s1, const char* s2, int n) { int d = 0; while (n > 0 && (d = toupper(*s2) - toupper(*s1)) == 0 && *s1) { s1++; s2++; n--; } return d; }
|
||||||
static char* Strdup(const char* s) { IM_ASSERT(s); size_t len = strlen(s) + 1; void* buf = ImGui::MemAlloc(len); IM_ASSERT(buf); return (char*)memcpy(buf, (const void*)s, len); }
|
static char* Strdup(const char* s) { IM_ASSERT(s); size_t len = strlen(s) + 1; void* buf = malloc(len); IM_ASSERT(buf); return (char*)memcpy(buf, (const void*)s, len); }
|
||||||
static void Strtrim(char* s) { char* str_end = s + strlen(s); while (str_end > s && str_end[-1] == ' ') str_end--; *str_end = 0; }
|
static void Strtrim(char* s) { char* str_end = s + strlen(s); while (str_end > s && str_end[-1] == ' ') str_end--; *str_end = 0; }
|
||||||
|
|
||||||
void ClearLog()
|
void ClearLog()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < Items.Size; i++)
|
for (int i = 0; i < Items.Size; i++)
|
||||||
ImGui::MemFree(Items[i]);
|
free(Items[i]);
|
||||||
Items.clear();
|
Items.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7226,7 +7070,6 @@ struct ExampleAppConsole
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Options, Filter
|
// Options, Filter
|
||||||
ImGui::SetNextItemShortcut(ImGuiMod_Ctrl | ImGuiKey_O, ImGuiInputFlags_Tooltip);
|
|
||||||
if (ImGui::Button("Options"))
|
if (ImGui::Button("Options"))
|
||||||
ImGui::OpenPopup("Options");
|
ImGui::OpenPopup("Options");
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
@ -7235,7 +7078,7 @@ struct ExampleAppConsole
|
|||||||
|
|
||||||
// Reserve enough left-over height for 1 separator + 1 input text
|
// Reserve enough left-over height for 1 separator + 1 input text
|
||||||
const float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing();
|
const float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing();
|
||||||
if (ImGui::BeginChild("ScrollingRegion", ImVec2(0, -footer_height_to_reserve), ImGuiChildFlags_None, ImGuiWindowFlags_HorizontalScrollbar | ImGuiWindowFlags_NavFlattened))
|
if (ImGui::BeginChild("ScrollingRegion", ImVec2(0, -footer_height_to_reserve), ImGuiChildFlags_None, ImGuiWindowFlags_HorizontalScrollbar))
|
||||||
{
|
{
|
||||||
if (ImGui::BeginPopupContextWindow())
|
if (ImGui::BeginPopupContextWindow())
|
||||||
{
|
{
|
||||||
@ -7332,7 +7175,7 @@ struct ExampleAppConsole
|
|||||||
for (int i = History.Size - 1; i >= 0; i--)
|
for (int i = History.Size - 1; i >= 0; i--)
|
||||||
if (Stricmp(History[i], command_line) == 0)
|
if (Stricmp(History[i], command_line) == 0)
|
||||||
{
|
{
|
||||||
ImGui::MemFree(History[i]);
|
free(History[i]);
|
||||||
History.erase(History.begin() + i);
|
History.erase(History.begin() + i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -7937,7 +7780,7 @@ static void ShowExampleAppConstrainedResize(bool* p_open)
|
|||||||
if (type == 2) ImGui::SetNextWindowSizeConstraints(ImVec2(-1, 0), ImVec2(-1, FLT_MAX)); // Resize vertical + lock current width
|
if (type == 2) ImGui::SetNextWindowSizeConstraints(ImVec2(-1, 0), ImVec2(-1, FLT_MAX)); // Resize vertical + lock current width
|
||||||
if (type == 3) ImGui::SetNextWindowSizeConstraints(ImVec2(0, -1), ImVec2(FLT_MAX, -1)); // Resize horizontal + lock current height
|
if (type == 3) ImGui::SetNextWindowSizeConstraints(ImVec2(0, -1), ImVec2(FLT_MAX, -1)); // Resize horizontal + lock current height
|
||||||
if (type == 4) ImGui::SetNextWindowSizeConstraints(ImVec2(400, -1), ImVec2(500, -1)); // Width Between and 400 and 500
|
if (type == 4) ImGui::SetNextWindowSizeConstraints(ImVec2(400, -1), ImVec2(500, -1)); // Width Between and 400 and 500
|
||||||
if (type == 5) ImGui::SetNextWindowSizeConstraints(ImVec2(-1, 400), ImVec2(-1, FLT_MAX)); // Height at least 400
|
if (type == 5) ImGui::SetNextWindowSizeConstraints(ImVec2(-1, 500), ImVec2(-1, FLT_MAX)); // Height at least 400
|
||||||
if (type == 6) ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX), CustomConstraints::AspectRatio, (void*)&aspect_ratio); // Aspect ratio
|
if (type == 6) ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX), CustomConstraints::AspectRatio, (void*)&aspect_ratio); // Aspect ratio
|
||||||
if (type == 7) ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX), CustomConstraints::Square); // Always Square
|
if (type == 7) ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX), CustomConstraints::Square); // Always Square
|
||||||
if (type == 8) ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX), CustomConstraints::Step, (void*)&fixed_step); // Fixed Step
|
if (type == 8) ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX), CustomConstraints::Step, (void*)&fixed_step); // Fixed Step
|
||||||
@ -8112,14 +7955,6 @@ static void ShowExampleAppWindowTitles(bool*)
|
|||||||
// [SECTION] Example App: Custom Rendering using ImDrawList API / ShowExampleAppCustomRendering()
|
// [SECTION] Example App: Custom Rendering using ImDrawList API / ShowExampleAppCustomRendering()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Add a |_| looking shape
|
|
||||||
static void PathConcaveShape(ImDrawList* draw_list, float x, float y, float sz)
|
|
||||||
{
|
|
||||||
const ImVec2 pos_norms[] = { { 0.0f, 0.0f }, { 0.3f, 0.0f }, { 0.3f, 0.7f }, { 0.7f, 0.7f }, { 0.7f, 0.0f }, { 1.0f, 0.0f }, { 1.0f, 1.0f }, { 0.0f, 1.0f } };
|
|
||||||
for (const ImVec2& p : pos_norms)
|
|
||||||
draw_list->PathLineTo(ImVec2(x + 0.5f + (int)(sz * p.x), y + 0.5f + (int)(sz * p.y)));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Demonstrate using the low-level ImDrawList to draw custom shapes.
|
// Demonstrate using the low-level ImDrawList to draw custom shapes.
|
||||||
static void ShowExampleAppCustomRendering(bool* p_open)
|
static void ShowExampleAppCustomRendering(bool* p_open)
|
||||||
{
|
{
|
||||||
@ -8192,9 +8027,6 @@ static void ShowExampleAppCustomRendering(bool* p_open)
|
|||||||
const float rounding = sz / 5.0f;
|
const float rounding = sz / 5.0f;
|
||||||
const int circle_segments = circle_segments_override ? circle_segments_override_v : 0;
|
const int circle_segments = circle_segments_override ? circle_segments_override_v : 0;
|
||||||
const int curve_segments = curve_segments_override ? curve_segments_override_v : 0;
|
const int curve_segments = curve_segments_override ? curve_segments_override_v : 0;
|
||||||
const ImVec2 cp3[3] = { ImVec2(0.0f, sz * 0.6f), ImVec2(sz * 0.5f, -sz * 0.4f), ImVec2(sz, sz) }; // Control points for curves
|
|
||||||
const ImVec2 cp4[4] = { ImVec2(0.0f, 0.0f), ImVec2(sz * 1.3f, sz * 0.3f), ImVec2(sz - sz * 1.3f, sz - sz * 0.3f), ImVec2(sz, sz) };
|
|
||||||
|
|
||||||
float x = p.x + 4.0f;
|
float x = p.x + 4.0f;
|
||||||
float y = p.y + 4.0f;
|
float y = p.y + 4.0f;
|
||||||
for (int n = 0; n < 2; n++)
|
for (int n = 0; n < 2; n++)
|
||||||
@ -8203,63 +8035,41 @@ static void ShowExampleAppCustomRendering(bool* p_open)
|
|||||||
float th = (n == 0) ? 1.0f : thickness;
|
float th = (n == 0) ? 1.0f : thickness;
|
||||||
draw_list->AddNgon(ImVec2(x + sz*0.5f, y + sz*0.5f), sz*0.5f, col, ngon_sides, th); x += sz + spacing; // N-gon
|
draw_list->AddNgon(ImVec2(x + sz*0.5f, y + sz*0.5f), sz*0.5f, col, ngon_sides, th); x += sz + spacing; // N-gon
|
||||||
draw_list->AddCircle(ImVec2(x + sz*0.5f, y + sz*0.5f), sz*0.5f, col, circle_segments, th); x += sz + spacing; // Circle
|
draw_list->AddCircle(ImVec2(x + sz*0.5f, y + sz*0.5f), sz*0.5f, col, circle_segments, th); x += sz + spacing; // Circle
|
||||||
draw_list->AddEllipse(ImVec2(x + sz*0.5f, y + sz*0.5f), ImVec2(sz*0.5f, sz*0.3f), col, -0.3f, circle_segments, th); x += sz + spacing; // Ellipse
|
draw_list->AddEllipse(ImVec2(x + sz*0.5f, y + sz*0.5f), sz*0.5f, sz*0.3f, col, -0.3f, circle_segments, th); x += sz + spacing; // Ellipse
|
||||||
draw_list->AddRect(ImVec2(x, y), ImVec2(x + sz, y + sz), col, 0.0f, ImDrawFlags_None, th); x += sz + spacing; // Square
|
draw_list->AddRect(ImVec2(x, y), ImVec2(x + sz, y + sz), col, 0.0f, ImDrawFlags_None, th); x += sz + spacing; // Square
|
||||||
draw_list->AddRect(ImVec2(x, y), ImVec2(x + sz, y + sz), col, rounding, ImDrawFlags_None, th); x += sz + spacing; // Square with all rounded corners
|
draw_list->AddRect(ImVec2(x, y), ImVec2(x + sz, y + sz), col, rounding, ImDrawFlags_None, th); x += sz + spacing; // Square with all rounded corners
|
||||||
draw_list->AddRect(ImVec2(x, y), ImVec2(x + sz, y + sz), col, rounding, corners_tl_br, th); x += sz + spacing; // Square with two rounded corners
|
draw_list->AddRect(ImVec2(x, y), ImVec2(x + sz, y + sz), col, rounding, corners_tl_br, th); x += sz + spacing; // Square with two rounded corners
|
||||||
draw_list->AddTriangle(ImVec2(x+sz*0.5f,y), ImVec2(x+sz, y+sz-0.5f), ImVec2(x, y+sz-0.5f), col, th);x += sz + spacing; // Triangle
|
draw_list->AddTriangle(ImVec2(x+sz*0.5f,y), ImVec2(x+sz, y+sz-0.5f), ImVec2(x, y+sz-0.5f), col, th);x += sz + spacing; // Triangle
|
||||||
//draw_list->AddTriangle(ImVec2(x+sz*0.2f,y), ImVec2(x, y+sz-0.5f), ImVec2(x+sz*0.4f, y+sz-0.5f), col, th);x+= sz*0.4f + spacing; // Thin triangle
|
//draw_list->AddTriangle(ImVec2(x+sz*0.2f,y), ImVec2(x, y+sz-0.5f), ImVec2(x+sz*0.4f, y+sz-0.5f), col, th);x+= sz*0.4f + spacing; // Thin triangle
|
||||||
PathConcaveShape(draw_list, x, y, sz); draw_list->PathStroke(col, ImDrawFlags_Closed, th); x += sz + spacing; // Concave Shape
|
|
||||||
//draw_list->AddPolyline(concave_shape, IM_ARRAYSIZE(concave_shape), col, ImDrawFlags_Closed, th);
|
|
||||||
draw_list->AddLine(ImVec2(x, y), ImVec2(x + sz, y), col, th); x += sz + spacing; // Horizontal line (note: drawing a filled rectangle will be faster!)
|
draw_list->AddLine(ImVec2(x, y), ImVec2(x + sz, y), col, th); x += sz + spacing; // Horizontal line (note: drawing a filled rectangle will be faster!)
|
||||||
draw_list->AddLine(ImVec2(x, y), ImVec2(x, y + sz), col, th); x += spacing; // Vertical line (note: drawing a filled rectangle will be faster!)
|
draw_list->AddLine(ImVec2(x, y), ImVec2(x, y + sz), col, th); x += spacing; // Vertical line (note: drawing a filled rectangle will be faster!)
|
||||||
draw_list->AddLine(ImVec2(x, y), ImVec2(x + sz, y + sz), col, th); x += sz + spacing; // Diagonal line
|
draw_list->AddLine(ImVec2(x, y), ImVec2(x + sz, y + sz), col, th); x += sz + spacing; // Diagonal line
|
||||||
|
|
||||||
// Path
|
|
||||||
draw_list->PathArcTo(ImVec2(x + sz*0.5f, y + sz*0.5f), sz*0.5f, 3.141592f, 3.141592f * -0.5f);
|
|
||||||
draw_list->PathStroke(col, ImDrawFlags_None, th);
|
|
||||||
x += sz + spacing;
|
|
||||||
|
|
||||||
// Quadratic Bezier Curve (3 control points)
|
// Quadratic Bezier Curve (3 control points)
|
||||||
draw_list->AddBezierQuadratic(ImVec2(x + cp3[0].x, y + cp3[0].y), ImVec2(x + cp3[1].x, y + cp3[1].y), ImVec2(x + cp3[2].x, y + cp3[2].y), col, th, curve_segments);
|
ImVec2 cp3[3] = { ImVec2(x, y + sz * 0.6f), ImVec2(x + sz * 0.5f, y - sz * 0.4f), ImVec2(x + sz, y + sz) };
|
||||||
x += sz + spacing;
|
draw_list->AddBezierQuadratic(cp3[0], cp3[1], cp3[2], col, th, curve_segments); x += sz + spacing;
|
||||||
|
|
||||||
// Cubic Bezier Curve (4 control points)
|
// Cubic Bezier Curve (4 control points)
|
||||||
draw_list->AddBezierCubic(ImVec2(x + cp4[0].x, y + cp4[0].y), ImVec2(x + cp4[1].x, y + cp4[1].y), ImVec2(x + cp4[2].x, y + cp4[2].y), ImVec2(x + cp4[3].x, y + cp4[3].y), col, th, curve_segments);
|
ImVec2 cp4[4] = { ImVec2(x, y), ImVec2(x + sz * 1.3f, y + sz * 0.3f), ImVec2(x + sz - sz * 1.3f, y + sz - sz * 0.3f), ImVec2(x + sz, y + sz) };
|
||||||
|
draw_list->AddBezierCubic(cp4[0], cp4[1], cp4[2], cp4[3], col, th, curve_segments);
|
||||||
|
|
||||||
x = p.x + 4;
|
x = p.x + 4;
|
||||||
y += sz + spacing;
|
y += sz + spacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filled shapes
|
|
||||||
draw_list->AddNgonFilled(ImVec2(x + sz * 0.5f, y + sz * 0.5f), sz * 0.5f, col, ngon_sides); x += sz + spacing; // N-gon
|
draw_list->AddNgonFilled(ImVec2(x + sz * 0.5f, y + sz * 0.5f), sz * 0.5f, col, ngon_sides); x += sz + spacing; // N-gon
|
||||||
draw_list->AddCircleFilled(ImVec2(x + sz * 0.5f, y + sz * 0.5f), sz * 0.5f, col, circle_segments); x += sz + spacing; // Circle
|
draw_list->AddCircleFilled(ImVec2(x + sz * 0.5f, y + sz * 0.5f), sz * 0.5f, col, circle_segments); x += sz + spacing; // Circle
|
||||||
draw_list->AddEllipseFilled(ImVec2(x + sz * 0.5f, y + sz * 0.5f), ImVec2(sz * 0.5f, sz * 0.3f), col, -0.3f, circle_segments); x += sz + spacing;// Ellipse
|
draw_list->AddEllipseFilled(ImVec2(x + sz * 0.5f, y + sz * 0.5f), sz * 0.5f, sz * 0.3f, col, -0.3f, circle_segments); x += sz + spacing;// Ellipse
|
||||||
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + sz, y + sz), col); x += sz + spacing; // Square
|
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + sz, y + sz), col); x += sz + spacing; // Square
|
||||||
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + sz, y + sz), col, 10.0f); x += sz + spacing; // Square with all rounded corners
|
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + sz, y + sz), col, 10.0f); x += sz + spacing; // Square with all rounded corners
|
||||||
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + sz, y + sz), col, 10.0f, corners_tl_br); x += sz + spacing; // Square with two rounded corners
|
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + sz, y + sz), col, 10.0f, corners_tl_br); x += sz + spacing; // Square with two rounded corners
|
||||||
draw_list->AddTriangleFilled(ImVec2(x+sz*0.5f,y), ImVec2(x+sz, y+sz-0.5f), ImVec2(x, y+sz-0.5f), col); x += sz + spacing; // Triangle
|
draw_list->AddTriangleFilled(ImVec2(x+sz*0.5f,y), ImVec2(x+sz, y+sz-0.5f), ImVec2(x, y+sz-0.5f), col); x += sz + spacing; // Triangle
|
||||||
//draw_list->AddTriangleFilled(ImVec2(x+sz*0.2f,y), ImVec2(x, y+sz-0.5f), ImVec2(x+sz*0.4f, y+sz-0.5f), col); x += sz*0.4f + spacing; // Thin triangle
|
//draw_list->AddTriangleFilled(ImVec2(x+sz*0.2f,y), ImVec2(x, y+sz-0.5f), ImVec2(x+sz*0.4f, y+sz-0.5f), col); x += sz*0.4f + spacing; // Thin triangle
|
||||||
PathConcaveShape(draw_list, x, y, sz); draw_list->PathFillConcave(col); x += sz + spacing; // Concave shape
|
|
||||||
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + sz, y + thickness), col); x += sz + spacing; // Horizontal line (faster than AddLine, but only handle integer thickness)
|
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + sz, y + thickness), col); x += sz + spacing; // Horizontal line (faster than AddLine, but only handle integer thickness)
|
||||||
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + thickness, y + sz), col); x += spacing * 2.0f;// Vertical line (faster than AddLine, but only handle integer thickness)
|
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + thickness, y + sz), col); x += spacing * 2.0f;// Vertical line (faster than AddLine, but only handle integer thickness)
|
||||||
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + 1, y + 1), col); x += sz; // Pixel (faster than AddLine)
|
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + 1, y + 1), col); x += sz; // Pixel (faster than AddLine)
|
||||||
|
|
||||||
// Path
|
|
||||||
draw_list->PathArcTo(ImVec2(x + sz * 0.5f, y + sz * 0.5f), sz * 0.5f, 3.141592f * -0.5f, 3.141592f);
|
|
||||||
draw_list->PathFillConvex(col);
|
|
||||||
x += sz + spacing;
|
|
||||||
|
|
||||||
// Quadratic Bezier Curve (3 control points)
|
|
||||||
draw_list->PathLineTo(ImVec2(x + cp3[0].x, y + cp3[0].y));
|
|
||||||
draw_list->PathBezierQuadraticCurveTo(ImVec2(x + cp3[1].x, y + cp3[1].y), ImVec2(x + cp3[2].x, y + cp3[2].y), curve_segments);
|
|
||||||
draw_list->PathFillConvex(col);
|
|
||||||
x += sz + spacing;
|
|
||||||
|
|
||||||
draw_list->AddRectFilledMultiColor(ImVec2(x, y), ImVec2(x + sz, y + sz), IM_COL32(0, 0, 0, 255), IM_COL32(255, 0, 0, 255), IM_COL32(255, 255, 0, 255), IM_COL32(0, 255, 0, 255));
|
draw_list->AddRectFilledMultiColor(ImVec2(x, y), ImVec2(x + sz, y + sz), IM_COL32(0, 0, 0, 255), IM_COL32(255, 0, 0, 255), IM_COL32(255, 255, 0, 255), IM_COL32(0, 255, 0, 255));
|
||||||
x += sz + spacing;
|
|
||||||
|
|
||||||
ImGui::Dummy(ImVec2((sz + spacing) * 13.2f, (sz + spacing) * 3.0f));
|
ImGui::Dummy(ImVec2((sz + spacing) * 11.2f, (sz + spacing) * 3.0f));
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
}
|
}
|
||||||
@ -8429,99 +8239,73 @@ static void ShowExampleAppCustomRendering(bool* p_open)
|
|||||||
// Simplified structure to mimic a Document model
|
// Simplified structure to mimic a Document model
|
||||||
struct MyDocument
|
struct MyDocument
|
||||||
{
|
{
|
||||||
char Name[32]; // Document title
|
const char* Name; // Document title
|
||||||
int UID; // Unique ID (necessary as we can change title)
|
|
||||||
bool Open; // Set when open (we keep an array of all available documents to simplify demo code!)
|
bool Open; // Set when open (we keep an array of all available documents to simplify demo code!)
|
||||||
bool OpenPrev; // Copy of Open from last update.
|
bool OpenPrev; // Copy of Open from last update.
|
||||||
bool Dirty; // Set when the document has been modified
|
bool Dirty; // Set when the document has been modified
|
||||||
|
bool WantClose; // Set when the document
|
||||||
ImVec4 Color; // An arbitrary variable associated to the document
|
ImVec4 Color; // An arbitrary variable associated to the document
|
||||||
|
|
||||||
MyDocument(int uid, const char* name, bool open = true, const ImVec4& color = ImVec4(1.0f, 1.0f, 1.0f, 1.0f))
|
MyDocument(const char* name, bool open = true, const ImVec4& color = ImVec4(1.0f, 1.0f, 1.0f, 1.0f))
|
||||||
{
|
{
|
||||||
UID = uid;
|
Name = name;
|
||||||
snprintf(Name, sizeof(Name), "%s", name);
|
|
||||||
Open = OpenPrev = open;
|
Open = OpenPrev = open;
|
||||||
Dirty = false;
|
Dirty = false;
|
||||||
|
WantClose = false;
|
||||||
Color = color;
|
Color = color;
|
||||||
}
|
}
|
||||||
void DoOpen() { Open = true; }
|
void DoOpen() { Open = true; }
|
||||||
|
void DoQueueClose() { WantClose = true; }
|
||||||
void DoForceClose() { Open = false; Dirty = false; }
|
void DoForceClose() { Open = false; Dirty = false; }
|
||||||
void DoSave() { Dirty = false; }
|
void DoSave() { Dirty = false; }
|
||||||
};
|
|
||||||
|
|
||||||
struct ExampleAppDocuments
|
|
||||||
{
|
|
||||||
ImVector<MyDocument> Documents;
|
|
||||||
ImVector<MyDocument*> CloseQueue;
|
|
||||||
MyDocument* RenamingDoc = NULL;
|
|
||||||
bool RenamingStarted = false;
|
|
||||||
|
|
||||||
ExampleAppDocuments()
|
|
||||||
{
|
|
||||||
Documents.push_back(MyDocument(0, "Lettuce", true, ImVec4(0.4f, 0.8f, 0.4f, 1.0f)));
|
|
||||||
Documents.push_back(MyDocument(1, "Eggplant", true, ImVec4(0.8f, 0.5f, 1.0f, 1.0f)));
|
|
||||||
Documents.push_back(MyDocument(2, "Carrot", true, ImVec4(1.0f, 0.8f, 0.5f, 1.0f)));
|
|
||||||
Documents.push_back(MyDocument(3, "Tomato", false, ImVec4(1.0f, 0.3f, 0.4f, 1.0f)));
|
|
||||||
Documents.push_back(MyDocument(4, "A Rather Long Title", false, ImVec4(0.4f, 0.8f, 0.8f, 1.0f)));
|
|
||||||
Documents.push_back(MyDocument(5, "Some Document", false, ImVec4(0.8f, 0.8f, 1.0f, 1.0f)));
|
|
||||||
}
|
|
||||||
|
|
||||||
// As we allow to change document name, we append a never-changing document ID so tabs are stable
|
|
||||||
void GetTabName(MyDocument* doc, char* out_buf, size_t out_buf_size)
|
|
||||||
{
|
|
||||||
snprintf(out_buf, out_buf_size, "%s###doc%d", doc->Name, doc->UID);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Display placeholder contents for the Document
|
// Display placeholder contents for the Document
|
||||||
void DisplayDocContents(MyDocument* doc)
|
static void DisplayContents(MyDocument* doc)
|
||||||
{
|
{
|
||||||
ImGui::PushID(doc);
|
ImGui::PushID(doc);
|
||||||
ImGui::Text("Document \"%s\"", doc->Name);
|
ImGui::Text("Document \"%s\"", doc->Name);
|
||||||
ImGui::PushStyleColor(ImGuiCol_Text, doc->Color);
|
ImGui::PushStyleColor(ImGuiCol_Text, doc->Color);
|
||||||
ImGui::TextWrapped("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
|
ImGui::TextWrapped("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
|
||||||
ImGui::PopStyleColor();
|
ImGui::PopStyleColor();
|
||||||
|
if (ImGui::Button("Modify", ImVec2(100, 0)))
|
||||||
ImGui::SetNextItemShortcut(ImGuiMod_Ctrl | ImGuiKey_R, ImGuiInputFlags_Tooltip);
|
|
||||||
if (ImGui::Button("Rename.."))
|
|
||||||
{
|
|
||||||
RenamingDoc = doc;
|
|
||||||
RenamingStarted = true;
|
|
||||||
}
|
|
||||||
ImGui::SameLine();
|
|
||||||
|
|
||||||
ImGui::SetNextItemShortcut(ImGuiMod_Ctrl | ImGuiKey_M, ImGuiInputFlags_Tooltip);
|
|
||||||
if (ImGui::Button("Modify"))
|
|
||||||
doc->Dirty = true;
|
doc->Dirty = true;
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::SetNextItemShortcut(ImGuiMod_Ctrl | ImGuiKey_S, ImGuiInputFlags_Tooltip);
|
if (ImGui::Button("Save", ImVec2(100, 0)))
|
||||||
if (ImGui::Button("Save"))
|
|
||||||
doc->DoSave();
|
doc->DoSave();
|
||||||
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::SetNextItemShortcut(ImGuiMod_Ctrl | ImGuiKey_W, ImGuiInputFlags_Tooltip);
|
|
||||||
if (ImGui::Button("Close"))
|
|
||||||
CloseQueue.push_back(doc);
|
|
||||||
ImGui::ColorEdit3("color", &doc->Color.x); // Useful to test drag and drop and hold-dragged-to-open-tab behavior.
|
ImGui::ColorEdit3("color", &doc->Color.x); // Useful to test drag and drop and hold-dragged-to-open-tab behavior.
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display context menu for the Document
|
// Display context menu for the Document
|
||||||
void DisplayDocContextMenu(MyDocument* doc)
|
static void DisplayContextMenu(MyDocument* doc)
|
||||||
{
|
{
|
||||||
if (!ImGui::BeginPopupContextItem())
|
if (!ImGui::BeginPopupContextItem())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char buf[256];
|
char buf[256];
|
||||||
sprintf(buf, "Save %s", doc->Name);
|
sprintf(buf, "Save %s", doc->Name);
|
||||||
if (ImGui::MenuItem(buf, "Ctrl+S", false, doc->Open))
|
if (ImGui::MenuItem(buf, "CTRL+S", false, doc->Open))
|
||||||
doc->DoSave();
|
doc->DoSave();
|
||||||
if (ImGui::MenuItem("Rename...", "Ctrl+R", false, doc->Open))
|
if (ImGui::MenuItem("Close", "CTRL+W", false, doc->Open))
|
||||||
RenamingDoc = doc;
|
doc->DoQueueClose();
|
||||||
if (ImGui::MenuItem("Close", "Ctrl+W", false, doc->Open))
|
|
||||||
CloseQueue.push_back(doc);
|
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ExampleAppDocuments
|
||||||
|
{
|
||||||
|
ImVector<MyDocument> Documents;
|
||||||
|
|
||||||
|
ExampleAppDocuments()
|
||||||
|
{
|
||||||
|
Documents.push_back(MyDocument("Lettuce", true, ImVec4(0.4f, 0.8f, 0.4f, 1.0f)));
|
||||||
|
Documents.push_back(MyDocument("Eggplant", true, ImVec4(0.8f, 0.5f, 1.0f, 1.0f)));
|
||||||
|
Documents.push_back(MyDocument("Carrot", true, ImVec4(1.0f, 0.8f, 0.5f, 1.0f)));
|
||||||
|
Documents.push_back(MyDocument("Tomato", false, ImVec4(1.0f, 0.3f, 0.4f, 1.0f)));
|
||||||
|
Documents.push_back(MyDocument("A Rather Long Title", false));
|
||||||
|
Documents.push_back(MyDocument("Some Document", false));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// [Optional] Notify the system of Tabs/Windows closure that happened outside the regular tab interface.
|
// [Optional] Notify the system of Tabs/Windows closure that happened outside the regular tab interface.
|
||||||
// If a tab has been closed programmatically (aka closed from another source such as the Checkbox() in the demo,
|
// If a tab has been closed programmatically (aka closed from another source such as the Checkbox() in the demo,
|
||||||
@ -8531,16 +8315,15 @@ struct ExampleAppDocuments
|
|||||||
// give the impression of a flicker for one frame.
|
// give the impression of a flicker for one frame.
|
||||||
// We call SetTabItemClosed() to manually notify the Tab Bar or Docking system of removed tabs to avoid this glitch.
|
// We call SetTabItemClosed() to manually notify the Tab Bar or Docking system of removed tabs to avoid this glitch.
|
||||||
// Note that this completely optional, and only affect tab bars with the ImGuiTabBarFlags_Reorderable flag.
|
// Note that this completely optional, and only affect tab bars with the ImGuiTabBarFlags_Reorderable flag.
|
||||||
void NotifyOfDocumentsClosedElsewhere()
|
static void NotifyOfDocumentsClosedElsewhere(ExampleAppDocuments& app)
|
||||||
{
|
{
|
||||||
for (MyDocument& doc : Documents)
|
for (MyDocument& doc : app.Documents)
|
||||||
{
|
{
|
||||||
if (!doc.Open && doc.OpenPrev)
|
if (!doc.Open && doc.OpenPrev)
|
||||||
ImGui::SetTabItemClosed(doc.Name);
|
ImGui::SetTabItemClosed(doc.Name);
|
||||||
doc.OpenPrev = doc.Open;
|
doc.OpenPrev = doc.Open;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
void ShowExampleAppDocuments(bool* p_open)
|
void ShowExampleAppDocuments(bool* p_open)
|
||||||
{
|
{
|
||||||
@ -8575,8 +8358,8 @@ void ShowExampleAppDocuments(bool* p_open)
|
|||||||
}
|
}
|
||||||
if (ImGui::MenuItem("Close All Documents", NULL, false, open_count > 0))
|
if (ImGui::MenuItem("Close All Documents", NULL, false, open_count > 0))
|
||||||
for (MyDocument& doc : app.Documents)
|
for (MyDocument& doc : app.Documents)
|
||||||
app.CloseQueue.push_back(&doc);
|
doc.DoQueueClose();
|
||||||
if (ImGui::MenuItem("Exit") && p_open)
|
if (ImGui::MenuItem("Exit", "Ctrl+F4") && p_open)
|
||||||
*p_open = false;
|
*p_open = false;
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
@ -8614,7 +8397,7 @@ void ShowExampleAppDocuments(bool* p_open)
|
|||||||
if (ImGui::BeginTabBar("##tabs", tab_bar_flags))
|
if (ImGui::BeginTabBar("##tabs", tab_bar_flags))
|
||||||
{
|
{
|
||||||
if (opt_reorderable)
|
if (opt_reorderable)
|
||||||
app.NotifyOfDocumentsClosedElsewhere();
|
NotifyOfDocumentsClosedElsewhere(app);
|
||||||
|
|
||||||
// [DEBUG] Stress tests
|
// [DEBUG] Stress tests
|
||||||
//if ((ImGui::GetFrameCount() % 30) == 0) docs[1].Open ^= 1; // [DEBUG] Automatically show/hide a tab. Test various interactions e.g. dragging with this on.
|
//if ((ImGui::GetFrameCount() % 30) == 0) docs[1].Open ^= 1; // [DEBUG] Automatically show/hide a tab. Test various interactions e.g. dragging with this on.
|
||||||
@ -8626,23 +8409,20 @@ void ShowExampleAppDocuments(bool* p_open)
|
|||||||
if (!doc.Open)
|
if (!doc.Open)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// As we allow to change document name, we append a never-changing document id so tabs are stable
|
|
||||||
char doc_name_buf[64];
|
|
||||||
app.GetTabName(&doc, doc_name_buf, sizeof(doc_name_buf));
|
|
||||||
ImGuiTabItemFlags tab_flags = (doc.Dirty ? ImGuiTabItemFlags_UnsavedDocument : 0);
|
ImGuiTabItemFlags tab_flags = (doc.Dirty ? ImGuiTabItemFlags_UnsavedDocument : 0);
|
||||||
bool visible = ImGui::BeginTabItem(doc_name_buf, &doc.Open, tab_flags);
|
bool visible = ImGui::BeginTabItem(doc.Name, &doc.Open, tab_flags);
|
||||||
|
|
||||||
// Cancel attempt to close when unsaved add to save queue so we can display a popup.
|
// Cancel attempt to close when unsaved add to save queue so we can display a popup.
|
||||||
if (!doc.Open && doc.Dirty)
|
if (!doc.Open && doc.Dirty)
|
||||||
{
|
{
|
||||||
doc.Open = true;
|
doc.Open = true;
|
||||||
app.CloseQueue.push_back(&doc);
|
doc.DoQueueClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
app.DisplayDocContextMenu(&doc);
|
MyDocument::DisplayContextMenu(&doc);
|
||||||
if (visible)
|
if (visible)
|
||||||
{
|
{
|
||||||
app.DisplayDocContents(&doc);
|
MyDocument::DisplayContents(&doc);
|
||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8651,44 +8431,33 @@ void ShowExampleAppDocuments(bool* p_open)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display renaming UI
|
// Update closing queue
|
||||||
if (app.RenamingDoc != NULL)
|
static ImVector<MyDocument*> close_queue;
|
||||||
|
if (close_queue.empty())
|
||||||
{
|
{
|
||||||
if (app.RenamingStarted)
|
// Close queue is locked once we started a popup
|
||||||
ImGui::OpenPopup("Rename");
|
for (MyDocument& doc : app.Documents)
|
||||||
if (ImGui::BeginPopup("Rename"))
|
if (doc.WantClose)
|
||||||
{
|
{
|
||||||
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 30);
|
doc.WantClose = false;
|
||||||
if (ImGui::InputText("###Name", app.RenamingDoc->Name, IM_ARRAYSIZE(app.RenamingDoc->Name), ImGuiInputTextFlags_EnterReturnsTrue))
|
close_queue.push_back(&doc);
|
||||||
{
|
|
||||||
ImGui::CloseCurrentPopup();
|
|
||||||
app.RenamingDoc = NULL;
|
|
||||||
}
|
}
|
||||||
if (app.RenamingStarted)
|
|
||||||
ImGui::SetKeyboardFocusHere(-1);
|
|
||||||
ImGui::EndPopup();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
app.RenamingDoc = NULL;
|
|
||||||
}
|
|
||||||
app.RenamingStarted = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display closing confirmation UI
|
// Display closing confirmation UI
|
||||||
if (!app.CloseQueue.empty())
|
if (!close_queue.empty())
|
||||||
{
|
{
|
||||||
int close_queue_unsaved_documents = 0;
|
int close_queue_unsaved_documents = 0;
|
||||||
for (int n = 0; n < app.CloseQueue.Size; n++)
|
for (int n = 0; n < close_queue.Size; n++)
|
||||||
if (app.CloseQueue[n]->Dirty)
|
if (close_queue[n]->Dirty)
|
||||||
close_queue_unsaved_documents++;
|
close_queue_unsaved_documents++;
|
||||||
|
|
||||||
if (close_queue_unsaved_documents == 0)
|
if (close_queue_unsaved_documents == 0)
|
||||||
{
|
{
|
||||||
// Close documents when all are unsaved
|
// Close documents when all are unsaved
|
||||||
for (int n = 0; n < app.CloseQueue.Size; n++)
|
for (int n = 0; n < close_queue.Size; n++)
|
||||||
app.CloseQueue[n]->DoForceClose();
|
close_queue[n]->DoForceClose();
|
||||||
app.CloseQueue.clear();
|
close_queue.clear();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -8699,35 +8468,37 @@ void ShowExampleAppDocuments(bool* p_open)
|
|||||||
ImGui::Text("Save change to the following items?");
|
ImGui::Text("Save change to the following items?");
|
||||||
float item_height = ImGui::GetTextLineHeightWithSpacing();
|
float item_height = ImGui::GetTextLineHeightWithSpacing();
|
||||||
if (ImGui::BeginChild(ImGui::GetID("frame"), ImVec2(-FLT_MIN, 6.25f * item_height), ImGuiChildFlags_FrameStyle))
|
if (ImGui::BeginChild(ImGui::GetID("frame"), ImVec2(-FLT_MIN, 6.25f * item_height), ImGuiChildFlags_FrameStyle))
|
||||||
for (MyDocument* doc : app.CloseQueue)
|
{
|
||||||
if (doc->Dirty)
|
for (int n = 0; n < close_queue.Size; n++)
|
||||||
ImGui::Text("%s", doc->Name);
|
if (close_queue[n]->Dirty)
|
||||||
|
ImGui::Text("%s", close_queue[n]->Name);
|
||||||
|
}
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
|
|
||||||
ImVec2 button_size(ImGui::GetFontSize() * 7.0f, 0.0f);
|
ImVec2 button_size(ImGui::GetFontSize() * 7.0f, 0.0f);
|
||||||
if (ImGui::Button("Yes", button_size))
|
if (ImGui::Button("Yes", button_size))
|
||||||
{
|
{
|
||||||
for (MyDocument* doc : app.CloseQueue)
|
for (int n = 0; n < close_queue.Size; n++)
|
||||||
{
|
{
|
||||||
if (doc->Dirty)
|
if (close_queue[n]->Dirty)
|
||||||
doc->DoSave();
|
close_queue[n]->DoSave();
|
||||||
doc->DoForceClose();
|
close_queue[n]->DoForceClose();
|
||||||
}
|
}
|
||||||
app.CloseQueue.clear();
|
close_queue.clear();
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::Button("No", button_size))
|
if (ImGui::Button("No", button_size))
|
||||||
{
|
{
|
||||||
for (MyDocument* doc : app.CloseQueue)
|
for (int n = 0; n < close_queue.Size; n++)
|
||||||
doc->DoForceClose();
|
close_queue[n]->DoForceClose();
|
||||||
app.CloseQueue.clear();
|
close_queue.clear();
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::Button("Cancel", button_size))
|
if (ImGui::Button("Cancel", button_size))
|
||||||
{
|
{
|
||||||
app.CloseQueue.clear();
|
close_queue.clear();
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
}
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
|
361
external/imgui/imgui/imgui_draw.cpp
vendored
361
external/imgui/imgui/imgui_draw.cpp
vendored
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.90.7
|
// dear imgui, v1.90.1
|
||||||
// (drawing and font code)
|
// (drawing and font code)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -8,7 +8,6 @@ Index of this file:
|
|||||||
// [SECTION] STB libraries implementation
|
// [SECTION] STB libraries implementation
|
||||||
// [SECTION] Style functions
|
// [SECTION] Style functions
|
||||||
// [SECTION] ImDrawList
|
// [SECTION] ImDrawList
|
||||||
// [SECTION] ImTriangulator, ImDrawList concave polygon fill
|
|
||||||
// [SECTION] ImDrawListSplitter
|
// [SECTION] ImDrawListSplitter
|
||||||
// [SECTION] ImDrawData
|
// [SECTION] ImDrawData
|
||||||
// [SECTION] Helpers ShadeVertsXXX functions
|
// [SECTION] Helpers ShadeVertsXXX functions
|
||||||
@ -65,7 +64,6 @@ Index of this file:
|
|||||||
#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double.
|
#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double.
|
||||||
#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision
|
#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision
|
||||||
#pragma clang diagnostic ignored "-Wreserved-identifier" // warning: identifier '_Xxx' is reserved because it starts with '_' followed by a capital letter
|
#pragma clang diagnostic ignored "-Wreserved-identifier" // warning: identifier '_Xxx' is reserved because it starts with '_' followed by a capital letter
|
||||||
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" // warning: 'xxx' is an unsafe pointer used for buffer access
|
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
||||||
#pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used
|
#pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used
|
||||||
@ -385,7 +383,6 @@ void ImDrawListSharedData::SetCircleTessellationMaxError(float max_error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialize before use in a new frame. We always have a command ready in the buffer.
|
// Initialize before use in a new frame. We always have a command ready in the buffer.
|
||||||
// In the majority of cases, you would want to call PushClipRect() and PushTextureID() after this.
|
|
||||||
void ImDrawList::_ResetForNewFrame()
|
void ImDrawList::_ResetForNewFrame()
|
||||||
{
|
{
|
||||||
// Verify that the ImDrawCmd fields we want to memcmp() are contiguous in memory.
|
// Verify that the ImDrawCmd fields we want to memcmp() are contiguous in memory.
|
||||||
@ -644,7 +641,7 @@ void ImDrawList::PrimReserve(int idx_count, int vtx_count)
|
|||||||
_IdxWritePtr = IdxBuffer.Data + idx_buffer_old_size;
|
_IdxWritePtr = IdxBuffer.Data + idx_buffer_old_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release the number of reserved vertices/indices from the end of the last reservation made with PrimReserve().
|
// Release the a number of reserved vertices/indices from the end of the last reservation made with PrimReserve().
|
||||||
void ImDrawList::PrimUnreserve(int idx_count, int vtx_count)
|
void ImDrawList::PrimUnreserve(int idx_count, int vtx_count)
|
||||||
{
|
{
|
||||||
IM_ASSERT_PARANOID(idx_count >= 0 && vtx_count >= 0);
|
IM_ASSERT_PARANOID(idx_count >= 0 && vtx_count >= 0);
|
||||||
@ -1220,10 +1217,10 @@ void ImDrawList::PathArcTo(const ImVec2& center, float radius, float a_min, floa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::PathEllipticalArcTo(const ImVec2& center, const ImVec2& radius, float rot, float a_min, float a_max, int num_segments)
|
void ImDrawList::PathEllipticalArcTo(const ImVec2& center, float radius_x, float radius_y, float rot, float a_min, float a_max, int num_segments)
|
||||||
{
|
{
|
||||||
if (num_segments <= 0)
|
if (num_segments <= 0)
|
||||||
num_segments = _CalcCircleAutoSegmentCount(ImMax(radius.x, radius.y)); // A bit pessimistic, maybe there's a better computation to do here.
|
num_segments = _CalcCircleAutoSegmentCount(ImMax(radius_x, radius_y)); // A bit pessimistic, maybe there's a better computation to do here.
|
||||||
|
|
||||||
_Path.reserve(_Path.Size + (num_segments + 1));
|
_Path.reserve(_Path.Size + (num_segments + 1));
|
||||||
|
|
||||||
@ -1232,10 +1229,11 @@ void ImDrawList::PathEllipticalArcTo(const ImVec2& center, const ImVec2& radius,
|
|||||||
for (int i = 0; i <= num_segments; i++)
|
for (int i = 0; i <= num_segments; i++)
|
||||||
{
|
{
|
||||||
const float a = a_min + ((float)i / (float)num_segments) * (a_max - a_min);
|
const float a = a_min + ((float)i / (float)num_segments) * (a_max - a_min);
|
||||||
ImVec2 point(ImCos(a) * radius.x, ImSin(a) * radius.y);
|
ImVec2 point(ImCos(a) * radius_x, ImSin(a) * radius_y);
|
||||||
const ImVec2 rel((point.x * cos_rot) - (point.y * sin_rot), (point.x * sin_rot) + (point.y * cos_rot));
|
const float rel_x = (point.x * cos_rot) - (point.y * sin_rot);
|
||||||
point.x = rel.x + center.x;
|
const float rel_y = (point.x * sin_rot) + (point.y * cos_rot);
|
||||||
point.y = rel.y + center.y;
|
point.x = rel_x + center.x;
|
||||||
|
point.y = rel_y + center.y;
|
||||||
_Path.push_back(point);
|
_Path.push_back(point);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1560,31 +1558,31 @@ void ImDrawList::AddNgonFilled(const ImVec2& center, float radius, ImU32 col, in
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ellipse
|
// Ellipse
|
||||||
void ImDrawList::AddEllipse(const ImVec2& center, const ImVec2& radius, ImU32 col, float rot, int num_segments, float thickness)
|
void ImDrawList::AddEllipse(const ImVec2& center, float radius_x, float radius_y, ImU32 col, float rot, int num_segments, float thickness)
|
||||||
{
|
{
|
||||||
if ((col & IM_COL32_A_MASK) == 0)
|
if ((col & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (num_segments <= 0)
|
if (num_segments <= 0)
|
||||||
num_segments = _CalcCircleAutoSegmentCount(ImMax(radius.x, radius.y)); // A bit pessimistic, maybe there's a better computation to do here.
|
num_segments = _CalcCircleAutoSegmentCount(ImMax(radius_x, radius_y)); // A bit pessimistic, maybe there's a better computation to do here.
|
||||||
|
|
||||||
// Because we are filling a closed shape we remove 1 from the count of segments/points
|
// Because we are filling a closed shape we remove 1 from the count of segments/points
|
||||||
const float a_max = IM_PI * 2.0f * ((float)num_segments - 1.0f) / (float)num_segments;
|
const float a_max = IM_PI * 2.0f * ((float)num_segments - 1.0f) / (float)num_segments;
|
||||||
PathEllipticalArcTo(center, radius, rot, 0.0f, a_max, num_segments - 1);
|
PathEllipticalArcTo(center, radius_x, radius_y, rot, 0.0f, a_max, num_segments - 1);
|
||||||
PathStroke(col, true, thickness);
|
PathStroke(col, true, thickness);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImDrawList::AddEllipseFilled(const ImVec2& center, const ImVec2& radius, ImU32 col, float rot, int num_segments)
|
void ImDrawList::AddEllipseFilled(const ImVec2& center, float radius_x, float radius_y, ImU32 col, float rot, int num_segments)
|
||||||
{
|
{
|
||||||
if ((col & IM_COL32_A_MASK) == 0)
|
if ((col & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (num_segments <= 0)
|
if (num_segments <= 0)
|
||||||
num_segments = _CalcCircleAutoSegmentCount(ImMax(radius.x, radius.y)); // A bit pessimistic, maybe there's a better computation to do here.
|
num_segments = _CalcCircleAutoSegmentCount(ImMax(radius_x, radius_y)); // A bit pessimistic, maybe there's a better computation to do here.
|
||||||
|
|
||||||
// Because we are filling a closed shape we remove 1 from the count of segments/points
|
// Because we are filling a closed shape we remove 1 from the count of segments/points
|
||||||
const float a_max = IM_PI * 2.0f * ((float)num_segments - 1.0f) / (float)num_segments;
|
const float a_max = IM_PI * 2.0f * ((float)num_segments - 1.0f) / (float)num_segments;
|
||||||
PathEllipticalArcTo(center, radius, rot, 0.0f, a_max, num_segments - 1);
|
PathEllipticalArcTo(center, radius_x, radius_y, rot, 0.0f, a_max, num_segments - 1);
|
||||||
PathFillConvex(col);
|
PathFillConvex(col);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1615,11 +1613,10 @@ void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos,
|
|||||||
if ((col & IM_COL32_A_MASK) == 0)
|
if ((col & IM_COL32_A_MASK) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Accept null ranges
|
|
||||||
if (text_begin == text_end || text_begin[0] == 0)
|
|
||||||
return;
|
|
||||||
if (text_end == NULL)
|
if (text_end == NULL)
|
||||||
text_end = text_begin + strlen(text_begin);
|
text_end = text_begin + strlen(text_begin);
|
||||||
|
if (text_begin == text_end)
|
||||||
|
return;
|
||||||
|
|
||||||
// Pull default font/size from the shared ImDrawListSharedData instance
|
// Pull default font/size from the shared ImDrawListSharedData instance
|
||||||
if (font == NULL)
|
if (font == NULL)
|
||||||
@ -1703,316 +1700,6 @@ void ImDrawList::AddImageRounded(ImTextureID user_texture_id, const ImVec2& p_mi
|
|||||||
PopTextureID();
|
PopTextureID();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// [SECTION] ImTriangulator, ImDrawList concave polygon fill
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Triangulate concave polygons. Based on "Triangulation by Ear Clipping" paper, O(N^2) complexity.
|
|
||||||
// Reference: https://www.geometrictools.com/Documentation/TriangulationByEarClipping.pdf
|
|
||||||
// Provided as a convenience for user but not used by main library.
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// - ImTriangulator [Internal]
|
|
||||||
// - AddConcavePolyFilled()
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
enum ImTriangulatorNodeType
|
|
||||||
{
|
|
||||||
ImTriangulatorNodeType_Convex,
|
|
||||||
ImTriangulatorNodeType_Ear,
|
|
||||||
ImTriangulatorNodeType_Reflex
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ImTriangulatorNode
|
|
||||||
{
|
|
||||||
ImTriangulatorNodeType Type;
|
|
||||||
int Index;
|
|
||||||
ImVec2 Pos;
|
|
||||||
ImTriangulatorNode* Next;
|
|
||||||
ImTriangulatorNode* Prev;
|
|
||||||
|
|
||||||
void Unlink() { Next->Prev = Prev; Prev->Next = Next; }
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ImTriangulatorNodeSpan
|
|
||||||
{
|
|
||||||
ImTriangulatorNode** Data = NULL;
|
|
||||||
int Size = 0;
|
|
||||||
|
|
||||||
void push_back(ImTriangulatorNode* node) { Data[Size++] = node; }
|
|
||||||
void find_erase_unsorted(int idx) { for (int i = Size - 1; i >= 0; i--) if (Data[i]->Index == idx) { Data[i] = Data[Size - 1]; Size--; return; } }
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ImTriangulator
|
|
||||||
{
|
|
||||||
static int EstimateTriangleCount(int points_count) { return (points_count < 3) ? 0 : points_count - 2; }
|
|
||||||
static int EstimateScratchBufferSize(int points_count) { return sizeof(ImTriangulatorNode) * points_count + sizeof(ImTriangulatorNode*) * points_count * 2; }
|
|
||||||
|
|
||||||
void Init(const ImVec2* points, int points_count, void* scratch_buffer);
|
|
||||||
void GetNextTriangle(unsigned int out_triangle[3]); // Return relative indexes for next triangle
|
|
||||||
|
|
||||||
// Internal functions
|
|
||||||
void BuildNodes(const ImVec2* points, int points_count);
|
|
||||||
void BuildReflexes();
|
|
||||||
void BuildEars();
|
|
||||||
void FlipNodeList();
|
|
||||||
bool IsEar(int i0, int i1, int i2, const ImVec2& v0, const ImVec2& v1, const ImVec2& v2) const;
|
|
||||||
void ReclassifyNode(ImTriangulatorNode* node);
|
|
||||||
|
|
||||||
// Internal members
|
|
||||||
int _TrianglesLeft = 0;
|
|
||||||
ImTriangulatorNode* _Nodes = NULL;
|
|
||||||
ImTriangulatorNodeSpan _Ears;
|
|
||||||
ImTriangulatorNodeSpan _Reflexes;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Distribute storage for nodes, ears and reflexes.
|
|
||||||
// FIXME-OPT: if everything is convex, we could report it to caller and let it switch to an convex renderer
|
|
||||||
// (this would require first building reflexes to bail to convex if empty, without even building nodes)
|
|
||||||
void ImTriangulator::Init(const ImVec2* points, int points_count, void* scratch_buffer)
|
|
||||||
{
|
|
||||||
IM_ASSERT(scratch_buffer != NULL && points_count >= 3);
|
|
||||||
_TrianglesLeft = EstimateTriangleCount(points_count);
|
|
||||||
_Nodes = (ImTriangulatorNode*)scratch_buffer; // points_count x Node
|
|
||||||
_Ears.Data = (ImTriangulatorNode**)(_Nodes + points_count); // points_count x Node*
|
|
||||||
_Reflexes.Data = (ImTriangulatorNode**)(_Nodes + points_count) + points_count; // points_count x Node*
|
|
||||||
BuildNodes(points, points_count);
|
|
||||||
BuildReflexes();
|
|
||||||
BuildEars();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImTriangulator::BuildNodes(const ImVec2* points, int points_count)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < points_count; i++)
|
|
||||||
{
|
|
||||||
_Nodes[i].Type = ImTriangulatorNodeType_Convex;
|
|
||||||
_Nodes[i].Index = i;
|
|
||||||
_Nodes[i].Pos = points[i];
|
|
||||||
_Nodes[i].Next = _Nodes + i + 1;
|
|
||||||
_Nodes[i].Prev = _Nodes + i - 1;
|
|
||||||
}
|
|
||||||
_Nodes[0].Prev = _Nodes + points_count - 1;
|
|
||||||
_Nodes[points_count - 1].Next = _Nodes;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImTriangulator::BuildReflexes()
|
|
||||||
{
|
|
||||||
ImTriangulatorNode* n1 = _Nodes;
|
|
||||||
for (int i = _TrianglesLeft; i >= 0; i--, n1 = n1->Next)
|
|
||||||
{
|
|
||||||
if (ImTriangleIsClockwise(n1->Prev->Pos, n1->Pos, n1->Next->Pos))
|
|
||||||
continue;
|
|
||||||
n1->Type = ImTriangulatorNodeType_Reflex;
|
|
||||||
_Reflexes.push_back(n1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImTriangulator::BuildEars()
|
|
||||||
{
|
|
||||||
ImTriangulatorNode* n1 = _Nodes;
|
|
||||||
for (int i = _TrianglesLeft; i >= 0; i--, n1 = n1->Next)
|
|
||||||
{
|
|
||||||
if (n1->Type != ImTriangulatorNodeType_Convex)
|
|
||||||
continue;
|
|
||||||
if (!IsEar(n1->Prev->Index, n1->Index, n1->Next->Index, n1->Prev->Pos, n1->Pos, n1->Next->Pos))
|
|
||||||
continue;
|
|
||||||
n1->Type = ImTriangulatorNodeType_Ear;
|
|
||||||
_Ears.push_back(n1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImTriangulator::GetNextTriangle(unsigned int out_triangle[3])
|
|
||||||
{
|
|
||||||
if (_Ears.Size == 0)
|
|
||||||
{
|
|
||||||
FlipNodeList();
|
|
||||||
|
|
||||||
ImTriangulatorNode* node = _Nodes;
|
|
||||||
for (int i = _TrianglesLeft; i >= 0; i--, node = node->Next)
|
|
||||||
node->Type = ImTriangulatorNodeType_Convex;
|
|
||||||
_Reflexes.Size = 0;
|
|
||||||
BuildReflexes();
|
|
||||||
BuildEars();
|
|
||||||
|
|
||||||
// If we still don't have ears, it means geometry is degenerated.
|
|
||||||
if (_Ears.Size == 0)
|
|
||||||
{
|
|
||||||
// Return first triangle available, mimicking the behavior of convex fill.
|
|
||||||
IM_ASSERT(_TrianglesLeft > 0); // Geometry is degenerated
|
|
||||||
_Ears.Data[0] = _Nodes;
|
|
||||||
_Ears.Size = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ImTriangulatorNode* ear = _Ears.Data[--_Ears.Size];
|
|
||||||
out_triangle[0] = ear->Prev->Index;
|
|
||||||
out_triangle[1] = ear->Index;
|
|
||||||
out_triangle[2] = ear->Next->Index;
|
|
||||||
|
|
||||||
ear->Unlink();
|
|
||||||
if (ear == _Nodes)
|
|
||||||
_Nodes = ear->Next;
|
|
||||||
|
|
||||||
ReclassifyNode(ear->Prev);
|
|
||||||
ReclassifyNode(ear->Next);
|
|
||||||
_TrianglesLeft--;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImTriangulator::FlipNodeList()
|
|
||||||
{
|
|
||||||
ImTriangulatorNode* prev = _Nodes;
|
|
||||||
ImTriangulatorNode* temp = _Nodes;
|
|
||||||
ImTriangulatorNode* current = _Nodes->Next;
|
|
||||||
prev->Next = prev;
|
|
||||||
prev->Prev = prev;
|
|
||||||
while (current != _Nodes)
|
|
||||||
{
|
|
||||||
temp = current->Next;
|
|
||||||
|
|
||||||
current->Next = prev;
|
|
||||||
prev->Prev = current;
|
|
||||||
_Nodes->Next = current;
|
|
||||||
current->Prev = _Nodes;
|
|
||||||
|
|
||||||
prev = current;
|
|
||||||
current = temp;
|
|
||||||
}
|
|
||||||
_Nodes = prev;
|
|
||||||
}
|
|
||||||
|
|
||||||
// A triangle is an ear is no other vertex is inside it. We can test reflexes vertices only (see reference algorithm)
|
|
||||||
bool ImTriangulator::IsEar(int i0, int i1, int i2, const ImVec2& v0, const ImVec2& v1, const ImVec2& v2) const
|
|
||||||
{
|
|
||||||
ImTriangulatorNode** p_end = _Reflexes.Data + _Reflexes.Size;
|
|
||||||
for (ImTriangulatorNode** p = _Reflexes.Data; p < p_end; p++)
|
|
||||||
{
|
|
||||||
ImTriangulatorNode* reflex = *p;
|
|
||||||
if (reflex->Index != i0 && reflex->Index != i1 && reflex->Index != i2)
|
|
||||||
if (ImTriangleContainsPoint(v0, v1, v2, reflex->Pos))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImTriangulator::ReclassifyNode(ImTriangulatorNode* n1)
|
|
||||||
{
|
|
||||||
// Classify node
|
|
||||||
ImTriangulatorNodeType type;
|
|
||||||
const ImTriangulatorNode* n0 = n1->Prev;
|
|
||||||
const ImTriangulatorNode* n2 = n1->Next;
|
|
||||||
if (!ImTriangleIsClockwise(n0->Pos, n1->Pos, n2->Pos))
|
|
||||||
type = ImTriangulatorNodeType_Reflex;
|
|
||||||
else if (IsEar(n0->Index, n1->Index, n2->Index, n0->Pos, n1->Pos, n2->Pos))
|
|
||||||
type = ImTriangulatorNodeType_Ear;
|
|
||||||
else
|
|
||||||
type = ImTriangulatorNodeType_Convex;
|
|
||||||
|
|
||||||
// Update lists when a type changes
|
|
||||||
if (type == n1->Type)
|
|
||||||
return;
|
|
||||||
if (n1->Type == ImTriangulatorNodeType_Reflex)
|
|
||||||
_Reflexes.find_erase_unsorted(n1->Index);
|
|
||||||
else if (n1->Type == ImTriangulatorNodeType_Ear)
|
|
||||||
_Ears.find_erase_unsorted(n1->Index);
|
|
||||||
if (type == ImTriangulatorNodeType_Reflex)
|
|
||||||
_Reflexes.push_back(n1);
|
|
||||||
else if (type == ImTriangulatorNodeType_Ear)
|
|
||||||
_Ears.push_back(n1);
|
|
||||||
n1->Type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use ear-clipping algorithm to triangulate a simple polygon (no self-interaction, no holes).
|
|
||||||
// (Reminder: we don't perform any coarse clipping/culling in ImDrawList layer!
|
|
||||||
// It is up to caller to ensure not making costly calls that will be outside of visible area.
|
|
||||||
// As concave fill is noticeably more expensive than other primitives, be mindful of this...
|
|
||||||
// Caller can build AABB of points, and avoid filling if 'draw_list->_CmdHeader.ClipRect.Overlays(points_bb) == false')
|
|
||||||
void ImDrawList::AddConcavePolyFilled(const ImVec2* points, const int points_count, ImU32 col)
|
|
||||||
{
|
|
||||||
if (points_count < 3 || (col & IM_COL32_A_MASK) == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
const ImVec2 uv = _Data->TexUvWhitePixel;
|
|
||||||
ImTriangulator triangulator;
|
|
||||||
unsigned int triangle[3];
|
|
||||||
if (Flags & ImDrawListFlags_AntiAliasedFill)
|
|
||||||
{
|
|
||||||
// Anti-aliased Fill
|
|
||||||
const float AA_SIZE = _FringeScale;
|
|
||||||
const ImU32 col_trans = col & ~IM_COL32_A_MASK;
|
|
||||||
const int idx_count = (points_count - 2) * 3 + points_count * 6;
|
|
||||||
const int vtx_count = (points_count * 2);
|
|
||||||
PrimReserve(idx_count, vtx_count);
|
|
||||||
|
|
||||||
// Add indexes for fill
|
|
||||||
unsigned int vtx_inner_idx = _VtxCurrentIdx;
|
|
||||||
unsigned int vtx_outer_idx = _VtxCurrentIdx + 1;
|
|
||||||
|
|
||||||
_Data->TempBuffer.reserve_discard((ImTriangulator::EstimateScratchBufferSize(points_count) + sizeof(ImVec2)) / sizeof(ImVec2));
|
|
||||||
triangulator.Init(points, points_count, _Data->TempBuffer.Data);
|
|
||||||
while (triangulator._TrianglesLeft > 0)
|
|
||||||
{
|
|
||||||
triangulator.GetNextTriangle(triangle);
|
|
||||||
_IdxWritePtr[0] = (ImDrawIdx)(vtx_inner_idx + (triangle[0] << 1)); _IdxWritePtr[1] = (ImDrawIdx)(vtx_inner_idx + (triangle[1] << 1)); _IdxWritePtr[2] = (ImDrawIdx)(vtx_inner_idx + (triangle[2] << 1));
|
|
||||||
_IdxWritePtr += 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compute normals
|
|
||||||
_Data->TempBuffer.reserve_discard(points_count);
|
|
||||||
ImVec2* temp_normals = _Data->TempBuffer.Data;
|
|
||||||
for (int i0 = points_count - 1, i1 = 0; i1 < points_count; i0 = i1++)
|
|
||||||
{
|
|
||||||
const ImVec2& p0 = points[i0];
|
|
||||||
const ImVec2& p1 = points[i1];
|
|
||||||
float dx = p1.x - p0.x;
|
|
||||||
float dy = p1.y - p0.y;
|
|
||||||
IM_NORMALIZE2F_OVER_ZERO(dx, dy);
|
|
||||||
temp_normals[i0].x = dy;
|
|
||||||
temp_normals[i0].y = -dx;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i0 = points_count - 1, i1 = 0; i1 < points_count; i0 = i1++)
|
|
||||||
{
|
|
||||||
// Average normals
|
|
||||||
const ImVec2& n0 = temp_normals[i0];
|
|
||||||
const ImVec2& n1 = temp_normals[i1];
|
|
||||||
float dm_x = (n0.x + n1.x) * 0.5f;
|
|
||||||
float dm_y = (n0.y + n1.y) * 0.5f;
|
|
||||||
IM_FIXNORMAL2F(dm_x, dm_y);
|
|
||||||
dm_x *= AA_SIZE * 0.5f;
|
|
||||||
dm_y *= AA_SIZE * 0.5f;
|
|
||||||
|
|
||||||
// Add vertices
|
|
||||||
_VtxWritePtr[0].pos.x = (points[i1].x - dm_x); _VtxWritePtr[0].pos.y = (points[i1].y - dm_y); _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col; // Inner
|
|
||||||
_VtxWritePtr[1].pos.x = (points[i1].x + dm_x); _VtxWritePtr[1].pos.y = (points[i1].y + dm_y); _VtxWritePtr[1].uv = uv; _VtxWritePtr[1].col = col_trans; // Outer
|
|
||||||
_VtxWritePtr += 2;
|
|
||||||
|
|
||||||
// Add indexes for fringes
|
|
||||||
_IdxWritePtr[0] = (ImDrawIdx)(vtx_inner_idx + (i1 << 1)); _IdxWritePtr[1] = (ImDrawIdx)(vtx_inner_idx + (i0 << 1)); _IdxWritePtr[2] = (ImDrawIdx)(vtx_outer_idx + (i0 << 1));
|
|
||||||
_IdxWritePtr[3] = (ImDrawIdx)(vtx_outer_idx + (i0 << 1)); _IdxWritePtr[4] = (ImDrawIdx)(vtx_outer_idx + (i1 << 1)); _IdxWritePtr[5] = (ImDrawIdx)(vtx_inner_idx + (i1 << 1));
|
|
||||||
_IdxWritePtr += 6;
|
|
||||||
}
|
|
||||||
_VtxCurrentIdx += (ImDrawIdx)vtx_count;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Non Anti-aliased Fill
|
|
||||||
const int idx_count = (points_count - 2) * 3;
|
|
||||||
const int vtx_count = points_count;
|
|
||||||
PrimReserve(idx_count, vtx_count);
|
|
||||||
for (int i = 0; i < vtx_count; i++)
|
|
||||||
{
|
|
||||||
_VtxWritePtr[0].pos = points[i]; _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col;
|
|
||||||
_VtxWritePtr++;
|
|
||||||
}
|
|
||||||
_Data->TempBuffer.reserve_discard((ImTriangulator::EstimateScratchBufferSize(points_count) + sizeof(ImVec2)) / sizeof(ImVec2));
|
|
||||||
triangulator.Init(points, points_count, _Data->TempBuffer.Data);
|
|
||||||
while (triangulator._TrianglesLeft > 0)
|
|
||||||
{
|
|
||||||
triangulator.GetNextTriangle(triangle);
|
|
||||||
_IdxWritePtr[0] = (ImDrawIdx)(_VtxCurrentIdx + triangle[0]); _IdxWritePtr[1] = (ImDrawIdx)(_VtxCurrentIdx + triangle[1]); _IdxWritePtr[2] = (ImDrawIdx)(_VtxCurrentIdx + triangle[2]);
|
|
||||||
_IdxWritePtr += 3;
|
|
||||||
}
|
|
||||||
_VtxCurrentIdx += (ImDrawIdx)vtx_count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] ImDrawListSplitter
|
// [SECTION] ImDrawListSplitter
|
||||||
@ -2985,8 +2672,8 @@ static bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
|
|||||||
int unscaled_ascent, unscaled_descent, unscaled_line_gap;
|
int unscaled_ascent, unscaled_descent, unscaled_line_gap;
|
||||||
stbtt_GetFontVMetrics(&src_tmp.FontInfo, &unscaled_ascent, &unscaled_descent, &unscaled_line_gap);
|
stbtt_GetFontVMetrics(&src_tmp.FontInfo, &unscaled_ascent, &unscaled_descent, &unscaled_line_gap);
|
||||||
|
|
||||||
const float ascent = ImCeil(unscaled_ascent * font_scale);
|
const float ascent = ImTrunc(unscaled_ascent * font_scale + ((unscaled_ascent > 0.0f) ? +1 : -1));
|
||||||
const float descent = ImFloor(unscaled_descent * font_scale);
|
const float descent = ImTrunc(unscaled_descent * font_scale + ((unscaled_descent > 0.0f) ? +1 : -1));
|
||||||
ImFontAtlasBuildSetupFont(atlas, dst_font, &cfg, ascent, descent);
|
ImFontAtlasBuildSetupFont(atlas, dst_font, &cfg, ascent, descent);
|
||||||
const float font_off_x = cfg.GlyphOffset.x;
|
const float font_off_x = cfg.GlyphOffset.x;
|
||||||
const float font_off_y = cfg.GlyphOffset.y + IM_ROUND(dst_font->Ascent);
|
const float font_off_y = cfg.GlyphOffset.y + IM_ROUND(dst_font->Ascent);
|
||||||
@ -4081,8 +3768,6 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, const ImVec2& pos, Im
|
|||||||
{
|
{
|
||||||
x = start_x;
|
x = start_x;
|
||||||
y += line_height;
|
y += line_height;
|
||||||
if (y > clip_rect.w)
|
|
||||||
break; // break out of main loop
|
|
||||||
word_wrap_eol = NULL;
|
word_wrap_eol = NULL;
|
||||||
s = CalcWordWrapNextLineStartA(s, text_end); // Wrapping skips upcoming blanks
|
s = CalcWordWrapNextLineStartA(s, text_end); // Wrapping skips upcoming blanks
|
||||||
continue;
|
continue;
|
||||||
@ -4312,8 +3997,8 @@ void ImGui::RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, Im
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
draw_list->PathArcTo(ImVec2(x0, p1.y - rounding), rounding, IM_PI - arc0_e, IM_PI - arc0_b); // BL
|
draw_list->PathArcTo(ImVec2(x0, p1.y - rounding), rounding, IM_PI - arc0_e, IM_PI - arc0_b, 3); // BL
|
||||||
draw_list->PathArcTo(ImVec2(x0, p0.y + rounding), rounding, IM_PI + arc0_b, IM_PI + arc0_e); // TR
|
draw_list->PathArcTo(ImVec2(x0, p0.y + rounding), rounding, IM_PI + arc0_b, IM_PI + arc0_e, 3); // TR
|
||||||
}
|
}
|
||||||
if (p1.x > rect.Min.x + rounding)
|
if (p1.x > rect.Min.x + rounding)
|
||||||
{
|
{
|
||||||
@ -4332,8 +4017,8 @@ void ImGui::RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, Im
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
draw_list->PathArcTo(ImVec2(x1, p0.y + rounding), rounding, -arc1_e, -arc1_b); // TR
|
draw_list->PathArcTo(ImVec2(x1, p0.y + rounding), rounding, -arc1_e, -arc1_b, 3); // TR
|
||||||
draw_list->PathArcTo(ImVec2(x1, p1.y - rounding), rounding, +arc1_b, +arc1_e); // BR
|
draw_list->PathArcTo(ImVec2(x1, p1.y - rounding), rounding, +arc1_b, +arc1_e, 3); // BR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
draw_list->PathFillConvex(col);
|
draw_list->PathFillConvex(col);
|
||||||
|
408
external/imgui/imgui/imgui_internal.h
vendored
408
external/imgui/imgui/imgui_internal.h
vendored
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.90.7
|
// dear imgui, v1.90.1
|
||||||
// (internal structures/api)
|
// (internal structures/api)
|
||||||
|
|
||||||
// You may use this file to debug, understand or extend Dear ImGui features but we don't provide any guarantee of forward compatibility.
|
// You may use this file to debug, understand or extend Dear ImGui features but we don't provide any guarantee of forward compatibility.
|
||||||
@ -15,8 +15,6 @@ Index of this file:
|
|||||||
// [SECTION] Generic helpers
|
// [SECTION] Generic helpers
|
||||||
// [SECTION] ImDrawList support
|
// [SECTION] ImDrawList support
|
||||||
// [SECTION] Widgets support: flags, enums, data structures
|
// [SECTION] Widgets support: flags, enums, data structures
|
||||||
// [SECTION] Data types support
|
|
||||||
// [SECTION] Popup support
|
|
||||||
// [SECTION] Inputs support
|
// [SECTION] Inputs support
|
||||||
// [SECTION] Clipper support
|
// [SECTION] Clipper support
|
||||||
// [SECTION] Navigation support
|
// [SECTION] Navigation support
|
||||||
@ -87,8 +85,6 @@ Index of this file:
|
|||||||
#pragma clang diagnostic ignored "-Wdouble-promotion"
|
#pragma clang diagnostic ignored "-Wdouble-promotion"
|
||||||
#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision
|
#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision
|
||||||
#pragma clang diagnostic ignored "-Wmissing-noreturn" // warning: function 'xxx' could be declared with attribute 'noreturn'
|
#pragma clang diagnostic ignored "-Wmissing-noreturn" // warning: function 'xxx' could be declared with attribute 'noreturn'
|
||||||
#pragma clang diagnostic ignored "-Wdeprecated-enum-enum-conversion"// warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_') is deprecated
|
|
||||||
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" // warning: 'xxx' is an unsafe pointer used for buffer access
|
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
||||||
@ -126,7 +122,7 @@ struct ImDrawListSharedData; // Data shared between all ImDrawList instan
|
|||||||
struct ImGuiColorMod; // Stacked color modifier, backup of modified data so we can restore it
|
struct ImGuiColorMod; // Stacked color modifier, backup of modified data so we can restore it
|
||||||
struct ImGuiContext; // Main Dear ImGui context
|
struct ImGuiContext; // Main Dear ImGui context
|
||||||
struct ImGuiContextHook; // Hook for extensions like ImGuiTestEngine
|
struct ImGuiContextHook; // Hook for extensions like ImGuiTestEngine
|
||||||
struct ImGuiDataVarInfo; // Variable information (e.g. to access style variables from an enum)
|
struct ImGuiDataVarInfo; // Variable information (e.g. to avoid style variables from an enum)
|
||||||
struct ImGuiDataTypeInfo; // Type information associated to a ImGuiDataType enum
|
struct ImGuiDataTypeInfo; // Type information associated to a ImGuiDataType enum
|
||||||
struct ImGuiGroupData; // Stacked storage data for BeginGroup()/EndGroup()
|
struct ImGuiGroupData; // Stacked storage data for BeginGroup()/EndGroup()
|
||||||
struct ImGuiInputTextState; // Internal state of the currently focused/edited text input box
|
struct ImGuiInputTextState; // Internal state of the currently focused/edited text input box
|
||||||
@ -148,7 +144,6 @@ struct ImGuiStyleMod; // Stacked style modifier, backup of modifie
|
|||||||
struct ImGuiTabBar; // Storage for a tab bar
|
struct ImGuiTabBar; // Storage for a tab bar
|
||||||
struct ImGuiTabItem; // Storage for a tab item (within a tab bar)
|
struct ImGuiTabItem; // Storage for a tab item (within a tab bar)
|
||||||
struct ImGuiTable; // Storage for a table
|
struct ImGuiTable; // Storage for a table
|
||||||
struct ImGuiTableHeaderData; // Storage for TableAngledHeadersRow()
|
|
||||||
struct ImGuiTableColumn; // Storage for one column of a table
|
struct ImGuiTableColumn; // Storage for one column of a table
|
||||||
struct ImGuiTableInstanceData; // Storage for one instance of a same table
|
struct ImGuiTableInstanceData; // Storage for one instance of a same table
|
||||||
struct ImGuiTableTempData; // Temporary storage for one table (one per table in the stack), shared between tables.
|
struct ImGuiTableTempData; // Temporary storage for one table (one per table in the stack), shared between tables.
|
||||||
@ -169,6 +164,7 @@ typedef int ImGuiLayoutType; // -> enum ImGuiLayoutType_ // E
|
|||||||
typedef int ImGuiActivateFlags; // -> enum ImGuiActivateFlags_ // Flags: for navigation/focus function (will be for ActivateItem() later)
|
typedef int ImGuiActivateFlags; // -> enum ImGuiActivateFlags_ // Flags: for navigation/focus function (will be for ActivateItem() later)
|
||||||
typedef int ImGuiDebugLogFlags; // -> enum ImGuiDebugLogFlags_ // Flags: for ShowDebugLogWindow(), g.DebugLogFlags
|
typedef int ImGuiDebugLogFlags; // -> enum ImGuiDebugLogFlags_ // Flags: for ShowDebugLogWindow(), g.DebugLogFlags
|
||||||
typedef int ImGuiFocusRequestFlags; // -> enum ImGuiFocusRequestFlags_ // Flags: for FocusWindow();
|
typedef int ImGuiFocusRequestFlags; // -> enum ImGuiFocusRequestFlags_ // Flags: for FocusWindow();
|
||||||
|
typedef int ImGuiInputFlags; // -> enum ImGuiInputFlags_ // Flags: for IsKeyPressed(), IsMouseClicked(), SetKeyOwner(), SetItemKeyOwner() etc.
|
||||||
typedef int ImGuiItemFlags; // -> enum ImGuiItemFlags_ // Flags: for PushItemFlag(), g.LastItemData.InFlags
|
typedef int ImGuiItemFlags; // -> enum ImGuiItemFlags_ // Flags: for PushItemFlag(), g.LastItemData.InFlags
|
||||||
typedef int ImGuiItemStatusFlags; // -> enum ImGuiItemStatusFlags_ // Flags: for g.LastItemData.StatusFlags
|
typedef int ImGuiItemStatusFlags; // -> enum ImGuiItemStatusFlags_ // Flags: for g.LastItemData.StatusFlags
|
||||||
typedef int ImGuiOldColumnFlags; // -> enum ImGuiOldColumnFlags_ // Flags: for BeginColumns()
|
typedef int ImGuiOldColumnFlags; // -> enum ImGuiOldColumnFlags_ // Flags: for BeginColumns()
|
||||||
@ -181,7 +177,6 @@ typedef int ImGuiSeparatorFlags; // -> enum ImGuiSeparatorFlags_ // F
|
|||||||
typedef int ImGuiTextFlags; // -> enum ImGuiTextFlags_ // Flags: for TextEx()
|
typedef int ImGuiTextFlags; // -> enum ImGuiTextFlags_ // Flags: for TextEx()
|
||||||
typedef int ImGuiTooltipFlags; // -> enum ImGuiTooltipFlags_ // Flags: for BeginTooltipEx()
|
typedef int ImGuiTooltipFlags; // -> enum ImGuiTooltipFlags_ // Flags: for BeginTooltipEx()
|
||||||
typedef int ImGuiTypingSelectFlags; // -> enum ImGuiTypingSelectFlags_ // Flags: for GetTypingSelectRequest()
|
typedef int ImGuiTypingSelectFlags; // -> enum ImGuiTypingSelectFlags_ // Flags: for GetTypingSelectRequest()
|
||||||
typedef int ImGuiWindowRefreshFlags; // -> enum ImGuiWindowRefreshFlags_ // Flags: for SetNextWindowRefreshPolicy()
|
|
||||||
|
|
||||||
typedef void (*ImGuiErrorLogCallback)(void* user_data, const char* fmt, ...);
|
typedef void (*ImGuiErrorLogCallback)(void* user_data, const char* fmt, ...);
|
||||||
|
|
||||||
@ -239,7 +234,6 @@ namespace ImStb
|
|||||||
#define IMGUI_DEBUG_LOG_SELECTION(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventSelection) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
#define IMGUI_DEBUG_LOG_SELECTION(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventSelection) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
||||||
#define IMGUI_DEBUG_LOG_CLIPPER(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventClipper) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
#define IMGUI_DEBUG_LOG_CLIPPER(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventClipper) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
||||||
#define IMGUI_DEBUG_LOG_IO(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventIO) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
#define IMGUI_DEBUG_LOG_IO(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventIO) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
||||||
#define IMGUI_DEBUG_LOG_INPUTROUTING(...) do{if (g.DebugLogFlags & ImGuiDebugLogFlags_EventInputRouting)IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)
|
|
||||||
|
|
||||||
// Static Asserts
|
// Static Asserts
|
||||||
#define IM_STATIC_ASSERT(_COND) static_assert(_COND, "")
|
#define IM_STATIC_ASSERT(_COND) static_assert(_COND, "")
|
||||||
@ -303,11 +297,11 @@ namespace ImStb
|
|||||||
#elif defined(__clang__)
|
#elif defined(__clang__)
|
||||||
#define IM_DEBUG_BREAK() __builtin_debugtrap()
|
#define IM_DEBUG_BREAK() __builtin_debugtrap()
|
||||||
#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
|
#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
|
||||||
#define IM_DEBUG_BREAK() __asm__ volatile("int3;nop")
|
#define IM_DEBUG_BREAK() __asm__ volatile("int $0x03")
|
||||||
#elif defined(__GNUC__) && defined(__thumb__)
|
#elif defined(__GNUC__) && defined(__thumb__)
|
||||||
#define IM_DEBUG_BREAK() __asm__ volatile(".inst 0xde01")
|
#define IM_DEBUG_BREAK() __asm__ volatile(".inst 0xde01")
|
||||||
#elif defined(__GNUC__) && defined(__arm__) && !defined(__thumb__)
|
#elif defined(__GNUC__) && defined(__arm__) && !defined(__thumb__)
|
||||||
#define IM_DEBUG_BREAK() __asm__ volatile(".inst 0xe7f001f0")
|
#define IM_DEBUG_BREAK() __asm__ volatile(".inst 0xe7f001f0");
|
||||||
#else
|
#else
|
||||||
#define IM_DEBUG_BREAK() IM_ASSERT(0) // It is expected that you define IM_DEBUG_BREAK() into something that will break nicely in a debugger!
|
#define IM_DEBUG_BREAK() IM_ASSERT(0) // It is expected that you define IM_DEBUG_BREAK() into something that will break nicely in a debugger!
|
||||||
#endif
|
#endif
|
||||||
@ -407,7 +401,6 @@ IMGUI_API int ImTextCountCharsFromUtf8(const char* in_text, const char
|
|||||||
IMGUI_API int ImTextCountUtf8BytesFromChar(const char* in_text, const char* in_text_end); // return number of bytes to express one char in UTF-8
|
IMGUI_API int ImTextCountUtf8BytesFromChar(const char* in_text, const char* in_text_end); // return number of bytes to express one char in UTF-8
|
||||||
IMGUI_API int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end); // return number of bytes to express string in UTF-8
|
IMGUI_API int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end); // return number of bytes to express string in UTF-8
|
||||||
IMGUI_API const char* ImTextFindPreviousUtf8Codepoint(const char* in_text_start, const char* in_text_curr); // return previous UTF-8 code-point.
|
IMGUI_API const char* ImTextFindPreviousUtf8Codepoint(const char* in_text_start, const char* in_text_curr); // return previous UTF-8 code-point.
|
||||||
IMGUI_API int ImTextCountLines(const char* in_text, const char* in_text_end); // return number of lines taken by text. trailing carriage return doesn't count as an extra line.
|
|
||||||
|
|
||||||
// Helpers: File System
|
// Helpers: File System
|
||||||
#ifdef IMGUI_DISABLE_FILE_FUNCTIONS
|
#ifdef IMGUI_DISABLE_FILE_FUNCTIONS
|
||||||
@ -503,7 +496,6 @@ IMGUI_API bool ImTriangleContainsPoint(const ImVec2& a, const ImVec2& b, c
|
|||||||
IMGUI_API ImVec2 ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p);
|
IMGUI_API ImVec2 ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p);
|
||||||
IMGUI_API void ImTriangleBarycentricCoords(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p, float& out_u, float& out_v, float& out_w);
|
IMGUI_API void ImTriangleBarycentricCoords(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p, float& out_u, float& out_v, float& out_w);
|
||||||
inline float ImTriangleArea(const ImVec2& a, const ImVec2& b, const ImVec2& c) { return ImFabs((a.x * (b.y - c.y)) + (b.x * (c.y - a.y)) + (c.x * (a.y - b.y))) * 0.5f; }
|
inline float ImTriangleArea(const ImVec2& a, const ImVec2& b, const ImVec2& c) { return ImFabs((a.x * (b.y - c.y)) + (b.x * (c.y - a.y)) + (c.x * (a.y - b.y))) * 0.5f; }
|
||||||
inline bool ImTriangleIsClockwise(const ImVec2& a, const ImVec2& b, const ImVec2& c) { return ((b.x - a.x) * (c.y - b.y)) - ((c.x - b.x) * (b.y - a.y)) > 0.0f; }
|
|
||||||
|
|
||||||
// Helper: ImVec1 (1D vector)
|
// Helper: ImVec1 (1D vector)
|
||||||
// (this odd construct is used to facilitate the transition between 1D and 2D, and the maintenance of some branches/patches)
|
// (this odd construct is used to facilitate the transition between 1D and 2D, and the maintenance of some branches/patches)
|
||||||
@ -697,6 +689,9 @@ struct ImPool
|
|||||||
int GetBufSize() const { return Buf.Size; }
|
int GetBufSize() const { return Buf.Size; }
|
||||||
int GetMapSize() const { return Map.Data.Size; } // It is the map we need iterate to find valid items, since we don't have "alive" storage anywhere
|
int GetMapSize() const { return Map.Data.Size; } // It is the map we need iterate to find valid items, since we don't have "alive" storage anywhere
|
||||||
T* TryGetMapData(ImPoolIdx n) { int idx = Map.Data[n].val_i; if (idx == -1) return NULL; return GetByIndex(idx); }
|
T* TryGetMapData(ImPoolIdx n) { int idx = Map.Data[n].val_i; if (idx == -1) return NULL; return GetByIndex(idx); }
|
||||||
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
|
int GetSize() { return GetMapSize(); } // For ImPlot: should use GetMapSize() from (IMGUI_VERSION_NUM >= 18304)
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
// Helper: ImChunkStream<>
|
// Helper: ImChunkStream<>
|
||||||
@ -841,8 +836,7 @@ enum ImGuiItemStatusFlags_
|
|||||||
ImGuiItemStatusFlags_Deactivated = 1 << 6, // Only valid if ImGuiItemStatusFlags_HasDeactivated is set.
|
ImGuiItemStatusFlags_Deactivated = 1 << 6, // Only valid if ImGuiItemStatusFlags_HasDeactivated is set.
|
||||||
ImGuiItemStatusFlags_HoveredWindow = 1 << 7, // Override the HoveredWindow test to allow cross-window hover testing.
|
ImGuiItemStatusFlags_HoveredWindow = 1 << 7, // Override the HoveredWindow test to allow cross-window hover testing.
|
||||||
ImGuiItemStatusFlags_Visible = 1 << 8, // [WIP] Set when item is overlapping the current clipping rectangle (Used internally. Please don't use yet: API/system will change as we refactor Itemadd()).
|
ImGuiItemStatusFlags_Visible = 1 << 8, // [WIP] Set when item is overlapping the current clipping rectangle (Used internally. Please don't use yet: API/system will change as we refactor Itemadd()).
|
||||||
ImGuiItemStatusFlags_HasClipRect = 1 << 9, // g.LastItemData.ClipRect is valid.
|
ImGuiItemStatusFlags_HasClipRect = 1 << 9, // g.LastItemData.ClipRect is valid
|
||||||
ImGuiItemStatusFlags_HasShortcut = 1 << 10, // g.LastItemData.Shortcut valid. Set by SetNextItemShortcut() -> ItemAdd().
|
|
||||||
|
|
||||||
// Additional status + semantic for ImGuiTestEngine
|
// Additional status + semantic for ImGuiTestEngine
|
||||||
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||||
@ -869,7 +863,6 @@ enum ImGuiInputTextFlagsPrivate_
|
|||||||
ImGuiInputTextFlags_Multiline = 1 << 26, // For internal use by InputTextMultiline()
|
ImGuiInputTextFlags_Multiline = 1 << 26, // For internal use by InputTextMultiline()
|
||||||
ImGuiInputTextFlags_NoMarkEdited = 1 << 27, // For internal use by functions using InputText() before reformatting data
|
ImGuiInputTextFlags_NoMarkEdited = 1 << 27, // For internal use by functions using InputText() before reformatting data
|
||||||
ImGuiInputTextFlags_MergedItem = 1 << 28, // For internal use by TempInputText(), will skip calling ItemAdd(). Require bounding-box to strictly match.
|
ImGuiInputTextFlags_MergedItem = 1 << 28, // For internal use by TempInputText(), will skip calling ItemAdd(). Require bounding-box to strictly match.
|
||||||
ImGuiInputTextFlags_LocalizeDecimalPoint= 1 << 29, // For internal use by InputScalar() and TempInputScalar()
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Extend ImGuiButtonFlags_
|
// Extend ImGuiButtonFlags_
|
||||||
@ -992,6 +985,43 @@ enum ImGuiPlotType
|
|||||||
ImGuiPlotType_Histogram,
|
ImGuiPlotType_Histogram,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ImGuiPopupPositionPolicy
|
||||||
|
{
|
||||||
|
ImGuiPopupPositionPolicy_Default,
|
||||||
|
ImGuiPopupPositionPolicy_ComboBox,
|
||||||
|
ImGuiPopupPositionPolicy_Tooltip,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ImGuiDataVarInfo
|
||||||
|
{
|
||||||
|
ImGuiDataType Type;
|
||||||
|
ImU32 Count; // 1+
|
||||||
|
ImU32 Offset; // Offset in parent structure
|
||||||
|
void* GetVarPtr(void* parent) const { return (void*)((unsigned char*)parent + Offset); }
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ImGuiDataTypeTempStorage
|
||||||
|
{
|
||||||
|
ImU8 Data[8]; // Can fit any data up to ImGuiDataType_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
|
// Type information associated to one ImGuiDataType. Retrieve with DataTypeGetInfo().
|
||||||
|
struct ImGuiDataTypeInfo
|
||||||
|
{
|
||||||
|
size_t Size; // Size in bytes
|
||||||
|
const char* Name; // Short descriptive name for the type, for debugging
|
||||||
|
const char* PrintFmt; // Default printf format for the type
|
||||||
|
const char* ScanFmt; // Default scanf format for the type
|
||||||
|
};
|
||||||
|
|
||||||
|
// Extend ImGuiDataType_
|
||||||
|
enum ImGuiDataTypePrivate_
|
||||||
|
{
|
||||||
|
ImGuiDataType_String = ImGuiDataType_COUNT + 1,
|
||||||
|
ImGuiDataType_Pointer,
|
||||||
|
ImGuiDataType_ID,
|
||||||
|
};
|
||||||
|
|
||||||
// Stacked color modifier, backup of modified data so we can restore it
|
// Stacked color modifier, backup of modified data so we can restore it
|
||||||
struct ImGuiColorMod
|
struct ImGuiColorMod
|
||||||
{
|
{
|
||||||
@ -1076,7 +1106,7 @@ struct IMGUI_API ImGuiInputTextState
|
|||||||
int CurLenW, CurLenA; // we need to maintain our buffer length in both UTF-8 and wchar format. UTF-8 length is valid even if TextA is not.
|
int CurLenW, CurLenA; // we need to maintain our buffer length in both UTF-8 and wchar format. UTF-8 length is valid even if TextA is not.
|
||||||
ImVector<ImWchar> TextW; // edit buffer, we need to persist but can't guarantee the persistence of the user-provided buffer. so we copy into own buffer.
|
ImVector<ImWchar> TextW; // edit buffer, we need to persist but can't guarantee the persistence of the user-provided buffer. so we copy into own buffer.
|
||||||
ImVector<char> TextA; // temporary UTF8 buffer for callbacks and other operations. this is not updated in every code-path! size=capacity.
|
ImVector<char> TextA; // temporary UTF8 buffer for callbacks and other operations. this is not updated in every code-path! size=capacity.
|
||||||
ImVector<char> InitialTextA; // value to revert to when pressing Escape = backup of end-user buffer at the time of focus (in UTF-8, unaltered)
|
ImVector<char> InitialTextA; // backup of end-user buffer at the time of focus (in UTF-8, unaltered)
|
||||||
bool TextAIsValid; // temporary UTF8 buffer is not initially valid before we make the widget active (until then we pull the data from user argument)
|
bool TextAIsValid; // temporary UTF8 buffer is not initially valid before we make the widget active (until then we pull the data from user argument)
|
||||||
int BufCapacityA; // end-user buffer capacity
|
int BufCapacityA; // end-user buffer capacity
|
||||||
float ScrollX; // horizontal scrolling/offset
|
float ScrollX; // horizontal scrolling/offset
|
||||||
@ -1086,9 +1116,6 @@ struct IMGUI_API ImGuiInputTextState
|
|||||||
bool SelectedAllMouseLock; // after a double-click to select all, we ignore further mouse drags to update selection
|
bool SelectedAllMouseLock; // after a double-click to select all, we ignore further mouse drags to update selection
|
||||||
bool Edited; // edited this frame
|
bool Edited; // edited this frame
|
||||||
ImGuiInputTextFlags Flags; // copy of InputText() flags. may be used to check if e.g. ImGuiInputTextFlags_Password is set.
|
ImGuiInputTextFlags Flags; // copy of InputText() flags. may be used to check if e.g. ImGuiInputTextFlags_Password is set.
|
||||||
bool ReloadUserBuf; // force a reload of user buf so it may be modified externally. may be automatic in future version.
|
|
||||||
int ReloadSelectionStart; // POSITIONS ARE IN IMWCHAR units *NOT* UTF-8 this is why this is not exposed yet.
|
|
||||||
int ReloadSelectionEnd;
|
|
||||||
|
|
||||||
ImGuiInputTextState() { memset(this, 0, sizeof(*this)); }
|
ImGuiInputTextState() { memset(this, 0, sizeof(*this)); }
|
||||||
void ClearText() { CurLenW = CurLenA = 0; TextW[0] = 0; TextA[0] = 0; CursorClamp(); }
|
void ClearText() { CurLenW = CurLenA = 0; TextW[0] = 0; TextA[0] = 0; CursorClamp(); }
|
||||||
@ -1106,25 +1133,21 @@ struct IMGUI_API ImGuiInputTextState
|
|||||||
int GetSelectionStart() const { return Stb.select_start; }
|
int GetSelectionStart() const { return Stb.select_start; }
|
||||||
int GetSelectionEnd() const { return Stb.select_end; }
|
int GetSelectionEnd() const { return Stb.select_end; }
|
||||||
void SelectAll() { Stb.select_start = 0; Stb.cursor = Stb.select_end = CurLenW; Stb.has_preferred_x = 0; }
|
void SelectAll() { Stb.select_start = 0; Stb.cursor = Stb.select_end = CurLenW; Stb.has_preferred_x = 0; }
|
||||||
|
|
||||||
// Reload user buf (WIP #2890)
|
|
||||||
// If you modify underlying user-passed const char* while active you need to call this (InputText V2 may lift this)
|
|
||||||
// strcpy(my_buf, "hello");
|
|
||||||
// if (ImGuiInputTextState* state = ImGui::GetInputTextState(id)) // id may be ImGui::GetItemID() is last item
|
|
||||||
// state->ReloadUserBufAndSelectAll();
|
|
||||||
void ReloadUserBufAndSelectAll() { ReloadUserBuf = true; ReloadSelectionStart = 0; ReloadSelectionEnd = INT_MAX; }
|
|
||||||
void ReloadUserBufAndKeepSelection() { ReloadUserBuf = true; ReloadSelectionStart = Stb.select_start; ReloadSelectionEnd = Stb.select_end; }
|
|
||||||
void ReloadUserBufAndMoveToEnd() { ReloadUserBuf = true; ReloadSelectionStart = ReloadSelectionEnd = INT_MAX; }
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ImGuiWindowRefreshFlags_
|
// Storage for current popup stack
|
||||||
|
struct ImGuiPopupData
|
||||||
{
|
{
|
||||||
ImGuiWindowRefreshFlags_None = 0,
|
ImGuiID PopupId; // Set on OpenPopup()
|
||||||
ImGuiWindowRefreshFlags_TryToAvoidRefresh = 1 << 0, // [EXPERIMENTAL] Try to keep existing contents, USER MUST NOT HONOR BEGIN() RETURNING FALSE AND NOT APPEND.
|
ImGuiWindow* Window; // Resolved on BeginPopup() - may stay unresolved if user never calls OpenPopup()
|
||||||
ImGuiWindowRefreshFlags_RefreshOnHover = 1 << 1, // [EXPERIMENTAL] Always refresh on hover
|
ImGuiWindow* BackupNavWindow;// Set on OpenPopup(), a NavWindow that will be restored on popup close
|
||||||
ImGuiWindowRefreshFlags_RefreshOnFocus = 1 << 2, // [EXPERIMENTAL] Always refresh on focus
|
int ParentNavLayer; // Resolved on BeginPopup(). Actually a ImGuiNavLayer type (declared down below), initialized to -1 which is not part of an enum, but serves well-enough as "not any of layers" value
|
||||||
// Refresh policy/frequency, Load Balancing etc.
|
int OpenFrameCount; // Set on OpenPopup()
|
||||||
|
ImGuiID OpenParentId; // Set on OpenPopup(), we need this to differentiate multiple menu sets from each others (e.g. inside menu bar vs loose menu items)
|
||||||
|
ImVec2 OpenPopupPos; // Set on OpenPopup(), preferred popup position (typically == OpenMousePos when using mouse)
|
||||||
|
ImVec2 OpenMousePos; // Set on OpenPopup(), copy of mouse position at the time of opening popup
|
||||||
|
|
||||||
|
ImGuiPopupData() { memset(this, 0, sizeof(*this)); ParentNavLayer = OpenFrameCount = -1; }
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ImGuiNextWindowDataFlags_
|
enum ImGuiNextWindowDataFlags_
|
||||||
@ -1139,7 +1162,6 @@ enum ImGuiNextWindowDataFlags_
|
|||||||
ImGuiNextWindowDataFlags_HasBgAlpha = 1 << 6,
|
ImGuiNextWindowDataFlags_HasBgAlpha = 1 << 6,
|
||||||
ImGuiNextWindowDataFlags_HasScroll = 1 << 7,
|
ImGuiNextWindowDataFlags_HasScroll = 1 << 7,
|
||||||
ImGuiNextWindowDataFlags_HasChildFlags = 1 << 8,
|
ImGuiNextWindowDataFlags_HasChildFlags = 1 << 8,
|
||||||
ImGuiNextWindowDataFlags_HasRefreshPolicy = 1 << 9,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Storage for SetNexWindow** functions
|
// Storage for SetNexWindow** functions
|
||||||
@ -1161,7 +1183,6 @@ struct ImGuiNextWindowData
|
|||||||
void* SizeCallbackUserData;
|
void* SizeCallbackUserData;
|
||||||
float BgAlphaVal; // Override background alpha
|
float BgAlphaVal; // Override background alpha
|
||||||
ImVec2 MenuBarOffsetMinVal; // (Always on) This is not exposed publicly, so we don't clear it and it doesn't have a corresponding flag (could we? for consistency?)
|
ImVec2 MenuBarOffsetMinVal; // (Always on) This is not exposed publicly, so we don't clear it and it doesn't have a corresponding flag (could we? for consistency?)
|
||||||
ImGuiWindowRefreshFlags RefreshFlagsVal;
|
|
||||||
|
|
||||||
ImGuiNextWindowData() { memset(this, 0, sizeof(*this)); }
|
ImGuiNextWindowData() { memset(this, 0, sizeof(*this)); }
|
||||||
inline void ClearFlags() { Flags = ImGuiNextWindowDataFlags_None; }
|
inline void ClearFlags() { Flags = ImGuiNextWindowDataFlags_None; }
|
||||||
@ -1176,7 +1197,6 @@ enum ImGuiNextItemDataFlags_
|
|||||||
ImGuiNextItemDataFlags_None = 0,
|
ImGuiNextItemDataFlags_None = 0,
|
||||||
ImGuiNextItemDataFlags_HasWidth = 1 << 0,
|
ImGuiNextItemDataFlags_HasWidth = 1 << 0,
|
||||||
ImGuiNextItemDataFlags_HasOpen = 1 << 1,
|
ImGuiNextItemDataFlags_HasOpen = 1 << 1,
|
||||||
ImGuiNextItemDataFlags_HasShortcut = 1 << 2,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ImGuiNextItemData
|
struct ImGuiNextItemData
|
||||||
@ -1184,12 +1204,10 @@ struct ImGuiNextItemData
|
|||||||
ImGuiNextItemDataFlags Flags;
|
ImGuiNextItemDataFlags Flags;
|
||||||
ImGuiItemFlags ItemFlags; // Currently only tested/used for ImGuiItemFlags_AllowOverlap.
|
ImGuiItemFlags ItemFlags; // Currently only tested/used for ImGuiItemFlags_AllowOverlap.
|
||||||
// Non-flags members are NOT cleared by ItemAdd() meaning they are still valid during NavProcessItem()
|
// Non-flags members are NOT cleared by ItemAdd() meaning they are still valid during NavProcessItem()
|
||||||
ImGuiSelectionUserData SelectionUserData; // Set by SetNextItemSelectionUserData() (note that NULL/0 is a valid value, we use -1 == ImGuiSelectionUserData_Invalid to mark invalid values)
|
|
||||||
float Width; // Set by SetNextItemWidth()
|
float Width; // Set by SetNextItemWidth()
|
||||||
ImGuiKeyChord Shortcut; // Set by SetNextItemShortcut()
|
ImGuiSelectionUserData SelectionUserData; // Set by SetNextItemSelectionUserData() (note that NULL/0 is a valid value, we use -1 == ImGuiSelectionUserData_Invalid to mark invalid values)
|
||||||
ImGuiInputFlags ShortcutFlags; // Set by SetNextItemShortcut()
|
ImGuiCond OpenCond;
|
||||||
bool OpenVal; // Set by SetNextItemOpen()
|
bool OpenVal; // Set by SetNextItemOpen()
|
||||||
ImGuiCond OpenCond : 8;
|
|
||||||
|
|
||||||
ImGuiNextItemData() { memset(this, 0, sizeof(*this)); SelectionUserData = -1; }
|
ImGuiNextItemData() { memset(this, 0, sizeof(*this)); SelectionUserData = -1; }
|
||||||
inline void ClearFlags() { Flags = ImGuiNextItemDataFlags_None; ItemFlags = ImGuiItemFlags_None; } // Also cleared manually by ItemAdd()!
|
inline void ClearFlags() { Flags = ImGuiNextItemDataFlags_None; ItemFlags = ImGuiItemFlags_None; } // Also cleared manually by ItemAdd()!
|
||||||
@ -1203,10 +1221,9 @@ struct ImGuiLastItemData
|
|||||||
ImGuiItemStatusFlags StatusFlags; // See ImGuiItemStatusFlags_
|
ImGuiItemStatusFlags StatusFlags; // See ImGuiItemStatusFlags_
|
||||||
ImRect Rect; // Full rectangle
|
ImRect Rect; // Full rectangle
|
||||||
ImRect NavRect; // Navigation scoring rectangle (not displayed)
|
ImRect NavRect; // Navigation scoring rectangle (not displayed)
|
||||||
// Rarely used fields are not explicitly cleared, only valid when the corresponding ImGuiItemStatusFlags ar set.
|
// Rarely used fields are not explicitly cleared, only valid when the corresponding ImGuiItemStatusFlags is set.
|
||||||
ImRect DisplayRect; // Display rectangle. ONLY VALID IF (StatusFlags & ImGuiItemStatusFlags_HasDisplayRect) is set.
|
ImRect DisplayRect; // Display rectangle (ONLY VALID IF ImGuiItemStatusFlags_HasDisplayRect is set)
|
||||||
ImRect ClipRect; // Clip rectangle at the time of submitting item. ONLY VALID IF (StatusFlags & ImGuiItemStatusFlags_HasClipRect) is set..
|
ImRect ClipRect; // Clip rectangle at the time of submitting item (ONLY VALID IF ImGuiItemStatusFlags_HasClipRect is set)
|
||||||
ImGuiKeyChord Shortcut; // Shortcut at the time of submitting item. ONLY VALID IF (StatusFlags & ImGuiItemStatusFlags_HasShortcut) is set..
|
|
||||||
|
|
||||||
ImGuiLastItemData() { memset(this, 0, sizeof(*this)); }
|
ImGuiLastItemData() { memset(this, 0, sizeof(*this)); }
|
||||||
};
|
};
|
||||||
@ -1262,66 +1279,6 @@ struct ImGuiPtrOrIndex
|
|||||||
ImGuiPtrOrIndex(int index) { Ptr = NULL; Index = index; }
|
ImGuiPtrOrIndex(int index) { Ptr = NULL; Index = index; }
|
||||||
};
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// [SECTION] Data types support
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
struct ImGuiDataVarInfo
|
|
||||||
{
|
|
||||||
ImGuiDataType Type;
|
|
||||||
ImU32 Count; // 1+
|
|
||||||
ImU32 Offset; // Offset in parent structure
|
|
||||||
void* GetVarPtr(void* parent) const { return (void*)((unsigned char*)parent + Offset); }
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ImGuiDataTypeTempStorage
|
|
||||||
{
|
|
||||||
ImU8 Data[8]; // Can fit any data up to ImGuiDataType_COUNT
|
|
||||||
};
|
|
||||||
|
|
||||||
// Type information associated to one ImGuiDataType. Retrieve with DataTypeGetInfo().
|
|
||||||
struct ImGuiDataTypeInfo
|
|
||||||
{
|
|
||||||
size_t Size; // Size in bytes
|
|
||||||
const char* Name; // Short descriptive name for the type, for debugging
|
|
||||||
const char* PrintFmt; // Default printf format for the type
|
|
||||||
const char* ScanFmt; // Default scanf format for the type
|
|
||||||
};
|
|
||||||
|
|
||||||
// Extend ImGuiDataType_
|
|
||||||
enum ImGuiDataTypePrivate_
|
|
||||||
{
|
|
||||||
ImGuiDataType_String = ImGuiDataType_COUNT + 1,
|
|
||||||
ImGuiDataType_Pointer,
|
|
||||||
ImGuiDataType_ID,
|
|
||||||
};
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// [SECTION] Popup support
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
enum ImGuiPopupPositionPolicy
|
|
||||||
{
|
|
||||||
ImGuiPopupPositionPolicy_Default,
|
|
||||||
ImGuiPopupPositionPolicy_ComboBox,
|
|
||||||
ImGuiPopupPositionPolicy_Tooltip,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Storage for popup stacks (g.OpenPopupStack and g.BeginPopupStack)
|
|
||||||
struct ImGuiPopupData
|
|
||||||
{
|
|
||||||
ImGuiID PopupId; // Set on OpenPopup()
|
|
||||||
ImGuiWindow* Window; // Resolved on BeginPopup() - may stay unresolved if user never calls OpenPopup()
|
|
||||||
ImGuiWindow* RestoreNavWindow;// Set on OpenPopup(), a NavWindow that will be restored on popup close
|
|
||||||
int ParentNavLayer; // Resolved on BeginPopup(). Actually a ImGuiNavLayer type (declared down below), initialized to -1 which is not part of an enum, but serves well-enough as "not any of layers" value
|
|
||||||
int OpenFrameCount; // Set on OpenPopup()
|
|
||||||
ImGuiID OpenParentId; // Set on OpenPopup(), we need this to differentiate multiple menu sets from each others (e.g. inside menu bar vs loose menu items)
|
|
||||||
ImVec2 OpenPopupPos; // Set on OpenPopup(), preferred popup position (typically == OpenMousePos when using mouse)
|
|
||||||
ImVec2 OpenMousePos; // Set on OpenPopup(), copy of mouse position at the time of opening popup
|
|
||||||
|
|
||||||
ImGuiPopupData() { memset(this, 0, sizeof(*this)); ParentNavLayer = OpenFrameCount = -1; }
|
|
||||||
};
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Inputs support
|
// [SECTION] Inputs support
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -1369,6 +1326,7 @@ enum ImGuiInputSource
|
|||||||
ImGuiInputSource_Mouse, // Note: may be Mouse or TouchScreen or Pen. See io.MouseSource to distinguish them.
|
ImGuiInputSource_Mouse, // Note: may be Mouse or TouchScreen or Pen. See io.MouseSource to distinguish them.
|
||||||
ImGuiInputSource_Keyboard,
|
ImGuiInputSource_Keyboard,
|
||||||
ImGuiInputSource_Gamepad,
|
ImGuiInputSource_Gamepad,
|
||||||
|
ImGuiInputSource_Clipboard, // Currently only used by InputText()
|
||||||
ImGuiInputSource_COUNT
|
ImGuiInputSource_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1402,8 +1360,7 @@ struct ImGuiInputEvent
|
|||||||
|
|
||||||
// Input function taking an 'ImGuiID owner_id' argument defaults to (ImGuiKeyOwner_Any == 0) aka don't test ownership, which matches legacy behavior.
|
// Input function taking an 'ImGuiID owner_id' argument defaults to (ImGuiKeyOwner_Any == 0) aka don't test ownership, which matches legacy behavior.
|
||||||
#define ImGuiKeyOwner_Any ((ImGuiID)0) // Accept key that have an owner, UNLESS a call to SetKeyOwner() explicitly used ImGuiInputFlags_LockThisFrame or ImGuiInputFlags_LockUntilRelease.
|
#define ImGuiKeyOwner_Any ((ImGuiID)0) // Accept key that have an owner, UNLESS a call to SetKeyOwner() explicitly used ImGuiInputFlags_LockThisFrame or ImGuiInputFlags_LockUntilRelease.
|
||||||
#define ImGuiKeyOwner_NoOwner ((ImGuiID)-1) // Require key to have no owner.
|
#define ImGuiKeyOwner_None ((ImGuiID)-1) // Require key to have no owner.
|
||||||
//#define ImGuiKeyOwner_None ImGuiKeyOwner_NoOwner // We previously called this 'ImGuiKeyOwner_None' but it was inconsistent with our pattern that _None values == 0 and quite dangerous. Also using _NoOwner makes the IsKeyPressed() calls more explicit.
|
|
||||||
|
|
||||||
typedef ImS16 ImGuiKeyRoutingIndex;
|
typedef ImS16 ImGuiKeyRoutingIndex;
|
||||||
|
|
||||||
@ -1411,13 +1368,12 @@ typedef ImS16 ImGuiKeyRoutingIndex;
|
|||||||
struct ImGuiKeyRoutingData
|
struct ImGuiKeyRoutingData
|
||||||
{
|
{
|
||||||
ImGuiKeyRoutingIndex NextEntryIndex;
|
ImGuiKeyRoutingIndex NextEntryIndex;
|
||||||
ImU16 Mods; // Technically we'd only need 4-bits but for simplify we store ImGuiMod_ values which need 16-bits.
|
ImU16 Mods; // Technically we'd only need 4-bits but for simplify we store ImGuiMod_ values which need 16-bits. ImGuiMod_Shortcut is already translated to Ctrl/Super.
|
||||||
ImU8 RoutingCurrScore; // [DEBUG] For debug display
|
|
||||||
ImU8 RoutingNextScore; // Lower is better (0: perfect score)
|
ImU8 RoutingNextScore; // Lower is better (0: perfect score)
|
||||||
ImGuiID RoutingCurr;
|
ImGuiID RoutingCurr;
|
||||||
ImGuiID RoutingNext;
|
ImGuiID RoutingNext;
|
||||||
|
|
||||||
ImGuiKeyRoutingData() { NextEntryIndex = -1; Mods = 0; RoutingCurrScore = RoutingNextScore = 255; RoutingCurr = RoutingNext = ImGuiKeyOwner_NoOwner; }
|
ImGuiKeyRoutingData() { NextEntryIndex = -1; Mods = 0; RoutingNextScore = 255; RoutingCurr = RoutingNext = ImGuiKeyOwner_None; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Routing table: maintain a desired owner for each possible key-chord (key + mods), and setup owner in NewFrame() when mods are matching.
|
// Routing table: maintain a desired owner for each possible key-chord (key + mods), and setup owner in NewFrame() when mods are matching.
|
||||||
@ -1441,47 +1397,63 @@ struct ImGuiKeyOwnerData
|
|||||||
bool LockThisFrame; // Reading this key requires explicit owner id (until end of frame). Set by ImGuiInputFlags_LockThisFrame.
|
bool LockThisFrame; // Reading this key requires explicit owner id (until end of frame). Set by ImGuiInputFlags_LockThisFrame.
|
||||||
bool LockUntilRelease; // Reading this key requires explicit owner id (until key is released). Set by ImGuiInputFlags_LockUntilRelease. When this is true LockThisFrame is always true as well.
|
bool LockUntilRelease; // Reading this key requires explicit owner id (until key is released). Set by ImGuiInputFlags_LockUntilRelease. When this is true LockThisFrame is always true as well.
|
||||||
|
|
||||||
ImGuiKeyOwnerData() { OwnerCurr = OwnerNext = ImGuiKeyOwner_NoOwner; LockThisFrame = LockUntilRelease = false; }
|
ImGuiKeyOwnerData() { OwnerCurr = OwnerNext = ImGuiKeyOwner_None; LockThisFrame = LockUntilRelease = false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Extend ImGuiInputFlags_
|
|
||||||
// Flags for extended versions of IsKeyPressed(), IsMouseClicked(), Shortcut(), SetKeyOwner(), SetItemKeyOwner()
|
// Flags for extended versions of IsKeyPressed(), IsMouseClicked(), Shortcut(), SetKeyOwner(), SetItemKeyOwner()
|
||||||
// Don't mistake with ImGuiInputTextFlags! (which is for ImGui::InputText() function)
|
// Don't mistake with ImGuiInputTextFlags! (for ImGui::InputText() function)
|
||||||
enum ImGuiInputFlagsPrivate_
|
enum ImGuiInputFlags_
|
||||||
{
|
{
|
||||||
// Flags for IsKeyPressed(), IsKeyChordPressed(), IsMouseClicked(), Shortcut()
|
// Flags for IsKeyPressed(), IsKeyChordPressed(), IsMouseClicked(), Shortcut()
|
||||||
// - Repeat mode: Repeat rate selection
|
ImGuiInputFlags_None = 0,
|
||||||
|
ImGuiInputFlags_Repeat = 1 << 0, // Return true on successive repeats. Default for legacy IsKeyPressed(). NOT Default for legacy IsMouseClicked(). MUST BE == 1.
|
||||||
ImGuiInputFlags_RepeatRateDefault = 1 << 1, // Repeat rate: Regular (default)
|
ImGuiInputFlags_RepeatRateDefault = 1 << 1, // Repeat rate: Regular (default)
|
||||||
ImGuiInputFlags_RepeatRateNavMove = 1 << 2, // Repeat rate: Fast
|
ImGuiInputFlags_RepeatRateNavMove = 1 << 2, // Repeat rate: Fast
|
||||||
ImGuiInputFlags_RepeatRateNavTweak = 1 << 3, // Repeat rate: Faster
|
ImGuiInputFlags_RepeatRateNavTweak = 1 << 3, // Repeat rate: Faster
|
||||||
// - Repeat mode: Specify when repeating key pressed can be interrupted.
|
|
||||||
// - In theory ImGuiInputFlags_RepeatUntilOtherKeyPress may be a desirable default, but it would break too many behavior so everything is opt-in.
|
// Specify when repeating key pressed can be interrupted.
|
||||||
|
// In theory ImGuiInputFlags_RepeatUntilOtherKeyPress may be a desirable default, but it would break too many behavior so everything is opt-in.
|
||||||
ImGuiInputFlags_RepeatUntilRelease = 1 << 4, // Stop repeating when released (default for all functions except Shortcut). This only exists to allow overriding Shortcut() default behavior.
|
ImGuiInputFlags_RepeatUntilRelease = 1 << 4, // Stop repeating when released (default for all functions except Shortcut). This only exists to allow overriding Shortcut() default behavior.
|
||||||
ImGuiInputFlags_RepeatUntilKeyModsChange = 1 << 5, // Stop repeating when released OR if keyboard mods are changed (default for Shortcut)
|
ImGuiInputFlags_RepeatUntilKeyModsChange = 1 << 5, // Stop repeating when released OR if keyboard mods are changed (default for Shortcut)
|
||||||
ImGuiInputFlags_RepeatUntilKeyModsChangeFromNone = 1 << 6, // Stop repeating when released OR if keyboard mods are leaving the None state. Allows going from Mod+Key to Key by releasing Mod.
|
ImGuiInputFlags_RepeatUntilKeyModsChangeFromNone = 1 << 6, // Stop repeating when released OR if keyboard mods are leaving the None state. Allows going from Mod+Key to Key by releasing Mod.
|
||||||
ImGuiInputFlags_RepeatUntilOtherKeyPress = 1 << 7, // Stop repeating when released OR if any other keyboard key is pressed during the repeat
|
ImGuiInputFlags_RepeatUntilOtherKeyPress = 1 << 7, // Stop repeating when released OR if any other keyboard key is pressed during the repeat
|
||||||
|
|
||||||
// Flags for SetKeyOwner(), SetItemKeyOwner()
|
// Flags for SetItemKeyOwner()
|
||||||
// - Locking key away from non-input aware code. Locking is useful to make input-owner-aware code steal keys from non-input-owner-aware code. If all code is input-owner-aware locking would never be necessary.
|
ImGuiInputFlags_CondHovered = 1 << 8, // Only set if item is hovered (default to both)
|
||||||
ImGuiInputFlags_LockThisFrame = 1 << 20, // Further accesses to key data will require EXPLICIT owner ID (ImGuiKeyOwner_Any/0 will NOT accepted for polling). Cleared at end of frame.
|
ImGuiInputFlags_CondActive = 1 << 9, // Only set if item is active (default to both)
|
||||||
ImGuiInputFlags_LockUntilRelease = 1 << 21, // Further accesses to key data will require EXPLICIT owner ID (ImGuiKeyOwner_Any/0 will NOT accepted for polling). Cleared when the key is released or at end of each frame if key is released.
|
|
||||||
|
|
||||||
// - Condition for SetItemKeyOwner()
|
|
||||||
ImGuiInputFlags_CondHovered = 1 << 22, // Only set if item is hovered (default to both)
|
|
||||||
ImGuiInputFlags_CondActive = 1 << 23, // Only set if item is active (default to both)
|
|
||||||
ImGuiInputFlags_CondDefault_ = ImGuiInputFlags_CondHovered | ImGuiInputFlags_CondActive,
|
ImGuiInputFlags_CondDefault_ = ImGuiInputFlags_CondHovered | ImGuiInputFlags_CondActive,
|
||||||
|
ImGuiInputFlags_CondMask_ = ImGuiInputFlags_CondHovered | ImGuiInputFlags_CondActive,
|
||||||
|
|
||||||
|
// Flags for SetKeyOwner(), SetItemKeyOwner()
|
||||||
|
ImGuiInputFlags_LockThisFrame = 1 << 10, // Access to key data will require EXPLICIT owner ID (ImGuiKeyOwner_Any/0 will NOT accepted for polling). Cleared at end of frame. This is useful to make input-owner-aware code steal keys from non-input-owner-aware code.
|
||||||
|
ImGuiInputFlags_LockUntilRelease = 1 << 11, // Access to key data will require EXPLICIT owner ID (ImGuiKeyOwner_Any/0 will NOT accepted for polling). Cleared when the key is released or at end of each frame if key is released. This is useful to make input-owner-aware code steal keys from non-input-owner-aware code.
|
||||||
|
|
||||||
|
// Routing policies for Shortcut() + low-level SetShortcutRouting()
|
||||||
|
// - The general idea is that several callers register interest in a shortcut, and only one owner gets it.
|
||||||
|
// - When a policy (other than _RouteAlways) is set, Shortcut() will register itself with SetShortcutRouting(),
|
||||||
|
// allowing the system to decide where to route the input among other route-aware calls.
|
||||||
|
// - Shortcut() uses ImGuiInputFlags_RouteFocused by default: meaning that a simple Shortcut() poll
|
||||||
|
// will register a route and only succeed when parent window is in the focus stack and if no-one
|
||||||
|
// with a higher priority is claiming the shortcut.
|
||||||
|
// - Using ImGuiInputFlags_RouteAlways is roughly equivalent to doing e.g. IsKeyPressed(key) + testing mods.
|
||||||
|
// - Priorities: GlobalHigh > Focused (when owner is active item) > Global > Focused (when focused window) > GlobalLow.
|
||||||
|
// - Can select only 1 policy among all available.
|
||||||
|
ImGuiInputFlags_RouteFocused = 1 << 12, // (Default) Register focused route: Accept inputs if window is in focus stack. Deep-most focused window takes inputs. ActiveId takes inputs over deep-most focused window.
|
||||||
|
ImGuiInputFlags_RouteGlobalLow = 1 << 13, // Register route globally (lowest priority: unless a focused window or active item registered the route) -> recommended Global priority.
|
||||||
|
ImGuiInputFlags_RouteGlobal = 1 << 14, // Register route globally (medium priority: unless an active item registered the route, e.g. CTRL+A registered by InputText).
|
||||||
|
ImGuiInputFlags_RouteGlobalHigh = 1 << 15, // Register route globally (highest priority: unlikely you need to use that: will interfere with every active items)
|
||||||
|
ImGuiInputFlags_RouteMask_ = ImGuiInputFlags_RouteFocused | ImGuiInputFlags_RouteGlobal | ImGuiInputFlags_RouteGlobalLow | ImGuiInputFlags_RouteGlobalHigh, // _Always not part of this!
|
||||||
|
ImGuiInputFlags_RouteAlways = 1 << 16, // Do not register route, poll keys directly.
|
||||||
|
ImGuiInputFlags_RouteUnlessBgFocused= 1 << 17, // Global routes will not be applied if underlying background/void is focused (== no Dear ImGui windows are focused). Useful for overlay applications.
|
||||||
|
ImGuiInputFlags_RouteExtraMask_ = ImGuiInputFlags_RouteAlways | ImGuiInputFlags_RouteUnlessBgFocused,
|
||||||
|
|
||||||
// [Internal] Mask of which function support which flags
|
// [Internal] Mask of which function support which flags
|
||||||
ImGuiInputFlags_RepeatRateMask_ = ImGuiInputFlags_RepeatRateDefault | ImGuiInputFlags_RepeatRateNavMove | ImGuiInputFlags_RepeatRateNavTweak,
|
ImGuiInputFlags_RepeatRateMask_ = ImGuiInputFlags_RepeatRateDefault | ImGuiInputFlags_RepeatRateNavMove | ImGuiInputFlags_RepeatRateNavTweak,
|
||||||
ImGuiInputFlags_RepeatUntilMask_ = ImGuiInputFlags_RepeatUntilRelease | ImGuiInputFlags_RepeatUntilKeyModsChange | ImGuiInputFlags_RepeatUntilKeyModsChangeFromNone | ImGuiInputFlags_RepeatUntilOtherKeyPress,
|
ImGuiInputFlags_RepeatUntilMask_ = ImGuiInputFlags_RepeatUntilRelease | ImGuiInputFlags_RepeatUntilKeyModsChange | ImGuiInputFlags_RepeatUntilKeyModsChangeFromNone | ImGuiInputFlags_RepeatUntilOtherKeyPress,
|
||||||
ImGuiInputFlags_RepeatMask_ = ImGuiInputFlags_Repeat | ImGuiInputFlags_RepeatRateMask_ | ImGuiInputFlags_RepeatUntilMask_,
|
ImGuiInputFlags_RepeatMask_ = ImGuiInputFlags_Repeat | ImGuiInputFlags_RepeatRateMask_ | ImGuiInputFlags_RepeatUntilMask_,
|
||||||
ImGuiInputFlags_CondMask_ = ImGuiInputFlags_CondHovered | ImGuiInputFlags_CondActive,
|
|
||||||
ImGuiInputFlags_RouteTypeMask_ = ImGuiInputFlags_RouteActive | ImGuiInputFlags_RouteFocused | ImGuiInputFlags_RouteGlobal | ImGuiInputFlags_RouteAlways,
|
|
||||||
ImGuiInputFlags_RouteOptionsMask_ = ImGuiInputFlags_RouteOverFocused | ImGuiInputFlags_RouteOverActive | ImGuiInputFlags_RouteUnlessBgFocused | ImGuiInputFlags_RouteFromRootWindow,
|
|
||||||
ImGuiInputFlags_SupportedByIsKeyPressed = ImGuiInputFlags_RepeatMask_,
|
ImGuiInputFlags_SupportedByIsKeyPressed = ImGuiInputFlags_RepeatMask_,
|
||||||
ImGuiInputFlags_SupportedByIsMouseClicked = ImGuiInputFlags_Repeat,
|
ImGuiInputFlags_SupportedByIsMouseClicked = ImGuiInputFlags_Repeat,
|
||||||
ImGuiInputFlags_SupportedByShortcut = ImGuiInputFlags_RepeatMask_ | ImGuiInputFlags_RouteTypeMask_ | ImGuiInputFlags_RouteOptionsMask_,
|
ImGuiInputFlags_SupportedByShortcut = ImGuiInputFlags_RepeatMask_ | ImGuiInputFlags_RouteMask_ | ImGuiInputFlags_RouteExtraMask_,
|
||||||
ImGuiInputFlags_SupportedBySetNextItemShortcut = ImGuiInputFlags_RepeatMask_ | ImGuiInputFlags_RouteTypeMask_ | ImGuiInputFlags_RouteOptionsMask_ | ImGuiInputFlags_Tooltip,
|
|
||||||
ImGuiInputFlags_SupportedBySetKeyOwner = ImGuiInputFlags_LockThisFrame | ImGuiInputFlags_LockUntilRelease,
|
ImGuiInputFlags_SupportedBySetKeyOwner = ImGuiInputFlags_LockThisFrame | ImGuiInputFlags_LockUntilRelease,
|
||||||
ImGuiInputFlags_SupportedBySetItemKeyOwner = ImGuiInputFlags_SupportedBySetKeyOwner | ImGuiInputFlags_CondMask_,
|
ImGuiInputFlags_SupportedBySetItemKeyOwner = ImGuiInputFlags_SupportedBySetKeyOwner | ImGuiInputFlags_CondMask_,
|
||||||
};
|
};
|
||||||
@ -1527,7 +1499,6 @@ enum ImGuiActivateFlags_
|
|||||||
ImGuiActivateFlags_PreferTweak = 1 << 1, // Favor activation for tweaking with arrows or gamepad (e.g. for Slider/Drag). Default for Space key and if keyboard is not used.
|
ImGuiActivateFlags_PreferTweak = 1 << 1, // Favor activation for tweaking with arrows or gamepad (e.g. for Slider/Drag). Default for Space key and if keyboard is not used.
|
||||||
ImGuiActivateFlags_TryToPreserveState = 1 << 2, // Request widget to preserve state if it can (e.g. InputText will try to preserve cursor/selection)
|
ImGuiActivateFlags_TryToPreserveState = 1 << 2, // Request widget to preserve state if it can (e.g. InputText will try to preserve cursor/selection)
|
||||||
ImGuiActivateFlags_FromTabbing = 1 << 3, // Activation requested by a tabbing request
|
ImGuiActivateFlags_FromTabbing = 1 << 3, // Activation requested by a tabbing request
|
||||||
ImGuiActivateFlags_FromShortcut = 1 << 4, // Activation requested by an item shortcut via SetNextItemShortcut() function.
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Early work-in-progress API for ScrollToItem()
|
// Early work-in-progress API for ScrollToItem()
|
||||||
@ -1548,7 +1519,8 @@ enum ImGuiScrollFlags_
|
|||||||
enum ImGuiNavHighlightFlags_
|
enum ImGuiNavHighlightFlags_
|
||||||
{
|
{
|
||||||
ImGuiNavHighlightFlags_None = 0,
|
ImGuiNavHighlightFlags_None = 0,
|
||||||
ImGuiNavHighlightFlags_Compact = 1 << 1, // Compact highlight, no padding
|
ImGuiNavHighlightFlags_TypeDefault = 1 << 0,
|
||||||
|
ImGuiNavHighlightFlags_TypeThin = 1 << 1,
|
||||||
ImGuiNavHighlightFlags_AlwaysDraw = 1 << 2, // Draw rectangular highlight if (g.NavId == id) _even_ when using the mouse.
|
ImGuiNavHighlightFlags_AlwaysDraw = 1 << 2, // Draw rectangular highlight if (g.NavId == id) _even_ when using the mouse.
|
||||||
ImGuiNavHighlightFlags_NoRounding = 1 << 3,
|
ImGuiNavHighlightFlags_NoRounding = 1 << 3,
|
||||||
};
|
};
|
||||||
@ -1572,7 +1544,6 @@ enum ImGuiNavMoveFlags_
|
|||||||
ImGuiNavMoveFlags_Activate = 1 << 12, // Activate/select target item.
|
ImGuiNavMoveFlags_Activate = 1 << 12, // Activate/select target item.
|
||||||
ImGuiNavMoveFlags_NoSelect = 1 << 13, // Don't trigger selection by not setting g.NavJustMovedTo
|
ImGuiNavMoveFlags_NoSelect = 1 << 13, // Don't trigger selection by not setting g.NavJustMovedTo
|
||||||
ImGuiNavMoveFlags_NoSetNavHighlight = 1 << 14, // Do not alter the visible state of keyboard vs mouse nav highlight
|
ImGuiNavMoveFlags_NoSetNavHighlight = 1 << 14, // Do not alter the visible state of keyboard vs mouse nav highlight
|
||||||
ImGuiNavMoveFlags_NoClearActiveId = 1 << 15, // (Experimental) Do not clear active id when applying move result
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ImGuiNavLayer
|
enum ImGuiNavLayer
|
||||||
@ -1589,21 +1560,15 @@ struct ImGuiNavItemData
|
|||||||
ImGuiID FocusScopeId; // Init,Move // Best candidate focus scope ID
|
ImGuiID FocusScopeId; // Init,Move // Best candidate focus scope ID
|
||||||
ImRect RectRel; // Init,Move // Best candidate bounding box in window relative space
|
ImRect RectRel; // Init,Move // Best candidate bounding box in window relative space
|
||||||
ImGuiItemFlags InFlags; // ????,Move // Best candidate item flags
|
ImGuiItemFlags InFlags; // ????,Move // Best candidate item flags
|
||||||
|
ImGuiSelectionUserData SelectionUserData;//I+Mov // Best candidate SetNextItemSelectionData() value.
|
||||||
float DistBox; // Move // Best candidate box distance to current NavId
|
float DistBox; // Move // Best candidate box distance to current NavId
|
||||||
float DistCenter; // Move // Best candidate center distance to current NavId
|
float DistCenter; // Move // Best candidate center distance to current NavId
|
||||||
float DistAxial; // Move // Best candidate axial distance to current NavId
|
float DistAxial; // Move // Best candidate axial distance to current NavId
|
||||||
ImGuiSelectionUserData SelectionUserData;//I+Mov // Best candidate SetNextItemSelectionData() value.
|
|
||||||
|
|
||||||
ImGuiNavItemData() { Clear(); }
|
ImGuiNavItemData() { Clear(); }
|
||||||
void Clear() { Window = NULL; ID = FocusScopeId = 0; InFlags = 0; SelectionUserData = -1; DistBox = DistCenter = DistAxial = FLT_MAX; }
|
void Clear() { Window = NULL; ID = FocusScopeId = 0; InFlags = 0; SelectionUserData = -1; DistBox = DistCenter = DistAxial = FLT_MAX; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ImGuiFocusScopeData
|
|
||||||
{
|
|
||||||
ImGuiID ID;
|
|
||||||
ImGuiID WindowID;
|
|
||||||
};
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Typing-select support
|
// [SECTION] Typing-select support
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -1823,9 +1788,8 @@ enum ImGuiDebugLogFlags_
|
|||||||
ImGuiDebugLogFlags_EventClipper = 1 << 4,
|
ImGuiDebugLogFlags_EventClipper = 1 << 4,
|
||||||
ImGuiDebugLogFlags_EventSelection = 1 << 5,
|
ImGuiDebugLogFlags_EventSelection = 1 << 5,
|
||||||
ImGuiDebugLogFlags_EventIO = 1 << 6,
|
ImGuiDebugLogFlags_EventIO = 1 << 6,
|
||||||
ImGuiDebugLogFlags_EventInputRouting = 1 << 7,
|
|
||||||
|
|
||||||
ImGuiDebugLogFlags_EventMask_ = ImGuiDebugLogFlags_EventActiveId | ImGuiDebugLogFlags_EventFocus | ImGuiDebugLogFlags_EventPopup | ImGuiDebugLogFlags_EventNav | ImGuiDebugLogFlags_EventClipper | ImGuiDebugLogFlags_EventSelection | ImGuiDebugLogFlags_EventIO | ImGuiDebugLogFlags_EventInputRouting,
|
ImGuiDebugLogFlags_EventMask_ = ImGuiDebugLogFlags_EventActiveId | ImGuiDebugLogFlags_EventFocus | ImGuiDebugLogFlags_EventPopup | ImGuiDebugLogFlags_EventNav | ImGuiDebugLogFlags_EventClipper | ImGuiDebugLogFlags_EventSelection | ImGuiDebugLogFlags_EventIO,
|
||||||
ImGuiDebugLogFlags_OutputToTTY = 1 << 20, // Also send output to TTY
|
ImGuiDebugLogFlags_OutputToTTY = 1 << 20, // Also send output to TTY
|
||||||
ImGuiDebugLogFlags_OutputToTestEngine = 1 << 21, // Also send output to Test Engine
|
ImGuiDebugLogFlags_OutputToTestEngine = 1 << 21, // Also send output to Test Engine
|
||||||
};
|
};
|
||||||
@ -1860,8 +1824,6 @@ struct ImGuiMetricsConfig
|
|||||||
bool ShowAtlasTintedWithTextColor = false;
|
bool ShowAtlasTintedWithTextColor = false;
|
||||||
int ShowWindowsRectsType = -1;
|
int ShowWindowsRectsType = -1;
|
||||||
int ShowTablesRectsType = -1;
|
int ShowTablesRectsType = -1;
|
||||||
int HighlightMonitorIdx = -1;
|
|
||||||
ImGuiID HighlightViewportID = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ImGuiStackLevelInfo
|
struct ImGuiStackLevelInfo
|
||||||
@ -1919,7 +1881,6 @@ struct ImGuiContext
|
|||||||
ImFont* Font; // (Shortcut) == FontStack.empty() ? IO.Font : FontStack.back()
|
ImFont* Font; // (Shortcut) == FontStack.empty() ? IO.Font : FontStack.back()
|
||||||
float FontSize; // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize(). Text height for current window.
|
float FontSize; // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize(). Text height for current window.
|
||||||
float FontBaseSize; // (Shortcut) == IO.FontGlobalScale * Font->Scale * Font->FontSize. Base text height.
|
float FontBaseSize; // (Shortcut) == IO.FontGlobalScale * Font->Scale * Font->FontSize. Base text height.
|
||||||
float CurrentDpiScale; // Current window/viewport DpiScale
|
|
||||||
ImDrawListSharedData DrawListSharedData;
|
ImDrawListSharedData DrawListSharedData;
|
||||||
double Time;
|
double Time;
|
||||||
int FrameCount;
|
int FrameCount;
|
||||||
@ -1945,7 +1906,7 @@ struct ImGuiContext
|
|||||||
ImVector<ImGuiWindowStackData> CurrentWindowStack;
|
ImVector<ImGuiWindowStackData> CurrentWindowStack;
|
||||||
ImGuiStorage WindowsById; // Map window's ImGuiID to ImGuiWindow*
|
ImGuiStorage WindowsById; // Map window's ImGuiID to ImGuiWindow*
|
||||||
int WindowsActiveCount; // Number of unique windows submitted by frame
|
int WindowsActiveCount; // Number of unique windows submitted by frame
|
||||||
ImVec2 WindowsHoverPadding; // Padding around resizable windows for which hovering on counts as hovering the window == ImMax(style.TouchExtraPadding, WINDOWS_HOVER_PADDING).
|
ImVec2 WindowsHoverPadding; // Padding around resizable windows for which hovering on counts as hovering the window == ImMax(style.TouchExtraPadding, WINDOWS_HOVER_PADDING)
|
||||||
ImGuiID DebugBreakInWindow; // Set to break in Begin() call.
|
ImGuiID DebugBreakInWindow; // Set to break in Begin() call.
|
||||||
ImGuiWindow* CurrentWindow; // Window being drawn into
|
ImGuiWindow* CurrentWindow; // Window being drawn into
|
||||||
ImGuiWindow* HoveredWindow; // Window the mouse is hovering. Will typically catch mouse inputs.
|
ImGuiWindow* HoveredWindow; // Window the mouse is hovering. Will typically catch mouse inputs.
|
||||||
@ -1976,11 +1937,10 @@ struct ImGuiContext
|
|||||||
bool ActiveIdHasBeenPressedBefore; // Track whether the active id led to a press (this is to allow changing between PressOnClick and PressOnRelease without pressing twice). Used by range_select branch.
|
bool ActiveIdHasBeenPressedBefore; // Track whether the active id led to a press (this is to allow changing between PressOnClick and PressOnRelease without pressing twice). Used by range_select branch.
|
||||||
bool ActiveIdHasBeenEditedBefore; // Was the value associated to the widget Edited over the course of the Active state.
|
bool ActiveIdHasBeenEditedBefore; // Was the value associated to the widget Edited over the course of the Active state.
|
||||||
bool ActiveIdHasBeenEditedThisFrame;
|
bool ActiveIdHasBeenEditedThisFrame;
|
||||||
bool ActiveIdFromShortcut;
|
|
||||||
int ActiveIdMouseButton : 8;
|
|
||||||
ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
|
ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
|
||||||
ImGuiWindow* ActiveIdWindow;
|
ImGuiWindow* ActiveIdWindow;
|
||||||
ImGuiInputSource ActiveIdSource; // Activating source: ImGuiInputSource_Mouse OR ImGuiInputSource_Keyboard OR ImGuiInputSource_Gamepad
|
ImGuiInputSource ActiveIdSource; // Activating source: ImGuiInputSource_Mouse OR ImGuiInputSource_Keyboard OR ImGuiInputSource_Gamepad
|
||||||
|
int ActiveIdMouseButton;
|
||||||
ImGuiID ActiveIdPreviousFrame;
|
ImGuiID ActiveIdPreviousFrame;
|
||||||
bool ActiveIdPreviousFrameIsAlive;
|
bool ActiveIdPreviousFrameIsAlive;
|
||||||
bool ActiveIdPreviousFrameHasBeenEditedBefore;
|
bool ActiveIdPreviousFrameHasBeenEditedBefore;
|
||||||
@ -1988,14 +1948,13 @@ struct ImGuiContext
|
|||||||
ImGuiID LastActiveId; // Store the last non-zero ActiveId, useful for animation.
|
ImGuiID LastActiveId; // Store the last non-zero ActiveId, useful for animation.
|
||||||
float LastActiveIdTimer; // Store the last non-zero ActiveId timer since the beginning of activation, useful for animation.
|
float LastActiveIdTimer; // Store the last non-zero ActiveId timer since the beginning of activation, useful for animation.
|
||||||
|
|
||||||
// Key/Input Ownership + Shortcut Routing system
|
// [EXPERIMENTAL] Key/Input Ownership + Shortcut Routing system
|
||||||
// - The idea is that instead of "eating" a given key, we can link to an owner.
|
// - The idea is that instead of "eating" a given key, we can link to an owner.
|
||||||
// - Input query can then read input by specifying ImGuiKeyOwner_Any (== 0), ImGuiKeyOwner_NoOwner (== -1) or a custom ID.
|
// - Input query can then read input by specifying ImGuiKeyOwner_Any (== 0), ImGuiKeyOwner_None (== -1) or a custom ID.
|
||||||
// - Routing is requested ahead of time for a given chord (Key + Mods) and granted in NewFrame().
|
// - Routing is requested ahead of time for a given chord (Key + Mods) and granted in NewFrame().
|
||||||
double LastKeyModsChangeTime; // Record the last time key mods changed (affect repeat delay when using shortcut logic)
|
double LastKeyModsChangeTime; // Record the last time key mods changed (affect repeat delay when using shortcut logic)
|
||||||
double LastKeyModsChangeFromNoneTime; // Record the last time key mods changed away from being 0 (affect repeat delay when using shortcut logic)
|
double LastKeyModsChangeFromNoneTime; // Record the last time key mods changed away from being 0 (affect repeat delay when using shortcut logic)
|
||||||
double LastKeyboardKeyPressTime; // Record the last time a keyboard key (ignore mouse/gamepad ones) was pressed.
|
double LastKeyboardKeyPressTime; // Record the last time a keyboard key (ignore mouse/gamepad ones) was pressed.
|
||||||
ImBitArrayForNamedKeys KeysMayBeCharInput; // Lookup to tell if a key can emit char input, see IsKeyChordPotentiallyCharInput(). sizeof() = 20 bytes
|
|
||||||
ImGuiKeyOwnerData KeysOwnerData[ImGuiKey_NamedKey_COUNT];
|
ImGuiKeyOwnerData KeysOwnerData[ImGuiKey_NamedKey_COUNT];
|
||||||
ImGuiKeyRoutingTable KeysRoutingTable;
|
ImGuiKeyRoutingTable KeysRoutingTable;
|
||||||
ImU32 ActiveIdUsingNavDirMask; // Active widget will want to read those nav move requests (e.g. can activate a button and move away from it)
|
ImU32 ActiveIdUsingNavDirMask; // Active widget will want to read those nav move requests (e.g. can activate a button and move away from it)
|
||||||
@ -2006,8 +1965,8 @@ struct ImGuiContext
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Next window/item data
|
// Next window/item data
|
||||||
ImGuiID CurrentFocusScopeId; // Value for currently appending items == g.FocusScopeStack.back(). Not to be mistaken with g.NavFocusScopeId.
|
ImGuiID CurrentFocusScopeId; // == g.FocusScopeStack.back()
|
||||||
ImGuiItemFlags CurrentItemFlags; // Value for currently appending items == g.ItemFlagsStack.back()
|
ImGuiItemFlags CurrentItemFlags; // == g.ItemFlagsStack.back()
|
||||||
ImGuiID DebugLocateId; // Storage for DebugLocateItemOnHover() feature: this is read by ItemAdd() so we keep it in a hot/cached location
|
ImGuiID DebugLocateId; // Storage for DebugLocateItemOnHover() feature: this is read by ItemAdd() so we keep it in a hot/cached location
|
||||||
ImGuiNextItemData NextItemData; // Storage for SetNextItem** functions
|
ImGuiNextItemData NextItemData; // Storage for SetNextItem** functions
|
||||||
ImGuiLastItemData LastItemData; // Storage for last submitted item (setup by ItemAdd)
|
ImGuiLastItemData LastItemData; // Storage for last submitted item (setup by ItemAdd)
|
||||||
@ -2019,27 +1978,26 @@ struct ImGuiContext
|
|||||||
ImVector<ImGuiColorMod> ColorStack; // Stack for PushStyleColor()/PopStyleColor() - inherited by Begin()
|
ImVector<ImGuiColorMod> ColorStack; // Stack for PushStyleColor()/PopStyleColor() - inherited by Begin()
|
||||||
ImVector<ImGuiStyleMod> StyleVarStack; // Stack for PushStyleVar()/PopStyleVar() - inherited by Begin()
|
ImVector<ImGuiStyleMod> StyleVarStack; // Stack for PushStyleVar()/PopStyleVar() - inherited by Begin()
|
||||||
ImVector<ImFont*> FontStack; // Stack for PushFont()/PopFont() - inherited by Begin()
|
ImVector<ImFont*> FontStack; // Stack for PushFont()/PopFont() - inherited by Begin()
|
||||||
ImVector<ImGuiFocusScopeData> FocusScopeStack; // Stack for PushFocusScope()/PopFocusScope() - inherited by BeginChild(), pushed into by Begin()
|
ImVector<ImGuiID> FocusScopeStack; // Stack for PushFocusScope()/PopFocusScope() - inherited by BeginChild(), pushed into by Begin()
|
||||||
ImVector<ImGuiItemFlags> ItemFlagsStack; // Stack for PushItemFlag()/PopItemFlag() - inherited by Begin()
|
ImVector<ImGuiItemFlags> ItemFlagsStack; // Stack for PushItemFlag()/PopItemFlag() - inherited by Begin()
|
||||||
ImVector<ImGuiGroupData> GroupStack; // Stack for BeginGroup()/EndGroup() - not inherited by Begin()
|
ImVector<ImGuiGroupData> GroupStack; // Stack for BeginGroup()/EndGroup() - not inherited by Begin()
|
||||||
ImVector<ImGuiPopupData> OpenPopupStack; // Which popups are open (persistent)
|
ImVector<ImGuiPopupData> OpenPopupStack; // Which popups are open (persistent)
|
||||||
ImVector<ImGuiPopupData> BeginPopupStack; // Which level of BeginPopup() we are in (reset every frame)
|
ImVector<ImGuiPopupData> BeginPopupStack; // Which level of BeginPopup() we are in (reset every frame)
|
||||||
ImVector<ImGuiNavTreeNodeData> NavTreeNodeStack; // Stack for TreeNode() when a NavLeft requested is emitted.
|
ImVector<ImGuiNavTreeNodeData> NavTreeNodeStack; // Stack for TreeNode() when a NavLeft requested is emitted.
|
||||||
|
|
||||||
|
int BeginMenuCount;
|
||||||
|
|
||||||
// Viewports
|
// Viewports
|
||||||
ImVector<ImGuiViewportP*> Viewports; // Active viewports (Size==1 in 'master' branch). Each viewports hold their copy of ImDrawData.
|
ImVector<ImGuiViewportP*> Viewports; // Active viewports (Size==1 in 'master' branch). Each viewports hold their copy of ImDrawData.
|
||||||
|
|
||||||
// Gamepad/keyboard Navigation
|
// Gamepad/keyboard Navigation
|
||||||
ImGuiWindow* NavWindow; // Focused window for navigation. Could be called 'FocusedWindow'
|
ImGuiWindow* NavWindow; // Focused window for navigation. Could be called 'FocusedWindow'
|
||||||
ImGuiID NavId; // Focused item for navigation
|
ImGuiID NavId; // Focused item for navigation
|
||||||
ImGuiID NavFocusScopeId; // Focused focus scope (e.g. selection code often wants to "clear other items" when landing on an item of the same scope)
|
ImGuiID NavFocusScopeId; // Identify a selection scope (selection code often wants to "clear other items" when landing on an item of the selection set)
|
||||||
ImVector<ImGuiFocusScopeData> NavFocusRoute; // Reversed copy focus scope stack for NavId (should contains NavFocusScopeId). This essentially follow the window->ParentWindowForFocusRoute chain.
|
|
||||||
ImGuiID NavActivateId; // ~~ (g.ActiveId == 0) && (IsKeyPressed(ImGuiKey_Space) || IsKeyDown(ImGuiKey_Enter) || IsKeyPressed(ImGuiKey_NavGamepadActivate)) ? NavId : 0, also set when calling ActivateItem()
|
ImGuiID NavActivateId; // ~~ (g.ActiveId == 0) && (IsKeyPressed(ImGuiKey_Space) || IsKeyDown(ImGuiKey_Enter) || IsKeyPressed(ImGuiKey_NavGamepadActivate)) ? NavId : 0, also set when calling ActivateItem()
|
||||||
ImGuiID NavActivateDownId; // ~~ IsKeyDown(ImGuiKey_Space) || IsKeyDown(ImGuiKey_Enter) || IsKeyDown(ImGuiKey_NavGamepadActivate) ? NavId : 0
|
ImGuiID NavActivateDownId; // ~~ IsKeyDown(ImGuiKey_Space) || IsKeyDown(ImGuiKey_Enter) || IsKeyDown(ImGuiKey_NavGamepadActivate) ? NavId : 0
|
||||||
ImGuiID NavActivatePressedId; // ~~ IsKeyPressed(ImGuiKey_Space) || IsKeyPressed(ImGuiKey_Enter) || IsKeyPressed(ImGuiKey_NavGamepadActivate) ? NavId : 0 (no repeat)
|
ImGuiID NavActivatePressedId; // ~~ IsKeyPressed(ImGuiKey_Space) || IsKeyPressed(ImGuiKey_Enter) || IsKeyPressed(ImGuiKey_NavGamepadActivate) ? NavId : 0 (no repeat)
|
||||||
ImGuiActivateFlags NavActivateFlags;
|
ImGuiActivateFlags NavActivateFlags;
|
||||||
ImGuiID NavHighlightActivatedId;
|
|
||||||
float NavHighlightActivatedTimer;
|
|
||||||
ImGuiID NavJustMovedToId; // Just navigated to this id (result of a successfully MoveRequest).
|
ImGuiID NavJustMovedToId; // Just navigated to this id (result of a successfully MoveRequest).
|
||||||
ImGuiID NavJustMovedToFocusScopeId; // Just navigated to this focus scope id (result of a successfully MoveRequest).
|
ImGuiID NavJustMovedToFocusScopeId; // Just navigated to this focus scope id (result of a successfully MoveRequest).
|
||||||
ImGuiKeyChord NavJustMovedToKeyMods;
|
ImGuiKeyChord NavJustMovedToKeyMods;
|
||||||
@ -2078,15 +2036,14 @@ struct ImGuiContext
|
|||||||
ImGuiNavItemData NavTabbingResultFirst; // First tabbing request candidate within NavWindow and flattened hierarchy
|
ImGuiNavItemData NavTabbingResultFirst; // First tabbing request candidate within NavWindow and flattened hierarchy
|
||||||
|
|
||||||
// Navigation: Windowing (CTRL+TAB for list, or Menu button + keys or directional pads to move/resize)
|
// Navigation: Windowing (CTRL+TAB for list, or Menu button + keys or directional pads to move/resize)
|
||||||
ImGuiKeyChord ConfigNavWindowingKeyNext; // = ImGuiMod_Ctrl | ImGuiKey_Tab (or ImGuiMod_Super | ImGuiKey_Tab on OS X). For reconfiguration (see #4828)
|
ImGuiKeyChord ConfigNavWindowingKeyNext; // = ImGuiMod_Ctrl | ImGuiKey_Tab, for reconfiguration (see #4828)
|
||||||
ImGuiKeyChord ConfigNavWindowingKeyPrev; // = ImGuiMod_Ctrl | ImGuiMod_Shift | ImGuiKey_Tab (or ImGuiMod_Super | ImGuiMod_Shift | ImGuiKey_Tab on OS X)
|
ImGuiKeyChord ConfigNavWindowingKeyPrev; // = ImGuiMod_Ctrl | ImGuiMod_Shift | ImGuiKey_Tab
|
||||||
ImGuiWindow* NavWindowingTarget; // Target window when doing CTRL+Tab (or Pad Menu + FocusPrev/Next), this window is temporarily displayed top-most!
|
ImGuiWindow* NavWindowingTarget; // Target window when doing CTRL+Tab (or Pad Menu + FocusPrev/Next), this window is temporarily displayed top-most!
|
||||||
ImGuiWindow* NavWindowingTargetAnim; // Record of last valid NavWindowingTarget until DimBgRatio and NavWindowingHighlightAlpha becomes 0.0f, so the fade-out can stay on it.
|
ImGuiWindow* NavWindowingTargetAnim; // Record of last valid NavWindowingTarget until DimBgRatio and NavWindowingHighlightAlpha becomes 0.0f, so the fade-out can stay on it.
|
||||||
ImGuiWindow* NavWindowingListWindow; // Internal window actually listing the CTRL+Tab contents
|
ImGuiWindow* NavWindowingListWindow; // Internal window actually listing the CTRL+Tab contents
|
||||||
float NavWindowingTimer;
|
float NavWindowingTimer;
|
||||||
float NavWindowingHighlightAlpha;
|
float NavWindowingHighlightAlpha;
|
||||||
bool NavWindowingToggleLayer;
|
bool NavWindowingToggleLayer;
|
||||||
ImGuiKey NavWindowingToggleKey;
|
|
||||||
ImVec2 NavWindowingAccumDeltaPos;
|
ImVec2 NavWindowingAccumDeltaPos;
|
||||||
ImVec2 NavWindowingAccumDeltaSize;
|
ImVec2 NavWindowingAccumDeltaSize;
|
||||||
|
|
||||||
@ -2150,8 +2107,6 @@ struct ImGuiContext
|
|||||||
ImGuiInputTextDeactivatedState InputTextDeactivatedState;
|
ImGuiInputTextDeactivatedState InputTextDeactivatedState;
|
||||||
ImFont InputTextPasswordFont;
|
ImFont InputTextPasswordFont;
|
||||||
ImGuiID TempInputId; // Temporary text input when CTRL+clicking on a slider, etc.
|
ImGuiID TempInputId; // Temporary text input when CTRL+clicking on a slider, etc.
|
||||||
int BeginMenuDepth;
|
|
||||||
int BeginComboDepth;
|
|
||||||
ImGuiColorEditFlags ColorEditOptions; // Store user options for color edit widgets
|
ImGuiColorEditFlags ColorEditOptions; // Store user options for color edit widgets
|
||||||
ImGuiID ColorEditCurrentID; // Set temporarily while inside of the parent-most ColorEdit4/ColorPicker4 (because they call each others).
|
ImGuiID ColorEditCurrentID; // Set temporarily while inside of the parent-most ColorEdit4/ColorPicker4 (because they call each others).
|
||||||
ImGuiID ColorEditSavedID; // ID we are saving/restoring HS for
|
ImGuiID ColorEditSavedID; // ID we are saving/restoring HS for
|
||||||
@ -2208,7 +2163,6 @@ struct ImGuiContext
|
|||||||
int LogDepthToExpandDefault; // Default/stored value for LogDepthMaxExpand if not specified in the LogXXX function call.
|
int LogDepthToExpandDefault; // Default/stored value for LogDepthMaxExpand if not specified in the LogXXX function call.
|
||||||
|
|
||||||
// Debug Tools
|
// Debug Tools
|
||||||
// (some of the highly frequently used data are interleaved in other structures above: DebugBreakXXX fields, DebugHookIdInfo, DebugLocateId etc.)
|
|
||||||
ImGuiDebugLogFlags DebugLogFlags;
|
ImGuiDebugLogFlags DebugLogFlags;
|
||||||
ImGuiTextBuffer DebugLogBuf;
|
ImGuiTextBuffer DebugLogBuf;
|
||||||
ImGuiTextIndex DebugLogIndex;
|
ImGuiTextIndex DebugLogIndex;
|
||||||
@ -2236,7 +2190,6 @@ struct ImGuiContext
|
|||||||
int WantCaptureKeyboardNextFrame; // "
|
int WantCaptureKeyboardNextFrame; // "
|
||||||
int WantTextInputNextFrame;
|
int WantTextInputNextFrame;
|
||||||
ImVector<char> TempBuffer; // Temporary text buffer
|
ImVector<char> TempBuffer; // Temporary text buffer
|
||||||
char TempKeychordName[64];
|
|
||||||
|
|
||||||
ImGuiContext(ImFontAtlas* shared_font_atlas)
|
ImGuiContext(ImFontAtlas* shared_font_atlas)
|
||||||
{
|
{
|
||||||
@ -2246,7 +2199,7 @@ struct ImGuiContext
|
|||||||
Initialized = false;
|
Initialized = false;
|
||||||
FontAtlasOwnedByContext = shared_font_atlas ? false : true;
|
FontAtlasOwnedByContext = shared_font_atlas ? false : true;
|
||||||
Font = NULL;
|
Font = NULL;
|
||||||
FontSize = FontBaseSize = CurrentDpiScale = 0.0f;
|
FontSize = FontBaseSize = 0.0f;
|
||||||
IO.Fonts = shared_font_atlas ? shared_font_atlas : IM_NEW(ImFontAtlas)();
|
IO.Fonts = shared_font_atlas ? shared_font_atlas : IM_NEW(ImFontAtlas)();
|
||||||
Time = 0.0f;
|
Time = 0.0f;
|
||||||
FrameCount = 0;
|
FrameCount = 0;
|
||||||
@ -2282,7 +2235,6 @@ struct ImGuiContext
|
|||||||
ActiveIdHasBeenPressedBefore = false;
|
ActiveIdHasBeenPressedBefore = false;
|
||||||
ActiveIdHasBeenEditedBefore = false;
|
ActiveIdHasBeenEditedBefore = false;
|
||||||
ActiveIdHasBeenEditedThisFrame = false;
|
ActiveIdHasBeenEditedThisFrame = false;
|
||||||
ActiveIdFromShortcut = false;
|
|
||||||
ActiveIdClickOffset = ImVec2(-1, -1);
|
ActiveIdClickOffset = ImVec2(-1, -1);
|
||||||
ActiveIdWindow = NULL;
|
ActiveIdWindow = NULL;
|
||||||
ActiveIdSource = ImGuiInputSource_None;
|
ActiveIdSource = ImGuiInputSource_None;
|
||||||
@ -2305,13 +2257,12 @@ struct ImGuiContext
|
|||||||
CurrentFocusScopeId = 0;
|
CurrentFocusScopeId = 0;
|
||||||
CurrentItemFlags = ImGuiItemFlags_None;
|
CurrentItemFlags = ImGuiItemFlags_None;
|
||||||
DebugShowGroupRects = false;
|
DebugShowGroupRects = false;
|
||||||
|
BeginMenuCount = 0;
|
||||||
|
|
||||||
NavWindow = NULL;
|
NavWindow = NULL;
|
||||||
NavId = NavFocusScopeId = NavActivateId = NavActivateDownId = NavActivatePressedId = 0;
|
NavId = NavFocusScopeId = NavActivateId = NavActivateDownId = NavActivatePressedId = 0;
|
||||||
NavJustMovedToId = NavJustMovedToFocusScopeId = NavNextActivateId = 0;
|
NavJustMovedToId = NavJustMovedToFocusScopeId = NavNextActivateId = 0;
|
||||||
NavActivateFlags = NavNextActivateFlags = ImGuiActivateFlags_None;
|
NavActivateFlags = NavNextActivateFlags = ImGuiActivateFlags_None;
|
||||||
NavHighlightActivatedId = 0;
|
|
||||||
NavHighlightActivatedTimer = 0.0f;
|
|
||||||
NavJustMovedToKeyMods = ImGuiMod_None;
|
NavJustMovedToKeyMods = ImGuiMod_None;
|
||||||
NavInputSource = ImGuiInputSource_Keyboard;
|
NavInputSource = ImGuiInputSource_Keyboard;
|
||||||
NavLayer = ImGuiNavLayer_Main;
|
NavLayer = ImGuiNavLayer_Main;
|
||||||
@ -2334,14 +2285,11 @@ struct ImGuiContext
|
|||||||
NavTabbingDir = 0;
|
NavTabbingDir = 0;
|
||||||
NavTabbingCounter = 0;
|
NavTabbingCounter = 0;
|
||||||
|
|
||||||
// All platforms use Ctrl+Tab but Ctrl<>Super are swapped on Mac...
|
ConfigNavWindowingKeyNext = ImGuiMod_Ctrl | ImGuiKey_Tab;
|
||||||
// FIXME: Because this value is stored, it annoyingly interfere with toggling io.ConfigMacOSXBehaviors updating this..
|
ConfigNavWindowingKeyPrev = ImGuiMod_Ctrl | ImGuiMod_Shift | ImGuiKey_Tab;
|
||||||
ConfigNavWindowingKeyNext = IO.ConfigMacOSXBehaviors ? (ImGuiMod_Super | ImGuiKey_Tab) : (ImGuiMod_Ctrl | ImGuiKey_Tab);
|
|
||||||
ConfigNavWindowingKeyPrev = IO.ConfigMacOSXBehaviors ? (ImGuiMod_Super | ImGuiMod_Shift | ImGuiKey_Tab) : (ImGuiMod_Ctrl | ImGuiMod_Shift | ImGuiKey_Tab);
|
|
||||||
NavWindowingTarget = NavWindowingTargetAnim = NavWindowingListWindow = NULL;
|
NavWindowingTarget = NavWindowingTargetAnim = NavWindowingListWindow = NULL;
|
||||||
NavWindowingTimer = NavWindowingHighlightAlpha = 0.0f;
|
NavWindowingTimer = NavWindowingHighlightAlpha = 0.0f;
|
||||||
NavWindowingToggleLayer = false;
|
NavWindowingToggleLayer = false;
|
||||||
NavWindowingToggleKey = ImGuiKey_None;
|
|
||||||
|
|
||||||
DimBgRatio = 0.0f;
|
DimBgRatio = 0.0f;
|
||||||
|
|
||||||
@ -2370,7 +2318,6 @@ struct ImGuiContext
|
|||||||
MouseStationaryTimer = 0.0f;
|
MouseStationaryTimer = 0.0f;
|
||||||
|
|
||||||
TempInputId = 0;
|
TempInputId = 0;
|
||||||
BeginMenuDepth = BeginComboDepth = 0;
|
|
||||||
ColorEditOptions = ImGuiColorEditFlags_DefaultOptions_;
|
ColorEditOptions = ImGuiColorEditFlags_DefaultOptions_;
|
||||||
ColorEditCurrentID = ColorEditSavedID = 0;
|
ColorEditCurrentID = ColorEditSavedID = 0;
|
||||||
ColorEditSavedHue = ColorEditSavedSat = 0.0f;
|
ColorEditSavedHue = ColorEditSavedSat = 0.0f;
|
||||||
@ -2429,7 +2376,6 @@ struct ImGuiContext
|
|||||||
FramerateSecPerFrameIdx = FramerateSecPerFrameCount = 0;
|
FramerateSecPerFrameIdx = FramerateSecPerFrameCount = 0;
|
||||||
FramerateSecPerFrameAccum = 0.0f;
|
FramerateSecPerFrameAccum = 0.0f;
|
||||||
WantCaptureMouseNextFrame = WantCaptureKeyboardNextFrame = WantTextInputNextFrame = -1;
|
WantCaptureMouseNextFrame = WantCaptureKeyboardNextFrame = WantTextInputNextFrame = -1;
|
||||||
memset(TempKeychordName, 0, sizeof(TempKeychordName));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2479,7 +2425,6 @@ struct IMGUI_API ImGuiWindowTempData
|
|||||||
int CurrentTableIdx; // Current table index (into g.Tables)
|
int CurrentTableIdx; // Current table index (into g.Tables)
|
||||||
ImGuiLayoutType LayoutType;
|
ImGuiLayoutType LayoutType;
|
||||||
ImGuiLayoutType ParentLayoutType; // Layout type of parent window at the time of Begin()
|
ImGuiLayoutType ParentLayoutType; // Layout type of parent window at the time of Begin()
|
||||||
ImU32 ModalDimBgColor;
|
|
||||||
|
|
||||||
// Local parameters stacks
|
// Local parameters stacks
|
||||||
// We store the current settings outside of the vectors to increase memory locality (reduce cache misses). The vectors are rarely modified. Also it allows us to not heap allocate for short-lived windows which are not using those settings.
|
// We store the current settings outside of the vectors to increase memory locality (reduce cache misses). The vectors are rarely modified. Also it allows us to not heap allocate for short-lived windows which are not using those settings.
|
||||||
@ -2526,7 +2471,6 @@ struct IMGUI_API ImGuiWindow
|
|||||||
bool Collapsed; // Set when collapsing window to become only title-bar
|
bool Collapsed; // Set when collapsing window to become only title-bar
|
||||||
bool WantCollapseToggle;
|
bool WantCollapseToggle;
|
||||||
bool SkipItems; // Set when items can safely be all clipped (e.g. window not visible or collapsed)
|
bool SkipItems; // Set when items can safely be all clipped (e.g. window not visible or collapsed)
|
||||||
bool SkipRefresh; // [EXPERIMENTAL] Reuse previous frame drawn contents, Begin() returns false.
|
|
||||||
bool Appearing; // Set during the frame where the window is appearing (or re-appearing)
|
bool Appearing; // Set during the frame where the window is appearing (or re-appearing)
|
||||||
bool Hidden; // Do not display (== HiddenFrames*** > 0)
|
bool Hidden; // Do not display (== HiddenFrames*** > 0)
|
||||||
bool IsFallbackWindow; // Set on the "Debug##Default" window.
|
bool IsFallbackWindow; // Set on the "Debug##Default" window.
|
||||||
@ -2584,7 +2528,6 @@ struct IMGUI_API ImGuiWindow
|
|||||||
ImGuiWindow* RootWindowPopupTree; // Point to ourself or first ancestor that is not a child window. Cross through popups parent<>child.
|
ImGuiWindow* RootWindowPopupTree; // Point to ourself or first ancestor that is not a child window. Cross through popups parent<>child.
|
||||||
ImGuiWindow* RootWindowForTitleBarHighlight; // Point to ourself or first ancestor which will display TitleBgActive color when this window is active.
|
ImGuiWindow* RootWindowForTitleBarHighlight; // Point to ourself or first ancestor which will display TitleBgActive color when this window is active.
|
||||||
ImGuiWindow* RootWindowForNav; // Point to ourself or first ancestor which doesn't have the NavFlattened flag.
|
ImGuiWindow* RootWindowForNav; // Point to ourself or first ancestor which doesn't have the NavFlattened flag.
|
||||||
ImGuiWindow* ParentWindowForFocusRoute; // Set to manual link a window to its logical parent so that Shortcut() chain are honoerd (e.g. Tool linked to Document)
|
|
||||||
|
|
||||||
ImGuiWindow* NavLastChildNavWindow; // When going to the menu bar, we remember the child window we came from. (This could probably be made implicit if we kept g.Windows sorted by last focused including child window.)
|
ImGuiWindow* NavLastChildNavWindow; // When going to the menu bar, we remember the child window we came from. (This could probably be made implicit if we kept g.Windows sorted by last focused including child window.)
|
||||||
ImGuiID NavLastIds[ImGuiNavLayer_COUNT]; // Last known NavId for this window, per layer (0/1)
|
ImGuiID NavLastIds[ImGuiNavLayer_COUNT]; // Last known NavId for this window, per layer (0/1)
|
||||||
@ -2766,24 +2709,13 @@ struct ImGuiTableColumn
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Transient cell data stored per row.
|
// Transient cell data stored per row.
|
||||||
// sizeof() ~ 6 bytes
|
// sizeof() ~ 6
|
||||||
struct ImGuiTableCellData
|
struct ImGuiTableCellData
|
||||||
{
|
{
|
||||||
ImU32 BgColor; // Actual color
|
ImU32 BgColor; // Actual color
|
||||||
ImGuiTableColumnIdx Column; // Column number
|
ImGuiTableColumnIdx Column; // Column number
|
||||||
};
|
};
|
||||||
|
|
||||||
// Parameters for TableAngledHeadersRowEx()
|
|
||||||
// This may end up being refactored for more general purpose.
|
|
||||||
// sizeof() ~ 12 bytes
|
|
||||||
struct ImGuiTableHeaderData
|
|
||||||
{
|
|
||||||
ImGuiTableColumnIdx Index; // Column index
|
|
||||||
ImU32 TextColor;
|
|
||||||
ImU32 BgColor0;
|
|
||||||
ImU32 BgColor1;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Per-instance data that needs preserving across frames (seemingly most others do not need to be preserved aside from debug needs. Does that means they could be moved to ImGuiTableTempData?)
|
// Per-instance data that needs preserving across frames (seemingly most others do not need to be preserved aside from debug needs. Does that means they could be moved to ImGuiTableTempData?)
|
||||||
// sizeof() ~ 24 bytes
|
// sizeof() ~ 24 bytes
|
||||||
struct ImGuiTableInstanceData
|
struct ImGuiTableInstanceData
|
||||||
@ -2798,7 +2730,8 @@ struct ImGuiTableInstanceData
|
|||||||
ImGuiTableInstanceData() { TableInstanceID = 0; LastOuterHeight = LastTopHeadersRowHeight = LastFrozenHeight = 0.0f; HoveredRowLast = HoveredRowNext = -1; }
|
ImGuiTableInstanceData() { TableInstanceID = 0; LastOuterHeight = LastTopHeadersRowHeight = LastFrozenHeight = 0.0f; HoveredRowLast = HoveredRowNext = -1; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// sizeof() ~ 592 bytes + heap allocs described in TableBeginInitMemory()
|
// FIXME-TABLE: more transient data could be stored in a stacked ImGuiTableTempData: e.g. SortSpecs, incoming RowData
|
||||||
|
// sizeof() ~ 580 bytes + heap allocs described in TableBeginInitMemory()
|
||||||
struct IMGUI_API ImGuiTable
|
struct IMGUI_API ImGuiTable
|
||||||
{
|
{
|
||||||
ImGuiID ID;
|
ImGuiID ID;
|
||||||
@ -2868,7 +2801,7 @@ struct IMGUI_API ImGuiTable
|
|||||||
ImGuiTableSortSpecs SortSpecs; // Public facing sorts specs, this is what we return in TableGetSortSpecs()
|
ImGuiTableSortSpecs SortSpecs; // Public facing sorts specs, this is what we return in TableGetSortSpecs()
|
||||||
ImGuiTableColumnIdx SortSpecsCount;
|
ImGuiTableColumnIdx SortSpecsCount;
|
||||||
ImGuiTableColumnIdx ColumnsEnabledCount; // Number of enabled columns (<= ColumnsCount)
|
ImGuiTableColumnIdx ColumnsEnabledCount; // Number of enabled columns (<= ColumnsCount)
|
||||||
ImGuiTableColumnIdx ColumnsEnabledFixedCount; // Number of enabled columns using fixed width (<= ColumnsCount)
|
ImGuiTableColumnIdx ColumnsEnabledFixedCount; // Number of enabled columns (<= ColumnsCount)
|
||||||
ImGuiTableColumnIdx DeclColumnsCount; // Count calls to TableSetupColumn()
|
ImGuiTableColumnIdx DeclColumnsCount; // Count calls to TableSetupColumn()
|
||||||
ImGuiTableColumnIdx AngledHeadersCount; // Count columns with angled headers
|
ImGuiTableColumnIdx AngledHeadersCount; // Count columns with angled headers
|
||||||
ImGuiTableColumnIdx HoveredColumnBody; // Index of column whose visible region is being hovered. Important: == ColumnsCount when hovering empty region after the right-most column!
|
ImGuiTableColumnIdx HoveredColumnBody; // Index of column whose visible region is being hovered. Important: == ColumnsCount when hovering empty region after the right-most column!
|
||||||
@ -2921,14 +2854,12 @@ struct IMGUI_API ImGuiTable
|
|||||||
// Transient data that are only needed between BeginTable() and EndTable(), those buffers are shared (1 per level of stacked table).
|
// Transient data that are only needed between BeginTable() and EndTable(), those buffers are shared (1 per level of stacked table).
|
||||||
// - Accessing those requires chasing an extra pointer so for very frequently used data we leave them in the main table structure.
|
// - Accessing those requires chasing an extra pointer so for very frequently used data we leave them in the main table structure.
|
||||||
// - We also leave out of this structure data that tend to be particularly useful for debugging/metrics.
|
// - We also leave out of this structure data that tend to be particularly useful for debugging/metrics.
|
||||||
// FIXME-TABLE: more transient data could be stored in a stacked ImGuiTableTempData: e.g. SortSpecs.
|
// sizeof() ~ 120 bytes.
|
||||||
// sizeof() ~ 136 bytes.
|
|
||||||
struct IMGUI_API ImGuiTableTempData
|
struct IMGUI_API ImGuiTableTempData
|
||||||
{
|
{
|
||||||
int TableIndex; // Index in g.Tables.Buf[] pool
|
int TableIndex; // Index in g.Tables.Buf[] pool
|
||||||
float LastTimeActive; // Last timestamp this structure was used
|
float LastTimeActive; // Last timestamp this structure was used
|
||||||
float AngledHeadersExtraWidth; // Used in EndTable()
|
float AngledheadersExtraWidth; // Used in EndTable()
|
||||||
ImVector<ImGuiTableHeaderData> AngledHeadersRequests; // Used in TableAngledHeadersRow()
|
|
||||||
|
|
||||||
ImVec2 UserOuterSize; // outer_size.x passed to BeginTable()
|
ImVec2 UserOuterSize; // outer_size.x passed to BeginTable()
|
||||||
ImDrawListSplitter DrawSplitter;
|
ImDrawListSplitter DrawSplitter;
|
||||||
@ -3000,7 +2931,6 @@ namespace ImGui
|
|||||||
IMGUI_API ImGuiWindow* FindWindowByID(ImGuiID id);
|
IMGUI_API ImGuiWindow* FindWindowByID(ImGuiID id);
|
||||||
IMGUI_API ImGuiWindow* FindWindowByName(const char* name);
|
IMGUI_API ImGuiWindow* FindWindowByName(const char* name);
|
||||||
IMGUI_API void UpdateWindowParentAndRootLinks(ImGuiWindow* window, ImGuiWindowFlags flags, ImGuiWindow* parent_window);
|
IMGUI_API void UpdateWindowParentAndRootLinks(ImGuiWindow* window, ImGuiWindowFlags flags, ImGuiWindow* parent_window);
|
||||||
IMGUI_API void UpdateWindowSkipRefresh(ImGuiWindow* window);
|
|
||||||
IMGUI_API ImVec2 CalcWindowNextAutoFitSize(ImGuiWindow* window);
|
IMGUI_API ImVec2 CalcWindowNextAutoFitSize(ImGuiWindow* window);
|
||||||
IMGUI_API bool IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent, bool popup_hierarchy);
|
IMGUI_API bool IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent, bool popup_hierarchy);
|
||||||
IMGUI_API bool IsWindowWithinBeginStackOf(ImGuiWindow* window, ImGuiWindow* potential_parent);
|
IMGUI_API bool IsWindowWithinBeginStackOf(ImGuiWindow* window, ImGuiWindow* potential_parent);
|
||||||
@ -3011,7 +2941,6 @@ namespace ImGui
|
|||||||
IMGUI_API void SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond cond = 0);
|
IMGUI_API void SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond cond = 0);
|
||||||
IMGUI_API void SetWindowHitTestHole(ImGuiWindow* window, const ImVec2& pos, const ImVec2& size);
|
IMGUI_API void SetWindowHitTestHole(ImGuiWindow* window, const ImVec2& pos, const ImVec2& size);
|
||||||
IMGUI_API void SetWindowHiddenAndSkipItemsForCurrentFrame(ImGuiWindow* window);
|
IMGUI_API void SetWindowHiddenAndSkipItemsForCurrentFrame(ImGuiWindow* window);
|
||||||
inline void SetWindowParentWindowForFocusRoute(ImGuiWindow* window, ImGuiWindow* parent_window) { window->ParentWindowForFocusRoute = parent_window; }
|
|
||||||
inline ImRect WindowRectAbsToRel(ImGuiWindow* window, const ImRect& r) { ImVec2 off = window->DC.CursorStartPos; return ImRect(r.Min.x - off.x, r.Min.y - off.y, r.Max.x - off.x, r.Max.y - off.y); }
|
inline ImRect WindowRectAbsToRel(ImGuiWindow* window, const ImRect& r) { ImVec2 off = window->DC.CursorStartPos; return ImRect(r.Min.x - off.x, r.Min.y - off.y, r.Max.x - off.x, r.Max.y - off.y); }
|
||||||
inline ImRect WindowRectRelToAbs(ImGuiWindow* window, const ImRect& r) { ImVec2 off = window->DC.CursorStartPos; return ImRect(r.Min.x + off.x, r.Min.y + off.y, r.Max.x + off.x, r.Max.y + off.y); }
|
inline ImRect WindowRectRelToAbs(ImGuiWindow* window, const ImRect& r) { ImVec2 off = window->DC.CursorStartPos; return ImRect(r.Min.x + off.x, r.Min.y + off.y, r.Max.x + off.x, r.Max.y + off.y); }
|
||||||
inline ImVec2 WindowPosRelToAbs(ImGuiWindow* window, const ImVec2& p) { ImVec2 off = window->DC.CursorStartPos; return ImVec2(p.x + off.x, p.y + off.y); }
|
inline ImVec2 WindowPosRelToAbs(ImGuiWindow* window, const ImVec2& p) { ImVec2 off = window->DC.CursorStartPos; return ImVec2(p.x + off.x, p.y + off.y); }
|
||||||
@ -3026,9 +2955,6 @@ namespace ImGui
|
|||||||
IMGUI_API int FindWindowDisplayIndex(ImGuiWindow* window);
|
IMGUI_API int FindWindowDisplayIndex(ImGuiWindow* window);
|
||||||
IMGUI_API ImGuiWindow* FindBottomMostVisibleWindowWithinBeginStack(ImGuiWindow* window);
|
IMGUI_API ImGuiWindow* FindBottomMostVisibleWindowWithinBeginStack(ImGuiWindow* window);
|
||||||
|
|
||||||
// Windows: Idle, Refresh Policies [EXPERIMENTAL]
|
|
||||||
IMGUI_API void SetNextWindowRefreshPolicy(ImGuiWindowRefreshFlags flags);
|
|
||||||
|
|
||||||
// Fonts, drawing
|
// Fonts, drawing
|
||||||
IMGUI_API void SetCurrentFont(ImFont* font);
|
IMGUI_API void SetCurrentFont(ImFont* font);
|
||||||
inline ImFont* GetDefaultFont() { ImGuiContext& g = *GImGui; return g.IO.FontDefault ? g.IO.FontDefault : g.IO.Fonts->Fonts[0]; }
|
inline ImFont* GetDefaultFont() { ImGuiContext& g = *GImGui; return g.IO.FontDefault ? g.IO.FontDefault : g.IO.Fonts->Fonts[0]; }
|
||||||
@ -3044,7 +2970,6 @@ namespace ImGui
|
|||||||
// NewFrame
|
// NewFrame
|
||||||
IMGUI_API void UpdateInputEvents(bool trickle_fast_inputs);
|
IMGUI_API void UpdateInputEvents(bool trickle_fast_inputs);
|
||||||
IMGUI_API void UpdateHoveredWindowAndCaptureFlags();
|
IMGUI_API void UpdateHoveredWindowAndCaptureFlags();
|
||||||
IMGUI_API void FindHoveredWindowEx(const ImVec2& pos, bool find_first_and_in_any_viewport, ImGuiWindow** out_hovered_window, ImGuiWindow** out_hovered_window_under_moving_window);
|
|
||||||
IMGUI_API void StartMouseMovingWindow(ImGuiWindow* window);
|
IMGUI_API void StartMouseMovingWindow(ImGuiWindow* window);
|
||||||
IMGUI_API void UpdateMouseMovingWindowNewFrame();
|
IMGUI_API void UpdateMouseMovingWindowNewFrame();
|
||||||
IMGUI_API void UpdateMouseMovingWindowEndFrame();
|
IMGUI_API void UpdateMouseMovingWindowEndFrame();
|
||||||
@ -3169,13 +3094,11 @@ namespace ImGui
|
|||||||
IMGUI_API void NavMoveRequestCancel();
|
IMGUI_API void NavMoveRequestCancel();
|
||||||
IMGUI_API void NavMoveRequestApplyResult();
|
IMGUI_API void NavMoveRequestApplyResult();
|
||||||
IMGUI_API void NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags move_flags);
|
IMGUI_API void NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags move_flags);
|
||||||
IMGUI_API void NavHighlightActivated(ImGuiID id);
|
|
||||||
IMGUI_API void NavClearPreferredPosForAxis(ImGuiAxis axis);
|
IMGUI_API void NavClearPreferredPosForAxis(ImGuiAxis axis);
|
||||||
IMGUI_API void NavRestoreHighlightAfterMove();
|
IMGUI_API void NavRestoreHighlightAfterMove();
|
||||||
IMGUI_API void NavUpdateCurrentWindowIsScrollPushableX();
|
IMGUI_API void NavUpdateCurrentWindowIsScrollPushableX();
|
||||||
IMGUI_API void SetNavWindow(ImGuiWindow* window);
|
IMGUI_API void SetNavWindow(ImGuiWindow* window);
|
||||||
IMGUI_API void SetNavID(ImGuiID id, ImGuiNavLayer nav_layer, ImGuiID focus_scope_id, const ImRect& rect_rel);
|
IMGUI_API void SetNavID(ImGuiID id, ImGuiNavLayer nav_layer, ImGuiID focus_scope_id, const ImRect& rect_rel);
|
||||||
IMGUI_API void SetNavFocusScope(ImGuiID focus_scope_id);
|
|
||||||
|
|
||||||
// Focus/Activation
|
// Focus/Activation
|
||||||
// This should be part of a larger set of API: FocusItem(offset = -1), FocusItemByID(id), ActivateItem(offset = -1), ActivateItemByID(id) etc. which are
|
// This should be part of a larger set of API: FocusItem(offset = -1), FocusItemByID(id), ActivateItem(offset = -1), ActivateItemByID(id) etc. which are
|
||||||
@ -3186,26 +3109,27 @@ namespace ImGui
|
|||||||
// Inputs
|
// Inputs
|
||||||
// FIXME: Eventually we should aim to move e.g. IsActiveIdUsingKey() into IsKeyXXX functions.
|
// FIXME: Eventually we should aim to move e.g. IsActiveIdUsingKey() into IsKeyXXX functions.
|
||||||
inline bool IsNamedKey(ImGuiKey key) { return key >= ImGuiKey_NamedKey_BEGIN && key < ImGuiKey_NamedKey_END; }
|
inline bool IsNamedKey(ImGuiKey key) { return key >= ImGuiKey_NamedKey_BEGIN && key < ImGuiKey_NamedKey_END; }
|
||||||
inline bool IsNamedKeyOrMod(ImGuiKey key) { return (key >= ImGuiKey_NamedKey_BEGIN && key < ImGuiKey_NamedKey_END) || key == ImGuiMod_Ctrl || key == ImGuiMod_Shift || key == ImGuiMod_Alt || key == ImGuiMod_Super; }
|
inline bool IsNamedKeyOrModKey(ImGuiKey key) { return (key >= ImGuiKey_NamedKey_BEGIN && key < ImGuiKey_NamedKey_END) || key == ImGuiMod_Ctrl || key == ImGuiMod_Shift || key == ImGuiMod_Alt || key == ImGuiMod_Super || key == ImGuiMod_Shortcut; }
|
||||||
inline bool IsLegacyKey(ImGuiKey key) { return key >= ImGuiKey_LegacyNativeKey_BEGIN && key < ImGuiKey_LegacyNativeKey_END; }
|
inline bool IsLegacyKey(ImGuiKey key) { return key >= ImGuiKey_LegacyNativeKey_BEGIN && key < ImGuiKey_LegacyNativeKey_END; }
|
||||||
inline bool IsKeyboardKey(ImGuiKey key) { return key >= ImGuiKey_Keyboard_BEGIN && key < ImGuiKey_Keyboard_END; }
|
inline bool IsKeyboardKey(ImGuiKey key) { return key >= ImGuiKey_Keyboard_BEGIN && key < ImGuiKey_Keyboard_END; }
|
||||||
inline bool IsGamepadKey(ImGuiKey key) { return key >= ImGuiKey_Gamepad_BEGIN && key < ImGuiKey_Gamepad_END; }
|
inline bool IsGamepadKey(ImGuiKey key) { return key >= ImGuiKey_Gamepad_BEGIN && key < ImGuiKey_Gamepad_END; }
|
||||||
inline bool IsMouseKey(ImGuiKey key) { return key >= ImGuiKey_Mouse_BEGIN && key < ImGuiKey_Mouse_END; }
|
inline bool IsMouseKey(ImGuiKey key) { return key >= ImGuiKey_Mouse_BEGIN && key < ImGuiKey_Mouse_END; }
|
||||||
inline bool IsAliasKey(ImGuiKey key) { return key >= ImGuiKey_Aliases_BEGIN && key < ImGuiKey_Aliases_END; }
|
inline bool IsAliasKey(ImGuiKey key) { return key >= ImGuiKey_Aliases_BEGIN && key < ImGuiKey_Aliases_END; }
|
||||||
inline bool IsModKey(ImGuiKey key) { return key >= ImGuiKey_LeftCtrl && key <= ImGuiKey_RightSuper; }
|
inline ImGuiKeyChord ConvertShortcutMod(ImGuiKeyChord key_chord) { ImGuiContext& g = *GImGui; IM_ASSERT_PARANOID(key_chord & ImGuiMod_Shortcut); return (key_chord & ~ImGuiMod_Shortcut) | (g.IO.ConfigMacOSXBehaviors ? ImGuiMod_Super : ImGuiMod_Ctrl); }
|
||||||
ImGuiKeyChord FixupKeyChord(ImGuiKeyChord key_chord);
|
inline ImGuiKey ConvertSingleModFlagToKey(ImGuiContext* ctx, ImGuiKey key)
|
||||||
inline ImGuiKey ConvertSingleModFlagToKey(ImGuiKey key)
|
|
||||||
{
|
{
|
||||||
|
ImGuiContext& g = *ctx;
|
||||||
if (key == ImGuiMod_Ctrl) return ImGuiKey_ReservedForModCtrl;
|
if (key == ImGuiMod_Ctrl) return ImGuiKey_ReservedForModCtrl;
|
||||||
if (key == ImGuiMod_Shift) return ImGuiKey_ReservedForModShift;
|
if (key == ImGuiMod_Shift) return ImGuiKey_ReservedForModShift;
|
||||||
if (key == ImGuiMod_Alt) return ImGuiKey_ReservedForModAlt;
|
if (key == ImGuiMod_Alt) return ImGuiKey_ReservedForModAlt;
|
||||||
if (key == ImGuiMod_Super) return ImGuiKey_ReservedForModSuper;
|
if (key == ImGuiMod_Super) return ImGuiKey_ReservedForModSuper;
|
||||||
|
if (key == ImGuiMod_Shortcut) return (g.IO.ConfigMacOSXBehaviors ? ImGuiKey_ReservedForModSuper : ImGuiKey_ReservedForModCtrl);
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
IMGUI_API ImGuiKeyData* GetKeyData(ImGuiContext* ctx, ImGuiKey key);
|
IMGUI_API ImGuiKeyData* GetKeyData(ImGuiContext* ctx, ImGuiKey key);
|
||||||
inline ImGuiKeyData* GetKeyData(ImGuiKey key) { ImGuiContext& g = *GImGui; return GetKeyData(&g, key); }
|
inline ImGuiKeyData* GetKeyData(ImGuiKey key) { ImGuiContext& g = *GImGui; return GetKeyData(&g, key); }
|
||||||
IMGUI_API const char* GetKeyChordName(ImGuiKeyChord key_chord);
|
IMGUI_API const char* GetKeyChordName(ImGuiKeyChord key_chord, char* out_buf, int out_buf_size);
|
||||||
inline ImGuiKey MouseButtonToKey(ImGuiMouseButton button) { IM_ASSERT(button >= 0 && button < ImGuiMouseButton_COUNT); return (ImGuiKey)(ImGuiKey_MouseLeft + button); }
|
inline ImGuiKey MouseButtonToKey(ImGuiMouseButton button) { IM_ASSERT(button >= 0 && button < ImGuiMouseButton_COUNT); return (ImGuiKey)(ImGuiKey_MouseLeft + button); }
|
||||||
IMGUI_API bool IsMouseDragPastThreshold(ImGuiMouseButton button, float lock_threshold = -1.0f);
|
IMGUI_API bool IsMouseDragPastThreshold(ImGuiMouseButton button, float lock_threshold = -1.0f);
|
||||||
IMGUI_API ImVec2 GetKeyMagnitude2d(ImGuiKey key_left, ImGuiKey key_right, ImGuiKey key_up, ImGuiKey key_down);
|
IMGUI_API ImVec2 GetKeyMagnitude2d(ImGuiKey key_left, ImGuiKey key_right, ImGuiKey key_up, ImGuiKey key_down);
|
||||||
@ -3219,7 +3143,7 @@ namespace ImGui
|
|||||||
// [EXPERIMENTAL] Low-Level: Key/Input Ownership
|
// [EXPERIMENTAL] Low-Level: Key/Input Ownership
|
||||||
// - The idea is that instead of "eating" a given input, we can link to an owner id.
|
// - The idea is that instead of "eating" a given input, we can link to an owner id.
|
||||||
// - Ownership is most often claimed as a result of reacting to a press/down event (but occasionally may be claimed ahead).
|
// - Ownership is most often claimed as a result of reacting to a press/down event (but occasionally may be claimed ahead).
|
||||||
// - Input queries can then read input by specifying ImGuiKeyOwner_Any (== 0), ImGuiKeyOwner_NoOwner (== -1) or a custom ID.
|
// - Input queries can then read input by specifying ImGuiKeyOwner_Any (== 0), ImGuiKeyOwner_None (== -1) or a custom ID.
|
||||||
// - Legacy input queries (without specifying an owner or _Any or _None) are equivalent to using ImGuiKeyOwner_Any (== 0).
|
// - Legacy input queries (without specifying an owner or _Any or _None) are equivalent to using ImGuiKeyOwner_Any (== 0).
|
||||||
// - Input ownership is automatically released on the frame after a key is released. Therefore:
|
// - Input ownership is automatically released on the frame after a key is released. Therefore:
|
||||||
// - for ownership registration happening as a result of a down/press event, the SetKeyOwner() call may be done once (common case).
|
// - for ownership registration happening as a result of a down/press event, the SetKeyOwner() call may be done once (common case).
|
||||||
@ -3232,7 +3156,7 @@ namespace ImGui
|
|||||||
IMGUI_API void SetKeyOwnersForKeyChord(ImGuiKeyChord key, ImGuiID owner_id, ImGuiInputFlags flags = 0);
|
IMGUI_API void SetKeyOwnersForKeyChord(ImGuiKeyChord key, ImGuiID owner_id, ImGuiInputFlags flags = 0);
|
||||||
IMGUI_API void SetItemKeyOwner(ImGuiKey key, ImGuiInputFlags flags = 0); // Set key owner to last item if it is hovered or active. Equivalent to 'if (IsItemHovered() || IsItemActive()) { SetKeyOwner(key, GetItemID());'.
|
IMGUI_API void SetItemKeyOwner(ImGuiKey key, ImGuiInputFlags flags = 0); // Set key owner to last item if it is hovered or active. Equivalent to 'if (IsItemHovered() || IsItemActive()) { SetKeyOwner(key, GetItemID());'.
|
||||||
IMGUI_API bool TestKeyOwner(ImGuiKey key, ImGuiID owner_id); // Test that key is either not owned, either owned by 'owner_id'
|
IMGUI_API bool TestKeyOwner(ImGuiKey key, ImGuiID owner_id); // Test that key is either not owned, either owned by 'owner_id'
|
||||||
inline ImGuiKeyOwnerData* GetKeyOwnerData(ImGuiContext* ctx, ImGuiKey key) { if (key & ImGuiMod_Mask_) key = ConvertSingleModFlagToKey(key); IM_ASSERT(IsNamedKey(key)); return &ctx->KeysOwnerData[key - ImGuiKey_NamedKey_BEGIN]; }
|
inline ImGuiKeyOwnerData* GetKeyOwnerData(ImGuiContext* ctx, ImGuiKey key) { if (key & ImGuiMod_Mask_) key = ConvertSingleModFlagToKey(ctx, key); IM_ASSERT(IsNamedKey(key)); return &ctx->KeysOwnerData[key - ImGuiKey_NamedKey_BEGIN]; }
|
||||||
|
|
||||||
// [EXPERIMENTAL] High-Level: Input Access functions w/ support for Key/Input Ownership
|
// [EXPERIMENTAL] High-Level: Input Access functions w/ support for Key/Input Ownership
|
||||||
// - Important: legacy IsKeyPressed(ImGuiKey, bool repeat=true) _DEFAULTS_ to repeat, new IsKeyPressed() requires _EXPLICIT_ ImGuiInputFlags_Repeat flag.
|
// - Important: legacy IsKeyPressed(ImGuiKey, bool repeat=true) _DEFAULTS_ to repeat, new IsKeyPressed() requires _EXPLICIT_ ImGuiInputFlags_Repeat flag.
|
||||||
@ -3241,30 +3165,29 @@ namespace ImGui
|
|||||||
// Legacy functions use ImGuiKeyOwner_Any meaning that they typically ignore ownership, unless a call to SetKeyOwner() explicitly used ImGuiInputFlags_LockThisFrame or ImGuiInputFlags_LockUntilRelease.
|
// Legacy functions use ImGuiKeyOwner_Any meaning that they typically ignore ownership, unless a call to SetKeyOwner() explicitly used ImGuiInputFlags_LockThisFrame or ImGuiInputFlags_LockUntilRelease.
|
||||||
// - Binding generators may want to ignore those for now, or suffix them with Ex() until we decide if this gets moved into public API.
|
// - Binding generators may want to ignore those for now, or suffix them with Ex() until we decide if this gets moved into public API.
|
||||||
IMGUI_API bool IsKeyDown(ImGuiKey key, ImGuiID owner_id);
|
IMGUI_API bool IsKeyDown(ImGuiKey key, ImGuiID owner_id);
|
||||||
IMGUI_API bool IsKeyPressed(ImGuiKey key, ImGuiInputFlags flags, ImGuiID owner_id = 0); // Important: when transitioning from old to new IsKeyPressed(): old API has "bool repeat = true", so would default to repeat. New API requiress explicit ImGuiInputFlags_Repeat.
|
IMGUI_API bool IsKeyPressed(ImGuiKey key, ImGuiID owner_id, ImGuiInputFlags flags = 0); // Important: when transitioning from old to new IsKeyPressed(): old API has "bool repeat = true", so would default to repeat. New API requiress explicit ImGuiInputFlags_Repeat.
|
||||||
IMGUI_API bool IsKeyReleased(ImGuiKey key, ImGuiID owner_id);
|
IMGUI_API bool IsKeyReleased(ImGuiKey key, ImGuiID owner_id);
|
||||||
IMGUI_API bool IsKeyChordPressed(ImGuiKeyChord key_chord, ImGuiInputFlags flags, ImGuiID owner_id = 0);
|
|
||||||
IMGUI_API bool IsMouseDown(ImGuiMouseButton button, ImGuiID owner_id);
|
IMGUI_API bool IsMouseDown(ImGuiMouseButton button, ImGuiID owner_id);
|
||||||
IMGUI_API bool IsMouseClicked(ImGuiMouseButton button, ImGuiInputFlags flags, ImGuiID owner_id = 0);
|
IMGUI_API bool IsMouseClicked(ImGuiMouseButton button, ImGuiID owner_id, ImGuiInputFlags flags = 0);
|
||||||
IMGUI_API bool IsMouseReleased(ImGuiMouseButton button, ImGuiID owner_id);
|
IMGUI_API bool IsMouseReleased(ImGuiMouseButton button, ImGuiID owner_id);
|
||||||
IMGUI_API bool IsMouseDoubleClicked(ImGuiMouseButton button, ImGuiID owner_id);
|
IMGUI_API bool IsMouseDoubleClicked(ImGuiMouseButton button, ImGuiID owner_id);
|
||||||
|
|
||||||
// Shortcut Testing & Routing
|
// [EXPERIMENTAL] Shortcut Routing
|
||||||
// - Set Shortcut() and SetNextItemShortcut() in imgui.h
|
// - ImGuiKeyChord = a ImGuiKey optionally OR-red with ImGuiMod_Alt/ImGuiMod_Ctrl/ImGuiMod_Shift/ImGuiMod_Super.
|
||||||
// - When a policy (except for ImGuiInputFlags_RouteAlways *) is set, Shortcut() will register itself with SetShortcutRouting(),
|
// ImGuiKey_C (accepted by functions taking ImGuiKey or ImGuiKeyChord)
|
||||||
// allowing the system to decide where to route the input among other route-aware calls.
|
// ImGuiKey_C | ImGuiMod_Ctrl (accepted by functions taking ImGuiKeyChord)
|
||||||
// (* using ImGuiInputFlags_RouteAlways is roughly equivalent to calling IsKeyChordPressed(key) and bypassing route registration and check)
|
// ONLY ImGuiMod_XXX values are legal to 'OR' with an ImGuiKey. You CANNOT 'OR' two ImGuiKey values.
|
||||||
// - When using one of the routing option:
|
// - When using one of the routing flags (e.g. ImGuiInputFlags_RouteFocused): routes requested ahead of time given a chord (key + modifiers) and a routing policy.
|
||||||
// - The default route is ImGuiInputFlags_RouteFocused (accept inputs if window is in focus stack. Deep-most focused window takes inputs. ActiveId takes inputs over deep-most focused window.)
|
|
||||||
// - Routes are requested given a chord (key + modifiers) and a routing policy.
|
|
||||||
// - Routes are resolved during NewFrame(): if keyboard modifiers are matching current ones: SetKeyOwner() is called + route is granted for the frame.
|
// - Routes are resolved during NewFrame(): if keyboard modifiers are matching current ones: SetKeyOwner() is called + route is granted for the frame.
|
||||||
// - Each route may be granted to a single owner. When multiple requests are made we have policies to select the winning route (e.g. deep most window).
|
// - Route is granted to a single owner. When multiple requests are made we have policies to select the winning route.
|
||||||
// - Multiple read sites may use the same owner id can all access the granted route.
|
// - Multiple read sites may use the same owner id and will all get the granted route.
|
||||||
// - When owner_id is 0 we use the current Focus Scope ID as a owner ID in order to identify our location.
|
// - For routing: when owner_id is 0 we use the current Focus Scope ID as a default owner in order to identify our location.
|
||||||
// - You can chain two unrelated windows in the focus stack using SetWindowParentWindowForFocusRoute()
|
// - TL;DR;
|
||||||
// e.g. if you have a tool window associated to a document, and you want document shortcuts to run when the tool is focused.
|
// - IsKeyChordPressed() compares mods + call IsKeyPressed() -> function has no side-effect.
|
||||||
IMGUI_API bool Shortcut(ImGuiKeyChord key_chord, ImGuiInputFlags flags, ImGuiID owner_id);
|
// - Shortcut() submits a route then if currently can be routed calls IsKeyChordPressed() -> function has (desirable) side-effects.
|
||||||
IMGUI_API bool SetShortcutRouting(ImGuiKeyChord key_chord, ImGuiInputFlags flags, ImGuiID owner_id); // owner_id needs to be explicit and cannot be 0
|
IMGUI_API bool IsKeyChordPressed(ImGuiKeyChord key_chord, ImGuiID owner_id, ImGuiInputFlags flags = 0);
|
||||||
|
IMGUI_API bool Shortcut(ImGuiKeyChord key_chord, ImGuiID owner_id = 0, ImGuiInputFlags flags = 0);
|
||||||
|
IMGUI_API bool SetShortcutRouting(ImGuiKeyChord key_chord, ImGuiID owner_id = 0, ImGuiInputFlags flags = 0);
|
||||||
IMGUI_API bool TestShortcutRouting(ImGuiKeyChord key_chord, ImGuiID owner_id);
|
IMGUI_API bool TestShortcutRouting(ImGuiKeyChord key_chord, ImGuiID owner_id);
|
||||||
IMGUI_API ImGuiKeyRoutingData* GetShortcutRoutingData(ImGuiKeyChord key_chord);
|
IMGUI_API ImGuiKeyRoutingData* GetShortcutRoutingData(ImGuiKeyChord key_chord);
|
||||||
|
|
||||||
@ -3315,7 +3238,7 @@ namespace ImGui
|
|||||||
IMGUI_API float TableGetHeaderAngledMaxLabelWidth();
|
IMGUI_API float TableGetHeaderAngledMaxLabelWidth();
|
||||||
IMGUI_API void TablePushBackgroundChannel();
|
IMGUI_API void TablePushBackgroundChannel();
|
||||||
IMGUI_API void TablePopBackgroundChannel();
|
IMGUI_API void TablePopBackgroundChannel();
|
||||||
IMGUI_API void TableAngledHeadersRowEx(ImGuiID row_id, float angle, float max_label_width, const ImGuiTableHeaderData* data, int data_count);
|
IMGUI_API void TableAngledHeadersRowEx(float angle, float label_width = 0.0f);
|
||||||
|
|
||||||
// Tables: Internals
|
// Tables: Internals
|
||||||
inline ImGuiTable* GetCurrentTable() { ImGuiContext& g = *GImGui; return g.CurrentTable; }
|
inline ImGuiTable* GetCurrentTable() { ImGuiContext& g = *GImGui; return g.CurrentTable; }
|
||||||
@ -3393,7 +3316,7 @@ namespace ImGui
|
|||||||
IMGUI_API void RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border = true, float rounding = 0.0f);
|
IMGUI_API void RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border = true, float rounding = 0.0f);
|
||||||
IMGUI_API void RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding = 0.0f);
|
IMGUI_API void RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding = 0.0f);
|
||||||
IMGUI_API void RenderColorRectWithAlphaCheckerboard(ImDrawList* draw_list, ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, float grid_step, ImVec2 grid_off, float rounding = 0.0f, ImDrawFlags flags = 0);
|
IMGUI_API void RenderColorRectWithAlphaCheckerboard(ImDrawList* draw_list, ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, float grid_step, ImVec2 grid_off, float rounding = 0.0f, ImDrawFlags flags = 0);
|
||||||
IMGUI_API void RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFlags flags = ImGuiNavHighlightFlags_None); // Navigation highlight
|
IMGUI_API void RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFlags flags = ImGuiNavHighlightFlags_TypeDefault); // Navigation highlight
|
||||||
IMGUI_API const char* FindRenderedTextEnd(const char* text, const char* text_end = NULL); // Find the optional ## from which we stop displaying text.
|
IMGUI_API const char* FindRenderedTextEnd(const char* text, const char* text_end = NULL); // Find the optional ## from which we stop displaying text.
|
||||||
IMGUI_API void RenderMouseCursor(ImVec2 pos, float scale, ImGuiMouseCursor mouse_cursor, ImU32 col_fill, ImU32 col_border, ImU32 col_shadow);
|
IMGUI_API void RenderMouseCursor(ImVec2 pos, float scale, ImGuiMouseCursor mouse_cursor, ImU32 col_fill, ImU32 col_border, ImU32 col_shadow);
|
||||||
|
|
||||||
@ -3498,6 +3421,7 @@ namespace ImGui
|
|||||||
IMGUI_API void DebugBreakClearData();
|
IMGUI_API void DebugBreakClearData();
|
||||||
IMGUI_API bool DebugBreakButton(const char* label, const char* description_of_location);
|
IMGUI_API bool DebugBreakButton(const char* label, const char* description_of_location);
|
||||||
IMGUI_API void DebugBreakButtonTooltip(bool keyboard_only, const char* description_of_location);
|
IMGUI_API void DebugBreakButtonTooltip(bool keyboard_only, const char* description_of_location);
|
||||||
|
inline void DebugStartItemPicker() { ImGuiContext& g = *GImGui; g.DebugItemPickerActive = true; }
|
||||||
IMGUI_API void ShowFontAtlas(ImFontAtlas* atlas);
|
IMGUI_API void ShowFontAtlas(ImFontAtlas* atlas);
|
||||||
IMGUI_API void DebugHookIdInfo(ImGuiID id, ImGuiDataType data_type, const void* data_id, const void* data_id_end);
|
IMGUI_API void DebugHookIdInfo(ImGuiID id, ImGuiDataType data_type, const void* data_id, const void* data_id_end);
|
||||||
IMGUI_API void DebugNodeColumns(ImGuiOldColumns* columns);
|
IMGUI_API void DebugNodeColumns(ImGuiOldColumns* columns);
|
||||||
@ -3524,14 +3448,16 @@ namespace ImGui
|
|||||||
inline void SetItemUsingMouseWheel() { SetItemKeyOwner(ImGuiKey_MouseWheelY); } // Changed in 1.89
|
inline void SetItemUsingMouseWheel() { SetItemKeyOwner(ImGuiKey_MouseWheelY); } // Changed in 1.89
|
||||||
inline bool TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags = 0) { return TreeNodeUpdateNextOpen(id, flags); } // Renamed in 1.89
|
inline bool TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags = 0) { return TreeNodeUpdateNextOpen(id, flags); } // Renamed in 1.89
|
||||||
|
|
||||||
//inline bool IsKeyPressedMap(ImGuiKey key, bool repeat = true) { IM_ASSERT(IsNamedKey(key)); return IsKeyPressed(key, repeat); } // Removed in 1.87: Mapping from named key is always identity!
|
// Refactored focus/nav/tabbing system in 1.82 and 1.84. If you have old/custom copy-and-pasted widgets that used FocusableItemRegister():
|
||||||
|
|
||||||
// Refactored focus/nav/tabbing system in 1.82 and 1.84. If you have old/custom copy-and-pasted widgets which used FocusableItemRegister():
|
|
||||||
// (Old) IMGUI_VERSION_NUM < 18209: using 'ItemAdd(....)' and 'bool tab_focused = FocusableItemRegister(...)'
|
// (Old) IMGUI_VERSION_NUM < 18209: using 'ItemAdd(....)' and 'bool tab_focused = FocusableItemRegister(...)'
|
||||||
// (Old) IMGUI_VERSION_NUM >= 18209: using 'ItemAdd(..., ImGuiItemAddFlags_Focusable)' and 'bool tab_focused = (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_Focused) != 0'
|
// (Old) IMGUI_VERSION_NUM >= 18209: using 'ItemAdd(..., ImGuiItemAddFlags_Focusable)' and 'bool tab_focused = (GetItemStatusFlags() & ImGuiItemStatusFlags_Focused) != 0'
|
||||||
// (New) IMGUI_VERSION_NUM >= 18413: using 'ItemAdd(..., ImGuiItemFlags_Inputable)' and 'bool tab_focused = (g.NavActivateId == id && (g.NavActivateFlags & ImGuiActivateFlags_PreferInput))'
|
// (New) IMGUI_VERSION_NUM >= 18413: using 'ItemAdd(..., ImGuiItemFlags_Inputable)' and 'bool tab_focused = (GetItemStatusFlags() & ImGuiItemStatusFlags_FocusedTabbing) != 0 || (g.NavActivateId == id && (g.NavActivateFlags & ImGuiActivateFlags_PreferInput))' (WIP)
|
||||||
//inline bool FocusableItemRegister(ImGuiWindow* window, ImGuiID id) // -> pass ImGuiItemAddFlags_Inputable flag to ItemAdd()
|
// Widget code are simplified as there's no need to call FocusableItemUnregister() while managing the transition from regular widget to TempInputText()
|
||||||
//inline void FocusableItemUnregister(ImGuiWindow* window) // -> unnecessary: TempInputText() uses ImGuiInputTextFlags_MergedItem
|
inline bool FocusableItemRegister(ImGuiWindow* window, ImGuiID id) { IM_ASSERT(0); IM_UNUSED(window); IM_UNUSED(id); return false; } // -> pass ImGuiItemAddFlags_Inputable flag to ItemAdd()
|
||||||
|
inline void FocusableItemUnregister(ImGuiWindow* window) { IM_ASSERT(0); IM_UNUSED(window); } // -> unnecessary: TempInputText() uses ImGuiInputTextFlags_MergedItem
|
||||||
|
#endif
|
||||||
|
#ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
|
||||||
|
inline bool IsKeyPressedMap(ImGuiKey key, bool repeat = true) { IM_ASSERT(IsNamedKey(key)); return IsKeyPressed(key, repeat); } // Removed in 1.87: Mapping from named key is always identity!
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // namespace ImGui
|
} // namespace ImGui
|
||||||
|
202
external/imgui/imgui/imgui_tables.cpp
vendored
202
external/imgui/imgui/imgui_tables.cpp
vendored
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.90.7
|
// dear imgui, v1.90.1
|
||||||
// (tables and columns code)
|
// (tables and columns code)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -24,9 +24,8 @@ Index of this file:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Navigating this file:
|
// Navigating this file:
|
||||||
// - In Visual Studio: CTRL+comma ("Edit.GoToAll") can follow symbols inside comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot.
|
// - In Visual Studio IDE: CTRL+comma ("Edit.GoToAll") can follow symbols in comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot.
|
||||||
// - In Visual Studio w/ Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols inside comments.
|
// - With Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols in comments.
|
||||||
// - In VS Code, CLion, etc.: CTRL+click can follow symbols inside comments.
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Commentary
|
// [SECTION] Commentary
|
||||||
@ -228,7 +227,6 @@ Index of this file:
|
|||||||
#pragma clang diagnostic ignored "-Wenum-enum-conversion" // warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_')
|
#pragma clang diagnostic ignored "-Wenum-enum-conversion" // warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_')
|
||||||
#pragma clang diagnostic ignored "-Wdeprecated-enum-enum-conversion"// warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_') is deprecated
|
#pragma clang diagnostic ignored "-Wdeprecated-enum-enum-conversion"// warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_') is deprecated
|
||||||
#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision
|
#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision
|
||||||
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" // warning: 'xxx' is an unsafe pointer used for buffer access
|
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
||||||
#pragma GCC diagnostic ignored "-Wformat-nonliteral" // warning: format not a string literal, format string not checked
|
#pragma GCC diagnostic ignored "-Wformat-nonliteral" // warning: format not a string literal, format string not checked
|
||||||
@ -320,12 +318,6 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
|
|||||||
IM_ASSERT(inner_width >= 0.0f);
|
IM_ASSERT(inner_width >= 0.0f);
|
||||||
|
|
||||||
// If an outer size is specified ahead we will be able to early out when not visible. Exact clipping criteria may evolve.
|
// If an outer size is specified ahead we will be able to early out when not visible. Exact clipping criteria may evolve.
|
||||||
// FIXME: coarse clipping because access to table data causes two issues:
|
|
||||||
// - instance numbers varying/unstable. may not be a direct problem for users, but could make outside access broken or confusing, e.g. TestEngine.
|
|
||||||
// - can't implement support for ImGuiChildFlags_ResizeY as we need to somehow pull the height data from somewhere. this also needs stable instance numbers.
|
|
||||||
// The side-effects of accessing table data on coarse clip would be:
|
|
||||||
// - always reserving the pooled ImGuiTable data ahead for a fully clipped table (minor IMHO). Also the 'outer_window_is_measuring_size' criteria may already be defeating this in some situations.
|
|
||||||
// - always performing the GetOrAddByKey() O(log N) query in g.Tables.Map[].
|
|
||||||
const bool use_child_window = (flags & (ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY)) != 0;
|
const bool use_child_window = (flags & (ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY)) != 0;
|
||||||
const ImVec2 avail_size = GetContentRegionAvail();
|
const ImVec2 avail_size = GetContentRegionAvail();
|
||||||
const ImVec2 actual_outer_size = CalcItemSize(outer_size, ImMax(avail_size.x, 1.0f), use_child_window ? ImMax(avail_size.y, 1.0f) : 0.0f);
|
const ImVec2 actual_outer_size = CalcItemSize(outer_size, ImMax(avail_size.x, 1.0f), use_child_window ? ImMax(avail_size.y, 1.0f) : 0.0f);
|
||||||
@ -334,7 +326,6 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
|
|||||||
if (use_child_window && IsClippedEx(outer_rect, 0) && !outer_window_is_measuring_size)
|
if (use_child_window && IsClippedEx(outer_rect, 0) && !outer_window_is_measuring_size)
|
||||||
{
|
{
|
||||||
ItemSize(outer_rect);
|
ItemSize(outer_rect);
|
||||||
ItemAdd(outer_rect, id);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,6 +335,7 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
|
|||||||
|
|
||||||
// Acquire storage for the table
|
// Acquire storage for the table
|
||||||
ImGuiTable* table = g.Tables.GetOrAddByKey(id);
|
ImGuiTable* table = g.Tables.GetOrAddByKey(id);
|
||||||
|
const ImGuiTableFlags table_last_flags = table->Flags;
|
||||||
|
|
||||||
// Acquire temporary buffers
|
// Acquire temporary buffers
|
||||||
const int table_idx = g.Tables.GetIndex(table);
|
const int table_idx = g.Tables.GetIndex(table);
|
||||||
@ -361,7 +353,6 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
|
|||||||
// Initialize
|
// Initialize
|
||||||
const int previous_frame_active = table->LastFrameActive;
|
const int previous_frame_active = table->LastFrameActive;
|
||||||
const int instance_no = (previous_frame_active != g.FrameCount) ? 0 : table->InstanceCurrent + 1;
|
const int instance_no = (previous_frame_active != g.FrameCount) ? 0 : table->InstanceCurrent + 1;
|
||||||
const ImGuiTableFlags previous_flags = table->Flags;
|
|
||||||
table->ID = id;
|
table->ID = id;
|
||||||
table->Flags = flags;
|
table->Flags = flags;
|
||||||
table->LastFrameActive = g.FrameCount;
|
table->LastFrameActive = g.FrameCount;
|
||||||
@ -408,7 +399,7 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
|
|||||||
SetNextWindowContentSize(ImVec2(override_content_size.x != FLT_MAX ? override_content_size.x : 0.0f, override_content_size.y != FLT_MAX ? override_content_size.y : 0.0f));
|
SetNextWindowContentSize(ImVec2(override_content_size.x != FLT_MAX ? override_content_size.x : 0.0f, override_content_size.y != FLT_MAX ? override_content_size.y : 0.0f));
|
||||||
|
|
||||||
// Reset scroll if we are reactivating it
|
// Reset scroll if we are reactivating it
|
||||||
if ((previous_flags & (ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY)) == 0)
|
if ((table_last_flags & (ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY)) == 0)
|
||||||
SetNextWindowScroll(ImVec2(0.0f, 0.0f));
|
SetNextWindowScroll(ImVec2(0.0f, 0.0f));
|
||||||
|
|
||||||
// Create scrolling region (without border and zero window padding)
|
// Create scrolling region (without border and zero window padding)
|
||||||
@ -507,8 +498,7 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
|
|||||||
table->DeclColumnsCount = table->AngledHeadersCount = 0;
|
table->DeclColumnsCount = table->AngledHeadersCount = 0;
|
||||||
if (previous_frame_active + 1 < g.FrameCount)
|
if (previous_frame_active + 1 < g.FrameCount)
|
||||||
table->IsActiveIdInTable = false;
|
table->IsActiveIdInTable = false;
|
||||||
table->AngledHeadersHeight = 0.0f;
|
temp_data->AngledheadersExtraWidth = 0.0f;
|
||||||
temp_data->AngledHeadersExtraWidth = 0.0f;
|
|
||||||
|
|
||||||
// Using opaque colors facilitate overlapping lines of the grid, otherwise we'd need to improve TableDrawBorders()
|
// Using opaque colors facilitate overlapping lines of the grid, otherwise we'd need to improve TableDrawBorders()
|
||||||
table->BorderColorStrong = GetColorU32(ImGuiCol_TableBorderStrong);
|
table->BorderColorStrong = GetColorU32(ImGuiCol_TableBorderStrong);
|
||||||
@ -521,7 +511,7 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
|
|||||||
if (inner_window != outer_window) // So EndChild() within the inner window can restore the table properly.
|
if (inner_window != outer_window) // So EndChild() within the inner window can restore the table properly.
|
||||||
inner_window->DC.CurrentTableIdx = table_idx;
|
inner_window->DC.CurrentTableIdx = table_idx;
|
||||||
|
|
||||||
if ((previous_flags & ImGuiTableFlags_Reorderable) && (flags & ImGuiTableFlags_Reorderable) == 0)
|
if ((table_last_flags & ImGuiTableFlags_Reorderable) && (flags & ImGuiTableFlags_Reorderable) == 0)
|
||||||
table->IsResetDisplayOrderRequest = true;
|
table->IsResetDisplayOrderRequest = true;
|
||||||
|
|
||||||
// Mark as used to avoid GC
|
// Mark as used to avoid GC
|
||||||
@ -1076,7 +1066,6 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
|||||||
// - ClipRect.Max.x: using WorkMaxX instead of MaxX (aka including padding) makes things more consistent when resizing down, tho slightly detrimental to visibility in very-small column.
|
// - ClipRect.Max.x: using WorkMaxX instead of MaxX (aka including padding) makes things more consistent when resizing down, tho slightly detrimental to visibility in very-small column.
|
||||||
// - ClipRect.Max.x: using MaxX makes it easier for header to receive hover highlight with no discontinuity and display sorting arrow.
|
// - ClipRect.Max.x: using MaxX makes it easier for header to receive hover highlight with no discontinuity and display sorting arrow.
|
||||||
// - FIXME-TABLE: We want equal width columns to have equal (ClipRect.Max.x - WorkMinX) width, which means ClipRect.max.x cannot stray off host_clip_rect.Max.x else right-most column may appear shorter.
|
// - FIXME-TABLE: We want equal width columns to have equal (ClipRect.Max.x - WorkMinX) width, which means ClipRect.max.x cannot stray off host_clip_rect.Max.x else right-most column may appear shorter.
|
||||||
const float previous_instance_work_min_x = column->WorkMinX;
|
|
||||||
column->WorkMinX = column->MinX + table->CellPaddingX + table->CellSpacingX1;
|
column->WorkMinX = column->MinX + table->CellPaddingX + table->CellSpacingX1;
|
||||||
column->WorkMaxX = column->MaxX - table->CellPaddingX - table->CellSpacingX2; // Expected max
|
column->WorkMaxX = column->MaxX - table->CellPaddingX - table->CellSpacingX2; // Expected max
|
||||||
column->ItemWidth = ImTrunc(column->WidthGiven * 0.65f);
|
column->ItemWidth = ImTrunc(column->WidthGiven * 0.65f);
|
||||||
@ -1129,22 +1118,8 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
|||||||
// column->WorkMinX = ImLerp(column->WorkMinX, ImMax(column->StartX, column->MaxX - column->ContentWidthRowsUnfrozen), 0.5f);
|
// column->WorkMinX = ImLerp(column->WorkMinX, ImMax(column->StartX, column->MaxX - column->ContentWidthRowsUnfrozen), 0.5f);
|
||||||
|
|
||||||
// Reset content width variables
|
// Reset content width variables
|
||||||
if (table->InstanceCurrent == 0)
|
column->ContentMaxXFrozen = column->ContentMaxXUnfrozen = column->WorkMinX;
|
||||||
{
|
column->ContentMaxXHeadersUsed = column->ContentMaxXHeadersIdeal = column->WorkMinX;
|
||||||
column->ContentMaxXFrozen = column->WorkMinX;
|
|
||||||
column->ContentMaxXUnfrozen = column->WorkMinX;
|
|
||||||
column->ContentMaxXHeadersUsed = column->WorkMinX;
|
|
||||||
column->ContentMaxXHeadersIdeal = column->WorkMinX;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// As we store an absolute value to make per-cell updates faster, we need to offset values used for width computation.
|
|
||||||
const float offset_from_previous_instance = column->WorkMinX - previous_instance_work_min_x;
|
|
||||||
column->ContentMaxXFrozen += offset_from_previous_instance;
|
|
||||||
column->ContentMaxXUnfrozen += offset_from_previous_instance;
|
|
||||||
column->ContentMaxXHeadersUsed += offset_from_previous_instance;
|
|
||||||
column->ContentMaxXHeadersIdeal += offset_from_previous_instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Don't decrement auto-fit counters until container window got a chance to submit its items
|
// Don't decrement auto-fit counters until container window got a chance to submit its items
|
||||||
if (table->HostSkipItems == false)
|
if (table->HostSkipItems == false)
|
||||||
@ -1263,9 +1238,9 @@ void ImGui::TableUpdateBorders(ImGuiTable* table)
|
|||||||
// really problematic (whereas the actual visual will be displayed in EndTable() and using the current frame height).
|
// really problematic (whereas the actual visual will be displayed in EndTable() and using the current frame height).
|
||||||
// Actual columns highlight/render will be performed in EndTable() and not be affected.
|
// Actual columns highlight/render will be performed in EndTable() and not be affected.
|
||||||
ImGuiTableInstanceData* table_instance = TableGetInstanceData(table, table->InstanceCurrent);
|
ImGuiTableInstanceData* table_instance = TableGetInstanceData(table, table->InstanceCurrent);
|
||||||
const float hit_half_width = ImTrunc(TABLE_RESIZE_SEPARATOR_HALF_THICKNESS * g.CurrentDpiScale);
|
const float hit_half_width = TABLE_RESIZE_SEPARATOR_HALF_THICKNESS;
|
||||||
const float hit_y1 = (table->FreezeRowsCount >= 1 ? table->OuterRect.Min.y : table->WorkRect.Min.y) + table->AngledHeadersHeight;
|
const float hit_y1 = (table->FreezeRowsCount >= 1 ? table->OuterRect.Min.y : table->WorkRect.Min.y) + table->AngledHeadersHeight;
|
||||||
const float hit_y2_body = ImMax(table->OuterRect.Max.y, hit_y1 + table_instance->LastOuterHeight - table->AngledHeadersHeight);
|
const float hit_y2_body = ImMax(table->OuterRect.Max.y, hit_y1 + table_instance->LastOuterHeight);
|
||||||
const float hit_y2_head = hit_y1 + table_instance->LastTopHeadersRowHeight;
|
const float hit_y2_head = hit_y1 + table_instance->LastTopHeadersRowHeight;
|
||||||
|
|
||||||
for (int order_n = 0; order_n < table->ColumnsCount; order_n++)
|
for (int order_n = 0; order_n < table->ColumnsCount; order_n++)
|
||||||
@ -1369,7 +1344,7 @@ void ImGui::EndTable()
|
|||||||
max_pos_x = ImMax(max_pos_x, table->Columns[table->RightMostEnabledColumn].WorkMaxX + table->CellPaddingX + table->OuterPaddingX - outer_padding_for_border);
|
max_pos_x = ImMax(max_pos_x, table->Columns[table->RightMostEnabledColumn].WorkMaxX + table->CellPaddingX + table->OuterPaddingX - outer_padding_for_border);
|
||||||
if (table->ResizedColumn != -1)
|
if (table->ResizedColumn != -1)
|
||||||
max_pos_x = ImMax(max_pos_x, table->ResizeLockMinContentsX2);
|
max_pos_x = ImMax(max_pos_x, table->ResizeLockMinContentsX2);
|
||||||
table->InnerWindow->DC.CursorMaxPos.x = max_pos_x + table->TempData->AngledHeadersExtraWidth;
|
table->InnerWindow->DC.CursorMaxPos.x = max_pos_x + table->TempData->AngledheadersExtraWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pop clipping rect
|
// Pop clipping rect
|
||||||
@ -1440,7 +1415,7 @@ void ImGui::EndTable()
|
|||||||
if (table->ResizedColumn != -1 && table->InstanceCurrent == table->InstanceInteracted)
|
if (table->ResizedColumn != -1 && table->InstanceCurrent == table->InstanceInteracted)
|
||||||
{
|
{
|
||||||
ImGuiTableColumn* column = &table->Columns[table->ResizedColumn];
|
ImGuiTableColumn* column = &table->Columns[table->ResizedColumn];
|
||||||
const float new_x2 = (g.IO.MousePos.x - g.ActiveIdClickOffset.x + ImTrunc(TABLE_RESIZE_SEPARATOR_HALF_THICKNESS * g.CurrentDpiScale));
|
const float new_x2 = (g.IO.MousePos.x - g.ActiveIdClickOffset.x + TABLE_RESIZE_SEPARATOR_HALF_THICKNESS);
|
||||||
const float new_width = ImTrunc(new_x2 - column->MinX - table->CellSpacingX1 - table->CellPaddingX * 2.0f);
|
const float new_width = ImTrunc(new_x2 - column->MinX - table->CellSpacingX1 - table->CellPaddingX * 2.0f);
|
||||||
table->ResizedColumnNextWidth = new_width;
|
table->ResizedColumnNextWidth = new_width;
|
||||||
}
|
}
|
||||||
@ -1469,10 +1444,7 @@ void ImGui::EndTable()
|
|||||||
// CursorPosPrevLine and CursorMaxPos manually. That should be a more general layout feature, see same problem e.g. #3414)
|
// CursorPosPrevLine and CursorMaxPos manually. That should be a more general layout feature, see same problem e.g. #3414)
|
||||||
if (inner_window != outer_window)
|
if (inner_window != outer_window)
|
||||||
{
|
{
|
||||||
short backup_nav_layers_active_mask = inner_window->DC.NavLayersActiveMask;
|
|
||||||
inner_window->DC.NavLayersActiveMask |= 1 << ImGuiNavLayer_Main; // So empty table don't appear to navigate differently.
|
|
||||||
EndChild();
|
EndChild();
|
||||||
inner_window->DC.NavLayersActiveMask = backup_nav_layers_active_mask;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1490,7 +1462,7 @@ void ImGui::EndTable()
|
|||||||
}
|
}
|
||||||
else if (temp_data->UserOuterSize.x <= 0.0f)
|
else if (temp_data->UserOuterSize.x <= 0.0f)
|
||||||
{
|
{
|
||||||
const float decoration_size = table->TempData->AngledHeadersExtraWidth + ((table->Flags & ImGuiTableFlags_ScrollX) ? inner_window->ScrollbarSizes.x : 0.0f);
|
const float decoration_size = table->TempData->AngledheadersExtraWidth + ((table->Flags & ImGuiTableFlags_ScrollX) ? inner_window->ScrollbarSizes.x : 0.0f);
|
||||||
outer_window->DC.IdealMaxPos.x = ImMax(outer_window->DC.IdealMaxPos.x, table->OuterRect.Min.x + table->ColumnsAutoFitWidth + decoration_size - temp_data->UserOuterSize.x);
|
outer_window->DC.IdealMaxPos.x = ImMax(outer_window->DC.IdealMaxPos.x, table->OuterRect.Min.x + table->ColumnsAutoFitWidth + decoration_size - temp_data->UserOuterSize.x);
|
||||||
outer_window->DC.CursorMaxPos.x = ImMax(backup_outer_max_pos.x, ImMin(table->OuterRect.Max.x, table->OuterRect.Min.x + table->ColumnsAutoFitWidth));
|
outer_window->DC.CursorMaxPos.x = ImMax(backup_outer_max_pos.x, ImMin(table->OuterRect.Max.x, table->OuterRect.Min.x + table->ColumnsAutoFitWidth));
|
||||||
}
|
}
|
||||||
@ -1595,7 +1567,6 @@ void ImGui::TableSetupColumn(const char* label, ImGuiTableColumnFlags flags, flo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Store name (append with zero-terminator in contiguous buffer)
|
// Store name (append with zero-terminator in contiguous buffer)
|
||||||
// FIXME: If we recorded the number of \n in names we could compute header row height
|
|
||||||
column->NameOffset = -1;
|
column->NameOffset = -1;
|
||||||
if (label != NULL && label[0] != 0)
|
if (label != NULL && label[0] != 0)
|
||||||
{
|
{
|
||||||
@ -1918,7 +1889,7 @@ void ImGui::TableEndRow(ImGuiTable* table)
|
|||||||
if (is_visible)
|
if (is_visible)
|
||||||
{
|
{
|
||||||
// Update data for TableGetHoveredRow()
|
// Update data for TableGetHoveredRow()
|
||||||
if (table->HoveredColumnBody != -1 && g.IO.MousePos.y >= bg_y1 && g.IO.MousePos.y < bg_y2 && table_instance->HoveredRowNext < 0)
|
if (table->HoveredColumnBody != -1 && g.IO.MousePos.y >= bg_y1 && g.IO.MousePos.y < bg_y2)
|
||||||
table_instance->HoveredRowNext = table->CurrentRow;
|
table_instance->HoveredRowNext = table->CurrentRow;
|
||||||
|
|
||||||
// Decide of background color for the row
|
// Decide of background color for the row
|
||||||
@ -1973,7 +1944,6 @@ void ImGui::TableEndRow(ImGuiTable* table)
|
|||||||
cell_bg_rect.ClipWith(table->BgClipRect);
|
cell_bg_rect.ClipWith(table->BgClipRect);
|
||||||
cell_bg_rect.Min.x = ImMax(cell_bg_rect.Min.x, column->ClipRect.Min.x); // So that first column after frozen one gets clipped when scrolling
|
cell_bg_rect.Min.x = ImMax(cell_bg_rect.Min.x, column->ClipRect.Min.x); // So that first column after frozen one gets clipped when scrolling
|
||||||
cell_bg_rect.Max.x = ImMin(cell_bg_rect.Max.x, column->MaxX);
|
cell_bg_rect.Max.x = ImMin(cell_bg_rect.Max.x, column->MaxX);
|
||||||
if (cell_bg_rect.Min.y < cell_bg_rect.Max.y)
|
|
||||||
window->DrawList->AddRectFilled(cell_bg_rect.Min, cell_bg_rect.Max, cell_data->BgColor);
|
window->DrawList->AddRectFilled(cell_bg_rect.Min, cell_bg_rect.Max, cell_data->BgColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2184,8 +2154,6 @@ void ImGui::TableEndCell(ImGuiTable* table)
|
|||||||
// - TableSetColumnWidthAutoAll() [Internal]
|
// - TableSetColumnWidthAutoAll() [Internal]
|
||||||
// - TableUpdateColumnsWeightFromWidth() [Internal]
|
// - TableUpdateColumnsWeightFromWidth() [Internal]
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// Note that actual columns widths are computed in TableUpdateLayout().
|
|
||||||
//-------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Maximum column content width given current layout. Use column->MinX so this value on a per-column basis.
|
// Maximum column content width given current layout. Use column->MinX so this value on a per-column basis.
|
||||||
float ImGui::TableGetMaxColumnWidth(const ImGuiTable* table, int column_n)
|
float ImGui::TableGetMaxColumnWidth(const ImGuiTable* table, int column_n)
|
||||||
@ -2936,7 +2904,6 @@ void ImGui::TableSortSpecsBuild(ImGuiTable* table)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write output
|
// Write output
|
||||||
// May be able to move all SortSpecs data from table (48 bytes) to ImGuiTableTempData if we decide to write it back on every BeginTable()
|
|
||||||
ImGuiTableColumnSortSpecs* sort_specs = (table->SortSpecsCount == 0) ? NULL : (table->SortSpecsCount == 1) ? &table->SortSpecsSingle : table->SortSpecsMulti.Data;
|
ImGuiTableColumnSortSpecs* sort_specs = (table->SortSpecsCount == 0) ? NULL : (table->SortSpecsCount == 1) ? &table->SortSpecsSingle : table->SortSpecsMulti.Data;
|
||||||
if (dirty && sort_specs != NULL)
|
if (dirty && sort_specs != NULL)
|
||||||
for (int column_n = 0; column_n < table->ColumnsCount; column_n++)
|
for (int column_n = 0; column_n < table->ColumnsCount; column_n++)
|
||||||
@ -2960,7 +2927,6 @@ void ImGui::TableSortSpecsBuild(ImGuiTable* table)
|
|||||||
// [SECTION] Tables: Headers
|
// [SECTION] Tables: Headers
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// - TableGetHeaderRowHeight() [Internal]
|
// - TableGetHeaderRowHeight() [Internal]
|
||||||
// - TableGetHeaderAngledMaxLabelWidth() [Internal]
|
|
||||||
// - TableHeadersRow()
|
// - TableHeadersRow()
|
||||||
// - TableHeader()
|
// - TableHeader()
|
||||||
// - TableAngledHeadersRow()
|
// - TableAngledHeadersRow()
|
||||||
@ -2992,12 +2958,12 @@ float ImGui::TableGetHeaderAngledMaxLabelWidth()
|
|||||||
if (IM_BITARRAY_TESTBIT(table->EnabledMaskByIndex, column_n))
|
if (IM_BITARRAY_TESTBIT(table->EnabledMaskByIndex, column_n))
|
||||||
if (table->Columns[column_n].Flags & ImGuiTableColumnFlags_AngledHeader)
|
if (table->Columns[column_n].Flags & ImGuiTableColumnFlags_AngledHeader)
|
||||||
width = ImMax(width, CalcTextSize(TableGetColumnName(table, column_n), NULL, true).x);
|
width = ImMax(width, CalcTextSize(TableGetColumnName(table, column_n), NULL, true).x);
|
||||||
return width + g.Style.CellPadding.y * 2.0f; // Swap padding
|
return width + g.Style.CellPadding.x * 2.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// [Public] This is a helper to output TableHeader() calls based on the column names declared in TableSetupColumn().
|
// [Public] This is a helper to output TableHeader() calls based on the column names declared in TableSetupColumn().
|
||||||
// The intent is that advanced users willing to create customized headers would not need to use this helper
|
// The intent is that advanced users willing to create customized headers would not need to use this helper
|
||||||
// and can create their own! For example: TableHeader() may be preceded by Checkbox() or other custom widgets.
|
// and can create their own! For example: TableHeader() may be preceeded by Checkbox() or other custom widgets.
|
||||||
// See 'Demo->Tables->Custom headers' for a demonstration of implementing a custom version of this.
|
// See 'Demo->Tables->Custom headers' for a demonstration of implementing a custom version of this.
|
||||||
// This code is constructed to not make much use of internal functions, as it is intended to be a template to copy.
|
// This code is constructed to not make much use of internal functions, as it is intended to be a template to copy.
|
||||||
// FIXME-TABLE: TableOpenContextMenu() and TableGetHeaderRowHeight() are not public.
|
// FIXME-TABLE: TableOpenContextMenu() and TableGetHeaderRowHeight() are not public.
|
||||||
@ -3116,7 +3082,7 @@ void ImGui::TableHeader(const char* label)
|
|||||||
if ((table->RowFlags & ImGuiTableRowFlags_Headers) == 0)
|
if ((table->RowFlags & ImGuiTableRowFlags_Headers) == 0)
|
||||||
TableSetBgColor(ImGuiTableBgTarget_CellBg, GetColorU32(ImGuiCol_TableHeaderBg), table->CurrentColumn);
|
TableSetBgColor(ImGuiTableBgTarget_CellBg, GetColorU32(ImGuiCol_TableHeaderBg), table->CurrentColumn);
|
||||||
}
|
}
|
||||||
RenderNavHighlight(bb, id, ImGuiNavHighlightFlags_Compact | ImGuiNavHighlightFlags_NoRounding);
|
RenderNavHighlight(bb, id, ImGuiNavHighlightFlags_TypeThin | ImGuiNavHighlightFlags_NoRounding);
|
||||||
if (held)
|
if (held)
|
||||||
table->HeldHeaderColumn = (ImGuiTableColumnIdx)column_n;
|
table->HeldHeaderColumn = (ImGuiTableColumnIdx)column_n;
|
||||||
window->DC.CursorPos.y -= g.Style.ItemSpacing.y * 0.5f;
|
window->DC.CursorPos.y -= g.Style.ItemSpacing.y * 0.5f;
|
||||||
@ -3183,43 +3149,15 @@ void ImGui::TableHeader(const char* label)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Unlike TableHeadersRow() it is not expected that you can reimplement or customize this with custom widgets.
|
// Unlike TableHeadersRow() it is not expected that you can reimplement or customize this with custom widgets.
|
||||||
|
// FIXME: highlight without ImGuiTableFlags_HighlightHoveredColumn
|
||||||
// FIXME: No hit-testing/button on the angled header.
|
// FIXME: No hit-testing/button on the angled header.
|
||||||
void ImGui::TableAngledHeadersRow()
|
void ImGui::TableAngledHeadersRow()
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiTable* table = g.CurrentTable;
|
TableAngledHeadersRowEx(g.Style.TableAngledHeadersAngle, 0.0f);
|
||||||
ImGuiTableTempData* temp_data = table->TempData;
|
|
||||||
temp_data->AngledHeadersRequests.resize(0);
|
|
||||||
temp_data->AngledHeadersRequests.reserve(table->ColumnsEnabledCount);
|
|
||||||
|
|
||||||
// Which column needs highlight?
|
|
||||||
const ImGuiID row_id = GetID("##AngledHeaders");
|
|
||||||
ImGuiTableInstanceData* table_instance = TableGetInstanceData(table, table->InstanceCurrent);
|
|
||||||
int highlight_column_n = table->HighlightColumnHeader;
|
|
||||||
if (highlight_column_n == -1 && table->HoveredColumnBody != -1)
|
|
||||||
if (table_instance->HoveredRowLast == 0 && table->HoveredColumnBorder == -1 && (g.ActiveId == 0 || g.ActiveId == row_id || (table->IsActiveIdInTable || g.DragDropActive)))
|
|
||||||
highlight_column_n = table->HoveredColumnBody;
|
|
||||||
|
|
||||||
// Build up request
|
|
||||||
ImU32 col_header_bg = GetColorU32(ImGuiCol_TableHeaderBg);
|
|
||||||
ImU32 col_text = GetColorU32(ImGuiCol_Text);
|
|
||||||
for (int order_n = 0; order_n < table->ColumnsCount; order_n++)
|
|
||||||
if (IM_BITARRAY_TESTBIT(table->EnabledMaskByDisplayOrder, order_n))
|
|
||||||
{
|
|
||||||
const int column_n = table->DisplayOrderToIndex[order_n];
|
|
||||||
ImGuiTableColumn* column = &table->Columns[column_n];
|
|
||||||
if ((column->Flags & ImGuiTableColumnFlags_AngledHeader) == 0) // Note: can't rely on ImGuiTableColumnFlags_IsVisible test here.
|
|
||||||
continue;
|
|
||||||
ImGuiTableHeaderData request = { (ImGuiTableColumnIdx)column_n, col_text, col_header_bg, (column_n == highlight_column_n) ? GetColorU32(ImGuiCol_Header) : 0 };
|
|
||||||
temp_data->AngledHeadersRequests.push_back(request);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render row
|
void ImGui::TableAngledHeadersRowEx(float angle, float max_label_width)
|
||||||
TableAngledHeadersRowEx(row_id, g.Style.TableAngledHeadersAngle, 0.0f, temp_data->AngledHeadersRequests.Data, temp_data->AngledHeadersRequests.Size);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Important: data must be fed left to right
|
|
||||||
void ImGui::TableAngledHeadersRowEx(ImGuiID row_id, float angle, float max_label_width, const ImGuiTableHeaderData* data, int data_count)
|
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiTable* table = g.CurrentTable;
|
ImGuiTable* table = g.CurrentTable;
|
||||||
@ -3242,41 +3180,45 @@ void ImGui::TableAngledHeadersRowEx(ImGuiID row_id, float angle, float max_label
|
|||||||
|
|
||||||
// Calculate our base metrics and set angled headers data _before_ the first call to TableNextRow()
|
// Calculate our base metrics and set angled headers data _before_ the first call to TableNextRow()
|
||||||
// FIXME-STYLE: Would it be better for user to submit 'max_label_width' or 'row_height' ? One can be derived from the other.
|
// FIXME-STYLE: Would it be better for user to submit 'max_label_width' or 'row_height' ? One can be derived from the other.
|
||||||
const float header_height = g.FontSize + g.Style.CellPadding.x * 2.0f;
|
const float header_height = table->RowCellPaddingY * 2.0f + g.FontSize;
|
||||||
const float row_height = ImTrunc(ImFabs(ImRotate(ImVec2(max_label_width, flip_label ? +header_height : -header_height), cos_a, sin_a).y));
|
const float row_height = ImFabs(ImRotate(ImVec2(max_label_width, flip_label ? +header_height : -header_height), cos_a, sin_a).y);
|
||||||
|
const ImVec2 header_angled_vector = unit_right * (row_height / -sin_a);
|
||||||
table->AngledHeadersHeight = row_height;
|
table->AngledHeadersHeight = row_height;
|
||||||
table->AngledHeadersSlope = (sin_a != 0.0f) ? (cos_a / sin_a) : 0.0f;
|
table->AngledHeadersSlope = (sin_a != 0.0f) ? (cos_a / sin_a) : 0.0f;
|
||||||
const ImVec2 header_angled_vector = unit_right * (row_height / -sin_a); // vector from bottom-left to top-left, and from bottom-right to top-right
|
|
||||||
|
|
||||||
// Declare row, override and draw our own background
|
// Declare row, override and draw our own background
|
||||||
TableNextRow(ImGuiTableRowFlags_Headers, row_height);
|
TableNextRow(ImGuiTableRowFlags_Headers, row_height);
|
||||||
TableNextColumn();
|
TableNextColumn();
|
||||||
const ImRect row_r(table->WorkRect.Min.x, table->BgClipRect.Min.y, table->WorkRect.Max.x, table->RowPosY2);
|
|
||||||
table->DrawSplitter->SetCurrentChannel(draw_list, TABLE_DRAW_CHANNEL_BG0);
|
table->DrawSplitter->SetCurrentChannel(draw_list, TABLE_DRAW_CHANNEL_BG0);
|
||||||
float clip_rect_min_x = table->BgClipRect.Min.x;
|
float clip_rect_min_x = table->BgClipRect.Min.x;
|
||||||
if (table->FreezeColumnsCount > 0)
|
if (table->FreezeColumnsCount > 0)
|
||||||
clip_rect_min_x = ImMax(clip_rect_min_x, table->Columns[table->FreezeColumnsCount - 1].MaxX);
|
clip_rect_min_x = ImMax(clip_rect_min_x, table->Columns[table->FreezeColumnsCount - 1].MaxX);
|
||||||
TableSetBgColor(ImGuiTableBgTarget_RowBg0, 0); // Cancel
|
TableSetBgColor(ImGuiTableBgTarget_RowBg0, 0); // Cancel
|
||||||
PushClipRect(table->BgClipRect.Min, table->BgClipRect.Max, false); // Span all columns
|
PushClipRect(table->BgClipRect.Min, table->BgClipRect.Max, false); // Span all columns
|
||||||
draw_list->AddRectFilled(ImVec2(table->BgClipRect.Min.x, row_r.Min.y), ImVec2(table->BgClipRect.Max.x, row_r.Max.y), GetColorU32(ImGuiCol_TableHeaderBg, 0.25f)); // FIXME-STYLE: Change row background with an arbitrary color.
|
draw_list->AddRectFilled(table->BgClipRect.Min, table->BgClipRect.Max, GetColorU32(ImGuiCol_TableHeaderBg, 0.25f)); // FIXME-STYLE: Change row background with an arbitrary color.
|
||||||
PushClipRect(ImVec2(clip_rect_min_x, table->BgClipRect.Min.y), table->BgClipRect.Max, true); // Span all columns
|
PushClipRect(ImVec2(clip_rect_min_x, table->BgClipRect.Min.y), table->BgClipRect.Max, true); // Span all columns
|
||||||
|
|
||||||
|
const ImRect row_r(table->WorkRect.Min.x, table->BgClipRect.Min.y, table->WorkRect.Max.x, window->DC.CursorPos.y + row_height);
|
||||||
|
const ImGuiID row_id = GetID("##AngledHeaders");
|
||||||
ButtonBehavior(row_r, row_id, NULL, NULL);
|
ButtonBehavior(row_r, row_id, NULL, NULL);
|
||||||
KeepAliveID(row_id);
|
KeepAliveID(row_id);
|
||||||
|
|
||||||
const float ascent_scaled = g.Font->Ascent * (g.FontSize / g.Font->FontSize); // FIXME: Standardize those scaling factors better
|
ImGuiTableInstanceData* table_instance = TableGetInstanceData(table, table->InstanceCurrent);
|
||||||
const float line_off_for_ascent_x = (ImMax((g.FontSize - ascent_scaled) * 0.5f, 0.0f) / -sin_a) * (flip_label ? -1.0f : 1.0f);
|
int highlight_column_n = table->HighlightColumnHeader;
|
||||||
const ImVec2 padding = g.Style.CellPadding; // We will always use swapped component
|
if (highlight_column_n == -1 && table->HoveredColumnBody != -1)
|
||||||
const ImVec2 align = g.Style.TableAngledHeadersTextAlign;
|
if (table_instance->HoveredRowLast == 0 && table->HoveredColumnBorder == -1 && (g.ActiveId == 0 || g.ActiveId == row_id || (table->IsActiveIdInTable || g.DragDropActive)))
|
||||||
|
highlight_column_n = table->HoveredColumnBody;
|
||||||
|
|
||||||
// Draw background and labels in first pass, then all borders.
|
|
||||||
float max_x = 0.0f;
|
float max_x = 0.0f;
|
||||||
for (int pass = 0; pass < 2; pass++)
|
for (int pass = 0; pass < 2; pass++)
|
||||||
for (int order_n = 0; order_n < data_count; order_n++)
|
for (int order_n = 0; order_n < table->ColumnsCount; order_n++)
|
||||||
{
|
{
|
||||||
const ImGuiTableHeaderData* request = &data[order_n];
|
if (!IM_BITARRAY_TESTBIT(table->EnabledMaskByDisplayOrder, order_n))
|
||||||
const int column_n = request->Index;
|
continue;
|
||||||
|
const int column_n = table->DisplayOrderToIndex[order_n];
|
||||||
ImGuiTableColumn* column = &table->Columns[column_n];
|
ImGuiTableColumn* column = &table->Columns[column_n];
|
||||||
|
if ((column->Flags & ImGuiTableColumnFlags_AngledHeader) == 0) // Note: can't rely on ImGuiTableColumnFlags_IsVisible test here.
|
||||||
|
continue;
|
||||||
|
|
||||||
ImVec2 bg_shape[4];
|
ImVec2 bg_shape[4];
|
||||||
bg_shape[0] = ImVec2(column->MaxX, row_r.Max.y);
|
bg_shape[0] = ImVec2(column->MaxX, row_r.Max.y);
|
||||||
@ -3286,60 +3228,28 @@ void ImGui::TableAngledHeadersRowEx(ImGuiID row_id, float angle, float max_label
|
|||||||
if (pass == 0)
|
if (pass == 0)
|
||||||
{
|
{
|
||||||
// Draw shape
|
// Draw shape
|
||||||
draw_list->AddQuadFilled(bg_shape[0], bg_shape[1], bg_shape[2], bg_shape[3], request->BgColor0);
|
draw_list->AddQuadFilled(bg_shape[0], bg_shape[1], bg_shape[2], bg_shape[3], GetColorU32(ImGuiCol_TableHeaderBg));
|
||||||
draw_list->AddQuadFilled(bg_shape[0], bg_shape[1], bg_shape[2], bg_shape[3], request->BgColor1); // Optional highlight
|
if (column_n == highlight_column_n)
|
||||||
|
draw_list->AddQuadFilled(bg_shape[0], bg_shape[1], bg_shape[2], bg_shape[3], GetColorU32(ImGuiCol_Header)); // Highlight on hover
|
||||||
|
//draw_list->AddQuad(bg_shape[0], bg_shape[1], bg_shape[2], bg_shape[3], GetColorU32(ImGuiCol_TableBorderLight), 1.0f);
|
||||||
max_x = ImMax(max_x, bg_shape[3].x);
|
max_x = ImMax(max_x, bg_shape[3].x);
|
||||||
|
|
||||||
// Draw label
|
// Draw label (first draw at an offset where RenderTextXXX() function won't meddle with applying current ClipRect, then transform to final offset)
|
||||||
// - First draw at an offset where RenderTextXXX() function won't meddle with applying current ClipRect, then transform to final offset.
|
// FIXME: May be worth tidying up all those operations to make them easier to understand.
|
||||||
// - Handle multiple lines manually, as we want each lines to follow on the horizontal border, rather than see a whole block rotated.
|
|
||||||
const char* label_name = TableGetColumnName(table, column_n);
|
const char* label_name = TableGetColumnName(table, column_n);
|
||||||
const char* label_name_end = FindRenderedTextEnd(label_name);
|
const float clip_width = max_label_width - (sin_a * table->RowCellPaddingY);
|
||||||
const float line_off_step_x = (g.FontSize / -sin_a);
|
ImRect label_r(window->ClipRect.Min, window->ClipRect.Min + ImVec2(clip_width + (flip_label ? 0.0f : table->CellPaddingX), header_height + table->RowCellPaddingY));
|
||||||
const int label_lines = ImTextCountLines(label_name, label_name_end);
|
ImVec2 label_size = CalcTextSize(label_name, NULL, true);
|
||||||
|
ImVec2 label_off = ImVec2(flip_label ? ImMax(0.0f, max_label_width - label_size.x - table->CellPaddingX) : table->CellPaddingX, table->RowCellPaddingY);
|
||||||
// Left<>Right alignment
|
|
||||||
float line_off_curr_x = flip_label ? (label_lines - 1) * line_off_step_x : 0.0f;
|
|
||||||
float line_off_for_align_x = ImMax((((column->MaxX - column->MinX) - padding.x * 2.0f) - (label_lines * line_off_step_x)), 0.0f) * align.x;
|
|
||||||
line_off_curr_x += line_off_for_align_x - line_off_for_ascent_x;
|
|
||||||
|
|
||||||
// Register header width
|
|
||||||
column->ContentMaxXHeadersUsed = column->ContentMaxXHeadersIdeal = column->WorkMinX + ImCeil(label_lines * line_off_step_x - line_off_for_align_x);
|
|
||||||
|
|
||||||
while (label_name < label_name_end)
|
|
||||||
{
|
|
||||||
const char* label_name_eol = strchr(label_name, '\n');
|
|
||||||
if (label_name_eol == NULL)
|
|
||||||
label_name_eol = label_name_end;
|
|
||||||
|
|
||||||
// FIXME: Individual line clipping for right-most column is broken for negative angles.
|
|
||||||
ImVec2 label_size = CalcTextSize(label_name, label_name_eol);
|
|
||||||
float clip_width = max_label_width - padding.y; // Using padding.y*2.0f would be symmetrical but hide more text.
|
|
||||||
float clip_height = ImMin(label_size.y, column->ClipRect.Max.x - column->WorkMinX - line_off_curr_x);
|
|
||||||
ImRect clip_r(window->ClipRect.Min, window->ClipRect.Min + ImVec2(clip_width, clip_height));
|
|
||||||
int vtx_idx_begin = draw_list->_VtxCurrentIdx;
|
int vtx_idx_begin = draw_list->_VtxCurrentIdx;
|
||||||
PushStyleColor(ImGuiCol_Text, request->TextColor);
|
RenderTextEllipsis(draw_list, label_r.Min + label_off, label_r.Max, label_r.Max.x, label_r.Max.x, label_name, NULL, &label_size);
|
||||||
RenderTextEllipsis(draw_list, clip_r.Min, clip_r.Max, clip_r.Max.x, clip_r.Max.x, label_name, label_name_eol, &label_size);
|
//if (g.IO.KeyShift) { draw_list->AddRect(label_r.Min, label_r.Max, IM_COL32(0, 255, 0, 255), 0.0f, 0, 2.0f); }
|
||||||
PopStyleColor();
|
|
||||||
int vtx_idx_end = draw_list->_VtxCurrentIdx;
|
int vtx_idx_end = draw_list->_VtxCurrentIdx;
|
||||||
|
|
||||||
// Up<>Down alignment
|
|
||||||
const float available_space = ImMax(clip_width - label_size.x + ImAbs(padding.x * cos_a) * 2.0f - ImAbs(padding.y * sin_a) * 2.0f, 0.0f);
|
|
||||||
const float vertical_offset = available_space * align.y * (flip_label ? -1.0f : 1.0f);
|
|
||||||
|
|
||||||
// Rotate and offset label
|
// Rotate and offset label
|
||||||
ImVec2 pivot_in = ImVec2(window->ClipRect.Min.x - vertical_offset, window->ClipRect.Min.y + label_size.y);
|
ImVec2 pivot_in = label_r.GetBL();
|
||||||
ImVec2 pivot_out = ImVec2(column->WorkMinX, row_r.Max.y);
|
ImVec2 pivot_out = ImVec2(column->WorkMinX, row_r.Max.y) + (flip_label ? (unit_right * clip_width) : ImVec2(header_height, 0.0f));
|
||||||
line_off_curr_x += flip_label ? -line_off_step_x : line_off_step_x;
|
|
||||||
pivot_out += unit_right * padding.y;
|
|
||||||
if (flip_label)
|
|
||||||
pivot_out += unit_right * (clip_width - ImMax(0.0f, clip_width - label_size.x));
|
|
||||||
pivot_out.x += flip_label ? line_off_curr_x + line_off_step_x : line_off_curr_x;
|
|
||||||
ShadeVertsTransformPos(draw_list, vtx_idx_begin, vtx_idx_end, pivot_in, label_cos_a, label_sin_a, pivot_out); // Rotate and offset
|
ShadeVertsTransformPos(draw_list, vtx_idx_begin, vtx_idx_end, pivot_in, label_cos_a, label_sin_a, pivot_out); // Rotate and offset
|
||||||
//if (g.IO.KeyShift) { ImDrawList* fg_dl = GetForegroundDrawList(); vtx_idx_begin = fg_dl->_VtxCurrentIdx; fg_dl->AddRect(clip_r.Min, clip_r.Max, IM_COL32(0, 255, 0, 255), 0.0f, 0, 1.0f); ShadeVertsTransformPos(fg_dl, vtx_idx_begin, fg_dl->_VtxCurrentIdx, pivot_in, label_cos_a, label_sin_a, pivot_out); }
|
|
||||||
|
|
||||||
label_name = label_name_eol + 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (pass == 1)
|
if (pass == 1)
|
||||||
{
|
{
|
||||||
@ -3349,7 +3259,7 @@ void ImGui::TableAngledHeadersRowEx(ImGuiID row_id, float angle, float max_label
|
|||||||
}
|
}
|
||||||
PopClipRect();
|
PopClipRect();
|
||||||
PopClipRect();
|
PopClipRect();
|
||||||
table->TempData->AngledHeadersExtraWidth = ImMax(0.0f, max_x - table->Columns[table->RightMostEnabledColumn].MaxX);
|
table->TempData->AngledheadersExtraWidth = ImMax(0.0f, max_x - table->Columns[table->RightMostEnabledColumn].MaxX);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
@ -4052,7 +3962,7 @@ float ImGui::GetColumnNormFromOffset(const ImGuiOldColumns* columns, float offse
|
|||||||
return offset / (columns->OffMaxX - columns->OffMinX);
|
return offset / (columns->OffMaxX - columns->OffMinX);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const float COLUMNS_HIT_RECT_HALF_THICKNESS = 4.0f;
|
static const float COLUMNS_HIT_RECT_HALF_WIDTH = 4.0f;
|
||||||
|
|
||||||
static float GetDraggedColumnOffset(ImGuiOldColumns* columns, int column_index)
|
static float GetDraggedColumnOffset(ImGuiOldColumns* columns, int column_index)
|
||||||
{
|
{
|
||||||
@ -4063,7 +3973,7 @@ static float GetDraggedColumnOffset(ImGuiOldColumns* columns, int column_index)
|
|||||||
IM_ASSERT(column_index > 0); // We are not supposed to drag column 0.
|
IM_ASSERT(column_index > 0); // We are not supposed to drag column 0.
|
||||||
IM_ASSERT(g.ActiveId == columns->ID + ImGuiID(column_index));
|
IM_ASSERT(g.ActiveId == columns->ID + ImGuiID(column_index));
|
||||||
|
|
||||||
float x = g.IO.MousePos.x - g.ActiveIdClickOffset.x + ImTrunc(COLUMNS_HIT_RECT_HALF_THICKNESS * g.CurrentDpiScale) - window->Pos.x;
|
float x = g.IO.MousePos.x - g.ActiveIdClickOffset.x + COLUMNS_HIT_RECT_HALF_WIDTH - window->Pos.x;
|
||||||
x = ImMax(x, ImGui::GetColumnOffset(column_index - 1) + g.Style.ColumnsMinSpacing);
|
x = ImMax(x, ImGui::GetColumnOffset(column_index - 1) + g.Style.ColumnsMinSpacing);
|
||||||
if ((columns->Flags & ImGuiOldColumnFlags_NoPreserveWidths))
|
if ((columns->Flags & ImGuiOldColumnFlags_NoPreserveWidths))
|
||||||
x = ImMin(x, ImGui::GetColumnOffset(column_index + 1) - g.Style.ColumnsMinSpacing);
|
x = ImMin(x, ImGui::GetColumnOffset(column_index + 1) - g.Style.ColumnsMinSpacing);
|
||||||
@ -4378,7 +4288,7 @@ void ImGui::EndColumns()
|
|||||||
ImGuiOldColumnData* column = &columns->Columns[n];
|
ImGuiOldColumnData* column = &columns->Columns[n];
|
||||||
float x = window->Pos.x + GetColumnOffset(n);
|
float x = window->Pos.x + GetColumnOffset(n);
|
||||||
const ImGuiID column_id = columns->ID + ImGuiID(n);
|
const ImGuiID column_id = columns->ID + ImGuiID(n);
|
||||||
const float column_hit_hw = ImTrunc(COLUMNS_HIT_RECT_HALF_THICKNESS * g.CurrentDpiScale);
|
const float column_hit_hw = COLUMNS_HIT_RECT_HALF_WIDTH;
|
||||||
const ImRect column_hit_rect(ImVec2(x - column_hit_hw, y1), ImVec2(x + column_hit_hw, y2));
|
const ImRect column_hit_rect(ImVec2(x - column_hit_hw, y1), ImVec2(x + column_hit_hw, y2));
|
||||||
if (!ItemAdd(column_hit_rect, column_id, NULL, ImGuiItemFlags_NoNav))
|
if (!ItemAdd(column_hit_rect, column_id, NULL, ImGuiItemFlags_NoNav))
|
||||||
continue;
|
continue;
|
||||||
|
201
external/imgui/imgui/imgui_widgets.cpp
vendored
201
external/imgui/imgui/imgui_widgets.cpp
vendored
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.90.7
|
// dear imgui, v1.90.1
|
||||||
// (widgets code)
|
// (widgets code)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -75,7 +75,6 @@ Index of this file:
|
|||||||
#pragma clang diagnostic ignored "-Wenum-enum-conversion" // warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_')
|
#pragma clang diagnostic ignored "-Wenum-enum-conversion" // warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_')
|
||||||
#pragma clang diagnostic ignored "-Wdeprecated-enum-enum-conversion"// warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_') is deprecated
|
#pragma clang diagnostic ignored "-Wdeprecated-enum-enum-conversion"// warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_') is deprecated
|
||||||
#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision
|
#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision
|
||||||
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" // warning: 'xxx' is an unsafe pointer used for buffer access
|
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
||||||
#pragma GCC diagnostic ignored "-Wformat-nonliteral" // warning: format not a string literal, format string not checked
|
#pragma GCC diagnostic ignored "-Wformat-nonliteral" // warning: format not a string literal, format string not checked
|
||||||
@ -123,7 +122,7 @@ static const ImU64 IM_U64_MAX = (2ULL * 9223372036854775807LL + 1);
|
|||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
// For InputTextEx()
|
// For InputTextEx()
|
||||||
static bool InputTextFilterCharacter(ImGuiContext* ctx, unsigned int* p_char, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data, bool input_source_is_clipboard = false);
|
static bool InputTextFilterCharacter(ImGuiContext* ctx, unsigned int* p_char, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data, ImGuiInputSource input_source);
|
||||||
static int InputTextCalcTextLenAndLineCount(const char* text_begin, const char** out_text_end);
|
static int InputTextCalcTextLenAndLineCount(const char* text_begin, const char** out_text_end);
|
||||||
static ImVec2 InputTextCalcTextSizeW(ImGuiContext* ctx, const ImWchar* text_begin, const ImWchar* text_end, const ImWchar** remaining = NULL, ImVec2* out_offset = NULL, bool stop_on_new_line = false);
|
static ImVec2 InputTextCalcTextSizeW(ImGuiContext* ctx, const ImWchar* text_begin, const ImWchar* text_end, const ImWchar** remaining = NULL, ImVec2* out_offset = NULL, bool stop_on_new_line = false);
|
||||||
|
|
||||||
@ -478,9 +477,6 @@ void ImGui::BulletTextV(const char* fmt, va_list args)
|
|||||||
// Frame N + RepeatDelay + RepeatRate*N true true - true
|
// Frame N + RepeatDelay + RepeatRate*N true true - true
|
||||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// FIXME: For refactor we could output flags, incl mouse hovered vs nav keyboard vs nav triggered etc.
|
|
||||||
// And better standardize how widgets use 'GetColor32((held && hovered) ? ... : hovered ? ...)' vs 'GetColor32(held ? ... : hovered ? ...);'
|
|
||||||
// For mouse feedback we typically prefer the 'held && hovered' test, but for nav feedback not always. Outputting hovered=true on Activation may be misleading.
|
|
||||||
bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool* out_held, ImGuiButtonFlags flags)
|
bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool* out_held, ImGuiButtonFlags flags)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
@ -509,7 +505,7 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
|||||||
|
|
||||||
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||||
// Alternate registration spot, for when caller didn't use ItemAdd()
|
// Alternate registration spot, for when caller didn't use ItemAdd()
|
||||||
if (g.LastItemData.ID != id)
|
if (id != 0 && g.LastItemData.ID != id)
|
||||||
IMGUI_TEST_ENGINE_ITEM_ADD(id, bb, NULL);
|
IMGUI_TEST_ENGINE_ITEM_ADD(id, bb, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -537,8 +533,6 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
|||||||
const ImGuiID test_owner_id = (flags & ImGuiButtonFlags_NoTestKeyOwner) ? ImGuiKeyOwner_Any : id;
|
const ImGuiID test_owner_id = (flags & ImGuiButtonFlags_NoTestKeyOwner) ? ImGuiKeyOwner_Any : id;
|
||||||
if (hovered)
|
if (hovered)
|
||||||
{
|
{
|
||||||
IM_ASSERT(id != 0); // Lazily check inside rare path.
|
|
||||||
|
|
||||||
// Poll mouse buttons
|
// Poll mouse buttons
|
||||||
// - 'mouse_button_clicked' is generally carried into ActiveIdMouseButton when setting ActiveId.
|
// - 'mouse_button_clicked' is generally carried into ActiveIdMouseButton when setting ActiveId.
|
||||||
// - Technically we only need some values in one code path, but since this is gated by hovered test this is fine.
|
// - Technically we only need some values in one code path, but since this is gated by hovered test this is fine.
|
||||||
@ -547,7 +541,7 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
|||||||
for (int button = 0; button < 3; button++)
|
for (int button = 0; button < 3; button++)
|
||||||
if (flags & (ImGuiButtonFlags_MouseButtonLeft << button)) // Handle ImGuiButtonFlags_MouseButtonRight and ImGuiButtonFlags_MouseButtonMiddle here.
|
if (flags & (ImGuiButtonFlags_MouseButtonLeft << button)) // Handle ImGuiButtonFlags_MouseButtonRight and ImGuiButtonFlags_MouseButtonMiddle here.
|
||||||
{
|
{
|
||||||
if (IsMouseClicked(button, ImGuiInputFlags_None, test_owner_id) && mouse_button_clicked == -1) { mouse_button_clicked = button; }
|
if (IsMouseClicked(button, test_owner_id) && mouse_button_clicked == -1) { mouse_button_clicked = button; }
|
||||||
if (IsMouseReleased(button, test_owner_id) && mouse_button_released == -1) { mouse_button_released = button; }
|
if (IsMouseReleased(button, test_owner_id) && mouse_button_released == -1) { mouse_button_released = button; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -595,7 +589,7 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
|||||||
// 'Repeat' mode acts when held regardless of _PressedOn flags (see table above).
|
// 'Repeat' mode acts when held regardless of _PressedOn flags (see table above).
|
||||||
// Relies on repeat logic of IsMouseClicked() but we may as well do it ourselves if we end up exposing finer RepeatDelay/RepeatRate settings.
|
// Relies on repeat logic of IsMouseClicked() but we may as well do it ourselves if we end up exposing finer RepeatDelay/RepeatRate settings.
|
||||||
if (g.ActiveId == id && (item_flags & ImGuiItemFlags_ButtonRepeat))
|
if (g.ActiveId == id && (item_flags & ImGuiItemFlags_ButtonRepeat))
|
||||||
if (g.IO.MouseDownDuration[g.ActiveIdMouseButton] > 0.0f && IsMouseClicked(g.ActiveIdMouseButton, ImGuiInputFlags_Repeat, test_owner_id))
|
if (g.IO.MouseDownDuration[g.ActiveIdMouseButton] > 0.0f && IsMouseClicked(g.ActiveIdMouseButton, test_owner_id, ImGuiInputFlags_Repeat))
|
||||||
pressed = true;
|
pressed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -603,9 +597,9 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
|||||||
g.NavDisableHighlight = true;
|
g.NavDisableHighlight = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gamepad/Keyboard handling
|
// Gamepad/Keyboard navigation
|
||||||
// We report navigated and navigation-activated items as hovered but we don't set g.HoveredId to not interfere with mouse.
|
// We report navigated item as hovered but we don't set g.HoveredId to not interfere with mouse.
|
||||||
if (g.NavId == id && !g.NavDisableHighlight && g.NavDisableMouseHover)
|
if (g.NavId == id && !g.NavDisableHighlight && g.NavDisableMouseHover && (g.ActiveId == 0 || g.ActiveId == id || g.ActiveId == window->MoveId))
|
||||||
if (!(flags & ImGuiButtonFlags_NoHoveredOnFocus))
|
if (!(flags & ImGuiButtonFlags_NoHoveredOnFocus))
|
||||||
hovered = true;
|
hovered = true;
|
||||||
if (g.NavActivateDownId == id)
|
if (g.NavActivateDownId == id)
|
||||||
@ -627,10 +621,8 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
|||||||
pressed = true;
|
pressed = true;
|
||||||
SetActiveID(id, window);
|
SetActiveID(id, window);
|
||||||
g.ActiveIdSource = g.NavInputSource;
|
g.ActiveIdSource = g.NavInputSource;
|
||||||
if (!(flags & ImGuiButtonFlags_NoNavFocus) && !(g.NavActivateFlags & ImGuiActivateFlags_FromShortcut))
|
if (!(flags & ImGuiButtonFlags_NoNavFocus))
|
||||||
SetFocusID(id, window);
|
SetFocusID(id, window);
|
||||||
if (g.NavActivateFlags & ImGuiActivateFlags_FromShortcut)
|
|
||||||
g.ActiveIdFromShortcut = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -674,19 +666,13 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
|||||||
else if (g.ActiveIdSource == ImGuiInputSource_Keyboard || g.ActiveIdSource == ImGuiInputSource_Gamepad)
|
else if (g.ActiveIdSource == ImGuiInputSource_Keyboard || g.ActiveIdSource == ImGuiInputSource_Gamepad)
|
||||||
{
|
{
|
||||||
// When activated using Nav, we hold on the ActiveID until activation button is released
|
// When activated using Nav, we hold on the ActiveID until activation button is released
|
||||||
if (g.NavActivateDownId == id)
|
if (g.NavActivateDownId != id)
|
||||||
held = true; // hovered == true not true as we are already likely hovered on direct activation.
|
|
||||||
else
|
|
||||||
ClearActiveID();
|
ClearActiveID();
|
||||||
}
|
}
|
||||||
if (pressed)
|
if (pressed)
|
||||||
g.ActiveIdHasBeenPressedBefore = true;
|
g.ActiveIdHasBeenPressedBefore = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Activation highlight (this may be a remote activation)
|
|
||||||
if (g.NavHighlightActivatedId == id)
|
|
||||||
hovered = true;
|
|
||||||
|
|
||||||
if (out_hovered) *out_hovered = hovered;
|
if (out_hovered) *out_hovered = hovered;
|
||||||
if (out_held) *out_held = held;
|
if (out_held) *out_held = held;
|
||||||
|
|
||||||
@ -980,6 +966,7 @@ bool ImGui::ScrollbarEx(const ImRect& bb_frame, ImGuiID id, ImGuiAxis axis, ImS6
|
|||||||
|
|
||||||
// Click position in scrollbar normalized space (0.0f->1.0f)
|
// Click position in scrollbar normalized space (0.0f->1.0f)
|
||||||
const float clicked_v_norm = ImSaturate((mouse_pos_v - scrollbar_pos_v) / scrollbar_size_v);
|
const float clicked_v_norm = ImSaturate((mouse_pos_v - scrollbar_pos_v) / scrollbar_size_v);
|
||||||
|
SetHoveredID(id);
|
||||||
|
|
||||||
bool seek_absolute = false;
|
bool seek_absolute = false;
|
||||||
if (g.ActiveIdIsJustActivated)
|
if (g.ActiveIdIsJustActivated)
|
||||||
@ -1001,7 +988,7 @@ bool ImGui::ScrollbarEx(const ImRect& bb_frame, ImGuiID id, ImGuiAxis axis, ImS6
|
|||||||
scroll_ratio = ImSaturate((float)*p_scroll_v / (float)scroll_max);
|
scroll_ratio = ImSaturate((float)*p_scroll_v / (float)scroll_max);
|
||||||
grab_v_norm = scroll_ratio * (scrollbar_size_v - grab_h_pixels) / scrollbar_size_v;
|
grab_v_norm = scroll_ratio * (scrollbar_size_v - grab_h_pixels) / scrollbar_size_v;
|
||||||
|
|
||||||
// Update distance to grab now that we have seek'ed and saturated
|
// Update distance to grab now that we have seeked and saturated
|
||||||
if (seek_absolute)
|
if (seek_absolute)
|
||||||
g.ScrollbarClickDeltaToGrabCenter = clicked_v_norm - grab_v_norm - grab_h_norm * 0.5f;
|
g.ScrollbarClickDeltaToGrabCenter = clicked_v_norm - grab_v_norm - grab_h_norm * 0.5f;
|
||||||
}
|
}
|
||||||
@ -1291,34 +1278,15 @@ void ImGui::ProgressBar(float fraction, const ImVec2& size_arg, const char* over
|
|||||||
if (!ItemAdd(bb, 0))
|
if (!ItemAdd(bb, 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Fraction < 0.0f will display an indeterminate progress bar animation
|
|
||||||
// The value must be animated along with time, so e.g. passing '-1.0f * ImGui::GetTime()' as fraction works.
|
|
||||||
const bool is_indeterminate = (fraction < 0.0f);
|
|
||||||
if (!is_indeterminate)
|
|
||||||
fraction = ImSaturate(fraction);
|
|
||||||
|
|
||||||
// Out of courtesy we accept a NaN fraction without crashing
|
|
||||||
float fill_n0 = 0.0f;
|
|
||||||
float fill_n1 = (fraction == fraction) ? fraction : 0.0f;
|
|
||||||
|
|
||||||
if (is_indeterminate)
|
|
||||||
{
|
|
||||||
const float fill_width_n = 0.2f;
|
|
||||||
fill_n0 = ImFmod(-fraction, 1.0f) * (1.0f + fill_width_n) - fill_width_n;
|
|
||||||
fill_n1 = ImSaturate(fill_n0 + fill_width_n);
|
|
||||||
fill_n0 = ImSaturate(fill_n0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render
|
// Render
|
||||||
|
fraction = ImSaturate(fraction);
|
||||||
RenderFrame(bb.Min, bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding);
|
RenderFrame(bb.Min, bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding);
|
||||||
bb.Expand(ImVec2(-style.FrameBorderSize, -style.FrameBorderSize));
|
bb.Expand(ImVec2(-style.FrameBorderSize, -style.FrameBorderSize));
|
||||||
RenderRectFilledRangeH(window->DrawList, bb, GetColorU32(ImGuiCol_PlotHistogram), fill_n0, fill_n1, style.FrameRounding);
|
const ImVec2 fill_br = ImVec2(ImLerp(bb.Min.x, bb.Max.x, fraction), bb.Max.y);
|
||||||
|
RenderRectFilledRangeH(window->DrawList, bb, GetColorU32(ImGuiCol_PlotHistogram), 0.0f, fraction, style.FrameRounding);
|
||||||
|
|
||||||
// Default displaying the fraction as percentage string, but user can override it
|
// Default displaying the fraction as percentage string, but user can override it
|
||||||
// Don't display text for indeterminate bars by default
|
|
||||||
char overlay_buf[32];
|
char overlay_buf[32];
|
||||||
if (!is_indeterminate || overlay != NULL)
|
|
||||||
{
|
|
||||||
if (!overlay)
|
if (!overlay)
|
||||||
{
|
{
|
||||||
ImFormatString(overlay_buf, IM_ARRAYSIZE(overlay_buf), "%.0f%%", fraction * 100 + 0.01f);
|
ImFormatString(overlay_buf, IM_ARRAYSIZE(overlay_buf), "%.0f%%", fraction * 100 + 0.01f);
|
||||||
@ -1327,11 +1295,7 @@ void ImGui::ProgressBar(float fraction, const ImVec2& size_arg, const char* over
|
|||||||
|
|
||||||
ImVec2 overlay_size = CalcTextSize(overlay, NULL);
|
ImVec2 overlay_size = CalcTextSize(overlay, NULL);
|
||||||
if (overlay_size.x > 0.0f)
|
if (overlay_size.x > 0.0f)
|
||||||
{
|
RenderTextClipped(ImVec2(ImClamp(fill_br.x + style.ItemSpacing.x, bb.Min.x, bb.Max.x - overlay_size.x - style.ItemInnerSpacing.x), bb.Min.y), bb.Max, overlay, NULL, &overlay_size, ImVec2(0.0f, 0.5f), &bb);
|
||||||
float text_x = is_indeterminate ? (bb.Min.x + bb.Max.x - overlay_size.x) * 0.5f : ImLerp(bb.Min.x, bb.Max.x, fill_n1) + style.ItemSpacing.x;
|
|
||||||
RenderTextClipped(ImVec2(ImClamp(text_x, bb.Min.x, bb.Max.x - overlay_size.x - style.ItemInnerSpacing.x), bb.Min.y), bb.Max, overlay, NULL, &overlay_size, ImVec2(0.0f, 0.5f), &bb);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::Bullet()
|
void ImGui::Bullet()
|
||||||
@ -1810,7 +1774,7 @@ bool ImGui::BeginComboPopup(ImGuiID popup_id, const ImRect& bb, ImGuiComboFlags
|
|||||||
|
|
||||||
// This is essentially a specialized version of BeginPopupEx()
|
// This is essentially a specialized version of BeginPopupEx()
|
||||||
char name[16];
|
char name[16];
|
||||||
ImFormatString(name, IM_ARRAYSIZE(name), "##Combo_%02d", g.BeginComboDepth); // Recycle windows based on depth
|
ImFormatString(name, IM_ARRAYSIZE(name), "##Combo_%02d", g.BeginPopupStack.Size); // Recycle windows based on depth
|
||||||
|
|
||||||
// Set position given a custom constraint (peak into expected window size so we can position it)
|
// Set position given a custom constraint (peak into expected window size so we can position it)
|
||||||
// FIXME: This might be easier to express with an hypothetical SetNextWindowPosConstraints() function?
|
// FIXME: This might be easier to express with an hypothetical SetNextWindowPosConstraints() function?
|
||||||
@ -1837,15 +1801,12 @@ bool ImGui::BeginComboPopup(ImGuiID popup_id, const ImRect& bb, ImGuiComboFlags
|
|||||||
IM_ASSERT(0); // This should never happen as we tested for IsPopupOpen() above
|
IM_ASSERT(0); // This should never happen as we tested for IsPopupOpen() above
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
g.BeginComboDepth++;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::EndCombo()
|
void ImGui::EndCombo()
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
|
||||||
EndPopup();
|
EndPopup();
|
||||||
g.BeginComboDepth--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call directly after the BeginCombo/EndCombo block. The preview is designed to only host non-interactive elements
|
// Call directly after the BeginCombo/EndCombo block. The preview is designed to only host non-interactive elements
|
||||||
@ -2021,7 +1982,7 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*old_getter)(void*
|
|||||||
// - DataTypeGetInfo()
|
// - DataTypeGetInfo()
|
||||||
// - DataTypeFormatString()
|
// - DataTypeFormatString()
|
||||||
// - DataTypeApplyOp()
|
// - DataTypeApplyOp()
|
||||||
// - DataTypeApplyFromText()
|
// - DataTypeApplyOpFromText()
|
||||||
// - DataTypeCompare()
|
// - DataTypeCompare()
|
||||||
// - DataTypeClamp()
|
// - DataTypeClamp()
|
||||||
// - GetMinimumStepAtDecimalPrecision
|
// - GetMinimumStepAtDecimalPrecision
|
||||||
@ -2309,7 +2270,7 @@ bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed, const
|
|||||||
const int decimal_precision = is_floating_point ? ImParseFormatPrecision(format, 3) : 0;
|
const int decimal_precision = is_floating_point ? ImParseFormatPrecision(format, 3) : 0;
|
||||||
const bool tweak_slow = IsKeyDown((g.NavInputSource == ImGuiInputSource_Gamepad) ? ImGuiKey_NavGamepadTweakSlow : ImGuiKey_NavKeyboardTweakSlow);
|
const bool tweak_slow = IsKeyDown((g.NavInputSource == ImGuiInputSource_Gamepad) ? ImGuiKey_NavGamepadTweakSlow : ImGuiKey_NavKeyboardTweakSlow);
|
||||||
const bool tweak_fast = IsKeyDown((g.NavInputSource == ImGuiInputSource_Gamepad) ? ImGuiKey_NavGamepadTweakFast : ImGuiKey_NavKeyboardTweakFast);
|
const bool tweak_fast = IsKeyDown((g.NavInputSource == ImGuiInputSource_Gamepad) ? ImGuiKey_NavGamepadTweakFast : ImGuiKey_NavKeyboardTweakFast);
|
||||||
const float tweak_factor = tweak_slow ? 1.0f / 10.0f : tweak_fast ? 10.0f : 1.0f;
|
const float tweak_factor = tweak_slow ? 1.0f / 1.0f : tweak_fast ? 10.0f : 1.0f;
|
||||||
adjust_delta = GetNavTweakPressedAmount(axis) * tweak_factor;
|
adjust_delta = GetNavTweakPressedAmount(axis) * tweak_factor;
|
||||||
v_speed = ImMax(v_speed, GetMinimumStepAtDecimalPrecision(decimal_precision));
|
v_speed = ImMax(v_speed, GetMinimumStepAtDecimalPrecision(decimal_precision));
|
||||||
}
|
}
|
||||||
@ -2468,7 +2429,7 @@ bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* p_data,
|
|||||||
if (!temp_input_is_active)
|
if (!temp_input_is_active)
|
||||||
{
|
{
|
||||||
// Tabbing or CTRL-clicking on Drag turns it into an InputText
|
// Tabbing or CTRL-clicking on Drag turns it into an InputText
|
||||||
const bool clicked = hovered && IsMouseClicked(0, ImGuiInputFlags_None, id);
|
const bool clicked = hovered && IsMouseClicked(0, id);
|
||||||
const bool double_clicked = (hovered && g.IO.MouseClickedCount[0] == 2 && TestKeyOwner(ImGuiKey_MouseLeft, id));
|
const bool double_clicked = (hovered && g.IO.MouseClickedCount[0] == 2 && TestKeyOwner(ImGuiKey_MouseLeft, id));
|
||||||
const bool make_active = (clicked || double_clicked || g.NavActivateId == id);
|
const bool make_active = (clicked || double_clicked || g.NavActivateId == id);
|
||||||
if (make_active && (clicked || double_clicked))
|
if (make_active && (clicked || double_clicked))
|
||||||
@ -3059,7 +3020,7 @@ bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* p_dat
|
|||||||
if (!temp_input_is_active)
|
if (!temp_input_is_active)
|
||||||
{
|
{
|
||||||
// Tabbing or CTRL-clicking on Slider turns it into an input box
|
// Tabbing or CTRL-clicking on Slider turns it into an input box
|
||||||
const bool clicked = hovered && IsMouseClicked(0, ImGuiInputFlags_None, id);
|
const bool clicked = hovered && IsMouseClicked(0, id);
|
||||||
const bool make_active = (clicked || g.NavActivateId == id);
|
const bool make_active = (clicked || g.NavActivateId == id);
|
||||||
if (make_active && clicked)
|
if (make_active && clicked)
|
||||||
SetKeyOwner(ImGuiKey_MouseLeft, id);
|
SetKeyOwner(ImGuiKey_MouseLeft, id);
|
||||||
@ -3221,7 +3182,7 @@ bool ImGui::VSliderScalar(const char* label, const ImVec2& size, ImGuiDataType d
|
|||||||
format = DataTypeGetInfo(data_type)->PrintFmt;
|
format = DataTypeGetInfo(data_type)->PrintFmt;
|
||||||
|
|
||||||
const bool hovered = ItemHoverable(frame_bb, id, g.LastItemData.InFlags);
|
const bool hovered = ItemHoverable(frame_bb, id, g.LastItemData.InFlags);
|
||||||
const bool clicked = hovered && IsMouseClicked(0, ImGuiInputFlags_None, id);
|
const bool clicked = hovered && IsMouseClicked(0, id);
|
||||||
if (clicked || g.NavActivateId == id)
|
if (clicked || g.NavActivateId == id)
|
||||||
{
|
{
|
||||||
if (clicked)
|
if (clicked)
|
||||||
@ -3452,7 +3413,7 @@ bool ImGui::TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImG
|
|||||||
DataTypeFormatString(data_buf, IM_ARRAYSIZE(data_buf), data_type, p_data, format);
|
DataTypeFormatString(data_buf, IM_ARRAYSIZE(data_buf), data_type, p_data, format);
|
||||||
ImStrTrimBlanks(data_buf);
|
ImStrTrimBlanks(data_buf);
|
||||||
|
|
||||||
ImGuiInputTextFlags flags = ImGuiInputTextFlags_AutoSelectAll | (ImGuiInputTextFlags)ImGuiInputTextFlags_NoMarkEdited | (ImGuiInputTextFlags)ImGuiInputTextFlags_LocalizeDecimalPoint;
|
ImGuiInputTextFlags flags = ImGuiInputTextFlags_AutoSelectAll | (ImGuiInputTextFlags)ImGuiInputTextFlags_NoMarkEdited;
|
||||||
|
|
||||||
bool value_changed = false;
|
bool value_changed = false;
|
||||||
if (TempInputText(bb, id, label, data_buf, IM_ARRAYSIZE(data_buf), flags))
|
if (TempInputText(bb, id, label, data_buf, IM_ARRAYSIZE(data_buf), flags))
|
||||||
@ -3497,7 +3458,6 @@ bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* p_data
|
|||||||
DataTypeFormatString(buf, IM_ARRAYSIZE(buf), data_type, p_data, format);
|
DataTypeFormatString(buf, IM_ARRAYSIZE(buf), data_type, p_data, format);
|
||||||
|
|
||||||
flags |= ImGuiInputTextFlags_AutoSelectAll | (ImGuiInputTextFlags)ImGuiInputTextFlags_NoMarkEdited; // We call MarkItemEdited() ourselves by comparing the actual data rather than the string.
|
flags |= ImGuiInputTextFlags_AutoSelectAll | (ImGuiInputTextFlags)ImGuiInputTextFlags_NoMarkEdited; // We call MarkItemEdited() ourselves by comparing the actual data rather than the string.
|
||||||
flags |= (ImGuiInputTextFlags)ImGuiInputTextFlags_LocalizeDecimalPoint;
|
|
||||||
|
|
||||||
bool value_changed = false;
|
bool value_changed = false;
|
||||||
if (p_step == NULL)
|
if (p_step == NULL)
|
||||||
@ -3943,8 +3903,9 @@ void ImGuiInputTextCallbackData::InsertChars(int pos, const char* new_text, cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return false to discard a character.
|
// Return false to discard a character.
|
||||||
static bool InputTextFilterCharacter(ImGuiContext* ctx, unsigned int* p_char, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data, bool input_source_is_clipboard)
|
static bool InputTextFilterCharacter(ImGuiContext* ctx, unsigned int* p_char, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data, ImGuiInputSource input_source)
|
||||||
{
|
{
|
||||||
|
IM_ASSERT(input_source == ImGuiInputSource_Keyboard || input_source == ImGuiInputSource_Clipboard);
|
||||||
unsigned int c = *p_char;
|
unsigned int c = *p_char;
|
||||||
|
|
||||||
// Filter non-printable (NB: isprint is unreliable! see #2467)
|
// Filter non-printable (NB: isprint is unreliable! see #2467)
|
||||||
@ -3959,7 +3920,7 @@ static bool InputTextFilterCharacter(ImGuiContext* ctx, unsigned int* p_char, Im
|
|||||||
apply_named_filters = false; // Override named filters below so newline and tabs can still be inserted.
|
apply_named_filters = false; // Override named filters below so newline and tabs can still be inserted.
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input_source_is_clipboard == false)
|
if (input_source != ImGuiInputSource_Clipboard)
|
||||||
{
|
{
|
||||||
// We ignore Ascii representation of delete (emitted from Backspace on OSX, see #2578, #2817)
|
// We ignore Ascii representation of delete (emitted from Backspace on OSX, see #2578, #2817)
|
||||||
if (c == 127)
|
if (c == 127)
|
||||||
@ -3975,7 +3936,7 @@ static bool InputTextFilterCharacter(ImGuiContext* ctx, unsigned int* p_char, Im
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Generic named filters
|
// Generic named filters
|
||||||
if (apply_named_filters && (flags & (ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase | ImGuiInputTextFlags_CharsNoBlank | ImGuiInputTextFlags_CharsScientific | (ImGuiInputTextFlags)ImGuiInputTextFlags_LocalizeDecimalPoint)))
|
if (apply_named_filters && (flags & (ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase | ImGuiInputTextFlags_CharsNoBlank | ImGuiInputTextFlags_CharsScientific)))
|
||||||
{
|
{
|
||||||
// The libc allows overriding locale, with e.g. 'setlocale(LC_NUMERIC, "de_DE.UTF-8");' which affect the output/input of printf/scanf to use e.g. ',' instead of '.'.
|
// The libc allows overriding locale, with e.g. 'setlocale(LC_NUMERIC, "de_DE.UTF-8");' which affect the output/input of printf/scanf to use e.g. ',' instead of '.'.
|
||||||
// The standard mandate that programs starts in the "C" locale where the decimal point is '.'.
|
// The standard mandate that programs starts in the "C" locale where the decimal point is '.'.
|
||||||
@ -3985,7 +3946,7 @@ static bool InputTextFilterCharacter(ImGuiContext* ctx, unsigned int* p_char, Im
|
|||||||
// Users of non-default decimal point (in particular ',') may be affected by word-selection logic (is_word_boundary_from_right/is_word_boundary_from_left) functions.
|
// Users of non-default decimal point (in particular ',') may be affected by word-selection logic (is_word_boundary_from_right/is_word_boundary_from_left) functions.
|
||||||
ImGuiContext& g = *ctx;
|
ImGuiContext& g = *ctx;
|
||||||
const unsigned c_decimal_point = (unsigned int)g.IO.PlatformLocaleDecimalPoint;
|
const unsigned c_decimal_point = (unsigned int)g.IO.PlatformLocaleDecimalPoint;
|
||||||
if (flags & (ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_CharsScientific | (ImGuiInputTextFlags)ImGuiInputTextFlags_LocalizeDecimalPoint))
|
if (flags & (ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_CharsScientific))
|
||||||
if (c == '.' || c == ',')
|
if (c == '.' || c == ',')
|
||||||
c = c_decimal_point;
|
c = c_decimal_point;
|
||||||
|
|
||||||
@ -4214,32 +4175,27 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
|
|
||||||
float scroll_y = is_multiline ? draw_window->Scroll.y : FLT_MAX;
|
float scroll_y = is_multiline ? draw_window->Scroll.y : FLT_MAX;
|
||||||
|
|
||||||
const bool init_reload_from_user_buf = (state != NULL && state->ReloadUserBuf);
|
|
||||||
const bool init_changed_specs = (state != NULL && state->Stb.single_line != !is_multiline); // state != NULL means its our state.
|
const bool init_changed_specs = (state != NULL && state->Stb.single_line != !is_multiline); // state != NULL means its our state.
|
||||||
const bool init_make_active = (user_clicked || user_scroll_finish || input_requested_by_nav);
|
const bool init_make_active = (user_clicked || user_scroll_finish || input_requested_by_nav);
|
||||||
const bool init_state = (init_make_active || user_scroll_active);
|
const bool init_state = (init_make_active || user_scroll_active);
|
||||||
if ((init_state && g.ActiveId != id) || init_changed_specs || init_reload_from_user_buf)
|
if ((init_state && g.ActiveId != id) || init_changed_specs)
|
||||||
{
|
{
|
||||||
// Access state even if we don't own it yet.
|
// Access state even if we don't own it yet.
|
||||||
state = &g.InputTextState;
|
state = &g.InputTextState;
|
||||||
state->CursorAnimReset();
|
state->CursorAnimReset();
|
||||||
state->ReloadUserBuf = false;
|
|
||||||
|
|
||||||
// Backup state of deactivating item so they'll have a chance to do a write to output buffer on the same frame they report IsItemDeactivatedAfterEdit (#4714)
|
// Backup state of deactivating item so they'll have a chance to do a write to output buffer on the same frame they report IsItemDeactivatedAfterEdit (#4714)
|
||||||
InputTextDeactivateHook(state->ID);
|
InputTextDeactivateHook(state->ID);
|
||||||
|
|
||||||
// From the moment we focused we are normally ignoring the content of 'buf' (unless we are in read-only mode)
|
// Take a copy of the initial buffer value (both in original UTF-8 format and converted to wchar)
|
||||||
|
// From the moment we focused we are ignoring the content of 'buf' (unless we are in read-only mode)
|
||||||
const int buf_len = (int)strlen(buf);
|
const int buf_len = (int)strlen(buf);
|
||||||
if (!init_reload_from_user_buf)
|
|
||||||
{
|
|
||||||
// Take a copy of the initial buffer value.
|
|
||||||
state->InitialTextA.resize(buf_len + 1); // UTF-8. we use +1 to make sure that .Data is always pointing to at least an empty string.
|
state->InitialTextA.resize(buf_len + 1); // UTF-8. we use +1 to make sure that .Data is always pointing to at least an empty string.
|
||||||
memcpy(state->InitialTextA.Data, buf, buf_len + 1);
|
memcpy(state->InitialTextA.Data, buf, buf_len + 1);
|
||||||
}
|
|
||||||
|
|
||||||
// Preserve cursor position and undo/redo stack if we come back to same widget
|
// Preserve cursor position and undo/redo stack if we come back to same widget
|
||||||
// FIXME: Since we reworked this on 2022/06, may want to differentiate recycle_cursor vs recycle_undostate?
|
// FIXME: Since we reworked this on 2022/06, may want to differenciate recycle_cursor vs recycle_undostate?
|
||||||
bool recycle_state = (state->ID == id && !init_changed_specs && !init_reload_from_user_buf);
|
bool recycle_state = (state->ID == id && !init_changed_specs);
|
||||||
if (recycle_state && (state->CurLenA != buf_len || (state->TextAIsValid && strncmp(state->TextA.Data, buf, buf_len) != 0)))
|
if (recycle_state && (state->CurLenA != buf_len || (state->TextAIsValid && strncmp(state->TextA.Data, buf, buf_len) != 0)))
|
||||||
recycle_state = false;
|
recycle_state = false;
|
||||||
|
|
||||||
@ -4264,13 +4220,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
stb_textedit_initialize_state(&state->Stb, !is_multiline);
|
stb_textedit_initialize_state(&state->Stb, !is_multiline);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (init_reload_from_user_buf)
|
if (!is_multiline)
|
||||||
{
|
|
||||||
state->Stb.select_start = state->ReloadSelectionStart;
|
|
||||||
state->Stb.cursor = state->Stb.select_end = state->ReloadSelectionEnd;
|
|
||||||
state->CursorClamp();
|
|
||||||
}
|
|
||||||
else if (!is_multiline)
|
|
||||||
{
|
{
|
||||||
if (flags & ImGuiInputTextFlags_AutoSelectAll)
|
if (flags & ImGuiInputTextFlags_AutoSelectAll)
|
||||||
select_all = true;
|
select_all = true;
|
||||||
@ -4300,8 +4250,6 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
g.ActiveIdUsingNavDirMask |= (1 << ImGuiDir_Left) | (1 << ImGuiDir_Right);
|
g.ActiveIdUsingNavDirMask |= (1 << ImGuiDir_Left) | (1 << ImGuiDir_Right);
|
||||||
if (is_multiline || (flags & ImGuiInputTextFlags_CallbackHistory))
|
if (is_multiline || (flags & ImGuiInputTextFlags_CallbackHistory))
|
||||||
g.ActiveIdUsingNavDirMask |= (1 << ImGuiDir_Up) | (1 << ImGuiDir_Down);
|
g.ActiveIdUsingNavDirMask |= (1 << ImGuiDir_Up) | (1 << ImGuiDir_Down);
|
||||||
SetKeyOwner(ImGuiKey_Enter, id);
|
|
||||||
SetKeyOwner(ImGuiKey_KeypadEnter, id);
|
|
||||||
SetKeyOwner(ImGuiKey_Home, id);
|
SetKeyOwner(ImGuiKey_Home, id);
|
||||||
SetKeyOwner(ImGuiKey_End, id);
|
SetKeyOwner(ImGuiKey_End, id);
|
||||||
if (is_multiline)
|
if (is_multiline)
|
||||||
@ -4309,9 +4257,10 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
SetKeyOwner(ImGuiKey_PageUp, id);
|
SetKeyOwner(ImGuiKey_PageUp, id);
|
||||||
SetKeyOwner(ImGuiKey_PageDown, id);
|
SetKeyOwner(ImGuiKey_PageDown, id);
|
||||||
}
|
}
|
||||||
// FIXME: May be a problem to always steal Alt on OSX, would ideally still allow an uninterrupted Alt down-up to toggle menu
|
|
||||||
if (is_osx)
|
if (is_osx)
|
||||||
SetKeyOwner(ImGuiMod_Alt, id);
|
SetKeyOwner(ImGuiMod_Alt, id);
|
||||||
|
if (flags & (ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_AllowTabInput)) // Disable keyboard tabbing out as we will use the \t character.
|
||||||
|
SetShortcutRouting(ImGuiKey_Tab, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have an edge case if ActiveId was set through another widget (e.g. widget being swapped), clear id immediately (don't wait until the end of the function)
|
// We have an edge case if ActiveId was set through another widget (e.g. widget being swapped), clear id immediately (don't wait until the end of the function)
|
||||||
@ -4440,25 +4389,16 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
|
|
||||||
// We expect backends to emit a Tab key but some also emit a Tab character which we ignore (#2467, #1336)
|
// We expect backends to emit a Tab key but some also emit a Tab character which we ignore (#2467, #1336)
|
||||||
// (For Tab and Enter: Win32/SFML/Allegro are sending both keys and chars, GLFW and SDL are only sending keys. For Space they all send all threes)
|
// (For Tab and Enter: Win32/SFML/Allegro are sending both keys and chars, GLFW and SDL are only sending keys. For Space they all send all threes)
|
||||||
if ((flags & ImGuiInputTextFlags_AllowTabInput) && !is_readonly)
|
if ((flags & ImGuiInputTextFlags_AllowTabInput) && Shortcut(ImGuiKey_Tab, id, ImGuiInputFlags_Repeat) && !is_readonly)
|
||||||
{
|
|
||||||
if (Shortcut(ImGuiKey_Tab, ImGuiInputFlags_Repeat, id))
|
|
||||||
{
|
{
|
||||||
unsigned int c = '\t'; // Insert TAB
|
unsigned int c = '\t'; // Insert TAB
|
||||||
if (InputTextFilterCharacter(&g, &c, flags, callback, callback_user_data))
|
if (InputTextFilterCharacter(&g, &c, flags, callback, callback_user_data, ImGuiInputSource_Keyboard))
|
||||||
state->OnKeyPressed((int)c);
|
state->OnKeyPressed((int)c);
|
||||||
}
|
}
|
||||||
// FIXME: Implement Shift+Tab
|
|
||||||
/*
|
|
||||||
if (Shortcut(ImGuiKey_Tab | ImGuiMod_Shift, ImGuiInputFlags_Repeat, id))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
// Process regular text input (before we check for Return because using some IME will effectively send a Return?)
|
// Process regular text input (before we check for Return because using some IME will effectively send a Return?)
|
||||||
// We ignore CTRL inputs, but need to allow ALT+CTRL as some keyboards (e.g. German) use AltGR (which _is_ Alt+Ctrl) to input certain characters.
|
// We ignore CTRL inputs, but need to allow ALT+CTRL as some keyboards (e.g. German) use AltGR (which _is_ Alt+Ctrl) to input certain characters.
|
||||||
const bool ignore_char_inputs = (io.KeyCtrl && !io.KeyAlt) || (is_osx && io.KeyCtrl);
|
const bool ignore_char_inputs = (io.KeyCtrl && !io.KeyAlt) || (is_osx && io.KeySuper);
|
||||||
if (io.InputQueueCharacters.Size > 0)
|
if (io.InputQueueCharacters.Size > 0)
|
||||||
{
|
{
|
||||||
if (!ignore_char_inputs && !is_readonly && !input_requested_by_nav)
|
if (!ignore_char_inputs && !is_readonly && !input_requested_by_nav)
|
||||||
@ -4468,7 +4408,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
unsigned int c = (unsigned int)io.InputQueueCharacters[n];
|
unsigned int c = (unsigned int)io.InputQueueCharacters[n];
|
||||||
if (c == '\t') // Skip Tab, see above.
|
if (c == '\t') // Skip Tab, see above.
|
||||||
continue;
|
continue;
|
||||||
if (InputTextFilterCharacter(&g, &c, flags, callback, callback_user_data))
|
if (InputTextFilterCharacter(&g, &c, flags, callback, callback_user_data, ImGuiInputSource_Keyboard))
|
||||||
state->OnKeyPressed((int)c);
|
state->OnKeyPressed((int)c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4488,26 +4428,25 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
|
|
||||||
const int k_mask = (io.KeyShift ? STB_TEXTEDIT_K_SHIFT : 0);
|
const int k_mask = (io.KeyShift ? STB_TEXTEDIT_K_SHIFT : 0);
|
||||||
const bool is_wordmove_key_down = is_osx ? io.KeyAlt : io.KeyCtrl; // OS X style: Text editing cursor movement using Alt instead of Ctrl
|
const bool is_wordmove_key_down = is_osx ? io.KeyAlt : io.KeyCtrl; // OS X style: Text editing cursor movement using Alt instead of Ctrl
|
||||||
const bool is_startend_key_down = is_osx && io.KeyCtrl && !io.KeySuper && !io.KeyAlt; // OS X style: Line/Text Start and End using Cmd+Arrows instead of Home/End
|
const bool is_startend_key_down = is_osx && io.KeySuper && !io.KeyCtrl && !io.KeyAlt; // OS X style: Line/Text Start and End using Cmd+Arrows instead of Home/End
|
||||||
|
|
||||||
// Using Shortcut() with ImGuiInputFlags_RouteFocused (default policy) to allow routing operations for other code (e.g. calling window trying to use CTRL+A and CTRL+B: formet would be handled by InputText)
|
// Using Shortcut() with ImGuiInputFlags_RouteFocused (default policy) to allow routing operations for other code (e.g. calling window trying to use CTRL+A and CTRL+B: formet would be handled by InputText)
|
||||||
// Otherwise we could simply assume that we own the keys as we are active.
|
// Otherwise we could simply assume that we own the keys as we are active.
|
||||||
const ImGuiInputFlags f_repeat = ImGuiInputFlags_Repeat;
|
const ImGuiInputFlags f_repeat = ImGuiInputFlags_Repeat;
|
||||||
const bool is_cut = (Shortcut(ImGuiMod_Ctrl | ImGuiKey_X, f_repeat, id) || Shortcut(ImGuiMod_Shift | ImGuiKey_Delete, f_repeat, id)) && !is_readonly && !is_password && (!is_multiline || state->HasSelection());
|
const bool is_cut = (Shortcut(ImGuiMod_Shortcut | ImGuiKey_X, id, f_repeat) || Shortcut(ImGuiMod_Shift | ImGuiKey_Delete, id, f_repeat)) && !is_readonly && !is_password && (!is_multiline || state->HasSelection());
|
||||||
const bool is_copy = (Shortcut(ImGuiMod_Ctrl | ImGuiKey_C, 0, id) || Shortcut(ImGuiMod_Ctrl | ImGuiKey_Insert, 0, id)) && !is_password && (!is_multiline || state->HasSelection());
|
const bool is_copy = (Shortcut(ImGuiMod_Shortcut | ImGuiKey_C, id) || Shortcut(ImGuiMod_Ctrl | ImGuiKey_Insert, id)) && !is_password && (!is_multiline || state->HasSelection());
|
||||||
const bool is_paste = (Shortcut(ImGuiMod_Ctrl | ImGuiKey_V, f_repeat, id) || Shortcut(ImGuiMod_Shift | ImGuiKey_Insert, f_repeat, id)) && !is_readonly;
|
const bool is_paste = (Shortcut(ImGuiMod_Shortcut | ImGuiKey_V, id, f_repeat) || Shortcut(ImGuiMod_Shift | ImGuiKey_Insert, id, f_repeat)) && !is_readonly;
|
||||||
const bool is_undo = (Shortcut(ImGuiMod_Ctrl | ImGuiKey_Z, f_repeat, id)) && !is_readonly && is_undoable;
|
const bool is_undo = (Shortcut(ImGuiMod_Shortcut | ImGuiKey_Z, id, f_repeat)) && !is_readonly && is_undoable;
|
||||||
const bool is_redo = (Shortcut(ImGuiMod_Ctrl | ImGuiKey_Y, f_repeat, id) || (is_osx && Shortcut(ImGuiMod_Ctrl | ImGuiMod_Shift | ImGuiKey_Z, f_repeat, id))) && !is_readonly && is_undoable;
|
const bool is_redo = (Shortcut(ImGuiMod_Shortcut | ImGuiKey_Y, id, f_repeat) || (is_osx && Shortcut(ImGuiMod_Shortcut | ImGuiMod_Shift | ImGuiKey_Z, id, f_repeat))) && !is_readonly && is_undoable;
|
||||||
const bool is_select_all = Shortcut(ImGuiMod_Ctrl | ImGuiKey_A, 0, id);
|
const bool is_select_all = Shortcut(ImGuiMod_Shortcut | ImGuiKey_A, id);
|
||||||
|
|
||||||
// We allow validate/cancel with Nav source (gamepad) to makes it easier to undo an accidental NavInput press with no keyboard wired, but otherwise it isn't very useful.
|
// We allow validate/cancel with Nav source (gamepad) to makes it easier to undo an accidental NavInput press with no keyboard wired, but otherwise it isn't very useful.
|
||||||
const bool nav_gamepad_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) != 0 && (io.BackendFlags & ImGuiBackendFlags_HasGamepad) != 0;
|
const bool nav_gamepad_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) != 0 && (io.BackendFlags & ImGuiBackendFlags_HasGamepad) != 0;
|
||||||
const bool is_enter_pressed = IsKeyPressed(ImGuiKey_Enter, true) || IsKeyPressed(ImGuiKey_KeypadEnter, true);
|
const bool is_enter_pressed = IsKeyPressed(ImGuiKey_Enter, true) || IsKeyPressed(ImGuiKey_KeypadEnter, true);
|
||||||
const bool is_gamepad_validate = nav_gamepad_active && (IsKeyPressed(ImGuiKey_NavGamepadActivate, false) || IsKeyPressed(ImGuiKey_NavGamepadInput, false));
|
const bool is_gamepad_validate = nav_gamepad_active && (IsKeyPressed(ImGuiKey_NavGamepadActivate, false) || IsKeyPressed(ImGuiKey_NavGamepadInput, false));
|
||||||
const bool is_cancel = Shortcut(ImGuiKey_Escape, f_repeat, id) || (nav_gamepad_active && Shortcut(ImGuiKey_NavGamepadCancel, f_repeat, id));
|
const bool is_cancel = Shortcut(ImGuiKey_Escape, id, f_repeat) || (nav_gamepad_active && Shortcut(ImGuiKey_NavGamepadCancel, id, f_repeat));
|
||||||
|
|
||||||
// FIXME: Should use more Shortcut() and reduce IsKeyPressed()+SetKeyOwner(), but requires modifiers combination to be taken account of.
|
// FIXME: Should use more Shortcut() and reduce IsKeyPressed()+SetKeyOwner(), but requires modifiers combination to be taken account of.
|
||||||
// FIXME-OSX: Missing support for Alt(option)+Right/Left = go to end of line, or next line if already in end of line.
|
|
||||||
if (IsKeyPressed(ImGuiKey_LeftArrow)) { state->OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_LINESTART : is_wordmove_key_down ? STB_TEXTEDIT_K_WORDLEFT : STB_TEXTEDIT_K_LEFT) | k_mask); }
|
if (IsKeyPressed(ImGuiKey_LeftArrow)) { state->OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_LINESTART : is_wordmove_key_down ? STB_TEXTEDIT_K_WORDLEFT : STB_TEXTEDIT_K_LEFT) | k_mask); }
|
||||||
else if (IsKeyPressed(ImGuiKey_RightArrow)) { state->OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_LINEEND : is_wordmove_key_down ? STB_TEXTEDIT_K_WORDRIGHT : STB_TEXTEDIT_K_RIGHT) | k_mask); }
|
else if (IsKeyPressed(ImGuiKey_RightArrow)) { state->OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_LINEEND : is_wordmove_key_down ? STB_TEXTEDIT_K_WORDRIGHT : STB_TEXTEDIT_K_RIGHT) | k_mask); }
|
||||||
else if (IsKeyPressed(ImGuiKey_UpArrow) && is_multiline) { if (io.KeyCtrl) SetScrollY(draw_window, ImMax(draw_window->Scroll.y - g.FontSize, 0.0f)); else state->OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_TEXTSTART : STB_TEXTEDIT_K_UP) | k_mask); }
|
else if (IsKeyPressed(ImGuiKey_UpArrow) && is_multiline) { if (io.KeyCtrl) SetScrollY(draw_window, ImMax(draw_window->Scroll.y - g.FontSize, 0.0f)); else state->OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_TEXTSTART : STB_TEXTEDIT_K_UP) | k_mask); }
|
||||||
@ -4532,7 +4471,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
{
|
{
|
||||||
if (is_wordmove_key_down)
|
if (is_wordmove_key_down)
|
||||||
state->OnKeyPressed(STB_TEXTEDIT_K_WORDLEFT | STB_TEXTEDIT_K_SHIFT);
|
state->OnKeyPressed(STB_TEXTEDIT_K_WORDLEFT | STB_TEXTEDIT_K_SHIFT);
|
||||||
else if (is_osx && io.KeyCtrl && !io.KeyAlt && !io.KeySuper)
|
else if (is_osx && io.KeySuper && !io.KeyAlt && !io.KeyCtrl)
|
||||||
state->OnKeyPressed(STB_TEXTEDIT_K_LINESTART | STB_TEXTEDIT_K_SHIFT);
|
state->OnKeyPressed(STB_TEXTEDIT_K_LINESTART | STB_TEXTEDIT_K_SHIFT);
|
||||||
}
|
}
|
||||||
state->OnKeyPressed(STB_TEXTEDIT_K_BACKSPACE | k_mask);
|
state->OnKeyPressed(STB_TEXTEDIT_K_BACKSPACE | k_mask);
|
||||||
@ -4552,7 +4491,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
else if (!is_readonly)
|
else if (!is_readonly)
|
||||||
{
|
{
|
||||||
unsigned int c = '\n'; // Insert new line
|
unsigned int c = '\n'; // Insert new line
|
||||||
if (InputTextFilterCharacter(&g, &c, flags, callback, callback_user_data))
|
if (InputTextFilterCharacter(&g, &c, flags, callback, callback_user_data, ImGuiInputSource_Keyboard))
|
||||||
state->OnKeyPressed((int)c);
|
state->OnKeyPressed((int)c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4619,7 +4558,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
{
|
{
|
||||||
unsigned int c;
|
unsigned int c;
|
||||||
s += ImTextCharFromUtf8(&c, s, NULL);
|
s += ImTextCharFromUtf8(&c, s, NULL);
|
||||||
if (!InputTextFilterCharacter(&g, &c, flags, callback, callback_user_data, true))
|
if (!InputTextFilterCharacter(&g, &c, flags, callback, callback_user_data, ImGuiInputSource_Clipboard))
|
||||||
continue;
|
continue;
|
||||||
clipboard_filtered[clipboard_filtered_len++] = (ImWchar)c;
|
clipboard_filtered[clipboard_filtered_len++] = (ImWchar)c;
|
||||||
}
|
}
|
||||||
@ -4702,7 +4641,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
// The reason we specify the usage semantic (Completion/History) is that Completion needs to disable keyboard TABBING at the moment.
|
// The reason we specify the usage semantic (Completion/History) is that Completion needs to disable keyboard TABBING at the moment.
|
||||||
ImGuiInputTextFlags event_flag = 0;
|
ImGuiInputTextFlags event_flag = 0;
|
||||||
ImGuiKey event_key = ImGuiKey_None;
|
ImGuiKey event_key = ImGuiKey_None;
|
||||||
if ((flags & ImGuiInputTextFlags_CallbackCompletion) != 0 && Shortcut(ImGuiKey_Tab, 0, id))
|
if ((flags & ImGuiInputTextFlags_CallbackCompletion) != 0 && Shortcut(ImGuiKey_Tab, id))
|
||||||
{
|
{
|
||||||
event_flag = ImGuiInputTextFlags_CallbackCompletion;
|
event_flag = ImGuiInputTextFlags_CallbackCompletion;
|
||||||
event_key = ImGuiKey_Tab;
|
event_key = ImGuiKey_Tab;
|
||||||
@ -6207,17 +6146,13 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
|||||||
label_end = FindRenderedTextEnd(label);
|
label_end = FindRenderedTextEnd(label);
|
||||||
const ImVec2 label_size = CalcTextSize(label, label_end, false);
|
const ImVec2 label_size = CalcTextSize(label, label_end, false);
|
||||||
|
|
||||||
const float text_offset_x = g.FontSize + (display_frame ? padding.x * 3 : padding.x * 2); // Collapsing arrow width + Spacing
|
|
||||||
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 + padding.x * 2; // Include collapsing arrow
|
|
||||||
|
|
||||||
// We vertically grow up to current line height up the typical widget height.
|
// We vertically grow up to current line height up the typical widget height.
|
||||||
const float frame_height = ImMax(ImMin(window->DC.CurrLineSize.y, g.FontSize + style.FramePadding.y * 2), label_size.y + padding.y * 2);
|
const float frame_height = ImMax(ImMin(window->DC.CurrLineSize.y, g.FontSize + style.FramePadding.y * 2), label_size.y + padding.y * 2);
|
||||||
const bool span_all_columns = (flags & ImGuiTreeNodeFlags_SpanAllColumns) != 0 && (g.CurrentTable != NULL);
|
const bool span_all_columns = (flags & ImGuiTreeNodeFlags_SpanAllColumns) != 0 && (g.CurrentTable != NULL);
|
||||||
ImRect frame_bb;
|
ImRect frame_bb;
|
||||||
frame_bb.Min.x = span_all_columns ? window->ParentWorkRect.Min.x : (flags & ImGuiTreeNodeFlags_SpanFullWidth) ? window->WorkRect.Min.x : window->DC.CursorPos.x;
|
frame_bb.Min.x = span_all_columns ? window->ParentWorkRect.Min.x : (flags & ImGuiTreeNodeFlags_SpanFullWidth) ? window->WorkRect.Min.x : window->DC.CursorPos.x;
|
||||||
frame_bb.Min.y = window->DC.CursorPos.y;
|
frame_bb.Min.y = window->DC.CursorPos.y;
|
||||||
frame_bb.Max.x = span_all_columns ? window->ParentWorkRect.Max.x : (flags & ImGuiTreeNodeFlags_SpanTextWidth) ? window->DC.CursorPos.x + text_width + padding.x : window->WorkRect.Max.x;
|
frame_bb.Max.x = span_all_columns ? window->ParentWorkRect.Max.x : window->WorkRect.Max.x;
|
||||||
frame_bb.Max.y = window->DC.CursorPos.y + frame_height;
|
frame_bb.Max.y = window->DC.CursorPos.y + frame_height;
|
||||||
if (display_frame)
|
if (display_frame)
|
||||||
{
|
{
|
||||||
@ -6227,13 +6162,16 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
|||||||
frame_bb.Max.x += IM_TRUNC(window->WindowPadding.x * 0.5f);
|
frame_bb.Max.x += IM_TRUNC(window->WindowPadding.x * 0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const float text_offset_x = g.FontSize + (display_frame ? padding.x * 3 : padding.x * 2); // Collapsing arrow width + Spacing
|
||||||
|
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 collapsing
|
||||||
ImVec2 text_pos(window->DC.CursorPos.x + text_offset_x, window->DC.CursorPos.y + text_offset_y);
|
ImVec2 text_pos(window->DC.CursorPos.x + text_offset_x, window->DC.CursorPos.y + text_offset_y);
|
||||||
ItemSize(ImVec2(text_width, frame_height), padding.y);
|
ItemSize(ImVec2(text_width, frame_height), padding.y);
|
||||||
|
|
||||||
// For regular tree nodes, we arbitrary allow to click past 2 worth of ItemSpacing
|
// For regular tree nodes, we arbitrary allow to click past 2 worth of ItemSpacing
|
||||||
ImRect interact_bb = frame_bb;
|
ImRect interact_bb = frame_bb;
|
||||||
if ((flags & (ImGuiTreeNodeFlags_Framed | ImGuiTreeNodeFlags_SpanAvailWidth | ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_SpanTextWidth | ImGuiTreeNodeFlags_SpanAllColumns)) == 0)
|
if (!display_frame && (flags & (ImGuiTreeNodeFlags_SpanAvailWidth | ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_SpanAllColumns)) == 0)
|
||||||
interact_bb.Max.x = frame_bb.Min.x + text_width + (label_size.x > 0.0f ? style.ItemSpacing.x * 2.0f : 0.0f);
|
interact_bb.Max.x = frame_bb.Min.x + text_width + style.ItemSpacing.x * 2.0f;
|
||||||
|
|
||||||
// Modify ClipRect for the ItemAdd(), faster than doing a PushColumnsBackground/PushTableBackgroundChannel for every Selectable..
|
// Modify ClipRect for the ItemAdd(), faster than doing a PushColumnsBackground/PushTableBackgroundChannel for every Selectable..
|
||||||
const float backup_clip_rect_min_x = window->ClipRect.Min.x;
|
const float backup_clip_rect_min_x = window->ClipRect.Min.x;
|
||||||
@ -6370,7 +6308,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
|||||||
|
|
||||||
// Render
|
// Render
|
||||||
const ImU32 text_col = GetColorU32(ImGuiCol_Text);
|
const ImU32 text_col = GetColorU32(ImGuiCol_Text);
|
||||||
ImGuiNavHighlightFlags nav_highlight_flags = ImGuiNavHighlightFlags_Compact;
|
ImGuiNavHighlightFlags nav_highlight_flags = ImGuiNavHighlightFlags_TypeThin;
|
||||||
if (display_frame)
|
if (display_frame)
|
||||||
{
|
{
|
||||||
// Framed type
|
// Framed type
|
||||||
@ -6673,7 +6611,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
|
|||||||
RenderFrame(bb.Min, bb.Max, col, false, 0.0f);
|
RenderFrame(bb.Min, bb.Max, col, false, 0.0f);
|
||||||
}
|
}
|
||||||
if (g.NavId == id)
|
if (g.NavId == id)
|
||||||
RenderNavHighlight(bb, id, ImGuiNavHighlightFlags_Compact | ImGuiNavHighlightFlags_NoRounding);
|
RenderNavHighlight(bb, id, ImGuiNavHighlightFlags_TypeThin | ImGuiNavHighlightFlags_NoRounding);
|
||||||
|
|
||||||
if (span_all_columns)
|
if (span_all_columns)
|
||||||
{
|
{
|
||||||
@ -6769,7 +6707,7 @@ ImGuiTypingSelectRequest* ImGui::GetTypingSelectRequest(ImGuiTypingSelectFlags f
|
|||||||
g.IO.InputQueueCharacters.resize(0);
|
g.IO.InputQueueCharacters.resize(0);
|
||||||
|
|
||||||
// Handle backspace
|
// Handle backspace
|
||||||
if ((flags & ImGuiTypingSelectFlags_AllowBackspace) && IsKeyPressed(ImGuiKey_Backspace, ImGuiInputFlags_Repeat))
|
if ((flags & ImGuiTypingSelectFlags_AllowBackspace) && IsKeyPressed(ImGuiKey_Backspace, 0, ImGuiInputFlags_Repeat))
|
||||||
{
|
{
|
||||||
char* p = (char*)(void*)ImTextFindPreviousUtf8Codepoint(data->SearchBuffer, data->SearchBuffer + buffer_len);
|
char* p = (char*)(void*)ImTextFindPreviousUtf8Codepoint(data->SearchBuffer, data->SearchBuffer + buffer_len);
|
||||||
*p = 0;
|
*p = 0;
|
||||||
@ -6957,7 +6895,6 @@ bool ImGui::BeginListBox(const char* label, const ImVec2& size_arg)
|
|||||||
ImVec2 label_pos = ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y);
|
ImVec2 label_pos = ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y);
|
||||||
RenderText(label_pos, label);
|
RenderText(label_pos, label);
|
||||||
window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, label_pos + label_size);
|
window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, label_pos + label_size);
|
||||||
AlignTextToFramePadding();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BeginChild(id, frame_bb.GetSize(), ImGuiChildFlags_FrameStyle);
|
BeginChild(id, frame_bb.GetSize(), ImGuiChildFlags_FrameStyle);
|
||||||
@ -7554,7 +7491,6 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)
|
|||||||
PopItemFlag();
|
PopItemFlag();
|
||||||
|
|
||||||
bool want_open = false;
|
bool want_open = false;
|
||||||
bool want_open_nav_init = false;
|
|
||||||
bool want_close = false;
|
bool want_close = false;
|
||||||
if (window->DC.LayoutType == ImGuiLayoutType_Vertical) // (window->Flags & (ImGuiWindowFlags_Popup|ImGuiWindowFlags_ChildMenu))
|
if (window->DC.LayoutType == ImGuiLayoutType_Vertical) // (window->Flags & (ImGuiWindowFlags_Popup|ImGuiWindowFlags_ChildMenu))
|
||||||
{
|
{
|
||||||
@ -7597,9 +7533,8 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)
|
|||||||
want_open = true;
|
want_open = true;
|
||||||
if (g.NavId == id && g.NavMoveDir == ImGuiDir_Right) // Nav-Right to open
|
if (g.NavId == id && g.NavMoveDir == ImGuiDir_Right) // Nav-Right to open
|
||||||
{
|
{
|
||||||
want_open = want_open_nav_init = true;
|
want_open = true;
|
||||||
NavMoveRequestCancel();
|
NavMoveRequestCancel();
|
||||||
NavRestoreHighlightAfterMove();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -7631,13 +7566,13 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)
|
|||||||
|
|
||||||
if (want_open && !menu_is_open && g.OpenPopupStack.Size > g.BeginPopupStack.Size)
|
if (want_open && !menu_is_open && g.OpenPopupStack.Size > g.BeginPopupStack.Size)
|
||||||
{
|
{
|
||||||
// Don't reopen/recycle same menu level in the same frame if it is a different menu ID, first close the other menu and yield for a frame.
|
// Don't reopen/recycle same menu level in the same frame, first close the other menu and yield for a frame.
|
||||||
OpenPopup(label);
|
OpenPopup(label);
|
||||||
}
|
}
|
||||||
else if (want_open)
|
else if (want_open)
|
||||||
{
|
{
|
||||||
menu_is_open = true;
|
menu_is_open = true;
|
||||||
OpenPopup(label, ImGuiPopupFlags_NoReopen);// | (want_open_nav_init ? ImGuiPopupFlags_NoReopenAlwaysNavInit : 0));
|
OpenPopup(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (menu_is_open)
|
if (menu_is_open)
|
||||||
@ -7649,14 +7584,6 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)
|
|||||||
PopStyleVar();
|
PopStyleVar();
|
||||||
if (menu_is_open)
|
if (menu_is_open)
|
||||||
{
|
{
|
||||||
// Implement what ImGuiPopupFlags_NoReopenAlwaysNavInit would do:
|
|
||||||
// Perform an init request in the case the popup was already open (via a previous mouse hover)
|
|
||||||
if (want_open && want_open_nav_init && !g.NavInitRequest)
|
|
||||||
{
|
|
||||||
FocusWindow(g.CurrentWindow, ImGuiFocusRequestFlags_UnlessBelowModal);
|
|
||||||
NavInitWindow(g.CurrentWindow, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Restore LastItemData so IsItemXXXX functions can work after BeginMenu()/EndMenu()
|
// Restore LastItemData so IsItemXXXX functions can work after BeginMenu()/EndMenu()
|
||||||
// (This fixes using IsItemClicked() and IsItemHovered(), but IsItemHovered() also relies on its support for ImGuiItemFlags_NoWindowHoverableCheck)
|
// (This fixes using IsItemClicked() and IsItemHovered(), but IsItemHovered() also relies on its support for ImGuiItemFlags_NoWindowHoverableCheck)
|
||||||
g.LastItemData = last_item_in_parent;
|
g.LastItemData = last_item_in_parent;
|
||||||
|
2
external/imgui/imgui/imstb_textedit.h
vendored
2
external/imgui/imgui/imstb_textedit.h
vendored
@ -41,7 +41,7 @@
|
|||||||
// 1.13 (2019-02-07) fix bug in undo size management
|
// 1.13 (2019-02-07) fix bug in undo size management
|
||||||
// 1.12 (2018-01-29) user can change STB_TEXTEDIT_KEYTYPE, fix redo to avoid crash
|
// 1.12 (2018-01-29) user can change STB_TEXTEDIT_KEYTYPE, fix redo to avoid crash
|
||||||
// 1.11 (2017-03-03) fix HOME on last line, dragging off single-line textfield
|
// 1.11 (2017-03-03) fix HOME on last line, dragging off single-line textfield
|
||||||
// 1.10 (2016-10-25) suppress warnings about casting away const with -Wcast-qual
|
// 1.10 (2016-10-25) supress warnings about casting away const with -Wcast-qual
|
||||||
// 1.9 (2016-08-27) customizable move-by-word
|
// 1.9 (2016-08-27) customizable move-by-word
|
||||||
// 1.8 (2016-04-02) better keyboard handling when mouse button is down
|
// 1.8 (2016-04-02) better keyboard handling when mouse button is down
|
||||||
// 1.7 (2015-09-13) change y range handling in case baseline is non-0
|
// 1.7 (2015-09-13) change y range handling in case baseline is non-0
|
||||||
|
2
external/imgui/imgui/imstb_truetype.h
vendored
2
external/imgui/imgui/imstb_truetype.h
vendored
@ -656,7 +656,7 @@ STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h
|
|||||||
STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, int skip);
|
STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, int skip);
|
||||||
// If skip != 0, this tells stb_truetype to skip any codepoints for which
|
// If skip != 0, this tells stb_truetype to skip any codepoints for which
|
||||||
// there is no corresponding glyph. If skip=0, which is the default, then
|
// there is no corresponding glyph. If skip=0, which is the default, then
|
||||||
// codepoints without a glyph received the font's "missing character" glyph,
|
// codepoints without a glyph recived the font's "missing character" glyph,
|
||||||
// typically an empty box by convention.
|
// typically an empty box by convention.
|
||||||
|
|
||||||
STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, // same data as above
|
STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, // same data as above
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
// 2023/01/04: fixed a packing issue which in some occurrences would prevent large amount of glyphs from being packed correctly.
|
// 2023/01/04: fixed a packing issue which in some occurrences would prevent large amount of glyphs from being packed correctly.
|
||||||
// 2021/08/23: fixed crash when FT_Render_Glyph() fails to render a glyph and returns NULL.
|
// 2021/08/23: fixed crash when FT_Render_Glyph() fails to render a glyph and returns NULL.
|
||||||
// 2021/03/05: added ImGuiFreeTypeBuilderFlags_Bitmap to load bitmap glyphs.
|
// 2021/03/05: added ImGuiFreeTypeBuilderFlags_Bitmap to load bitmap glyphs.
|
||||||
// 2021/03/02: set 'atlas->TexPixelsUseColors = true' to help some backends with deciding of a preferred texture format.
|
// 2021/03/02: set 'atlas->TexPixelsUseColors = true' to help some backends with deciding of a prefered texture format.
|
||||||
// 2021/01/28: added support for color-layered glyphs via ImGuiFreeTypeBuilderFlags_LoadColor (require Freetype 2.10+).
|
// 2021/01/28: added support for color-layered glyphs via ImGuiFreeTypeBuilderFlags_LoadColor (require Freetype 2.10+).
|
||||||
// 2021/01/26: simplified integration by using '#define IMGUI_ENABLE_FREETYPE'. renamed ImGuiFreeType::XXX flags to ImGuiFreeTypeBuilderFlags_XXX for consistency with other API. removed ImGuiFreeType::BuildFontAtlas().
|
// 2021/01/26: simplified integration by using '#define IMGUI_ENABLE_FREETYPE'. renamed ImGuiFreeType::XXX flags to ImGuiFreeTypeBuilderFlags_XXX for consistency with other API. removed ImGuiFreeType::BuildFontAtlas().
|
||||||
// 2020/06/04: fix for rare case where FT_Get_Char_Index() succeed but FT_Load_Glyph() fails.
|
// 2020/06/04: fix for rare case where FT_Get_Char_Index() succeed but FT_Load_Glyph() fails.
|
||||||
|
27
external/libwebp/CMakeLists.txt
vendored
27
external/libwebp/CMakeLists.txt
vendored
@ -1,29 +1,6 @@
|
|||||||
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
|
||||||
|
|
||||||
include(FetchContent)
|
set(WEBP_LINK_STATIC ON CACHE INTERNAL "")
|
||||||
|
|
||||||
if (NOT TARGET libwebp)
|
add_subdirectory(./libwebp EXCLUDE_FROM_ALL)
|
||||||
set(WEBP_LINK_STATIC ON CACHE BOOL "" FORCE)
|
|
||||||
set(WEBP_BUILD_ANIM_UTILS OFF CACHE BOOL "" FORCE)
|
|
||||||
set(WEBP_BUILD_CWEBP OFF CACHE BOOL "" FORCE)
|
|
||||||
set(WEBP_BUILD_DWEBP OFF CACHE BOOL "" FORCE)
|
|
||||||
set(WEBP_BUILD_GIF2WEBP OFF CACHE BOOL "" FORCE)
|
|
||||||
set(WEBP_BUILD_IMG2WEBP OFF CACHE BOOL "" FORCE)
|
|
||||||
set(WEBP_BUILD_VWEBP OFF CACHE BOOL "" FORCE)
|
|
||||||
set(WEBP_BUILD_WEBPINFO OFF CACHE BOOL "" FORCE)
|
|
||||||
set(WEBP_BUILD_LIBWEBPMUX ON CACHE BOOL "" FORCE)
|
|
||||||
set(WEBP_BUILD_WEBPMUX OFF CACHE BOOL "" FORCE)
|
|
||||||
set(WEBP_BUILD_EXTRAS OFF CACHE BOOL "" FORCE)
|
|
||||||
set(WEBP_BUILD_WEBP_JS OFF CACHE BOOL "" FORCE)
|
|
||||||
set(WEBP_USE_THREAD ON CACHE BOOL "" FORCE)
|
|
||||||
|
|
||||||
FetchContent_Declare(libwebp
|
|
||||||
GIT_REPOSITORY https://github.com/webmproject/libwebp
|
|
||||||
GIT_TAG v1.3.2
|
|
||||||
FIND_PACKAGE_ARGS
|
|
||||||
)
|
|
||||||
FetchContent_MakeAvailable(libwebp)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#add_subdirectory(./libwebp EXCLUDE_FROM_ALL)
|
|
||||||
|
|
||||||
|
240
external/libwebp/libwebp/.cmake-format.py
vendored
Normal file
240
external/libwebp/libwebp/.cmake-format.py
vendored
Normal file
@ -0,0 +1,240 @@
|
|||||||
|
# ----------------------------------
|
||||||
|
# Options affecting listfile parsing
|
||||||
|
# ----------------------------------
|
||||||
|
with section("parse"):
|
||||||
|
|
||||||
|
# Specify structure for custom cmake functions
|
||||||
|
additional_commands = { 'foo': { 'flags': ['BAR', 'BAZ'],
|
||||||
|
'kwargs': {'DEPENDS': '*', 'HEADERS': '*', 'SOURCES': '*'}}}
|
||||||
|
|
||||||
|
# Override configurations per-command where available
|
||||||
|
override_spec = {}
|
||||||
|
|
||||||
|
# Specify variable tags.
|
||||||
|
vartags = []
|
||||||
|
|
||||||
|
# Specify property tags.
|
||||||
|
proptags = []
|
||||||
|
|
||||||
|
# -----------------------------
|
||||||
|
# Options affecting formatting.
|
||||||
|
# -----------------------------
|
||||||
|
with section("format"):
|
||||||
|
|
||||||
|
# Disable formatting entirely, making cmake-format a no-op
|
||||||
|
disable = False
|
||||||
|
|
||||||
|
# How wide to allow formatted cmake files
|
||||||
|
line_width = 80
|
||||||
|
|
||||||
|
# How many spaces to tab for indent
|
||||||
|
tab_size = 2
|
||||||
|
|
||||||
|
# If true, lines are indented using tab characters (utf-8 0x09) instead of
|
||||||
|
# <tab_size> space characters (utf-8 0x20). In cases where the layout would
|
||||||
|
# require a fractional tab character, the behavior of the fractional
|
||||||
|
# indentation is governed by <fractional_tab_policy>
|
||||||
|
use_tabchars = False
|
||||||
|
|
||||||
|
# If <use_tabchars> is True, then the value of this variable indicates how
|
||||||
|
# fractional indentions are handled during whitespace replacement. If set to
|
||||||
|
# 'use-space', fractional indentation is left as spaces (utf-8 0x20). If set
|
||||||
|
# to `round-up` fractional indentation is replaced with a single tab character
|
||||||
|
# (utf-8 0x09) effectively shifting the column to the next tabstop
|
||||||
|
fractional_tab_policy = 'use-space'
|
||||||
|
|
||||||
|
# If an argument group contains more than this many sub-groups (parg or kwarg
|
||||||
|
# groups) then force it to a vertical layout.
|
||||||
|
max_subgroups_hwrap = 3
|
||||||
|
|
||||||
|
# If a positional argument group contains more than this many arguments, then
|
||||||
|
# force it to a vertical layout.
|
||||||
|
max_pargs_hwrap = 6
|
||||||
|
|
||||||
|
# If a cmdline positional group consumes more than this many lines without
|
||||||
|
# nesting, then invalidate the layout (and nest)
|
||||||
|
max_rows_cmdline = 2
|
||||||
|
|
||||||
|
# If true, separate flow control names from their parentheses with a space
|
||||||
|
separate_ctrl_name_with_space = False
|
||||||
|
|
||||||
|
# If true, separate function names from parentheses with a space
|
||||||
|
separate_fn_name_with_space = False
|
||||||
|
|
||||||
|
# If a statement is wrapped to more than one line, than dangle the closing
|
||||||
|
# parenthesis on its own line.
|
||||||
|
dangle_parens = False
|
||||||
|
|
||||||
|
# If the trailing parenthesis must be 'dangled' on its on line, then align it
|
||||||
|
# to this reference: `prefix`: the start of the statement, `prefix-indent`:
|
||||||
|
# the start of the statement, plus one indentation level, `child`: align to
|
||||||
|
# the column of the arguments
|
||||||
|
dangle_align = 'prefix'
|
||||||
|
|
||||||
|
# If the statement spelling length (including space and parenthesis) is
|
||||||
|
# smaller than this amount, then force reject nested layouts.
|
||||||
|
min_prefix_chars = 4
|
||||||
|
|
||||||
|
# If the statement spelling length (including space and parenthesis) is larger
|
||||||
|
# than the tab width by more than this amount, then force reject un-nested
|
||||||
|
# layouts.
|
||||||
|
max_prefix_chars = 10
|
||||||
|
|
||||||
|
# If a candidate layout is wrapped horizontally but it exceeds this many
|
||||||
|
# lines, then reject the layout.
|
||||||
|
max_lines_hwrap = 2
|
||||||
|
|
||||||
|
# What style line endings to use in the output.
|
||||||
|
line_ending = 'unix'
|
||||||
|
|
||||||
|
# Format command names consistently as 'lower' or 'upper' case
|
||||||
|
command_case = 'canonical'
|
||||||
|
|
||||||
|
# Format keywords consistently as 'lower' or 'upper' case
|
||||||
|
keyword_case = 'unchanged'
|
||||||
|
|
||||||
|
# A list of command names which should always be wrapped
|
||||||
|
always_wrap = []
|
||||||
|
|
||||||
|
# If true, the argument lists which are known to be sortable will be sorted
|
||||||
|
# lexicographicall
|
||||||
|
enable_sort = True
|
||||||
|
|
||||||
|
# If true, the parsers may infer whether or not an argument list is sortable
|
||||||
|
# (without annotation).
|
||||||
|
autosort = False
|
||||||
|
|
||||||
|
# By default, if cmake-format cannot successfully fit everything into the
|
||||||
|
# desired linewidth it will apply the last, most agressive attempt that it
|
||||||
|
# made. If this flag is True, however, cmake-format will print error, exit
|
||||||
|
# with non-zero status code, and write-out nothing
|
||||||
|
require_valid_layout = False
|
||||||
|
|
||||||
|
# A dictionary mapping layout nodes to a list of wrap decisions. See the
|
||||||
|
# documentation for more information.
|
||||||
|
layout_passes = {}
|
||||||
|
|
||||||
|
# ------------------------------------------------
|
||||||
|
# Options affecting comment reflow and formatting.
|
||||||
|
# ------------------------------------------------
|
||||||
|
with section("markup"):
|
||||||
|
|
||||||
|
# What character to use for bulleted lists
|
||||||
|
bullet_char = '*'
|
||||||
|
|
||||||
|
# What character to use as punctuation after numerals in an enumerated list
|
||||||
|
enum_char = '.'
|
||||||
|
|
||||||
|
# If comment markup is enabled, don't reflow the first comment block in each
|
||||||
|
# listfile. Use this to preserve formatting of your copyright/license
|
||||||
|
# statements.
|
||||||
|
first_comment_is_literal = True
|
||||||
|
|
||||||
|
# If comment markup is enabled, don't reflow any comment block which matches
|
||||||
|
# this (regex) pattern. Default is `None` (disabled).
|
||||||
|
literal_comment_pattern = None
|
||||||
|
|
||||||
|
# Regular expression to match preformat fences in comments default=
|
||||||
|
# ``r'^\s*([`~]{3}[`~]*)(.*)$'``
|
||||||
|
fence_pattern = '^\\s*([`~]{3}[`~]*)(.*)$'
|
||||||
|
|
||||||
|
# Regular expression to match rulers in comments default=
|
||||||
|
# ``r'^\s*[^\w\s]{3}.*[^\w\s]{3}$'``
|
||||||
|
ruler_pattern = '^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$'
|
||||||
|
|
||||||
|
# If a comment line matches starts with this pattern then it is explicitly a
|
||||||
|
# trailing comment for the preceeding argument. Default is '#<'
|
||||||
|
explicit_trailing_pattern = '#<'
|
||||||
|
|
||||||
|
# If a comment line starts with at least this many consecutive hash
|
||||||
|
# characters, then don't lstrip() them off. This allows for lazy hash rulers
|
||||||
|
# where the first hash char is not separated by space
|
||||||
|
hashruler_min_length = 10
|
||||||
|
|
||||||
|
# If true, then insert a space between the first hash char and remaining hash
|
||||||
|
# chars in a hash ruler, and normalize its length to fill the column
|
||||||
|
canonicalize_hashrulers = True
|
||||||
|
|
||||||
|
# enable comment markup parsing and reflow
|
||||||
|
enable_markup = True
|
||||||
|
|
||||||
|
# ----------------------------
|
||||||
|
# Options affecting the linter
|
||||||
|
# ----------------------------
|
||||||
|
with section("lint"):
|
||||||
|
|
||||||
|
# a list of lint codes to disable
|
||||||
|
disabled_codes = []
|
||||||
|
|
||||||
|
# regular expression pattern describing valid function names
|
||||||
|
function_pattern = '[0-9a-z_]+'
|
||||||
|
|
||||||
|
# regular expression pattern describing valid macro names
|
||||||
|
macro_pattern = '[0-9A-Z_]+'
|
||||||
|
|
||||||
|
# regular expression pattern describing valid names for variables with global
|
||||||
|
# (cache) scope
|
||||||
|
global_var_pattern = '[A-Z][0-9A-Z_]+'
|
||||||
|
|
||||||
|
# regular expression pattern describing valid names for variables with global
|
||||||
|
# scope (but internal semantic)
|
||||||
|
internal_var_pattern = '_[A-Z][0-9A-Z_]+'
|
||||||
|
|
||||||
|
# regular expression pattern describing valid names for variables with local
|
||||||
|
# scope
|
||||||
|
local_var_pattern = '[a-z][a-z0-9_]+'
|
||||||
|
|
||||||
|
# regular expression pattern describing valid names for privatedirectory
|
||||||
|
# variables
|
||||||
|
private_var_pattern = '_[0-9a-z_]+'
|
||||||
|
|
||||||
|
# regular expression pattern describing valid names for public directory
|
||||||
|
# variables
|
||||||
|
public_var_pattern = '[A-Z][0-9A-Z_]+'
|
||||||
|
|
||||||
|
# regular expression pattern describing valid names for function/macro
|
||||||
|
# arguments and loop variables.
|
||||||
|
argument_var_pattern = '[a-z][a-z0-9_]+'
|
||||||
|
|
||||||
|
# regular expression pattern describing valid names for keywords used in
|
||||||
|
# functions or macros
|
||||||
|
keyword_pattern = '[A-Z][0-9A-Z_]+'
|
||||||
|
|
||||||
|
# In the heuristic for C0201, how many conditionals to match within a loop in
|
||||||
|
# before considering the loop a parser.
|
||||||
|
max_conditionals_custom_parser = 2
|
||||||
|
|
||||||
|
# Require at least this many newlines between statements
|
||||||
|
min_statement_spacing = 1
|
||||||
|
|
||||||
|
# Require no more than this many newlines between statements
|
||||||
|
max_statement_spacing = 2
|
||||||
|
max_returns = 6
|
||||||
|
max_branches = 12
|
||||||
|
max_arguments = 5
|
||||||
|
max_localvars = 15
|
||||||
|
max_statements = 50
|
||||||
|
|
||||||
|
# -------------------------------
|
||||||
|
# Options affecting file encoding
|
||||||
|
# -------------------------------
|
||||||
|
with section("encode"):
|
||||||
|
|
||||||
|
# If true, emit the unicode byte-order mark (BOM) at the start of the file
|
||||||
|
emit_byteorder_mark = False
|
||||||
|
|
||||||
|
# Specify the encoding of the input file. Defaults to utf-8
|
||||||
|
input_encoding = 'utf-8'
|
||||||
|
|
||||||
|
# Specify the encoding of the output file. Defaults to utf-8. Note that cmake
|
||||||
|
# only claims to support utf-8 so be careful when using anything else
|
||||||
|
output_encoding = 'utf-8'
|
||||||
|
|
||||||
|
# -------------------------------------
|
||||||
|
# Miscellaneous configurations options.
|
||||||
|
# -------------------------------------
|
||||||
|
with section("misc"):
|
||||||
|
|
||||||
|
# A dictionary containing any per-command configuration overrides. Currently
|
||||||
|
# only `command_case` is supported.
|
||||||
|
per_command = {}
|
6
external/libwebp/libwebp/.gitattributes
vendored
Normal file
6
external/libwebp/libwebp/.gitattributes
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
.gitattributes export-ignore
|
||||||
|
.gitignore export-ignore
|
||||||
|
.mailmap export-ignore
|
||||||
|
*.bat text eol=crlf
|
||||||
|
*.pdf -text -diff
|
||||||
|
*.ppm -text -diff
|
56
external/libwebp/libwebp/.gitignore
vendored
Normal file
56
external/libwebp/libwebp/.gitignore
vendored
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
*.l[ao]
|
||||||
|
*.[ao]
|
||||||
|
*.pc
|
||||||
|
.DS_Store
|
||||||
|
.deps
|
||||||
|
.idea
|
||||||
|
.libs
|
||||||
|
.vscode
|
||||||
|
/aclocal.m4
|
||||||
|
/ar-lib
|
||||||
|
/autom4te.cache
|
||||||
|
/compile
|
||||||
|
/config.*
|
||||||
|
/configure
|
||||||
|
/depcomp
|
||||||
|
/dist
|
||||||
|
/install-sh
|
||||||
|
/libtool
|
||||||
|
/ltmain.sh
|
||||||
|
/missing
|
||||||
|
/mkinstalldirs
|
||||||
|
/stamp-h1
|
||||||
|
Makefile
|
||||||
|
Makefile.in
|
||||||
|
examples/anim_diff
|
||||||
|
examples/anim_dump
|
||||||
|
examples/[cdv]webp
|
||||||
|
examples/gif2webp
|
||||||
|
examples/img2webp
|
||||||
|
examples/webpinfo
|
||||||
|
examples/webpmux
|
||||||
|
src/webp/config.h*
|
||||||
|
src/webp/stamp-h1
|
||||||
|
/output
|
||||||
|
/doc/output
|
||||||
|
*.idb
|
||||||
|
*.pdb
|
||||||
|
/iosbuild
|
||||||
|
/xcframeworkbuild
|
||||||
|
/WebP*.*framework
|
||||||
|
CMakeCache.txt
|
||||||
|
CMakeFiles/
|
||||||
|
cmake_install.cmake
|
||||||
|
.gradle
|
||||||
|
/build
|
||||||
|
extras/get_disto
|
||||||
|
extras/vwebp_sdl
|
||||||
|
extras/webp_quality
|
||||||
|
tests/fuzzer/advanced_api_fuzzer
|
||||||
|
tests/fuzzer/animation_api_fuzzer
|
||||||
|
tests/fuzzer/animdecoder_fuzzer
|
||||||
|
tests/fuzzer/animencoder_fuzzer
|
||||||
|
tests/fuzzer/demux_api_fuzzer
|
||||||
|
tests/fuzzer/enc_dec_fuzzer
|
||||||
|
tests/fuzzer/mux_demux_api_fuzzer
|
||||||
|
tests/fuzzer/simple_api_fuzzer
|
19
external/libwebp/libwebp/.mailmap
vendored
Normal file
19
external/libwebp/libwebp/.mailmap
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
Johann Koenig <johann.koenig@duck.com>
|
||||||
|
Johann Koenig <johann.koenig@duck.com> <johannkoenig@google.com>
|
||||||
|
Mikołaj Zalewski <mikolajz@google.com>
|
||||||
|
Pascal Massimino <pascal.massimino@gmail.com>
|
||||||
|
Pascal Massimino <pascal.massimino@gmail.com> <skal@google.com>
|
||||||
|
Vikas Arora <vikasa@google.com>
|
||||||
|
<vikasa@google.com> <vikasa@gmail.com>
|
||||||
|
<vikasa@google.com> <vikaas.arora@gmail.com>
|
||||||
|
<slobodan.prijic@imgtec.com> <Slobodan.Prijic@imgtec.com>
|
||||||
|
<vrabaud@google.com> <vincent.rabaud@gmail.com>
|
||||||
|
Vincent Rabaud <vrabaud@google.com>
|
||||||
|
Tamar Levy <tamar.levy@intel.com>
|
||||||
|
<qrczak@google.com> <qrczak>
|
||||||
|
Hui Su <huisu@google.com>
|
||||||
|
James Zern <jzern@google.com>
|
||||||
|
Roberto Alanis <alanisbaez@google.com>
|
||||||
|
Brian Ledger <brianpl@google.com>
|
||||||
|
Maryla Ustarroz-Calonge <maryla@google.com>
|
||||||
|
Yannis Guyon <yguyon@google.com>
|
441
external/libwebp/libwebp/.pylintrc
vendored
Normal file
441
external/libwebp/libwebp/.pylintrc
vendored
Normal file
@ -0,0 +1,441 @@
|
|||||||
|
# This Pylint rcfile contains a best-effort configuration to uphold the
|
||||||
|
# best-practices and style described in the Google Python style guide:
|
||||||
|
# https://google.github.io/styleguide/pyguide.html
|
||||||
|
#
|
||||||
|
# Its canonical open-source location is:
|
||||||
|
# https://google.github.io/styleguide/pylintrc
|
||||||
|
|
||||||
|
[MASTER]
|
||||||
|
|
||||||
|
# Files or directories to be skipped. They should be base names, not paths.
|
||||||
|
ignore=third_party
|
||||||
|
|
||||||
|
# Files or directories matching the regex patterns are skipped. The regex
|
||||||
|
# matches against base names, not paths.
|
||||||
|
ignore-patterns=
|
||||||
|
|
||||||
|
# Pickle collected data for later comparisons.
|
||||||
|
persistent=no
|
||||||
|
|
||||||
|
# List of plugins (as comma separated values of python modules names) to load,
|
||||||
|
# usually to register additional checkers.
|
||||||
|
load-plugins=
|
||||||
|
|
||||||
|
# Use multiple processes to speed up Pylint.
|
||||||
|
jobs=4
|
||||||
|
|
||||||
|
# Allow loading of arbitrary C extensions. Extensions are imported into the
|
||||||
|
# active Python interpreter and may run arbitrary code.
|
||||||
|
unsafe-load-any-extension=no
|
||||||
|
|
||||||
|
|
||||||
|
[MESSAGES CONTROL]
|
||||||
|
|
||||||
|
# Only show warnings with the listed confidence levels. Leave empty to show
|
||||||
|
# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED
|
||||||
|
confidence=
|
||||||
|
|
||||||
|
# Enable the message, report, category or checker with the given id(s). You can
|
||||||
|
# either give multiple identifier separated by comma (,) or put this option
|
||||||
|
# multiple time (only on the command line, not in the configuration file where
|
||||||
|
# it should appear only once). See also the "--disable" option for examples.
|
||||||
|
#enable=
|
||||||
|
|
||||||
|
# Disable the message, report, category or checker with the given id(s). You
|
||||||
|
# can either give multiple identifiers separated by comma (,) or put this
|
||||||
|
# option multiple times (only on the command line, not in the configuration
|
||||||
|
# file where it should appear only once).You can also use "--disable=all" to
|
||||||
|
# disable everything first and then reenable specific checks. For example, if
|
||||||
|
# you want to run only the similarities checker, you can use "--disable=all
|
||||||
|
# --enable=similarities". If you want to run only the classes checker, but have
|
||||||
|
# no Warning level messages displayed, use"--disable=all --enable=classes
|
||||||
|
# --disable=W"
|
||||||
|
disable=abstract-method,
|
||||||
|
apply-builtin,
|
||||||
|
arguments-differ,
|
||||||
|
attribute-defined-outside-init,
|
||||||
|
backtick,
|
||||||
|
bad-option-value,
|
||||||
|
basestring-builtin,
|
||||||
|
buffer-builtin,
|
||||||
|
c-extension-no-member,
|
||||||
|
consider-using-enumerate,
|
||||||
|
cmp-builtin,
|
||||||
|
cmp-method,
|
||||||
|
coerce-builtin,
|
||||||
|
coerce-method,
|
||||||
|
delslice-method,
|
||||||
|
div-method,
|
||||||
|
duplicate-code,
|
||||||
|
eq-without-hash,
|
||||||
|
execfile-builtin,
|
||||||
|
file-builtin,
|
||||||
|
filter-builtin-not-iterating,
|
||||||
|
fixme,
|
||||||
|
getslice-method,
|
||||||
|
global-statement,
|
||||||
|
hex-method,
|
||||||
|
idiv-method,
|
||||||
|
implicit-str-concat-in-sequence,
|
||||||
|
import-error,
|
||||||
|
import-self,
|
||||||
|
import-star-module-level,
|
||||||
|
inconsistent-return-statements,
|
||||||
|
input-builtin,
|
||||||
|
intern-builtin,
|
||||||
|
invalid-str-codec,
|
||||||
|
locally-disabled,
|
||||||
|
long-builtin,
|
||||||
|
long-suffix,
|
||||||
|
map-builtin-not-iterating,
|
||||||
|
misplaced-comparison-constant,
|
||||||
|
missing-function-docstring,
|
||||||
|
metaclass-assignment,
|
||||||
|
next-method-called,
|
||||||
|
next-method-defined,
|
||||||
|
no-absolute-import,
|
||||||
|
no-else-break,
|
||||||
|
no-else-continue,
|
||||||
|
no-else-raise,
|
||||||
|
no-else-return,
|
||||||
|
no-init, # added
|
||||||
|
no-member,
|
||||||
|
no-name-in-module,
|
||||||
|
no-self-use,
|
||||||
|
nonzero-method,
|
||||||
|
oct-method,
|
||||||
|
old-division,
|
||||||
|
old-ne-operator,
|
||||||
|
old-octal-literal,
|
||||||
|
old-raise-syntax,
|
||||||
|
parameter-unpacking,
|
||||||
|
print-statement,
|
||||||
|
raising-string,
|
||||||
|
range-builtin-not-iterating,
|
||||||
|
raw_input-builtin,
|
||||||
|
rdiv-method,
|
||||||
|
reduce-builtin,
|
||||||
|
relative-import,
|
||||||
|
reload-builtin,
|
||||||
|
round-builtin,
|
||||||
|
setslice-method,
|
||||||
|
signature-differs,
|
||||||
|
standarderror-builtin,
|
||||||
|
suppressed-message,
|
||||||
|
sys-max-int,
|
||||||
|
too-few-public-methods,
|
||||||
|
too-many-ancestors,
|
||||||
|
too-many-arguments,
|
||||||
|
too-many-boolean-expressions,
|
||||||
|
too-many-branches,
|
||||||
|
too-many-instance-attributes,
|
||||||
|
too-many-locals,
|
||||||
|
too-many-nested-blocks,
|
||||||
|
too-many-public-methods,
|
||||||
|
too-many-return-statements,
|
||||||
|
too-many-statements,
|
||||||
|
trailing-newlines,
|
||||||
|
unichr-builtin,
|
||||||
|
unicode-builtin,
|
||||||
|
unnecessary-pass,
|
||||||
|
unpacking-in-except,
|
||||||
|
useless-else-on-loop,
|
||||||
|
useless-object-inheritance,
|
||||||
|
useless-suppression,
|
||||||
|
using-cmp-argument,
|
||||||
|
wrong-import-order,
|
||||||
|
xrange-builtin,
|
||||||
|
zip-builtin-not-iterating,
|
||||||
|
|
||||||
|
|
||||||
|
[REPORTS]
|
||||||
|
|
||||||
|
# Set the output format. Available formats are text, parseable, colorized, msvs
|
||||||
|
# (visual studio) and html. You can also give a reporter class, eg
|
||||||
|
# mypackage.mymodule.MyReporterClass.
|
||||||
|
output-format=text
|
||||||
|
|
||||||
|
# Put messages in a separate file for each module / package specified on the
|
||||||
|
# command line instead of printing them on stdout. Reports (if any) will be
|
||||||
|
# written in a file name "pylint_global.[txt|html]". This option is deprecated
|
||||||
|
# and it will be removed in Pylint 2.0.
|
||||||
|
files-output=no
|
||||||
|
|
||||||
|
# Tells whether to display a full report or only the messages
|
||||||
|
reports=no
|
||||||
|
|
||||||
|
# Python expression which should return a note less than 10 (10 is the highest
|
||||||
|
# note). You have access to the variables errors warning, statement which
|
||||||
|
# respectively contain the number of errors / warnings messages and the total
|
||||||
|
# number of statements analyzed. This is used by the global evaluation report
|
||||||
|
# (RP0004).
|
||||||
|
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
|
||||||
|
|
||||||
|
# Template used to display messages. This is a python new-style format string
|
||||||
|
# used to format the message information. See doc for all details
|
||||||
|
#msg-template=
|
||||||
|
|
||||||
|
|
||||||
|
[BASIC]
|
||||||
|
|
||||||
|
# Good variable names which should always be accepted, separated by a comma
|
||||||
|
good-names=main,_,PRESUBMIT
|
||||||
|
|
||||||
|
# Bad variable names which should always be refused, separated by a comma
|
||||||
|
bad-names=
|
||||||
|
|
||||||
|
# Colon-delimited sets of names that determine each other's naming style when
|
||||||
|
# the name regexes allow several styles.
|
||||||
|
name-group=
|
||||||
|
|
||||||
|
# Include a hint for the correct naming format with invalid-name
|
||||||
|
include-naming-hint=no
|
||||||
|
|
||||||
|
# List of decorators that produce properties, such as abc.abstractproperty. Add
|
||||||
|
# to this list to register other decorators that produce valid properties.
|
||||||
|
property-classes=abc.abstractproperty,cached_property.cached_property,cached_property.threaded_cached_property,cached_property.cached_property_with_ttl,cached_property.threaded_cached_property_with_ttl
|
||||||
|
|
||||||
|
# Regular expression matching correct function names
|
||||||
|
function-rgx=^(?:(?P<exempt>setUp|tearDown|setUpModule|tearDownModule)|(?P<camel_case>_?[A-Z][a-zA-Z0-9]*)|(?P<snake_case>_?[a-z][a-z0-9_]*))$
|
||||||
|
|
||||||
|
# Regular expression matching correct variable names
|
||||||
|
variable-rgx=^[a-z][a-z0-9_]*$
|
||||||
|
|
||||||
|
# Regular expression matching correct constant names
|
||||||
|
const-rgx=^(_?[A-Z][A-Z0-9_]*|__[a-z0-9_]+__|_?[a-z][a-z0-9_]*)$
|
||||||
|
|
||||||
|
# Regular expression matching correct attribute names
|
||||||
|
attr-rgx=^_{0,2}[a-z][a-z0-9_]*$
|
||||||
|
|
||||||
|
# Regular expression matching correct argument names
|
||||||
|
argument-rgx=^[a-z][a-z0-9_]*$
|
||||||
|
|
||||||
|
# Regular expression matching correct class attribute names
|
||||||
|
class-attribute-rgx=^(_?[A-Z][A-Z0-9_]*|__[a-z0-9_]+__|_?[a-z][a-z0-9_]*)$
|
||||||
|
|
||||||
|
# Regular expression matching correct inline iteration names
|
||||||
|
inlinevar-rgx=^[a-z][a-z0-9_]*$
|
||||||
|
|
||||||
|
# Regular expression matching correct class names
|
||||||
|
class-rgx=^_?[A-Z][a-zA-Z0-9]*$
|
||||||
|
|
||||||
|
# Regular expression matching correct module names
|
||||||
|
module-rgx=^(_?[a-z][a-z0-9_]*|__init__)$
|
||||||
|
|
||||||
|
# Regular expression matching correct method names
|
||||||
|
method-rgx=(?x)^(?:(?P<exempt>_[a-z0-9_]+__|runTest|setUp|tearDown|setUpTestCase|tearDownTestCase|setupSelf|tearDownClass|setUpClass|(test|assert)_*[A-Z0-9][a-zA-Z0-9_]*|next)|(?P<camel_case>_{0,2}[A-Z][a-zA-Z0-9_]*)|(?P<snake_case>_{0,2}[a-z][a-z0-9_]*))$
|
||||||
|
|
||||||
|
# Regular expression which should only match function or class names that do
|
||||||
|
# not require a docstring.
|
||||||
|
no-docstring-rgx=(__.*__|main|test.*|.*test|.*Test)$
|
||||||
|
|
||||||
|
# Minimum line length for functions/classes that require docstrings, shorter
|
||||||
|
# ones are exempt.
|
||||||
|
docstring-min-length=10
|
||||||
|
|
||||||
|
|
||||||
|
[TYPECHECK]
|
||||||
|
|
||||||
|
# List of decorators that produce context managers, such as
|
||||||
|
# contextlib.contextmanager. Add to this list to register other decorators that
|
||||||
|
# produce valid context managers.
|
||||||
|
contextmanager-decorators=contextlib.contextmanager,contextlib2.contextmanager
|
||||||
|
|
||||||
|
# Tells whether missing members accessed in mixin class should be ignored. A
|
||||||
|
# mixin class is detected if its name ends with "mixin" (case insensitive).
|
||||||
|
ignore-mixin-members=yes
|
||||||
|
|
||||||
|
# List of module names for which member attributes should not be checked
|
||||||
|
# (useful for modules/projects where namespaces are manipulated during runtime
|
||||||
|
# and thus existing member attributes cannot be deduced by static analysis. It
|
||||||
|
# supports qualified module names, as well as Unix pattern matching.
|
||||||
|
ignored-modules=
|
||||||
|
|
||||||
|
# List of class names for which member attributes should not be checked (useful
|
||||||
|
# for classes with dynamically set attributes). This supports the use of
|
||||||
|
# qualified names.
|
||||||
|
ignored-classes=optparse.Values,thread._local,_thread._local
|
||||||
|
|
||||||
|
# List of members which are set dynamically and missed by pylint inference
|
||||||
|
# system, and so shouldn't trigger E1101 when accessed. Python regular
|
||||||
|
# expressions are accepted.
|
||||||
|
generated-members=
|
||||||
|
|
||||||
|
|
||||||
|
[FORMAT]
|
||||||
|
|
||||||
|
# Maximum number of characters on a single line.
|
||||||
|
max-line-length=80
|
||||||
|
|
||||||
|
# TODO(https://github.com/PyCQA/pylint/issues/3352): Direct pylint to exempt
|
||||||
|
# lines made too long by directives to pytype.
|
||||||
|
|
||||||
|
# Regexp for a line that is allowed to be longer than the limit.
|
||||||
|
ignore-long-lines=(?x)(
|
||||||
|
^\s*(\#\ )?<?https?://\S+>?$|
|
||||||
|
^\s*(from\s+\S+\s+)?import\s+.+$)
|
||||||
|
|
||||||
|
# Allow the body of an if to be on the same line as the test if there is no
|
||||||
|
# else.
|
||||||
|
single-line-if-stmt=yes
|
||||||
|
|
||||||
|
# List of optional constructs for which whitespace checking is disabled. `dict-
|
||||||
|
# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
|
||||||
|
# `trailing-comma` allows a space between comma and closing bracket: (a, ).
|
||||||
|
# `empty-line` allows space-only lines.
|
||||||
|
no-space-check=
|
||||||
|
|
||||||
|
# Maximum number of lines in a module
|
||||||
|
max-module-lines=99999
|
||||||
|
|
||||||
|
# String used as indentation unit. The internal Google style guide mandates 2
|
||||||
|
# spaces. Google's externaly-published style guide says 4, consistent with
|
||||||
|
# PEP 8. Here, we use 2 spaces, for conformity with many open-sourced Google
|
||||||
|
# projects (like TensorFlow).
|
||||||
|
indent-string=' '
|
||||||
|
|
||||||
|
# Number of spaces of indent required inside a hanging or continued line.
|
||||||
|
indent-after-paren=4
|
||||||
|
|
||||||
|
# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
|
||||||
|
expected-line-ending-format=
|
||||||
|
|
||||||
|
|
||||||
|
[MISCELLANEOUS]
|
||||||
|
|
||||||
|
# List of note tags to take in consideration, separated by a comma.
|
||||||
|
notes=TODO
|
||||||
|
|
||||||
|
|
||||||
|
[STRING]
|
||||||
|
|
||||||
|
# This flag controls whether inconsistent-quotes generates a warning when the
|
||||||
|
# character used as a quote delimiter is used inconsistently within a module.
|
||||||
|
check-quote-consistency=yes
|
||||||
|
|
||||||
|
|
||||||
|
[VARIABLES]
|
||||||
|
|
||||||
|
# Tells whether we should check for unused import in __init__ files.
|
||||||
|
init-import=no
|
||||||
|
|
||||||
|
# A regular expression matching the name of dummy variables (i.e. expectedly
|
||||||
|
# not used).
|
||||||
|
dummy-variables-rgx=^\*{0,2}(_$|unused_|dummy_)
|
||||||
|
|
||||||
|
# List of additional names supposed to be defined in builtins. Remember that
|
||||||
|
# you should avoid to define new builtins when possible.
|
||||||
|
additional-builtins=
|
||||||
|
|
||||||
|
# List of strings which can identify a callback function by name. A callback
|
||||||
|
# name must start or end with one of those strings.
|
||||||
|
callbacks=cb_,_cb
|
||||||
|
|
||||||
|
# List of qualified module names which can have objects that can redefine
|
||||||
|
# builtins.
|
||||||
|
redefining-builtins-modules=six,six.moves,past.builtins,future.builtins,functools
|
||||||
|
|
||||||
|
|
||||||
|
[LOGGING]
|
||||||
|
|
||||||
|
# Logging modules to check that the string format arguments are in logging
|
||||||
|
# function parameter format
|
||||||
|
logging-modules=logging,absl.logging,tensorflow.io.logging
|
||||||
|
|
||||||
|
|
||||||
|
[SIMILARITIES]
|
||||||
|
|
||||||
|
# Minimum lines number of a similarity.
|
||||||
|
min-similarity-lines=4
|
||||||
|
|
||||||
|
# Ignore comments when computing similarities.
|
||||||
|
ignore-comments=yes
|
||||||
|
|
||||||
|
# Ignore docstrings when computing similarities.
|
||||||
|
ignore-docstrings=yes
|
||||||
|
|
||||||
|
# Ignore imports when computing similarities.
|
||||||
|
ignore-imports=no
|
||||||
|
|
||||||
|
|
||||||
|
[SPELLING]
|
||||||
|
|
||||||
|
# Spelling dictionary name. Available dictionaries: none. To make it working
|
||||||
|
# install python-enchant package.
|
||||||
|
spelling-dict=
|
||||||
|
|
||||||
|
# List of comma separated words that should not be checked.
|
||||||
|
spelling-ignore-words=
|
||||||
|
|
||||||
|
# A path to a file that contains private dictionary; one word per line.
|
||||||
|
spelling-private-dict-file=
|
||||||
|
|
||||||
|
# Tells whether to store unknown words to indicated private dictionary in
|
||||||
|
# --spelling-private-dict-file option instead of raising a message.
|
||||||
|
spelling-store-unknown-words=no
|
||||||
|
|
||||||
|
|
||||||
|
[IMPORTS]
|
||||||
|
|
||||||
|
# Deprecated modules which should not be used, separated by a comma
|
||||||
|
deprecated-modules=regsub,
|
||||||
|
TERMIOS,
|
||||||
|
Bastion,
|
||||||
|
rexec,
|
||||||
|
sets
|
||||||
|
|
||||||
|
# Create a graph of every (i.e. internal and external) dependencies in the
|
||||||
|
# given file (report RP0402 must not be disabled)
|
||||||
|
import-graph=
|
||||||
|
|
||||||
|
# Create a graph of external dependencies in the given file (report RP0402 must
|
||||||
|
# not be disabled)
|
||||||
|
ext-import-graph=
|
||||||
|
|
||||||
|
# Create a graph of internal dependencies in the given file (report RP0402 must
|
||||||
|
# not be disabled)
|
||||||
|
int-import-graph=
|
||||||
|
|
||||||
|
# Force import order to recognize a module as part of the standard
|
||||||
|
# compatibility libraries.
|
||||||
|
known-standard-library=
|
||||||
|
|
||||||
|
# Force import order to recognize a module as part of a third party library.
|
||||||
|
known-third-party=enchant, absl
|
||||||
|
|
||||||
|
# Analyse import fallback blocks. This can be used to support both Python 2 and
|
||||||
|
# 3 compatible code, which means that the block might have code that exists
|
||||||
|
# only in one or another interpreter, leading to false positives when analysed.
|
||||||
|
analyse-fallback-blocks=no
|
||||||
|
|
||||||
|
|
||||||
|
[CLASSES]
|
||||||
|
|
||||||
|
# List of method names used to declare (i.e. assign) instance attributes.
|
||||||
|
defining-attr-methods=__init__,
|
||||||
|
__new__,
|
||||||
|
setUp
|
||||||
|
|
||||||
|
# List of member names, which should be excluded from the protected access
|
||||||
|
# warning.
|
||||||
|
exclude-protected=_asdict,
|
||||||
|
_fields,
|
||||||
|
_replace,
|
||||||
|
_source,
|
||||||
|
_make
|
||||||
|
|
||||||
|
# List of valid names for the first argument in a class method.
|
||||||
|
valid-classmethod-first-arg=cls,
|
||||||
|
class_
|
||||||
|
|
||||||
|
# List of valid names for the first argument in a metaclass class method.
|
||||||
|
valid-metaclass-classmethod-first-arg=mcs
|
||||||
|
|
||||||
|
|
||||||
|
[EXCEPTIONS]
|
||||||
|
|
||||||
|
# Exceptions that will emit a warning when being caught. Defaults to
|
||||||
|
# "Exception"
|
||||||
|
overgeneral-exceptions=StandardError,
|
||||||
|
Exception,
|
||||||
|
BaseException
|
2
external/libwebp/libwebp/.style.yapf
vendored
Normal file
2
external/libwebp/libwebp/.style.yapf
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[style]
|
||||||
|
based_on_style = yapf
|
60
external/libwebp/libwebp/AUTHORS
vendored
Normal file
60
external/libwebp/libwebp/AUTHORS
vendored
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
Contributors:
|
||||||
|
- Aidan O'Loan (aidanol at gmail dot com)
|
||||||
|
- Alan Browning (browning at google dot com)
|
||||||
|
- Alexandru Ardelean (ardeleanalex at gmail dot com)
|
||||||
|
- Brian Ledger (brianpl at google dot com)
|
||||||
|
- Charles Munger (clm at google dot com)
|
||||||
|
- Cheng Yi (cyi at google dot com)
|
||||||
|
- Christian Duvivier (cduvivier at google dot com)
|
||||||
|
- Christopher Degawa (ccom at randomderp dot com)
|
||||||
|
- Clement Courbet (courbet at google dot com)
|
||||||
|
- Djordje Pesut (djordje dot pesut at imgtec dot com)
|
||||||
|
- Frank Barchard (fbarchard at google dot com)
|
||||||
|
- Hui Su (huisu at google dot com)
|
||||||
|
- H. Vetinari (h dot vetinari at gmx dot com)
|
||||||
|
- Ilya Kurdyukov (jpegqs at gmail dot com)
|
||||||
|
- Ingvar Stepanyan (rreverser at google dot com)
|
||||||
|
- James Zern (jzern at google dot com)
|
||||||
|
- Jan Engelhardt (jengelh at medozas dot de)
|
||||||
|
- Jehan (jehan at girinstud dot io)
|
||||||
|
- Jeremy Maitin-Shepard (jbms at google dot com)
|
||||||
|
- Johann Koenig (johann dot koenig at duck dot com)
|
||||||
|
- Jovan Zelincevic (jovan dot zelincevic at imgtec dot com)
|
||||||
|
- Jyrki Alakuijala (jyrki at google dot com)
|
||||||
|
- Konstantin Ivlev (tomskside at gmail dot com)
|
||||||
|
- Lode Vandevenne (lode at google dot com)
|
||||||
|
- Lou Quillio (louquillio at google dot com)
|
||||||
|
- Mans Rullgard (mans at mansr dot com)
|
||||||
|
- Marcin Kowalczyk (qrczak at google dot com)
|
||||||
|
- Martin Olsson (mnemo at minimum dot se)
|
||||||
|
- Maryla Ustarroz-Calonge (maryla at google dot com)
|
||||||
|
- Mikołaj Zalewski (mikolajz at google dot com)
|
||||||
|
- Mislav Bradac (mislavm at google dot com)
|
||||||
|
- Nico Weber (thakis at chromium dot org)
|
||||||
|
- Noel Chromium (noel at chromium dot org)
|
||||||
|
- Nozomi Isozaki (nontan at pixiv dot co dot jp)
|
||||||
|
- Oliver Wolff (oliver dot wolff at qt dot io)
|
||||||
|
- Owen Rodley (orodley at google dot com)
|
||||||
|
- Parag Salasakar (img dot mips1 at gmail dot com)
|
||||||
|
- Pascal Massimino (pascal dot massimino at gmail dot com)
|
||||||
|
- Paweł Hajdan, Jr (phajdan dot jr at chromium dot org)
|
||||||
|
- Pierre Joye (pierre dot php at gmail dot com)
|
||||||
|
- Roberto Alanis (alanisbaez at google dot com)
|
||||||
|
- Sam Clegg (sbc at chromium dot org)
|
||||||
|
- Scott Hancher (seh at google dot com)
|
||||||
|
- Scott LaVarnway (slavarnway at google dot com)
|
||||||
|
- Scott Talbot (s at chikachow dot org)
|
||||||
|
- Slobodan Prijic (slobodan dot prijic at imgtec dot com)
|
||||||
|
- Somnath Banerjee (somnath dot banerjee at gmail dot com)
|
||||||
|
- Sriraman Tallam (tmsriram at google dot com)
|
||||||
|
- Tamar Levy (tamar dot levy at intel dot com)
|
||||||
|
- Thiago Perrotta (tperrotta at google dot com)
|
||||||
|
- Timothy Gu (timothygu99 at gmail dot com)
|
||||||
|
- Urvang Joshi (urvang at google dot com)
|
||||||
|
- Vikas Arora (vikasa at google dot com)
|
||||||
|
- Vincent Rabaud (vrabaud at google dot com)
|
||||||
|
- Vlad Tsyrklevich (vtsyrklevich at chromium dot org)
|
||||||
|
- Wan-Teh Chang (wtc at google dot com)
|
||||||
|
- Yang Zhang (yang dot zhang at arm dot com)
|
||||||
|
- Yannis Guyon (yguyon at google dot com)
|
||||||
|
- Zhi An Ng (zhin at chromium dot org)
|
295
external/libwebp/libwebp/Android.mk
vendored
Normal file
295
external/libwebp/libwebp/Android.mk
vendored
Normal file
@ -0,0 +1,295 @@
|
|||||||
|
# Ignore this file during non-NDK builds.
|
||||||
|
ifdef NDK_ROOT
|
||||||
|
LOCAL_PATH := $(call my-dir)
|
||||||
|
|
||||||
|
WEBP_CFLAGS := -Wall -DANDROID -DHAVE_MALLOC_H -DHAVE_PTHREAD -DWEBP_USE_THREAD
|
||||||
|
WEBP_CFLAGS += -fvisibility=hidden
|
||||||
|
|
||||||
|
ifeq ($(APP_OPTIM),release)
|
||||||
|
WEBP_CFLAGS += -finline-functions -ffast-math \
|
||||||
|
-ffunction-sections -fdata-sections
|
||||||
|
ifeq ($(findstring clang,$(NDK_TOOLCHAIN_VERSION)),)
|
||||||
|
WEBP_CFLAGS += -frename-registers -s
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# mips32 fails to build with clang from r14b
|
||||||
|
# https://bugs.chromium.org/p/webp/issues/detail?id=343
|
||||||
|
ifeq ($(findstring clang,$(NDK_TOOLCHAIN_VERSION)),clang)
|
||||||
|
ifeq ($(TARGET_ARCH),mips)
|
||||||
|
clang_version := $(shell $(TARGET_CC) --version)
|
||||||
|
ifneq ($(findstring clang version 3,$(clang_version)),)
|
||||||
|
WEBP_CFLAGS += -no-integrated-as
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(findstring armeabi-v7a, $(TARGET_ARCH_ABI)),)
|
||||||
|
# Setting LOCAL_ARM_NEON will enable -mfpu=neon which may cause illegal
|
||||||
|
# instructions to be generated for armv7a code. Instead target the neon code
|
||||||
|
# specifically.
|
||||||
|
NEON := c.neon
|
||||||
|
USE_CPUFEATURES := yes
|
||||||
|
WEBP_CFLAGS += -DHAVE_CPU_FEATURES_H
|
||||||
|
else
|
||||||
|
NEON := c
|
||||||
|
endif
|
||||||
|
|
||||||
|
sharpyuv_srcs := \
|
||||||
|
sharpyuv/sharpyuv.c \
|
||||||
|
sharpyuv/sharpyuv_cpu.c \
|
||||||
|
sharpyuv/sharpyuv_csp.c \
|
||||||
|
sharpyuv/sharpyuv_dsp.c \
|
||||||
|
sharpyuv/sharpyuv_gamma.c \
|
||||||
|
sharpyuv/sharpyuv_neon.$(NEON) \
|
||||||
|
sharpyuv/sharpyuv_sse2.c \
|
||||||
|
|
||||||
|
dec_srcs := \
|
||||||
|
src/dec/alpha_dec.c \
|
||||||
|
src/dec/buffer_dec.c \
|
||||||
|
src/dec/frame_dec.c \
|
||||||
|
src/dec/idec_dec.c \
|
||||||
|
src/dec/io_dec.c \
|
||||||
|
src/dec/quant_dec.c \
|
||||||
|
src/dec/tree_dec.c \
|
||||||
|
src/dec/vp8_dec.c \
|
||||||
|
src/dec/vp8l_dec.c \
|
||||||
|
src/dec/webp_dec.c \
|
||||||
|
|
||||||
|
demux_srcs := \
|
||||||
|
src/demux/anim_decode.c \
|
||||||
|
src/demux/demux.c \
|
||||||
|
|
||||||
|
dsp_dec_srcs := \
|
||||||
|
src/dsp/alpha_processing.c \
|
||||||
|
src/dsp/alpha_processing_mips_dsp_r2.c \
|
||||||
|
src/dsp/alpha_processing_neon.$(NEON) \
|
||||||
|
src/dsp/alpha_processing_sse2.c \
|
||||||
|
src/dsp/alpha_processing_sse41.c \
|
||||||
|
src/dsp/cpu.c \
|
||||||
|
src/dsp/dec.c \
|
||||||
|
src/dsp/dec_clip_tables.c \
|
||||||
|
src/dsp/dec_mips32.c \
|
||||||
|
src/dsp/dec_mips_dsp_r2.c \
|
||||||
|
src/dsp/dec_msa.c \
|
||||||
|
src/dsp/dec_neon.$(NEON) \
|
||||||
|
src/dsp/dec_sse2.c \
|
||||||
|
src/dsp/dec_sse41.c \
|
||||||
|
src/dsp/filters.c \
|
||||||
|
src/dsp/filters_mips_dsp_r2.c \
|
||||||
|
src/dsp/filters_msa.c \
|
||||||
|
src/dsp/filters_neon.$(NEON) \
|
||||||
|
src/dsp/filters_sse2.c \
|
||||||
|
src/dsp/lossless.c \
|
||||||
|
src/dsp/lossless_mips_dsp_r2.c \
|
||||||
|
src/dsp/lossless_msa.c \
|
||||||
|
src/dsp/lossless_neon.$(NEON) \
|
||||||
|
src/dsp/lossless_sse2.c \
|
||||||
|
src/dsp/lossless_sse41.c \
|
||||||
|
src/dsp/rescaler.c \
|
||||||
|
src/dsp/rescaler_mips32.c \
|
||||||
|
src/dsp/rescaler_mips_dsp_r2.c \
|
||||||
|
src/dsp/rescaler_msa.c \
|
||||||
|
src/dsp/rescaler_neon.$(NEON) \
|
||||||
|
src/dsp/rescaler_sse2.c \
|
||||||
|
src/dsp/upsampling.c \
|
||||||
|
src/dsp/upsampling_mips_dsp_r2.c \
|
||||||
|
src/dsp/upsampling_msa.c \
|
||||||
|
src/dsp/upsampling_neon.$(NEON) \
|
||||||
|
src/dsp/upsampling_sse2.c \
|
||||||
|
src/dsp/upsampling_sse41.c \
|
||||||
|
src/dsp/yuv.c \
|
||||||
|
src/dsp/yuv_mips32.c \
|
||||||
|
src/dsp/yuv_mips_dsp_r2.c \
|
||||||
|
src/dsp/yuv_neon.$(NEON) \
|
||||||
|
src/dsp/yuv_sse2.c \
|
||||||
|
src/dsp/yuv_sse41.c \
|
||||||
|
|
||||||
|
dsp_enc_srcs := \
|
||||||
|
src/dsp/cost.c \
|
||||||
|
src/dsp/cost_mips32.c \
|
||||||
|
src/dsp/cost_mips_dsp_r2.c \
|
||||||
|
src/dsp/cost_neon.$(NEON) \
|
||||||
|
src/dsp/cost_sse2.c \
|
||||||
|
src/dsp/enc.c \
|
||||||
|
src/dsp/enc_mips32.c \
|
||||||
|
src/dsp/enc_mips_dsp_r2.c \
|
||||||
|
src/dsp/enc_msa.c \
|
||||||
|
src/dsp/enc_neon.$(NEON) \
|
||||||
|
src/dsp/enc_sse2.c \
|
||||||
|
src/dsp/enc_sse41.c \
|
||||||
|
src/dsp/lossless_enc.c \
|
||||||
|
src/dsp/lossless_enc_mips32.c \
|
||||||
|
src/dsp/lossless_enc_mips_dsp_r2.c \
|
||||||
|
src/dsp/lossless_enc_msa.c \
|
||||||
|
src/dsp/lossless_enc_neon.$(NEON) \
|
||||||
|
src/dsp/lossless_enc_sse2.c \
|
||||||
|
src/dsp/lossless_enc_sse41.c \
|
||||||
|
src/dsp/ssim.c \
|
||||||
|
src/dsp/ssim_sse2.c \
|
||||||
|
|
||||||
|
enc_srcs := \
|
||||||
|
src/enc/alpha_enc.c \
|
||||||
|
src/enc/analysis_enc.c \
|
||||||
|
src/enc/backward_references_cost_enc.c \
|
||||||
|
src/enc/backward_references_enc.c \
|
||||||
|
src/enc/config_enc.c \
|
||||||
|
src/enc/cost_enc.c \
|
||||||
|
src/enc/filter_enc.c \
|
||||||
|
src/enc/frame_enc.c \
|
||||||
|
src/enc/histogram_enc.c \
|
||||||
|
src/enc/iterator_enc.c \
|
||||||
|
src/enc/near_lossless_enc.c \
|
||||||
|
src/enc/picture_enc.c \
|
||||||
|
src/enc/picture_csp_enc.c \
|
||||||
|
src/enc/picture_psnr_enc.c \
|
||||||
|
src/enc/picture_rescale_enc.c \
|
||||||
|
src/enc/picture_tools_enc.c \
|
||||||
|
src/enc/predictor_enc.c \
|
||||||
|
src/enc/quant_enc.c \
|
||||||
|
src/enc/syntax_enc.c \
|
||||||
|
src/enc/token_enc.c \
|
||||||
|
src/enc/tree_enc.c \
|
||||||
|
src/enc/vp8l_enc.c \
|
||||||
|
src/enc/webp_enc.c \
|
||||||
|
|
||||||
|
mux_srcs := \
|
||||||
|
src/mux/anim_encode.c \
|
||||||
|
src/mux/muxedit.c \
|
||||||
|
src/mux/muxinternal.c \
|
||||||
|
src/mux/muxread.c \
|
||||||
|
|
||||||
|
utils_dec_srcs := \
|
||||||
|
src/utils/bit_reader_utils.c \
|
||||||
|
src/utils/color_cache_utils.c \
|
||||||
|
src/utils/filters_utils.c \
|
||||||
|
src/utils/huffman_utils.c \
|
||||||
|
src/utils/palette.c \
|
||||||
|
src/utils/quant_levels_dec_utils.c \
|
||||||
|
src/utils/random_utils.c \
|
||||||
|
src/utils/rescaler_utils.c \
|
||||||
|
src/utils/thread_utils.c \
|
||||||
|
src/utils/utils.c \
|
||||||
|
|
||||||
|
utils_enc_srcs := \
|
||||||
|
src/utils/bit_writer_utils.c \
|
||||||
|
src/utils/huffman_encode_utils.c \
|
||||||
|
src/utils/quant_levels_utils.c \
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# libwebpdecoder
|
||||||
|
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
|
LOCAL_SRC_FILES := \
|
||||||
|
$(dec_srcs) \
|
||||||
|
$(dsp_dec_srcs) \
|
||||||
|
$(utils_dec_srcs) \
|
||||||
|
|
||||||
|
LOCAL_CFLAGS := $(WEBP_CFLAGS)
|
||||||
|
LOCAL_EXPORT_C_INCLUDES += $(LOCAL_PATH)/src
|
||||||
|
|
||||||
|
# prefer arm over thumb mode for performance gains
|
||||||
|
LOCAL_ARM_MODE := arm
|
||||||
|
|
||||||
|
ifeq ($(USE_CPUFEATURES),yes)
|
||||||
|
LOCAL_STATIC_LIBRARIES := cpufeatures
|
||||||
|
endif
|
||||||
|
|
||||||
|
LOCAL_MODULE := webpdecoder_static
|
||||||
|
|
||||||
|
include $(BUILD_STATIC_LIBRARY)
|
||||||
|
|
||||||
|
ifeq ($(ENABLE_SHARED),1)
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
|
LOCAL_WHOLE_STATIC_LIBRARIES := webpdecoder_static
|
||||||
|
|
||||||
|
LOCAL_MODULE := webpdecoder
|
||||||
|
|
||||||
|
include $(BUILD_SHARED_LIBRARY)
|
||||||
|
endif # ENABLE_SHARED=1
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# libwebp
|
||||||
|
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
|
LOCAL_SRC_FILES := \
|
||||||
|
$(sharpyuv_srcs) \
|
||||||
|
$(dsp_enc_srcs) \
|
||||||
|
$(enc_srcs) \
|
||||||
|
$(utils_enc_srcs) \
|
||||||
|
|
||||||
|
LOCAL_CFLAGS := $(WEBP_CFLAGS)
|
||||||
|
LOCAL_EXPORT_C_INCLUDES += $(LOCAL_PATH)/src $(LOCAL_PATH)
|
||||||
|
|
||||||
|
# prefer arm over thumb mode for performance gains
|
||||||
|
LOCAL_ARM_MODE := arm
|
||||||
|
|
||||||
|
LOCAL_WHOLE_STATIC_LIBRARIES := webpdecoder_static
|
||||||
|
|
||||||
|
LOCAL_MODULE := webp
|
||||||
|
|
||||||
|
ifeq ($(ENABLE_SHARED),1)
|
||||||
|
include $(BUILD_SHARED_LIBRARY)
|
||||||
|
else
|
||||||
|
include $(BUILD_STATIC_LIBRARY)
|
||||||
|
endif
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# libwebpdemux
|
||||||
|
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
|
LOCAL_SRC_FILES := $(demux_srcs)
|
||||||
|
|
||||||
|
LOCAL_CFLAGS := $(WEBP_CFLAGS)
|
||||||
|
LOCAL_EXPORT_C_INCLUDES += $(LOCAL_PATH)/src
|
||||||
|
|
||||||
|
# prefer arm over thumb mode for performance gains
|
||||||
|
LOCAL_ARM_MODE := arm
|
||||||
|
|
||||||
|
LOCAL_MODULE := webpdemux
|
||||||
|
|
||||||
|
ifeq ($(ENABLE_SHARED),1)
|
||||||
|
LOCAL_SHARED_LIBRARIES := webp
|
||||||
|
include $(BUILD_SHARED_LIBRARY)
|
||||||
|
else
|
||||||
|
LOCAL_STATIC_LIBRARIES := webp
|
||||||
|
include $(BUILD_STATIC_LIBRARY)
|
||||||
|
endif
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# libwebpmux
|
||||||
|
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
|
LOCAL_SRC_FILES := $(mux_srcs)
|
||||||
|
|
||||||
|
LOCAL_CFLAGS := $(WEBP_CFLAGS)
|
||||||
|
LOCAL_EXPORT_C_INCLUDES += $(LOCAL_PATH)/src
|
||||||
|
|
||||||
|
# prefer arm over thumb mode for performance gains
|
||||||
|
LOCAL_ARM_MODE := arm
|
||||||
|
|
||||||
|
LOCAL_MODULE := webpmux
|
||||||
|
|
||||||
|
ifeq ($(ENABLE_SHARED),1)
|
||||||
|
LOCAL_SHARED_LIBRARIES := webp
|
||||||
|
include $(BUILD_SHARED_LIBRARY)
|
||||||
|
else
|
||||||
|
LOCAL_STATIC_LIBRARIES := webp
|
||||||
|
include $(BUILD_STATIC_LIBRARY)
|
||||||
|
endif
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
WEBP_SRC_PATH := $(LOCAL_PATH)
|
||||||
|
include $(WEBP_SRC_PATH)/imageio/Android.mk
|
||||||
|
include $(WEBP_SRC_PATH)/examples/Android.mk
|
||||||
|
|
||||||
|
ifeq ($(USE_CPUFEATURES),yes)
|
||||||
|
$(call import-module,android/cpufeatures)
|
||||||
|
endif
|
||||||
|
endif # NDK_ROOT
|
802
external/libwebp/libwebp/CMakeLists.txt
vendored
Normal file
802
external/libwebp/libwebp/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,802 @@
|
|||||||
|
# Copyright (c) 2020 Google LLC.
|
||||||
|
#
|
||||||
|
# Use of this source code is governed by a BSD-style license
|
||||||
|
# that can be found in the LICENSE file in the root of the source
|
||||||
|
# tree. An additional intellectual property rights grant can be found
|
||||||
|
# in the file PATENTS. All contributing project authors may
|
||||||
|
# be found in the AUTHORS file in the root of the source tree.
|
||||||
|
|
||||||
|
if(APPLE)
|
||||||
|
cmake_minimum_required(VERSION 3.17)
|
||||||
|
else()
|
||||||
|
cmake_minimum_required(VERSION 3.7)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(POLICY CMP0072)
|
||||||
|
cmake_policy(SET CMP0072 NEW)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
project(WebP C)
|
||||||
|
|
||||||
|
# Options for coder / decoder executables.
|
||||||
|
if(BUILD_SHARED_LIBS)
|
||||||
|
set(WEBP_LINK_STATIC_DEFAULT OFF)
|
||||||
|
else()
|
||||||
|
set(WEBP_LINK_STATIC_DEFAULT ON)
|
||||||
|
endif()
|
||||||
|
option(WEBP_LINK_STATIC
|
||||||
|
"Link using static libraries. If OFF, use dynamic libraries."
|
||||||
|
${WEBP_LINK_STATIC_DEFAULT})
|
||||||
|
if(NOT EMSCRIPTEN)
|
||||||
|
# Disable SIMD on Emscripten by default, as it's a new unstable Wasm feature.
|
||||||
|
# Users can still explicitly opt-in to make a SIMD-enabled build.
|
||||||
|
set(WEBP_ENABLE_SIMD_DEFAULT ON)
|
||||||
|
endif()
|
||||||
|
option(WEBP_ENABLE_SIMD "Enable any SIMD optimization."
|
||||||
|
${WEBP_ENABLE_SIMD_DEFAULT})
|
||||||
|
option(WEBP_BUILD_ANIM_UTILS "Build animation utilities." ON)
|
||||||
|
option(WEBP_BUILD_CWEBP "Build the cwebp command line tool." ON)
|
||||||
|
option(WEBP_BUILD_DWEBP "Build the dwebp command line tool." ON)
|
||||||
|
option(WEBP_BUILD_GIF2WEBP "Build the gif2webp conversion tool." ON)
|
||||||
|
option(WEBP_BUILD_IMG2WEBP "Build the img2webp animation tool." ON)
|
||||||
|
option(WEBP_BUILD_VWEBP "Build the vwebp viewer tool." ON)
|
||||||
|
option(WEBP_BUILD_WEBPINFO "Build the webpinfo command line tool." ON)
|
||||||
|
option(WEBP_BUILD_LIBWEBPMUX "Build the libwebpmux library." ON)
|
||||||
|
option(WEBP_BUILD_WEBPMUX "Build the webpmux command line tool." ON)
|
||||||
|
option(WEBP_BUILD_EXTRAS "Build extras." ON)
|
||||||
|
option(WEBP_BUILD_WEBP_JS "Emscripten build of webp.js." OFF)
|
||||||
|
option(WEBP_USE_THREAD "Enable threading support" ON)
|
||||||
|
option(WEBP_NEAR_LOSSLESS "Enable near-lossless encoding" ON)
|
||||||
|
option(WEBP_ENABLE_SWAP_16BIT_CSP "Enable byte swap for 16 bit colorspaces."
|
||||||
|
OFF)
|
||||||
|
set(WEBP_BITTRACE "0" CACHE STRING "Bit trace mode (0=none, 1=bit, 2=bytes)")
|
||||||
|
set_property(CACHE WEBP_BITTRACE PROPERTY STRINGS 0 1 2)
|
||||||
|
|
||||||
|
if(WEBP_LINK_STATIC)
|
||||||
|
if(WIN32)
|
||||||
|
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||||
|
else()
|
||||||
|
set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||||
|
endif()
|
||||||
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
|
# vwebp does not compile on Ubuntu with static libraries so disabling it for
|
||||||
|
# now.
|
||||||
|
set(WEBP_BUILD_VWEBP OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Option needed for handling Unicode file names on Windows.
|
||||||
|
if(WIN32)
|
||||||
|
option(WEBP_UNICODE "Build Unicode executables." ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WEBP_BUILD_WEBP_JS)
|
||||||
|
set(WEBP_BUILD_ANIM_UTILS OFF)
|
||||||
|
set(WEBP_BUILD_CWEBP OFF)
|
||||||
|
set(WEBP_BUILD_DWEBP OFF)
|
||||||
|
set(WEBP_BUILD_GIF2WEBP OFF)
|
||||||
|
set(WEBP_BUILD_IMG2WEBP OFF)
|
||||||
|
set(WEBP_BUILD_VWEBP OFF)
|
||||||
|
set(WEBP_BUILD_WEBPINFO OFF)
|
||||||
|
set(WEBP_BUILD_WEBPMUX OFF)
|
||||||
|
set(WEBP_BUILD_EXTRAS OFF)
|
||||||
|
set(WEBP_USE_THREAD OFF)
|
||||||
|
|
||||||
|
if(WEBP_ENABLE_SIMD)
|
||||||
|
message(NOTICE
|
||||||
|
"wasm2js does not support SIMD, disabling webp.js generation.")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(SHARPYUV_DEP_LIBRARIES)
|
||||||
|
set(SHARPYUV_DEP_INCLUDE_DIRS)
|
||||||
|
set(WEBP_DEP_LIBRARIES)
|
||||||
|
set(WEBP_DEP_INCLUDE_DIRS)
|
||||||
|
|
||||||
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
|
set(CMAKE_BUILD_TYPE "Release"
|
||||||
|
CACHE STRING "Build type: Release, Debug, MinSizeRel or RelWithDebInfo"
|
||||||
|
FORCE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Include dependencies.
|
||||||
|
if(WEBP_BUILD_ANIM_UTILS
|
||||||
|
OR WEBP_BUILD_CWEBP
|
||||||
|
OR WEBP_BUILD_DWEBP
|
||||||
|
OR WEBP_BUILD_EXTRAS
|
||||||
|
OR WEBP_BUILD_GIF2WEBP
|
||||||
|
OR WEBP_BUILD_IMG2WEBP)
|
||||||
|
set(WEBP_FIND_IMG_LIBS TRUE)
|
||||||
|
else()
|
||||||
|
set(WEBP_FIND_IMG_LIBS FALSE)
|
||||||
|
endif()
|
||||||
|
include(cmake/deps.cmake)
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
|
if(BUILD_SHARED_LIBS AND NOT DEFINED CMAKE_INSTALL_RPATH)
|
||||||
|
# Set the rpath to match autoconf/libtool behavior. Note this must be set
|
||||||
|
# before target creation.
|
||||||
|
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# ##############################################################################
|
||||||
|
# Options.
|
||||||
|
if(WEBP_ENABLE_SWAP_16BIT_CSP)
|
||||||
|
add_definitions(-DWEBP_SWAP_16BIT_CSP=1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT WEBP_BITTRACE STREQUAL "0")
|
||||||
|
add_definitions(-DBITTRACE=${WEBP_BITTRACE})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WEBP_UNICODE)
|
||||||
|
# Windows recommends setting both UNICODE and _UNICODE.
|
||||||
|
add_definitions(-DUNICODE -D_UNICODE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(MSVC AND BUILD_SHARED_LIBS)
|
||||||
|
add_definitions(-DWEBP_DLL)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# pkg-config variables used by *.pc.in.
|
||||||
|
set(prefix ${CMAKE_INSTALL_PREFIX})
|
||||||
|
set(exec_prefix "\${prefix}")
|
||||||
|
if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
|
||||||
|
set(libdir "${CMAKE_INSTALL_LIBDIR}")
|
||||||
|
else()
|
||||||
|
set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
|
||||||
|
endif()
|
||||||
|
if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||||
|
set(includedir "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||||
|
else()
|
||||||
|
set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
|
||||||
|
endif()
|
||||||
|
set(PTHREAD_LIBS ${CMAKE_THREAD_LIBS_INIT})
|
||||||
|
set(INSTALLED_LIBRARIES)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
# match the naming convention used by nmake
|
||||||
|
set(webp_libname_prefix "lib")
|
||||||
|
set(CMAKE_SHARED_LIBRARY_PREFIX "${webp_libname_prefix}")
|
||||||
|
set(CMAKE_IMPORT_LIBRARY_PREFIX "${webp_libname_prefix}")
|
||||||
|
set(CMAKE_STATIC_LIBRARY_PREFIX "${webp_libname_prefix}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CMAKE_C_VISIBILITY_PRESET hidden)
|
||||||
|
|
||||||
|
# ##############################################################################
|
||||||
|
# Android only.
|
||||||
|
if(ANDROID)
|
||||||
|
include_directories(${ANDROID_NDK}/sources/android/cpufeatures)
|
||||||
|
add_library(cpufeatures-webp STATIC
|
||||||
|
${ANDROID_NDK}/sources/android/cpufeatures/cpu-features.c)
|
||||||
|
list(APPEND INSTALLED_LIBRARIES cpufeatures-webp)
|
||||||
|
target_link_libraries(cpufeatures-webp dl)
|
||||||
|
set(SHARPYUV_DEP_LIBRARIES ${SHARPYUV_DEP_LIBRARIES} cpufeatures-webp)
|
||||||
|
set(WEBP_DEP_LIBRARIES ${WEBP_DEP_LIBRARIES} cpufeatures-webp)
|
||||||
|
set(cpufeatures_include_dir ${ANDROID_NDK}/sources/android/cpufeatures)
|
||||||
|
set(SHARPYUV_DEP_INCLUDE_DIRS ${SHARPYUV_DEP_INCLUDE_DIRS}
|
||||||
|
${cpufeatures_include_dir})
|
||||||
|
set(WEBP_DEP_INCLUDE_DIRS ${WEBP_DEP_INCLUDE_DIRS} ${cpufeatures_include_dir})
|
||||||
|
add_definitions(-DHAVE_CPU_FEATURES_H=1)
|
||||||
|
set(HAVE_CPU_FEATURES_H 1)
|
||||||
|
else()
|
||||||
|
set(HAVE_CPU_FEATURES_H 0)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
function(configure_pkg_config FILE)
|
||||||
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${FILE}.in"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/${FILE}" @ONLY)
|
||||||
|
|
||||||
|
if(HAVE_MATH_LIBRARY)
|
||||||
|
# MSVC doesn't have libm
|
||||||
|
file(READ ${CMAKE_CURRENT_BINARY_DIR}/${FILE} data)
|
||||||
|
string(REPLACE "-lm" "" data ${data})
|
||||||
|
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${FILE} ${data})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${FILE}"
|
||||||
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# ##############################################################################
|
||||||
|
# WebP source files. Read the Makefile.am to get the source files.
|
||||||
|
|
||||||
|
# We expect the Makefiles to define the sources as defined in the first regex.
|
||||||
|
# E.g.: libimagedec_la_SOURCES = image_dec.c image_dec.h
|
||||||
|
function(parse_Makefile_am FOLDER VAR SRC_REGEX)
|
||||||
|
file(READ ${FOLDER}/Makefile.am MAKEFILE_AM)
|
||||||
|
string(REGEX MATCHALL "${SRC_REGEX}_SOURCES[ ]*\\+?=[ ]+[0-9a-z\\._ ]*"
|
||||||
|
FILES_PER_LINE ${MAKEFILE_AM})
|
||||||
|
set(SRCS ${${VAR}})
|
||||||
|
foreach(FILES ${FILES_PER_LINE})
|
||||||
|
string(FIND ${FILES} "=" OFFSET)
|
||||||
|
math(EXPR OFFSET "${OFFSET} + 2")
|
||||||
|
string(SUBSTRING ${FILES} ${OFFSET} -1 FILES)
|
||||||
|
if(FILES)
|
||||||
|
string(REGEX MATCHALL "[0-9a-z\\._]+" FILES ${FILES})
|
||||||
|
foreach(FILE ${FILES})
|
||||||
|
list(APPEND SRCS ${FOLDER}/${FILE})
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
set(${VAR} ${SRCS} PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
set(WEBP_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||||
|
parse_makefile_am(${WEBP_SRC_DIR}/dec "WEBP_DEC_SRCS" "")
|
||||||
|
parse_makefile_am(${WEBP_SRC_DIR}/demux "WEBP_DEMUX_SRCS" "")
|
||||||
|
parse_makefile_am(${WEBP_SRC_DIR}/dsp "WEBP_DSP_COMMON_SRCS" "COMMON")
|
||||||
|
parse_makefile_am(${WEBP_SRC_DIR}/dsp "WEBP_DSP_ENC_SRCS" "ENC")
|
||||||
|
parse_makefile_am(${WEBP_SRC_DIR}/dsp "WEBP_DSP_ENC_SRCS" "dsp_[^ ]*")
|
||||||
|
parse_makefile_am(${WEBP_SRC_DIR}/dsp "WEBP_DSP_DEC_SRCS" "decode_[^ ]*")
|
||||||
|
parse_makefile_am(${WEBP_SRC_DIR}/enc "WEBP_ENC_SRCS" "")
|
||||||
|
parse_makefile_am(${WEBP_SRC_DIR}/utils "WEBP_UTILS_COMMON_SRCS" "COMMON")
|
||||||
|
parse_makefile_am(${WEBP_SRC_DIR}/utils "WEBP_UTILS_ENC_SRCS" "ENC")
|
||||||
|
parse_makefile_am(${WEBP_SRC_DIR}/utils "WEBP_UTILS_DEC_SRCS" "decode_[^ ]*")
|
||||||
|
|
||||||
|
# Remove the files specific to SIMD we don't use.
|
||||||
|
foreach(FILE ${WEBP_SIMD_FILES_NOT_TO_INCLUDE})
|
||||||
|
list(REMOVE_ITEM WEBP_DSP_ENC_SRCS ${FILE})
|
||||||
|
list(REMOVE_ITEM WEBP_DSP_DEC_SRCS ${FILE})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# Generate the config.h file.
|
||||||
|
configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake/config.h.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/src/webp/config.h @ONLY)
|
||||||
|
add_definitions(-DHAVE_CONFIG_H)
|
||||||
|
|
||||||
|
# Set the version numbers.
|
||||||
|
macro(set_version FILE TARGET_NAME NAME_IN_MAKEFILE)
|
||||||
|
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} SOURCE_FILE)
|
||||||
|
string(REGEX MATCH
|
||||||
|
"${NAME_IN_MAKEFILE}_la_LDFLAGS[^\n]* -version-info [0-9:]+" TMP
|
||||||
|
${SOURCE_FILE})
|
||||||
|
string(REGEX MATCH "[0-9:]+" TMP ${TMP})
|
||||||
|
string(REGEX REPLACE ":" " " LT_VERSION ${TMP})
|
||||||
|
|
||||||
|
# See the libtool docs for more information:
|
||||||
|
# https://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info
|
||||||
|
#
|
||||||
|
# c=<current>, a=<age>, r=<revision>
|
||||||
|
#
|
||||||
|
# libtool generates a .so file as .so.[c-a].a.r, while -version-info c:r:a is
|
||||||
|
# passed to libtool.
|
||||||
|
#
|
||||||
|
# We set FULL = [c-a].a.r and MAJOR = [c-a].
|
||||||
|
separate_arguments(LT_VERSION)
|
||||||
|
list(GET LT_VERSION 0 LT_CURRENT)
|
||||||
|
list(GET LT_VERSION 1 LT_REVISION)
|
||||||
|
list(GET LT_VERSION 2 LT_AGE)
|
||||||
|
math(EXPR LT_CURRENT_MINUS_AGE "${LT_CURRENT} - ${LT_AGE}")
|
||||||
|
|
||||||
|
set_target_properties(
|
||||||
|
${TARGET_NAME}
|
||||||
|
PROPERTIES VERSION ${LT_CURRENT_MINUS_AGE}.${LT_AGE}.${LT_REVISION}
|
||||||
|
SOVERSION ${LT_CURRENT_MINUS_AGE})
|
||||||
|
if(APPLE)
|
||||||
|
# For compatibility, set MACHO_COMPATIBILITY_VERSION and
|
||||||
|
# MACHO_CURRENT_VERSION to match libtool. These properties were introduced
|
||||||
|
# in 3.17:
|
||||||
|
# https://cmake.org/cmake/help/latest/prop_tgt/MACHO_COMPATIBILITY_VERSION.html
|
||||||
|
math(EXPR LIBWEBP_MACHO_COMPATIBILITY_VERSION "${LT_CURRENT} + 1")
|
||||||
|
set_target_properties(
|
||||||
|
${TARGET_NAME}
|
||||||
|
PROPERTIES MACHO_COMPATIBILITY_VERSION
|
||||||
|
${LIBWEBP_MACHO_COMPATIBILITY_VERSION}
|
||||||
|
MACHO_CURRENT_VERSION
|
||||||
|
${LIBWEBP_MACHO_COMPATIBILITY_VERSION}.${LT_REVISION})
|
||||||
|
endif()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
# ##############################################################################
|
||||||
|
# Build the webpdecoder library.
|
||||||
|
|
||||||
|
# Creates a source file with an unused stub function in $CMAKE_BINARY_DIR and
|
||||||
|
# adds it to the specified target. Currently used only with Xcode.
|
||||||
|
#
|
||||||
|
# See also:
|
||||||
|
# https://cmake.org/cmake/help/v3.18/command/add_library.html#object-libraries
|
||||||
|
# "Some native build systems (such as Xcode) may not like targets that have only
|
||||||
|
# object files, so consider adding at least one real source file to any target
|
||||||
|
# that references $<TARGET_OBJECTS:objlib>."
|
||||||
|
function(libwebp_add_stub_file TARGET)
|
||||||
|
set(stub_source_dir "${CMAKE_BINARY_DIR}")
|
||||||
|
set(stub_source_file "${stub_source_dir}/libwebp_${TARGET}_stub.c")
|
||||||
|
set(stub_source_code
|
||||||
|
"// Generated file. DO NOT EDIT!\n"
|
||||||
|
"// C source file created for target ${TARGET}.\n"
|
||||||
|
"void libwebp_${TARGET}_stub_function(void)\;\n"
|
||||||
|
"void libwebp_${TARGET}_stub_function(void) {}\n")
|
||||||
|
file(WRITE "${stub_source_file}" ${stub_source_code})
|
||||||
|
|
||||||
|
target_sources(${TARGET} PRIVATE ${stub_source_file})
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/sharpyuv "WEBP_SHARPYUV_SRCS" "")
|
||||||
|
add_library(sharpyuv ${WEBP_SHARPYUV_SRCS})
|
||||||
|
target_link_libraries(sharpyuv ${SHARPYUV_DEP_LIBRARIES})
|
||||||
|
set_version(sharpyuv/Makefile.am sharpyuv sharpyuv)
|
||||||
|
target_include_directories(
|
||||||
|
sharpyuv PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||||
|
set_target_properties(
|
||||||
|
sharpyuv
|
||||||
|
PROPERTIES PUBLIC_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/sharpyuv/sharpyuv.h;\
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/sharpyuv/sharpyuv_csp.h")
|
||||||
|
configure_pkg_config("sharpyuv/libsharpyuv.pc")
|
||||||
|
install(
|
||||||
|
TARGETS sharpyuv
|
||||||
|
EXPORT ${PROJECT_NAME}Targets
|
||||||
|
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/webp/sharpyuv
|
||||||
|
INCLUDES
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
|
${CMAKE_INSTALL_INCLUDEDIR}/webp
|
||||||
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
# avoid security warnings for e.g., fopen() used in the examples.
|
||||||
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||||
|
else()
|
||||||
|
add_compile_options(-Wall)
|
||||||
|
endif()
|
||||||
|
include_directories(${WEBP_DEP_INCLUDE_DIRS})
|
||||||
|
add_library(webpdecode OBJECT ${WEBP_DEC_SRCS})
|
||||||
|
target_include_directories(webpdecode PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
add_library(webpdspdecode OBJECT ${WEBP_DSP_COMMON_SRCS} ${WEBP_DSP_DEC_SRCS})
|
||||||
|
target_include_directories(webpdspdecode PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
add_library(webputilsdecode OBJECT ${WEBP_UTILS_COMMON_SRCS}
|
||||||
|
${WEBP_UTILS_DEC_SRCS})
|
||||||
|
target_include_directories(webputilsdecode PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
add_library(
|
||||||
|
webpdecoder $<TARGET_OBJECTS:webpdecode> $<TARGET_OBJECTS:webpdspdecode>
|
||||||
|
$<TARGET_OBJECTS:webputilsdecode>)
|
||||||
|
if(XCODE)
|
||||||
|
libwebp_add_stub_file(webpdecoder)
|
||||||
|
endif()
|
||||||
|
target_link_libraries(webpdecoder ${WEBP_DEP_LIBRARIES})
|
||||||
|
target_include_directories(
|
||||||
|
webpdecoder PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||||
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
||||||
|
set_target_properties(
|
||||||
|
webpdecoder
|
||||||
|
PROPERTIES PUBLIC_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/src/webp/decode.h;\
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/src/webp/types.h")
|
||||||
|
|
||||||
|
configure_pkg_config("src/libwebpdecoder.pc")
|
||||||
|
|
||||||
|
# Build the webp library.
|
||||||
|
add_library(webpencode OBJECT ${WEBP_ENC_SRCS})
|
||||||
|
target_include_directories(
|
||||||
|
webpencode PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||||
|
add_library(webpdsp OBJECT ${WEBP_DSP_COMMON_SRCS} ${WEBP_DSP_DEC_SRCS}
|
||||||
|
${WEBP_DSP_ENC_SRCS})
|
||||||
|
target_include_directories(webpdsp PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
add_library(webputils OBJECT ${WEBP_UTILS_COMMON_SRCS} ${WEBP_UTILS_DEC_SRCS}
|
||||||
|
${WEBP_UTILS_ENC_SRCS})
|
||||||
|
target_include_directories(webputils PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
add_library(webp $<TARGET_OBJECTS:webpdecode> $<TARGET_OBJECTS:webpdsp>
|
||||||
|
$<TARGET_OBJECTS:webpencode> $<TARGET_OBJECTS:webputils>)
|
||||||
|
target_link_libraries(webp sharpyuv)
|
||||||
|
if(XCODE)
|
||||||
|
libwebp_add_stub_file(webp)
|
||||||
|
endif()
|
||||||
|
target_link_libraries(webp ${WEBP_DEP_LIBRARIES})
|
||||||
|
target_include_directories(
|
||||||
|
webp PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
|
||||||
|
$<INSTALL_INTERFACE:include>)
|
||||||
|
set_target_properties(
|
||||||
|
webp
|
||||||
|
PROPERTIES PUBLIC_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/src/webp/decode.h;\
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/src/webp/encode.h;\
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/src/webp/types.h")
|
||||||
|
|
||||||
|
# Make sure the OBJECT libraries are built with position independent code (it is
|
||||||
|
# not ON by default).
|
||||||
|
set_target_properties(webpdecode webpdspdecode webputilsdecode webpencode
|
||||||
|
webpdsp webputils PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||||
|
configure_pkg_config("src/libwebp.pc")
|
||||||
|
|
||||||
|
# Build the webp demux library.
|
||||||
|
add_library(webpdemux ${WEBP_DEMUX_SRCS})
|
||||||
|
target_link_libraries(webpdemux webp)
|
||||||
|
target_include_directories(
|
||||||
|
webpdemux PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
PUBLIC $<INSTALL_INTERFACE:include>)
|
||||||
|
set_target_properties(
|
||||||
|
webpdemux
|
||||||
|
PROPERTIES
|
||||||
|
PUBLIC_HEADER
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/src/webp/decode.h;\
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/src/webp/demux.h;\
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/src/webp/mux_types.h;\
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/src/webp/types.h")
|
||||||
|
|
||||||
|
configure_pkg_config("src/demux/libwebpdemux.pc")
|
||||||
|
|
||||||
|
set_version(src/Makefile.am webp webp)
|
||||||
|
set_version(src/Makefile.am webpdecoder webpdecoder)
|
||||||
|
set_version(src/demux/Makefile.am webpdemux webpdemux)
|
||||||
|
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/configure.ac CONFIGURE_FILE)
|
||||||
|
string(REGEX MATCH "AC_INIT\\([^\n]*\\[[0-9\\.]+\\]" TMP ${CONFIGURE_FILE})
|
||||||
|
string(REGEX MATCH "[0-9\\.]+" PROJECT_VERSION ${TMP})
|
||||||
|
|
||||||
|
# Define the libraries to install.
|
||||||
|
list(APPEND INSTALLED_LIBRARIES webpdecoder webp webpdemux)
|
||||||
|
|
||||||
|
# Deal with SIMD. Change the compile flags for SIMD files we use.
|
||||||
|
list(LENGTH WEBP_SIMD_FILES_TO_INCLUDE WEBP_SIMD_FILES_TO_INCLUDE_LENGTH)
|
||||||
|
math(EXPR WEBP_SIMD_FILES_TO_INCLUDE_RANGE
|
||||||
|
"${WEBP_SIMD_FILES_TO_INCLUDE_LENGTH}-1")
|
||||||
|
|
||||||
|
foreach(I_FILE RANGE ${WEBP_SIMD_FILES_TO_INCLUDE_RANGE})
|
||||||
|
list(GET WEBP_SIMD_FILES_TO_INCLUDE ${I_FILE} FILE)
|
||||||
|
list(GET WEBP_SIMD_FLAGS_TO_INCLUDE ${I_FILE} SIMD_COMPILE_FLAG)
|
||||||
|
set_source_files_properties(${FILE} PROPERTIES COMPILE_FLAGS
|
||||||
|
${SIMD_COMPILE_FLAG})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
if(NOT WEBP_BUILD_LIBWEBPMUX)
|
||||||
|
set(WEBP_BUILD_GIF2WEBP OFF)
|
||||||
|
set(WEBP_BUILD_IMG2WEBP OFF)
|
||||||
|
set(WEBP_BUILD_WEBPMUX OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WEBP_BUILD_GIF2WEBP AND NOT GIF_FOUND)
|
||||||
|
set(WEBP_BUILD_GIF2WEBP OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WEBP_BUILD_ANIM_UTILS AND NOT GIF_FOUND)
|
||||||
|
set(WEBP_BUILD_ANIM_UTILS OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Build the executables if asked for.
|
||||||
|
if(WEBP_BUILD_ANIM_UTILS
|
||||||
|
OR WEBP_BUILD_CWEBP
|
||||||
|
OR WEBP_BUILD_DWEBP
|
||||||
|
OR WEBP_BUILD_GIF2WEBP
|
||||||
|
OR WEBP_BUILD_IMG2WEBP
|
||||||
|
OR WEBP_BUILD_VWEBP
|
||||||
|
OR WEBP_BUILD_WEBPMUX
|
||||||
|
OR WEBP_BUILD_WEBPINFO)
|
||||||
|
# Example utility library.
|
||||||
|
parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/examples "EXAMPLEUTIL_SRCS"
|
||||||
|
"example_util_[^ ]*")
|
||||||
|
list(APPEND EXAMPLEUTIL_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/examples/stopwatch.h)
|
||||||
|
add_library(exampleutil STATIC ${EXAMPLEUTIL_SRCS})
|
||||||
|
target_include_directories(
|
||||||
|
exampleutil PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>)
|
||||||
|
|
||||||
|
parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/imageio "IMAGEIOUTILS_SRCS"
|
||||||
|
"imageio_util_[^ ]*")
|
||||||
|
add_library(imageioutil STATIC ${IMAGEIOUTILS_SRCS})
|
||||||
|
target_link_libraries(imageioutil webp)
|
||||||
|
target_link_libraries(exampleutil imageioutil)
|
||||||
|
|
||||||
|
# Image-decoding utility library.
|
||||||
|
parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/imageio "IMAGEDEC_SRCS"
|
||||||
|
"imagedec_[^ ]*")
|
||||||
|
add_library(imagedec STATIC ${IMAGEDEC_SRCS})
|
||||||
|
target_link_libraries(imagedec imageioutil webpdemux webp
|
||||||
|
${WEBP_DEP_IMG_LIBRARIES})
|
||||||
|
|
||||||
|
# Image-encoding utility library.
|
||||||
|
parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/imageio "IMAGEENC_SRCS"
|
||||||
|
"imageenc_[^ ]*")
|
||||||
|
add_library(imageenc STATIC ${IMAGEENC_SRCS})
|
||||||
|
target_link_libraries(imageenc imageioutil webp)
|
||||||
|
|
||||||
|
set_property(
|
||||||
|
TARGET exampleutil imageioutil imagedec imageenc
|
||||||
|
PROPERTY INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/src)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WEBP_BUILD_DWEBP)
|
||||||
|
# dwebp
|
||||||
|
parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/examples "DWEBP_SRCS" "dwebp")
|
||||||
|
add_executable(dwebp ${DWEBP_SRCS})
|
||||||
|
target_link_libraries(dwebp exampleutil imagedec imageenc)
|
||||||
|
target_include_directories(dwebp PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src)
|
||||||
|
install(TARGETS dwebp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WEBP_BUILD_CWEBP)
|
||||||
|
# cwebp
|
||||||
|
parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/examples "CWEBP_SRCS" "cwebp")
|
||||||
|
add_executable(cwebp ${CWEBP_SRCS})
|
||||||
|
target_link_libraries(cwebp exampleutil imagedec webp)
|
||||||
|
target_include_directories(cwebp PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
install(TARGETS cwebp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WEBP_BUILD_LIBWEBPMUX)
|
||||||
|
parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/src/mux "WEBP_MUX_SRCS" "")
|
||||||
|
add_library(libwebpmux ${WEBP_MUX_SRCS})
|
||||||
|
target_link_libraries(libwebpmux webp)
|
||||||
|
target_include_directories(libwebpmux PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
set_version(src/mux/Makefile.am libwebpmux webpmux)
|
||||||
|
set_target_properties(
|
||||||
|
libwebpmux
|
||||||
|
PROPERTIES PUBLIC_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/src/webp/mux.h;\
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/src/webp/mux_types.h;\
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/src/webp/types.h;")
|
||||||
|
set_target_properties(libwebpmux PROPERTIES OUTPUT_NAME webpmux)
|
||||||
|
list(APPEND INSTALLED_LIBRARIES libwebpmux)
|
||||||
|
configure_pkg_config("src/mux/libwebpmux.pc")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WEBP_BUILD_GIF2WEBP)
|
||||||
|
# gif2webp
|
||||||
|
include_directories(${WEBP_DEP_GIF_INCLUDE_DIRS})
|
||||||
|
parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/examples "GIF2WEBP_SRCS"
|
||||||
|
"gif2webp")
|
||||||
|
add_executable(gif2webp ${GIF2WEBP_SRCS})
|
||||||
|
target_link_libraries(gif2webp exampleutil imageioutil webp libwebpmux
|
||||||
|
${WEBP_DEP_GIF_LIBRARIES})
|
||||||
|
target_include_directories(gif2webp PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src)
|
||||||
|
install(TARGETS gif2webp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WEBP_BUILD_IMG2WEBP)
|
||||||
|
# img2webp
|
||||||
|
include_directories(${WEBP_DEP_IMG_INCLUDE_DIRS})
|
||||||
|
parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/examples "IMG2WEBP_SRCS"
|
||||||
|
"img2webp")
|
||||||
|
add_executable(img2webp ${IMG2WEBP_SRCS})
|
||||||
|
target_link_libraries(img2webp exampleutil imagedec imageioutil webp
|
||||||
|
libwebpmux)
|
||||||
|
target_include_directories(img2webp PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
install(TARGETS img2webp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WEBP_BUILD_VWEBP)
|
||||||
|
# vwebp
|
||||||
|
find_package(GLUT)
|
||||||
|
if(GLUT_FOUND)
|
||||||
|
include_directories(${WEBP_DEP_IMG_INCLUDE_DIRS})
|
||||||
|
parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/examples "VWEBP_SRCS" "vwebp")
|
||||||
|
add_executable(vwebp ${VWEBP_SRCS})
|
||||||
|
target_link_libraries(
|
||||||
|
vwebp
|
||||||
|
${OPENGL_LIBRARIES}
|
||||||
|
exampleutil
|
||||||
|
GLUT::GLUT
|
||||||
|
imageioutil
|
||||||
|
webp
|
||||||
|
webpdemux)
|
||||||
|
target_include_directories(
|
||||||
|
vwebp PRIVATE ${GLUT_INCLUDE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/src
|
||||||
|
${OPENGL_INCLUDE_DIR})
|
||||||
|
install(TARGETS vwebp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
|
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
|
||||||
|
check_c_compiler_flag("-Wno-deprecated-declarations" HAS_NO_DEPRECATED)
|
||||||
|
if(HAS_NO_DEPRECATED)
|
||||||
|
target_compile_options(vwebp PRIVATE "-Wno-deprecated-declarations")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WEBP_BUILD_WEBPINFO)
|
||||||
|
# webpinfo
|
||||||
|
include_directories(${WEBP_DEP_IMG_INCLUDE_DIRS})
|
||||||
|
parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/examples "WEBPINFO_SRCS"
|
||||||
|
"webpinfo")
|
||||||
|
add_executable(webpinfo ${WEBPINFO_SRCS})
|
||||||
|
target_link_libraries(webpinfo exampleutil imageioutil)
|
||||||
|
target_include_directories(webpinfo PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||||
|
install(TARGETS webpinfo RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WEBP_BUILD_WEBPMUX)
|
||||||
|
# webpmux
|
||||||
|
parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/examples "WEBPMUX_SRCS"
|
||||||
|
"webpmux")
|
||||||
|
add_executable(webpmux ${WEBPMUX_SRCS})
|
||||||
|
target_link_libraries(webpmux exampleutil imageioutil libwebpmux webp)
|
||||||
|
target_include_directories(webpmux PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src)
|
||||||
|
install(TARGETS webpmux RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WEBP_BUILD_EXTRAS)
|
||||||
|
set(EXTRAS_MAKEFILE "${CMAKE_CURRENT_SOURCE_DIR}/extras")
|
||||||
|
parse_makefile_am(${EXTRAS_MAKEFILE} "WEBP_EXTRAS_SRCS" "libwebpextras_la")
|
||||||
|
parse_makefile_am(${EXTRAS_MAKEFILE} "GET_DISTO_SRCS" "get_disto")
|
||||||
|
parse_makefile_am(${EXTRAS_MAKEFILE} "WEBP_QUALITY_SRCS" "webp_quality")
|
||||||
|
parse_makefile_am(${EXTRAS_MAKEFILE} "VWEBP_SDL_SRCS" "vwebp_sdl")
|
||||||
|
|
||||||
|
# libextras
|
||||||
|
add_library(extras STATIC ${WEBP_EXTRAS_SRCS})
|
||||||
|
target_include_directories(
|
||||||
|
extras PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||||
|
|
||||||
|
# get_disto
|
||||||
|
add_executable(get_disto ${GET_DISTO_SRCS})
|
||||||
|
target_link_libraries(get_disto imagedec)
|
||||||
|
target_include_directories(get_disto PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/src)
|
||||||
|
|
||||||
|
# webp_quality
|
||||||
|
add_executable(webp_quality ${WEBP_QUALITY_SRCS})
|
||||||
|
target_link_libraries(webp_quality exampleutil imagedec extras)
|
||||||
|
target_include_directories(webp_quality PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
|
# vwebp_sdl
|
||||||
|
find_package(SDL)
|
||||||
|
if(WEBP_BUILD_VWEBP AND SDL_FOUND)
|
||||||
|
add_executable(vwebp_sdl ${VWEBP_SDL_SRCS})
|
||||||
|
target_link_libraries(vwebp_sdl ${SDL_LIBRARY} imageioutil webp)
|
||||||
|
target_include_directories(
|
||||||
|
vwebp_sdl PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/src ${SDL_INCLUDE_DIR})
|
||||||
|
set(WEBP_HAVE_SDL 1)
|
||||||
|
target_compile_definitions(vwebp_sdl PUBLIC WEBP_HAVE_SDL)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WEBP_BUILD_WEBP_JS)
|
||||||
|
# The default stack size changed from 5MB to 64KB in 3.1.27. See
|
||||||
|
# https://crbug.com/webp/614.
|
||||||
|
if(EMSCRIPTEN_VERSION VERSION_GREATER_EQUAL "3.1.27")
|
||||||
|
# TOTAL_STACK size was renamed to STACK_SIZE in 3.1.27. The old name was
|
||||||
|
# kept for compatibility, but prefer the new one in case it is removed in
|
||||||
|
# the future.
|
||||||
|
set(emscripten_stack_size "-sSTACK_SIZE=5MB")
|
||||||
|
else()
|
||||||
|
set(emscripten_stack_size "-sTOTAL_STACK=5MB")
|
||||||
|
endif()
|
||||||
|
# wasm2js does not support SIMD.
|
||||||
|
if(NOT WEBP_ENABLE_SIMD)
|
||||||
|
# JavaScript version
|
||||||
|
add_executable(webp_js ${CMAKE_CURRENT_SOURCE_DIR}/extras/webp_to_sdl.c)
|
||||||
|
target_link_libraries(webp_js webpdecoder SDL)
|
||||||
|
target_include_directories(webp_js PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
set(WEBP_HAVE_SDL 1)
|
||||||
|
set_target_properties(
|
||||||
|
webp_js
|
||||||
|
PROPERTIES LINK_FLAGS "-sWASM=0 ${emscripten_stack_size} \
|
||||||
|
-sEXPORTED_FUNCTIONS=_WebPToSDL -sINVOKE_RUN=0 \
|
||||||
|
-sEXPORTED_RUNTIME_METHODS=cwrap")
|
||||||
|
set_target_properties(webp_js PROPERTIES OUTPUT_NAME webp)
|
||||||
|
target_compile_definitions(webp_js PUBLIC EMSCRIPTEN WEBP_HAVE_SDL)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# WASM version
|
||||||
|
add_executable(webp_wasm ${CMAKE_CURRENT_SOURCE_DIR}/extras/webp_to_sdl.c)
|
||||||
|
target_link_libraries(webp_wasm webpdecoder SDL)
|
||||||
|
target_include_directories(webp_wasm PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
set_target_properties(
|
||||||
|
webp_wasm
|
||||||
|
PROPERTIES LINK_FLAGS "-sWASM=1 ${emscripten_stack_size} \
|
||||||
|
-sEXPORTED_FUNCTIONS=_WebPToSDL -sINVOKE_RUN=0 \
|
||||||
|
-sEXPORTED_RUNTIME_METHODS=cwrap")
|
||||||
|
target_compile_definitions(webp_wasm PUBLIC EMSCRIPTEN WEBP_HAVE_SDL)
|
||||||
|
|
||||||
|
target_compile_definitions(webpdspdecode PUBLIC EMSCRIPTEN)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WEBP_BUILD_ANIM_UTILS)
|
||||||
|
# anim_diff
|
||||||
|
include_directories(${WEBP_DEP_IMG_INCLUDE_DIRS} ${WEBP_DEP_GIF_INCLUDE_DIRS})
|
||||||
|
parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/examples "ANIM_DIFF_SRCS"
|
||||||
|
"anim_diff")
|
||||||
|
add_executable(anim_diff ${ANIM_DIFF_SRCS})
|
||||||
|
target_link_libraries(
|
||||||
|
anim_diff
|
||||||
|
exampleutil
|
||||||
|
imagedec
|
||||||
|
imageenc
|
||||||
|
imageioutil
|
||||||
|
webp
|
||||||
|
webpdemux
|
||||||
|
${WEBP_DEP_GIF_LIBRARIES})
|
||||||
|
target_include_directories(anim_diff PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src)
|
||||||
|
|
||||||
|
# anim_dump
|
||||||
|
include_directories(${WEBP_DEP_IMG_INCLUDE_DIRS} ${WEBP_DEP_GIF_INCLUDE_DIRS})
|
||||||
|
parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/examples "ANIM_DUMP_SRCS"
|
||||||
|
"anim_dump")
|
||||||
|
add_executable(anim_dump ${ANIM_DUMP_SRCS})
|
||||||
|
target_link_libraries(
|
||||||
|
anim_dump
|
||||||
|
exampleutil
|
||||||
|
imagedec
|
||||||
|
imageenc
|
||||||
|
imageioutil
|
||||||
|
webp
|
||||||
|
webpdemux
|
||||||
|
${WEBP_DEP_GIF_LIBRARIES})
|
||||||
|
target_include_directories(anim_dump PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Install the different headers and libraries.
|
||||||
|
install(
|
||||||
|
TARGETS ${INSTALLED_LIBRARIES}
|
||||||
|
EXPORT ${PROJECT_NAME}Targets
|
||||||
|
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/webp
|
||||||
|
INCLUDES
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
|
set(ConfigPackageLocation ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake/)
|
||||||
|
install(EXPORT ${PROJECT_NAME}Targets NAMESPACE ${PROJECT_NAME}::
|
||||||
|
DESTINATION ${ConfigPackageLocation})
|
||||||
|
|
||||||
|
# Create the CMake version file.
|
||||||
|
include(CMakePackageConfigHelpers)
|
||||||
|
write_basic_package_version_file(
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/WebPConfigVersion.cmake"
|
||||||
|
VERSION ${PACKAGE_VERSION} COMPATIBILITY AnyNewerVersion)
|
||||||
|
|
||||||
|
# Create the Config file.
|
||||||
|
include(CMakePackageConfigHelpers)
|
||||||
|
# Fix libwebpmux reference. The target name libwebpmux is used for compatibility
|
||||||
|
# purposes, but the library mentioned in WebPConfig.cmake should be the
|
||||||
|
# unprefixed version. Note string(...) can be replaced with list(TRANSFORM ...)
|
||||||
|
# if cmake_minimum_required is >= 3.12.
|
||||||
|
string(REGEX REPLACE "libwebpmux" "webpmux" INSTALLED_LIBRARIES
|
||||||
|
"${INSTALLED_LIBRARIES}")
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
# For compatibility with nmake, MSVC builds use a custom prefix (lib) that
|
||||||
|
# needs to be included in the library name.
|
||||||
|
string(REGEX REPLACE "[A-Za-z0-9_]+" "${CMAKE_STATIC_LIBRARY_PREFIX}\\0"
|
||||||
|
INSTALLED_LIBRARIES "${INSTALLED_LIBRARIES}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
configure_package_config_file(
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/cmake/WebPConfig.cmake.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/WebPConfig.cmake
|
||||||
|
INSTALL_DESTINATION ${ConfigPackageLocation}
|
||||||
|
PATH_VARS CMAKE_INSTALL_INCLUDEDIR)
|
||||||
|
|
||||||
|
# Install the generated CMake files.
|
||||||
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/WebPConfigVersion.cmake"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/WebPConfig.cmake"
|
||||||
|
DESTINATION ${ConfigPackageLocation})
|
||||||
|
|
||||||
|
# Install the man pages.
|
||||||
|
set(MAN_PAGES
|
||||||
|
cwebp.1
|
||||||
|
dwebp.1
|
||||||
|
gif2webp.1
|
||||||
|
img2webp.1
|
||||||
|
vwebp.1
|
||||||
|
webpmux.1
|
||||||
|
webpinfo.1)
|
||||||
|
set(EXEC_BUILDS
|
||||||
|
"CWEBP"
|
||||||
|
"DWEBP"
|
||||||
|
"GIF2WEBP"
|
||||||
|
"IMG2WEBP"
|
||||||
|
"VWEBP"
|
||||||
|
"WEBPMUX"
|
||||||
|
"WEBPINFO")
|
||||||
|
list(LENGTH MAN_PAGES MAN_PAGES_LENGTH)
|
||||||
|
math(EXPR MAN_PAGES_RANGE "${MAN_PAGES_LENGTH} - 1")
|
||||||
|
|
||||||
|
foreach(I_MAN RANGE ${MAN_PAGES_RANGE})
|
||||||
|
list(GET EXEC_BUILDS ${I_MAN} EXEC_BUILD)
|
||||||
|
if(WEBP_BUILD_${EXEC_BUILD})
|
||||||
|
list(GET MAN_PAGES ${I_MAN} MAN_PAGE)
|
||||||
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/man/${MAN_PAGE}
|
||||||
|
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT doc)
|
||||||
|
endif()
|
||||||
|
endforeach()
|
78
external/libwebp/libwebp/CONTRIBUTING.md
vendored
Normal file
78
external/libwebp/libwebp/CONTRIBUTING.md
vendored
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
# How to Contribute
|
||||||
|
|
||||||
|
We'd love to accept your patches and contributions to this project. There are
|
||||||
|
just a few small guidelines you need to follow.
|
||||||
|
|
||||||
|
## Contributor License Agreement
|
||||||
|
|
||||||
|
Contributions to this project must be accompanied by a Contributor License
|
||||||
|
Agreement. You (or your employer) retain the copyright to your contribution;
|
||||||
|
this simply gives us permission to use and redistribute your contributions as
|
||||||
|
part of the project. Head over to <https://cla.developers.google.com/> to see
|
||||||
|
your current agreements on file or to sign a new one.
|
||||||
|
|
||||||
|
You generally only need to submit a CLA once, so if you've already submitted one
|
||||||
|
(even if it was for a different project), you probably don't need to do it
|
||||||
|
again.
|
||||||
|
|
||||||
|
## Code reviews
|
||||||
|
|
||||||
|
All submissions, including submissions by project members, require review. We
|
||||||
|
use a [Gerrit](https://www.gerritcodereview.com) instance hosted at
|
||||||
|
https://chromium-review.googlesource.com for this purpose.
|
||||||
|
|
||||||
|
## Sending patches
|
||||||
|
|
||||||
|
The basic git workflow for modifying libwebp code and sending for review is:
|
||||||
|
|
||||||
|
1. Get the latest version of the repository locally:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git clone https://chromium.googlesource.com/webm/libwebp && cd libwebp
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Copy the commit-msg script into ./git/hooks (this will add an ID to all of
|
||||||
|
your commits):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
curl -Lo .git/hooks/commit-msg https://chromium-review.googlesource.com/tools/hooks/commit-msg && chmod u+x .git/hooks/commit-msg
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Modify the local copy of libwebp. Make sure the code
|
||||||
|
[builds successfully](https://chromium.googlesource.com/webm/libwebp/+/HEAD/doc/building.md#cmake).
|
||||||
|
|
||||||
|
4. Choose a short and representative commit message:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git commit -a -m "Set commit message here"
|
||||||
|
```
|
||||||
|
|
||||||
|
5. Send the patch for review:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git push https://chromium-review.googlesource.com/webm/libwebp HEAD:refs/for/main
|
||||||
|
```
|
||||||
|
|
||||||
|
Go to https://chromium-review.googlesource.com to view your patch and
|
||||||
|
request a review from the maintainers.
|
||||||
|
|
||||||
|
See the
|
||||||
|
[WebM Project page](https://www.webmproject.org/code/contribute/submitting-patches/)
|
||||||
|
for additional details.
|
||||||
|
|
||||||
|
## Code Style
|
||||||
|
|
||||||
|
The C code style is based on the
|
||||||
|
[Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html) and
|
||||||
|
`clang-format --style=Google`, though this project doesn't use the tool to
|
||||||
|
enforce the formatting.
|
||||||
|
|
||||||
|
CMake files are formatted with
|
||||||
|
[cmake-format](https://cmake-format.readthedocs.io/en/latest/). `cmake-format
|
||||||
|
-i` can be used to format individual files, it will use the settings from
|
||||||
|
`.cmake-format.py`.
|
||||||
|
|
||||||
|
## Community Guidelines
|
||||||
|
|
||||||
|
This project follows
|
||||||
|
[Google's Open Source Community Guidelines](https://opensource.google.com/conduct/).
|
30
external/libwebp/libwebp/COPYING
vendored
Normal file
30
external/libwebp/libwebp/COPYING
vendored
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
Copyright (c) 2010, Google Inc. All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in
|
||||||
|
the documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
|
||||||
|
* Neither the name of Google nor the names of its contributors may
|
||||||
|
be used to endorse or promote products derived from this software
|
||||||
|
without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
4622
external/libwebp/libwebp/ChangeLog
vendored
Normal file
4622
external/libwebp/libwebp/ChangeLog
vendored
Normal file
File diff suppressed because it is too large
Load Diff
9
external/libwebp/libwebp/Makefile.am
vendored
Normal file
9
external/libwebp/libwebp/Makefile.am
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
ACLOCAL_AMFLAGS = -I m4
|
||||||
|
SUBDIRS = sharpyuv src imageio man
|
||||||
|
EXTRA_DIST = COPYING autogen.sh
|
||||||
|
|
||||||
|
if BUILD_EXTRAS
|
||||||
|
SUBDIRS += extras
|
||||||
|
endif
|
||||||
|
|
||||||
|
SUBDIRS += examples
|
528
external/libwebp/libwebp/Makefile.vc
vendored
Normal file
528
external/libwebp/libwebp/Makefile.vc
vendored
Normal file
@ -0,0 +1,528 @@
|
|||||||
|
#
|
||||||
|
# Stem for static libs and DLLs
|
||||||
|
#
|
||||||
|
LIBWEBPDECODER_BASENAME = libwebpdecoder
|
||||||
|
LIBWEBP_BASENAME = libwebp
|
||||||
|
LIBWEBPMUX_BASENAME = libwebpmux
|
||||||
|
LIBWEBPDEMUX_BASENAME = libwebpdemux
|
||||||
|
LIBSHARPYUV_BASENAME = libsharpyuv
|
||||||
|
|
||||||
|
!IFNDEF ARCH
|
||||||
|
!IF ! [ cl 2>&1 | find "x86" > NUL ]
|
||||||
|
ARCH = x86
|
||||||
|
!ELSE IF ! [ cl 2>&1 | find "x64" > NUL ]
|
||||||
|
ARCH = x64
|
||||||
|
!ELSE IF ! [ cl 2>&1 | find "ARM" > NUL ]
|
||||||
|
ARCH = ARM
|
||||||
|
!ELSE
|
||||||
|
!ERROR Unable to auto-detect toolchain architecture! \
|
||||||
|
If cl.exe is in your PATH rerun nmake with ARCH=<arch>.
|
||||||
|
!ENDIF
|
||||||
|
!ENDIF
|
||||||
|
|
||||||
|
!IF "$(ARCH)" == "x86"
|
||||||
|
PLATFORM_LDFLAGS = /SAFESEH
|
||||||
|
!ENDIF
|
||||||
|
|
||||||
|
#############################################################
|
||||||
|
## Nothing more to do below this line!
|
||||||
|
|
||||||
|
NOLOGO = /nologo
|
||||||
|
CCNODBG = cl.exe $(NOLOGO) /O2 /DNDEBUG
|
||||||
|
CCDEBUG = cl.exe $(NOLOGO) /Od /Zi /D_DEBUG /RTC1
|
||||||
|
CFLAGS = /I. /Isrc $(NOLOGO) /W3 /EHsc /c
|
||||||
|
CFLAGS = $(CFLAGS) /DWIN32 /D_CRT_SECURE_NO_WARNINGS /DWIN32_LEAN_AND_MEAN
|
||||||
|
LDFLAGS = /LARGEADDRESSAWARE /MANIFEST:EMBED /NXCOMPAT /DYNAMICBASE
|
||||||
|
LDFLAGS = $(LDFLAGS) $(PLATFORM_LDFLAGS)
|
||||||
|
LNKDLL = link.exe /DLL $(NOLOGO)
|
||||||
|
LNKEXE = link.exe $(NOLOGO)
|
||||||
|
LNKLIB = lib.exe $(NOLOGO)
|
||||||
|
RCNODBG = rc.exe $(NOLOGO) /l"0x0409" # 0x409 = U.S. English
|
||||||
|
RCDEBUG = $(RCNODBG) /D_DEBUG
|
||||||
|
|
||||||
|
!IF "$(ARCH)" == "ARM"
|
||||||
|
CFLAGS = $(CFLAGS) /DWINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP /DWEBP_USE_THREAD
|
||||||
|
!ELSE
|
||||||
|
CFLAGS = $(CFLAGS) /DHAVE_WINCODEC_H /DWEBP_USE_THREAD
|
||||||
|
!ENDIF
|
||||||
|
|
||||||
|
CFGSET = FALSE
|
||||||
|
!IF "$(OBJDIR)" == ""
|
||||||
|
OUTDIR = ..\obj\
|
||||||
|
!ELSE
|
||||||
|
OUTDIR = $(OBJDIR)
|
||||||
|
!ENDIF
|
||||||
|
|
||||||
|
##############################################################
|
||||||
|
# Runtime library configuration
|
||||||
|
!IF "$(RTLIBCFG)" == "static"
|
||||||
|
RTLIB = /MT
|
||||||
|
RTLIBD = /MTd
|
||||||
|
!ELSE IF "$(RTLIBCFG)" == "legacy"
|
||||||
|
RTLIBCFG = static
|
||||||
|
RTLIB = /MT
|
||||||
|
RTLIBD = /MTd
|
||||||
|
CFLAGS = $(CFLAGS) /GS- /arch:IA32
|
||||||
|
!ELSE
|
||||||
|
RTLIB = /MD
|
||||||
|
RTLIBD = /MDd
|
||||||
|
!ENDIF
|
||||||
|
DIRBASE = $(OUTDIR)\$(CFG)\$(ARCH)
|
||||||
|
DIROBJ = $(DIRBASE)\obj
|
||||||
|
DIRLIB = $(DIRBASE)\lib
|
||||||
|
DIRINC = $(DIRBASE)\include
|
||||||
|
DIRBIN = $(DIRBASE)\bin
|
||||||
|
LIBWEBP_PDBNAME = $(DIROBJ)\$(LIBWEBP_BASENAME).pdb
|
||||||
|
OUTPUT_DIRS = $(DIRBIN) $(DIRINC) $(DIRLIB) \
|
||||||
|
$(DIROBJ)\dec \
|
||||||
|
$(DIROBJ)\demux \
|
||||||
|
$(DIROBJ)\dsp \
|
||||||
|
$(DIROBJ)\enc \
|
||||||
|
$(DIROBJ)\examples \
|
||||||
|
$(DIROBJ)\extras \
|
||||||
|
$(DIROBJ)\imageio \
|
||||||
|
$(DIROBJ)\mux \
|
||||||
|
$(DIROBJ)\sharpyuv \
|
||||||
|
$(DIROBJ)\utils \
|
||||||
|
|
||||||
|
# Target configuration
|
||||||
|
!IF "$(CFG)" == "release-static"
|
||||||
|
CC = $(CCNODBG)
|
||||||
|
STATICLIBBUILD = TRUE
|
||||||
|
!ELSE IF "$(CFG)" == "debug-static"
|
||||||
|
CC = $(CCDEBUG)
|
||||||
|
RTLIB = $(RTLIBD)
|
||||||
|
STATICLIBBUILD = TRUE
|
||||||
|
LIBWEBPDECODER_BASENAME = $(LIBWEBPDECODER_BASENAME)_debug
|
||||||
|
LIBWEBP_BASENAME = $(LIBWEBP_BASENAME)_debug
|
||||||
|
LIBWEBPMUX_BASENAME = $(LIBWEBPMUX_BASENAME)_debug
|
||||||
|
LIBWEBPDEMUX_BASENAME = $(LIBWEBPDEMUX_BASENAME)_debug
|
||||||
|
LIBSHARPYUV_BASENAME = $(LIBSHARPYUV_BASENAME)_debug
|
||||||
|
!ELSE IF "$(CFG)" == "release-dynamic"
|
||||||
|
CC = $(CCNODBG)
|
||||||
|
RC = $(RCNODBG)
|
||||||
|
DLLBUILD = TRUE
|
||||||
|
!ELSE IF "$(CFG)" == "debug-dynamic"
|
||||||
|
CC = $(CCDEBUG)
|
||||||
|
RC = $(RCDEBUG)
|
||||||
|
RTLIB = $(RTLIBD)
|
||||||
|
DLLBUILD = TRUE
|
||||||
|
LIBWEBPDECODER_BASENAME = $(LIBWEBPDECODER_BASENAME)_debug
|
||||||
|
LIBWEBP_BASENAME = $(LIBWEBP_BASENAME)_debug
|
||||||
|
LIBWEBPMUX_BASENAME = $(LIBWEBPMUX_BASENAME)_debug
|
||||||
|
LIBWEBPDEMUX_BASENAME = $(LIBWEBPDEMUX_BASENAME)_debug
|
||||||
|
LIBSHARPYUV_BASENAME = $(LIBSHARPYUV_BASENAME)_debug
|
||||||
|
!ENDIF
|
||||||
|
|
||||||
|
!IF "$(STATICLIBBUILD)" == "TRUE"
|
||||||
|
CC = $(CC) $(RTLIB)
|
||||||
|
CFGSET = TRUE
|
||||||
|
LIBWEBPDECODER = $(DIRLIB)\$(LIBWEBPDECODER_BASENAME).lib
|
||||||
|
LIBWEBP = $(DIRLIB)\$(LIBWEBP_BASENAME).lib
|
||||||
|
LIBWEBPMUX = $(DIRLIB)\$(LIBWEBPMUX_BASENAME).lib
|
||||||
|
LIBWEBPDEMUX = $(DIRLIB)\$(LIBWEBPDEMUX_BASENAME).lib
|
||||||
|
LIBSHARPYUV = $(DIRLIB)\$(LIBSHARPYUV_BASENAME).lib
|
||||||
|
!ELSE IF "$(DLLBUILD)" == "TRUE"
|
||||||
|
CC = $(CC) /I$(DIROBJ) $(RTLIB) /DWEBP_DLL
|
||||||
|
LIBWEBPDECODER = $(DIRLIB)\$(LIBWEBPDECODER_BASENAME)_dll.lib
|
||||||
|
LIBWEBP = $(DIRLIB)\$(LIBWEBP_BASENAME)_dll.lib
|
||||||
|
LIBWEBPMUX = $(DIRLIB)\$(LIBWEBPMUX_BASENAME)_dll.lib
|
||||||
|
LIBWEBPDEMUX = $(DIRLIB)\$(LIBWEBPDEMUX_BASENAME)_dll.lib
|
||||||
|
LIBSHARPYUV = $(DIRLIB)\$(LIBSHARPYUV_BASENAME)_dll.lib
|
||||||
|
LIBWEBP_PDBNAME = $(DIROBJ)\$(LIBWEBP_BASENAME)_dll.pdb
|
||||||
|
CFGSET = TRUE
|
||||||
|
!ENDIF
|
||||||
|
|
||||||
|
!IF "$(UNICODE)" == "1"
|
||||||
|
CFLAGS = $(CFLAGS) /D_UNICODE /DUNICODE
|
||||||
|
!ENDIF
|
||||||
|
|
||||||
|
#######################
|
||||||
|
# Usage
|
||||||
|
#
|
||||||
|
!IF "$(CFGSET)" == "FALSE"
|
||||||
|
!MESSAGE Usage: nmake /f Makefile.vc [CFG=<config>]
|
||||||
|
!MESSAGE . [OBJDIR=<path>] [RTLIBCFG=<rtlib>] [UNICODE=1] [<target>]
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE where <config> is one of:
|
||||||
|
!MESSAGE - release-static - release static library
|
||||||
|
!MESSAGE - debug-static - debug static library
|
||||||
|
!MESSAGE - release-dynamic - release dynamic link library (DLL)
|
||||||
|
!MESSAGE - debug-dynamic - debug dynamic link library (DLL)
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE <target> may be:
|
||||||
|
!MESSAGE - clean - perform a clean for CFG
|
||||||
|
!MESSAGE - experimental - build CFG with experimental
|
||||||
|
!MESSAGE . features enabled.
|
||||||
|
!MESSAGE - (empty) - build libwebp-based targets for CFG
|
||||||
|
!MESSAGE - all - build (de)mux-based targets for CFG
|
||||||
|
!MESSAGE - gif2webp - requires libgif & >= VS2013
|
||||||
|
!MESSAGE - anim_diff - requires libgif & >= VS2013
|
||||||
|
!MESSAGE - anim_dump
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE RTLIBCFG controls the runtime library linkage - 'static' or 'dynamic'.
|
||||||
|
!MESSAGE 'legacy' will produce a Windows 2000 compatible library.
|
||||||
|
!MESSAGE OBJDIR is the path where you like to build (obj, bins, etc.),
|
||||||
|
!MESSAGE defaults to ..\obj
|
||||||
|
|
||||||
|
!IF "$(CFG)" != ""
|
||||||
|
!MESSAGE
|
||||||
|
!ERROR please choose a valid configuration instead of "$(CFG)"
|
||||||
|
!ENDIF
|
||||||
|
!ENDIF
|
||||||
|
|
||||||
|
#######################
|
||||||
|
# Rules
|
||||||
|
#
|
||||||
|
!IF "$(CFGSET)" == "TRUE"
|
||||||
|
# A config was provided, so the library can be built.
|
||||||
|
#
|
||||||
|
|
||||||
|
SHARPYUV_OBJS = \
|
||||||
|
$(DIROBJ)\sharpyuv\sharpyuv.obj \
|
||||||
|
$(DIROBJ)\sharpyuv\sharpyuv_cpu.obj \
|
||||||
|
$(DIROBJ)\sharpyuv\sharpyuv_csp.obj \
|
||||||
|
$(DIROBJ)\sharpyuv\sharpyuv_dsp.obj \
|
||||||
|
$(DIROBJ)\sharpyuv\sharpyuv_gamma.obj \
|
||||||
|
$(DIROBJ)\sharpyuv\sharpyuv_neon.obj \
|
||||||
|
$(DIROBJ)\sharpyuv\sharpyuv_sse2.obj \
|
||||||
|
|
||||||
|
DEC_OBJS = \
|
||||||
|
$(DIROBJ)\dec\alpha_dec.obj \
|
||||||
|
$(DIROBJ)\dec\buffer_dec.obj \
|
||||||
|
$(DIROBJ)\dec\frame_dec.obj \
|
||||||
|
$(DIROBJ)\dec\idec_dec.obj \
|
||||||
|
$(DIROBJ)\dec\io_dec.obj \
|
||||||
|
$(DIROBJ)\dec\quant_dec.obj \
|
||||||
|
$(DIROBJ)\dec\tree_dec.obj \
|
||||||
|
$(DIROBJ)\dec\vp8_dec.obj \
|
||||||
|
$(DIROBJ)\dec\vp8l_dec.obj \
|
||||||
|
$(DIROBJ)\dec\webp_dec.obj \
|
||||||
|
|
||||||
|
DEMUX_OBJS = \
|
||||||
|
$(DIROBJ)\demux\anim_decode.obj \
|
||||||
|
$(DIROBJ)\demux\demux.obj \
|
||||||
|
|
||||||
|
DSP_DEC_OBJS = \
|
||||||
|
$(DIROBJ)\dsp\alpha_processing.obj \
|
||||||
|
$(DIROBJ)\dsp\alpha_processing_mips_dsp_r2.obj \
|
||||||
|
$(DIROBJ)\dsp\alpha_processing_neon.obj \
|
||||||
|
$(DIROBJ)\dsp\alpha_processing_sse2.obj \
|
||||||
|
$(DIROBJ)\dsp\alpha_processing_sse41.obj \
|
||||||
|
$(DIROBJ)\dsp\cpu.obj \
|
||||||
|
$(DIROBJ)\dsp\dec.obj \
|
||||||
|
$(DIROBJ)\dsp\dec_clip_tables.obj \
|
||||||
|
$(DIROBJ)\dsp\dec_mips32.obj \
|
||||||
|
$(DIROBJ)\dsp\dec_mips_dsp_r2.obj \
|
||||||
|
$(DIROBJ)\dsp\dec_msa.obj \
|
||||||
|
$(DIROBJ)\dsp\dec_neon.obj \
|
||||||
|
$(DIROBJ)\dsp\dec_sse2.obj \
|
||||||
|
$(DIROBJ)\dsp\dec_sse41.obj \
|
||||||
|
$(DIROBJ)\dsp\filters.obj \
|
||||||
|
$(DIROBJ)\dsp\filters_mips_dsp_r2.obj \
|
||||||
|
$(DIROBJ)\dsp\filters_msa.obj \
|
||||||
|
$(DIROBJ)\dsp\filters_neon.obj \
|
||||||
|
$(DIROBJ)\dsp\filters_sse2.obj \
|
||||||
|
$(DIROBJ)\dsp\lossless.obj \
|
||||||
|
$(DIROBJ)\dsp\lossless_mips_dsp_r2.obj \
|
||||||
|
$(DIROBJ)\dsp\lossless_msa.obj \
|
||||||
|
$(DIROBJ)\dsp\lossless_neon.obj \
|
||||||
|
$(DIROBJ)\dsp\lossless_sse2.obj \
|
||||||
|
$(DIROBJ)\dsp\lossless_sse41.obj \
|
||||||
|
$(DIROBJ)\dsp\rescaler.obj \
|
||||||
|
$(DIROBJ)\dsp\rescaler_mips32.obj \
|
||||||
|
$(DIROBJ)\dsp\rescaler_mips_dsp_r2.obj \
|
||||||
|
$(DIROBJ)\dsp\rescaler_msa.obj \
|
||||||
|
$(DIROBJ)\dsp\rescaler_neon.obj \
|
||||||
|
$(DIROBJ)\dsp\rescaler_sse2.obj \
|
||||||
|
$(DIROBJ)\dsp\upsampling.obj \
|
||||||
|
$(DIROBJ)\dsp\upsampling_mips_dsp_r2.obj \
|
||||||
|
$(DIROBJ)\dsp\upsampling_msa.obj \
|
||||||
|
$(DIROBJ)\dsp\upsampling_neon.obj \
|
||||||
|
$(DIROBJ)\dsp\upsampling_sse2.obj \
|
||||||
|
$(DIROBJ)\dsp\upsampling_sse41.obj \
|
||||||
|
$(DIROBJ)\dsp\yuv.obj \
|
||||||
|
$(DIROBJ)\dsp\yuv_mips32.obj \
|
||||||
|
$(DIROBJ)\dsp\yuv_mips_dsp_r2.obj \
|
||||||
|
$(DIROBJ)\dsp\yuv_neon.obj \
|
||||||
|
$(DIROBJ)\dsp\yuv_sse2.obj \
|
||||||
|
$(DIROBJ)\dsp\yuv_sse41.obj \
|
||||||
|
|
||||||
|
DSP_ENC_OBJS = \
|
||||||
|
$(DIROBJ)\dsp\cost.obj \
|
||||||
|
$(DIROBJ)\dsp\cost_mips32.obj \
|
||||||
|
$(DIROBJ)\dsp\cost_mips_dsp_r2.obj \
|
||||||
|
$(DIROBJ)\dsp\cost_neon.obj \
|
||||||
|
$(DIROBJ)\dsp\cost_sse2.obj \
|
||||||
|
$(DIROBJ)\dsp\enc.obj \
|
||||||
|
$(DIROBJ)\dsp\enc_mips32.obj \
|
||||||
|
$(DIROBJ)\dsp\enc_mips_dsp_r2.obj \
|
||||||
|
$(DIROBJ)\dsp\enc_msa.obj \
|
||||||
|
$(DIROBJ)\dsp\enc_neon.obj \
|
||||||
|
$(DIROBJ)\dsp\enc_sse2.obj \
|
||||||
|
$(DIROBJ)\dsp\enc_sse41.obj \
|
||||||
|
$(DIROBJ)\dsp\lossless_enc.obj \
|
||||||
|
$(DIROBJ)\dsp\lossless_enc_mips32.obj \
|
||||||
|
$(DIROBJ)\dsp\lossless_enc_mips_dsp_r2.obj \
|
||||||
|
$(DIROBJ)\dsp\lossless_enc_msa.obj \
|
||||||
|
$(DIROBJ)\dsp\lossless_enc_neon.obj \
|
||||||
|
$(DIROBJ)\dsp\lossless_enc_sse2.obj \
|
||||||
|
$(DIROBJ)\dsp\lossless_enc_sse41.obj \
|
||||||
|
$(DIROBJ)\dsp\ssim.obj \
|
||||||
|
$(DIROBJ)\dsp\ssim_sse2.obj \
|
||||||
|
|
||||||
|
EX_ANIM_UTIL_OBJS = \
|
||||||
|
$(DIROBJ)\examples\anim_util.obj \
|
||||||
|
|
||||||
|
IMAGEIO_DEC_OBJS = \
|
||||||
|
$(DIROBJ)\imageio\image_dec.obj \
|
||||||
|
$(DIROBJ)\imageio\jpegdec.obj \
|
||||||
|
$(DIROBJ)\imageio\metadata.obj \
|
||||||
|
$(DIROBJ)\imageio\pngdec.obj \
|
||||||
|
$(DIROBJ)\imageio\pnmdec.obj \
|
||||||
|
$(DIROBJ)\imageio\tiffdec.obj \
|
||||||
|
$(DIROBJ)\imageio\webpdec.obj \
|
||||||
|
$(DIROBJ)\imageio\wicdec.obj \
|
||||||
|
|
||||||
|
IMAGEIO_ENC_OBJS = \
|
||||||
|
$(DIROBJ)\imageio\image_enc.obj \
|
||||||
|
|
||||||
|
EX_GIF_DEC_OBJS = \
|
||||||
|
$(DIROBJ)\examples\gifdec.obj \
|
||||||
|
|
||||||
|
EX_UTIL_OBJS = \
|
||||||
|
$(DIROBJ)\examples\example_util.obj \
|
||||||
|
|
||||||
|
ENC_OBJS = \
|
||||||
|
$(DIROBJ)\enc\alpha_enc.obj \
|
||||||
|
$(DIROBJ)\enc\analysis_enc.obj \
|
||||||
|
$(DIROBJ)\enc\backward_references_cost_enc.obj \
|
||||||
|
$(DIROBJ)\enc\backward_references_enc.obj \
|
||||||
|
$(DIROBJ)\enc\config_enc.obj \
|
||||||
|
$(DIROBJ)\enc\cost_enc.obj \
|
||||||
|
$(DIROBJ)\enc\filter_enc.obj \
|
||||||
|
$(DIROBJ)\enc\frame_enc.obj \
|
||||||
|
$(DIROBJ)\enc\histogram_enc.obj \
|
||||||
|
$(DIROBJ)\enc\iterator_enc.obj \
|
||||||
|
$(DIROBJ)\enc\near_lossless_enc.obj \
|
||||||
|
$(DIROBJ)\enc\picture_enc.obj \
|
||||||
|
$(DIROBJ)\enc\picture_csp_enc.obj \
|
||||||
|
$(DIROBJ)\enc\picture_psnr_enc.obj \
|
||||||
|
$(DIROBJ)\enc\picture_rescale_enc.obj \
|
||||||
|
$(DIROBJ)\enc\picture_tools_enc.obj \
|
||||||
|
$(DIROBJ)\enc\predictor_enc.obj \
|
||||||
|
$(DIROBJ)\enc\quant_enc.obj \
|
||||||
|
$(DIROBJ)\enc\syntax_enc.obj \
|
||||||
|
$(DIROBJ)\enc\token_enc.obj \
|
||||||
|
$(DIROBJ)\enc\tree_enc.obj \
|
||||||
|
$(DIROBJ)\enc\vp8l_enc.obj \
|
||||||
|
$(DIROBJ)\enc\webp_enc.obj \
|
||||||
|
|
||||||
|
EXTRAS_OBJS = \
|
||||||
|
$(DIROBJ)\extras\extras.obj \
|
||||||
|
$(DIROBJ)\extras\quality_estimate.obj \
|
||||||
|
|
||||||
|
IMAGEIO_UTIL_OBJS = \
|
||||||
|
$(DIROBJ)\imageio\imageio_util.obj \
|
||||||
|
|
||||||
|
MUX_OBJS = \
|
||||||
|
$(DIROBJ)\mux\anim_encode.obj \
|
||||||
|
$(DIROBJ)\mux\muxedit.obj \
|
||||||
|
$(DIROBJ)\mux\muxinternal.obj \
|
||||||
|
$(DIROBJ)\mux\muxread.obj \
|
||||||
|
|
||||||
|
UTILS_DEC_OBJS = \
|
||||||
|
$(DIROBJ)\utils\bit_reader_utils.obj \
|
||||||
|
$(DIROBJ)\utils\color_cache_utils.obj \
|
||||||
|
$(DIROBJ)\utils\filters_utils.obj \
|
||||||
|
$(DIROBJ)\utils\huffman_utils.obj \
|
||||||
|
$(DIROBJ)\utils\palette.obj \
|
||||||
|
$(DIROBJ)\utils\quant_levels_dec_utils.obj \
|
||||||
|
$(DIROBJ)\utils\rescaler_utils.obj \
|
||||||
|
$(DIROBJ)\utils\random_utils.obj \
|
||||||
|
$(DIROBJ)\utils\thread_utils.obj \
|
||||||
|
$(DIROBJ)\utils\utils.obj \
|
||||||
|
|
||||||
|
UTILS_ENC_OBJS = \
|
||||||
|
$(DIROBJ)\utils\bit_writer_utils.obj \
|
||||||
|
$(DIROBJ)\utils\huffman_encode_utils.obj \
|
||||||
|
$(DIROBJ)\utils\quant_levels_utils.obj \
|
||||||
|
|
||||||
|
LIBWEBPDECODER_OBJS = $(DEC_OBJS) $(DSP_DEC_OBJS) $(UTILS_DEC_OBJS)
|
||||||
|
LIBWEBP_OBJS = $(LIBWEBPDECODER_OBJS) $(ENC_OBJS) \
|
||||||
|
$(DSP_ENC_OBJS) $(UTILS_ENC_OBJS) $(DLL_OBJS)
|
||||||
|
LIBWEBPMUX_OBJS = $(MUX_OBJS) $(LIBWEBPMUX_OBJS)
|
||||||
|
LIBWEBPDEMUX_OBJS = $(DEMUX_OBJS) $(LIBWEBPDEMUX_OBJS)
|
||||||
|
LIBSHARPYUV_OBJS = $(SHARPYUV_OBJS)
|
||||||
|
|
||||||
|
OUT_LIBS = $(LIBWEBPDECODER) $(LIBWEBP) $(LIBSHARPYUV)
|
||||||
|
!IF "$(ARCH)" == "ARM"
|
||||||
|
ex: $(OUT_LIBS)
|
||||||
|
all: ex
|
||||||
|
!ELSE
|
||||||
|
OUT_EXAMPLES = $(DIRBIN)\cwebp.exe $(DIRBIN)\dwebp.exe
|
||||||
|
EXTRA_EXAMPLES = $(DIRBIN)\vwebp.exe $(DIRBIN)\webpmux.exe \
|
||||||
|
$(DIRBIN)\img2webp.exe $(DIRBIN)\get_disto.exe \
|
||||||
|
$(DIRBIN)\webp_quality.exe $(DIRBIN)\vwebp_sdl.exe \
|
||||||
|
$(DIRBIN)\webpinfo.exe
|
||||||
|
|
||||||
|
ex: $(OUT_LIBS) $(OUT_EXAMPLES)
|
||||||
|
all: ex $(EXTRA_EXAMPLES)
|
||||||
|
# NB: gif2webp.exe and anim_diff.exe are excluded from 'all' as libgif requires
|
||||||
|
# C99 support which is only available from VS2013 onward.
|
||||||
|
gif2webp: $(DIRBIN)\gif2webp.exe
|
||||||
|
anim_diff: $(DIRBIN)\anim_diff.exe
|
||||||
|
anim_dump: $(DIRBIN)\anim_dump.exe
|
||||||
|
|
||||||
|
$(DIRBIN)\anim_diff.exe: $(DIROBJ)\examples\anim_diff.obj $(EX_ANIM_UTIL_OBJS)
|
||||||
|
$(DIRBIN)\anim_diff.exe: $(EX_UTIL_OBJS) $(IMAGEIO_UTIL_OBJS)
|
||||||
|
$(DIRBIN)\anim_diff.exe: $(EX_GIF_DEC_OBJS) $(LIBWEBPDEMUX) $(LIBWEBP)
|
||||||
|
$(DIRBIN)\anim_dump.exe: $(DIROBJ)\examples\anim_dump.obj $(EX_ANIM_UTIL_OBJS)
|
||||||
|
$(DIRBIN)\anim_dump.exe: $(EX_UTIL_OBJS) $(IMAGEIO_UTIL_OBJS)
|
||||||
|
$(DIRBIN)\anim_dump.exe: $(EX_GIF_DEC_OBJS) $(LIBWEBPDEMUX) $(LIBWEBP)
|
||||||
|
$(DIRBIN)\anim_dump.exe: $(IMAGEIO_ENC_OBJS)
|
||||||
|
$(DIRBIN)\cwebp.exe: $(DIROBJ)\examples\cwebp.obj $(IMAGEIO_DEC_OBJS)
|
||||||
|
$(DIRBIN)\cwebp.exe: $(IMAGEIO_UTIL_OBJS)
|
||||||
|
$(DIRBIN)\cwebp.exe: $(LIBWEBPDEMUX) $(LIBSHARPYUV)
|
||||||
|
$(DIRBIN)\dwebp.exe: $(DIROBJ)\examples\dwebp.obj $(IMAGEIO_DEC_OBJS)
|
||||||
|
$(DIRBIN)\dwebp.exe: $(IMAGEIO_ENC_OBJS)
|
||||||
|
$(DIRBIN)\dwebp.exe: $(IMAGEIO_UTIL_OBJS)
|
||||||
|
$(DIRBIN)\dwebp.exe: $(LIBWEBPDEMUX)
|
||||||
|
$(DIRBIN)\gif2webp.exe: $(DIROBJ)\examples\gif2webp.obj $(EX_GIF_DEC_OBJS)
|
||||||
|
$(DIRBIN)\gif2webp.exe: $(EX_UTIL_OBJS) $(IMAGEIO_UTIL_OBJS) $(LIBWEBPMUX)
|
||||||
|
$(DIRBIN)\gif2webp.exe: $(LIBWEBP)
|
||||||
|
$(DIRBIN)\vwebp.exe: $(DIROBJ)\examples\vwebp.obj $(EX_UTIL_OBJS)
|
||||||
|
$(DIRBIN)\vwebp.exe: $(IMAGEIO_UTIL_OBJS) $(LIBWEBPDEMUX) $(LIBWEBP)
|
||||||
|
$(DIRBIN)\vwebp_sdl.exe: $(DIROBJ)\extras\vwebp_sdl.obj
|
||||||
|
$(DIRBIN)\vwebp_sdl.exe: $(DIROBJ)\extras\webp_to_sdl.obj
|
||||||
|
$(DIRBIN)\vwebp_sdl.exe: $(IMAGEIO_UTIL_OBJS) $(LIBWEBP)
|
||||||
|
$(DIRBIN)\webpmux.exe: $(DIROBJ)\examples\webpmux.obj $(LIBWEBPMUX)
|
||||||
|
$(DIRBIN)\webpmux.exe: $(EX_UTIL_OBJS) $(IMAGEIO_UTIL_OBJS) $(LIBWEBP)
|
||||||
|
$(DIRBIN)\img2webp.exe: $(DIROBJ)\examples\img2webp.obj $(LIBWEBPMUX)
|
||||||
|
$(DIRBIN)\img2webp.exe: $(IMAGEIO_DEC_OBJS)
|
||||||
|
$(DIRBIN)\img2webp.exe: $(EX_UTIL_OBJS) $(IMAGEIO_UTIL_OBJS)
|
||||||
|
$(DIRBIN)\img2webp.exe: $(LIBWEBPDEMUX) $(LIBWEBP) $(LIBSHARPYUV)
|
||||||
|
$(DIRBIN)\get_disto.exe: $(DIROBJ)\extras\get_disto.obj
|
||||||
|
$(DIRBIN)\get_disto.exe: $(IMAGEIO_DEC_OBJS) $(IMAGEIO_UTIL_OBJS)
|
||||||
|
$(DIRBIN)\get_disto.exe: $(LIBWEBPDEMUX) $(LIBWEBP)
|
||||||
|
$(DIRBIN)\webp_quality.exe: $(DIROBJ)\extras\webp_quality.obj
|
||||||
|
$(DIRBIN)\webp_quality.exe: $(IMAGEIO_UTIL_OBJS)
|
||||||
|
$(DIRBIN)\webp_quality.exe: $(EXTRAS_OBJS)
|
||||||
|
# EXTRA_OBJS requires private symbols from dsp. Explicitly add those when
|
||||||
|
# building libwebp as a dll.
|
||||||
|
!IF "$(DLLBUILD)" == "TRUE"
|
||||||
|
$(DIRBIN)\webp_quality.exe: $(DSP_DEC_OBJS)
|
||||||
|
!ENDIF
|
||||||
|
$(DIRBIN)\webp_quality.exe: $(LIBWEBP)
|
||||||
|
$(DIRBIN)\webpinfo.exe: $(DIROBJ)\examples\webpinfo.obj
|
||||||
|
$(DIRBIN)\webpinfo.exe: $(IMAGEIO_DEC_OBJS)
|
||||||
|
$(DIRBIN)\webpinfo.exe: $(EX_UTIL_OBJS) $(IMAGEIO_UTIL_OBJS)
|
||||||
|
$(DIRBIN)\webpinfo.exe: $(LIBWEBPDEMUX) $(LIBWEBP)
|
||||||
|
|
||||||
|
$(OUT_EXAMPLES): $(EX_UTIL_OBJS) $(LIBWEBP)
|
||||||
|
$(EX_UTIL_OBJS) $(IMAGEIO_UTIL_OBJS): $(OUTPUT_DIRS)
|
||||||
|
$(IMAGEIO_DEC_OBJS) $(IMAGEIO_ENC_OBJS) $(EXTRAS_OBJS): $(OUTPUT_DIRS)
|
||||||
|
!ENDIF # ARCH == ARM
|
||||||
|
|
||||||
|
$(LIBSHARPYUV): $(LIBSHARPYUV_OBJS)
|
||||||
|
$(LIBWEBPDECODER): $(LIBWEBPDECODER_OBJS)
|
||||||
|
$(LIBWEBP): $(LIBWEBP_OBJS) $(LIBSHARPYUV)
|
||||||
|
$(LIBWEBPMUX): $(LIBWEBPMUX_OBJS)
|
||||||
|
$(LIBWEBPDEMUX): $(LIBWEBPDEMUX_OBJS)
|
||||||
|
|
||||||
|
$(LIBWEBP_OBJS) $(LIBWEBPMUX_OBJS) $(LIBWEBPDEMUX_OBJS) $(LIBSHARPYUV_OBJS): \
|
||||||
|
$(OUTPUT_DIRS)
|
||||||
|
|
||||||
|
!IF "$(DLLBUILD)" == "TRUE"
|
||||||
|
{$(DIROBJ)}.c{$(DIROBJ)}.obj:
|
||||||
|
$(CC) $(CFLAGS) /Fd$(LIBWEBP_PDBNAME) /Fo$@ $<
|
||||||
|
|
||||||
|
{src}.rc{$(DIROBJ)}.res:
|
||||||
|
$(RC) /fo$@ $<
|
||||||
|
{src\demux}.rc{$(DIROBJ)\demux}.res:
|
||||||
|
$(RC) /fo$@ $<
|
||||||
|
{src\mux}.rc{$(DIROBJ)\mux}.res:
|
||||||
|
$(RC) /fo$@ $<
|
||||||
|
{sharpyuv}.rc{$(DIROBJ)\sharpyuv}.res:
|
||||||
|
$(RC) /fo$@ $<
|
||||||
|
|
||||||
|
$(LIBSHARPYUV): $(DIROBJ)\sharpyuv\$(LIBSHARPYUV_BASENAME:_debug=).res
|
||||||
|
$(LIBWEBP): $(LIBSHARPYUV) $(DIROBJ)\$(LIBWEBP_BASENAME:_debug=).res
|
||||||
|
$(LIBWEBPDECODER): $(DIROBJ)\$(LIBWEBPDECODER_BASENAME:_debug=).res
|
||||||
|
$(LIBWEBPMUX): $(LIBWEBP) $(DIROBJ)\mux\$(LIBWEBPMUX_BASENAME:_debug=).res
|
||||||
|
$(LIBWEBPDEMUX): $(LIBWEBP) $(DIROBJ)\demux\$(LIBWEBPDEMUX_BASENAME:_debug=).res
|
||||||
|
|
||||||
|
$(LIBWEBPDECODER) $(LIBWEBP) $(LIBWEBPMUX) $(LIBWEBPDEMUX) $(LIBSHARPYUV):
|
||||||
|
$(LNKDLL) /out:$(DIRBIN)\$(@B:_dll=.dll) /implib:$@ $(LFLAGS) $**
|
||||||
|
-xcopy $(DIROBJ)\*.pdb $(DIRLIB) /y
|
||||||
|
!ELSE
|
||||||
|
$(LIBWEBPDECODER) $(LIBWEBP) $(LIBWEBPMUX) $(LIBWEBPDEMUX) $(LIBSHARPYUV):
|
||||||
|
$(LNKLIB) /out:$@ $**
|
||||||
|
-xcopy $(DIROBJ)\*.pdb $(DIRLIB) /y
|
||||||
|
!ENDIF
|
||||||
|
|
||||||
|
$(OUTPUT_DIRS):
|
||||||
|
@if not exist "$(@)" mkdir "$(@)"
|
||||||
|
|
||||||
|
.SUFFIXES: .c .obj .res .exe
|
||||||
|
# File-specific flag builds. Note batch rules take precedence over wildcards,
|
||||||
|
# so for now name each file individually.
|
||||||
|
$(DIROBJ)\examples\anim_diff.obj: examples\anim_diff.c
|
||||||
|
$(CC) $(CFLAGS) /DWEBP_HAVE_GIF /Fd$(LIBWEBP_PDBNAME) \
|
||||||
|
/Fo$(DIROBJ)\examples\ examples\$(@B).c
|
||||||
|
$(DIROBJ)\examples\anim_dump.obj: examples\anim_dump.c
|
||||||
|
$(CC) $(CFLAGS) /DWEBP_HAVE_GIF /Fd$(LIBWEBP_PDBNAME) \
|
||||||
|
/Fo$(DIROBJ)\examples\ examples\$(@B).c
|
||||||
|
$(DIROBJ)\examples\anim_util.obj: examples\anim_util.c
|
||||||
|
$(CC) $(CFLAGS) /DWEBP_HAVE_GIF /Fd$(LIBWEBP_PDBNAME) \
|
||||||
|
/Fo$(DIROBJ)\examples\ examples\$(@B).c
|
||||||
|
$(DIROBJ)\examples\gif2webp.obj: examples\gif2webp.c
|
||||||
|
$(CC) $(CFLAGS) /DWEBP_HAVE_GIF /Fd$(LIBWEBP_PDBNAME) \
|
||||||
|
/Fo$(DIROBJ)\examples\ examples\$(@B).c
|
||||||
|
$(DIROBJ)\examples\gifdec.obj: examples\gifdec.c
|
||||||
|
$(CC) $(CFLAGS) /DWEBP_HAVE_GIF /Fd$(LIBWEBP_PDBNAME) \
|
||||||
|
/Fo$(DIROBJ)\examples\ examples\$(@B).c
|
||||||
|
# Batch rules
|
||||||
|
{examples}.c{$(DIROBJ)\examples}.obj::
|
||||||
|
$(CC) $(CFLAGS) /Fd$(DIROBJ)\examples\ /Fo$(DIROBJ)\examples\ $<
|
||||||
|
{extras}.c{$(DIROBJ)\extras}.obj::
|
||||||
|
$(CC) $(CFLAGS) /Fd$(DIROBJ)\extras\ /Fo$(DIROBJ)\extras\ $<
|
||||||
|
{imageio}.c{$(DIROBJ)\imageio}.obj::
|
||||||
|
$(CC) $(CFLAGS) /Fd$(DIROBJ)\imageio\ /Fo$(DIROBJ)\imageio\ $<
|
||||||
|
{sharpyuv}.c{$(DIROBJ)\sharpyuv}.obj::
|
||||||
|
$(CC) $(CFLAGS) /Fd$(DIROBJ)\sharpyuv\ /Fo$(DIROBJ)\sharpyuv\ $<
|
||||||
|
{src\dec}.c{$(DIROBJ)\dec}.obj::
|
||||||
|
$(CC) $(CFLAGS) /Fd$(LIBWEBP_PDBNAME) /Fo$(DIROBJ)\dec\ $<
|
||||||
|
{src\demux}.c{$(DIROBJ)\demux}.obj::
|
||||||
|
$(CC) $(CFLAGS) /Fd$(LIBWEBP_PDBNAME) /Fo$(DIROBJ)\demux\ $<
|
||||||
|
{src\dsp}.c{$(DIROBJ)\dsp}.obj::
|
||||||
|
$(CC) $(CFLAGS) /Fd$(LIBWEBP_PDBNAME) /Fo$(DIROBJ)\dsp\ $<
|
||||||
|
{src\enc}.c{$(DIROBJ)\enc}.obj::
|
||||||
|
$(CC) $(CFLAGS) /Fd$(LIBWEBP_PDBNAME) /Fo$(DIROBJ)\enc\ $<
|
||||||
|
{src\mux}.c{$(DIROBJ)\mux}.obj::
|
||||||
|
$(CC) $(CFLAGS) /Fd$(LIBWEBP_PDBNAME) /Fo$(DIROBJ)\mux\ $<
|
||||||
|
{src\utils}.c{$(DIROBJ)\utils}.obj::
|
||||||
|
$(CC) $(CFLAGS) /Fd$(LIBWEBP_PDBNAME) /Fo$(DIROBJ)\utils\ $<
|
||||||
|
|
||||||
|
LNKLIBS = ole32.lib windowscodecs.lib shlwapi.lib
|
||||||
|
!IF "$(UNICODE)" == "1"
|
||||||
|
LNKLIBS = $(LNKLIBS) Shell32.lib
|
||||||
|
!ENDIF
|
||||||
|
|
||||||
|
{$(DIROBJ)\examples}.obj{$(DIRBIN)}.exe:
|
||||||
|
$(LNKEXE) $(LDFLAGS) /OUT:$@ $** $(LNKLIBS)
|
||||||
|
|
||||||
|
{$(DIROBJ)\extras}.obj{$(DIRBIN)}.exe:
|
||||||
|
$(LNKEXE) $(LDFLAGS) /OUT:$@ $** $(LNKLIBS)
|
||||||
|
|
||||||
|
clean::
|
||||||
|
@-erase /s $(DIROBJ)\*.dll 2> NUL
|
||||||
|
@-erase /s $(DIROBJ)\*.exp 2> NUL
|
||||||
|
@-erase /s $(DIROBJ)\*.idb 2> NUL
|
||||||
|
@-erase /s $(DIROBJ)\*.lib 2> NUL
|
||||||
|
@-erase /s $(DIROBJ)\*.obj 2> NUL
|
||||||
|
@-erase /s $(DIROBJ)\*.pch 2> NUL
|
||||||
|
@-erase /s $(DIROBJ)\*.pdb 2> NUL
|
||||||
|
@-erase /s $(DIROBJ)\*.res 2> NUL
|
||||||
|
|
||||||
|
!ENDIF # End of case where a config was provided.
|
311
external/libwebp/libwebp/NEWS
vendored
Normal file
311
external/libwebp/libwebp/NEWS
vendored
Normal file
@ -0,0 +1,311 @@
|
|||||||
|
- 6/23/2023: version 1.3.1
|
||||||
|
This is a binary compatible release.
|
||||||
|
* security fixes for lossless encoder (#603, chromium: #1420107, #1455619,
|
||||||
|
CVE-2023-1999)
|
||||||
|
* improve error reporting through WebPPicture error codes
|
||||||
|
* fix upsampling for RGB565 and RGBA4444 in NEON builds
|
||||||
|
* img2webp: add -sharp_yuv & -near_lossless
|
||||||
|
* Windows builds:
|
||||||
|
- fix compatibility with clang-cl (#607)
|
||||||
|
- improve Arm64 performance with cl.exe
|
||||||
|
- add Arm64EC support
|
||||||
|
* fix webp_js with emcc >= 3.1.27 (stack size change, #614)
|
||||||
|
* CMake fixes (#592, #610, #612)
|
||||||
|
* further updates to the container and lossless bitstream docs (#581, #611)
|
||||||
|
|
||||||
|
- 12/16/2022: version 1.3.0
|
||||||
|
This is a binary compatible release.
|
||||||
|
* add libsharpyuv, which exposes -sharp_yuv/config.use_sharp_yuv
|
||||||
|
functionality to other libraries; libwebp now depends on this library
|
||||||
|
* major updates to the container and lossless bitstream docs (#448, #546,
|
||||||
|
#551)
|
||||||
|
* miscellaneous warning, bug & build fixes (#576, #583, #584)
|
||||||
|
|
||||||
|
- 8/4/2022: version 1.2.4
|
||||||
|
This is a binary compatible release.
|
||||||
|
* restore CMake libwebpmux target name for compatibility with 1.2.2 (#575)
|
||||||
|
* fix lossless crunch mode encoding with WEBP_REDUCE_SIZE
|
||||||
|
(chromium: #1345547, #1345595, #1345772, #1345804)
|
||||||
|
|
||||||
|
- 6/30/2022: version 1.2.3
|
||||||
|
This is a binary compatible release.
|
||||||
|
* security fix for lossless encoder (#565, chromium:1313709)
|
||||||
|
* improved progress granularity in WebPReportProgress() when using lossless
|
||||||
|
* improved precision in Sharp YUV (-sharp_yuv) conversion
|
||||||
|
* many corrections to webp-lossless-bitstream-spec.txt (#551)
|
||||||
|
* crash/leak fixes on error/OOM and other bug fixes (#558, #563, #569, #573)
|
||||||
|
|
||||||
|
- 1/11/2022: version 1.2.2
|
||||||
|
This is a binary compatible release.
|
||||||
|
* webpmux: add "-set bgcolor A,R,G,B"
|
||||||
|
* add ARM64 NEON support for MSVC builds (#539)
|
||||||
|
* fix duplicate include error in Xcode when using multiple XCFrameworks in a
|
||||||
|
project (#542)
|
||||||
|
* doc updates and bug fixes (#538, #544, #548, #550)
|
||||||
|
|
||||||
|
- 7/20/2021: version 1.2.1
|
||||||
|
This is a binary compatible release.
|
||||||
|
* minor lossless encoder improvements and x86 color conversion speed up
|
||||||
|
* add ARM64 simulator support to xcframeworkbuild.sh (#510)
|
||||||
|
* further security related hardening in libwebp & examples
|
||||||
|
(issues: #497, #508, #518)
|
||||||
|
(chromium: #1196480, #1196773, #1196775, #1196777, #1196778, #1196850)
|
||||||
|
(oss-fuzz: #28658, #28978)
|
||||||
|
* toolchain updates and bug fixes (#498, #501, #502, #504, #505, #506, #509,
|
||||||
|
#533)
|
||||||
|
* use more inclusive language within the source (#507)
|
||||||
|
|
||||||
|
- 12/23/2020: version 1.2.0
|
||||||
|
* API changes:
|
||||||
|
- libwebp:
|
||||||
|
encode.h: add a qmin / qmax range for quality factor (cwebp adds -qrange)
|
||||||
|
* lossless encoder improvements
|
||||||
|
* SIMD support for Wasm builds
|
||||||
|
* add xcframeworkbuild.sh, supports Mac Catalyst builds
|
||||||
|
* import fuzzers from oss-fuzz & chromium (#409)
|
||||||
|
* webpmux: add an '-set loop <value>' option (#494)
|
||||||
|
* toolchain updates and bug fixes (#449, #463, #470, #475, #477, #478, #479,
|
||||||
|
#488, #491)
|
||||||
|
|
||||||
|
- 12/18/2019: version 1.1.0
|
||||||
|
* API changes:
|
||||||
|
- libwebp:
|
||||||
|
WebPMalloc (issue #442)
|
||||||
|
- extras:
|
||||||
|
WebPUnmultiplyARGB
|
||||||
|
* alpha decode fix (issue #439)
|
||||||
|
* toolchain updates and bug fixes
|
||||||
|
(chromium: #1026858, #1027136, #1027409, #1028620, #1028716, #995200)
|
||||||
|
(oss-fuzz: #19430, #19447)
|
||||||
|
|
||||||
|
- 7/4/2019: version 1.0.3
|
||||||
|
This is a binary compatible release.
|
||||||
|
* resize fixes for Nx1 sizes and the addition of non-opaque alpha values for
|
||||||
|
odd sizes (issues #418, #434)
|
||||||
|
* lossless encode/decode performance improvements
|
||||||
|
* lossy compression performance improvement at low quality levels with flat
|
||||||
|
content (issue #432)
|
||||||
|
* python swig files updated to support python 3
|
||||||
|
Tool updates:
|
||||||
|
vwebp will now preserve the aspect ratio of images that exceed monitor
|
||||||
|
resolution by scaling the image to fit (issue #433)
|
||||||
|
|
||||||
|
- 1/14/2019: version 1.0.2
|
||||||
|
This is a binary compatible release.
|
||||||
|
* (Windows) unicode file support in the tools (linux and mac already had
|
||||||
|
support, issue #398)
|
||||||
|
* lossless encoder speedups
|
||||||
|
* lossy encoder speedup on ARM
|
||||||
|
* lossless multi-threaded security fix (chromium:917029)
|
||||||
|
|
||||||
|
- 11/2/2018: version 1.0.1
|
||||||
|
This is a binary compatible release.
|
||||||
|
* lossless encoder speedups
|
||||||
|
* big-endian fix for alpha decoding (issue #393)
|
||||||
|
* gif2webp fix for loop count=65535 transcode (issue #382)
|
||||||
|
* further security related hardening in libwebp & libwebpmux
|
||||||
|
(issues #383, #385, #386, #387, #388, #391)
|
||||||
|
(oss-fuzz #9099, #9100, #9105, #9106, #9111, #9112, #9119, #9123, #9170,
|
||||||
|
#9178, #9179, #9183, #9186, #9191, #9364, #9417, #9496, #10349,
|
||||||
|
#10423, #10634, #10700, #10838, #10922, #11021, #11088, #11152)
|
||||||
|
* miscellaneous bug & build fixes (issues #381, #394, #396, #397, #400)
|
||||||
|
|
||||||
|
- 4/2/2018: version 1.0.0
|
||||||
|
This is a binary compatible release.
|
||||||
|
* lossy encoder improvements to avoid chroma shifts in various circumstances
|
||||||
|
(issues #308, #340)
|
||||||
|
* big-endian fixes for decode, RGBA import and WebPPictureDistortion
|
||||||
|
Tool updates:
|
||||||
|
gifwebp, anim_diff - default duration behavior (<= 10ms) changed to match
|
||||||
|
web browsers, transcoding tools (issue #379)
|
||||||
|
img2webp, webpmux - allow options to be passed in via a file (issue #355)
|
||||||
|
|
||||||
|
- 11/24/2017: version 0.6.1
|
||||||
|
This is a binary compatible release.
|
||||||
|
* lossless performance and compression improvements + a new 'cruncher' mode
|
||||||
|
(-m 6 -q 100)
|
||||||
|
* ARM performance improvements with clang (15-20% w/ndk r15c, issue #339)
|
||||||
|
* webp-js: emscripten/webassembly based javascript decoder
|
||||||
|
* miscellaneous bug & build fixes (issue #329, #332, #343, #353, #360, #361,
|
||||||
|
#363)
|
||||||
|
Tool updates / additions:
|
||||||
|
added webpinfo - prints file format information (issue #330)
|
||||||
|
gif2webp - loop behavior modified to match Chrome M63+ (crbug.com/649264);
|
||||||
|
'-loop_compatibility' can be used for the old behavior
|
||||||
|
|
||||||
|
- 1/26/2017: version 0.6.0
|
||||||
|
* lossless performance and compression improvements
|
||||||
|
* miscellaneous performance improvements (SSE2, NEON, MSA)
|
||||||
|
* webpmux gained a -duration option allowing for frame timing modification
|
||||||
|
* new img2webp utility allowing a sequence of images to be converted to
|
||||||
|
animated webp
|
||||||
|
* API changes:
|
||||||
|
- libwebp:
|
||||||
|
WebPPictureSharpARGBToYUVA
|
||||||
|
WebPPlaneDistortion
|
||||||
|
- libwebpmux / gif2webp:
|
||||||
|
WebPAnimEncoderOptions: kmax <= 0 now disables keyframes, kmax == 1
|
||||||
|
forces all keyframes. See mux.h and the gif2webp
|
||||||
|
manpage for details.
|
||||||
|
|
||||||
|
- 12/13/2016: version 0.5.2
|
||||||
|
This is a binary compatible release.
|
||||||
|
This release covers CVE-2016-8888 and CVE-2016-9085.
|
||||||
|
* further security related hardening in the tools; fixes to
|
||||||
|
gif2webp/AnimEncoder (issues #310, #314, #316, #322), cwebp/libwebp (issue
|
||||||
|
#312)
|
||||||
|
* full libwebp (encoder & decoder) iOS framework; libwebpdecoder
|
||||||
|
WebP.framework renamed to WebPDecoder.framework (issue #307)
|
||||||
|
* CMake support for Android Studio (2.2)
|
||||||
|
* miscellaneous build related fixes (issue #306, #313)
|
||||||
|
* miscellaneous documentation improvements (issue #225)
|
||||||
|
* minor lossy encoder fixes and improvements
|
||||||
|
|
||||||
|
- 6/14/2016: version 0.5.1
|
||||||
|
This is a binary compatible release.
|
||||||
|
* miscellaneous bug fixes (issues #280, #289)
|
||||||
|
* reverted alpha plane encoding with color cache for compatibility with
|
||||||
|
libwebp 0.4.0->0.4.3 (issues #291, #298)
|
||||||
|
* lossless encoding performance improvements
|
||||||
|
* memory reduction in both lossless encoding and decoding
|
||||||
|
* force mux output to be in the extended format (VP8X) when undefined chunks
|
||||||
|
are present (issue #294)
|
||||||
|
* gradle, cmake build support
|
||||||
|
* workaround for compiler bug causing 64-bit decode failures on android
|
||||||
|
devices using clang-3.8 in the r11c NDK
|
||||||
|
* various WebPAnimEncoder improvements
|
||||||
|
|
||||||
|
- 12/17/2015: version 0.5.0
|
||||||
|
* miscellaneous bug & build fixes (issues #234, #258, #274, #275, #278)
|
||||||
|
* encoder & decoder speed-ups on x86/ARM/MIPS for lossy & lossless
|
||||||
|
- note! YUV->RGB conversion was sped-up, but the results will be slightly
|
||||||
|
different from previous releases
|
||||||
|
* various lossless encoder improvements
|
||||||
|
* gif2webp improvements, -min_size option added
|
||||||
|
* tools fully support input from stdin and output to stdout (issue #168)
|
||||||
|
* New WebPAnimEncoder API for creating animations
|
||||||
|
* New WebPAnimDecoder API for decoding animations
|
||||||
|
* other API changes:
|
||||||
|
- libwebp:
|
||||||
|
WebPPictureSmartARGBToYUVA() (-pre 4 in cwebp)
|
||||||
|
WebPConfig::exact (-exact in cwebp; -alpha_cleanup is now the default)
|
||||||
|
WebPConfig::near_lossless (-near_lossless in cwebp)
|
||||||
|
WebPFree() (free'ing webp allocated memory in other languages)
|
||||||
|
WebPConfigLosslessPreset()
|
||||||
|
WebPMemoryWriterClear()
|
||||||
|
- libwebpdemux: removed experimental fragment related fields and functions
|
||||||
|
- libwebpmux: WebPMuxSetCanvasSize()
|
||||||
|
* new libwebpextras library with some uncommon import functions:
|
||||||
|
WebPImportGray/WebPImportRGB565/WebPImportRGB4444
|
||||||
|
|
||||||
|
- 10/15/15: version 0.4.4
|
||||||
|
This is a binary compatible release.
|
||||||
|
* rescaling out-of-bounds read fix (issue #254)
|
||||||
|
* various build fixes and improvements (issues #253, #259, #262, #267, #268)
|
||||||
|
* container documentation update
|
||||||
|
* gif2webp transparency fix (issue #245)
|
||||||
|
|
||||||
|
- 3/3/15: version 0.4.3
|
||||||
|
This is a binary compatible release.
|
||||||
|
* Android / gcc / iOS / MSVS build fixes and improvements
|
||||||
|
* lossless decode fix (issue #239 -- since 0.4.0)
|
||||||
|
* documentation / vwebp updates for animation
|
||||||
|
* multi-threading fix (issue #234)
|
||||||
|
|
||||||
|
- 10/13/14: version 0.4.2
|
||||||
|
This is a binary compatible release.
|
||||||
|
* Android / gcc build fixes
|
||||||
|
* (Windows) fix reading from stdin and writing to stdout
|
||||||
|
* gif2webp: miscellaneous fixes
|
||||||
|
* fix 'alpha-leak' with lossy compression (issue #220)
|
||||||
|
* the lossless bitstream spec has been amended to reflect the current code
|
||||||
|
|
||||||
|
- 7/24/14: version 0.4.1
|
||||||
|
This is a binary compatible release.
|
||||||
|
* AArch64 (arm64) & MIPS support/optimizations
|
||||||
|
* NEON assembly additions:
|
||||||
|
- ~25% faster lossy decode / encode (-m 4)
|
||||||
|
- ~10% faster lossless decode
|
||||||
|
- ~5-10% faster lossless encode (-m 3/4)
|
||||||
|
* dwebp/vwebp can read from stdin
|
||||||
|
* cwebp/gif2webp can write to stdout
|
||||||
|
* cwebp can read webp files; useful if storing sources as webp lossless
|
||||||
|
|
||||||
|
- 12/19/13: version 0.4.0
|
||||||
|
* improved gif2webp tool
|
||||||
|
* numerous fixes, compression improvement and speed-up
|
||||||
|
* dither option added to decoder (dwebp -dither 50 ...)
|
||||||
|
* improved multi-threaded modes (-mt option)
|
||||||
|
* improved filtering strength determination
|
||||||
|
* New function: WebPMuxGetCanvasSize
|
||||||
|
* BMP and TIFF format output added to 'dwebp'
|
||||||
|
* Significant memory reduction for decoding lossy images with alpha.
|
||||||
|
* Intertwined decoding of RGB and alpha for a shorter
|
||||||
|
time-to-first-decoded-pixel.
|
||||||
|
* WebPIterator has a new member 'has_alpha' denoting whether the frame
|
||||||
|
contains transparency.
|
||||||
|
* Container spec amended with new 'blending method' for animation.
|
||||||
|
|
||||||
|
- 6/13/13: version 0.3.1
|
||||||
|
This is a binary compatible release.
|
||||||
|
* Add incremental decoding support for images containing ALPH and ICCP chunks.
|
||||||
|
* Python bindings via swig for the simple encode/decode interfaces similar to
|
||||||
|
Java.
|
||||||
|
|
||||||
|
- 3/20/13: version 0.3.0
|
||||||
|
This is a binary compatible release.
|
||||||
|
* WebPINewRGB/WebPINewYUVA accept being passed a NULL output buffer
|
||||||
|
and will perform auto-allocation.
|
||||||
|
* default filter option is now '-strong -f 60'
|
||||||
|
* encoding speed-up for lossy methods 3 to 6
|
||||||
|
* alpha encoding can be done in parallel to lossy using 'cwebp -mt ...'
|
||||||
|
* color profile, metadata (XMP/EXIF) and animation support finalized in the
|
||||||
|
container.
|
||||||
|
* various NEON assembly additions
|
||||||
|
Tool updates / additions:
|
||||||
|
* gif2webp added
|
||||||
|
* vwebp given color profile & animation support
|
||||||
|
* cwebp can preserve color profile / metadata with '-metadata'
|
||||||
|
|
||||||
|
- 10/30/12: version 0.2.1
|
||||||
|
* Various security related fixes
|
||||||
|
* cwebp.exe: fix import errors on Windows XP
|
||||||
|
* enable DLL builds for mingw targets
|
||||||
|
|
||||||
|
- 8/3/12: version 0.2.0
|
||||||
|
* Add support for ARGB -> YUVA conversion for lossless decoder
|
||||||
|
New functions: WebPINewYUVA, WebPIDecGetYUVA
|
||||||
|
* Add stats for lossless and alpha encoding
|
||||||
|
* Security related hardening: allocation and size checks
|
||||||
|
* Add PAM output support to dwebp
|
||||||
|
|
||||||
|
- 7/19/12: version 0.1.99
|
||||||
|
* This is a pre-release of 0.2.0, not an rc to allow for further
|
||||||
|
incompatible changes based on user feedback.
|
||||||
|
* Alpha channel encode/decode support.
|
||||||
|
* Lossless encoder/decoder.
|
||||||
|
* Add TIFF input support to cwebp.
|
||||||
|
Incompatible changes:
|
||||||
|
* The encode ABI has been modified to support alpha encoding.
|
||||||
|
* Deprecated function WebPINew() has been removed.
|
||||||
|
* Decode function signatures have changed to consistently use size_t over
|
||||||
|
int/uint32_t.
|
||||||
|
* decode_vp8.h is no longer installed system-wide.
|
||||||
|
* cwebp will encode the alpha channel if present.
|
||||||
|
|
||||||
|
- 9/19/11: version 0.1.3
|
||||||
|
* Advanced decoding APIs.
|
||||||
|
* On-the-fly cropping and rescaling of images.
|
||||||
|
* SSE2 instructions for decoding performance optimizations on x86 based
|
||||||
|
platforms.
|
||||||
|
* Support Multi-threaded decoding.
|
||||||
|
* 40% improvement in Decoding performance.
|
||||||
|
* Add support for RGB565, RGBA4444 & ARGB image colorspace.
|
||||||
|
* Better handling of large picture encoding.
|
||||||
|
|
||||||
|
- 3/25/11: version 0.1.2
|
||||||
|
* Incremental decoding: picture can be decoded byte-by-byte if needs be.
|
||||||
|
* lot of bug-fixes, consolidation and stabilization
|
||||||
|
|
||||||
|
- 2/23/11: initial release of version 0.1, with the new encoder
|
||||||
|
- 9/30/10: initial release version with only the lightweight decoder
|
23
external/libwebp/libwebp/PATENTS
vendored
Normal file
23
external/libwebp/libwebp/PATENTS
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
Additional IP Rights Grant (Patents)
|
||||||
|
------------------------------------
|
||||||
|
|
||||||
|
"These implementations" means the copyrightable works that implement the WebM
|
||||||
|
codecs distributed by Google as part of the WebM Project.
|
||||||
|
|
||||||
|
Google hereby grants to you a perpetual, worldwide, non-exclusive, no-charge,
|
||||||
|
royalty-free, irrevocable (except as stated in this section) patent license to
|
||||||
|
make, have made, use, offer to sell, sell, import, transfer, and otherwise
|
||||||
|
run, modify and propagate the contents of these implementations of WebM, where
|
||||||
|
such license applies only to those patent claims, both currently owned by
|
||||||
|
Google and acquired in the future, licensable by Google that are necessarily
|
||||||
|
infringed by these implementations of WebM. This grant does not include claims
|
||||||
|
that would be infringed only as a consequence of further modification of these
|
||||||
|
implementations. If you or your agent or exclusive licensee institute or order
|
||||||
|
or agree to the institution of patent litigation or any other patent
|
||||||
|
enforcement activity against any entity (including a cross-claim or
|
||||||
|
counterclaim in a lawsuit) alleging that any of these implementations of WebM
|
||||||
|
or any code incorporated within any of these implementations of WebM
|
||||||
|
constitute direct or contributory patent infringement, or inducement of
|
||||||
|
patent infringement, then any patent rights granted to you under this License
|
||||||
|
for these implementations of WebM shall terminate as of the date such
|
||||||
|
litigation is filed.
|
245
external/libwebp/libwebp/PRESUBMIT.py
vendored
Normal file
245
external/libwebp/libwebp/PRESUBMIT.py
vendored
Normal file
@ -0,0 +1,245 @@
|
|||||||
|
# Copyright (c) 2021, Google Inc. All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions are
|
||||||
|
# met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
#
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in
|
||||||
|
# the documentation and/or other materials provided with the
|
||||||
|
# distribution.
|
||||||
|
#
|
||||||
|
# * Neither the name of Google nor the names of its contributors may
|
||||||
|
# be used to endorse or promote products derived from this software
|
||||||
|
# without specific prior written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
"""Top-level presubmit script for libwebp.
|
||||||
|
|
||||||
|
See https://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for
|
||||||
|
details on the presubmit API built into depot_tools.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import re
|
||||||
|
import subprocess2
|
||||||
|
|
||||||
|
USE_PYTHON3 = True
|
||||||
|
_BASH_INDENTATION = "2"
|
||||||
|
_GIT_COMMIT_SUBJECT_LENGTH = 65
|
||||||
|
_INCLUDE_BASH_FILES_ONLY = [r".*\.sh$"]
|
||||||
|
_INCLUDE_MAN_FILES_ONLY = [r"man/.+\.1$"]
|
||||||
|
_INCLUDE_SOURCE_FILES_ONLY = [r".*\.[ch]$"]
|
||||||
|
_LIBWEBP_MAX_LINE_LENGTH = 80
|
||||||
|
|
||||||
|
|
||||||
|
def _CheckCommitSubjectLength(input_api, output_api):
|
||||||
|
"""Ensures commit's subject length is no longer than 65 chars."""
|
||||||
|
name = "git-commit subject"
|
||||||
|
cmd = ["git", "log", "-1", "--pretty=%s"]
|
||||||
|
start = input_api.time.time()
|
||||||
|
proc = subprocess2.Popen(
|
||||||
|
cmd,
|
||||||
|
stderr=subprocess2.PIPE,
|
||||||
|
stdout=subprocess2.PIPE,
|
||||||
|
universal_newlines=True)
|
||||||
|
|
||||||
|
stdout, _ = proc.communicate()
|
||||||
|
duration = input_api.time.time() - start
|
||||||
|
|
||||||
|
if not re.match(r"^Revert",
|
||||||
|
stdout) and (len(stdout) - 1) > _GIT_COMMIT_SUBJECT_LENGTH:
|
||||||
|
failure_msg = (
|
||||||
|
"The commit subject: %s is too long (%d chars)\n"
|
||||||
|
"Try to keep this to 50 or less (up to 65 is permitted for "
|
||||||
|
"non-reverts).\n"
|
||||||
|
"https://www.git-scm.com/book/en/v2/Distributed-Git-Contributing-to-a-"
|
||||||
|
"Project#_commit_guidelines") % (stdout, len(stdout) - 1)
|
||||||
|
return output_api.PresubmitError("%s\n (%4.2fs) failed\n%s" %
|
||||||
|
(name, duration, failure_msg))
|
||||||
|
|
||||||
|
return output_api.PresubmitResult("%s\n (%4.2fs) success" % (name, duration))
|
||||||
|
|
||||||
|
|
||||||
|
def _CheckDuplicateFiles(input_api, output_api):
|
||||||
|
"""Ensures there are not repeated filenames."""
|
||||||
|
all_files = []
|
||||||
|
for f in input_api.change.AllFiles():
|
||||||
|
for include_file in _INCLUDE_SOURCE_FILES_ONLY:
|
||||||
|
if re.match(include_file, f):
|
||||||
|
all_files.append(f)
|
||||||
|
break
|
||||||
|
|
||||||
|
basename_to_path = {}
|
||||||
|
for f in all_files:
|
||||||
|
basename_file = input_api.basename(f)
|
||||||
|
if basename_file in basename_to_path:
|
||||||
|
basename_to_path[basename_file].append(f)
|
||||||
|
else:
|
||||||
|
basename_to_path[basename_file] = [f]
|
||||||
|
|
||||||
|
dupes = []
|
||||||
|
for files in basename_to_path.values():
|
||||||
|
if len(files) > 1:
|
||||||
|
dupes.extend(files)
|
||||||
|
|
||||||
|
if dupes:
|
||||||
|
return output_api.PresubmitError(
|
||||||
|
"Duplicate source files, rebase or rename some to make them unique:\n%s"
|
||||||
|
% dupes)
|
||||||
|
return output_api.PresubmitResult("No duplicates, success\n")
|
||||||
|
|
||||||
|
|
||||||
|
def _GetFilesToSkip(input_api):
|
||||||
|
return list(input_api.DEFAULT_FILES_TO_SKIP) + [
|
||||||
|
r"swig/.*\.py$",
|
||||||
|
r"\.pylintrc$",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def _RunManCmd(input_api, output_api, man_file):
|
||||||
|
"""man command wrapper."""
|
||||||
|
cmd = ["man", "--warnings", "-EUTF-8", "-l", "-Tutf8", "-Z", man_file]
|
||||||
|
name = "Check %s file." % man_file
|
||||||
|
start = input_api.time.time()
|
||||||
|
output, _ = subprocess2.communicate(
|
||||||
|
cmd, stdout=None, stderr=subprocess2.PIPE, universal_newlines=True)
|
||||||
|
duration = input_api.time.time() - start
|
||||||
|
if output[1]:
|
||||||
|
return output_api.PresubmitError("%s\n%s (%4.2fs) failed\n%s" %
|
||||||
|
(name, " ".join(cmd), duration, output[1]))
|
||||||
|
return output_api.PresubmitResult("%s\n%s (%4.2fs)\n" %
|
||||||
|
(name, " ".join(cmd), duration))
|
||||||
|
|
||||||
|
|
||||||
|
def _RunShellCheckCmd(input_api, output_api, bash_file):
|
||||||
|
"""shellcheck command wrapper."""
|
||||||
|
cmd = ["shellcheck", "-x", "-oall", "-sbash", bash_file]
|
||||||
|
name = "Check %s file." % bash_file
|
||||||
|
start = input_api.time.time()
|
||||||
|
output, rc = subprocess2.communicate(
|
||||||
|
cmd, stdout=None, stderr=subprocess2.PIPE, universal_newlines=True)
|
||||||
|
duration = input_api.time.time() - start
|
||||||
|
if rc == 0:
|
||||||
|
return output_api.PresubmitResult("%s\n%s (%4.2fs)\n" %
|
||||||
|
(name, " ".join(cmd), duration))
|
||||||
|
return output_api.PresubmitError("%s\n%s (%4.2fs) failed\n%s" %
|
||||||
|
(name, " ".join(cmd), duration, output[1]))
|
||||||
|
|
||||||
|
|
||||||
|
def _RunShfmtCheckCmd(input_api, output_api, bash_file):
|
||||||
|
"""shfmt command wrapper."""
|
||||||
|
cmd = [
|
||||||
|
"shfmt", "-i", _BASH_INDENTATION, "-bn", "-ci", "-sr", "-kp", "-d",
|
||||||
|
bash_file
|
||||||
|
]
|
||||||
|
name = "Check %s file." % bash_file
|
||||||
|
start = input_api.time.time()
|
||||||
|
output, rc = subprocess2.communicate(
|
||||||
|
cmd, stdout=None, stderr=subprocess2.PIPE, universal_newlines=True)
|
||||||
|
duration = input_api.time.time() - start
|
||||||
|
if rc == 0:
|
||||||
|
return output_api.PresubmitResult("%s\n%s (%4.2fs)\n" %
|
||||||
|
(name, " ".join(cmd), duration))
|
||||||
|
return output_api.PresubmitError("%s\n%s (%4.2fs) failed\n%s" %
|
||||||
|
(name, " ".join(cmd), duration, output[1]))
|
||||||
|
|
||||||
|
|
||||||
|
def _RunCmdOnCheckedFiles(input_api, output_api, run_cmd, files_to_check):
|
||||||
|
"""Ensure that libwebp/ files are clean."""
|
||||||
|
file_filter = lambda x: input_api.FilterSourceFile(
|
||||||
|
x, files_to_check=files_to_check, files_to_skip=None)
|
||||||
|
|
||||||
|
affected_files = input_api.change.AffectedFiles(file_filter=file_filter)
|
||||||
|
results = [
|
||||||
|
run_cmd(input_api, output_api, f.AbsoluteLocalPath())
|
||||||
|
for f in affected_files
|
||||||
|
]
|
||||||
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
def _CommonChecks(input_api, output_api):
|
||||||
|
"""Ensures this patch does not have trailing spaces, extra EOLs,
|
||||||
|
or long lines.
|
||||||
|
"""
|
||||||
|
results = []
|
||||||
|
results.extend(
|
||||||
|
input_api.canned_checks.CheckChangeHasNoCrAndHasOnlyOneEol(
|
||||||
|
input_api, output_api))
|
||||||
|
results.extend(
|
||||||
|
input_api.canned_checks.CheckChangeHasNoTabs(input_api, output_api))
|
||||||
|
results.extend(
|
||||||
|
input_api.canned_checks.CheckChangeHasNoStrayWhitespace(
|
||||||
|
input_api, output_api))
|
||||||
|
results.append(_CheckCommitSubjectLength(input_api, output_api))
|
||||||
|
results.append(_CheckDuplicateFiles(input_api, output_api))
|
||||||
|
|
||||||
|
source_file_filter = lambda x: input_api.FilterSourceFile(
|
||||||
|
x, files_to_skip=_GetFilesToSkip(input_api))
|
||||||
|
results.extend(
|
||||||
|
input_api.canned_checks.CheckLongLines(
|
||||||
|
input_api,
|
||||||
|
output_api,
|
||||||
|
maxlen=_LIBWEBP_MAX_LINE_LENGTH,
|
||||||
|
source_file_filter=source_file_filter))
|
||||||
|
|
||||||
|
results.extend(
|
||||||
|
input_api.canned_checks.CheckPatchFormatted(
|
||||||
|
input_api,
|
||||||
|
output_api,
|
||||||
|
check_clang_format=False,
|
||||||
|
check_python=True,
|
||||||
|
result_factory=output_api.PresubmitError))
|
||||||
|
results.extend(
|
||||||
|
_RunCmdOnCheckedFiles(input_api, output_api, _RunManCmd,
|
||||||
|
_INCLUDE_MAN_FILES_ONLY))
|
||||||
|
# Run pylint.
|
||||||
|
results.extend(
|
||||||
|
input_api.canned_checks.RunPylint(
|
||||||
|
input_api,
|
||||||
|
output_api,
|
||||||
|
files_to_skip=_GetFilesToSkip(input_api),
|
||||||
|
pylintrc=".pylintrc",
|
||||||
|
version="2.7"))
|
||||||
|
|
||||||
|
# Binaries shellcheck and shfmt are not installed in depot_tools.
|
||||||
|
# Installation is needed
|
||||||
|
try:
|
||||||
|
subprocess2.communicate(["shellcheck", "--version"])
|
||||||
|
results.extend(
|
||||||
|
_RunCmdOnCheckedFiles(input_api, output_api, _RunShellCheckCmd,
|
||||||
|
_INCLUDE_BASH_FILES_ONLY))
|
||||||
|
print("shfmt")
|
||||||
|
subprocess2.communicate(["shfmt", "-version"])
|
||||||
|
results.extend(
|
||||||
|
_RunCmdOnCheckedFiles(input_api, output_api, _RunShfmtCheckCmd,
|
||||||
|
_INCLUDE_BASH_FILES_ONLY))
|
||||||
|
except OSError as os_error:
|
||||||
|
results.append(
|
||||||
|
output_api.PresubmitPromptWarning(
|
||||||
|
"%s\nPlease install missing binaries locally." % os_error.args[0]))
|
||||||
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
def CheckChangeOnUpload(input_api, output_api):
|
||||||
|
results = []
|
||||||
|
results.extend(_CommonChecks(input_api, output_api))
|
||||||
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
def CheckChangeOnCommit(input_api, output_api):
|
||||||
|
results = []
|
||||||
|
results.extend(_CommonChecks(input_api, output_api))
|
||||||
|
return results
|
53
external/libwebp/libwebp/README.md
vendored
Normal file
53
external/libwebp/libwebp/README.md
vendored
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
# WebP Codec
|
||||||
|
|
||||||
|
```
|
||||||
|
__ __ ____ ____ ____
|
||||||
|
/ \\/ \/ _ \/ _ )/ _ \
|
||||||
|
\ / __/ _ \ __/
|
||||||
|
\__\__/\____/\_____/__/ ____ ___
|
||||||
|
/ _/ / \ \ / _ \/ _/
|
||||||
|
/ \_/ / / \ \ __/ \__
|
||||||
|
\____/____/\_____/_____/____/v1.3.1
|
||||||
|
```
|
||||||
|
|
||||||
|
WebP codec is a library to encode and decode images in WebP format. This package
|
||||||
|
contains the library that can be used in other programs to add WebP support, as
|
||||||
|
well as the command line tools 'cwebp' and 'dwebp' to compress and decompress
|
||||||
|
images respectively.
|
||||||
|
|
||||||
|
See https://developers.google.com/speed/webp for details on the image format.
|
||||||
|
|
||||||
|
The latest source tree is available at
|
||||||
|
https://chromium.googlesource.com/webm/libwebp
|
||||||
|
|
||||||
|
It is released under the same license as the WebM project. See
|
||||||
|
https://www.webmproject.org/license/software/ or the "COPYING" file for details.
|
||||||
|
An additional intellectual property rights grant can be found in the file
|
||||||
|
PATENTS.
|
||||||
|
|
||||||
|
## Building
|
||||||
|
|
||||||
|
See the [building documentation](doc/building.md).
|
||||||
|
|
||||||
|
## Encoding and Decoding Tools
|
||||||
|
|
||||||
|
The examples/ directory contains tools to encode and decode images and
|
||||||
|
animations, view information about WebP images, and more. See the
|
||||||
|
[tools documentation](doc/tools.md).
|
||||||
|
|
||||||
|
## APIs
|
||||||
|
|
||||||
|
See the [APIs documentation](doc/api.md), and API usage examples in the
|
||||||
|
`examples/` directory.
|
||||||
|
|
||||||
|
## Bugs
|
||||||
|
|
||||||
|
Please report all bugs to the issue tracker: https://bugs.chromium.org/p/webp
|
||||||
|
|
||||||
|
Patches welcome! See [how to contribute](CONTRIBUTING.md).
|
||||||
|
|
||||||
|
## Discuss
|
||||||
|
|
||||||
|
Email: webp-discuss@webmproject.org
|
||||||
|
|
||||||
|
Web: https://groups.google.com/a/webmproject.org/group/webp-discuss
|
2
external/libwebp/libwebp/autogen.sh
vendored
Executable file
2
external/libwebp/libwebp/autogen.sh
vendored
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
#! /bin/sh -e
|
||||||
|
exec autoreconf -fi
|
444
external/libwebp/libwebp/build.gradle
vendored
Normal file
444
external/libwebp/libwebp/build.gradle
vendored
Normal file
@ -0,0 +1,444 @@
|
|||||||
|
// Define dependencies.
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
url "https://jcenter.bintray.com"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath "com.android.tools.build:gradle:${ANDROID_GRADLE_PLUGIN_VERSION}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Define versions in the project.
|
||||||
|
project.ext {
|
||||||
|
buildToolsVersion = "${BUILD_TOOLS_VERSION}"
|
||||||
|
compileSdkVersion = COMPILE_SDK_VERSION.toInteger()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Core libraries and executables.
|
||||||
|
apply plugin: "c"
|
||||||
|
def NEON
|
||||||
|
model {
|
||||||
|
buildTypes {
|
||||||
|
debug
|
||||||
|
release
|
||||||
|
}
|
||||||
|
platforms {
|
||||||
|
arm {
|
||||||
|
architecture "arm"
|
||||||
|
}
|
||||||
|
arm64 {
|
||||||
|
architecture "arm64"
|
||||||
|
}
|
||||||
|
x86 {
|
||||||
|
architecture "x86"
|
||||||
|
}
|
||||||
|
x64 {
|
||||||
|
architecture "x86_64"
|
||||||
|
}
|
||||||
|
mips32r2
|
||||||
|
mips32r5
|
||||||
|
mips64r6
|
||||||
|
}
|
||||||
|
toolChains {
|
||||||
|
gcc(Gcc) {
|
||||||
|
target("mips32r2") {
|
||||||
|
cCompiler.args "-mips32r2"
|
||||||
|
}
|
||||||
|
target("mips32r5") {
|
||||||
|
cCompiler.args "-mips32r5"
|
||||||
|
}
|
||||||
|
target("mips64r6") {
|
||||||
|
cCompiler.args "-mips64r6"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
binaries {
|
||||||
|
all {
|
||||||
|
if (toolChain in Gcc) {
|
||||||
|
cCompiler.args "-fPIC"
|
||||||
|
cCompiler.args "-Wall"
|
||||||
|
cCompiler.define "ANDROID"
|
||||||
|
cCompiler.define "HAVE_MALLOC_H"
|
||||||
|
}
|
||||||
|
// Optimizations.
|
||||||
|
if (buildType == buildTypes.release) {
|
||||||
|
if (toolChain in Gcc) {
|
||||||
|
cCompiler.args "-finline-functions"
|
||||||
|
cCompiler.args "-ffast-math"
|
||||||
|
cCompiler.args "-ffunction-sections"
|
||||||
|
cCompiler.args "-fdata-sections"
|
||||||
|
}
|
||||||
|
if (toolChain in Clang) {
|
||||||
|
cCompiler.args "-frename-registers -s"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// mips32 fails to build with clang from r14b
|
||||||
|
// https://bugs.chromium.org/p/webp/issues/detail?id=343
|
||||||
|
if (toolChain in Clang) {
|
||||||
|
if (getTargetPlatform() == "mips") {
|
||||||
|
cCompiler.args "-no-integrated-as"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Check for NEON usage.
|
||||||
|
if (getTargetPlatform() == "arm") {
|
||||||
|
NEON = "c.neon"
|
||||||
|
cCompiler.define "HAVE_CPU_FEATURES_H"
|
||||||
|
} else {
|
||||||
|
NEON = "c"
|
||||||
|
}
|
||||||
|
|
||||||
|
cCompiler.args "-I" + file(".").absolutePath
|
||||||
|
}
|
||||||
|
// Link to pthread for shared libraries.
|
||||||
|
withType(SharedLibraryBinarySpec) {
|
||||||
|
if (toolChain in Gcc) {
|
||||||
|
cCompiler.define "HAVE_PTHREAD"
|
||||||
|
cCompiler.define "WEBP_USE_THREAD"
|
||||||
|
linker.args "-pthread"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
components {
|
||||||
|
webp(NativeLibrarySpec) {
|
||||||
|
sources {
|
||||||
|
c {
|
||||||
|
source {
|
||||||
|
srcDir "sharpyuv"
|
||||||
|
include "sharpyuv.c"
|
||||||
|
include "sharpyuv_cpu.c"
|
||||||
|
include "sharpyuv_csp.c"
|
||||||
|
include "sharpyuv_dsp.c"
|
||||||
|
include "sharpyuv_gamma.c"
|
||||||
|
include "sharpyuv_neon.c"
|
||||||
|
include "sharpyuv_sse2.c"
|
||||||
|
srcDir "src/dec"
|
||||||
|
include "alpha_dec.c"
|
||||||
|
include "buffer_dec.c"
|
||||||
|
include "frame_dec.c"
|
||||||
|
include "idec_dec.c"
|
||||||
|
include "io_dec.c"
|
||||||
|
include "quant_dec.c"
|
||||||
|
include "tree_dec.c"
|
||||||
|
include "vp8_dec.c"
|
||||||
|
include "vp8l_dec.c"
|
||||||
|
include "webp_dec.c"
|
||||||
|
srcDir "src/dsp"
|
||||||
|
include "alpha_processing.c"
|
||||||
|
include "alpha_processing_mips_dsp_r2.c"
|
||||||
|
include "alpha_processing_neon.$NEON"
|
||||||
|
include "alpha_processing_sse2.c"
|
||||||
|
include "alpha_processing_sse41.c"
|
||||||
|
include "cpu.c"
|
||||||
|
include "dec.c"
|
||||||
|
include "dec_clip_tables.c"
|
||||||
|
include "dec_mips32.c"
|
||||||
|
include "dec_mips_dsp_r2.c"
|
||||||
|
include "dec_msa.c"
|
||||||
|
include "dec_neon.$NEON"
|
||||||
|
include "dec_sse2.c"
|
||||||
|
include "dec_sse41.c"
|
||||||
|
include "filters.c"
|
||||||
|
include "filters_mips_dsp_r2.c"
|
||||||
|
include "filters_msa.c"
|
||||||
|
include "filters_neon.$NEON"
|
||||||
|
include "filters_sse2.c"
|
||||||
|
include "lossless.c"
|
||||||
|
include "lossless_mips_dsp_r2.c"
|
||||||
|
include "lossless_msa.c"
|
||||||
|
include "lossless_neon.$NEON"
|
||||||
|
include "lossless_sse2.c"
|
||||||
|
include "lossless_sse41.c"
|
||||||
|
include "rescaler.c"
|
||||||
|
include "rescaler_mips32.c"
|
||||||
|
include "rescaler_mips_dsp_r2.c"
|
||||||
|
include "rescaler_msa.c"
|
||||||
|
include "rescaler_neon.$NEON"
|
||||||
|
include "rescaler_sse2.c"
|
||||||
|
include "upsampling.c"
|
||||||
|
include "upsampling_mips_dsp_r2.c"
|
||||||
|
include "upsampling_msa.c"
|
||||||
|
include "upsampling_neon.$NEON"
|
||||||
|
include "upsampling_sse2.c"
|
||||||
|
include "upsampling_sse41.c"
|
||||||
|
include "yuv.c"
|
||||||
|
include "yuv_mips32.c"
|
||||||
|
include "yuv_mips_dsp_r2.c"
|
||||||
|
include "yuv_neon.$NEON"
|
||||||
|
include "yuv_sse2.c"
|
||||||
|
include "yuv_sse41.c"
|
||||||
|
srcDir "src/utils"
|
||||||
|
include "bit_reader_utils.c"
|
||||||
|
include "color_cache_utils.c"
|
||||||
|
include "filters_utils.c"
|
||||||
|
include "huffman_utils.c"
|
||||||
|
include "palette.c"
|
||||||
|
include "quant_levels_dec_utils.c"
|
||||||
|
include "random_utils.c"
|
||||||
|
include "rescaler_utils.c"
|
||||||
|
include "thread_utils.c"
|
||||||
|
include "utils.c"
|
||||||
|
srcDir "src/dsp"
|
||||||
|
include "cost.c"
|
||||||
|
include "cost_mips32.c"
|
||||||
|
include "cost_mips_dsp_r2.c"
|
||||||
|
include "cost_neon.$NEON"
|
||||||
|
include "cost_sse2.c"
|
||||||
|
include "enc.c"
|
||||||
|
include "enc_mips32.c"
|
||||||
|
include "enc_mips_dsp_r2.c"
|
||||||
|
include "enc_msa.c"
|
||||||
|
include "enc_neon.$NEON"
|
||||||
|
include "enc_sse2.c"
|
||||||
|
include "enc_sse41.c"
|
||||||
|
include "lossless_enc.c"
|
||||||
|
include "lossless_enc_mips32.c"
|
||||||
|
include "lossless_enc_mips_dsp_r2.c"
|
||||||
|
include "lossless_enc_msa.c"
|
||||||
|
include "lossless_enc_neon.$NEON"
|
||||||
|
include "lossless_enc_sse2.c"
|
||||||
|
include "lossless_enc_sse41.c"
|
||||||
|
include "ssim.c"
|
||||||
|
include "ssim_sse2.c"
|
||||||
|
srcDir "src/enc"
|
||||||
|
include "alpha_enc.c"
|
||||||
|
include "analysis_enc.c"
|
||||||
|
include "backward_references_cost_enc.c"
|
||||||
|
include "backward_references_enc.c"
|
||||||
|
include "config_enc.c"
|
||||||
|
include "cost_enc.c"
|
||||||
|
include "filter_enc.c"
|
||||||
|
include "frame_enc.c"
|
||||||
|
include "histogram_enc.c"
|
||||||
|
include "iterator_enc.c"
|
||||||
|
include "near_lossless_enc.c"
|
||||||
|
include "picture_enc.c"
|
||||||
|
include "picture_csp_enc.c"
|
||||||
|
include "picture_psnr_enc.c"
|
||||||
|
include "picture_rescale_enc.c"
|
||||||
|
include "picture_tools_enc.c"
|
||||||
|
include "predictor_enc.c"
|
||||||
|
include "quant_enc.c"
|
||||||
|
include "syntax_enc.c"
|
||||||
|
include "token_enc.c"
|
||||||
|
include "tree_enc.c"
|
||||||
|
include "vp8l_enc.c"
|
||||||
|
include "webp_enc.c"
|
||||||
|
srcDir "src/utils"
|
||||||
|
include "bit_writer_utils.c"
|
||||||
|
include "huffman_encode_utils.c"
|
||||||
|
include "quant_levels_utils.c"
|
||||||
|
}
|
||||||
|
exportedHeaders {
|
||||||
|
srcDir "src"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
webpdemux(NativeLibrarySpec) {
|
||||||
|
sources {
|
||||||
|
c {
|
||||||
|
source {
|
||||||
|
srcDir "src/demux"
|
||||||
|
include "anim_decode.c"
|
||||||
|
include "demux.c"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
webpmux(NativeLibrarySpec) {
|
||||||
|
sources {
|
||||||
|
c {
|
||||||
|
source {
|
||||||
|
srcDir "src/mux/"
|
||||||
|
include "anim_encode.c"
|
||||||
|
include "muxedit.c"
|
||||||
|
include "muxinternal.c"
|
||||||
|
include "muxread.c"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Executables from examples.
|
||||||
|
example_util(NativeLibrarySpec) {
|
||||||
|
binaries {
|
||||||
|
all {
|
||||||
|
lib library: "webp", linkage: "static"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sources {
|
||||||
|
c {
|
||||||
|
source {
|
||||||
|
srcDir "./examples"
|
||||||
|
include "example_util.c"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
imageio_util(NativeLibrarySpec) {
|
||||||
|
binaries {
|
||||||
|
all {
|
||||||
|
lib library: "webp", linkage: "static"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sources {
|
||||||
|
c {
|
||||||
|
source {
|
||||||
|
srcDir "./imageio"
|
||||||
|
include "imageio_util.c"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
imagedec(NativeLibrarySpec) {
|
||||||
|
binaries {
|
||||||
|
all {
|
||||||
|
lib library: "webpdemux", linkage: "static"
|
||||||
|
lib library: "webp", linkage: "static"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sources {
|
||||||
|
c {
|
||||||
|
source {
|
||||||
|
srcDir "./imageio"
|
||||||
|
include "image_dec.c"
|
||||||
|
include "jpegdec.c"
|
||||||
|
include "metadata.c"
|
||||||
|
include "pngdec.c"
|
||||||
|
include "pnmdec.c"
|
||||||
|
include "tiffdec.c"
|
||||||
|
include "webpdec.c"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
imageenc(NativeLibrarySpec) {
|
||||||
|
binaries {
|
||||||
|
all {
|
||||||
|
lib library: "webp", linkage: "static"
|
||||||
|
lib library: "imageio_util", linkage: "static"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sources {
|
||||||
|
c {
|
||||||
|
source {
|
||||||
|
srcDir "./imageio"
|
||||||
|
include "image_enc.c"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cwebp(NativeExecutableSpec) {
|
||||||
|
binaries {
|
||||||
|
all {
|
||||||
|
lib library: "example_util", linkage: "static"
|
||||||
|
lib library: "imagedec", linkage: "static"
|
||||||
|
lib library: "imageio_util", linkage: "static"
|
||||||
|
lib library: "webpdemux", linkage: "static"
|
||||||
|
lib library: "webp", linkage: "static"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sources {
|
||||||
|
c {
|
||||||
|
source {
|
||||||
|
srcDir "./examples"
|
||||||
|
include "cwebp.c"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dwebp(NativeExecutableSpec) {
|
||||||
|
binaries {
|
||||||
|
all {
|
||||||
|
lib library: "example_util", linkage: "static"
|
||||||
|
lib library: "imagedec", linkage: "static"
|
||||||
|
lib library: "imageenc", linkage: "static"
|
||||||
|
lib library: "imageio_util", linkage: "static"
|
||||||
|
lib library: "webpdemux", linkage: "static"
|
||||||
|
lib library: "webp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sources {
|
||||||
|
c {
|
||||||
|
source {
|
||||||
|
srcDir "./examples"
|
||||||
|
include "dwebp.c"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
webpmux_example(NativeExecutableSpec) {
|
||||||
|
binaries {
|
||||||
|
all {
|
||||||
|
lib library: "example_util", linkage: "static"
|
||||||
|
lib library: "imageio_util", linkage: "static"
|
||||||
|
lib library: "webpmux", linkage: "static"
|
||||||
|
lib library: "webp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sources {
|
||||||
|
c {
|
||||||
|
source {
|
||||||
|
srcDir "./examples"
|
||||||
|
include "webpmux.c"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
img2webp_example(NativeExecutableSpec) {
|
||||||
|
binaries {
|
||||||
|
all {
|
||||||
|
lib library: "example_util", linkage: "static"
|
||||||
|
lib library: "imagedec", linkage: "static"
|
||||||
|
lib library: "imageio_util", linkage: "static"
|
||||||
|
lib library: "webpmux", linkage: "static"
|
||||||
|
lib library: "webpdemux", linkage: "static"
|
||||||
|
lib library: "webp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sources {
|
||||||
|
c {
|
||||||
|
source {
|
||||||
|
srcDir "./examples"
|
||||||
|
include "img2webp.c"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
webpinfo_example(NativeExecutableSpec) {
|
||||||
|
binaries {
|
||||||
|
all {
|
||||||
|
lib library: "example_util", linkage: "static"
|
||||||
|
lib library: "imageio_util", linkage: "static"
|
||||||
|
lib library: "webp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sources {
|
||||||
|
c {
|
||||||
|
source {
|
||||||
|
srcDir "./examples"
|
||||||
|
include "webpinfo.c"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tasks {
|
||||||
|
// Task to test all possible configurations.
|
||||||
|
buildAllExecutables(Task) {
|
||||||
|
dependsOn $.binaries.findAll { it.buildable }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
18
external/libwebp/libwebp/cmake/WebPConfig.cmake.in
vendored
Normal file
18
external/libwebp/libwebp/cmake/WebPConfig.cmake.in
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
set(WebP_VERSION @PROJECT_VERSION@)
|
||||||
|
set(WEBP_VERSION ${WebP_VERSION})
|
||||||
|
|
||||||
|
@PACKAGE_INIT@
|
||||||
|
|
||||||
|
if(@WEBP_USE_THREAD@)
|
||||||
|
include(CMakeFindDependencyMacro)
|
||||||
|
find_dependency(Threads REQUIRED)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
|
||||||
|
|
||||||
|
set_and_check(WebP_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@")
|
||||||
|
set(WEBP_INCLUDE_DIRS ${WebP_INCLUDE_DIRS})
|
||||||
|
set(WebP_LIBRARIES "@INSTALLED_LIBRARIES@")
|
||||||
|
set(WEBP_LIBRARIES "${WebP_LIBRARIES}")
|
||||||
|
|
||||||
|
check_required_components(WebP)
|
116
external/libwebp/libwebp/cmake/config.h.in
vendored
Normal file
116
external/libwebp/libwebp/cmake/config.h.in
vendored
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
/* Adapted from the autotools src/webp/config.h.in. */
|
||||||
|
|
||||||
|
/* Define if building universal (internal helper macro) */
|
||||||
|
/* TODO: handle properly in CMake */
|
||||||
|
#cmakedefine AC_APPLE_UNIVERSAL_BUILD 1
|
||||||
|
|
||||||
|
/* Set to 1 if __builtin_bswap16 is available */
|
||||||
|
#cmakedefine HAVE_BUILTIN_BSWAP16 1
|
||||||
|
|
||||||
|
/* Set to 1 if __builtin_bswap32 is available */
|
||||||
|
#cmakedefine HAVE_BUILTIN_BSWAP32 1
|
||||||
|
|
||||||
|
/* Set to 1 if __builtin_bswap64 is available */
|
||||||
|
#cmakedefine HAVE_BUILTIN_BSWAP64 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <cpu-features.h> header file. */
|
||||||
|
#cmakedefine HAVE_CPU_FEATURES_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <GLUT/glut.h> header file. */
|
||||||
|
#cmakedefine HAVE_GLUT_GLUT_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <GL/glut.h> header file. */
|
||||||
|
#cmakedefine HAVE_GL_GLUT_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <OpenGL/glut.h> header file. */
|
||||||
|
#cmakedefine HAVE_OPENGL_GLUT_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <shlwapi.h> header file. */
|
||||||
|
#cmakedefine HAVE_SHLWAPI_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <unistd.h> header file. */
|
||||||
|
#cmakedefine HAVE_UNISTD_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <wincodec.h> header file. */
|
||||||
|
#cmakedefine HAVE_WINCODEC_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <windows.h> header file. */
|
||||||
|
#cmakedefine HAVE_WINDOWS_H 1
|
||||||
|
|
||||||
|
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||||
|
*/
|
||||||
|
/* TODO: handle properly in CMake */
|
||||||
|
#cmakedefine LT_OBJDIR "@LT_OBJDIR@"
|
||||||
|
|
||||||
|
/* Name of package */
|
||||||
|
#cmakedefine PACKAGE "@PROJECT_NAME@"
|
||||||
|
|
||||||
|
/* Define to the address where bug reports for this package should be sent. */
|
||||||
|
#cmakedefine PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@"
|
||||||
|
|
||||||
|
/* Define to the full name of this package. */
|
||||||
|
#cmakedefine PACKAGE_NAME "@PACKAGE_NAME@"
|
||||||
|
|
||||||
|
/* Define to the full name and version of this package. */
|
||||||
|
#cmakedefine PACKAGE_STRING "@PACKAGE_STRING@"
|
||||||
|
|
||||||
|
/* Define to the one symbol short name of this package. */
|
||||||
|
#cmakedefine PACKAGE_TARNAME "@PACKAGE_TARNAME@"
|
||||||
|
|
||||||
|
/* Define to the home page for this package. */
|
||||||
|
#cmakedefine PACKAGE_URL "@PACKAGE_URL@"
|
||||||
|
|
||||||
|
/* Define to the version of this package. */
|
||||||
|
#cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@"
|
||||||
|
|
||||||
|
/* Version number of package */
|
||||||
|
#cmakedefine VERSION "@VERSION@"
|
||||||
|
|
||||||
|
/* Set to 1 if GIF library is installed */
|
||||||
|
#cmakedefine WEBP_HAVE_GIF 1
|
||||||
|
|
||||||
|
/* Set to 1 if OpenGL is supported */
|
||||||
|
#cmakedefine WEBP_HAVE_GL 1
|
||||||
|
|
||||||
|
/* Set to 1 if JPEG library is installed */
|
||||||
|
#cmakedefine WEBP_HAVE_JPEG 1
|
||||||
|
|
||||||
|
/* Set to 1 if NEON is supported */
|
||||||
|
#cmakedefine WEBP_HAVE_NEON
|
||||||
|
|
||||||
|
/* Set to 1 if runtime detection of NEON is enabled */
|
||||||
|
/* TODO: handle properly in CMake */
|
||||||
|
#cmakedefine WEBP_HAVE_NEON_RTCD
|
||||||
|
|
||||||
|
/* Set to 1 if PNG library is installed */
|
||||||
|
#cmakedefine WEBP_HAVE_PNG 1
|
||||||
|
|
||||||
|
/* Set to 1 if SDL library is installed */
|
||||||
|
#cmakedefine WEBP_HAVE_SDL 1
|
||||||
|
|
||||||
|
/* Set to 1 if SSE2 is supported */
|
||||||
|
#cmakedefine WEBP_HAVE_SSE2 1
|
||||||
|
|
||||||
|
/* Set to 1 if SSE4.1 is supported */
|
||||||
|
#cmakedefine WEBP_HAVE_SSE41 1
|
||||||
|
|
||||||
|
/* Set to 1 if TIFF library is installed */
|
||||||
|
#cmakedefine WEBP_HAVE_TIFF 1
|
||||||
|
|
||||||
|
/* Enable near lossless encoding */
|
||||||
|
#cmakedefine WEBP_NEAR_LOSSLESS 1
|
||||||
|
|
||||||
|
/* Undefine this to disable thread support. */
|
||||||
|
#cmakedefine WEBP_USE_THREAD 1
|
||||||
|
|
||||||
|
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
||||||
|
significant byte first (like Motorola and SPARC, unlike Intel). */
|
||||||
|
#if defined AC_APPLE_UNIVERSAL_BUILD
|
||||||
|
# if defined __BIG_ENDIAN__
|
||||||
|
# define WORDS_BIGENDIAN 1
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# ifndef WORDS_BIGENDIAN
|
||||||
|
# undef WORDS_BIGENDIAN
|
||||||
|
# endif
|
||||||
|
#endif
|
159
external/libwebp/libwebp/cmake/cpu.cmake
vendored
Normal file
159
external/libwebp/libwebp/cmake/cpu.cmake
vendored
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
# Copyright (c) 2021 Google LLC.
|
||||||
|
#
|
||||||
|
# Use of this source code is governed by a BSD-style license
|
||||||
|
# that can be found in the LICENSE file in the root of the source
|
||||||
|
# tree. An additional intellectual property rights grant can be found
|
||||||
|
# in the file PATENTS. All contributing project authors may
|
||||||
|
# be found in the AUTHORS file in the root of the source tree.
|
||||||
|
|
||||||
|
# Check for SIMD extensions.
|
||||||
|
include(CMakePushCheckState)
|
||||||
|
|
||||||
|
function(webp_check_compiler_flag WEBP_SIMD_FLAG ENABLE_SIMD)
|
||||||
|
if(NOT ENABLE_SIMD)
|
||||||
|
message(STATUS "Disabling ${WEBP_SIMD_FLAG} optimization.")
|
||||||
|
set(WEBP_HAVE_${WEBP_SIMD_FLAG} 0 PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
unset(WEBP_HAVE_FLAG_${WEBP_SIMD_FLAG} CACHE)
|
||||||
|
cmake_push_check_state()
|
||||||
|
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
check_c_source_compiles(
|
||||||
|
"
|
||||||
|
#include \"${CMAKE_CURRENT_LIST_DIR}/../src/dsp/dsp.h\"
|
||||||
|
int main(void) {
|
||||||
|
#if !defined(WEBP_USE_${WEBP_SIMD_FLAG})
|
||||||
|
this is not valid code
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
"
|
||||||
|
WEBP_HAVE_FLAG_${WEBP_SIMD_FLAG})
|
||||||
|
cmake_pop_check_state()
|
||||||
|
if(WEBP_HAVE_FLAG_${WEBP_SIMD_FLAG})
|
||||||
|
set(WEBP_HAVE_${WEBP_SIMD_FLAG} 1 PARENT_SCOPE)
|
||||||
|
else()
|
||||||
|
set(WEBP_HAVE_${WEBP_SIMD_FLAG} 0 PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# those are included in the names of WEBP_USE_* in c++ code.
|
||||||
|
set(WEBP_SIMD_FLAGS "SSE41;SSE2;MIPS32;MIPS_DSP_R2;NEON;MSA")
|
||||||
|
set(WEBP_SIMD_FILE_EXTENSIONS
|
||||||
|
"_sse41.c;_sse2.c;_mips32.c;_mips_dsp_r2.c;_neon.c;_msa.c")
|
||||||
|
if(MSVC AND CMAKE_C_COMPILER_ID STREQUAL "MSVC")
|
||||||
|
# With at least Visual Studio 12 (2013)+ /arch is not necessary to build SSE2
|
||||||
|
# or SSE4 code unless a lesser /arch is forced. MSVC does not have a SSE4
|
||||||
|
# flag, but an AVX one. Using that with SSE4 code risks generating illegal
|
||||||
|
# instructions when used on machines with SSE4 only. The flags are left for
|
||||||
|
# older (untested) versions to avoid any potential compatibility issues.
|
||||||
|
if(MSVC_VERSION GREATER_EQUAL 1800 AND NOT CMAKE_C_FLAGS MATCHES "/arch:")
|
||||||
|
set(SIMD_ENABLE_FLAGS)
|
||||||
|
else()
|
||||||
|
set(SIMD_ENABLE_FLAGS "/arch:AVX;/arch:SSE2;;;;")
|
||||||
|
endif()
|
||||||
|
set(SIMD_DISABLE_FLAGS)
|
||||||
|
else()
|
||||||
|
set(SIMD_ENABLE_FLAGS "-msse4.1;-msse2;-mips32;-mdspr2;-mfpu=neon;-mmsa")
|
||||||
|
set(SIMD_DISABLE_FLAGS "-mno-sse4.1;-mno-sse2;;-mno-dspr2;;-mno-msa")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(WEBP_SIMD_FILES_TO_INCLUDE)
|
||||||
|
set(WEBP_SIMD_FLAGS_TO_INCLUDE)
|
||||||
|
|
||||||
|
if(${ANDROID})
|
||||||
|
if(${ANDROID_ABI} STREQUAL "armeabi-v7a")
|
||||||
|
# This is because Android studio uses the configuration "-march=armv7-a
|
||||||
|
# -mfloat-abi=softfp -mfpu=vfpv3-d16" that does not trigger neon
|
||||||
|
# optimizations but should (as this configuration does not exist anymore).
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=neon ")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
list(LENGTH WEBP_SIMD_FLAGS WEBP_SIMD_FLAGS_LENGTH)
|
||||||
|
math(EXPR WEBP_SIMD_FLAGS_RANGE "${WEBP_SIMD_FLAGS_LENGTH} - 1")
|
||||||
|
|
||||||
|
foreach(I_SIMD RANGE ${WEBP_SIMD_FLAGS_RANGE})
|
||||||
|
# With Emscripten 2.0.9 -msimd128 -mfpu=neon will enable NEON, but the source
|
||||||
|
# will fail to compile.
|
||||||
|
if(EMSCRIPTEN AND ${I_SIMD} GREATER_EQUAL 2)
|
||||||
|
break()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
list(GET WEBP_SIMD_FLAGS ${I_SIMD} WEBP_SIMD_FLAG)
|
||||||
|
|
||||||
|
# First try with no extra flag added as the compiler might have default flags
|
||||||
|
# (especially on Android).
|
||||||
|
unset(WEBP_HAVE_${WEBP_SIMD_FLAG} CACHE)
|
||||||
|
cmake_push_check_state()
|
||||||
|
set(CMAKE_REQUIRED_FLAGS)
|
||||||
|
webp_check_compiler_flag(${WEBP_SIMD_FLAG} ${WEBP_ENABLE_SIMD})
|
||||||
|
if(NOT WEBP_HAVE_${WEBP_SIMD_FLAG})
|
||||||
|
list(GET SIMD_ENABLE_FLAGS ${I_SIMD} SIMD_COMPILE_FLAG)
|
||||||
|
if(EMSCRIPTEN)
|
||||||
|
set(SIMD_COMPILE_FLAG "-msimd128 ${SIMD_COMPILE_FLAG}")
|
||||||
|
endif()
|
||||||
|
set(CMAKE_REQUIRED_FLAGS ${SIMD_COMPILE_FLAG})
|
||||||
|
webp_check_compiler_flag(${WEBP_SIMD_FLAG} ${WEBP_ENABLE_SIMD})
|
||||||
|
else()
|
||||||
|
if(MSVC AND SIMD_ENABLE_FLAGS)
|
||||||
|
# The detection for SSE2/SSE4 support under MSVC is based on the compiler
|
||||||
|
# version so e.g., clang-cl will require flags to enable the assembly.
|
||||||
|
list(GET SIMD_ENABLE_FLAGS ${I_SIMD} SIMD_COMPILE_FLAG)
|
||||||
|
else()
|
||||||
|
set(SIMD_COMPILE_FLAG " ")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
# Check which files we should include or not.
|
||||||
|
list(GET WEBP_SIMD_FILE_EXTENSIONS ${I_SIMD} WEBP_SIMD_FILE_EXTENSION)
|
||||||
|
file(GLOB SIMD_FILES "${CMAKE_CURRENT_LIST_DIR}/../"
|
||||||
|
"src/dsp/*${WEBP_SIMD_FILE_EXTENSION}")
|
||||||
|
if(WEBP_HAVE_${WEBP_SIMD_FLAG})
|
||||||
|
# Memorize the file and flags.
|
||||||
|
foreach(FILE ${SIMD_FILES})
|
||||||
|
list(APPEND WEBP_SIMD_FILES_TO_INCLUDE ${FILE})
|
||||||
|
list(APPEND WEBP_SIMD_FLAGS_TO_INCLUDE ${SIMD_COMPILE_FLAG})
|
||||||
|
endforeach()
|
||||||
|
else()
|
||||||
|
# Remove the file from the list.
|
||||||
|
foreach(FILE ${SIMD_FILES})
|
||||||
|
list(APPEND WEBP_SIMD_FILES_NOT_TO_INCLUDE ${FILE})
|
||||||
|
endforeach()
|
||||||
|
# Explicitly disable SIMD.
|
||||||
|
if(SIMD_DISABLE_FLAGS)
|
||||||
|
list(GET SIMD_DISABLE_FLAGS ${I_SIMD} SIMD_COMPILE_FLAG)
|
||||||
|
include(CheckCCompilerFlag)
|
||||||
|
if(SIMD_COMPILE_FLAG)
|
||||||
|
# Between 3.17.0 and 3.18.2 check_cxx_compiler_flag() sets a normal
|
||||||
|
# variable at parent scope while check_cxx_source_compiles() continues
|
||||||
|
# to set an internal cache variable, so we unset both to avoid the
|
||||||
|
# failure / success state persisting between checks. See
|
||||||
|
# https://gitlab.kitware.com/cmake/cmake/-/issues/21207.
|
||||||
|
unset(HAS_COMPILE_FLAG)
|
||||||
|
unset(HAS_COMPILE_FLAG CACHE)
|
||||||
|
check_c_compiler_flag(${SIMD_COMPILE_FLAG} HAS_COMPILE_FLAG)
|
||||||
|
if(HAS_COMPILE_FLAG)
|
||||||
|
# Do one more check for Clang to circumvent CMake issue 13194.
|
||||||
|
if(COMMAND check_compiler_flag_common_patterns)
|
||||||
|
# Only in CMake 3.0 and above.
|
||||||
|
check_compiler_flag_common_patterns(COMMON_PATTERNS)
|
||||||
|
else()
|
||||||
|
set(COMMON_PATTERNS)
|
||||||
|
endif()
|
||||||
|
set(CMAKE_REQUIRED_DEFINITIONS ${SIMD_COMPILE_FLAG})
|
||||||
|
check_c_source_compiles(
|
||||||
|
"int main(void) {return 0;}" FLAG_${SIMD_COMPILE_FLAG} FAIL_REGEX
|
||||||
|
"warning: argument unused during compilation:" ${COMMON_PATTERNS})
|
||||||
|
if(NOT FLAG_${SIMD_COMPILE_FLAG})
|
||||||
|
unset(HAS_COMPILE_FLAG)
|
||||||
|
unset(HAS_COMPILE_FLAG CACHE)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
if(HAS_COMPILE_FLAG)
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SIMD_COMPILE_FLAG}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
cmake_pop_check_state()
|
||||||
|
endforeach()
|
172
external/libwebp/libwebp/cmake/deps.cmake
vendored
Normal file
172
external/libwebp/libwebp/cmake/deps.cmake
vendored
Normal file
@ -0,0 +1,172 @@
|
|||||||
|
# Copyright (c) 2021 Google LLC.
|
||||||
|
#
|
||||||
|
# Use of this source code is governed by a BSD-style license
|
||||||
|
# that can be found in the LICENSE file in the root of the source
|
||||||
|
# tree. An additional intellectual property rights grant can be found
|
||||||
|
# in the file PATENTS. All contributing project authors may
|
||||||
|
# be found in the AUTHORS file in the root of the source tree.
|
||||||
|
|
||||||
|
# Generate the config.h to compile with specific intrinsics / libs.
|
||||||
|
|
||||||
|
# Check for compiler options.
|
||||||
|
include(CheckCSourceCompiles)
|
||||||
|
check_c_source_compiles(
|
||||||
|
"
|
||||||
|
int main(void) {
|
||||||
|
(void)__builtin_bswap16(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
"
|
||||||
|
HAVE_BUILTIN_BSWAP16)
|
||||||
|
check_c_source_compiles(
|
||||||
|
"
|
||||||
|
int main(void) {
|
||||||
|
(void)__builtin_bswap32(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
"
|
||||||
|
HAVE_BUILTIN_BSWAP32)
|
||||||
|
check_c_source_compiles(
|
||||||
|
"
|
||||||
|
int main(void) {
|
||||||
|
(void)__builtin_bswap64(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
"
|
||||||
|
HAVE_BUILTIN_BSWAP64)
|
||||||
|
|
||||||
|
# Check for libraries.
|
||||||
|
if(WEBP_USE_THREAD)
|
||||||
|
find_package(Threads)
|
||||||
|
if(Threads_FOUND)
|
||||||
|
# work around cmake bug on QNX (https://cmake.org/Bug/view.php?id=11333)
|
||||||
|
if(CMAKE_USE_PTHREADS_INIT AND NOT CMAKE_SYSTEM_NAME STREQUAL "QNX")
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
|
||||||
|
endif()
|
||||||
|
list(APPEND WEBP_DEP_LIBRARIES Threads::Threads)
|
||||||
|
endif()
|
||||||
|
set(WEBP_USE_THREAD ${Threads_FOUND})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# TODO: this seems unused, check with autotools.
|
||||||
|
set(LT_OBJDIR ".libs/")
|
||||||
|
|
||||||
|
# Only useful for vwebp, so useless for now.
|
||||||
|
find_package(OpenGL)
|
||||||
|
set(WEBP_HAVE_GL ${OPENGL_FOUND})
|
||||||
|
|
||||||
|
# Check if we need to link to the C math library. We do not look for it as it is
|
||||||
|
# not found when cross-compiling, while it is here.
|
||||||
|
check_c_source_compiles(
|
||||||
|
"
|
||||||
|
#include <math.h>
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
return (int)pow(argc, 2.5);
|
||||||
|
}
|
||||||
|
"
|
||||||
|
HAVE_MATH_LIBRARY)
|
||||||
|
if(NOT HAVE_MATH_LIBRARY)
|
||||||
|
message(STATUS "Adding -lm flag.")
|
||||||
|
list(APPEND SHARPYUV_DEP_LIBRARIES m)
|
||||||
|
list(APPEND WEBP_DEP_LIBRARIES m)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Find the standard image libraries.
|
||||||
|
set(WEBP_DEP_IMG_LIBRARIES)
|
||||||
|
set(WEBP_DEP_IMG_INCLUDE_DIRS)
|
||||||
|
if(WEBP_FIND_IMG_LIBS)
|
||||||
|
foreach(I_LIB PNG JPEG TIFF)
|
||||||
|
# Disable tiff when compiling in static mode as it is failing on Ubuntu.
|
||||||
|
if(WEBP_LINK_STATIC AND ${I_LIB} STREQUAL "TIFF")
|
||||||
|
message(STATUS "TIFF is disabled when statically linking.")
|
||||||
|
continue()
|
||||||
|
endif()
|
||||||
|
find_package(${I_LIB})
|
||||||
|
set(WEBP_HAVE_${I_LIB} ${${I_LIB}_FOUND})
|
||||||
|
if(${I_LIB}_FOUND)
|
||||||
|
list(APPEND WEBP_DEP_IMG_LIBRARIES ${${I_LIB}_LIBRARIES})
|
||||||
|
list(APPEND WEBP_DEP_IMG_INCLUDE_DIRS ${${I_LIB}_INCLUDE_DIR}
|
||||||
|
${${I_LIB}_INCLUDE_DIRS})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
if(WEBP_DEP_IMG_INCLUDE_DIRS)
|
||||||
|
list(REMOVE_DUPLICATES WEBP_DEP_IMG_INCLUDE_DIRS)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# GIF detection, gifdec isn't part of the imageio lib.
|
||||||
|
include(CMakePushCheckState)
|
||||||
|
set(WEBP_DEP_GIF_LIBRARIES)
|
||||||
|
set(WEBP_DEP_GIF_INCLUDE_DIRS)
|
||||||
|
find_package(GIF)
|
||||||
|
set(WEBP_HAVE_GIF ${GIF_FOUND})
|
||||||
|
if(GIF_FOUND)
|
||||||
|
# GIF find_package only locates the header and library, it doesn't fail
|
||||||
|
# compile tests when detecting the version, but falls back to 3 (as of at
|
||||||
|
# least cmake 3.7.2). Make sure the library links to avoid incorrect
|
||||||
|
# detection when cross compiling.
|
||||||
|
cmake_push_check_state()
|
||||||
|
set(CMAKE_REQUIRED_LIBRARIES ${GIF_LIBRARIES})
|
||||||
|
set(CMAKE_REQUIRED_INCLUDES ${GIF_INCLUDE_DIR})
|
||||||
|
check_c_source_compiles(
|
||||||
|
"
|
||||||
|
#include <gif_lib.h>
|
||||||
|
int main(void) {
|
||||||
|
(void)DGifOpenFileHandle;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
"
|
||||||
|
GIF_COMPILES)
|
||||||
|
cmake_pop_check_state()
|
||||||
|
if(GIF_COMPILES)
|
||||||
|
list(APPEND WEBP_DEP_GIF_LIBRARIES ${GIF_LIBRARIES})
|
||||||
|
list(APPEND WEBP_DEP_GIF_INCLUDE_DIRS ${GIF_INCLUDE_DIR})
|
||||||
|
else()
|
||||||
|
unset(GIF_FOUND)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Check for specific headers.
|
||||||
|
include(CheckIncludeFiles)
|
||||||
|
check_include_files(GLUT/glut.h HAVE_GLUT_GLUT_H)
|
||||||
|
check_include_files(GL/glut.h HAVE_GL_GLUT_H)
|
||||||
|
check_include_files(OpenGL/glut.h HAVE_OPENGL_GLUT_H)
|
||||||
|
check_include_files(shlwapi.h HAVE_SHLWAPI_H)
|
||||||
|
check_include_files(unistd.h HAVE_UNISTD_H)
|
||||||
|
check_include_files(wincodec.h HAVE_WINCODEC_H)
|
||||||
|
check_include_files(windows.h HAVE_WINDOWS_H)
|
||||||
|
|
||||||
|
# Windows specifics
|
||||||
|
if(HAVE_WINCODEC_H)
|
||||||
|
list(APPEND WEBP_DEP_LIBRARIES shlwapi ole32 windowscodecs)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Check for SIMD extensions.
|
||||||
|
include(${CMAKE_CURRENT_LIST_DIR}/cpu.cmake)
|
||||||
|
|
||||||
|
# Define extra info.
|
||||||
|
set(PACKAGE ${PROJECT_NAME})
|
||||||
|
set(PACKAGE_NAME ${PROJECT_NAME})
|
||||||
|
|
||||||
|
# Read from configure.ac.
|
||||||
|
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/configure.ac CONFIGURE_AC)
|
||||||
|
string(REGEX MATCHALL "\\[([0-9a-z\\.:/]*)\\]" CONFIGURE_AC_PACKAGE_INFO
|
||||||
|
${CONFIGURE_AC})
|
||||||
|
function(strip_bracket VAR)
|
||||||
|
string(LENGTH ${${VAR}} TMP_LEN)
|
||||||
|
math(EXPR TMP_LEN ${TMP_LEN}-2)
|
||||||
|
string(SUBSTRING ${${VAR}} 1 ${TMP_LEN} TMP_SUB)
|
||||||
|
set(${VAR} ${TMP_SUB} PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
list(GET CONFIGURE_AC_PACKAGE_INFO 1 PACKAGE_VERSION)
|
||||||
|
strip_bracket(PACKAGE_VERSION)
|
||||||
|
list(GET CONFIGURE_AC_PACKAGE_INFO 2 PACKAGE_BUGREPORT)
|
||||||
|
strip_bracket(PACKAGE_BUGREPORT)
|
||||||
|
list(GET CONFIGURE_AC_PACKAGE_INFO 3 PACKAGE_URL)
|
||||||
|
strip_bracket(PACKAGE_URL)
|
||||||
|
|
||||||
|
# Build more info.
|
||||||
|
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
|
||||||
|
set(PACKAGE_TARNAME ${PACKAGE_NAME})
|
||||||
|
set(VERSION ${PACKAGE_VERSION})
|
4
external/libwebp/libwebp/codereview.settings
vendored
Normal file
4
external/libwebp/libwebp/codereview.settings
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# This file is used by git cl to get repository specific information.
|
||||||
|
GERRIT_HOST: True
|
||||||
|
CODE_REVIEW_SERVER: chromium-review.googlesource.com
|
||||||
|
GERRIT_SQUASH_UPLOADS: False
|
803
external/libwebp/libwebp/configure.ac
vendored
Normal file
803
external/libwebp/libwebp/configure.ac
vendored
Normal file
@ -0,0 +1,803 @@
|
|||||||
|
AC_INIT([libwebp], [1.3.1],
|
||||||
|
[https://bugs.chromium.org/p/webp],,
|
||||||
|
[https://developers.google.com/speed/webp])
|
||||||
|
AC_CANONICAL_HOST
|
||||||
|
AC_PREREQ([2.60])
|
||||||
|
AM_INIT_AUTOMAKE([-Wall foreign subdir-objects])
|
||||||
|
|
||||||
|
dnl === automake >= 1.12 requires this for 'unusual archivers' support.
|
||||||
|
dnl === it must occur before LT_INIT (AC_PROG_LIBTOOL).
|
||||||
|
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
|
||||||
|
|
||||||
|
dnl === AC_PROG_LIBTOOL is deprecated.
|
||||||
|
m4_ifdef([LT_INIT], [LT_INIT], [AC_PROG_LIBTOOL])
|
||||||
|
AC_PROG_SED
|
||||||
|
AM_PROG_CC_C_O
|
||||||
|
|
||||||
|
dnl === Enable less verbose output when building.
|
||||||
|
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
||||||
|
|
||||||
|
dnl == test endianness
|
||||||
|
AC_C_BIGENDIAN
|
||||||
|
|
||||||
|
dnl === SET_IF_UNSET(shell_var, value)
|
||||||
|
dnl === Set the shell variable 'shell_var' to 'value' if it is unset.
|
||||||
|
AC_DEFUN([SET_IF_UNSET], [test "${$1+set}" = "set" || $1=$2])
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([everything],
|
||||||
|
AS_HELP_STRING([--enable-everything],
|
||||||
|
[Enable all optional targets. These can still be
|
||||||
|
disabled with --disable-target]),
|
||||||
|
[SET_IF_UNSET([enable_libsharpyuv], [$enableval])
|
||||||
|
SET_IF_UNSET([enable_libwebpdecoder], [$enableval])
|
||||||
|
SET_IF_UNSET([enable_libwebpdemux], [$enableval])
|
||||||
|
SET_IF_UNSET([enable_libwebpextras], [$enableval])
|
||||||
|
SET_IF_UNSET([enable_libwebpmux], [$enableval])])
|
||||||
|
|
||||||
|
dnl === Check whether libwebpmux should be built
|
||||||
|
AC_MSG_CHECKING(whether libwebpmux is to be built)
|
||||||
|
AC_ARG_ENABLE([libwebpmux],
|
||||||
|
AS_HELP_STRING([--disable-libwebpmux],
|
||||||
|
[Disable libwebpmux @<:@default=no@:>@]),
|
||||||
|
[], [enable_libwebpmux=yes])
|
||||||
|
AC_MSG_RESULT(${enable_libwebpmux-no})
|
||||||
|
AM_CONDITIONAL([BUILD_MUX], [test "$enable_libwebpmux" = "yes"])
|
||||||
|
|
||||||
|
dnl === Check whether libwebpdemux should be built
|
||||||
|
AC_MSG_CHECKING(whether libwebpdemux is to be built)
|
||||||
|
AC_ARG_ENABLE([libwebpdemux],
|
||||||
|
AS_HELP_STRING([--disable-libwebpdemux],
|
||||||
|
[Disable libwebpdemux @<:@default=no@:>@]),
|
||||||
|
[], [enable_libwebpdemux=yes])
|
||||||
|
AC_MSG_RESULT(${enable_libwebpdemux-no})
|
||||||
|
AM_CONDITIONAL([BUILD_DEMUX], [test "$enable_libwebpdemux" = "yes"])
|
||||||
|
|
||||||
|
dnl === Check whether decoder library should be built.
|
||||||
|
AC_MSG_CHECKING(whether decoder library is to be built)
|
||||||
|
AC_ARG_ENABLE([libwebpdecoder],
|
||||||
|
AS_HELP_STRING([--enable-libwebpdecoder],
|
||||||
|
[Build libwebpdecoder @<:@default=no@:>@]))
|
||||||
|
AC_MSG_RESULT(${enable_libwebpdecoder-no})
|
||||||
|
AM_CONDITIONAL([BUILD_LIBWEBPDECODER], [test "$enable_libwebpdecoder" = "yes"])
|
||||||
|
|
||||||
|
dnl === Check whether libwebpextras should be built
|
||||||
|
AC_MSG_CHECKING(whether libwebpextras is to be built)
|
||||||
|
AC_ARG_ENABLE([libwebpextras],
|
||||||
|
AS_HELP_STRING([--enable-libwebpextras],
|
||||||
|
[Build libwebpextras @<:@default=no@:>@]))
|
||||||
|
AC_MSG_RESULT(${enable_libwebpextras-no})
|
||||||
|
AM_CONDITIONAL([BUILD_EXTRAS], [test "$enable_libwebpextras" = "yes"])
|
||||||
|
|
||||||
|
dnl === If --enable-asserts is not defined, define NDEBUG
|
||||||
|
|
||||||
|
AC_MSG_CHECKING(whether asserts are enabled)
|
||||||
|
AC_ARG_ENABLE([asserts],
|
||||||
|
AS_HELP_STRING([--enable-asserts],
|
||||||
|
[Enable assert checks]))
|
||||||
|
if test "x${enable_asserts-no}" = "xno"; then
|
||||||
|
AM_CPPFLAGS="${AM_CPPFLAGS} -DNDEBUG"
|
||||||
|
fi
|
||||||
|
AC_MSG_RESULT(${enable_asserts-no})
|
||||||
|
AC_SUBST([AM_CPPFLAGS])
|
||||||
|
|
||||||
|
AC_ARG_WITH([pkgconfigdir], AS_HELP_STRING([--with-pkgconfigdir=DIR],
|
||||||
|
[Path to the pkgconfig directory @<:@LIBDIR/pkgconfig@:>@]),
|
||||||
|
[pkgconfigdir="$withval"], [pkgconfigdir='${libdir}/pkgconfig'])
|
||||||
|
AC_SUBST([pkgconfigdir])
|
||||||
|
|
||||||
|
dnl === TEST_AND_ADD_CFLAGS(var, flag)
|
||||||
|
dnl === Checks whether $CC supports 'flag' and adds it to 'var'
|
||||||
|
dnl === on success.
|
||||||
|
AC_DEFUN([TEST_AND_ADD_CFLAGS],
|
||||||
|
[SAVED_CFLAGS="$CFLAGS"
|
||||||
|
CFLAGS="-Werror $2"
|
||||||
|
AC_MSG_CHECKING([whether $CC supports $2])
|
||||||
|
dnl Note AC_LANG_PROGRAM([]) uses an old-style main definition.
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }])],
|
||||||
|
[AC_MSG_RESULT([yes])]
|
||||||
|
dnl Simply append the variable avoiding a
|
||||||
|
dnl compatibility ifdef for AS_VAR_APPEND as this
|
||||||
|
dnl variable shouldn't grow all that large.
|
||||||
|
[$1="${$1} $2"],
|
||||||
|
[AC_MSG_RESULT([no])])
|
||||||
|
CFLAGS="$SAVED_CFLAGS"])
|
||||||
|
TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-fvisibility=hidden])
|
||||||
|
TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wall])
|
||||||
|
TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wconstant-conversion])
|
||||||
|
TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wdeclaration-after-statement])
|
||||||
|
TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wextra])
|
||||||
|
TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wfloat-conversion])
|
||||||
|
TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wformat -Wformat-nonliteral])
|
||||||
|
TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wformat -Wformat-security])
|
||||||
|
TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wmissing-declarations])
|
||||||
|
TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wmissing-prototypes])
|
||||||
|
TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wold-style-definition])
|
||||||
|
TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wparentheses-equality])
|
||||||
|
TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wshadow])
|
||||||
|
TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wshorten-64-to-32])
|
||||||
|
TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wundef])
|
||||||
|
TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wunreachable-code-aggressive])
|
||||||
|
TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wunreachable-code])
|
||||||
|
TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wunused-but-set-variable])
|
||||||
|
TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wunused])
|
||||||
|
TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wvla])
|
||||||
|
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62040
|
||||||
|
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61622
|
||||||
|
AS_IF([test "$GCC" = "yes" ], [
|
||||||
|
gcc_version=`$CC -dumpversion`
|
||||||
|
gcc_wht_bug=""
|
||||||
|
case "$host_cpu" in
|
||||||
|
aarch64|arm64)
|
||||||
|
case "$gcc_version" in
|
||||||
|
4.9|4.9.0|4.9.1) gcc_wht_bug=yes ;;
|
||||||
|
esac
|
||||||
|
esac
|
||||||
|
AS_IF([test "$gcc_wht_bug" = "yes"], [
|
||||||
|
TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-frename-registers])])])
|
||||||
|
# Use -flax-vector-conversions, if available, when building intrinsics with
|
||||||
|
# older versions of gcc. The flag appeared in 4.3.x, but if backported, and
|
||||||
|
# -fno-lax-vector-conversions is set, errors may occur with the intrinsics
|
||||||
|
# files along with the older system includes, e.g., emmintrin.h.
|
||||||
|
# Originally observed with cc (GCC) 4.2.1 20070831 patched [FreeBSD] (9.3).
|
||||||
|
# https://bugs.chromium.org/p/webp/issues/detail?id=274
|
||||||
|
AS_IF([test "$GCC" = "yes" ], [
|
||||||
|
case "$host_cpu" in
|
||||||
|
amd64|i?86|x86_64)
|
||||||
|
AC_COMPILE_IFELSE(
|
||||||
|
dnl only check for -flax-vector-conversions with older gcc, skip
|
||||||
|
dnl clang as it reports itself as 4.2.1, but the flag isn't needed.
|
||||||
|
[AC_LANG_SOURCE([#if !defined(__clang__) && defined(__GNUC__) && \
|
||||||
|
((__GNUC__ << 8) | __GNUC_MINOR__) < 0x403
|
||||||
|
#error old gcc
|
||||||
|
#endif
|
||||||
|
int main(void) { return 0; }
|
||||||
|
])],,
|
||||||
|
[TEST_AND_ADD_CFLAGS([INTRINSICS_CFLAGS],
|
||||||
|
[-flax-vector-conversions])])
|
||||||
|
;;
|
||||||
|
esac])
|
||||||
|
AC_SUBST([AM_CFLAGS])
|
||||||
|
|
||||||
|
dnl === Check for machine specific flags
|
||||||
|
AC_ARG_ENABLE([sse4.1],
|
||||||
|
AS_HELP_STRING([--disable-sse4.1],
|
||||||
|
[Disable detection of SSE4.1 support
|
||||||
|
@<:@default=auto@:>@]))
|
||||||
|
|
||||||
|
AS_IF([test "x$enable_sse4_1" != "xno" -a "x$enable_sse2" != "xno"], [
|
||||||
|
SSE41_FLAGS="$INTRINSICS_CFLAGS $SSE41_FLAGS"
|
||||||
|
TEST_AND_ADD_CFLAGS([SSE41_FLAGS], [-msse4.1])
|
||||||
|
AS_IF([test -n "$SSE41_FLAGS"], [
|
||||||
|
SAVED_CFLAGS=$CFLAGS
|
||||||
|
CFLAGS="$CFLAGS $SSE41_FLAGS"
|
||||||
|
AC_CHECK_HEADER([smmintrin.h],
|
||||||
|
[AC_DEFINE(WEBP_HAVE_SSE41, [1],
|
||||||
|
[Set to 1 if SSE4.1 is supported])],
|
||||||
|
[SSE41_FLAGS=""])
|
||||||
|
CFLAGS=$SAVED_CFLAGS])
|
||||||
|
AC_SUBST([SSE41_FLAGS])])
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([sse2],
|
||||||
|
AS_HELP_STRING([--disable-sse2],
|
||||||
|
[Disable detection of SSE2 support
|
||||||
|
@<:@default=auto@:>@]))
|
||||||
|
|
||||||
|
AS_IF([test "x$enable_sse2" != "xno"], [
|
||||||
|
SSE2_FLAGS="$INTRINSICS_CFLAGS $SSE2_FLAGS"
|
||||||
|
TEST_AND_ADD_CFLAGS([SSE2_FLAGS], [-msse2])
|
||||||
|
AS_IF([test -n "$SSE2_FLAGS"], [
|
||||||
|
SAVED_CFLAGS=$CFLAGS
|
||||||
|
CFLAGS="$CFLAGS $SSE2_FLAGS"
|
||||||
|
AC_CHECK_HEADER([emmintrin.h],
|
||||||
|
[AC_DEFINE(WEBP_HAVE_SSE2, [1],
|
||||||
|
[Set to 1 if SSE2 is supported])],
|
||||||
|
[SSE2_FLAGS=""])
|
||||||
|
CFLAGS=$SAVED_CFLAGS])
|
||||||
|
AC_SUBST([SSE2_FLAGS])])
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([neon],
|
||||||
|
AS_HELP_STRING([--disable-neon],
|
||||||
|
[Disable detection of NEON support
|
||||||
|
@<:@default=auto@:>@]))
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([neon_rtcd],
|
||||||
|
AS_HELP_STRING([--disable-neon-rtcd],
|
||||||
|
[Disable runtime detection of NEON support via
|
||||||
|
/proc/cpuinfo on Linux hosts
|
||||||
|
@<:@default=auto@:>@]))
|
||||||
|
# For ARM(7) hosts:
|
||||||
|
# Both NEON flags unset and NEON support detected = build all modules with NEON
|
||||||
|
# NEON detected with the use of -mfpu=neon = build only NEON modules with NEON
|
||||||
|
AS_IF([test "x$enable_neon" != "xno"], [
|
||||||
|
case "$host_cpu" in
|
||||||
|
arm|armv7*)
|
||||||
|
# Test for NEON support without flags before falling back to -mfpu=neon
|
||||||
|
for flag in '' '-mfpu=neon'; do
|
||||||
|
LOCAL_NEON_FLAGS="$INTRINSICS_CFLAGS $NEON_FLAGS"
|
||||||
|
TEST_AND_ADD_CFLAGS([LOCAL_NEON_FLAGS], [$flag])
|
||||||
|
SAVED_CFLAGS=$CFLAGS
|
||||||
|
CFLAGS="$CFLAGS $LOCAL_NEON_FLAGS"
|
||||||
|
|
||||||
|
dnl Note AC_LANG_PROGRAM([]) uses an old-style main definition.
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
|
||||||
|
#include <arm_neon.h>
|
||||||
|
int main(void) {
|
||||||
|
int8x8_t v = vdup_n_s8(0);
|
||||||
|
(void)v;
|
||||||
|
return 0;
|
||||||
|
}])],
|
||||||
|
[NEON_FLAGS="$(echo $LOCAL_NEON_FLAGS | $SED 's/^ *//')"
|
||||||
|
AS_IF([test -n "$NEON_FLAGS"], [
|
||||||
|
AS_IF([test "${host_os%%-*}" = "linux" -o \
|
||||||
|
"x$enable_neon_rtcd" = "xno"], [
|
||||||
|
CFLAGS=$SAVED_CFLAGS
|
||||||
|
AC_DEFINE(WEBP_HAVE_NEON, [1], [Set to 1 if NEON is supported])
|
||||||
|
break
|
||||||
|
],[
|
||||||
|
AC_MSG_WARN(m4_normalize([NEON runtime cpu-detection is
|
||||||
|
unavailable for ${host_os%%-*}. Force
|
||||||
|
with CFLAGS=-mfpu=neon or
|
||||||
|
--disable-neon-rtcd.]))
|
||||||
|
enable_neon_rtcd=no
|
||||||
|
NEON_FLAGS=""
|
||||||
|
])
|
||||||
|
],[
|
||||||
|
CFLAGS=$SAVED_CFLAGS
|
||||||
|
AC_DEFINE(WEBP_HAVE_NEON, [1], [Set to 1 if NEON is supported])
|
||||||
|
break
|
||||||
|
])])
|
||||||
|
CFLAGS=$SAVED_CFLAGS
|
||||||
|
done
|
||||||
|
|
||||||
|
AS_IF([test -n "$NEON_FLAGS"], [
|
||||||
|
# If NEON is available and rtcd is disabled apply NEON_FLAGS globally.
|
||||||
|
AS_IF([test "x$enable_neon_rtcd" = "xno"], [
|
||||||
|
AM_CFLAGS="$AM_CFLAGS $NEON_FLAGS"
|
||||||
|
NEON_FLAGS=""],
|
||||||
|
[AC_DEFINE(WEBP_HAVE_NEON_RTCD, [1],
|
||||||
|
[Set to 1 if runtime detection of NEON is enabled])])])
|
||||||
|
|
||||||
|
case "$host_os" in
|
||||||
|
*android*) AC_CHECK_HEADERS([cpu-features.h]) ;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
aarch64*|arm64*)
|
||||||
|
AC_DEFINE(WEBP_HAVE_NEON, [1], [Set to 1 if NEON is supported])
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
AC_SUBST([NEON_FLAGS])])
|
||||||
|
|
||||||
|
dnl === CLEAR_LIBVARS([var_pfx])
|
||||||
|
dnl === Clears <var_pfx>_{INCLUDES,LIBS}.
|
||||||
|
AC_DEFUN([CLEAR_LIBVARS], [$1_INCLUDES=""; $1_LIBS=""])
|
||||||
|
|
||||||
|
dnl === WITHLIB_OPTION([opt_pfx], [outvar_pfx])
|
||||||
|
dnl === Defines --with-<opt_pfx>{include,lib}dir options which set
|
||||||
|
dnl === the variables <outvar_pfx>_{INCLUDES,LIBS}.
|
||||||
|
AC_DEFUN([WITHLIB_OPTION],
|
||||||
|
[AC_ARG_WITH([$1includedir],
|
||||||
|
AS_HELP_STRING([--with-$1includedir=DIR],
|
||||||
|
[use $2 includes from DIR]),
|
||||||
|
$2_INCLUDES="-I$withval")
|
||||||
|
AC_ARG_WITH([$1libdir],
|
||||||
|
AS_HELP_STRING([--with-$1libdir=DIR],
|
||||||
|
[use $2 libraries from DIR]),
|
||||||
|
[$2_LIBS="-L$withval"])])
|
||||||
|
|
||||||
|
dnl === LIBCHECK_PROLOGUE([var_pfx])
|
||||||
|
dnl === Caches the current values of CPPFLAGS/LIBS in SAVED_* then
|
||||||
|
dnl === prepends the current values with <var_pfx>_{INCLUDES,LIBS}.
|
||||||
|
AC_DEFUN([LIBCHECK_PROLOGUE],
|
||||||
|
[SAVED_CPPFLAGS=$CPPFLAGS
|
||||||
|
SAVED_LIBS=$LIBS
|
||||||
|
CPPFLAGS="$$1_INCLUDES $CPPFLAGS"
|
||||||
|
LIBS="$$1_LIBS $LIBS"])
|
||||||
|
|
||||||
|
dnl === LIBCHECK_EPILOGUE([var_pfx])
|
||||||
|
dnl === Restores the values of CPPFLAGS/LIBS from SAVED_* and exports
|
||||||
|
dnl === <var_pfx>_{INCLUDES,LIBS} with AC_SUBST.
|
||||||
|
AC_DEFUN([LIBCHECK_EPILOGUE],
|
||||||
|
[AC_SUBST($1_LIBS)
|
||||||
|
AC_SUBST($1_INCLUDES)
|
||||||
|
CPPFLAGS=$SAVED_CPPFLAGS
|
||||||
|
LIBS=$SAVED_LIBS])
|
||||||
|
|
||||||
|
dnl === Check for gcc builtins
|
||||||
|
|
||||||
|
dnl === CHECK_FOR_BUILTIN([builtin], [param], [define])
|
||||||
|
dnl === links a C AC_LANG_PROGRAM, with <builtin>(<param>)
|
||||||
|
dnl === AC_DEFINE'ing <define> if successful.
|
||||||
|
AC_DEFUN([CHECK_FOR_BUILTIN],
|
||||||
|
[AC_LANG_PUSH([C])
|
||||||
|
AC_MSG_CHECKING([for $1])
|
||||||
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([], [(void)$1($2)])],
|
||||||
|
[AC_MSG_RESULT([yes])
|
||||||
|
AC_DEFINE([$3], [1],
|
||||||
|
[Set to 1 if $1 is available])],
|
||||||
|
[AC_MSG_RESULT([no])]),
|
||||||
|
AC_LANG_POP])
|
||||||
|
|
||||||
|
dnl AC_CHECK_FUNC doesn't work with builtin's.
|
||||||
|
CHECK_FOR_BUILTIN([__builtin_bswap16], [1u << 15], [HAVE_BUILTIN_BSWAP16])
|
||||||
|
CHECK_FOR_BUILTIN([__builtin_bswap32], [1u << 31], [HAVE_BUILTIN_BSWAP32])
|
||||||
|
CHECK_FOR_BUILTIN([__builtin_bswap64], [1ull << 63], [HAVE_BUILTIN_BSWAP64])
|
||||||
|
|
||||||
|
dnl === Check for pthread support
|
||||||
|
AC_ARG_ENABLE([threading],
|
||||||
|
AS_HELP_STRING([--disable-threading],
|
||||||
|
[Disable detection of thread support]),,
|
||||||
|
[enable_threading=yes])
|
||||||
|
if test "$enable_threading" = "yes"; then
|
||||||
|
AC_MSG_NOTICE([checking for threading support...])
|
||||||
|
AX_PTHREAD([AC_DEFINE([WEBP_USE_THREAD], [1],
|
||||||
|
[Undefine this to disable thread support.])
|
||||||
|
LIBS="$PTHREAD_LIBS $LIBS"
|
||||||
|
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||||
|
CC="$PTHREAD_CC"
|
||||||
|
],
|
||||||
|
[AC_CHECK_FUNC([_beginthreadex],
|
||||||
|
[AC_DEFINE([WEBP_USE_THREAD], [1],
|
||||||
|
[Undefine this to disable thread
|
||||||
|
support.])],
|
||||||
|
[enable_threading=no])])
|
||||||
|
fi
|
||||||
|
AC_MSG_NOTICE([checking if threading is enabled... ${enable_threading-no}])
|
||||||
|
|
||||||
|
dnl === check for OpenGL/GLUT support ===
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([gl], AS_HELP_STRING([--disable-gl],
|
||||||
|
[Disable detection of OpenGL support
|
||||||
|
@<:@default=auto@:>@]))
|
||||||
|
AS_IF([test "x$enable_gl" != "xno"], [
|
||||||
|
CLEAR_LIBVARS([GL])
|
||||||
|
WITHLIB_OPTION([gl], [GL])
|
||||||
|
|
||||||
|
LIBCHECK_PROLOGUE([GL])
|
||||||
|
|
||||||
|
glut_cflags="none"
|
||||||
|
glut_ldflags="none"
|
||||||
|
case $host_os in
|
||||||
|
darwin*)
|
||||||
|
# Special case for OSX builds. Append these to give the user a chance to
|
||||||
|
# override with --with-gl*
|
||||||
|
glut_cflags="$glut_cflags|-framework GLUT -framework OpenGL"
|
||||||
|
glut_ldflags="$glut_ldflags|-framework GLUT -framework OpenGL"
|
||||||
|
# quiet deprecation warnings for glut
|
||||||
|
TEST_AND_ADD_CFLAGS([AM_CFLAGS], [-Wno-deprecated-declarations])
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
GLUT_SAVED_CPPFLAGS="$CPPFLAGS"
|
||||||
|
SAVED_IFS="$IFS"
|
||||||
|
IFS="|"
|
||||||
|
for flag in $glut_cflags; do
|
||||||
|
# restore IFS immediately as the autoconf macros may need the default.
|
||||||
|
IFS="$SAVED_IFS"
|
||||||
|
unset ac_cv_header_GL_glut_h
|
||||||
|
unset ac_cv_header_OpenGL_glut_h
|
||||||
|
|
||||||
|
case $flag in
|
||||||
|
none) ;;
|
||||||
|
*) CPPFLAGS="$flag $CPPFLAGS";;
|
||||||
|
esac
|
||||||
|
AC_CHECK_HEADERS([GL/glut.h GLUT/glut.h OpenGL/glut.h],
|
||||||
|
[glut_headers=yes;
|
||||||
|
test "$flag" = "none" || GL_INCLUDES="$CPPFLAGS";
|
||||||
|
break])
|
||||||
|
CPPFLAGS="$GLUT_SAVED_CPPFLAGS"
|
||||||
|
test "$glut_headers" = "yes" && break
|
||||||
|
done
|
||||||
|
IFS="$SAVED_IFS"
|
||||||
|
|
||||||
|
if test "$glut_headers" = "yes"; then
|
||||||
|
AC_LANG_PUSH([C])
|
||||||
|
GLUT_SAVED_LDFLAGS="$LDFLAGS"
|
||||||
|
SAVED_IFS="$IFS"
|
||||||
|
IFS="|"
|
||||||
|
for flag in $glut_ldflags; do
|
||||||
|
# restore IFS immediately as the autoconf macros may need the default.
|
||||||
|
IFS="$SAVED_IFS"
|
||||||
|
unset ac_cv_search_glBegin
|
||||||
|
|
||||||
|
case $flag in
|
||||||
|
none) ;;
|
||||||
|
*) LDFLAGS="$flag $LDFLAGS";;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# find libGL
|
||||||
|
GL_SAVED_LIBS="$LIBS"
|
||||||
|
AC_SEARCH_LIBS([glBegin], [GL OpenGL opengl32])
|
||||||
|
LIBS="$GL_SAVED_LIBS"
|
||||||
|
|
||||||
|
# A direct link to libGL may not be necessary on e.g., linux.
|
||||||
|
GLUT_SAVED_LIBS="$LIBS"
|
||||||
|
for lib in "" "-lglut" "-lglut $ac_cv_search_glBegin"; do
|
||||||
|
LIBS="$lib"
|
||||||
|
AC_LINK_IFELSE(
|
||||||
|
[AC_LANG_PROGRAM([
|
||||||
|
#ifdef __cplusplus
|
||||||
|
# define EXTERN_C extern "C"
|
||||||
|
#else
|
||||||
|
# define EXTERN_C
|
||||||
|
#endif
|
||||||
|
EXTERN_C char glOrtho();
|
||||||
|
EXTERN_C char glutMainLoop();
|
||||||
|
],[
|
||||||
|
glOrtho();
|
||||||
|
glutMainLoop();
|
||||||
|
])
|
||||||
|
],
|
||||||
|
AC_DEFINE(WEBP_HAVE_GL, [1],
|
||||||
|
[Set to 1 if OpenGL is supported])
|
||||||
|
[glut_support=yes], []
|
||||||
|
)
|
||||||
|
if test "$glut_support" = "yes"; then
|
||||||
|
GL_LIBS="$LDFLAGS $lib"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
LIBS="$GLUT_SAVED_LIBS"
|
||||||
|
LDFLAGS="$GLUT_SAVED_LDFLAGS"
|
||||||
|
test "$glut_support" = "yes" && break
|
||||||
|
done
|
||||||
|
IFS="$SAVED_IFS"
|
||||||
|
AC_LANG_POP
|
||||||
|
fi
|
||||||
|
|
||||||
|
LIBCHECK_EPILOGUE([GL])
|
||||||
|
|
||||||
|
if test "$glut_support" = "yes" -a "$enable_libwebpdemux" = "yes"; then
|
||||||
|
build_vwebp=yes
|
||||||
|
else
|
||||||
|
AC_MSG_NOTICE(
|
||||||
|
m4_normalize([Not building vwebp.
|
||||||
|
OpenGL libraries and --enable-libwebpdemux are required.]))
|
||||||
|
fi
|
||||||
|
])
|
||||||
|
AM_CONDITIONAL([BUILD_VWEBP], [test "$build_vwebp" = "yes"])
|
||||||
|
|
||||||
|
dnl === check for SDL support ===
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([sdl],
|
||||||
|
AS_HELP_STRING([--disable-sdl],
|
||||||
|
[Disable detection of SDL support
|
||||||
|
@<:@default=auto@:>@]))
|
||||||
|
AS_IF([test "x$enable_sdl" != "xno"], [
|
||||||
|
CLEAR_LIBVARS([SDL])
|
||||||
|
AC_PATH_PROGS([LIBSDL_CONFIG], [sdl-config])
|
||||||
|
if test -n "$LIBSDL_CONFIG"; then
|
||||||
|
SDL_INCLUDES=`$LIBSDL_CONFIG --cflags`
|
||||||
|
SDL_LIBS="`$LIBSDL_CONFIG --libs`"
|
||||||
|
fi
|
||||||
|
|
||||||
|
WITHLIB_OPTION([sdl], [SDL])
|
||||||
|
|
||||||
|
sdl_header="no"
|
||||||
|
LIBCHECK_PROLOGUE([SDL])
|
||||||
|
AC_CHECK_HEADER([SDL/SDL.h], [sdl_header="SDL/SDL.h"],
|
||||||
|
[AC_CHECK_HEADER([SDL.h], [sdl_header="SDL.h"],
|
||||||
|
[AC_MSG_WARN(SDL library not available - no sdl.h)])])
|
||||||
|
if test x"$sdl_header" != "xno"; then
|
||||||
|
AC_LANG_PUSH(C)
|
||||||
|
SDL_SAVED_LIBS="$LIBS"
|
||||||
|
for lib in "" "-lSDL" "-lSDLmain -lSDL"; do
|
||||||
|
LIBS="$SDL_SAVED_LIBS $lib"
|
||||||
|
# Perform a full link to ensure SDL_main is resolved if needed.
|
||||||
|
AC_LINK_IFELSE(
|
||||||
|
[AC_LANG_SOURCE([
|
||||||
|
#include <$sdl_header>
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
SDL_Init(0);
|
||||||
|
return 0;
|
||||||
|
}])],
|
||||||
|
[SDL_LIBS="$LDFLAGS $LIBS"
|
||||||
|
SDL_INCLUDES="$SDL_INCLUDES -DWEBP_HAVE_SDL"
|
||||||
|
AC_DEFINE(WEBP_HAVE_SDL, [1],
|
||||||
|
[Set to 1 if SDL library is installed])
|
||||||
|
sdl_support=yes]
|
||||||
|
)
|
||||||
|
if test x"$sdl_support" = "xyes"; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
# LIBS is restored by LIBCHECK_EPILOGUE
|
||||||
|
AC_LANG_POP
|
||||||
|
if test x"$sdl_header" = "xSDL.h"; then
|
||||||
|
SDL_INCLUDES="$SDL_INCLUDES -DWEBP_HAVE_JUST_SDL_H"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
LIBCHECK_EPILOGUE([SDL])
|
||||||
|
|
||||||
|
if test x"$sdl_support" = "xyes"; then
|
||||||
|
build_vwebp_sdl=yes
|
||||||
|
else
|
||||||
|
AC_MSG_NOTICE([Not building vwebp-sdl. SDL library is required.])
|
||||||
|
fi
|
||||||
|
])
|
||||||
|
|
||||||
|
AM_CONDITIONAL([BUILD_VWEBP_SDL], [test "$build_vwebp_sdl" = "yes"])
|
||||||
|
|
||||||
|
dnl === check for PNG support ===
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([png], AS_HELP_STRING([--disable-png],
|
||||||
|
[Disable detection of PNG format support
|
||||||
|
@<:@default=auto@:>@]))
|
||||||
|
AS_IF([test "x$enable_png" != "xno"], [
|
||||||
|
CLEAR_LIBVARS([PNG])
|
||||||
|
AC_PATH_PROGS([LIBPNG_CONFIG],
|
||||||
|
[libpng-config libpng16-config libpng15-config libpng14-config \
|
||||||
|
libpng12-config])
|
||||||
|
if test -n "$LIBPNG_CONFIG"; then
|
||||||
|
PNG_INCLUDES=`$LIBPNG_CONFIG --cflags`
|
||||||
|
PNG_LIBS="`$LIBPNG_CONFIG --ldflags`"
|
||||||
|
fi
|
||||||
|
|
||||||
|
WITHLIB_OPTION([png], [PNG])
|
||||||
|
|
||||||
|
LIBCHECK_PROLOGUE([PNG])
|
||||||
|
AC_CHECK_HEADER(png.h,
|
||||||
|
AC_SEARCH_LIBS(png_get_libpng_ver, [png],
|
||||||
|
[test "$ac_cv_search_png_get_libpng_ver" = "none required" \
|
||||||
|
|| PNG_LIBS="$PNG_LIBS $ac_cv_search_png_get_libpng_ver"
|
||||||
|
PNG_INCLUDES="$PNG_INCLUDES -DWEBP_HAVE_PNG"
|
||||||
|
AC_DEFINE(WEBP_HAVE_PNG, [1],
|
||||||
|
[Set to 1 if PNG library is installed])
|
||||||
|
png_support=yes
|
||||||
|
],
|
||||||
|
[AC_MSG_WARN(Optional png library not found)
|
||||||
|
PNG_LIBS=""
|
||||||
|
PNG_INCLUDES=""
|
||||||
|
],
|
||||||
|
[$MATH_LIBS]),
|
||||||
|
[AC_MSG_WARN(png library not available - no png.h)
|
||||||
|
PNG_LIBS=""
|
||||||
|
PNG_INCLUDES=""
|
||||||
|
],
|
||||||
|
)
|
||||||
|
LIBCHECK_EPILOGUE([PNG])
|
||||||
|
])
|
||||||
|
|
||||||
|
dnl === check for JPEG support ===
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([jpeg],
|
||||||
|
AS_HELP_STRING([--disable-jpeg],
|
||||||
|
[Disable detection of JPEG format support
|
||||||
|
@<:@default=auto@:>@]))
|
||||||
|
AS_IF([test "x$enable_jpeg" != "xno"], [
|
||||||
|
CLEAR_LIBVARS([JPEG])
|
||||||
|
WITHLIB_OPTION([jpeg], [JPEG])
|
||||||
|
|
||||||
|
LIBCHECK_PROLOGUE([JPEG])
|
||||||
|
AC_CHECK_HEADER(jpeglib.h,
|
||||||
|
AC_CHECK_LIB(jpeg, jpeg_set_defaults,
|
||||||
|
[JPEG_LIBS="$JPEG_LIBS -ljpeg"
|
||||||
|
JPEG_INCLUDES="$JPEG_INCLUDES -DWEBP_HAVE_JPEG"
|
||||||
|
AC_DEFINE(WEBP_HAVE_JPEG, [1],
|
||||||
|
[Set to 1 if JPEG library is installed])
|
||||||
|
jpeg_support=yes
|
||||||
|
],
|
||||||
|
AC_MSG_WARN(Optional jpeg library not found),
|
||||||
|
[$MATH_LIBS]),
|
||||||
|
AC_MSG_WARN(jpeg library not available - no jpeglib.h)
|
||||||
|
)
|
||||||
|
LIBCHECK_EPILOGUE([JPEG])
|
||||||
|
])
|
||||||
|
|
||||||
|
dnl === check for TIFF support ===
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([tiff],
|
||||||
|
AS_HELP_STRING([--disable-tiff],
|
||||||
|
[Disable detection of TIFF format support
|
||||||
|
@<:@default=auto@:>@]))
|
||||||
|
AS_IF([test "x$enable_tiff" != "xno"], [
|
||||||
|
CLEAR_LIBVARS([TIFF])
|
||||||
|
WITHLIB_OPTION([tiff], [TIFF])
|
||||||
|
|
||||||
|
LIBCHECK_PROLOGUE([TIFF])
|
||||||
|
AC_CHECK_HEADER(tiffio.h,
|
||||||
|
AC_CHECK_LIB(tiff, TIFFGetVersion,
|
||||||
|
[TIFF_LIBS="$TIFF_LIBS -ltiff"
|
||||||
|
TIFF_INCLUDES="$TIFF_INCLUDES -DWEBP_HAVE_TIFF"
|
||||||
|
AC_DEFINE(WEBP_HAVE_TIFF, [1],
|
||||||
|
[Set to 1 if TIFF library is installed])
|
||||||
|
tiff_support=yes
|
||||||
|
],
|
||||||
|
AC_MSG_WARN(Optional tiff library not found),
|
||||||
|
[$MATH_LIBS]),
|
||||||
|
AC_MSG_WARN(tiff library not available - no tiffio.h)
|
||||||
|
)
|
||||||
|
LIBCHECK_EPILOGUE([TIFF])
|
||||||
|
])
|
||||||
|
|
||||||
|
dnl === check for GIF support ===
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([gif], AS_HELP_STRING([--disable-gif],
|
||||||
|
[Disable detection of GIF format support
|
||||||
|
@<:@default=auto@:>@]))
|
||||||
|
AS_IF([test "x$enable_gif" != "xno"], [
|
||||||
|
CLEAR_LIBVARS([GIF])
|
||||||
|
WITHLIB_OPTION([gif], [GIF])
|
||||||
|
|
||||||
|
LIBCHECK_PROLOGUE([GIF])
|
||||||
|
AC_CHECK_HEADER(gif_lib.h,
|
||||||
|
AC_CHECK_LIB([gif], [DGifOpenFileHandle],
|
||||||
|
[GIF_LIBS="$GIF_LIBS -lgif"
|
||||||
|
AC_DEFINE(WEBP_HAVE_GIF, [1],
|
||||||
|
[Set to 1 if GIF library is installed])
|
||||||
|
gif_support=yes
|
||||||
|
],
|
||||||
|
AC_MSG_WARN(Optional gif library not found),
|
||||||
|
[$MATH_LIBS]),
|
||||||
|
AC_MSG_WARN(gif library not available - no gif_lib.h)
|
||||||
|
)
|
||||||
|
LIBCHECK_EPILOGUE([GIF])
|
||||||
|
|
||||||
|
if test "$gif_support" = "yes" -a \
|
||||||
|
"$enable_libwebpdemux" = "yes"; then
|
||||||
|
build_anim_diff=yes
|
||||||
|
else
|
||||||
|
AC_MSG_NOTICE(
|
||||||
|
[Not building anim_diff. libgif and --enable-libwebpdemux are required.])
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test "$gif_support" = "yes" -a \
|
||||||
|
"$enable_libwebpmux" = "yes"; then
|
||||||
|
build_gif2webp=yes
|
||||||
|
else
|
||||||
|
AC_MSG_NOTICE(
|
||||||
|
[Not building gif2webp. libgif and --enable-libwebpmux are required.])
|
||||||
|
fi
|
||||||
|
])
|
||||||
|
AM_CONDITIONAL([BUILD_ANIMDIFF], [test "${build_anim_diff}" = "yes"])
|
||||||
|
AM_CONDITIONAL([BUILD_GIF2WEBP], [test "${build_gif2webp}" = "yes"])
|
||||||
|
|
||||||
|
if test "$enable_libwebpdemux" = "yes" -a "$enable_libwebpmux" = "yes"; then
|
||||||
|
build_img2webp=yes
|
||||||
|
else
|
||||||
|
AC_MSG_NOTICE(
|
||||||
|
m4_normalize([Not building img2webp.
|
||||||
|
--enable-libwebpdemux & --enable-libwebpmux are required.]))
|
||||||
|
fi
|
||||||
|
AM_CONDITIONAL([BUILD_IMG2WEBP], [test "${build_img2webp}" = "yes"])
|
||||||
|
|
||||||
|
if test "$enable_libwebpmux" = "yes"; then
|
||||||
|
build_webpinfo=yes
|
||||||
|
else
|
||||||
|
AC_MSG_NOTICE([Not building webpinfo. --enable-libwebpdemux is required.])
|
||||||
|
fi
|
||||||
|
AM_CONDITIONAL([BUILD_WEBPINFO], [test "${build_webpinfo}" = "yes"])
|
||||||
|
|
||||||
|
dnl === check for WIC support ===
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([wic],
|
||||||
|
AS_HELP_STRING([--disable-wic],
|
||||||
|
[Disable Windows Imaging Component (WIC) detection.
|
||||||
|
@<:@default=auto@:>@]),,
|
||||||
|
[enable_wic=yes])
|
||||||
|
|
||||||
|
case $host_os in
|
||||||
|
mingw*)
|
||||||
|
if test "$enable_wic" = "yes"; then
|
||||||
|
AC_CHECK_HEADERS([wincodec.h shlwapi.h windows.h])
|
||||||
|
if test "$ac_cv_header_wincodec_h" = "yes"; then
|
||||||
|
AC_MSG_CHECKING(for Windows Imaging Component support)
|
||||||
|
SAVED_LIBS=$LIBS
|
||||||
|
LIBS="-lshlwapi -lole32 $LIBS"
|
||||||
|
# match include structure from [cd]webp.c
|
||||||
|
wic_headers="
|
||||||
|
#define INITGUID
|
||||||
|
#define CINTERFACE
|
||||||
|
#define COBJMACROS
|
||||||
|
#define _WIN32_IE 0x500
|
||||||
|
|
||||||
|
#include <shlwapi.h>
|
||||||
|
#include <windows.h>
|
||||||
|
#include <wincodec.h>
|
||||||
|
"
|
||||||
|
# test for functions from each lib and the GUID is created properly
|
||||||
|
wic_main="
|
||||||
|
int main(void) {
|
||||||
|
CLSID_WICImagingFactory;
|
||||||
|
CoInitialize(NULL);
|
||||||
|
SHCreateStreamOnFile(NULL, 0, NULL);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
"
|
||||||
|
AC_LANG_PUSH(C)
|
||||||
|
AC_LINK_IFELSE(
|
||||||
|
[AC_LANG_SOURCE([
|
||||||
|
$wic_headers
|
||||||
|
$wic_main])],
|
||||||
|
[wic_support=yes],
|
||||||
|
[wic_support=no]
|
||||||
|
)
|
||||||
|
AC_LANG_POP
|
||||||
|
|
||||||
|
test "$wic_support" = "yes" || LIBS=$SAVED_LIBS
|
||||||
|
AC_MSG_RESULT(${wic_support-no})
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
esac
|
||||||
|
|
||||||
|
dnl === If --enable-swap-16bit-csp is defined, add -DWEBP_SWAP_16BIT_CSP=1
|
||||||
|
|
||||||
|
USE_SWAP_16BIT_CSP=""
|
||||||
|
AC_MSG_CHECKING(if --enable-swap-16bit-csp option is specified)
|
||||||
|
AC_ARG_ENABLE([swap-16bit-csp],
|
||||||
|
AS_HELP_STRING([--enable-swap-16bit-csp],
|
||||||
|
[Enable byte swap for 16 bit colorspaces]))
|
||||||
|
if test "$enable_swap_16bit_csp" = "yes"; then
|
||||||
|
USE_SWAP_16BIT_CSP="-DWEBP_SWAP_16BIT_CSP=1"
|
||||||
|
fi
|
||||||
|
AC_MSG_RESULT(${enable_swap_16bit_csp-no})
|
||||||
|
AC_SUBST(USE_SWAP_16BIT_CSP)
|
||||||
|
|
||||||
|
dnl === If --disable-near-lossless is defined, add -DWEBP_NEAR_LOSSLESS=0
|
||||||
|
|
||||||
|
AC_DEFINE(WEBP_NEAR_LOSSLESS, [1], [Enable near lossless encoding])
|
||||||
|
AC_MSG_CHECKING(if --disable-near-lossless option is specified)
|
||||||
|
AC_ARG_ENABLE([near_lossless],
|
||||||
|
AS_HELP_STRING([--disable-near-lossless],
|
||||||
|
[Disable near lossless encoding]),
|
||||||
|
[], [enable_near_lossless=yes])
|
||||||
|
if test "$enable_near_lossless" = "no"; then
|
||||||
|
AC_DEFINE(WEBP_NEAR_LOSSLESS, [0], [Enable near lossless encoding])
|
||||||
|
AC_MSG_RESULT([yes])
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT([no])
|
||||||
|
fi
|
||||||
|
|
||||||
|
dnl =========================
|
||||||
|
|
||||||
|
dnl Add an empty webp_libname_prefix variable for use in *.pc.in.
|
||||||
|
AC_SUBST([webp_libname_prefix])
|
||||||
|
AC_CONFIG_MACRO_DIR([m4])
|
||||||
|
AC_CONFIG_HEADERS([src/webp/config.h])
|
||||||
|
AC_CONFIG_FILES([Makefile src/Makefile man/Makefile \
|
||||||
|
examples/Makefile extras/Makefile imageio/Makefile \
|
||||||
|
sharpyuv/Makefile sharpyuv/libsharpyuv.pc \
|
||||||
|
src/dec/Makefile src/enc/Makefile src/dsp/Makefile \
|
||||||
|
src/demux/Makefile src/mux/Makefile \
|
||||||
|
src/utils/Makefile \
|
||||||
|
src/libwebp.pc src/libwebpdecoder.pc \
|
||||||
|
src/demux/libwebpdemux.pc src/mux/libwebpmux.pc])
|
||||||
|
|
||||||
|
|
||||||
|
AC_OUTPUT
|
||||||
|
|
||||||
|
AC_MSG_NOTICE([
|
||||||
|
WebP Configuration Summary
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
Shared libraries: ${enable_shared}
|
||||||
|
Static libraries: ${enable_static}
|
||||||
|
Threading support: ${enable_threading-no}
|
||||||
|
libwebp: yes
|
||||||
|
libwebpdecoder: ${enable_libwebpdecoder-no}
|
||||||
|
libwebpdemux: ${enable_libwebpdemux-no}
|
||||||
|
libwebpmux: ${enable_libwebpmux-no}
|
||||||
|
libwebpextras: ${enable_libwebpextras-no}
|
||||||
|
|
||||||
|
Tools:
|
||||||
|
cwebp : ${enable_libwebpdemux-no}
|
||||||
|
Input format support
|
||||||
|
====================
|
||||||
|
JPEG : ${jpeg_support-no}
|
||||||
|
PNG : ${png_support-no}
|
||||||
|
TIFF : ${tiff_support-no}
|
||||||
|
WIC : ${wic_support-no}
|
||||||
|
dwebp : ${enable_libwebpdemux-no}
|
||||||
|
Output format support
|
||||||
|
=====================
|
||||||
|
PNG : ${png_support-no}
|
||||||
|
WIC : ${wic_support-no}
|
||||||
|
GIF support : ${gif_support-no}
|
||||||
|
anim_diff : ${build_anim_diff-no}
|
||||||
|
gif2webp : ${build_gif2webp-no}
|
||||||
|
img2webp : ${build_img2webp-no}
|
||||||
|
webpmux : ${enable_libwebpmux-no}
|
||||||
|
vwebp : ${build_vwebp-no}
|
||||||
|
webpinfo : ${build_webpinfo-no}
|
||||||
|
SDL support : ${sdl_support-no}
|
||||||
|
vwebp_sdl : ${build_vwebp_sdl-no}
|
||||||
|
])
|
13
external/libwebp/libwebp/doc/TODO
vendored
Normal file
13
external/libwebp/libwebp/doc/TODO
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<louquillio@google.com>, 20111004
|
||||||
|
|
||||||
|
* Determine that normative RFC 2119 terms (MUST, SHOULD, MAY, etc.) are
|
||||||
|
truly intended in all cases where capitalized.
|
||||||
|
|
||||||
|
* Several passages could be made clearer.
|
||||||
|
|
||||||
|
* Overall edit for scope. Portions are phrased as an introduction to
|
||||||
|
the 0.1.3 RIFF container additions, rather than a holistic guide to
|
||||||
|
WebP.
|
||||||
|
|
||||||
|
* To wit, suggest s/[spec|specification]/guide/g . "Spec" can imply a
|
||||||
|
standards track; in any case it's too formal for a work in progress.
|
385
external/libwebp/libwebp/doc/api.md
vendored
Normal file
385
external/libwebp/libwebp/doc/api.md
vendored
Normal file
@ -0,0 +1,385 @@
|
|||||||
|
# WebP APIs
|
||||||
|
|
||||||
|
## Encoding API
|
||||||
|
|
||||||
|
The main encoding functions are available in the header src/webp/encode.h
|
||||||
|
|
||||||
|
The ready-to-use ones are:
|
||||||
|
|
||||||
|
```c
|
||||||
|
size_t WebPEncodeRGB(const uint8_t* rgb, int width, int height, int stride,
|
||||||
|
float quality_factor, uint8_t** output);
|
||||||
|
size_t WebPEncodeBGR(const uint8_t* bgr, int width, int height, int stride,
|
||||||
|
float quality_factor, uint8_t** output);
|
||||||
|
size_t WebPEncodeRGBA(const uint8_t* rgba, int width, int height, int stride,
|
||||||
|
float quality_factor, uint8_t** output);
|
||||||
|
size_t WebPEncodeBGRA(const uint8_t* bgra, int width, int height, int stride,
|
||||||
|
float quality_factor, uint8_t** output);
|
||||||
|
```
|
||||||
|
|
||||||
|
They will convert raw RGB samples to a WebP data. The only control supplied is
|
||||||
|
the quality factor.
|
||||||
|
|
||||||
|
There are some variants for using the lossless format:
|
||||||
|
|
||||||
|
```c
|
||||||
|
size_t WebPEncodeLosslessRGB(const uint8_t* rgb, int width, int height,
|
||||||
|
int stride, uint8_t** output);
|
||||||
|
size_t WebPEncodeLosslessBGR(const uint8_t* bgr, int width, int height,
|
||||||
|
int stride, uint8_t** output);
|
||||||
|
size_t WebPEncodeLosslessRGBA(const uint8_t* rgba, int width, int height,
|
||||||
|
int stride, uint8_t** output);
|
||||||
|
size_t WebPEncodeLosslessBGRA(const uint8_t* bgra, int width, int height,
|
||||||
|
int stride, uint8_t** output);
|
||||||
|
```
|
||||||
|
|
||||||
|
Of course in this case, no quality factor is needed since the compression occurs
|
||||||
|
without loss of the input values, at the expense of larger output sizes.
|
||||||
|
|
||||||
|
### Advanced encoding API
|
||||||
|
|
||||||
|
A more advanced API is based on the WebPConfig and WebPPicture structures.
|
||||||
|
|
||||||
|
WebPConfig contains the encoding settings and is not tied to a particular
|
||||||
|
picture. WebPPicture contains input data, on which some WebPConfig will be used
|
||||||
|
for compression. The encoding flow looks like:
|
||||||
|
|
||||||
|
```c
|
||||||
|
#include <webp/encode.h>
|
||||||
|
|
||||||
|
// Setup a config, starting form a preset and tuning some additional
|
||||||
|
// parameters
|
||||||
|
WebPConfig config;
|
||||||
|
if (!WebPConfigPreset(&config, WEBP_PRESET_PHOTO, quality_factor)) {
|
||||||
|
return 0; // version error
|
||||||
|
}
|
||||||
|
// ... additional tuning
|
||||||
|
config.sns_strength = 90;
|
||||||
|
config.filter_sharpness = 6;
|
||||||
|
config_error = WebPValidateConfig(&config); // not mandatory, but useful
|
||||||
|
|
||||||
|
// Setup the input data
|
||||||
|
WebPPicture pic;
|
||||||
|
if (!WebPPictureInit(&pic)) {
|
||||||
|
return 0; // version error
|
||||||
|
}
|
||||||
|
pic.width = width;
|
||||||
|
pic.height = height;
|
||||||
|
// allocated picture of dimension width x height
|
||||||
|
if (!WebPPictureAlloc(&pic)) {
|
||||||
|
return 0; // memory error
|
||||||
|
}
|
||||||
|
// at this point, 'pic' has been initialized as a container,
|
||||||
|
// and can receive the Y/U/V samples.
|
||||||
|
// Alternatively, one could use ready-made import functions like
|
||||||
|
// WebPPictureImportRGB(), which will take care of memory allocation.
|
||||||
|
// In any case, past this point, one will have to call
|
||||||
|
// WebPPictureFree(&pic) to reclaim memory.
|
||||||
|
|
||||||
|
// Set up a byte-output write method. WebPMemoryWriter, for instance.
|
||||||
|
WebPMemoryWriter wrt;
|
||||||
|
WebPMemoryWriterInit(&wrt); // initialize 'wrt'
|
||||||
|
|
||||||
|
pic.writer = MyFileWriter;
|
||||||
|
pic.custom_ptr = my_opaque_structure_to_make_MyFileWriter_work;
|
||||||
|
|
||||||
|
// Compress!
|
||||||
|
int ok = WebPEncode(&config, &pic); // ok = 0 => error occurred!
|
||||||
|
WebPPictureFree(&pic); // must be called independently of the 'ok' result.
|
||||||
|
|
||||||
|
// output data should have been handled by the writer at that point.
|
||||||
|
// -> compressed data is the memory buffer described by wrt.mem / wrt.size
|
||||||
|
|
||||||
|
// deallocate the memory used by compressed data
|
||||||
|
WebPMemoryWriterClear(&wrt);
|
||||||
|
```
|
||||||
|
|
||||||
|
## Decoding API
|
||||||
|
|
||||||
|
This is mainly just one function to call:
|
||||||
|
|
||||||
|
```c
|
||||||
|
#include "webp/decode.h"
|
||||||
|
uint8_t* WebPDecodeRGB(const uint8_t* data, size_t data_size,
|
||||||
|
int* width, int* height);
|
||||||
|
```
|
||||||
|
|
||||||
|
Please have a look at the file src/webp/decode.h for the details. There are
|
||||||
|
variants for decoding in BGR/RGBA/ARGB/BGRA order, along with decoding to raw
|
||||||
|
Y'CbCr samples. One can also decode the image directly into a pre-allocated
|
||||||
|
buffer.
|
||||||
|
|
||||||
|
To detect a WebP file and gather the picture's dimensions, the function:
|
||||||
|
|
||||||
|
```c
|
||||||
|
int WebPGetInfo(const uint8_t* data, size_t data_size,
|
||||||
|
int* width, int* height);
|
||||||
|
```
|
||||||
|
|
||||||
|
is supplied. No decoding is involved when using it.
|
||||||
|
|
||||||
|
### Incremental decoding API
|
||||||
|
|
||||||
|
In the case when data is being progressively transmitted, pictures can still be
|
||||||
|
incrementally decoded using a slightly more complicated API. Decoder state is
|
||||||
|
stored into an instance of the WebPIDecoder object. This object can be created
|
||||||
|
with the purpose of decoding either RGB or Y'CbCr samples. For instance:
|
||||||
|
|
||||||
|
```c
|
||||||
|
WebPDecBuffer buffer;
|
||||||
|
WebPInitDecBuffer(&buffer);
|
||||||
|
buffer.colorspace = MODE_BGR;
|
||||||
|
...
|
||||||
|
WebPIDecoder* idec = WebPINewDecoder(&buffer);
|
||||||
|
```
|
||||||
|
|
||||||
|
As data is made progressively available, this incremental-decoder object can be
|
||||||
|
used to decode the picture further. There are two (mutually exclusive) ways to
|
||||||
|
pass freshly arrived data:
|
||||||
|
|
||||||
|
either by appending the fresh bytes:
|
||||||
|
|
||||||
|
```c
|
||||||
|
WebPIAppend(idec, fresh_data, size_of_fresh_data);
|
||||||
|
```
|
||||||
|
|
||||||
|
or by just mentioning the new size of the transmitted data:
|
||||||
|
|
||||||
|
```c
|
||||||
|
WebPIUpdate(idec, buffer, size_of_transmitted_buffer);
|
||||||
|
```
|
||||||
|
|
||||||
|
Note that 'buffer' can be modified between each call to WebPIUpdate, in
|
||||||
|
particular when the buffer is resized to accommodate larger data.
|
||||||
|
|
||||||
|
These functions will return the decoding status: either VP8_STATUS_SUSPENDED if
|
||||||
|
decoding is not finished yet or VP8_STATUS_OK when decoding is done. Any other
|
||||||
|
status is an error condition.
|
||||||
|
|
||||||
|
The 'idec' object must always be released (even upon an error condition) by
|
||||||
|
calling: WebPDelete(idec).
|
||||||
|
|
||||||
|
To retrieve partially decoded picture samples, one must use the corresponding
|
||||||
|
method: WebPIDecGetRGB or WebPIDecGetYUVA. It will return the last displayable
|
||||||
|
pixel row.
|
||||||
|
|
||||||
|
Lastly, note that decoding can also be performed into a pre-allocated pixel
|
||||||
|
buffer. This buffer must be passed when creating a WebPIDecoder, calling
|
||||||
|
WebPINewRGB() or WebPINewYUVA().
|
||||||
|
|
||||||
|
Please have a look at the src/webp/decode.h header for further details.
|
||||||
|
|
||||||
|
### Advanced Decoding API
|
||||||
|
|
||||||
|
WebP decoding supports an advanced API which provides on-the-fly cropping and
|
||||||
|
rescaling, something of great usefulness on memory-constrained environments like
|
||||||
|
mobile phones. Basically, the memory usage will scale with the output's size,
|
||||||
|
not the input's, when one only needs a quick preview or a zoomed in portion of
|
||||||
|
an otherwise too-large picture. Some CPU can be saved too, incidentally.
|
||||||
|
|
||||||
|
```c
|
||||||
|
// A) Init a configuration object
|
||||||
|
WebPDecoderConfig config;
|
||||||
|
CHECK(WebPInitDecoderConfig(&config));
|
||||||
|
|
||||||
|
// B) optional: retrieve the bitstream's features.
|
||||||
|
CHECK(WebPGetFeatures(data, data_size, &config.input) == VP8_STATUS_OK);
|
||||||
|
|
||||||
|
// C) Adjust 'config' options, if needed
|
||||||
|
config.options.no_fancy_upsampling = 1;
|
||||||
|
config.options.use_scaling = 1;
|
||||||
|
config.options.scaled_width = scaledWidth();
|
||||||
|
config.options.scaled_height = scaledHeight();
|
||||||
|
// etc.
|
||||||
|
|
||||||
|
// D) Specify 'config' output options for specifying output colorspace.
|
||||||
|
// Optionally the external image decode buffer can also be specified.
|
||||||
|
config.output.colorspace = MODE_BGRA;
|
||||||
|
// Optionally, the config.output can be pointed to an external buffer as
|
||||||
|
// well for decoding the image. This externally supplied memory buffer
|
||||||
|
// should be big enough to store the decoded picture.
|
||||||
|
config.output.u.RGBA.rgba = (uint8_t*) memory_buffer;
|
||||||
|
config.output.u.RGBA.stride = scanline_stride;
|
||||||
|
config.output.u.RGBA.size = total_size_of_the_memory_buffer;
|
||||||
|
config.output.is_external_memory = 1;
|
||||||
|
|
||||||
|
// E) Decode the WebP image. There are two variants w.r.t decoding image.
|
||||||
|
// The first one (E.1) decodes the full image and the second one (E.2) is
|
||||||
|
// used to incrementally decode the image using small input buffers.
|
||||||
|
// Any one of these steps can be used to decode the WebP image.
|
||||||
|
|
||||||
|
// E.1) Decode full image.
|
||||||
|
CHECK(WebPDecode(data, data_size, &config) == VP8_STATUS_OK);
|
||||||
|
|
||||||
|
// E.2) Decode image incrementally.
|
||||||
|
WebPIDecoder* const idec = WebPIDecode(NULL, NULL, &config);
|
||||||
|
CHECK(idec != NULL);
|
||||||
|
while (bytes_remaining > 0) {
|
||||||
|
VP8StatusCode status = WebPIAppend(idec, input, bytes_read);
|
||||||
|
if (status == VP8_STATUS_OK || status == VP8_STATUS_SUSPENDED) {
|
||||||
|
bytes_remaining -= bytes_read;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
WebPIDelete(idec);
|
||||||
|
|
||||||
|
// F) Decoded image is now in config.output (and config.output.u.RGBA).
|
||||||
|
// It can be saved, displayed or otherwise processed.
|
||||||
|
|
||||||
|
// G) Reclaim memory allocated in config's object. It's safe to call
|
||||||
|
// this function even if the memory is external and wasn't allocated
|
||||||
|
// by WebPDecode().
|
||||||
|
WebPFreeDecBuffer(&config.output);
|
||||||
|
```
|
||||||
|
|
||||||
|
## WebP Mux
|
||||||
|
|
||||||
|
WebPMux is a set of two libraries 'Mux' and 'Demux' for creation, extraction and
|
||||||
|
manipulation of an extended format WebP file, which can have features like color
|
||||||
|
profile, metadata and animation. Reference command-line tools `webpmux` and
|
||||||
|
`vwebp` as well as the WebP container specification
|
||||||
|
'doc/webp-container-spec.txt' are also provided in this package, see the
|
||||||
|
[tools documentation](tools.md).
|
||||||
|
|
||||||
|
### Mux API
|
||||||
|
|
||||||
|
The Mux API contains methods for adding data to and reading data from WebP
|
||||||
|
files. This API currently supports XMP/EXIF metadata, ICC profile and animation.
|
||||||
|
Other features may be added in subsequent releases.
|
||||||
|
|
||||||
|
Example#1 (pseudo code): Creating a WebPMux object with image data, color
|
||||||
|
profile and XMP metadata.
|
||||||
|
|
||||||
|
```c
|
||||||
|
int copy_data = 0;
|
||||||
|
WebPMux* mux = WebPMuxNew();
|
||||||
|
// ... (Prepare image data).
|
||||||
|
WebPMuxSetImage(mux, &image, copy_data);
|
||||||
|
// ... (Prepare ICC profile data).
|
||||||
|
WebPMuxSetChunk(mux, "ICCP", &icc_profile, copy_data);
|
||||||
|
// ... (Prepare XMP metadata).
|
||||||
|
WebPMuxSetChunk(mux, "XMP ", &xmp, copy_data);
|
||||||
|
// Get data from mux in WebP RIFF format.
|
||||||
|
WebPMuxAssemble(mux, &output_data);
|
||||||
|
WebPMuxDelete(mux);
|
||||||
|
// ... (Consume output_data; e.g. write output_data.bytes to file).
|
||||||
|
WebPDataClear(&output_data);
|
||||||
|
```
|
||||||
|
|
||||||
|
Example#2 (pseudo code): Get image and color profile data from a WebP file.
|
||||||
|
|
||||||
|
```c
|
||||||
|
int copy_data = 0;
|
||||||
|
// ... (Read data from file).
|
||||||
|
WebPMux* mux = WebPMuxCreate(&data, copy_data);
|
||||||
|
WebPMuxGetFrame(mux, 1, &image);
|
||||||
|
// ... (Consume image; e.g. call WebPDecode() to decode the data).
|
||||||
|
WebPMuxGetChunk(mux, "ICCP", &icc_profile);
|
||||||
|
// ... (Consume icc_profile).
|
||||||
|
WebPMuxDelete(mux);
|
||||||
|
free(data);
|
||||||
|
```
|
||||||
|
|
||||||
|
For a detailed Mux API reference, please refer to the header file
|
||||||
|
(src/webp/mux.h).
|
||||||
|
|
||||||
|
### Demux API
|
||||||
|
|
||||||
|
The Demux API enables extraction of images and extended format data from WebP
|
||||||
|
files. This API currently supports reading of XMP/EXIF metadata, ICC profile and
|
||||||
|
animated images. Other features may be added in subsequent releases.
|
||||||
|
|
||||||
|
Code example: Demuxing WebP data to extract all the frames, ICC profile and
|
||||||
|
EXIF/XMP metadata.
|
||||||
|
|
||||||
|
```c
|
||||||
|
WebPDemuxer* demux = WebPDemux(&webp_data);
|
||||||
|
uint32_t width = WebPDemuxGetI(demux, WEBP_FF_CANVAS_WIDTH);
|
||||||
|
uint32_t height = WebPDemuxGetI(demux, WEBP_FF_CANVAS_HEIGHT);
|
||||||
|
// ... (Get information about the features present in the WebP file).
|
||||||
|
uint32_t flags = WebPDemuxGetI(demux, WEBP_FF_FORMAT_FLAGS);
|
||||||
|
|
||||||
|
// ... (Iterate over all frames).
|
||||||
|
WebPIterator iter;
|
||||||
|
if (WebPDemuxGetFrame(demux, 1, &iter)) {
|
||||||
|
do {
|
||||||
|
// ... (Consume 'iter'; e.g. Decode 'iter.fragment' with WebPDecode(),
|
||||||
|
// ... and get other frame properties like width, height, offsets etc.
|
||||||
|
// ... see 'struct WebPIterator' below for more info).
|
||||||
|
} while (WebPDemuxNextFrame(&iter));
|
||||||
|
WebPDemuxReleaseIterator(&iter);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ... (Extract metadata).
|
||||||
|
WebPChunkIterator chunk_iter;
|
||||||
|
if (flags & ICCP_FLAG) WebPDemuxGetChunk(demux, "ICCP", 1, &chunk_iter);
|
||||||
|
// ... (Consume the ICC profile in 'chunk_iter.chunk').
|
||||||
|
WebPDemuxReleaseChunkIterator(&chunk_iter);
|
||||||
|
if (flags & EXIF_FLAG) WebPDemuxGetChunk(demux, "EXIF", 1, &chunk_iter);
|
||||||
|
// ... (Consume the EXIF metadata in 'chunk_iter.chunk').
|
||||||
|
WebPDemuxReleaseChunkIterator(&chunk_iter);
|
||||||
|
if (flags & XMP_FLAG) WebPDemuxGetChunk(demux, "XMP ", 1, &chunk_iter);
|
||||||
|
// ... (Consume the XMP metadata in 'chunk_iter.chunk').
|
||||||
|
WebPDemuxReleaseChunkIterator(&chunk_iter);
|
||||||
|
WebPDemuxDelete(demux);
|
||||||
|
```
|
||||||
|
|
||||||
|
For a detailed Demux API reference, please refer to the header file
|
||||||
|
(src/webp/demux.h).
|
||||||
|
|
||||||
|
## AnimEncoder API
|
||||||
|
|
||||||
|
The AnimEncoder API can be used to create animated WebP images.
|
||||||
|
|
||||||
|
Code example:
|
||||||
|
|
||||||
|
```c
|
||||||
|
WebPAnimEncoderOptions enc_options;
|
||||||
|
WebPAnimEncoderOptionsInit(&enc_options);
|
||||||
|
// ... (Tune 'enc_options' as needed).
|
||||||
|
WebPAnimEncoder* enc = WebPAnimEncoderNew(width, height, &enc_options);
|
||||||
|
while(<there are more frames>) {
|
||||||
|
WebPConfig config;
|
||||||
|
WebPConfigInit(&config);
|
||||||
|
// ... (Tune 'config' as needed).
|
||||||
|
WebPAnimEncoderAdd(enc, frame, duration, &config);
|
||||||
|
}
|
||||||
|
WebPAnimEncoderAssemble(enc, webp_data);
|
||||||
|
WebPAnimEncoderDelete(enc);
|
||||||
|
// ... (Write the 'webp_data' to a file, or re-mux it further).
|
||||||
|
```
|
||||||
|
|
||||||
|
For a detailed AnimEncoder API reference, please refer to the header file
|
||||||
|
(src/webp/mux.h).
|
||||||
|
|
||||||
|
## AnimDecoder API
|
||||||
|
|
||||||
|
This AnimDecoder API allows decoding (possibly) animated WebP images.
|
||||||
|
|
||||||
|
Code Example:
|
||||||
|
|
||||||
|
```c
|
||||||
|
WebPAnimDecoderOptions dec_options;
|
||||||
|
WebPAnimDecoderOptionsInit(&dec_options);
|
||||||
|
// Tune 'dec_options' as needed.
|
||||||
|
WebPAnimDecoder* dec = WebPAnimDecoderNew(webp_data, &dec_options);
|
||||||
|
WebPAnimInfo anim_info;
|
||||||
|
WebPAnimDecoderGetInfo(dec, &anim_info);
|
||||||
|
for (uint32_t i = 0; i < anim_info.loop_count; ++i) {
|
||||||
|
while (WebPAnimDecoderHasMoreFrames(dec)) {
|
||||||
|
uint8_t* buf;
|
||||||
|
int timestamp;
|
||||||
|
WebPAnimDecoderGetNext(dec, &buf, ×tamp);
|
||||||
|
// ... (Render 'buf' based on 'timestamp').
|
||||||
|
// ... (Do NOT free 'buf', as it is owned by 'dec').
|
||||||
|
}
|
||||||
|
WebPAnimDecoderReset(dec);
|
||||||
|
}
|
||||||
|
const WebPDemuxer* demuxer = WebPAnimDecoderGetDemuxer(dec);
|
||||||
|
// ... (Do something using 'demuxer'; e.g. get EXIF/XMP/ICC data).
|
||||||
|
WebPAnimDecoderDelete(dec);
|
||||||
|
```
|
||||||
|
|
||||||
|
For a detailed AnimDecoder API reference, please refer to the header file
|
||||||
|
(src/webp/demux.h).
|
213
external/libwebp/libwebp/doc/building.md
vendored
Normal file
213
external/libwebp/libwebp/doc/building.md
vendored
Normal file
@ -0,0 +1,213 @@
|
|||||||
|
# Building
|
||||||
|
|
||||||
|
## Windows build
|
||||||
|
|
||||||
|
By running:
|
||||||
|
|
||||||
|
```batch
|
||||||
|
nmake /f Makefile.vc CFG=release-static RTLIBCFG=static OBJDIR=output
|
||||||
|
```
|
||||||
|
|
||||||
|
the directory `output\release-static\(x64|x86)\bin` will contain the tools
|
||||||
|
cwebp.exe and dwebp.exe. The directory `output\release-static\(x64|x86)\lib`
|
||||||
|
will contain the libwebp static library. The target architecture (x86/x64) is
|
||||||
|
detected by Makefile.vc from the Visual Studio compiler (cl.exe) available in
|
||||||
|
the system path.
|
||||||
|
|
||||||
|
## Unix build using makefile.unix
|
||||||
|
|
||||||
|
On platforms with GNU tools installed (gcc and make), running
|
||||||
|
|
||||||
|
```shell
|
||||||
|
make -f makefile.unix
|
||||||
|
```
|
||||||
|
|
||||||
|
will build the binaries examples/cwebp and examples/dwebp, along with the static
|
||||||
|
library src/libwebp.a. No system-wide installation is supplied, as this is a
|
||||||
|
simple alternative to the full installation system based on the autoconf tools
|
||||||
|
(see below). Please refer to makefile.unix for additional details and
|
||||||
|
customizations.
|
||||||
|
|
||||||
|
## Using autoconf tools
|
||||||
|
|
||||||
|
Prerequisites: a compiler (e.g., gcc), make, autoconf, automake, libtool.
|
||||||
|
|
||||||
|
On a Debian-like system the following should install everything you need for a
|
||||||
|
minimal build:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ sudo apt-get install gcc make autoconf automake libtool
|
||||||
|
```
|
||||||
|
|
||||||
|
When building from git sources, you will need to run autogen.sh to generate the
|
||||||
|
configure script.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
./configure
|
||||||
|
make
|
||||||
|
make install
|
||||||
|
```
|
||||||
|
|
||||||
|
should be all you need to have the following files
|
||||||
|
|
||||||
|
```
|
||||||
|
/usr/local/include/webp/decode.h
|
||||||
|
/usr/local/include/webp/encode.h
|
||||||
|
/usr/local/include/webp/types.h
|
||||||
|
/usr/local/lib/libwebp.*
|
||||||
|
/usr/local/bin/cwebp
|
||||||
|
/usr/local/bin/dwebp
|
||||||
|
```
|
||||||
|
|
||||||
|
installed.
|
||||||
|
|
||||||
|
Note: A decode-only library, libwebpdecoder, is available using the
|
||||||
|
`--enable-libwebpdecoder` flag. The encode library is built separately and can
|
||||||
|
be installed independently using a minor modification in the corresponding
|
||||||
|
Makefile.am configure files (see comments there). See `./configure --help` for
|
||||||
|
more options.
|
||||||
|
|
||||||
|
## Building for MIPS Linux
|
||||||
|
|
||||||
|
MIPS Linux toolchain stable available releases can be found at:
|
||||||
|
https://community.imgtec.com/developers/mips/tools/codescape-mips-sdk/available-releases/
|
||||||
|
|
||||||
|
```shell
|
||||||
|
# Add toolchain to PATH
|
||||||
|
export PATH=$PATH:/path/to/toolchain/bin
|
||||||
|
|
||||||
|
# 32-bit build for mips32r5 (p5600)
|
||||||
|
HOST=mips-mti-linux-gnu
|
||||||
|
MIPS_CFLAGS="-O3 -mips32r5 -mabi=32 -mtune=p5600 -mmsa -mfp64 \
|
||||||
|
-msched-weight -mload-store-pairs -fPIE"
|
||||||
|
MIPS_LDFLAGS="-mips32r5 -mabi=32 -mmsa -mfp64 -pie"
|
||||||
|
|
||||||
|
# 64-bit build for mips64r6 (i6400)
|
||||||
|
HOST=mips-img-linux-gnu
|
||||||
|
MIPS_CFLAGS="-O3 -mips64r6 -mabi=64 -mtune=i6400 -mmsa -mfp64 \
|
||||||
|
-msched-weight -mload-store-pairs -fPIE"
|
||||||
|
MIPS_LDFLAGS="-mips64r6 -mabi=64 -mmsa -mfp64 -pie"
|
||||||
|
|
||||||
|
./configure --host=${HOST} --build=`config.guess` \
|
||||||
|
CC="${HOST}-gcc -EL" \
|
||||||
|
CFLAGS="$MIPS_CFLAGS" \
|
||||||
|
LDFLAGS="$MIPS_LDFLAGS"
|
||||||
|
make
|
||||||
|
make install
|
||||||
|
```
|
||||||
|
|
||||||
|
## CMake
|
||||||
|
|
||||||
|
With CMake, you can compile libwebp, cwebp, dwebp, gif2webp, img2webp, webpinfo
|
||||||
|
and the JS bindings.
|
||||||
|
|
||||||
|
Prerequisites: a compiler (e.g., gcc with autotools) and CMake.
|
||||||
|
|
||||||
|
On a Debian-like system the following should install everything you need for a
|
||||||
|
minimal build:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ sudo apt-get install build-essential cmake
|
||||||
|
```
|
||||||
|
|
||||||
|
When building from git sources, you will need to run cmake to generate the
|
||||||
|
makefiles.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
mkdir build && cd build && cmake ../
|
||||||
|
make
|
||||||
|
make install
|
||||||
|
```
|
||||||
|
|
||||||
|
If you also want any of the executables, you will need to enable them through
|
||||||
|
CMake, e.g.:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
cmake -DWEBP_BUILD_CWEBP=ON -DWEBP_BUILD_DWEBP=ON ../
|
||||||
|
```
|
||||||
|
|
||||||
|
or through your favorite interface (like ccmake or cmake-qt-gui).
|
||||||
|
|
||||||
|
Use option `-DWEBP_UNICODE=ON` for Unicode support on Windows (with chcp 65001).
|
||||||
|
|
||||||
|
Finally, once installed, you can also use WebP in your CMake project by doing:
|
||||||
|
|
||||||
|
```cmake
|
||||||
|
find_package(WebP)
|
||||||
|
```
|
||||||
|
|
||||||
|
which will define the CMake variables WebP_INCLUDE_DIRS and WebP_LIBRARIES.
|
||||||
|
|
||||||
|
## Gradle
|
||||||
|
|
||||||
|
The support for Gradle is minimal: it only helps you compile libwebp, cwebp and
|
||||||
|
dwebp and webpmux_example.
|
||||||
|
|
||||||
|
Prerequisites: a compiler (e.g., gcc with autotools) and gradle.
|
||||||
|
|
||||||
|
On a Debian-like system the following should install everything you need for a
|
||||||
|
minimal build:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ sudo apt-get install build-essential gradle
|
||||||
|
```
|
||||||
|
|
||||||
|
When building from git sources, you will need to run the Gradle wrapper with the
|
||||||
|
appropriate target, e.g. :
|
||||||
|
|
||||||
|
```shell
|
||||||
|
./gradlew buildAllExecutables
|
||||||
|
```
|
||||||
|
|
||||||
|
## SWIG bindings
|
||||||
|
|
||||||
|
To generate language bindings from swig/libwebp.swig at least swig-1.3
|
||||||
|
(http://www.swig.org) is required.
|
||||||
|
|
||||||
|
Currently the following functions are mapped:
|
||||||
|
|
||||||
|
Decode:
|
||||||
|
|
||||||
|
```
|
||||||
|
WebPGetDecoderVersion
|
||||||
|
WebPGetInfo
|
||||||
|
WebPDecodeRGBA
|
||||||
|
WebPDecodeARGB
|
||||||
|
WebPDecodeBGRA
|
||||||
|
WebPDecodeBGR
|
||||||
|
WebPDecodeRGB
|
||||||
|
```
|
||||||
|
|
||||||
|
Encode:
|
||||||
|
|
||||||
|
```
|
||||||
|
WebPGetEncoderVersion
|
||||||
|
WebPEncodeRGBA
|
||||||
|
WebPEncodeBGRA
|
||||||
|
WebPEncodeRGB
|
||||||
|
WebPEncodeBGR
|
||||||
|
WebPEncodeLosslessRGBA
|
||||||
|
WebPEncodeLosslessBGRA
|
||||||
|
WebPEncodeLosslessRGB
|
||||||
|
WebPEncodeLosslessBGR
|
||||||
|
```
|
||||||
|
|
||||||
|
See also the [swig documentation](../swig/README.md) for more detailed build
|
||||||
|
instructions and usage examples.
|
||||||
|
|
||||||
|
### Java bindings
|
||||||
|
|
||||||
|
To build the swig-generated JNI wrapper code at least JDK-1.5 (or equivalent) is
|
||||||
|
necessary for enum support. The output is intended to be a shared object / DLL
|
||||||
|
that can be loaded via `System.loadLibrary("webp_jni")`.
|
||||||
|
|
||||||
|
### Python bindings
|
||||||
|
|
||||||
|
To build the swig-generated Python extension code at least Python 2.6 is
|
||||||
|
required. Python < 2.6 may build with some minor changes to libwebp.swig or the
|
||||||
|
generated code, but is untested.
|
||||||
|
|
||||||
|
## Javascript decoder
|
||||||
|
|
||||||
|
Libwebp can be compiled into a JavaScript decoder using Emscripten and CMake.
|
||||||
|
See the [corresponding documentation](../README.md)
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user