Compare commits
41 Commits
android_co
...
66a9271f44
Author | SHA1 | Date | |
---|---|---|---|
66a9271f44 | |||
25b55b3530 | |||
9fd2440ec6 | |||
d6d91e61f4 | |||
5230770062 | |||
1dccce8097 | |||
7f2df29304 | |||
732e08736f | |||
d5709c421c | |||
18c37f9934 | |||
53ae3f8ce5 | |||
b5e90528f0 | |||
22071b60e6 | |||
5283df7b98 | |||
21243ea979 | |||
1d212c5fab | |||
37239f1c25 | |||
780e1e06d4 | |||
7c227457cd | |||
5544adf345 | |||
6d3ef742b5 | |||
cba3282dce | |||
5c5e830f0f | |||
e08dbba940 | |||
752f2ebe2c | |||
a47d607a8d | |||
5356e59088 | |||
2189c4c3cb | |||
4b99da5e4e | |||
16dc9e4071 | |||
faad603d88 | |||
41c83619b5 | |||
ea83589a82 | |||
727f33ae82 | |||
1111a11577 | |||
9b163e00d9 | |||
183277250f | |||
6b96be7a57 | |||
a2001b34ea | |||
85b5c9200a | |||
8ab503840a |
10
.github/workflows/cd.yml
vendored
10
.github/workflows/cd.yml
vendored
@ -128,13 +128,13 @@ jobs:
|
||||
- name: rename apk
|
||||
id: rename_apk
|
||||
shell: bash
|
||||
run: mv "${{github.workspace}}/build/android/tomato.apk" "${{github.workspace}}/build/android/${{github.event.repository.name}}-${{steps.tag.outputs.name}}-android-${{matrix.platform.ndk_abi}}.apk"
|
||||
run: mv "${{github.workspace}}/build/android/tomato.apk" "${{github.workspace}}/build/android/${{github.event.repository.name}}-${{steps.tag.outputs.name}}-Android-${{matrix.platform.ndk_abi}}.apk"
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{github.event.repository.name}}-${{steps.tag.outputs.name}}-${{runner.os}}-android-${{matrix.platform.ndk_abi}}
|
||||
name: ${{github.event.repository.name}}-${{steps.tag.outputs.name}}-${{runner.os}}-Android-${{matrix.platform.ndk_abi}}
|
||||
path: |
|
||||
${{github.workspace}}/build/android/${{github.event.repository.name}}-${{steps.tag.outputs.name}}-android-${{matrix.platform.ndk_abi}}.apk
|
||||
${{github.workspace}}/build/android/${{github.event.repository.name}}-${{steps.tag.outputs.name}}-Android-${{matrix.platform.ndk_abi}}.apk
|
||||
|
||||
windows:
|
||||
timeout-minutes: 15
|
||||
@ -153,7 +153,7 @@ jobs:
|
||||
git pull
|
||||
|
||||
- name: Install Dependencies
|
||||
run: vcpkg install libsodium:x64-windows-static pthreads:x64-windows-static pkgconf:x64-windows
|
||||
run: vcpkg install pkgconf:x64-windows libsodium:x64-windows-static pthreads:x64-windows-static opus:x64-windows-static libvpx:x64-windows-static
|
||||
|
||||
# setup vs env
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
@ -212,7 +212,7 @@ jobs:
|
||||
git pull
|
||||
|
||||
- name: Install Dependencies
|
||||
run: vcpkg install libsodium:x64-windows-static pthreads:x64-windows-static pkgconf:x64-windows
|
||||
run: vcpkg install pkgconf:x64-windows libsodium:x64-windows-static pthreads:x64-windows-static opus:x64-windows-static libvpx:x64-windows-static
|
||||
|
||||
# setup vs env
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
|
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -129,7 +129,7 @@ jobs:
|
||||
git pull
|
||||
|
||||
- name: Install Dependencies
|
||||
run: vcpkg install libsodium:x64-windows-static pthreads:x64-windows-static pkgconf:x64-windows
|
||||
run: vcpkg install pkgconf:x64-windows libsodium:x64-windows-static pthreads:x64-windows-static opus:x64-windows-static libvpx:x64-windows-static
|
||||
|
||||
# setup vs env
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
|
@ -44,7 +44,7 @@ endif()
|
||||
add_compile_definitions(ENTT_API_EXPORT)
|
||||
|
||||
# external libs
|
||||
add_subdirectory(./external) # before increasing warn levels, sad :(
|
||||
add_subdirectory(./external EXCLUDE_FROM_ALL) # before increasing warn levels, sad :(
|
||||
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
|
@ -1,109 +1,106 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Replace com.test.game with the identifier of your game below, e.g.
|
||||
com.gamemaker.game
|
||||
com.gamemaker.game
|
||||
-->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.libsdl.app.tomato"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0"
|
||||
android:installLocation="auto">
|
||||
|
||||
<!-- OpenGL ES 2.0 -->
|
||||
<uses-feature android:glEsVersion="0x00020000" />
|
||||
<!-- OpenGL ES 2.0 -->
|
||||
<uses-feature android:glEsVersion="0x00020000" />
|
||||
|
||||
<!-- Touchscreen support -->
|
||||
<uses-feature
|
||||
android:name="android.hardware.touchscreen"
|
||||
android:required="false" />
|
||||
<!-- Touchscreen support -->
|
||||
<uses-feature
|
||||
android:name="android.hardware.touchscreen"
|
||||
android:required="false" />
|
||||
|
||||
<!-- Game controller support -->
|
||||
<uses-feature
|
||||
android:name="android.hardware.bluetooth"
|
||||
android:required="false" />
|
||||
<uses-feature
|
||||
android:name="android.hardware.gamepad"
|
||||
android:required="false" />
|
||||
<uses-feature
|
||||
android:name="android.hardware.usb.host"
|
||||
android:required="false" />
|
||||
<!-- Game controller support -->
|
||||
<uses-feature
|
||||
android:name="android.hardware.bluetooth"
|
||||
android:required="false" />
|
||||
<uses-feature
|
||||
android:name="android.hardware.gamepad"
|
||||
android:required="false" />
|
||||
<uses-feature
|
||||
android:name="android.hardware.usb.host"
|
||||
android:required="false" />
|
||||
|
||||
<!-- External mouse input events -->
|
||||
<uses-feature
|
||||
android:name="android.hardware.type.pc"
|
||||
android:required="false" />
|
||||
<!-- External mouse input events -->
|
||||
<uses-feature
|
||||
android:name="android.hardware.type.pc"
|
||||
android:required="false" />
|
||||
|
||||
<!-- Audio recording support -->
|
||||
<!-- if you want to capture audio, uncomment this. -->
|
||||
<!-- <uses-feature
|
||||
android:name="android.hardware.microphone"
|
||||
android:required="false" /> -->
|
||||
<!-- Audio recording support -->
|
||||
<!-- if you want to capture audio, uncomment this. -->
|
||||
<!-- <uses-feature
|
||||
android:name="android.hardware.microphone"
|
||||
android:required="false" /> -->
|
||||
|
||||
<!-- Camera support -->
|
||||
<!-- if you want to record video, uncomment this. -->
|
||||
<!--
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-feature android:name="android.hardware.camera" />
|
||||
-->
|
||||
<!-- Camera support -->
|
||||
<!-- if you want to record video, uncomment this. -->
|
||||
<!--
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-feature android:name="android.hardware.camera" />
|
||||
-->
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<!-- Allow downloading to the external storage on Android 5.1 and older -->
|
||||
<!-- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="22" /> -->
|
||||
<!-- Allow downloading to the external storage on Android 5.1 and older -->
|
||||
<!-- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="22" /> -->
|
||||
|
||||
<!-- Allow access to Bluetooth devices -->
|
||||
<!-- Currently this is just for Steam Controller support and requires setting SDL_HINT_JOYSTICK_HIDAPI_STEAM -->
|
||||
<!-- <uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" /> -->
|
||||
<!-- <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" /> -->
|
||||
<!-- Allow access to Bluetooth devices -->
|
||||
<!-- Currently this is just for Steam Controller support and requires setting SDL_HINT_JOYSTICK_HIDAPI_STEAM -->
|
||||
<!-- <uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" /> -->
|
||||
<!-- <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" /> -->
|
||||
|
||||
<!-- Allow access to the vibrator -->
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<!-- Allow access to the vibrator -->
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
|
||||
<!-- if you want to capture audio, uncomment this. -->
|
||||
<!-- <uses-permission android:name="android.permission.RECORD_AUDIO" /> -->
|
||||
<!-- if you want to capture audio, uncomment this. -->
|
||||
<!-- <uses-permission android:name="android.permission.RECORD_AUDIO" /> -->
|
||||
|
||||
<!-- Create a Java class extending SDLActivity and place it in a
|
||||
directory under app/src/main/java matching the package, e.g. app/src/main/java/com/gamemaker/game/MyGame.java
|
||||
<!-- Create a Java class extending SDLActivity and place it in a
|
||||
directory under app/src/main/java matching the package, e.g. app/src/main/java/com/gamemaker/game/MyGame.java
|
||||
|
||||
then replace "SDLActivity" with the name of your class (e.g. "MyGame")
|
||||
in the XML below.
|
||||
then replace "SDLActivity" with the name of your class (e.g. "MyGame")
|
||||
in the XML below.
|
||||
|
||||
An example Java class can be found in README-android.md
|
||||
-->
|
||||
<application android:label="@string/app_name"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
An example Java class can be found in README-android.md
|
||||
-->
|
||||
<application android:label="@string/app_name"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:appCategory="social"
|
||||
android:allowBackup="true"
|
||||
android:theme="@style/AppTheme"
|
||||
android:hardwareAccelerated="true" >
|
||||
android:allowBackup="true"
|
||||
android:theme="@style/AppTheme"
|
||||
android:hardwareAccelerated="true" >
|
||||
|
||||
<!-- setting sdl hints. uses the string value -->
|
||||
<meta-data android:name="SDL_ENV.SDL_ANDROID_BLOCK_ON_PAUSE" android:value="0"/>
|
||||
|
||||
<activity android:name="TomatoActivity"
|
||||
android:label="@string/app_name"
|
||||
android:alwaysRetainTaskState="true"
|
||||
android:launchMode="singleInstance"
|
||||
android:configChanges="layoutDirection|locale|orientation|uiMode|screenLayout|screenSize|smallestScreenSize|keyboard|keyboardHidden|navigation"
|
||||
android:preferMinimalPostProcessing="true"
|
||||
android:exported="true"
|
||||
>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
<!-- Let Android know that we can handle some USB devices and should receive this event -->
|
||||
<intent-filter>
|
||||
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
|
||||
</intent-filter>
|
||||
<!-- Drop file event -->
|
||||
<!--
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:mimeType="*/*" />
|
||||
</intent-filter>
|
||||
-->
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
<activity android:name="TomatoActivity"
|
||||
android:label="@string/app_name"
|
||||
android:alwaysRetainTaskState="true"
|
||||
android:launchMode="singleInstance"
|
||||
android:configChanges="layoutDirection|locale|orientation|uiMode|screenLayout|screenSize|smallestScreenSize|keyboard|keyboardHidden|navigation"
|
||||
android:preferMinimalPostProcessing="true"
|
||||
android:exported="true"
|
||||
>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
<!-- Let Android know that we can handle some USB devices and should receive this event -->
|
||||
<intent-filter>
|
||||
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
|
||||
</intent-filter>
|
||||
<!-- Drop file event -->
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:mimeType="*/*" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
|
@ -3,7 +3,7 @@
|
||||
<!-- Base application theme. -->
|
||||
<!-- <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar"> -->
|
||||
<!--<style name="AppTheme" parent="android:Theme.AppCompat">-->
|
||||
<style name="AppTheme" parent="android:Theme">
|
||||
<style name="AppTheme" parent="android:Theme.NoTitleBar">
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
|
||||
|
1
external/imgui/CMakeLists.txt
vendored
1
external/imgui/CMakeLists.txt
vendored
@ -18,6 +18,7 @@ add_library(imgui
|
||||
imgui/misc/cpp/imgui_stdlib.cpp
|
||||
)
|
||||
|
||||
target_compile_definitions(imgui PUBLIC IMGUI_USE_WCHAR32)
|
||||
target_compile_features(imgui PUBLIC cxx_std_11)
|
||||
|
||||
target_include_directories(imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
2
external/imgui/imgui/.github/FUNDING.yml
vendored
2
external/imgui/imgui/.github/FUNDING.yml
vendored
@ -1 +1 @@
|
||||
custom: ['https://github.com/ocornut/imgui/wiki/Sponsors']
|
||||
custom: ['https://github.com/ocornut/imgui/wiki/Funding']
|
||||
|
1
external/imgui/imgui/.gitignore
vendored
1
external/imgui/imgui/.gitignore
vendored
@ -3,6 +3,7 @@
|
||||
|
||||
## Dear ImGui artifacts
|
||||
imgui.ini
|
||||
imgui*.ini
|
||||
|
||||
## General build artifacts
|
||||
*.o
|
||||
|
@ -62,8 +62,8 @@
|
||||
#ifdef _WIN32
|
||||
#include <allegro5/allegro_windows.h>
|
||||
#endif
|
||||
#define ALLEGRO_HAS_CLIPBOARD (ALLEGRO_VERSION_INT >= ((5 << 24) | (1 << 16) | (12 << 8))) // Clipboard only supported from Allegro 5.1.12
|
||||
#define ALLEGRO_HAS_DRAW_INDEXED_PRIM (ALLEGRO_VERSION_INT >= ((5 << 24) | (2 << 16) | ( 5 << 8))) // DX9 implementation of al_draw_indexed_prim() got fixed in Allegro 5.2.5
|
||||
#define ALLEGRO_HAS_CLIPBOARD ((ALLEGRO_VERSION_INT & ~ALLEGRO_UNSTABLE_BIT) >= ((5 << 24) | (1 << 16) | (12 << 8))) // Clipboard only supported from Allegro 5.1.12
|
||||
#define ALLEGRO_HAS_DRAW_INDEXED_PRIM ((ALLEGRO_VERSION_INT & ~ALLEGRO_UNSTABLE_BIT) >= ((5 << 24) | (2 << 16) | ( 5 << 8))) // DX9 implementation of al_draw_indexed_prim() got fixed in Allegro 5.2.5
|
||||
|
||||
// Visual Studio warnings
|
||||
#ifdef _MSC_VER
|
||||
|
@ -20,6 +20,9 @@
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2024-07-08: *BREAKING* Renamed ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback to ImGui_ImplGlfw_InstallEmscriptenCallbacks(), added GLFWWindow* parameter.
|
||||
// 2024-07-08: Emscripten: Added support for GLFW3 contrib port (GLFW 3.4.0 features + bug fixes): to enable, replace -sUSE_GLFW=3 with --use-port=contrib.glfw3 (requires emscripten 3.1.59+) (https://github.com/pongasoft/emscripten-glfw)
|
||||
// 2024-07-02: Emscripten: Added io.PlatformOpenInShellFn() handler for Emscripten versions.
|
||||
// 2023-12-19: Emscripten: Added ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback() to register canvas selector and auto-resize GLFW window.
|
||||
// 2023-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F24 function keys.
|
||||
// 2023-07-18: Inputs: Revert ignoring mouse data on GLFW_CURSOR_DISABLED as it can be used differently. User may set ImGuiConfigFLags_NoMouse if desired. (#5625, #6609)
|
||||
@ -100,6 +103,11 @@
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
#include <emscripten/html5.h>
|
||||
#ifdef EMSCRIPTEN_USE_PORT_CONTRIB_GLFW3
|
||||
#include <GLFW/emscripten_glfw3.h>
|
||||
#else
|
||||
#define EMSCRIPTEN_USE_EMBEDDED_GLFW3
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// We gather version tests as define in order to easily see which features are version-dependent.
|
||||
@ -131,7 +139,7 @@ struct ImGui_ImplGlfw_Data
|
||||
ImVec2 LastValidMousePos;
|
||||
bool InstalledCallbacks;
|
||||
bool CallbacksChainForAllWindows;
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#ifdef EMSCRIPTEN_USE_EMBEDDED_GLFW3
|
||||
const char* CanvasSelector;
|
||||
#endif
|
||||
|
||||
@ -145,7 +153,7 @@ struct ImGui_ImplGlfw_Data
|
||||
GLFWcharfun PrevUserCallbackChar;
|
||||
GLFWmonitorfun PrevUserCallbackMonitor;
|
||||
#ifdef _WIN32
|
||||
WNDPROC GlfwWndProc;
|
||||
WNDPROC PrevWndProc;
|
||||
#endif
|
||||
|
||||
ImGui_ImplGlfw_Data() { memset((void*)this, 0, sizeof(*this)); }
|
||||
@ -335,7 +343,7 @@ void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yo
|
||||
if (bd->PrevUserCallbackScroll != nullptr && ImGui_ImplGlfw_ShouldChainCallback(window))
|
||||
bd->PrevUserCallbackScroll(window, xoffset, yoffset);
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#ifdef EMSCRIPTEN_USE_EMBEDDED_GLFW3
|
||||
// Ignore GLFW events: will be processed in ImGui_ImplEmscripten_WheelCallback().
|
||||
return;
|
||||
#endif
|
||||
@ -346,7 +354,7 @@ void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yo
|
||||
|
||||
static int ImGui_ImplGlfw_TranslateUntranslatedKey(int key, int scancode)
|
||||
{
|
||||
#if GLFW_HAS_GETKEYNAME && !defined(__EMSCRIPTEN__)
|
||||
#if GLFW_HAS_GETKEYNAME && !defined(EMSCRIPTEN_USE_EMBEDDED_GLFW3)
|
||||
// GLFW 3.1+ attempts to "untranslate" keys, which goes the opposite of what every other framework does, making using lettered shortcuts difficult.
|
||||
// (It had reasons to do so: namely GLFW is/was more likely to be used for WASD-type game controls rather than lettered shortcuts, but IHMO the 3.1 change could have been done differently)
|
||||
// See https://github.com/glfw/glfw/issues/1502 for details.
|
||||
@ -357,7 +365,7 @@ static int ImGui_ImplGlfw_TranslateUntranslatedKey(int key, int scancode)
|
||||
GLFWerrorfun prev_error_callback = glfwSetErrorCallback(nullptr);
|
||||
const char* key_name = glfwGetKeyName(key, scancode);
|
||||
glfwSetErrorCallback(prev_error_callback);
|
||||
#if GLFW_HAS_GETERROR && !defined(__EMSCRIPTEN__) // Eat errors (see #5908)
|
||||
#if GLFW_HAS_GETERROR && !defined(EMSCRIPTEN_USE_EMBEDDED_GLFW3) // Eat errors (see #5908)
|
||||
(void)glfwGetError(nullptr);
|
||||
#endif
|
||||
if (key_name && key_name[0] != 0 && key_name[1] == 0)
|
||||
@ -454,7 +462,7 @@ void ImGui_ImplGlfw_MonitorCallback(GLFWmonitor*, int)
|
||||
// Unused in 'master' branch but 'docking' branch will use this, so we declare it ahead of it so if you have to install callbacks you can install this one too.
|
||||
}
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#ifdef EMSCRIPTEN_USE_EMBEDDED_GLFW3
|
||||
static EM_BOOL ImGui_ImplEmscripten_WheelCallback(int, const EmscriptenWheelEvent* ev, void*)
|
||||
{
|
||||
// Mimic Emscripten_HandleWheel() in SDL.
|
||||
@ -497,7 +505,7 @@ static LRESULT CALLBACK ImGui_ImplGlfw_WndProc(HWND hWnd, UINT msg, WPARAM wPara
|
||||
ImGui::GetIO().AddMouseSourceEvent(GetMouseSourceFromMessageExtraInfo());
|
||||
break;
|
||||
}
|
||||
return ::CallWindowProcW(bd->GlfwWndProc, hWnd, msg, wParam, lParam);
|
||||
return ::CallWindowProcW(bd->PrevWndProc, hWnd, msg, wParam, lParam);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -553,6 +561,10 @@ void ImGui_ImplGlfw_SetCallbacksChainForAllWindows(bool chain_for_all_windows)
|
||||
bd->CallbacksChainForAllWindows = chain_for_all_windows;
|
||||
}
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
EM_JS(void, ImGui_ImplGlfw_EmscriptenOpenURL, (char const* url), { url = url ? UTF8ToString(url) : null; if (url) window.open(url, '_blank'); });
|
||||
#endif
|
||||
|
||||
static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, GlfwClientApi client_api)
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
@ -573,6 +585,9 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
|
||||
io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
|
||||
io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
|
||||
io.ClipboardUserData = bd->Window;
|
||||
#ifdef __EMSCRIPTEN__
|
||||
io.PlatformOpenInShellFn = [](ImGuiContext*, const char* url) { ImGui_ImplGlfw_EmscriptenOpenURL(url); return true; };
|
||||
#endif
|
||||
|
||||
// Create mouse cursors
|
||||
// (By design, on X11 cursors are user configurable and some cursors may be missing. When a cursor doesn't exist,
|
||||
@ -603,15 +618,10 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
|
||||
// Chain GLFW callbacks: our callbacks will call the user's previously installed callbacks, if any.
|
||||
if (install_callbacks)
|
||||
ImGui_ImplGlfw_InstallCallbacks(window);
|
||||
// Register Emscripten Wheel callback to workaround issue in Emscripten GLFW Emulation (#6096)
|
||||
// We intentionally do not check 'if (install_callbacks)' here, as some users may set it to false and call GLFW callback themselves.
|
||||
// FIXME: May break chaining in case user registered their own Emscripten callback?
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_set_wheel_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, nullptr, false, ImGui_ImplEmscripten_WheelCallback);
|
||||
#endif
|
||||
|
||||
// Set platform dependent data in viewport
|
||||
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||
main_viewport->PlatformHandle = (void*)bd->Window;
|
||||
#ifdef _WIN32
|
||||
main_viewport->PlatformHandleRaw = glfwGetWin32Window(bd->Window);
|
||||
#elif defined(__APPLE__)
|
||||
@ -622,8 +632,8 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
|
||||
|
||||
// Windows: register a WndProc hook so we can intercept some messages.
|
||||
#ifdef _WIN32
|
||||
bd->GlfwWndProc = (WNDPROC)::GetWindowLongPtrW((HWND)main_viewport->PlatformHandleRaw, GWLP_WNDPROC);
|
||||
IM_ASSERT(bd->GlfwWndProc != nullptr);
|
||||
bd->PrevWndProc = (WNDPROC)::GetWindowLongPtrW((HWND)main_viewport->PlatformHandleRaw, GWLP_WNDPROC);
|
||||
IM_ASSERT(bd->PrevWndProc != nullptr);
|
||||
::SetWindowLongPtrW((HWND)main_viewport->PlatformHandleRaw, GWLP_WNDPROC, (LONG_PTR)ImGui_ImplGlfw_WndProc);
|
||||
#endif
|
||||
|
||||
@ -654,18 +664,19 @@ void ImGui_ImplGlfw_Shutdown()
|
||||
|
||||
if (bd->InstalledCallbacks)
|
||||
ImGui_ImplGlfw_RestoreCallbacks(bd->Window);
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_set_wheel_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, nullptr, false, nullptr);
|
||||
#ifdef EMSCRIPTEN_USE_EMBEDDED_GLFW3
|
||||
if (bd->CanvasSelector)
|
||||
emscripten_set_wheel_callback(bd->CanvasSelector, nullptr, false, nullptr);
|
||||
#endif
|
||||
|
||||
for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++)
|
||||
glfwDestroyCursor(bd->MouseCursors[cursor_n]);
|
||||
|
||||
// Windows: register a WndProc hook so we can intercept some messages.
|
||||
// Windows: restore our WndProc hook
|
||||
#ifdef _WIN32
|
||||
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||
::SetWindowLongPtrW((HWND)main_viewport->PlatformHandleRaw, GWLP_WNDPROC, (LONG_PTR)bd->GlfwWndProc);
|
||||
bd->GlfwWndProc = nullptr;
|
||||
::SetWindowLongPtrW((HWND)main_viewport->PlatformHandleRaw, GWLP_WNDPROC, (LONG_PTR)bd->PrevWndProc);
|
||||
bd->PrevWndProc = nullptr;
|
||||
#endif
|
||||
|
||||
io.BackendPlatformName = nullptr;
|
||||
@ -682,7 +693,7 @@ static void ImGui_ImplGlfw_UpdateMouseData()
|
||||
// (those braces are here to reduce diff with multi-viewports support in 'docking' branch)
|
||||
{
|
||||
GLFWwindow* window = bd->Window;
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#ifdef EMSCRIPTEN_USE_EMBEDDED_GLFW3
|
||||
const bool is_window_focused = true;
|
||||
#else
|
||||
const bool is_window_focused = glfwGetWindowAttrib(window, GLFW_FOCUSED) != 0;
|
||||
@ -740,7 +751,7 @@ static void ImGui_ImplGlfw_UpdateGamepads()
|
||||
return;
|
||||
|
||||
io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
|
||||
#if GLFW_HAS_GAMEPAD_API && !defined(__EMSCRIPTEN__)
|
||||
#if GLFW_HAS_GAMEPAD_API && !defined(EMSCRIPTEN_USE_EMBEDDED_GLFW3)
|
||||
GLFWgamepadstate gamepad;
|
||||
if (!glfwGetGamepadState(GLFW_JOYSTICK_1, &gamepad))
|
||||
return;
|
||||
@ -814,7 +825,7 @@ void ImGui_ImplGlfw_NewFrame()
|
||||
ImGui_ImplGlfw_UpdateGamepads();
|
||||
}
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#ifdef EMSCRIPTEN_USE_EMBEDDED_GLFW3
|
||||
static EM_BOOL ImGui_ImplGlfw_OnCanvasSizeChange(int event_type, const EmscriptenUiEvent* event, void* user_data)
|
||||
{
|
||||
ImGui_ImplGlfw_Data* bd = (ImGui_ImplGlfw_Data*)user_data;
|
||||
@ -835,7 +846,7 @@ static EM_BOOL ImGui_ImplEmscripten_FullscreenChangeCallback(int event_type, con
|
||||
|
||||
// 'canvas_selector' is a CSS selector. The event listener is applied to the first element that matches the query.
|
||||
// STRING MUST PERSIST FOR THE APPLICATION DURATION. PLEASE USE A STRING LITERAL OR ENSURE POINTER WILL STAY VALID.
|
||||
void ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback(const char* canvas_selector)
|
||||
void ImGui_ImplGlfw_InstallEmscriptenCallbacks(GLFWwindow*, const char* canvas_selector)
|
||||
{
|
||||
IM_ASSERT(canvas_selector != nullptr);
|
||||
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||
@ -847,8 +858,24 @@ void ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback(const char* canvas_sel
|
||||
|
||||
// Change the size of the GLFW window according to the size of the canvas
|
||||
ImGui_ImplGlfw_OnCanvasSizeChange(EMSCRIPTEN_EVENT_RESIZE, {}, bd);
|
||||
|
||||
// Register Emscripten Wheel callback to workaround issue in Emscripten GLFW Emulation (#6096)
|
||||
// We intentionally do not check 'if (install_callbacks)' here, as some users may set it to false and call GLFW callback themselves.
|
||||
// FIXME: May break chaining in case user registered their own Emscripten callback?
|
||||
emscripten_set_wheel_callback(bd->CanvasSelector, nullptr, false, ImGui_ImplEmscripten_WheelCallback);
|
||||
}
|
||||
#endif
|
||||
#elif defined(EMSCRIPTEN_USE_PORT_CONTRIB_GLFW3)
|
||||
// When using --use-port=contrib.glfw3 for the GLFW implementation, you can override the behavior of this call
|
||||
// by invoking emscripten_glfw_make_canvas_resizable afterward.
|
||||
// See https://github.com/pongasoft/emscripten-glfw/blob/master/docs/Usage.md#how-to-make-the-canvas-resizable-by-the-user for an explanation
|
||||
void ImGui_ImplGlfw_InstallEmscriptenCallbacks(GLFWwindow* window, const char* canvas_selector)
|
||||
{
|
||||
GLFWwindow* w = (GLFWwindow*)(EM_ASM_INT({ return Module.glfwGetWindow(UTF8ToString($0)); }, canvas_selector));
|
||||
IM_ASSERT(window == w); // Sanity check
|
||||
IM_UNUSED(w);
|
||||
emscripten_glfw_make_canvas_resizable(window, "window", nullptr);
|
||||
}
|
||||
#endif // #ifdef EMSCRIPTEN_USE_PORT_CONTRIB_GLFW3
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
@ -30,9 +30,10 @@ IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOther(GLFWwindow* window, bool ins
|
||||
IMGUI_IMPL_API void ImGui_ImplGlfw_Shutdown();
|
||||
IMGUI_IMPL_API void ImGui_ImplGlfw_NewFrame();
|
||||
|
||||
// Emscripten related initialization phase methods
|
||||
// Emscripten related initialization phase methods (call after ImGui_ImplGlfw_InitForOpenGL)
|
||||
#ifdef __EMSCRIPTEN__
|
||||
IMGUI_IMPL_API void ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback(const char* canvas_selector);
|
||||
IMGUI_IMPL_API void ImGui_ImplGlfw_InstallEmscriptenCallbacks(GLFWwindow* window, const char* canvas_selector);
|
||||
//static inline void ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback(const char* canvas_selector) { ImGui_ImplGlfw_InstallEmscriptenCallbacks(nullptr, canvas_selector); } } // Renamed in 1.91.0
|
||||
#endif
|
||||
|
||||
// GLFW callbacks install
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2024-06-28: OpenGL: ImGui_ImplOpenGL2_NewFrame() recreates font texture if it has been destroyed by ImGui_ImplOpenGL2_DestroyFontsTexture(). (#7748)
|
||||
// 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-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).
|
||||
@ -113,6 +114,8 @@ void ImGui_ImplOpenGL2_NewFrame()
|
||||
|
||||
if (!bd->FontTexture)
|
||||
ImGui_ImplOpenGL2_CreateDeviceObjects();
|
||||
if (!bd->FontTexture)
|
||||
ImGui_ImplOpenGL2_CreateFontsTexture();
|
||||
}
|
||||
|
||||
static void ImGui_ImplOpenGL2_SetupRenderState(ImDrawData* draw_data, int fb_width, int fb_height)
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2024-06-28: OpenGL: ImGui_ImplOpenGL3_NewFrame() recreates font texture if it has been destroyed by ImGui_ImplOpenGL3_DestroyFontsTexture(). (#7748)
|
||||
// 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.
|
||||
@ -402,6 +403,8 @@ void ImGui_ImplOpenGL3_NewFrame()
|
||||
|
||||
if (!bd->ShaderHandle)
|
||||
ImGui_ImplOpenGL3_CreateDeviceObjects();
|
||||
if (!bd->FontTexture)
|
||||
ImGui_ImplOpenGL3_CreateFontsTexture();
|
||||
}
|
||||
|
||||
static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_width, int fb_height, GLuint vertex_array_object)
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2024-07-02: Update for io.SetPlatformImeDataFn() -> io.PlatformSetImeDataFn() renaming in main library.
|
||||
// 2023-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F20 function keys. Stopped mapping F13 into PrintScreen.
|
||||
// 2023-04-09: Inputs: Added support for io.AddMouseSourceEvent() to discriminate ImGuiMouseSource_Mouse/ImGuiMouseSource_Pen.
|
||||
// 2023-02-01: Fixed scroll wheel scaling for devices emitting events with hasPreciseScrollingDeltas==false (e.g. non-Apple mices).
|
||||
@ -80,6 +81,7 @@ struct ImGui_ImplOSX_Data
|
||||
KeyEventResponder* KeyEventResponder;
|
||||
NSTextInputContext* InputContext;
|
||||
id Monitor;
|
||||
NSWindow* Window;
|
||||
|
||||
ImGui_ImplOSX_Data() { memset(this, 0, sizeof(*this)); }
|
||||
};
|
||||
@ -133,7 +135,7 @@ static bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view);
|
||||
|
||||
- (void)updateImePosWithView:(NSView *)view
|
||||
{
|
||||
NSWindow *window = view.window;
|
||||
NSWindow* window = view.window;
|
||||
if (!window)
|
||||
return;
|
||||
NSRect contentRect = [window contentRectForFrameRect:window.frame];
|
||||
@ -402,6 +404,9 @@ bool ImGui_ImplOSX_Init(NSView* view)
|
||||
//io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
||||
|
||||
bd->Observer = [ImGuiObserver new];
|
||||
bd->Window = view.window ?: NSApp.orderedWindows.firstObject;
|
||||
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||
main_viewport->PlatformHandle = main_viewport->PlatformHandleRaw = (__bridge_retained void*)bd->Window;
|
||||
|
||||
// Load cursors. Some of them are undocumented.
|
||||
bd->MouseCursorHidden = false;
|
||||
@ -460,7 +465,7 @@ bool ImGui_ImplOSX_Init(NSView* view)
|
||||
[view addSubview:bd->KeyEventResponder];
|
||||
ImGui_ImplOSX_AddTrackingArea(view);
|
||||
|
||||
io.SetPlatformImeDataFn = [](ImGuiViewport* viewport, ImGuiPlatformImeData* data) -> void
|
||||
io.PlatformSetImeDataFn = [](ImGuiContext*, ImGuiViewport* viewport, ImGuiPlatformImeData* data) -> void
|
||||
{
|
||||
ImGui_ImplOSX_Data* bd = ImGui_ImplOSX_GetBackendData();
|
||||
if (data->WantVisible)
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2024-07-02: Emscripten: Added io.PlatformOpenInShellFn() handler for Emscripten versions.
|
||||
// 2024-07-02: Update for io.SetPlatformImeDataFn() -> io.PlatformSetImeDataFn() renaming in main library.
|
||||
// 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-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)
|
||||
@ -90,9 +92,12 @@
|
||||
// SDL
|
||||
#include <SDL.h>
|
||||
#include <SDL_syswm.h>
|
||||
#if defined(__APPLE__)
|
||||
#ifdef __APPLE__
|
||||
#include <TargetConditionals.h>
|
||||
#endif
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten/em_js.h>
|
||||
#endif
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2,0,4) && !defined(__EMSCRIPTEN__) && !defined(__ANDROID__) && !(defined(__APPLE__) && TARGET_OS_IOS) && !defined(__amigaos4__)
|
||||
#define SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE 1
|
||||
@ -150,7 +155,7 @@ static void ImGui_ImplSDL2_SetClipboardText(void*, const char* text)
|
||||
}
|
||||
|
||||
// Note: native IME will only display if user calls SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1") _before_ SDL_CreateWindow().
|
||||
static void ImGui_ImplSDL2_SetPlatformImeData(ImGuiViewport*, ImGuiPlatformImeData* data)
|
||||
static void ImGui_ImplSDL2_PlatformSetImeData(ImGuiContext*, ImGuiViewport*, ImGuiPlatformImeData* data)
|
||||
{
|
||||
if (data->WantVisible)
|
||||
{
|
||||
@ -163,8 +168,9 @@ static void ImGui_ImplSDL2_SetPlatformImeData(ImGuiViewport*, ImGuiPlatformImeDa
|
||||
}
|
||||
}
|
||||
|
||||
static ImGuiKey ImGui_ImplSDL2_KeycodeToImGuiKey(int keycode)
|
||||
static ImGuiKey ImGui_ImplSDL2_KeyEventToImGuiKey(SDL_Keycode keycode, SDL_Scancode scancode)
|
||||
{
|
||||
IM_UNUSED(scancode);
|
||||
switch (keycode)
|
||||
{
|
||||
case SDLK_TAB: return ImGuiKey_Tab;
|
||||
@ -286,6 +292,7 @@ static ImGuiKey ImGui_ImplSDL2_KeycodeToImGuiKey(int keycode)
|
||||
case SDLK_F24: return ImGuiKey_F24;
|
||||
case SDLK_AC_BACK: return ImGuiKey_AppBack;
|
||||
case SDLK_AC_FORWARD: return ImGuiKey_AppForward;
|
||||
default: break;
|
||||
}
|
||||
return ImGuiKey_None;
|
||||
}
|
||||
@ -361,7 +368,7 @@ bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
|
||||
case SDL_KEYUP:
|
||||
{
|
||||
ImGui_ImplSDL2_UpdateKeyModifiers((SDL_Keymod)event->key.keysym.mod);
|
||||
ImGuiKey key = ImGui_ImplSDL2_KeycodeToImGuiKey(event->key.keysym.sym);
|
||||
ImGuiKey key = ImGui_ImplSDL2_KeyEventToImGuiKey(event->key.keysym.sym, event->key.keysym.scancode);
|
||||
io.AddKeyEvent(key, (event->type == SDL_KEYDOWN));
|
||||
io.SetKeyEventNativeData(key, event->key.keysym.sym, event->key.keysym.scancode, event->key.keysym.scancode); // To support legacy indexing (<1.87 user code). Legacy backend uses SDLK_*** as indices to IsKeyXXX() functions.
|
||||
return true;
|
||||
@ -397,7 +404,11 @@ bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool ImGui_ImplSDL2_Init(SDL_Window* window, SDL_Renderer* renderer)
|
||||
#ifdef __EMSCRIPTEN__
|
||||
EM_JS(void, ImGui_ImplSDL2_EmscriptenOpenURL, (char const* url), { url = url ? UTF8ToString(url) : null; if (url) window.open(url, '_blank'); });
|
||||
#endif
|
||||
|
||||
static bool ImGui_ImplSDL2_Init(SDL_Window* window, SDL_Renderer* renderer, void* sdl_gl_context)
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
IMGUI_CHECKVERSION();
|
||||
@ -428,7 +439,10 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window, SDL_Renderer* renderer)
|
||||
io.SetClipboardTextFn = ImGui_ImplSDL2_SetClipboardText;
|
||||
io.GetClipboardTextFn = ImGui_ImplSDL2_GetClipboardText;
|
||||
io.ClipboardUserData = nullptr;
|
||||
io.SetPlatformImeDataFn = ImGui_ImplSDL2_SetPlatformImeData;
|
||||
io.PlatformSetImeDataFn = ImGui_ImplSDL2_PlatformSetImeData;
|
||||
#ifdef __EMSCRIPTEN__
|
||||
io.PlatformOpenInShellFn = [](ImGuiContext*, const char* url) { ImGui_ImplSDL2_EmscriptenOpenURL(url); return true; };
|
||||
#endif
|
||||
|
||||
// Gamepad handling
|
||||
bd->GamepadMode = ImGui_ImplSDL2_GamepadMode_AutoFirst;
|
||||
@ -448,6 +462,7 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window, SDL_Renderer* renderer)
|
||||
// Set platform dependent data in viewport
|
||||
// Our mouse update function expect PlatformHandle to be filled for the main viewport
|
||||
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||
main_viewport->PlatformHandle = (void*)window;
|
||||
main_viewport->PlatformHandleRaw = nullptr;
|
||||
SDL_SysWMinfo info;
|
||||
SDL_VERSION(&info.version);
|
||||
@ -481,13 +496,13 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window, SDL_Renderer* renderer)
|
||||
SDL_SetHint(SDL_HINT_MOUSE_AUTO_CAPTURE, "0");
|
||||
#endif
|
||||
|
||||
(void)sdl_gl_context; // Unused in 'master' branch.
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context)
|
||||
{
|
||||
IM_UNUSED(sdl_gl_context); // Viewport branch will need this.
|
||||
return ImGui_ImplSDL2_Init(window, nullptr);
|
||||
return ImGui_ImplSDL2_Init(window, nullptr, sdl_gl_context);
|
||||
}
|
||||
|
||||
bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window)
|
||||
@ -495,7 +510,7 @@ bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window)
|
||||
#if !SDL_HAS_VULKAN
|
||||
IM_ASSERT(0 && "Unsupported");
|
||||
#endif
|
||||
return ImGui_ImplSDL2_Init(window, nullptr);
|
||||
return ImGui_ImplSDL2_Init(window, nullptr, nullptr);
|
||||
}
|
||||
|
||||
bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window)
|
||||
@ -503,22 +518,22 @@ bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window)
|
||||
#if !defined(_WIN32)
|
||||
IM_ASSERT(0 && "Unsupported");
|
||||
#endif
|
||||
return ImGui_ImplSDL2_Init(window, nullptr);
|
||||
return ImGui_ImplSDL2_Init(window, nullptr, nullptr);
|
||||
}
|
||||
|
||||
bool ImGui_ImplSDL2_InitForMetal(SDL_Window* window)
|
||||
{
|
||||
return ImGui_ImplSDL2_Init(window, nullptr);
|
||||
return ImGui_ImplSDL2_Init(window, nullptr, nullptr);
|
||||
}
|
||||
|
||||
bool ImGui_ImplSDL2_InitForSDLRenderer(SDL_Window* window, SDL_Renderer* renderer)
|
||||
{
|
||||
return ImGui_ImplSDL2_Init(window, renderer);
|
||||
return ImGui_ImplSDL2_Init(window, renderer, nullptr);
|
||||
}
|
||||
|
||||
bool ImGui_ImplSDL2_InitForOther(SDL_Window* window)
|
||||
{
|
||||
return ImGui_ImplSDL2_Init(window, nullptr);
|
||||
return ImGui_ImplSDL2_Init(window, nullptr, nullptr);
|
||||
}
|
||||
|
||||
static void ImGui_ImplSDL2_CloseGamepads();
|
||||
|
161
external/imgui/imgui/backends/imgui_impl_sdl3.cpp
vendored
161
external/imgui/imgui/backends/imgui_impl_sdl3.cpp
vendored
@ -1,7 +1,8 @@
|
||||
// dear imgui: Platform Backend for SDL3 (*EXPERIMENTAL*)
|
||||
// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
|
||||
// (Info: SDL3 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.)
|
||||
// (IMPORTANT: SDL 3.0.0 is NOT YET RELEASED. IT IS POSSIBLE THAT ITS SPECS/API WILL CHANGE BEFORE RELEASE)
|
||||
|
||||
// (**IMPORTANT: SDL 3.0.0 is NOT YET RELEASED AND CURRENTLY HAS A FAST CHANGING API. THIS CODE BREAKS OFTEN**)
|
||||
|
||||
// Implemented features:
|
||||
// [X] Platform: Clipboard support.
|
||||
@ -9,8 +10,6 @@
|
||||
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||
// 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()!.
|
||||
|
||||
// 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.
|
||||
@ -22,6 +21,12 @@
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2024-07-02: Update for SDL3 api changes: SDLK_x renames and SDLK_KP_x removals (#7761, #7762).
|
||||
// 2024-07-01: Update for SDL3 api changes: SDL_SetTextInputRect() changed to SDL_SetTextInputArea().
|
||||
// 2024-06-26: Update for SDL3 api changes: SDL_StartTextInput()/SDL_StopTextInput()/SDL_SetTextInputRect() functions signatures.
|
||||
// 2024-06-24: Update for SDL3 api changes: SDL_EVENT_KEY_DOWN/SDL_EVENT_KEY_UP contents.
|
||||
// 2024-06-03; Update for SDL3 api changes: SDL_SYSTEM_CURSOR_ renames.
|
||||
// 2024-05-15: Update for SDL3 api changes: SDLK_ renames.
|
||||
// 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.
|
||||
@ -76,6 +81,9 @@ struct ImGui_ImplSDL3_Data
|
||||
Uint64 Time;
|
||||
char* ClipboardTextData;
|
||||
|
||||
// IME handling
|
||||
SDL_Window* ImeWindow;
|
||||
|
||||
// Mouse handling
|
||||
Uint32 MouseWindowID;
|
||||
int MouseButtonsDown;
|
||||
@ -116,8 +124,15 @@ static void ImGui_ImplSDL3_SetClipboardText(void*, const char* text)
|
||||
SDL_SetClipboardText(text);
|
||||
}
|
||||
|
||||
static void ImGui_ImplSDL3_SetPlatformImeData(ImGuiViewport*, ImGuiPlatformImeData* data)
|
||||
static void ImGui_ImplSDL3_PlatformSetImeData(ImGuiContext*, ImGuiViewport* viewport, ImGuiPlatformImeData* data)
|
||||
{
|
||||
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
||||
SDL_Window* window = (SDL_Window*)viewport->PlatformHandle;
|
||||
if ((data->WantVisible == false || bd->ImeWindow != window) && bd->ImeWindow != NULL)
|
||||
{
|
||||
SDL_StopTextInput(bd->ImeWindow);
|
||||
bd->ImeWindow = nullptr;
|
||||
}
|
||||
if (data->WantVisible)
|
||||
{
|
||||
SDL_Rect r;
|
||||
@ -125,17 +140,36 @@ static void ImGui_ImplSDL3_SetPlatformImeData(ImGuiViewport*, ImGuiPlatformImeDa
|
||||
r.y = (int)data->InputPos.y;
|
||||
r.w = 1;
|
||||
r.h = (int)data->InputLineHeight;
|
||||
SDL_SetTextInputRect(&r);
|
||||
SDL_StartTextInput();
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_StopTextInput();
|
||||
SDL_SetTextInputArea(window, &r, 0);
|
||||
SDL_StartTextInput(window);
|
||||
bd->ImeWindow = window;
|
||||
}
|
||||
}
|
||||
|
||||
static ImGuiKey ImGui_ImplSDL3_KeycodeToImGuiKey(int keycode)
|
||||
static ImGuiKey ImGui_ImplSDL3_KeyEventToImGuiKey(SDL_Keycode keycode, SDL_Scancode scancode)
|
||||
{
|
||||
// Keypad doesn't have individual key values in SDL3
|
||||
switch (scancode)
|
||||
{
|
||||
case SDL_SCANCODE_KP_0: return ImGuiKey_Keypad0;
|
||||
case SDL_SCANCODE_KP_1: return ImGuiKey_Keypad1;
|
||||
case SDL_SCANCODE_KP_2: return ImGuiKey_Keypad2;
|
||||
case SDL_SCANCODE_KP_3: return ImGuiKey_Keypad3;
|
||||
case SDL_SCANCODE_KP_4: return ImGuiKey_Keypad4;
|
||||
case SDL_SCANCODE_KP_5: return ImGuiKey_Keypad5;
|
||||
case SDL_SCANCODE_KP_6: return ImGuiKey_Keypad6;
|
||||
case SDL_SCANCODE_KP_7: return ImGuiKey_Keypad7;
|
||||
case SDL_SCANCODE_KP_8: return ImGuiKey_Keypad8;
|
||||
case SDL_SCANCODE_KP_9: return ImGuiKey_Keypad9;
|
||||
case SDL_SCANCODE_KP_PERIOD: return ImGuiKey_KeypadDecimal;
|
||||
case SDL_SCANCODE_KP_DIVIDE: return ImGuiKey_KeypadDivide;
|
||||
case SDL_SCANCODE_KP_MULTIPLY: return ImGuiKey_KeypadMultiply;
|
||||
case SDL_SCANCODE_KP_MINUS: return ImGuiKey_KeypadSubtract;
|
||||
case SDL_SCANCODE_KP_PLUS: return ImGuiKey_KeypadAdd;
|
||||
case SDL_SCANCODE_KP_ENTER: return ImGuiKey_KeypadEnter;
|
||||
case SDL_SCANCODE_KP_EQUALS: return ImGuiKey_KeypadEqual;
|
||||
default: break;
|
||||
}
|
||||
switch (keycode)
|
||||
{
|
||||
case SDLK_TAB: return ImGuiKey_Tab;
|
||||
@ -169,23 +203,6 @@ static ImGuiKey ImGui_ImplSDL3_KeycodeToImGuiKey(int keycode)
|
||||
case SDLK_NUMLOCKCLEAR: return ImGuiKey_NumLock;
|
||||
case SDLK_PRINTSCREEN: return ImGuiKey_PrintScreen;
|
||||
case SDLK_PAUSE: return ImGuiKey_Pause;
|
||||
case SDLK_KP_0: return ImGuiKey_Keypad0;
|
||||
case SDLK_KP_1: return ImGuiKey_Keypad1;
|
||||
case SDLK_KP_2: return ImGuiKey_Keypad2;
|
||||
case SDLK_KP_3: return ImGuiKey_Keypad3;
|
||||
case SDLK_KP_4: return ImGuiKey_Keypad4;
|
||||
case SDLK_KP_5: return ImGuiKey_Keypad5;
|
||||
case SDLK_KP_6: return ImGuiKey_Keypad6;
|
||||
case SDLK_KP_7: return ImGuiKey_Keypad7;
|
||||
case SDLK_KP_8: return ImGuiKey_Keypad8;
|
||||
case SDLK_KP_9: return ImGuiKey_Keypad9;
|
||||
case SDLK_KP_PERIOD: return ImGuiKey_KeypadDecimal;
|
||||
case SDLK_KP_DIVIDE: return ImGuiKey_KeypadDivide;
|
||||
case SDLK_KP_MULTIPLY: return ImGuiKey_KeypadMultiply;
|
||||
case SDLK_KP_MINUS: return ImGuiKey_KeypadSubtract;
|
||||
case SDLK_KP_PLUS: return ImGuiKey_KeypadAdd;
|
||||
case SDLK_KP_ENTER: return ImGuiKey_KeypadEnter;
|
||||
case SDLK_KP_EQUALS: return ImGuiKey_KeypadEqual;
|
||||
case SDLK_LCTRL: return ImGuiKey_LeftCtrl;
|
||||
case SDLK_LSHIFT: return ImGuiKey_LeftShift;
|
||||
case SDLK_LALT: return ImGuiKey_LeftAlt;
|
||||
@ -205,32 +222,32 @@ static ImGuiKey ImGui_ImplSDL3_KeycodeToImGuiKey(int keycode)
|
||||
case SDLK_7: return ImGuiKey_7;
|
||||
case SDLK_8: return ImGuiKey_8;
|
||||
case SDLK_9: return ImGuiKey_9;
|
||||
case SDLK_a: return ImGuiKey_A;
|
||||
case SDLK_b: return ImGuiKey_B;
|
||||
case SDLK_c: return ImGuiKey_C;
|
||||
case SDLK_d: return ImGuiKey_D;
|
||||
case SDLK_e: return ImGuiKey_E;
|
||||
case SDLK_f: return ImGuiKey_F;
|
||||
case SDLK_g: return ImGuiKey_G;
|
||||
case SDLK_h: return ImGuiKey_H;
|
||||
case SDLK_i: return ImGuiKey_I;
|
||||
case SDLK_j: return ImGuiKey_J;
|
||||
case SDLK_k: return ImGuiKey_K;
|
||||
case SDLK_l: return ImGuiKey_L;
|
||||
case SDLK_m: return ImGuiKey_M;
|
||||
case SDLK_n: return ImGuiKey_N;
|
||||
case SDLK_o: return ImGuiKey_O;
|
||||
case SDLK_p: return ImGuiKey_P;
|
||||
case SDLK_q: return ImGuiKey_Q;
|
||||
case SDLK_r: return ImGuiKey_R;
|
||||
case SDLK_s: return ImGuiKey_S;
|
||||
case SDLK_t: return ImGuiKey_T;
|
||||
case SDLK_u: return ImGuiKey_U;
|
||||
case SDLK_v: return ImGuiKey_V;
|
||||
case SDLK_w: return ImGuiKey_W;
|
||||
case SDLK_x: return ImGuiKey_X;
|
||||
case SDLK_y: return ImGuiKey_Y;
|
||||
case SDLK_z: return ImGuiKey_Z;
|
||||
case SDLK_A: return ImGuiKey_A;
|
||||
case SDLK_B: return ImGuiKey_B;
|
||||
case SDLK_C: return ImGuiKey_C;
|
||||
case SDLK_D: return ImGuiKey_D;
|
||||
case SDLK_E: return ImGuiKey_E;
|
||||
case SDLK_F: return ImGuiKey_F;
|
||||
case SDLK_G: return ImGuiKey_G;
|
||||
case SDLK_H: return ImGuiKey_H;
|
||||
case SDLK_I: return ImGuiKey_I;
|
||||
case SDLK_J: return ImGuiKey_J;
|
||||
case SDLK_K: return ImGuiKey_K;
|
||||
case SDLK_L: return ImGuiKey_L;
|
||||
case SDLK_M: return ImGuiKey_M;
|
||||
case SDLK_N: return ImGuiKey_N;
|
||||
case SDLK_O: return ImGuiKey_O;
|
||||
case SDLK_P: return ImGuiKey_P;
|
||||
case SDLK_Q: return ImGuiKey_Q;
|
||||
case SDLK_R: return ImGuiKey_R;
|
||||
case SDLK_S: return ImGuiKey_S;
|
||||
case SDLK_T: return ImGuiKey_T;
|
||||
case SDLK_U: return ImGuiKey_U;
|
||||
case SDLK_V: return ImGuiKey_V;
|
||||
case SDLK_W: return ImGuiKey_W;
|
||||
case SDLK_X: return ImGuiKey_X;
|
||||
case SDLK_Y: return ImGuiKey_Y;
|
||||
case SDLK_Z: return ImGuiKey_Z;
|
||||
case SDLK_F1: return ImGuiKey_F1;
|
||||
case SDLK_F2: return ImGuiKey_F2;
|
||||
case SDLK_F3: return ImGuiKey_F3;
|
||||
@ -257,6 +274,7 @@ static ImGuiKey ImGui_ImplSDL3_KeycodeToImGuiKey(int keycode)
|
||||
case SDLK_F24: return ImGuiKey_F24;
|
||||
case SDLK_AC_BACK: return ImGuiKey_AppBack;
|
||||
case SDLK_AC_FORWARD: return ImGuiKey_AppForward;
|
||||
default: break;
|
||||
}
|
||||
return ImGuiKey_None;
|
||||
}
|
||||
@ -326,10 +344,11 @@ bool ImGui_ImplSDL3_ProcessEvent(const SDL_Event* event)
|
||||
case SDL_EVENT_KEY_DOWN:
|
||||
case SDL_EVENT_KEY_UP:
|
||||
{
|
||||
ImGui_ImplSDL3_UpdateKeyModifiers((SDL_Keymod)event->key.keysym.mod);
|
||||
ImGuiKey key = ImGui_ImplSDL3_KeycodeToImGuiKey(event->key.keysym.sym);
|
||||
//IMGUI_DEBUG_LOG("SDL_EVENT_KEY_%d: key=%d, scancode=%d, mod=%X\n", (event->type == SDL_EVENT_KEY_DOWN) ? "DOWN" : "UP", event->key.key, event->key.scancode, event->key.mod);
|
||||
ImGui_ImplSDL3_UpdateKeyModifiers((SDL_Keymod)event->key.mod);
|
||||
ImGuiKey key = ImGui_ImplSDL3_KeyEventToImGuiKey(event->key.key, event->key.scancode);
|
||||
io.AddKeyEvent(key, (event->type == SDL_EVENT_KEY_DOWN));
|
||||
io.SetKeyEventNativeData(key, event->key.keysym.sym, event->key.keysym.scancode, event->key.keysym.scancode); // To support legacy indexing (<1.87 user code). Legacy backend uses SDLK_*** as indices to IsKeyXXX() functions.
|
||||
io.SetKeyEventNativeData(key, event->key.key, event->key.scancode, event->key.scancode); // To support legacy indexing (<1.87 user code). Legacy backend uses SDLK_*** as indices to IsKeyXXX() functions.
|
||||
return true;
|
||||
}
|
||||
case SDL_EVENT_WINDOW_MOUSE_ENTER:
|
||||
@ -365,12 +384,12 @@ bool ImGui_ImplSDL3_ProcessEvent(const SDL_Event* event)
|
||||
|
||||
static void ImGui_ImplSDL3_SetupPlatformHandles(ImGuiViewport* viewport, SDL_Window* window)
|
||||
{
|
||||
IM_UNUSED(window);
|
||||
viewport->PlatformHandle = window;
|
||||
viewport->PlatformHandleRaw = nullptr;
|
||||
#if defined(__WIN32__) && !defined(__WINRT__)
|
||||
viewport->PlatformHandleRaw = (HWND)SDL_GetProperty(SDL_GetWindowProperties(window), "SDL.window.win32.hwnd", nullptr);
|
||||
#if defined(_WIN32) && !defined(__WINRT__)
|
||||
viewport->PlatformHandleRaw = (HWND)SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WIN32_HWND_POINTER, nullptr);
|
||||
#elif defined(__APPLE__) && defined(SDL_VIDEO_DRIVER_COCOA)
|
||||
viewport->PlatformHandleRaw = (void*)SDL_GetProperty(SDL_GetWindowProperties(window), "SDL.window.cocoa.window", nullptr);
|
||||
viewport->PlatformHandleRaw = SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_COCOA_WINDOW_POINTER, nullptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -406,22 +425,22 @@ static bool ImGui_ImplSDL3_Init(SDL_Window* window, SDL_Renderer* renderer, void
|
||||
io.SetClipboardTextFn = ImGui_ImplSDL3_SetClipboardText;
|
||||
io.GetClipboardTextFn = ImGui_ImplSDL3_GetClipboardText;
|
||||
io.ClipboardUserData = nullptr;
|
||||
io.SetPlatformImeDataFn = ImGui_ImplSDL3_SetPlatformImeData;
|
||||
io.PlatformSetImeDataFn = ImGui_ImplSDL3_PlatformSetImeData;
|
||||
|
||||
// Gamepad handling
|
||||
bd->GamepadMode = ImGui_ImplSDL3_GamepadMode_AutoFirst;
|
||||
bd->WantUpdateGamepadsList = true;
|
||||
|
||||
// Load mouse cursors
|
||||
bd->MouseCursors[ImGuiMouseCursor_Arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
|
||||
bd->MouseCursors[ImGuiMouseCursor_TextInput] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
|
||||
bd->MouseCursors[ImGuiMouseCursor_ResizeAll] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL);
|
||||
bd->MouseCursors[ImGuiMouseCursor_ResizeNS] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENS);
|
||||
bd->MouseCursors[ImGuiMouseCursor_ResizeEW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEWE);
|
||||
bd->MouseCursors[ImGuiMouseCursor_ResizeNESW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENESW);
|
||||
bd->MouseCursors[ImGuiMouseCursor_ResizeNWSE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENWSE);
|
||||
bd->MouseCursors[ImGuiMouseCursor_Hand] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND);
|
||||
bd->MouseCursors[ImGuiMouseCursor_NotAllowed] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NO);
|
||||
bd->MouseCursors[ImGuiMouseCursor_Arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_DEFAULT);
|
||||
bd->MouseCursors[ImGuiMouseCursor_TextInput] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_TEXT);
|
||||
bd->MouseCursors[ImGuiMouseCursor_ResizeAll] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_MOVE);
|
||||
bd->MouseCursors[ImGuiMouseCursor_ResizeNS] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NS_RESIZE);
|
||||
bd->MouseCursors[ImGuiMouseCursor_ResizeEW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_EW_RESIZE);
|
||||
bd->MouseCursors[ImGuiMouseCursor_ResizeNESW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NESW_RESIZE);
|
||||
bd->MouseCursors[ImGuiMouseCursor_ResizeNWSE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NWSE_RESIZE);
|
||||
bd->MouseCursors[ImGuiMouseCursor_Hand] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_POINTER);
|
||||
bd->MouseCursors[ImGuiMouseCursor_NotAllowed] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NOT_ALLOWED);
|
||||
|
||||
// Set platform dependent data in viewport
|
||||
// Our mouse update function expect PlatformHandle to be filled for the main viewport
|
||||
|
@ -1,7 +1,8 @@
|
||||
// dear imgui: Platform Backend for SDL3 (*EXPERIMENTAL*)
|
||||
// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
|
||||
// (Info: SDL3 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.)
|
||||
// (IMPORTANT: SDL 3.0.0 is NOT YET RELEASED. IT IS POSSIBLE THAT ITS SPECS/API WILL CHANGE BEFORE RELEASE)
|
||||
|
||||
// (**IMPORTANT: SDL 3.0.0 is NOT YET RELEASED AND CURRENTLY HAS A FAST CHANGING API. THIS CODE BREAKS OFTEN**)
|
||||
|
||||
// Implemented features:
|
||||
// [X] Platform: Clipboard support.
|
||||
@ -9,8 +10,6 @@
|
||||
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy SDL_SCANCODE_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
|
||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||
// 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()!.
|
||||
|
||||
// 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.
|
||||
|
@ -20,6 +20,7 @@
|
||||
// - Introduction, links and more at the top of imgui.cpp
|
||||
|
||||
// CHANGELOG
|
||||
// 2024-07-01: Update for SDL3 api changes: SDL_RenderGeometryRaw() uint32 version was removed (SDL#9009).
|
||||
// 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.
|
||||
@ -44,8 +45,10 @@
|
||||
// SDL_Renderer data
|
||||
struct ImGui_ImplSDLRenderer3_Data
|
||||
{
|
||||
SDL_Renderer* Renderer; // Main viewport's renderer
|
||||
SDL_Texture* FontTexture;
|
||||
SDL_Renderer* Renderer; // Main viewport's renderer
|
||||
SDL_Texture* FontTexture;
|
||||
ImVector<SDL_FColor> ColorBuffer;
|
||||
|
||||
ImGui_ImplSDLRenderer3_Data() { memset((void*)this, 0, sizeof(*this)); }
|
||||
};
|
||||
|
||||
@ -106,8 +109,28 @@ void ImGui_ImplSDLRenderer3_NewFrame()
|
||||
ImGui_ImplSDLRenderer3_CreateDeviceObjects();
|
||||
}
|
||||
|
||||
// https://github.com/libsdl-org/SDL/issues/9009
|
||||
static int SDL_RenderGeometryRaw8BitColor(SDL_Renderer* renderer, ImVector<SDL_FColor>& colors_out, SDL_Texture* texture, const float* xy, int xy_stride, const SDL_Color* color, int color_stride, const float* uv, int uv_stride, int num_vertices, const void* indices, int num_indices, int size_indices)
|
||||
{
|
||||
const Uint8* color2 = (const Uint8*)color;
|
||||
colors_out.resize(num_vertices);
|
||||
SDL_FColor* color3 = colors_out.Data;
|
||||
for (int i = 0; i < num_vertices; i++)
|
||||
{
|
||||
color3[i].r = color->r / 255.0f;
|
||||
color3[i].g = color->g / 255.0f;
|
||||
color3[i].b = color->b / 255.0f;
|
||||
color3[i].a = color->a / 255.0f;
|
||||
color2 += color_stride;
|
||||
color = (const SDL_Color*)color2;
|
||||
}
|
||||
return SDL_RenderGeometryRaw(renderer, texture, xy, xy_stride, color3, sizeof(*color3), uv, uv_stride, num_vertices, indices, num_indices, size_indices);
|
||||
}
|
||||
|
||||
void ImGui_ImplSDLRenderer3_RenderDrawData(ImDrawData* draw_data, SDL_Renderer* renderer)
|
||||
{
|
||||
ImGui_ImplSDLRenderer3_Data* bd = ImGui_ImplSDLRenderer3_GetBackendData();
|
||||
|
||||
// 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
|
||||
// to SDL_RenderGeometryRaw() by that scale factor. In that case we don't want to be also scaling it ourselves here.
|
||||
@ -183,7 +206,7 @@ void ImGui_ImplSDLRenderer3_RenderDrawData(ImDrawData* draw_data, SDL_Renderer*
|
||||
|
||||
// Bind texture, Draw
|
||||
SDL_Texture* tex = (SDL_Texture*)pcmd->GetTexID();
|
||||
SDL_RenderGeometryRaw(renderer, tex,
|
||||
SDL_RenderGeometryRaw8BitColor(renderer, bd->ColorBuffer, tex,
|
||||
xy, (int)sizeof(ImDrawVert),
|
||||
color, (int)sizeof(ImDrawVert),
|
||||
uv, (int)sizeof(ImDrawVert),
|
||||
|
@ -55,7 +55,7 @@
|
||||
|
||||
// Vulkan includes
|
||||
#ifdef IMGUI_IMPL_VULKAN_USE_VOLK
|
||||
#include <Volk/volk.h>
|
||||
#include <volk.h>
|
||||
#else
|
||||
#include <vulkan/vulkan.h>
|
||||
#endif
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2024-07-08: Inputs: Fixed ImGuiMod_Super being mapped to VK_APPS instead of VK_LWIN||VK_RWIN. (#7768)
|
||||
// 2023-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F24 function keys, app back/forward keys.
|
||||
// 2023-09-25: Inputs: Synthesize key-down event on key-up for VK_SNAPSHOT / ImGuiKey_PrintScreen as Windows doesn't emit it (same behavior as GLFW/SDL).
|
||||
// 2023-09-07: Inputs: Added support for keyboard codepage conversion for when application is compiled in MBCS mode and using a non-Unicode window.
|
||||
@ -98,6 +99,7 @@ typedef DWORD(WINAPI* PFN_XInputGetState)(DWORD, XINPUT_STATE*);
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
||||
#pragma GCC diagnostic ignored "-Wcast-function-type" // warning: cast between incompatible function types (for loader)
|
||||
#endif
|
||||
|
||||
@ -169,7 +171,8 @@ static bool ImGui_ImplWin32_InitEx(void* hwnd, bool platform_has_own_dc)
|
||||
ImGui_ImplWin32_UpdateKeyboardCodePage();
|
||||
|
||||
// Set platform dependent data in viewport
|
||||
ImGui::GetMainViewport()->PlatformHandleRaw = (void*)hwnd;
|
||||
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||
main_viewport->PlatformHandle = main_viewport->PlatformHandleRaw = (void*)bd->hWnd;
|
||||
IM_UNUSED(platform_has_own_dc); // Used in 'docking' branch
|
||||
|
||||
// Dynamically load XInput library
|
||||
@ -292,7 +295,7 @@ static void ImGui_ImplWin32_UpdateKeyModifiers()
|
||||
io.AddKeyEvent(ImGuiMod_Ctrl, IsVkDown(VK_CONTROL));
|
||||
io.AddKeyEvent(ImGuiMod_Shift, IsVkDown(VK_SHIFT));
|
||||
io.AddKeyEvent(ImGuiMod_Alt, IsVkDown(VK_MENU));
|
||||
io.AddKeyEvent(ImGuiMod_Super, IsVkDown(VK_APPS));
|
||||
io.AddKeyEvent(ImGuiMod_Super, IsVkDown(VK_LWIN) || IsVkDown(VK_RWIN));
|
||||
}
|
||||
|
||||
static void ImGui_ImplWin32_UpdateMouseData()
|
||||
|
198
external/imgui/imgui/docs/CHANGELOG.txt
vendored
198
external/imgui/imgui/docs/CHANGELOG.txt
vendored
@ -35,6 +35,198 @@ 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.
|
||||
- Please report any issue!
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
VERSION 1.91.0 WIP (In Progress)
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
Breaking changes:
|
||||
|
||||
- IO, IME: renamed platform IME hook and added explicit context for consistency and future-proofness.
|
||||
- old: io.SetPlatformImeDataFn(ImGuiViewport* viewport, ImGuiPlatformImeData* data);
|
||||
- new: io.PlatformSetImeDataFn(ImGuiContext* ctx, ImGuiViewport* viewport, ImGuiPlatformImeData* data);
|
||||
It is expected that for a vast majority of users this is automatically set by core
|
||||
library and/or platform backend so it won't have any effect.
|
||||
- Item flag changes:
|
||||
- Obsoleted PushButtonRepeat()/PopButtonRepeat() in favor of using new PushItemFlag()/PopItemFlag()
|
||||
with ImGuiItemFlags_ButtonRepeat. Kept inline redirecting functions (will obsolete).
|
||||
- Obsoleted PushTabStop()/PopTabStop() in favor of using new PushItemFlag()/PopItemFlag()
|
||||
with ImGuiItemFlags_NoTabStop. Kept inline redirecting functions (will obsolete).
|
||||
- Renamed ImGuiSelectableFlags_DontClosePopups to ImGuiSelectableFlags_NoAutoClosePopups for
|
||||
consistency. Kept inline redirecting functions (will obsolete).
|
||||
+ Internals: changed/inverted ImGuiItemFlags_SelectableDontClosePopup (default==false) to
|
||||
ImGuiItemFlags_AutoClosePopups (default==true), same logic, only inverted behavior.
|
||||
(#1379, #1468, #2200, #4936, #5216, #7302, #7573)
|
||||
- Commented out obsolete ImGuiModFlags (renamed to ImGuiKeyChord in 1.89). (#4921, #456)
|
||||
- Commented out obsolete ImGuiModFlags_XXX values (renamed to ImGuiMod_XXX in 1.89). (#4921, #456)
|
||||
- ImGuiModFlags_Ctrl -> ImGuiMod_Ctrl, ImGuiModFlags_Shift -> ImGuiMod_Shift etc.
|
||||
- Backends: GLFW+Emscripten: Renamed ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback() to
|
||||
ImGui_ImplGlfw_InstallEmscriptenCallbacks(), with additional GLFWWindow* parameter. (#7647) [@ypujante]
|
||||
|
||||
Other changes:
|
||||
|
||||
- Added TextLink(), TextLinkOpenURL() hyperlink widgets. (#7660)
|
||||
- IO: added io.PlatformOpenInShellFn handler to open a link/folder/file in OS shell. (#7660)
|
||||
Default to use ShellExecute() under Windows, and system("") under Mac/Linux/etc.
|
||||
Added IMGUI_DISABLE_DEFAULT_SHELL_FUNCTIONS to disable default implementation.
|
||||
- Added PushItemFlag()/PopItemFlags(), ImGuiItemFlags to modify shared item flags:
|
||||
- Added ImGuiItemFlags_NoTabStop to disable tabbing through items.
|
||||
- Added ImGuiItemFlags_NoNav to disable any navigation and focus of items. (#787)
|
||||
- Added ImGuiItemFlags_NoNavDefaultFocus to disable item being default focus. (#787)
|
||||
- Added ImGuiItemFlags_ButtonRepeat to enable repeat on any button-like behavior.
|
||||
- Added ImGuiItemFlags_AutoClosePopups to disable menu items/selection auto closing parent popups.
|
||||
Disabling this was previously possible for Selectable() via a direct flag but not for MenuItem().
|
||||
(#1379, #1468, #2200, #4936, #5216, #7302, #7573)
|
||||
- This was mostly all previously in imgui_internal.h.
|
||||
- Clipper: added SeekCursorForItem() function. When using ImGuiListClipper::Begin(INT_MAX) you can
|
||||
can use the clipper without knowing the amount of items beforehand. (#1311)
|
||||
In this situation, call ImGuiListClipper::SeekCursorForItem(items_count) as the end of your iteration
|
||||
loop to position the layout cursor correctly. This is done automatically if provided a count to Begin().
|
||||
- Style: close button and collapse/window-menu button hover highlight made rectangular instead of round.
|
||||
- Debug Tools: Added IMGUI_DEBUG_LOG(), ImGui::DebugLog() in public API. (#5855)
|
||||
Debug log entries add a imgui frame counter prefix + are redirected to ShowDebugLogWindow() and
|
||||
other configurable locations. Always call IMGUI_DEBUG_LOG() for maximum stripping in caller code.
|
||||
- Debug Tools: Debug Log: Added "Configure Outputs.." button. (#5855)
|
||||
- Demo: Reworked "Property Editor" demo in a manner that more ressemble the tree data and
|
||||
struct description data that a real application would want to use.
|
||||
- Backends: Win32: Fixed ImGuiMod_Super being mapped to VK_APPS instead of VK_LWIN||VK_RWIN.
|
||||
(#7768, #4858, #2622) [@Aemony]
|
||||
- Backends: SDL3: Update for API changes: SDLK_x renames and SDLK_KP_x removals (#7761, #7762)
|
||||
- Backends: SDL3: Update for API changes: SDL_GetProperty() change to SDL_GetPointerProperty(). (#7794) [@wermipls]
|
||||
- Backends: SDL2,SDL3,OSX: Update for io.SetPlatformImeDataFn() -> io.PlatformSetImeDataFn() rename.
|
||||
- Backends: GLFW,SDL2: Added io.PlatformOpenInShellFn handler for web/Emscripten versions. (#7660)
|
||||
[@ypujante, @ocornut]
|
||||
- Backends; GLFW+Emscripten: Added support for GLFW3 contrib port which fixes many of the things
|
||||
not supported by the embedded GLFW: gamepad support, mouse cursor shapes, copy to clipboard,
|
||||
workaround for Super/Meta key, different ways of resizing, multi-window (glfw/canvas) support.
|
||||
(#7647) [@ypujante]
|
||||
- Backends: GLFW+Emscripten: Fixed Emscripten warning when using mouse wheel on some setups
|
||||
"Unable to preventDefault inside passive event listener". (#7647, #7600) [@ypujante]
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
VERSION 1.90.9 (Released 2024-07-01)
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.90.9
|
||||
|
||||
Breaking changes:
|
||||
|
||||
- Removed old nested structure: renaming ImGuiStorage::ImGuiStoragePair type to
|
||||
ImGuiStoragePair (simpler for many languages). No significant nested type left.
|
||||
- BeginChild: added ImGuiChildFlags_NavFlattened as a replacement for the window
|
||||
flag ImGuiWindowFlags_NavFlattened: the feature only ever made sense for
|
||||
BeginChild() calls anyhow. (#7687) [@cfillion]
|
||||
- old: BeginChild("Name", size, 0, ImGuiWindowFlags_NavFlattened);
|
||||
- new: BeginChild("Name", size, ImGuiChildFlags_NavFlattened, 0)
|
||||
Kept inline redirection flag (will obsolete).
|
||||
- Style: renamed tab colors for clarity and consistency with other changes: (#261, #351)
|
||||
- ImGuiCol_TabActive -> ImGuiCol_TabSelected
|
||||
- ImGuiCol_TabUnfocused -> ImGuiCol_TabDimmed
|
||||
- ImGuiCol_TabUnfocusedActive -> ImGuiCol_TabDimmedSelected
|
||||
Kept inline redirecting enums (will obsolete).
|
||||
- IO: io.ClearInputKeys() (first exposed in 1.89.8) doesn't clear mouse data.
|
||||
Newly added io.ClearInputMouse() does. (#4921)
|
||||
- Drag and Drop: renamed ImGuiDragDropFlags_SourceAutoExpirePayload to
|
||||
ImGuiDragDropFlags_PayloadAutoExpire. Kept inline redirecting enum (will obsolete). (#1725, #143)
|
||||
|
||||
Other changes:
|
||||
|
||||
- IO: do not disable io.ConfigWindowsResizeFromEdges (which allow resizing from borders
|
||||
and lower-left corner) when ImGuiBackendFlags_HasMouseCursors is not set by backend.
|
||||
The initial reasoning is that resizing from borders feels better when correct mouse cursor
|
||||
shape change as honored by backends. Keeping this enabling will hopefully increase pressure
|
||||
on third-party backends to set ImGuiBackendFlags_HasMouseCursors and honor changes of
|
||||
ImGui::GetMouseCursor() value. (#1495)
|
||||
- IO: do not claim io.WantCaptureMouse=true on the mouse release frame of a button
|
||||
which was pressed over void/underlying app, which is consistent/needed to allow the
|
||||
mouse up event of a drag over void/underlying app to catch release. (#1392) [@Moka42]
|
||||
- IO: Added io.ClearInputMouse() to clear mouse state. (#4921)
|
||||
- Windows: BeginChild(): fixed a glitch when during a resize of a child window which is
|
||||
tightly close to the boundaries of its parent (e.g. with zero WindowPadding), the child
|
||||
position could have temporarily be moved around by erroneous padding application. (#7706)
|
||||
- TabBar, Style: added ImGuiTabBarFlags_DrawSelectedOverline option to draw an horizontal
|
||||
line over selected tabs to increase visibility. This is used by docking.
|
||||
Added corresponding ImGuiCol_TabSelectedOverline and ImGuiCol_TabDimmedSelectedOverline colors.
|
||||
- Tables: added TableGetHoveredColumn() to public API, as an alternative to testing for
|
||||
'TableGetColumnFlags(column) & ImGuiTableColumnFlags_IsHovered' on each column. (#3740)
|
||||
- Disabled, Inputs: fixed using Shortcut() or SetNextItemShortcut() within a disabled block
|
||||
bypassing the disabled state. (#7726)
|
||||
- Disabled: Reworked 1.90.8 behavior of Begin() not inheriting current BeginDisabled() state,
|
||||
to make it that only tooltip windows are temporarily clearing it. (#211, #7640)
|
||||
- Drags: added ImGuiSliderFlags_WrapAround flag for DragInt(), DragFloat() etc. (#7749)
|
||||
- Drag and Drop: BeginDragDropSource() with ImGuiDragDropFlags_SourceExtern sets
|
||||
active id so a multi-frame extern source doesn't interfere with hovered widgets. (#143)
|
||||
- Drag and Drop: BeginDragDropSource() with ImGuiDragDropFlags_SourceExtern does not assume
|
||||
a mouse button being pressed. Facilitate implementing cross-context drag and drop. (#143)
|
||||
- Drag and Drop: Added ImGuiDragDropFlags_PayloadNoCrossContext/_PayloadNoCrossProcess flags
|
||||
as metadata to specify that a payload may not be copied outside the context/process by
|
||||
some logic aiming to copy payloads around.
|
||||
- Drag and Drop: Fixes an issue when elapsing payload would be based on last payload
|
||||
frame instead of last drag source frame, which makes a difference if not resubmitting
|
||||
payload every frame. (#143)
|
||||
- Debug Tools: Metrics/Debugger: Browsing a Storage perform hover lookup on identifier.
|
||||
- Viewports: Backported 'void* ImGuiViewport::PlatformHandle' from docking branch for
|
||||
use by backends.
|
||||
- imgui_freetype: Fixed divide by zero while handling FT_PIXEL_MODE_BGRA glyphs. (#7267, #3369)
|
||||
- Backends: OpenGL2, OpenGL3: ImGui_ImplOpenGL3_NewFrame() recreates font texture if it
|
||||
has been destroyed by ImGui_ImplOpenGL3_DestroyFontsTexture(). (#7748) [@mlauss2]
|
||||
- Backends: SDL3: Update for API removal of keysym field in SDL_KeyboardEvent. (#7728)
|
||||
- Backends: SDL3: Update for SDL_StartTextInput()/SDL_StopTextInput() API changes. (#7735)
|
||||
- Backends: SDL3: Update for SDL_SetTextInputRect() API rename. (#7760, #7754) [@maxortner01]
|
||||
- Backends: SDLRenderer3: Update for SDL_RenderGeometryRaw() API changes. (SDL#9009).
|
||||
- Backends: Vulkan: Remove Volk/ from volk.h #include directives. (#7722, #6582, #4854)
|
||||
[@martin-ejdestig]
|
||||
- Examples: SDL3: Remove use of SDL_HINT_IME_NATIVE_UI since new SDL_HINT_IME_IMPLEMENTED_UI
|
||||
values has a more suitable default for our case case.
|
||||
- Examples: GLFW+Vulkan, SDL+Vulkan: handle swap chain resize even without Vulkan
|
||||
returning VK_SUBOPTIMAL_KHR, which doesn't seem to happen on Wayland. (#7671)
|
||||
[@AndreiNego, @ocornut]
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
VERSION 1.90.8 (Released 2024-06-06)
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
Decorated log and release notes: https://github.com/ocornut/imgui/releases/tag/v1.90.8
|
||||
|
||||
Breaking changes:
|
||||
|
||||
- Reordered various ImGuiInputTextFlags values. This should NOT be breaking unless
|
||||
you are using generated headers that have values not matching the main library.
|
||||
- Removed ImGuiButtonFlags_MouseButtonDefault_ = ImGuiButtonFlags_MouseButtonLeft
|
||||
from imgui.h, was mostly unused and misleading.
|
||||
|
||||
Other changes:
|
||||
|
||||
- Inputs: fixed IsMouseClicked(..., repeat=true); broken in 1.90.7 on 2024/05/22.
|
||||
(due to an internal api parameter swap, repeat wouldn't be honored and
|
||||
ownership would be accidentally checked even though this api is meant to not
|
||||
check ownership). (#7657) [@korenkonder]
|
||||
- Windows: fixed altering FramePadding mid-frame not correctly affecting logic
|
||||
responsible for honoring io.ConfigWindowsMoveFromTitleBarOnly. (#7576, #899)
|
||||
- Scrollbar: made scrolling logic more standard: clicking above or below the
|
||||
grab scrolls by one page, holding mouse button repeats scrolling. (#7328, #150)
|
||||
- Scrollbar: fixed miscalculation of vertical scrollbar visibility when required
|
||||
solely by the presence of an horizontal scrollbar. (#1574)
|
||||
- InputScalar, InputInt, InputFloat: added ImGuiInputTextFlags_ParseEmptyRefVal
|
||||
to parse an empty field as zero-value. (#7305) [@supermerill, @ocornut]
|
||||
- InputScalar, InputInt, InputFloat: added ImGuiInputTextFlags_DisplayEmptyRefVal
|
||||
to display a zero-value as empty. (#7305) [@supermerill, @ocornut]
|
||||
- Popups: fixed an issue preventing to close a popup opened over a modal by clicking
|
||||
over void (it required clicking over the visible part of the modal). (#7654)
|
||||
- Tables: fixed an issue where ideal size reported to parent container wouldn't
|
||||
correctly take account of inner scrollbar, affecting potential auto-resize of
|
||||
parent container. (#7651)
|
||||
- Tables: fixed a bug where after disabling the ScrollY flag for a table,
|
||||
previous scrollbar width would be accounted for. (#5920)
|
||||
- Combo: simplified Combo() API uses a list clipper (due to its api it wasn't
|
||||
previously trivial before we added clipper.IncludeItemByIndex() function).
|
||||
- Disabled: nested tooltips or other non-child window within a BeginDisabled()
|
||||
block disable the disabled state. (#211, #7640)
|
||||
- Misc: made ImGuiDir and ImGuiSortDirection stronger-typed enums.
|
||||
- Backends: SDL3: Update for SDL_SYSTEM_CURSOR_xxx api renames. (#7653)
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
VERSION 1.90.7 (Released 2024-05-27)
|
||||
-----------------------------------------------------------------------
|
||||
@ -756,7 +948,7 @@ Breaking changes:
|
||||
|
||||
- IO: Obsoleted io.ClearInputCharacters() (added in 1.47) as it now ambiguous
|
||||
and often incorrect/misleading considering the existence of a higher-level
|
||||
input queue. This is automatically cleared by io.ClearInputsKeys(). (#4921)
|
||||
input queue. This is automatically cleared by io.ClearInputKeys(). (#4921)
|
||||
- ImDrawData: CmdLists[] array is now owned, changed from 'ImDrawList**' to
|
||||
'ImVector<ImDrawList*>'. Majority of users shouldn't be affected, but you
|
||||
cannot compare to NULL nor reassign manually anymore.
|
||||
@ -794,10 +986,10 @@ Other changes:
|
||||
will slightly reduce scrollbar size. Generally we tried to make it that window
|
||||
border size has no incidence on layout but this can't work with thick borders. (#2522)
|
||||
- IO: Added io.ClearEventsQueue() to clear incoming inputs events. (#4921)
|
||||
May be useful in conjunction with io.ClearInputsKeys() if you need to clear
|
||||
May be useful in conjunction with io.ClearInputKeys() if you need to clear
|
||||
both current inputs state and queued events (e.g. when using blocking native
|
||||
dialogs such as Windows's ::MessageBox() or ::GetOpenFileName()).
|
||||
- IO: Changed io.ClearInputsKeys() specs to also clear current frame character buffer
|
||||
- IO: Changed io.ClearInputKeys() specs to also clear current frame character buffer
|
||||
(what now obsoleted io.ClearInputCharacters() did), as this is effectively the
|
||||
desirable behavior.
|
||||
- Misc: Added IMGUI_DISABLE_STB_SPRINTF_IMPLEMENTATION config macro to disable
|
||||
|
2
external/imgui/imgui/docs/FAQ.md
vendored
2
external/imgui/imgui/docs/FAQ.md
vendored
@ -639,7 +639,7 @@ The applications in examples/ are doing that.
|
||||
Windows: you can use the WM_CHAR or WM_UNICHAR or WM_IME_CHAR message (depending if your app is built using Unicode or MultiByte mode).
|
||||
You may also use `MultiByteToWideChar()` or `ToUnicode()` to retrieve Unicode codepoints from MultiByte characters or keyboard state.
|
||||
Windows: if your language is relying on an Input Method Editor (IME), you can write your HWND to ImGui::GetMainViewport()->PlatformHandleRaw
|
||||
for the default implementation of io.SetPlatformImeDataFn() to set your Microsoft IME position correctly.
|
||||
for the default implementation of io.PlatformSetImeDataFn() to set your Microsoft IME position correctly.
|
||||
|
||||
##### [Return to Index](#index)
|
||||
|
||||
|
2
external/imgui/imgui/docs/README.md
vendored
2
external/imgui/imgui/docs/README.md
vendored
@ -162,7 +162,7 @@ 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.
|
||||
|
||||
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/)).
|
||||
For the purposes of getting search engines to crawl the wiki, here's a link to the [Crawlable 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.
|
||||
|
||||
|
16
external/imgui/imgui/docs/TODO.txt
vendored
16
external/imgui/imgui/docs/TODO.txt
vendored
@ -39,7 +39,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
||||
- scrolling: forward mouse wheel scrolling to parent window when at the edge of scrolling limits? (useful for listbox,tables?)
|
||||
- scrolling/style: shadows on scrollable areas to denote that there is more contents (see e.g. DaVinci Resolve ui)
|
||||
|
||||
- drawdata: make it easy to deep-copy (or swap?) a full ImDrawData so user can easily save that data if they use threaded rendering. (e.g. #2646)
|
||||
- drawdata: make it easy to deep-copy (or swap?) a full ImDrawData so user can easily save that data if they use threaded rendering. (#1860 see ImDrawDataSnapshot)
|
||||
! drawlist: add CalcTextSize() func to facilitate consistent code from user pov (currently need to use ImGui or ImFont alternatives!)
|
||||
- drawlist: maintaining bounding box per command would allow to merge draw command when clipping isn't relied on (typical non-scrolling window or non-overflowing column would merge with previous command). (WIP branch)
|
||||
- drawlist: make it easier to toggle AA per primitive, so we can use e.g. non-AA fill + AA borders more naturally
|
||||
@ -117,7 +117,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
||||
!- color: the color conversion helpers/types are a mess and needs sorting out.
|
||||
- color: (api breaking) ImGui::ColorConvertXXX functions should be loose ImColorConvertXX to match imgui_internals.h
|
||||
|
||||
- plot: full featured plot/graph api w/ scrolling, zooming etc. --> ImPlot
|
||||
- plot: full featured plot/graph api w/ scrolling, zooming etc. --> promote using ImPlot
|
||||
- (plot: deleted all other todo lines on 2023-06-28)
|
||||
|
||||
- clipper: ability to disable the clipping through a simple flag/bool.
|
||||
@ -150,7 +150,6 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
||||
- drag float: power != 0.0f with current value being outside the range keeps the value stuck.
|
||||
- drag float: added leeway on edge (e.g. a few invisible steps past the clamp limits)
|
||||
|
||||
- combo: use clipper.
|
||||
- combo: a way/helper to customize the combo preview (#1658) -> experimental BeginComboPreview()
|
||||
- combo/listbox: keyboard control. need InputText-like non-active focus + key handling. considering keyboard for custom listbox (pr #203)
|
||||
- listbox: multiple selection (WIP range-select branch)
|
||||
@ -173,15 +172,14 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
||||
- tooltip: drag and drop with tooltip near monitor edges lose/changes its last direction instead of locking one. The drag and drop tooltip should always follow without changing direction.
|
||||
- tooltip: allow to set the width of a tooltip to allow TextWrapped() etc. while keeping the height automatic.
|
||||
- tooltip: drag tooltip hovering over source widget with IsItemHovered/SetTooltip flickers (WIP branch)
|
||||
- tooltip: tooltip priorities to override a stock tooltip (e.g. shortcut tooltip)
|
||||
|
||||
- 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,menus: global-style shortcut api e.g. "Save (CTRL+S)" -> explicit flag for recursing into closed menu
|
||||
- shortcuts: programmatically access shortcuts "Focus("&Save"))
|
||||
- menus: menu-bar: main menu-bar could affect clamping of windows position (~ akin to modifying DisplayMin)
|
||||
- menus: hovering from menu to menu on a menu-bar has 1 frame without any menu, which is a little annoying. ideally either 0 either longer.
|
||||
- menus: hovering from menu to menu on a menu-bar has 1 frame without any menu, which is a little annoying. ideally zero.
|
||||
- menus: would be nice if the Selectable() supported horizontal alignment (must be given the equivalent of WorkRect.Max.x matching the position of the shortcut column)
|
||||
|
||||
- tree node: add treenode/treepush int variants? not there because (void*) cast from int warns on some platforms/settings?
|
||||
@ -277,7 +275,6 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
||||
- font/opt: Considering storing standalone AdvanceX table as 16-bit fixed point integer?
|
||||
- font/opt: Glyph currently 40 bytes (2+9*4). Consider storing UV as 16-bits integer? (->32 bytes). X0/Y0/X1/Y1 as 16 fixed-point integers? Or X0/Y0 as float and X1/Y1 as fixed8_8?
|
||||
|
||||
- nav: visual feedback on button press.
|
||||
- nav: some features such as PageUp/Down/Home/End should probably work without ImGuiConfigFlags_NavEnableKeyboard? (where do we draw the line? how about CTRL+Tab)
|
||||
! nav: never clear NavId on some setup (e.g. gamepad centric)
|
||||
- nav: there's currently no way to completely clear focus with the keyboard. depending on patterns used by the application to dispatch inputs, it may be desirable.
|
||||
@ -317,8 +314,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
||||
- misc: make the ImGuiCond values linear (non-power-of-two). internal storage for ImGuiWindow can use integers to combine into flags (Why?)
|
||||
- misc: PushItemFlag(): add a flag to disable keyboard capture when used with mouse? (#1682)
|
||||
- misc: use more size_t in public api?
|
||||
- misc: possible compile-time support for string view/range instead of char* would e.g. facilitate usage with Rust (#683, #3038, WIP string_view branch)
|
||||
- misc: possible compile-time support for wchar_t instead of char*?
|
||||
- misc: support for string view/range instead of char* would e.g. facilitate usage with Rust (#683, #3038, WIP string_view branch)
|
||||
|
||||
- demo: demonstrate using PushStyleVar() in more details.
|
||||
- demo: add vertical separator demo
|
||||
@ -338,7 +334,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
||||
- backends: bgfx: https://gist.github.com/RichardGale/6e2b74bc42b3005e08397236e4be0fd0
|
||||
- backends: emscriptem: with refactored examples, we could provide a direct imgui_impl_emscripten platform layer (see eg. https://github.com/floooh/sokol-samples/blob/master/html5/imgui-emsc.cc#L42)
|
||||
|
||||
- bindings: ways to use clang ast dump to generate bindings or helpers for bindings? (e.g. clang++ -Xclang -ast-dump=json imgui.h) (WIP project "dear-bindings" still private)
|
||||
- bindings: ways to use clang ast dump to generate bindings or helpers for bindings? (e.g. clang++ -Xclang -ast-dump=json imgui.h) (--> use https://github.com/dearimgui/dear_bindings)
|
||||
|
||||
- optimization: replace vsnprintf with stb_printf? using IMGUI_USE_STB_SPRINTF. (#1038 + needed for string_view)
|
||||
- optimization: add clipping for multi-component widgets (SliderFloatX, ColorEditX, etc.). one problem is that nav branch can't easily clip parent group when there is a move request.
|
||||
|
@ -85,7 +85,7 @@ int main(int, char**)
|
||||
// Setup Platform/Renderer backends
|
||||
ImGui_ImplGlfw_InitForOpenGL(window, true);
|
||||
#ifdef __EMSCRIPTEN__
|
||||
ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback("#canvas");
|
||||
ImGui_ImplGlfw_InstallEmscriptenCallbacks(window, "#canvas");
|
||||
#endif
|
||||
ImGui_ImplOpenGL3_Init(glsl_version);
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
// Volk headers
|
||||
#ifdef IMGUI_IMPL_VULKAN_USE_VOLK
|
||||
#define VOLK_IMPLEMENTATION
|
||||
#include <Volk/volk.h>
|
||||
#include <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.
|
||||
@ -485,17 +485,14 @@ int main(int, char**)
|
||||
glfwPollEvents();
|
||||
|
||||
// Resize swap chain?
|
||||
if (g_SwapChainRebuild)
|
||||
int fb_width, fb_height;
|
||||
glfwGetFramebufferSize(window, &fb_width, &fb_height);
|
||||
if (fb_width > 0 && fb_height > 0 && (g_SwapChainRebuild || g_MainWindowData.Width != fb_width || g_MainWindowData.Height != fb_height))
|
||||
{
|
||||
int width, height;
|
||||
glfwGetFramebufferSize(window, &width, &height);
|
||||
if (width > 0 && height > 0)
|
||||
{
|
||||
ImGui_ImplVulkan_SetMinImageCount(g_MinImageCount);
|
||||
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, &g_MainWindowData, g_QueueFamily, g_Allocator, width, height, g_MinImageCount);
|
||||
g_MainWindowData.FrameIndex = 0;
|
||||
g_SwapChainRebuild = false;
|
||||
}
|
||||
ImGui_ImplVulkan_SetMinImageCount(g_MinImageCount);
|
||||
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, &g_MainWindowData, g_QueueFamily, g_Allocator, fb_width, fb_height, g_MinImageCount);
|
||||
g_MainWindowData.FrameIndex = 0;
|
||||
g_SwapChainRebuild = false;
|
||||
}
|
||||
|
||||
// Start the Dear ImGui frame
|
||||
|
@ -27,6 +27,12 @@ set(IMGUI_DIR ../../)
|
||||
|
||||
# Libraries
|
||||
if(EMSCRIPTEN)
|
||||
if(EMSCRIPTEN_VERSION VERSION_GREATER_EQUAL "3.1.57")
|
||||
set(IMGUI_EMSCRIPTEN_GLFW3 "--use-port=contrib.glfw3" CACHE STRING "Choose between --use-port=contrib.glfw3 and -sUSE_GLFW=3 for GLFW implementation (default to --use-port=contrib.glfw3)")
|
||||
else()
|
||||
# cannot use contrib.glfw3 prior to 3.1.57
|
||||
set(IMGUI_EMSCRIPTEN_GLFW3 "-sUSE_GLFW=3" CACHE STRING "Use -sUSE_GLFW=3 for GLFW implementation" FORCE)
|
||||
endif()
|
||||
set(LIBRARIES glfw)
|
||||
add_compile_options(-sDISABLE_EXCEPTION_CATCHING=1 -DIMGUI_DISABLE_FILE_FUNCTIONS=1)
|
||||
else()
|
||||
@ -82,9 +88,16 @@ target_link_libraries(example_glfw_wgpu PUBLIC ${LIBRARIES})
|
||||
|
||||
# Emscripten settings
|
||||
if(EMSCRIPTEN)
|
||||
if("${IMGUI_EMSCRIPTEN_GLFW3}" STREQUAL "--use-port=contrib.glfw3")
|
||||
target_compile_options(example_glfw_wgpu PUBLIC
|
||||
"${IMGUI_EMSCRIPTEN_GLFW3}"
|
||||
"-DEMSCRIPTEN_USE_PORT_CONTRIB_GLFW3" # unnecessary beyond emscripten 3.1.59
|
||||
)
|
||||
endif()
|
||||
message(STATUS "Using ${IMGUI_EMSCRIPTEN_GLFW3} GLFW implementation")
|
||||
target_link_options(example_glfw_wgpu PRIVATE
|
||||
"-sUSE_WEBGPU=1"
|
||||
"-sUSE_GLFW=3"
|
||||
"${IMGUI_EMSCRIPTEN_GLFW3}"
|
||||
"-sWASM=1"
|
||||
"-sALLOW_MEMORY_GROWTH=1"
|
||||
"-sNO_EXIT_RUNTIME=0"
|
||||
|
@ -101,7 +101,7 @@ int main(int, char**)
|
||||
// Setup Platform/Renderer backends
|
||||
ImGui_ImplGlfw_InitForOther(window, true);
|
||||
#ifdef __EMSCRIPTEN__
|
||||
ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback("#canvas");
|
||||
ImGui_ImplGlfw_InstallEmscriptenCallbacks(window, "#canvas");
|
||||
#endif
|
||||
ImGui_ImplWGPU_InitInfo init_info;
|
||||
init_info.Device = wgpu_device;
|
||||
|
@ -24,7 +24,7 @@
|
||||
// Volk headers
|
||||
#ifdef IMGUI_IMPL_VULKAN_USE_VOLK
|
||||
#define VOLK_IMPLEMENTATION
|
||||
#include <Volk/volk.h>
|
||||
#include <volk.h>
|
||||
#endif
|
||||
|
||||
//#define APP_USE_UNLIMITED_FRAME_RATE
|
||||
@ -494,17 +494,14 @@ int main(int, char**)
|
||||
}
|
||||
|
||||
// Resize swap chain?
|
||||
if (g_SwapChainRebuild)
|
||||
int fb_width, fb_height;
|
||||
SDL_GetWindowSize(window, &fb_width, &fb_height);
|
||||
if (fb_width > 0 && fb_height > 0 && (g_SwapChainRebuild || g_MainWindowData.Width != fb_width || g_MainWindowData.Height != fb_height))
|
||||
{
|
||||
int width, height;
|
||||
SDL_GetWindowSize(window, &width, &height);
|
||||
if (width > 0 && height > 0)
|
||||
{
|
||||
ImGui_ImplVulkan_SetMinImageCount(g_MinImageCount);
|
||||
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, &g_MainWindowData, g_QueueFamily, g_Allocator, width, height, g_MinImageCount);
|
||||
g_MainWindowData.FrameIndex = 0;
|
||||
g_SwapChainRebuild = false;
|
||||
}
|
||||
ImGui_ImplVulkan_SetMinImageCount(g_MinImageCount);
|
||||
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, &g_MainWindowData, g_QueueFamily, g_Allocator, fb_width, fb_height, g_MinImageCount);
|
||||
g_MainWindowData.FrameIndex = 0;
|
||||
g_SwapChainRebuild = false;
|
||||
}
|
||||
|
||||
// Start the Dear ImGui frame
|
||||
|
@ -37,9 +37,9 @@ LIBS =
|
||||
|
||||
ifeq ($(UNAME_S), Linux) #LINUX
|
||||
ECHO_MESSAGE = "Linux"
|
||||
LIBS += $(LINUX_GL_LIBS) -ldl `sdl3-config --libs`
|
||||
LIBS += $(LINUX_GL_LIBS) -ldl `pkg-config sdl3 --libs`
|
||||
|
||||
CXXFLAGS += `sdl3-config --cflags`
|
||||
CXXFLAGS += `pkg-config sdl3 --cflags`
|
||||
CFLAGS = $(CXXFLAGS)
|
||||
endif
|
||||
|
||||
@ -48,7 +48,7 @@ ifeq ($(UNAME_S), Darwin) #APPLE
|
||||
LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo `sdl3-config --libs`
|
||||
LIBS += -L/usr/local/lib -L/opt/local/lib
|
||||
|
||||
CXXFLAGS += `sdl3-config --cflags`
|
||||
CXXFLAGS += `pkg-config sdl3 --cflags`
|
||||
CXXFLAGS += -I/usr/local/include -I/opt/local/include
|
||||
CFLAGS = $(CXXFLAGS)
|
||||
endif
|
||||
|
@ -57,9 +57,6 @@ int main(int, char**)
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
|
||||
#endif
|
||||
|
||||
// Enable native IME.
|
||||
SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");
|
||||
|
||||
// Create window with graphics context
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
|
||||
@ -199,7 +196,7 @@ int main(int, char**)
|
||||
ImGui_ImplSDL3_Shutdown();
|
||||
ImGui::DestroyContext();
|
||||
|
||||
SDL_GL_DeleteContext(gl_context);
|
||||
SDL_GL_DestroyContext(gl_context);
|
||||
SDL_DestroyWindow(window);
|
||||
SDL_Quit();
|
||||
|
||||
|
@ -26,9 +26,9 @@ LIBS =
|
||||
|
||||
ifeq ($(UNAME_S), Linux) #LINUX
|
||||
ECHO_MESSAGE = "Linux"
|
||||
LIBS += -ldl `sdl3-config --libs`
|
||||
LIBS += -ldl `pkg-config sdl3 --libs`
|
||||
|
||||
CXXFLAGS += `sdl3-config --cflags`
|
||||
CXXFLAGS += `pkg-config sdl3 --cflags`
|
||||
CFLAGS = $(CXXFLAGS)
|
||||
endif
|
||||
|
||||
@ -37,7 +37,7 @@ ifeq ($(UNAME_S), Darwin) #APPLE
|
||||
LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo `sdl3-config --libs`
|
||||
LIBS += -L/usr/local/lib -L/opt/local/lib
|
||||
|
||||
CXXFLAGS += `sdl3-config --cflags`
|
||||
CXXFLAGS += `pkg-config sdl3 --cflags`
|
||||
CXXFLAGS += -I/usr/local/include -I/opt/local/include
|
||||
CFLAGS = $(CXXFLAGS)
|
||||
endif
|
||||
|
@ -31,9 +31,6 @@ int main(int, char**)
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Enable native IME.
|
||||
SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1");
|
||||
|
||||
// Create window with SDL_Renderer graphics context
|
||||
Uint32 window_flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN;
|
||||
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL3+SDL_Renderer example", 1280, 720, window_flags);
|
||||
@ -160,7 +157,7 @@ int main(int, char**)
|
||||
// Rendering
|
||||
ImGui::Render();
|
||||
//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_SetRenderDrawColorFloat(renderer, clear_color.x, clear_color.y, clear_color.z, clear_color.w);
|
||||
SDL_RenderClear(renderer);
|
||||
ImGui_ImplSDLRenderer3_RenderDrawData(ImGui::GetDrawData(), renderer);
|
||||
SDL_RenderPresent(renderer);
|
||||
|
20
external/imgui/imgui/examples/imgui_examples.sln
vendored
20
external/imgui/imgui/examples/imgui_examples.sln
vendored
@ -29,6 +29,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_win32_opengl3", "ex
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_sdl2_sdlrenderer2", "example_sdl2_sdlrenderer2\example_sdl2_sdlrenderer2.vcxproj", "{0C0B2BEA-311F-473C-9652-87923EF639E3}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_sdl3_opengl3", "example_sdl3_opengl3\example_sdl3_opengl3.vcxproj", "{84AAA301-84FE-428B-9E3E-817BC8123C0C}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_sdl3_sdlrenderer3", "example_sdl3_sdlrenderer3\example_sdl3_sdlrenderer3.vcxproj", "{C0290D21-3AD2-4A35-ABBC-A2F5F48326DA}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
@ -141,6 +145,22 @@ Global
|
||||
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Release|Win32.Build.0 = Release|Win32
|
||||
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Release|x64.ActiveCfg = Release|x64
|
||||
{0C0B2BEA-311F-473C-9652-87923EF639E3}.Release|x64.Build.0 = Release|x64
|
||||
{84AAA301-84FE-428B-9E3E-817BC8123C0C}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{84AAA301-84FE-428B-9E3E-817BC8123C0C}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{84AAA301-84FE-428B-9E3E-817BC8123C0C}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{84AAA301-84FE-428B-9E3E-817BC8123C0C}.Debug|x64.Build.0 = Debug|x64
|
||||
{84AAA301-84FE-428B-9E3E-817BC8123C0C}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{84AAA301-84FE-428B-9E3E-817BC8123C0C}.Release|Win32.Build.0 = Release|Win32
|
||||
{84AAA301-84FE-428B-9E3E-817BC8123C0C}.Release|x64.ActiveCfg = Release|x64
|
||||
{84AAA301-84FE-428B-9E3E-817BC8123C0C}.Release|x64.Build.0 = Release|x64
|
||||
{C0290D21-3AD2-4A35-ABBC-A2F5F48326DA}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{C0290D21-3AD2-4A35-ABBC-A2F5F48326DA}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{C0290D21-3AD2-4A35-ABBC-A2F5F48326DA}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{C0290D21-3AD2-4A35-ABBC-A2F5F48326DA}.Debug|x64.Build.0 = Debug|x64
|
||||
{C0290D21-3AD2-4A35-ABBC-A2F5F48326DA}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{C0290D21-3AD2-4A35-ABBC-A2F5F48326DA}.Release|Win32.Build.0 = Release|Win32
|
||||
{C0290D21-3AD2-4A35-ABBC-A2F5F48326DA}.Release|x64.ActiveCfg = Release|x64
|
||||
{C0290D21-3AD2-4A35-ABBC-A2F5F48326DA}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
4
external/imgui/imgui/imconfig.h
vendored
4
external/imgui/imgui/imconfig.h
vendored
@ -42,6 +42,7 @@
|
||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] [Default with non-Visual Studio compilers] Don't implement default IME handler (won't require imm32.lib/.a)
|
||||
//#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, IME).
|
||||
//#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices', this is why this is not the default).
|
||||
//#define IMGUI_DISABLE_DEFAULT_SHELL_FUNCTIONS // Don't implement default io.PlatformOpenInShellFn() handler (Win32: ShellExecute(), require shell32.lib/.a, Mac/Linux: use system("")).
|
||||
//#define IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself (e.g. if you don't want to link with vsnprintf)
|
||||
//#define IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 so you can implement them yourself.
|
||||
//#define IMGUI_DISABLE_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle at all (replace them with dummies)
|
||||
@ -49,6 +50,9 @@
|
||||
//#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions().
|
||||
//#define IMGUI_DISABLE_SSE // Disable use of SSE intrinsics even if available
|
||||
|
||||
//---- Enable Test Engine / Automation features.
|
||||
//#define IMGUI_ENABLE_TEST_ENGINE // Enable imgui_test_engine hooks. Generally set automatically by include "imgui_te_config.h", see Test Engine for details.
|
||||
|
||||
//---- Include imgui_user.h at the end of imgui.h as a convenience
|
||||
// May be convenient for some users to only explicitly include vanilla imgui.h and have extra stuff included.
|
||||
//#define IMGUI_INCLUDE_IMGUI_USER_H
|
||||
|
604
external/imgui/imgui/imgui.cpp
vendored
604
external/imgui/imgui/imgui.cpp
vendored
File diff suppressed because it is too large
Load Diff
286
external/imgui/imgui/imgui.h
vendored
286
external/imgui/imgui/imgui.h
vendored
@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.90.7
|
||||
// dear imgui, v1.91.0 WIP
|
||||
// (headers)
|
||||
|
||||
// Help:
|
||||
@ -27,8 +27,8 @@
|
||||
|
||||
// Library Version
|
||||
// (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_NUM 19070
|
||||
#define IMGUI_VERSION "1.91.0 WIP"
|
||||
#define IMGUI_VERSION_NUM 19095
|
||||
#define IMGUI_HAS_TABLE
|
||||
|
||||
/*
|
||||
@ -39,7 +39,7 @@ Index of this file:
|
||||
// [SECTION] Dear ImGui end-user API functions
|
||||
// [SECTION] Flags & Enumerations
|
||||
// [SECTION] Tables API flags and structures (ImGuiTableFlags, ImGuiTableColumnFlags, ImGuiTableRowFlags, ImGuiTableBgTarget, ImGuiTableSortSpecs, ImGuiTableColumnSortSpecs)
|
||||
// [SECTION] Helpers: Memory allocations macros, ImVector<>
|
||||
// [SECTION] Helpers: Debug log, Memory allocations macros, ImVector<>
|
||||
// [SECTION] ImGuiStyle
|
||||
// [SECTION] ImGuiIO
|
||||
// [SECTION] Misc data structures (ImGuiInputTextCallbackData, ImGuiSizeCallbackData, ImGuiPayload)
|
||||
@ -143,6 +143,17 @@ Index of this file:
|
||||
// [SECTION] Forward declarations and basic types
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Scalar data types
|
||||
typedef unsigned int ImGuiID;// A unique ID used by widgets (typically the result of hashing a stack of string)
|
||||
typedef signed char ImS8; // 8-bit signed integer
|
||||
typedef unsigned char ImU8; // 8-bit unsigned integer
|
||||
typedef signed short ImS16; // 16-bit signed integer
|
||||
typedef unsigned short ImU16; // 16-bit unsigned integer
|
||||
typedef signed int ImS32; // 32-bit signed integer == int
|
||||
typedef unsigned int ImU32; // 32-bit unsigned integer (often used to store packed colors)
|
||||
typedef signed long long ImS64; // 64-bit signed integer
|
||||
typedef unsigned long long ImU64; // 64-bit unsigned integer
|
||||
|
||||
// Forward declarations
|
||||
struct ImDrawChannel; // Temporary storage to output draw commands out of order, used by ImDrawListSplitter and ImDrawList::ChannelsSplit()
|
||||
struct ImDrawCmd; // A single draw command within a parent ImDrawList (generally maps to 1 GPU draw call, unless it is a callback)
|
||||
@ -165,9 +176,10 @@ struct ImGuiKeyData; // Storage for ImGuiIO and IsKeyDown(), IsKe
|
||||
struct ImGuiListClipper; // Helper to manually clip large list of items
|
||||
struct ImGuiOnceUponAFrame; // Helper for running a block of code not more than once a frame
|
||||
struct ImGuiPayload; // User data payload for drag and drop operations
|
||||
struct ImGuiPlatformImeData; // Platform IME data for io.SetPlatformImeDataFn() function.
|
||||
struct ImGuiPlatformImeData; // Platform IME data for io.PlatformSetImeDataFn() function.
|
||||
struct ImGuiSizeCallbackData; // Callback data when using SetNextWindowSizeConstraints() (rare/advanced use)
|
||||
struct ImGuiStorage; // Helper for key->value storage
|
||||
struct ImGuiStorage; // Helper for key->value storage (container sorted by key)
|
||||
struct ImGuiStoragePair; // Helper for key->value storage (pair)
|
||||
struct ImGuiStyle; // Runtime data for styling/colors
|
||||
struct ImGuiTableSortSpecs; // Sorting specifications for a table (often handling sort specs for a single column, occasionally more)
|
||||
struct ImGuiTableColumnSortSpecs; // Sorting specification for one column of a table
|
||||
@ -181,15 +193,15 @@ struct ImGuiViewport; // A Platform Window (always only one in 'ma
|
||||
// - In Visual Studio: CTRL+comma ("Edit.GoToAll") can follow symbols inside comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot.
|
||||
// - In Visual Studio w/ Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols inside comments.
|
||||
// - In VS Code, CLion, etc.: CTRL+click can follow symbols inside comments.
|
||||
enum ImGuiDir : int; // -> enum ImGuiDir // Enum: A cardinal direction (Left, Right, Up, Down)
|
||||
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 ImGuiSortDirection : ImU8; // -> enum ImGuiSortDirection // Enum: A sorting direction (ascending or descending)
|
||||
typedef int ImGuiCol; // -> enum ImGuiCol_ // Enum: A color identifier for styling
|
||||
typedef int ImGuiCond; // -> enum ImGuiCond_ // Enum: A condition for many Set*() functions
|
||||
typedef int ImGuiDataType; // -> enum ImGuiDataType_ // Enum: A primary data type
|
||||
typedef int ImGuiDir; // -> enum ImGuiDir_ // Enum: A cardinal direction
|
||||
typedef int ImGuiMouseButton; // -> enum ImGuiMouseButton_ // Enum: A mouse button identifier (0=left, 1=right, 2=middle)
|
||||
typedef int ImGuiMouseCursor; // -> enum ImGuiMouseCursor_ // Enum: A mouse cursor shape
|
||||
typedef int ImGuiSortDirection; // -> enum ImGuiSortDirection_ // Enum: A sorting direction (ascending or descending)
|
||||
typedef int ImGuiStyleVar; // -> enum ImGuiStyleVar_ // Enum: A variable identifier for styling
|
||||
typedef int ImGuiTableBgTarget; // -> enum ImGuiTableBgTarget_ // Enum: A color target for TableSetBgColor()
|
||||
|
||||
@ -212,6 +224,7 @@ typedef int ImGuiFocusedFlags; // -> enum ImGuiFocusedFlags_ // Flags: f
|
||||
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 ImGuiItemFlags; // -> enum ImGuiItemFlags_ // Flags: for PushItemFlag(), shared by all items
|
||||
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 ImGuiSelectableFlags; // -> enum ImGuiSelectableFlags_ // Flags: for Selectable()
|
||||
@ -239,17 +252,6 @@ typedef void* ImTextureID; // Default: store a pointer or an integer fi
|
||||
typedef unsigned short ImDrawIdx; // Default: 16-bit (for maximum compatibility with renderer backends)
|
||||
#endif
|
||||
|
||||
// Scalar data types
|
||||
typedef unsigned int ImGuiID;// A unique ID used by widgets (typically the result of hashing a stack of string)
|
||||
typedef signed char ImS8; // 8-bit signed integer
|
||||
typedef unsigned char ImU8; // 8-bit unsigned integer
|
||||
typedef signed short ImS16; // 16-bit signed integer
|
||||
typedef unsigned short ImU16; // 16-bit unsigned integer
|
||||
typedef signed int ImS32; // 32-bit signed integer == int
|
||||
typedef unsigned int ImU32; // 32-bit unsigned integer (often used to store packed colors)
|
||||
typedef signed long long ImS64; // 64-bit signed integer
|
||||
typedef unsigned long long ImU64; // 64-bit unsigned integer
|
||||
|
||||
// Character types
|
||||
// (we generally use UTF-8 encoded string in the API. This is storage specifically for a decoded character used for keyboard input and display)
|
||||
typedef unsigned int ImWchar32; // A single decoded U32 character/code point. We encode them as multi bytes UTF-8 when used in strings.
|
||||
@ -435,10 +437,8 @@ namespace ImGui
|
||||
IMGUI_API void PushStyleVar(ImGuiStyleVar idx, float val); // modify a style float variable. always use this if you modify the style after NewFrame().
|
||||
IMGUI_API void PushStyleVar(ImGuiStyleVar idx, const ImVec2& val); // modify a style ImVec2 variable. always use this if you modify the style after NewFrame().
|
||||
IMGUI_API void PopStyleVar(int count = 1);
|
||||
IMGUI_API void PushTabStop(bool tab_stop); // == tab stop enable. Allow focusing using TAB/Shift-TAB, enabled by default but you can disable it for certain widgets
|
||||
IMGUI_API void PopTabStop();
|
||||
IMGUI_API void PushButtonRepeat(bool repeat); // in 'repeat' mode, Button*() functions return repeated true in a typematic manner (using io.KeyRepeatDelay/io.KeyRepeatRate setting). Note that you can call IsItemActive() after any Button() to tell if the button is held in the current frame.
|
||||
IMGUI_API void PopButtonRepeat();
|
||||
IMGUI_API void PushItemFlag(ImGuiItemFlags option, bool enabled); // modify specified shared item flag, e.g. PushItemFlag(ImGuiItemFlags_NoTabStop, true)
|
||||
IMGUI_API void PopItemFlag();
|
||||
|
||||
// Parameters stacks (current window)
|
||||
IMGUI_API void PushItemWidth(float item_width); // push width of items for common large "item+label" widgets. >0.0f: width in pixels, <0.0f align xx pixels to the right of window (so -FLT_MIN always align width to the right side).
|
||||
@ -542,6 +542,8 @@ namespace ImGui
|
||||
IMGUI_API bool RadioButton(const char* label, int* v, int v_button); // shortcut to handle the above pattern when value is an integer
|
||||
IMGUI_API void ProgressBar(float fraction, const ImVec2& size_arg = ImVec2(-FLT_MIN, 0), const char* overlay = NULL);
|
||||
IMGUI_API void Bullet(); // draw a small circle + keep the cursor on the same line. advance cursor x position by GetTreeNodeToLabelSpacing(), same distance that TreeNode() uses
|
||||
IMGUI_API bool TextLink(const char* label); // hyperlink text button, return true when clicked
|
||||
IMGUI_API void TextLinkOpenURL(const char* label, const char* url = NULL); // hyperlink text button, automatically open file/url when clicked
|
||||
|
||||
// Widgets: Images
|
||||
// - Read about ImTextureID here: https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples
|
||||
@ -778,7 +780,7 @@ namespace ImGui
|
||||
// - TableNextColumn() -> Text("Hello 0") -> TableNextColumn() -> Text("Hello 1") // OK: TableNextColumn() automatically gets to next row!
|
||||
// - TableNextRow() -> Text("Hello 0") // Not OK! Missing TableSetColumnIndex() or TableNextColumn()! Text will not appear!
|
||||
// - 5. Call EndTable()
|
||||
IMGUI_API bool BeginTable(const char* str_id, int column, ImGuiTableFlags flags = 0, const ImVec2& outer_size = ImVec2(0.0f, 0.0f), float inner_width = 0.0f);
|
||||
IMGUI_API bool BeginTable(const char* str_id, int columns, ImGuiTableFlags flags = 0, const ImVec2& outer_size = ImVec2(0.0f, 0.0f), float inner_width = 0.0f);
|
||||
IMGUI_API void EndTable(); // only call EndTable() if BeginTable() returns true!
|
||||
IMGUI_API void TableNextRow(ImGuiTableRowFlags row_flags = 0, float min_row_height = 0.0f); // append into the first cell of a new row.
|
||||
IMGUI_API bool TableNextColumn(); // append into the next column (or first column of next row if currently in last column). Return true when column is visible.
|
||||
@ -811,6 +813,7 @@ namespace ImGui
|
||||
IMGUI_API const char* TableGetColumnName(int column_n = -1); // return "" if column didn't have a name declared by TableSetupColumn(). Pass -1 to use current column.
|
||||
IMGUI_API ImGuiTableColumnFlags TableGetColumnFlags(int column_n = -1); // return column flags so you can query their Enabled/Visible/Sorted/Hovered status flags. Pass -1 to use current column.
|
||||
IMGUI_API void TableSetColumnEnabled(int column_n, bool v);// change user accessible enabled/disabled state of a column. Set to false to hide the column. User can use the context menu to change this themselves (right-click in headers, or right-click in columns body with ImGuiTableFlags_ContextMenuInBody)
|
||||
IMGUI_API int TableGetHoveredColumn(); // return hovered column. return -1 when table is not hovered. return columns_count if the unused space at the right of visible columns is hovered. Can also use (TableGetColumnFlags() & ImGuiTableColumnFlags_IsHovered) instead.
|
||||
IMGUI_API void TableSetBgColor(ImGuiTableBgTarget target, ImU32 color, int column_n = -1); // change the color of a cell, row, or column. See ImGuiTableBgTarget_ flags for details.
|
||||
|
||||
// Legacy Columns API (prefer using Tables!)
|
||||
@ -859,6 +862,7 @@ namespace ImGui
|
||||
// Disabling [BETA API]
|
||||
// - Disable all user interactions and dim items visuals (applying style.DisabledAlpha over current colors)
|
||||
// - Those can be nested but it cannot be used to enable an already disabled section (a single BeginDisabled(true) in the stack is enough to keep everything disabled)
|
||||
// - Tooltips windows by exception are opted out of disabling.
|
||||
// - BeginDisabled(false) essentially does nothing useful but is provided to facilitate use of boolean expressions. If you can avoid calling BeginDisabled(False)/EndDisabled() best to avoid it.
|
||||
IMGUI_API void BeginDisabled(bool disabled = true);
|
||||
IMGUI_API void EndDisabled();
|
||||
@ -998,6 +1002,10 @@ namespace ImGui
|
||||
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.
|
||||
#ifndef IMGUI_DISABLE_DEBUG_TOOLS
|
||||
IMGUI_API void DebugLog(const char* fmt, ...) IM_FMTARGS(1); // Call via IMGUI_DEBUG_LOG() for maximum stripping in caller code!
|
||||
IMGUI_API void DebugLogV(const char* fmt, va_list args) IM_FMTLIST(1);
|
||||
#endif
|
||||
|
||||
// Memory Allocators
|
||||
// - Those functions are not reliant on the current context.
|
||||
@ -1043,7 +1051,6 @@ enum ImGuiWindowFlags_
|
||||
ImGuiWindowFlags_NoInputs = ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus,
|
||||
|
||||
// [Internal]
|
||||
ImGuiWindowFlags_NavFlattened = 1 << 23, // [BETA] On child window: share focus scope, allow gamepad/keyboard navigation to cross over parent border to this child or between sibling child windows.
|
||||
ImGuiWindowFlags_ChildWindow = 1 << 24, // Don't use! For internal use by BeginChild()
|
||||
ImGuiWindowFlags_Tooltip = 1 << 25, // Don't use! For internal use by BeginTooltip()
|
||||
ImGuiWindowFlags_Popup = 1 << 26, // Don't use! For internal use by BeginPopup()
|
||||
@ -1053,6 +1060,7 @@ enum ImGuiWindowFlags_
|
||||
// Obsolete names
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
ImGuiWindowFlags_AlwaysUseWindowPadding = 1 << 30, // Obsoleted in 1.90: Use ImGuiChildFlags_AlwaysUseWindowPadding in BeginChild() call.
|
||||
ImGuiWindowFlags_NavFlattened = 1 << 31, // Obsoleted in 1.90.9: Use ImGuiChildFlags_NavFlattened in BeginChild() call.
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -1076,34 +1084,56 @@ enum ImGuiChildFlags_
|
||||
ImGuiChildFlags_AutoResizeY = 1 << 5, // Enable auto-resizing height. Read "IMPORTANT: Size measurement" details above.
|
||||
ImGuiChildFlags_AlwaysAutoResize = 1 << 6, // Combined with AutoResizeX/AutoResizeY. Always measure size even when child is hidden, always return true, always disable clipping optimization! NOT RECOMMENDED.
|
||||
ImGuiChildFlags_FrameStyle = 1 << 7, // Style the child window like a framed item: use FrameBg, FrameRounding, FrameBorderSize, FramePadding instead of ChildBg, ChildRounding, ChildBorderSize, WindowPadding.
|
||||
ImGuiChildFlags_NavFlattened = 1 << 8, // Share focus scope, allow gamepad/keyboard navigation to cross over parent border to this child or between sibling child windows.
|
||||
};
|
||||
|
||||
// Flags for ImGui::PushItemFlag()
|
||||
// (Those are shared by all items)
|
||||
enum ImGuiItemFlags_
|
||||
{
|
||||
ImGuiItemFlags_None = 0, // (Default)
|
||||
ImGuiItemFlags_NoTabStop = 1 << 0, // false // Disable keyboard tabbing. This is a "lighter" version of ImGuiItemFlags_NoNav.
|
||||
ImGuiItemFlags_NoNav = 1 << 1, // false // Disable any form of focusing (keyboard/gamepad directional navigation and SetKeyboardFocusHere() calls).
|
||||
ImGuiItemFlags_NoNavDefaultFocus = 1 << 2, // false // Disable item being a candidate for default focus (e.g. used by title bar items).
|
||||
ImGuiItemFlags_ButtonRepeat = 1 << 3, // false // Any button-like behavior will have repeat mode enabled (based on io.KeyRepeatDelay and io.KeyRepeatRate values). Note that you can also call IsItemActive() after any button to tell if it is being held.
|
||||
ImGuiItemFlags_AutoClosePopups = 1 << 4, // true // MenuItem()/Selectable() automatically close their parent popup window.
|
||||
};
|
||||
|
||||
// Flags for ImGui::InputText()
|
||||
// (Those are per-item flags. There are shared flags in ImGuiIO: io.ConfigInputTextCursorBlink and io.ConfigInputTextEnterKeepActive)
|
||||
enum ImGuiInputTextFlags_
|
||||
{
|
||||
// Basic filters (also see ImGuiInputTextFlags_CallbackCharFilter)
|
||||
ImGuiInputTextFlags_None = 0,
|
||||
ImGuiInputTextFlags_CharsDecimal = 1 << 0, // Allow 0123456789.+-*/
|
||||
ImGuiInputTextFlags_CharsHexadecimal = 1 << 1, // Allow 0123456789ABCDEFabcdef
|
||||
ImGuiInputTextFlags_CharsUppercase = 1 << 2, // Turn a..z into A..Z
|
||||
ImGuiInputTextFlags_CharsNoBlank = 1 << 3, // Filter out spaces, tabs
|
||||
ImGuiInputTextFlags_AutoSelectAll = 1 << 4, // Select entire text when first taking mouse focus
|
||||
ImGuiInputTextFlags_EnterReturnsTrue = 1 << 5, // Return 'true' when Enter is pressed (as opposed to every time the value was modified). Consider looking at the IsItemDeactivatedAfterEdit() function.
|
||||
ImGuiInputTextFlags_CallbackCompletion = 1 << 6, // Callback on pressing TAB (for completion handling)
|
||||
ImGuiInputTextFlags_CallbackHistory = 1 << 7, // Callback on pressing Up/Down arrows (for history handling)
|
||||
ImGuiInputTextFlags_CallbackAlways = 1 << 8, // Callback on each iteration. User code may query cursor position, modify text buffer.
|
||||
ImGuiInputTextFlags_CallbackCharFilter = 1 << 9, // Callback on character inputs to replace or discard them. Modify 'EventChar' to replace or discard, or return 1 in callback to discard.
|
||||
ImGuiInputTextFlags_AllowTabInput = 1 << 10, // Pressing TAB input a '\t' character into the text field
|
||||
ImGuiInputTextFlags_CtrlEnterForNewLine = 1 << 11, // In multi-line mode, unfocus with Enter, add new line with Ctrl+Enter (default is opposite: unfocus with Ctrl+Enter, add line with Enter).
|
||||
ImGuiInputTextFlags_NoHorizontalScroll = 1 << 12, // Disable following the cursor horizontally
|
||||
ImGuiInputTextFlags_AlwaysOverwrite = 1 << 13, // Overwrite mode
|
||||
ImGuiInputTextFlags_ReadOnly = 1 << 14, // Read-only mode
|
||||
ImGuiInputTextFlags_Password = 1 << 15, // Password mode, display all characters as '*'
|
||||
ImGuiInputTextFlags_CharsScientific = 1 << 2, // Allow 0123456789.+-*/eE (Scientific notation input)
|
||||
ImGuiInputTextFlags_CharsUppercase = 1 << 3, // Turn a..z into A..Z
|
||||
ImGuiInputTextFlags_CharsNoBlank = 1 << 4, // Filter out spaces, tabs
|
||||
|
||||
// Inputs
|
||||
ImGuiInputTextFlags_AllowTabInput = 1 << 5, // Pressing TAB input a '\t' character into the text field
|
||||
ImGuiInputTextFlags_EnterReturnsTrue = 1 << 6, // Return 'true' when Enter is pressed (as opposed to every time the value was modified). Consider looking at the IsItemDeactivatedAfterEdit() function.
|
||||
ImGuiInputTextFlags_EscapeClearsAll = 1 << 7, // Escape key clears content if not empty, and deactivate otherwise (contrast to default behavior of Escape to revert)
|
||||
ImGuiInputTextFlags_CtrlEnterForNewLine = 1 << 8, // In multi-line mode, validate with Enter, add new line with Ctrl+Enter (default is opposite: validate with Ctrl+Enter, add line with Enter).
|
||||
|
||||
// Other options
|
||||
ImGuiInputTextFlags_ReadOnly = 1 << 9, // Read-only mode
|
||||
ImGuiInputTextFlags_Password = 1 << 10, // Password mode, display all characters as '*', disable copy
|
||||
ImGuiInputTextFlags_AlwaysOverwrite = 1 << 11, // Overwrite mode
|
||||
ImGuiInputTextFlags_AutoSelectAll = 1 << 12, // Select entire text when first taking mouse focus
|
||||
ImGuiInputTextFlags_ParseEmptyRefVal = 1 << 13, // InputFloat(), InputInt(), InputScalar() etc. only: parse empty string as zero value.
|
||||
ImGuiInputTextFlags_DisplayEmptyRefVal = 1 << 14, // InputFloat(), InputInt(), InputScalar() etc. only: when value is zero, do not display it. Generally used with ImGuiInputTextFlags_ParseEmptyRefVal.
|
||||
ImGuiInputTextFlags_NoHorizontalScroll = 1 << 15, // Disable following the cursor horizontally
|
||||
ImGuiInputTextFlags_NoUndoRedo = 1 << 16, // Disable undo/redo. Note that input text owns the text data while active, if you want to provide your own undo/redo stack you need e.g. to call ClearActiveID().
|
||||
ImGuiInputTextFlags_CharsScientific = 1 << 17, // Allow 0123456789.+-*/eE (Scientific notation input)
|
||||
ImGuiInputTextFlags_CallbackResize = 1 << 18, // Callback on buffer capacity changes request (beyond 'buf_size' parameter value), allowing the string to grow. Notify when the string wants to be resized (for string types which hold a cache of their Size). You will be provided a new BufSize in the callback and NEED to honor it. (see misc/cpp/imgui_stdlib.h for an example of using this)
|
||||
ImGuiInputTextFlags_CallbackEdit = 1 << 19, // Callback on any edit (note that InputText() already returns true on edit, the callback is useful mainly to manipulate the underlying buffer while focus is active)
|
||||
ImGuiInputTextFlags_EscapeClearsAll = 1 << 20, // Escape key clears content if not empty, and deactivate otherwise (contrast to default behavior of Escape to revert)
|
||||
|
||||
// Callback features
|
||||
ImGuiInputTextFlags_CallbackCompletion = 1 << 17, // Callback on pressing TAB (for completion handling)
|
||||
ImGuiInputTextFlags_CallbackHistory = 1 << 18, // Callback on pressing Up/Down arrows (for history handling)
|
||||
ImGuiInputTextFlags_CallbackAlways = 1 << 19, // Callback on each iteration. User code may query cursor position, modify text buffer.
|
||||
ImGuiInputTextFlags_CallbackCharFilter = 1 << 20, // Callback on character inputs to replace or discard them. Modify 'EventChar' to replace or discard, or return 1 in callback to discard.
|
||||
ImGuiInputTextFlags_CallbackResize = 1 << 21, // Callback on buffer capacity changes request (beyond 'buf_size' parameter value), allowing the string to grow. Notify when the string wants to be resized (for string types which hold a cache of their Size). You will be provided a new BufSize in the callback and NEED to honor it. (see misc/cpp/imgui_stdlib.h for an example of using this)
|
||||
ImGuiInputTextFlags_CallbackEdit = 1 << 22, // Callback on any edit (note that InputText() already returns true on edit, the callback is useful mainly to manipulate the underlying buffer while focus is active)
|
||||
|
||||
// Obsolete names
|
||||
//ImGuiInputTextFlags_AlwaysInsertMode = ImGuiInputTextFlags_AlwaysOverwrite // [renamed in 1.82] name was not matching behavior
|
||||
@ -1123,7 +1153,7 @@ enum ImGuiTreeNodeFlags_
|
||||
ImGuiTreeNodeFlags_OpenOnArrow = 1 << 7, // Only open when clicking on the arrow part. If ImGuiTreeNodeFlags_OpenOnDoubleClick is also set, single-click arrow or double-click all box to open.
|
||||
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_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() before the node.
|
||||
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_SpanFullWidth = 1 << 12, // Extend hit box to the left-most and right-most edges (cover the indent area).
|
||||
ImGuiTreeNodeFlags_SpanTextWidth = 1 << 13, // Narrow hit box + narrow hovering highlight, will only cover the label text.
|
||||
@ -1166,14 +1196,15 @@ enum ImGuiPopupFlags_
|
||||
enum ImGuiSelectableFlags_
|
||||
{
|
||||
ImGuiSelectableFlags_None = 0,
|
||||
ImGuiSelectableFlags_DontClosePopups = 1 << 0, // Clicking this doesn't close parent popup window
|
||||
ImGuiSelectableFlags_NoAutoClosePopups = 1 << 0, // Clicking this doesn't close parent popup window (overrides ImGuiItemFlags_AutoClosePopups)
|
||||
ImGuiSelectableFlags_SpanAllColumns = 1 << 1, // Frame will span all columns of its container table (text will still fit in current column)
|
||||
ImGuiSelectableFlags_AllowDoubleClick = 1 << 2, // Generate press events on double clicks too
|
||||
ImGuiSelectableFlags_Disabled = 1 << 3, // Cannot be selected, display grayed out text
|
||||
ImGuiSelectableFlags_AllowOverlap = 1 << 4, // (WIP) Hit testing to allow subsequent widgets to overlap this one
|
||||
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
ImGuiSelectableFlags_AllowItemOverlap = ImGuiSelectableFlags_AllowOverlap, // Renamed in 1.89.7
|
||||
ImGuiSelectableFlags_DontClosePopups = ImGuiSelectableFlags_NoAutoClosePopups, // Renamed in 1.91.0
|
||||
ImGuiSelectableFlags_AllowItemOverlap = ImGuiSelectableFlags_AllowOverlap, // Renamed in 1.89.7
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -1202,8 +1233,9 @@ enum ImGuiTabBarFlags_
|
||||
ImGuiTabBarFlags_NoCloseWithMiddleMouseButton = 1 << 3, // Disable behavior of closing tabs (that are submitted with p_open != NULL) with middle mouse button. You may handle this behavior manually on user's side with if (IsItemHovered() && IsMouseClicked(2)) *p_open = false.
|
||||
ImGuiTabBarFlags_NoTabListScrollingButtons = 1 << 4, // Disable scrolling buttons (apply when fitting policy is ImGuiTabBarFlags_FittingPolicyScroll)
|
||||
ImGuiTabBarFlags_NoTooltip = 1 << 5, // Disable tooltips when hovering a tab
|
||||
ImGuiTabBarFlags_FittingPolicyResizeDown = 1 << 6, // Resize tabs when they don't fit
|
||||
ImGuiTabBarFlags_FittingPolicyScroll = 1 << 7, // Add scroll buttons when tabs don't fit
|
||||
ImGuiTabBarFlags_DrawSelectedOverline = 1 << 6, // Draw selected overline markers over selected tab
|
||||
ImGuiTabBarFlags_FittingPolicyResizeDown = 1 << 7, // Resize tabs when they don't fit
|
||||
ImGuiTabBarFlags_FittingPolicyScroll = 1 << 8, // Add scroll buttons when tabs don't fit
|
||||
ImGuiTabBarFlags_FittingPolicyMask_ = ImGuiTabBarFlags_FittingPolicyResizeDown | ImGuiTabBarFlags_FittingPolicyScroll,
|
||||
ImGuiTabBarFlags_FittingPolicyDefault_ = ImGuiTabBarFlags_FittingPolicyResizeDown,
|
||||
};
|
||||
@ -1285,12 +1317,18 @@ enum ImGuiDragDropFlags_
|
||||
ImGuiDragDropFlags_SourceNoHoldToOpenOthers = 1 << 2, // Disable the behavior that allows to open tree nodes and collapsing header by holding over them while dragging a source item.
|
||||
ImGuiDragDropFlags_SourceAllowNullID = 1 << 3, // Allow items such as Text(), Image() that have no unique identifier to be used as drag source, by manufacturing a temporary identifier based on their window-relative position. This is extremely unusual within the dear imgui ecosystem and so we made it explicit.
|
||||
ImGuiDragDropFlags_SourceExtern = 1 << 4, // External source (from outside of dear imgui), won't attempt to read current item/window info. Will always return true. Only one Extern source can be active simultaneously.
|
||||
ImGuiDragDropFlags_SourceAutoExpirePayload = 1 << 5, // Automatically expire the payload if the source cease to be submitted (otherwise payloads are persisting while being dragged)
|
||||
ImGuiDragDropFlags_PayloadAutoExpire = 1 << 5, // Automatically expire the payload if the source cease to be submitted (otherwise payloads are persisting while being dragged)
|
||||
ImGuiDragDropFlags_PayloadNoCrossContext = 1 << 6, // Hint to specify that the payload may not be copied outside current dear imgui context.
|
||||
ImGuiDragDropFlags_PayloadNoCrossProcess = 1 << 7, // Hint to specify that the payload may not be copied outside current process.
|
||||
// AcceptDragDropPayload() flags
|
||||
ImGuiDragDropFlags_AcceptBeforeDelivery = 1 << 10, // AcceptDragDropPayload() will returns true even before the mouse button is released. You can then call IsDelivery() to test if the payload needs to be delivered.
|
||||
ImGuiDragDropFlags_AcceptNoDrawDefaultRect = 1 << 11, // Do not draw the default highlight rectangle when hovering over target.
|
||||
ImGuiDragDropFlags_AcceptNoPreviewTooltip = 1 << 12, // Request hiding the BeginDragDropSource tooltip from the BeginDragDropTarget site.
|
||||
ImGuiDragDropFlags_AcceptPeekOnly = ImGuiDragDropFlags_AcceptBeforeDelivery | ImGuiDragDropFlags_AcceptNoDrawDefaultRect, // For peeking ahead and inspecting the payload before delivery.
|
||||
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
ImGuiDragDropFlags_SourceAutoExpirePayload = ImGuiDragDropFlags_PayloadAutoExpire, // Renamed in 1.90.9
|
||||
#endif
|
||||
};
|
||||
|
||||
// Standard Drag and Drop payload types. You can define you own payload types using short strings. Types starting with '_' are defined by Dear ImGui.
|
||||
@ -1310,11 +1348,12 @@ enum ImGuiDataType_
|
||||
ImGuiDataType_U64, // unsigned long long / unsigned __int64
|
||||
ImGuiDataType_Float, // float
|
||||
ImGuiDataType_Double, // double
|
||||
ImGuiDataType_Bool, // bool (provided for user convenience, not supported by scalar widgets)
|
||||
ImGuiDataType_COUNT
|
||||
};
|
||||
|
||||
// A cardinal direction
|
||||
enum ImGuiDir_
|
||||
enum ImGuiDir : int
|
||||
{
|
||||
ImGuiDir_None = -1,
|
||||
ImGuiDir_Left = 0,
|
||||
@ -1325,7 +1364,7 @@ enum ImGuiDir_
|
||||
};
|
||||
|
||||
// A sorting direction
|
||||
enum ImGuiSortDirection_
|
||||
enum ImGuiSortDirection : ImU8
|
||||
{
|
||||
ImGuiSortDirection_None = 0,
|
||||
ImGuiSortDirection_Ascending = 1, // Ascending = 0->9, A->Z etc.
|
||||
@ -1518,8 +1557,9 @@ enum ImGuiConfigFlags_
|
||||
ImGuiConfigFlags_NavEnableGamepad = 1 << 1, // Master gamepad navigation enable flag. Backend also needs to set ImGuiBackendFlags_HasGamepad.
|
||||
ImGuiConfigFlags_NavEnableSetMousePos = 1 << 2, // Instruct navigation to move the mouse cursor. May be useful on TV/console systems where moving a virtual mouse is awkward. Will update io.MousePos and set io.WantSetMousePos=true. If enabled you MUST honor io.WantSetMousePos requests in your backend, otherwise ImGui will react as if the mouse is jumping around back and forth.
|
||||
ImGuiConfigFlags_NavNoCaptureKeyboard = 1 << 3, // Instruct navigation to not set the io.WantCaptureKeyboard flag when io.NavActive is set.
|
||||
ImGuiConfigFlags_NoMouse = 1 << 4, // Instruct imgui to clear mouse position/buttons in NewFrame(). This allows ignoring the mouse information set by the backend.
|
||||
ImGuiConfigFlags_NoMouse = 1 << 4, // Instruct dear imgui to disable mouse inputs and interactions.
|
||||
ImGuiConfigFlags_NoMouseCursorChange = 1 << 5, // Instruct backend to not alter mouse cursor shape and visibility. Use if the backend cursor changes are interfering with yours and you don't want to use SetMouseCursor() to change mouse cursor. You may want to honor requests from imgui by reading GetMouseCursor() yourself instead.
|
||||
ImGuiConfigFlags_NoKeyboard = 1 << 6, // Instruct dear imgui to disable keyboard inputs and interactions. This is done by ignoring keyboard events and clearing existing states.
|
||||
|
||||
// User storage (to allow your backend/engine to communicate to code that may be shared between multiple projects. Those flags are NOT used by core Dear ImGui)
|
||||
ImGuiConfigFlags_IsSRGB = 1 << 20, // Application is SRGB-aware.
|
||||
@ -1572,11 +1612,13 @@ enum ImGuiCol_
|
||||
ImGuiCol_ResizeGrip, // Resize grip in lower-right and lower-left corners of windows.
|
||||
ImGuiCol_ResizeGripHovered,
|
||||
ImGuiCol_ResizeGripActive,
|
||||
ImGuiCol_Tab, // TabItem in a TabBar
|
||||
ImGuiCol_TabHovered,
|
||||
ImGuiCol_TabActive,
|
||||
ImGuiCol_TabUnfocused,
|
||||
ImGuiCol_TabUnfocusedActive,
|
||||
ImGuiCol_TabHovered, // Tab background, when hovered
|
||||
ImGuiCol_Tab, // Tab background, when tab-bar is focused & tab is unselected
|
||||
ImGuiCol_TabSelected, // Tab background, when tab-bar is focused & tab is selected
|
||||
ImGuiCol_TabSelectedOverline, // Tab horizontal overline, when tab-bar is focused & tab is selected
|
||||
ImGuiCol_TabDimmed, // Tab background, when tab-bar is unfocused & tab is unselected
|
||||
ImGuiCol_TabDimmedSelected, // Tab background, when tab-bar is unfocused & tab is selected
|
||||
ImGuiCol_TabDimmedSelectedOverline,//..horizontal overline, when tab-bar is unfocused & tab is selected
|
||||
ImGuiCol_PlotLines,
|
||||
ImGuiCol_PlotLinesHovered,
|
||||
ImGuiCol_PlotHistogram,
|
||||
@ -1586,13 +1628,20 @@ enum ImGuiCol_
|
||||
ImGuiCol_TableBorderLight, // Table inner borders (prefer using Alpha=1.0 here)
|
||||
ImGuiCol_TableRowBg, // Table row background (even rows)
|
||||
ImGuiCol_TableRowBgAlt, // Table row background (odd rows)
|
||||
ImGuiCol_TextLink, // Hyperlink color
|
||||
ImGuiCol_TextSelectedBg,
|
||||
ImGuiCol_DragDropTarget, // Rectangle highlighting a drop target
|
||||
ImGuiCol_NavHighlight, // Gamepad/keyboard: current highlighted item
|
||||
ImGuiCol_NavWindowingHighlight, // Highlight window when using CTRL+TAB
|
||||
ImGuiCol_NavWindowingDimBg, // Darken/colorize entire screen behind the CTRL+TAB window list, when active
|
||||
ImGuiCol_ModalWindowDimBg, // Darken/colorize entire screen behind a modal window, when one is active
|
||||
ImGuiCol_COUNT
|
||||
ImGuiCol_COUNT,
|
||||
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
ImGuiCol_TabActive = ImGuiCol_TabSelected, // [renamed in 1.90.9]
|
||||
ImGuiCol_TabUnfocused = ImGuiCol_TabDimmed, // [renamed in 1.90.9]
|
||||
ImGuiCol_TabUnfocusedActive = ImGuiCol_TabDimmedSelected, // [renamed in 1.90.9]
|
||||
#endif
|
||||
};
|
||||
|
||||
// Enumeration for PushStyleVar() / PopStyleVar() to temporarily modify the ImGuiStyle structure.
|
||||
@ -1631,11 +1680,11 @@ enum ImGuiStyleVar_
|
||||
ImGuiStyleVar_TabRounding, // float TabRounding
|
||||
ImGuiStyleVar_TabBorderSize, // float TabBorderSize
|
||||
ImGuiStyleVar_TabBarBorderSize, // float TabBarBorderSize
|
||||
ImGuiStyleVar_TableAngledHeadersAngle, // float TableAngledHeadersAngle
|
||||
ImGuiStyleVar_TableAngledHeadersTextAlign,// ImVec2 TableAngledHeadersTextAlign
|
||||
ImGuiStyleVar_TableAngledHeadersAngle, // float TableAngledHeadersAngle
|
||||
ImGuiStyleVar_TableAngledHeadersTextAlign,// ImVec2 TableAngledHeadersTextAlign
|
||||
ImGuiStyleVar_ButtonTextAlign, // ImVec2 ButtonTextAlign
|
||||
ImGuiStyleVar_SelectableTextAlign, // ImVec2 SelectableTextAlign
|
||||
ImGuiStyleVar_SeparatorTextBorderSize, // float SeparatorTextBorderSize
|
||||
ImGuiStyleVar_SeparatorTextBorderSize, // float SeparatorTextBorderSize
|
||||
ImGuiStyleVar_SeparatorTextAlign, // ImVec2 SeparatorTextAlign
|
||||
ImGuiStyleVar_SeparatorTextPadding, // ImVec2 SeparatorTextPadding
|
||||
ImGuiStyleVar_COUNT
|
||||
@ -1648,10 +1697,8 @@ enum ImGuiButtonFlags_
|
||||
ImGuiButtonFlags_MouseButtonLeft = 1 << 0, // React on left mouse button (default)
|
||||
ImGuiButtonFlags_MouseButtonRight = 1 << 1, // React on right mouse button
|
||||
ImGuiButtonFlags_MouseButtonMiddle = 1 << 2, // React on center mouse button
|
||||
|
||||
// [Internal]
|
||||
ImGuiButtonFlags_MouseButtonMask_ = ImGuiButtonFlags_MouseButtonLeft | ImGuiButtonFlags_MouseButtonRight | ImGuiButtonFlags_MouseButtonMiddle,
|
||||
ImGuiButtonFlags_MouseButtonDefault_ = ImGuiButtonFlags_MouseButtonLeft,
|
||||
ImGuiButtonFlags_MouseButtonMask_ = ImGuiButtonFlags_MouseButtonLeft | ImGuiButtonFlags_MouseButtonRight | ImGuiButtonFlags_MouseButtonMiddle, // [Internal]
|
||||
//ImGuiButtonFlags_MouseButtonDefault_ = ImGuiButtonFlags_MouseButtonLeft,
|
||||
};
|
||||
|
||||
// Flags for ColorEdit3() / ColorEdit4() / ColorPicker3() / ColorPicker4() / ColorButton()
|
||||
@ -1706,8 +1753,9 @@ enum ImGuiSliderFlags_
|
||||
ImGuiSliderFlags_None = 0,
|
||||
ImGuiSliderFlags_AlwaysClamp = 1 << 4, // Clamp value to min/max bounds when input manually with CTRL+Click. By default CTRL+Click allows going out of bounds.
|
||||
ImGuiSliderFlags_Logarithmic = 1 << 5, // Make the widget logarithmic (linear otherwise). Consider using ImGuiSliderFlags_NoRoundToFormat with this if using a format-string with small amount of digits.
|
||||
ImGuiSliderFlags_NoRoundToFormat = 1 << 6, // Disable rounding underlying value to match precision of the display format string (e.g. %.3f values are rounded to those 3 digits)
|
||||
ImGuiSliderFlags_NoInput = 1 << 7, // Disable CTRL+Click or Enter key allowing to input text directly into the widget
|
||||
ImGuiSliderFlags_NoRoundToFormat = 1 << 6, // Disable rounding underlying value to match precision of the display format string (e.g. %.3f values are rounded to those 3 digits).
|
||||
ImGuiSliderFlags_NoInput = 1 << 7, // Disable CTRL+Click or Enter key allowing to input text directly into the widget.
|
||||
ImGuiSliderFlags_WrapAround = 1 << 8, // Enable wrapping around from max to min and from min to max (only supported by DragXXX() functions for now.
|
||||
ImGuiSliderFlags_InvalidMask_ = 0x7000000F, // [Internal] We treat using those bits as being potentially a 'float power' argument from the previous API that has got miscast to this enum, and will trigger an assert if needed.
|
||||
|
||||
// Obsolete names
|
||||
@ -1924,15 +1972,25 @@ struct ImGuiTableColumnSortSpecs
|
||||
ImGuiID ColumnUserID; // User id of the column (if specified by a TableSetupColumn() call)
|
||||
ImS16 ColumnIndex; // Index of the column
|
||||
ImS16 SortOrder; // Index within parent ImGuiTableSortSpecs (always stored in order starting from 0, tables sorted on a single criteria will always have a 0 here)
|
||||
ImGuiSortDirection SortDirection : 8; // ImGuiSortDirection_Ascending or ImGuiSortDirection_Descending
|
||||
ImGuiSortDirection SortDirection; // ImGuiSortDirection_Ascending or ImGuiSortDirection_Descending
|
||||
|
||||
ImGuiTableColumnSortSpecs() { memset(this, 0, sizeof(*this)); }
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Helpers: Memory allocations macros, ImVector<>
|
||||
// [SECTION] Helpers: Debug log, memory allocations macros, ImVector<>
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Debug Logging into ShowDebugLogWindow(), tty and more.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef IMGUI_DISABLE_DEBUG_TOOLS
|
||||
#define IMGUI_DEBUG_LOG(...) ImGui::DebugLog(__VA_ARGS__)
|
||||
#else
|
||||
#define IMGUI_DEBUG_LOG(...) ((void)0)
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// IM_MALLOC(), IM_FREE(), IM_NEW(), IM_PLACEMENT_NEW(), IM_DELETE()
|
||||
// We call C++ constructor on own allocated memory via the placement "new(ptr) Type()" syntax.
|
||||
@ -2073,9 +2131,9 @@ struct ImGuiStyle
|
||||
float SeparatorTextBorderSize; // Thickkness of border in SeparatorText()
|
||||
ImVec2 SeparatorTextAlign; // Alignment of text within the separator. Defaults to (0.0f, 0.5f) (left aligned, center).
|
||||
ImVec2 SeparatorTextPadding; // Horizontal offset of text from each edge of the separator + spacing on other axis. Generally small values. .y is recommended to be == FramePadding.y.
|
||||
ImVec2 DisplayWindowPadding; // Window position are clamped to be visible within the display area or monitors by at least this amount. Only applies to regular windows.
|
||||
ImVec2 DisplaySafeAreaPadding; // If you cannot see the edges of your screen (e.g. on a TV) increase the safe area padding. Apply to popups/tooltips as well regular windows. NB: Prefer configuring your TV sets correctly!
|
||||
float MouseCursorScale; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). May be removed later.
|
||||
ImVec2 DisplayWindowPadding; // Apply to regular windows: amount which we enforce to keep visible when moving near edges of your screen.
|
||||
ImVec2 DisplaySafeAreaPadding; // Apply to every windows, menus, popups, tooltips: amount where we avoid displaying contents. Adjust if you cannot see the edges of your screen (e.g. on a TV where scaling has not been configured).
|
||||
float MouseCursorScale; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). We apply per-monitor DPI scaling over this scale. May be removed later.
|
||||
bool AntiAliasedLines; // Enable anti-aliased lines/borders. Disable if you are really tight on CPU/GPU. Latched at the beginning of the frame (copied to ImDrawList).
|
||||
bool AntiAliasedLinesUseTex; // Enable anti-aliased lines/borders using textures where possible. Require backend to render with bilinear filtering (NOT point/nearest filtering). Latched at the beginning of the frame (copied to ImDrawList).
|
||||
bool AntiAliasedFill; // Enable anti-aliased edges around filled shapes (rounded rectangles, circles, etc.). Disable if you are really tight on CPU/GPU. Latched at the beginning of the frame (copied to ImDrawList).
|
||||
@ -2175,9 +2233,9 @@ struct ImGuiIO
|
||||
// Option to deactivate io.AddFocusEvent(false) handling.
|
||||
// - May facilitate interactions with a debugger when focus loss leads to clearing inputs data.
|
||||
// - Backends may have other side-effects on focus loss, so this will reduce side-effects but not necessary remove all of them.
|
||||
bool ConfigDebugIgnoreFocusLoss; // = false // Ignore io.AddFocusEvent(false), consequently not calling io.ClearInputKeys() in input processing.
|
||||
bool ConfigDebugIgnoreFocusLoss; // = false // Ignore io.AddFocusEvent(false), consequently not calling io.ClearInputKeys()/io.ClearInputMouse() in input processing.
|
||||
|
||||
// Options to audit .ini data
|
||||
// Option to audit .ini data
|
||||
bool ConfigDebugIniSettings; // = false // Save .ini data with extra comments (particularly helpful for Docking, but makes saving slower)
|
||||
|
||||
//------------------------------------------------------------------
|
||||
@ -2198,9 +2256,15 @@ struct ImGuiIO
|
||||
void (*SetClipboardTextFn)(void* user_data, const char* text);
|
||||
void* ClipboardUserData;
|
||||
|
||||
// Optional: Open link/folder/file in OS Shell
|
||||
// (default to use ShellExecuteA() on Windows, system() on Linux/Mac)
|
||||
bool (*PlatformOpenInShellFn)(ImGuiContext* ctx, const char* path);
|
||||
void* PlatformOpenInShellUserData;
|
||||
|
||||
// Optional: Notify OS Input Method Editor of the screen position of your cursor for text input position (e.g. when using Japanese/Chinese IME on Windows)
|
||||
// (default to use native imm32 api on Windows)
|
||||
void (*SetPlatformImeDataFn)(ImGuiViewport* viewport, ImGuiPlatformImeData* data);
|
||||
void (*PlatformSetImeDataFn)(ImGuiContext* ctx, ImGuiViewport* viewport, ImGuiPlatformImeData* data);
|
||||
//void (*SetPlatformImeDataFn)(ImGuiViewport* viewport, ImGuiPlatformImeData* data); // [Renamed to io.PlatformSetImeDataFn in 1.91.0]
|
||||
|
||||
// Optional: Platform locale
|
||||
ImWchar PlatformLocaleDecimalPoint; // '.' // [Experimental] Configure decimal point e.g. '.' or ',' useful for some languages (e.g. German), generally pulled from *localeconv()->decimal_point
|
||||
@ -2224,7 +2288,8 @@ struct ImGuiIO
|
||||
IMGUI_API void SetKeyEventNativeData(ImGuiKey key, int native_keycode, int native_scancode, int native_legacy_index = -1); // [Optional] Specify index for legacy <1.87 IsKeyXXX() functions with native indices + specify native keycode, scancode.
|
||||
IMGUI_API void SetAppAcceptingEvents(bool accepting_events); // Set master flag for accepting key/mouse/text events (default to true). Useful if you have native dialog boxes that are interrupting your application loop/refresh, and you want to disable events being queued while your app is frozen.
|
||||
IMGUI_API void ClearEventsQueue(); // Clear all incoming events.
|
||||
IMGUI_API void ClearInputKeys(); // Clear current keyboard/mouse/gamepad state + current frame text input buffer. Equivalent to releasing all keys/buttons.
|
||||
IMGUI_API void ClearInputKeys(); // Clear current keyboard/gamepad state + current frame text input buffer. Equivalent to releasing all keys/buttons.
|
||||
IMGUI_API void ClearInputMouse(); // Clear current mouse state.
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
IMGUI_API void ClearInputCharacters(); // [Obsoleted in 1.89.8] Clear the current frame text input buffer. Now included within ClearInputKeys().
|
||||
#endif
|
||||
@ -2453,6 +2518,16 @@ struct ImGuiTextBuffer
|
||||
IMGUI_API void appendfv(const char* fmt, va_list args) IM_FMTLIST(2);
|
||||
};
|
||||
|
||||
// [Internal] Key+Value for ImGuiStorage
|
||||
struct ImGuiStoragePair
|
||||
{
|
||||
ImGuiID key;
|
||||
union { int val_i; float val_f; void* val_p; };
|
||||
ImGuiStoragePair(ImGuiID _key, int _val) { key = _key; val_i = _val; }
|
||||
ImGuiStoragePair(ImGuiID _key, float _val) { key = _key; val_f = _val; }
|
||||
ImGuiStoragePair(ImGuiID _key, void* _val) { key = _key; val_p = _val; }
|
||||
};
|
||||
|
||||
// Helper: Key->Value storage
|
||||
// Typically you don't have to worry about this since a storage is held within each Window.
|
||||
// We use it to e.g. store collapse state for a tree (Int 0/1)
|
||||
@ -2464,15 +2539,6 @@ struct ImGuiTextBuffer
|
||||
struct ImGuiStorage
|
||||
{
|
||||
// [Internal]
|
||||
struct ImGuiStoragePair
|
||||
{
|
||||
ImGuiID key;
|
||||
union { int val_i; float val_f; void* val_p; };
|
||||
ImGuiStoragePair(ImGuiID _key, int _val) { key = _key; val_i = _val; }
|
||||
ImGuiStoragePair(ImGuiID _key, float _val) { key = _key; val_f = _val; }
|
||||
ImGuiStoragePair(ImGuiID _key, void* _val) { key = _key; val_p = _val; }
|
||||
};
|
||||
|
||||
ImVector<ImGuiStoragePair> Data;
|
||||
|
||||
// - Get***() functions find pair, never add/allocate. Pairs are sorted so a query is O(log N)
|
||||
@ -2501,6 +2567,10 @@ struct ImGuiStorage
|
||||
IMGUI_API void BuildSortByKey();
|
||||
// Obsolete: use on your own storage if you know only integer are being stored (open/close all tree nodes)
|
||||
IMGUI_API void SetAllInt(int val);
|
||||
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
//typedef ::ImGuiStoragePair ImGuiStoragePair; // 1.90.8: moved type outside struct
|
||||
#endif
|
||||
};
|
||||
|
||||
// Helper: Manually clip large list of items.
|
||||
@ -2531,9 +2601,10 @@ struct ImGuiListClipper
|
||||
int ItemsCount; // [Internal] Number of items
|
||||
float ItemsHeight; // [Internal] Height of item after a first step and item submission can calculate it
|
||||
float StartPosY; // [Internal] Cursor position at the time of Begin() or after table frozen rows are all processed
|
||||
double StartSeekOffsetY; // [Internal] Account for frozen rows in a table and initial loss of precision in very large windows.
|
||||
void* TempData; // [Internal] Internal data
|
||||
|
||||
// items_count: Use INT_MAX if you don't know how many items you have (in which case the cursor won't be advanced in the final step)
|
||||
// items_count: Use INT_MAX if you don't know how many items you have (in which case the cursor won't be advanced in the final step, and you can call SeekCursorForItem() manually if you need)
|
||||
// items_height: Use -1.0f to be calculated automatically on first step. Otherwise pass in the distance between your items, typically GetTextLineHeightWithSpacing() or GetFrameHeightWithSpacing().
|
||||
IMGUI_API ImGuiListClipper();
|
||||
IMGUI_API ~ImGuiListClipper();
|
||||
@ -2546,6 +2617,11 @@ struct ImGuiListClipper
|
||||
inline void IncludeItemByIndex(int item_index) { IncludeItemsByIndex(item_index, item_index + 1); }
|
||||
IMGUI_API void IncludeItemsByIndex(int item_begin, int item_end); // item_end is exclusive e.g. use (42, 42+1) to make item 42 never clipped.
|
||||
|
||||
// Seek cursor toward given item. This is automatically called while stepping.
|
||||
// - The only reason to call this is: you can use ImGuiListClipper::Begin(INT_MAX) if you don't know item count ahead of time.
|
||||
// - In this case, after all steps are done, you'll want to call SeekCursorForItem(item_count).
|
||||
IMGUI_API void SeekCursorForItem(int item_index);
|
||||
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
inline void IncludeRangeByIndices(int item_begin, int item_end) { IncludeItemsByIndex(item_begin, item_end); } // [renamed in 1.89.9]
|
||||
inline void ForceDisplayRangeByIndices(int item_begin, int item_end) { IncludeItemsByIndex(item_begin, item_end); } // [renamed in 1.89.6]
|
||||
@ -3149,7 +3225,7 @@ struct ImFont
|
||||
float EllipsisCharStep; // 4 // out // Step between characters when EllipsisCount > 0
|
||||
bool DirtyLookupTables; // 1 // out //
|
||||
float Scale; // 4 // in // = 1.f // Base font scale, multiplied by the per-window font scale which you can adjust with SetWindowFontScale()
|
||||
float Ascent, Descent; // 4+4 // out // // Ascent: distance from top to bottom of e.g. 'A' [0..FontSize]
|
||||
float Ascent, Descent; // 4+4 // out // // Ascent: distance from top to bottom of e.g. 'A' [0..FontSize] (unscaled)
|
||||
int MetricsTotalSurface;// 4 // out // // Total surface in pixels to get an idea of the font rasterization/texture cost (not exact, we approximate the cost of padding between glyphs)
|
||||
ImU8 Used4kPagesMap[(IM_UNICODE_CODEPOINT_MAX+1)/4096/8]; // 2 bytes if ImWchar=ImWchar16, 34 bytes if ImWchar==ImWchar32. Store 1-bit for each block of 4K codepoints that has one active glyph. This is mainly used to facilitate iterations across all used codepoints.
|
||||
|
||||
@ -3209,6 +3285,7 @@ struct ImGuiViewport
|
||||
ImVec2 WorkSize; // Work Area: Size of the viewport minus task bars, menu bars, status bars (<= Size)
|
||||
|
||||
// Platform/Backend Dependent Data
|
||||
void* PlatformHandle; // void* to hold higher-level, platform window handle (e.g. HWND, GLFWWindow*, SDL_Window*)
|
||||
void* PlatformHandleRaw; // void* to hold lower-level, platform-native window handle (under Win32 this is expected to be a HWND, unused for other platforms)
|
||||
|
||||
ImGuiViewport() { memset(this, 0, sizeof(*this)); }
|
||||
@ -3222,7 +3299,7 @@ struct ImGuiViewport
|
||||
// [SECTION] Platform Dependent Interfaces
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// (Optional) Support for IME (Input Method Editor) via the io.SetPlatformImeDataFn() function.
|
||||
// (Optional) Support for IME (Input Method Editor) via the io.PlatformSetImeDataFn() function.
|
||||
struct ImGuiPlatformImeData
|
||||
{
|
||||
bool WantVisible; // A widget wants the IME to be visible
|
||||
@ -3241,29 +3318,34 @@ struct ImGuiPlatformImeData
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
namespace ImGui
|
||||
{
|
||||
// OBSOLETED in 1.91.0 (from July 2024)
|
||||
static inline void PushButtonRepeat(bool repeat) { PushItemFlag(ImGuiItemFlags_ButtonRepeat, repeat); }
|
||||
static inline void PopButtonRepeat() { PopItemFlag(); }
|
||||
static inline void PushTabStop(bool tab_stop) { PushItemFlag(ImGuiItemFlags_NoTabStop, !tab_stop); }
|
||||
static inline void PopTabStop() { PopItemFlag(); }
|
||||
// OBSOLETED in 1.90.0 (from September 2023)
|
||||
static inline bool BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags window_flags = 0) { return BeginChild(id, size, ImGuiChildFlags_FrameStyle, window_flags); }
|
||||
static inline void EndChildFrame() { EndChild(); }
|
||||
static inline bool BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags window_flags = 0) { return BeginChild(id, size, ImGuiChildFlags_FrameStyle, window_flags); }
|
||||
static inline void EndChildFrame() { EndChild(); }
|
||||
//static inline bool BeginChild(const char* str_id, const ImVec2& size_arg, bool border, ImGuiWindowFlags window_flags){ return BeginChild(str_id, size_arg, border ? ImGuiChildFlags_Border : ImGuiChildFlags_None, window_flags); } // Unnecessary as true == ImGuiChildFlags_Border
|
||||
//static inline bool BeginChild(ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags window_flags) { return BeginChild(id, size_arg, border ? ImGuiChildFlags_Border : ImGuiChildFlags_None, window_flags); } // Unnecessary as true == ImGuiChildFlags_Border
|
||||
static inline void ShowStackToolWindow(bool* p_open = NULL) { ShowIDStackToolWindow(p_open); }
|
||||
IMGUI_API bool ListBox(const char* label, int* current_item, bool (*old_callback)(void* user_data, int idx, const char** out_text), void* user_data, int items_count, int height_in_items = -1);
|
||||
static inline void ShowStackToolWindow(bool* p_open = NULL) { ShowIDStackToolWindow(p_open); }
|
||||
IMGUI_API bool Combo(const char* label, int* current_item, bool (*old_callback)(void* user_data, int idx, const char** out_text), void* user_data, int items_count, int popup_max_height_in_items = -1);
|
||||
IMGUI_API bool ListBox(const char* label, int* current_item, bool (*old_callback)(void* user_data, int idx, const char** out_text), void* user_data, int items_count, int height_in_items = -1);
|
||||
// OBSOLETED in 1.89.7 (from June 2023)
|
||||
IMGUI_API void SetItemAllowOverlap(); // Use SetNextItemAllowOverlap() before item.
|
||||
IMGUI_API void SetItemAllowOverlap(); // Use SetNextItemAllowOverlap() before item.
|
||||
// OBSOLETED in 1.89.4 (from March 2023)
|
||||
static inline void PushAllowKeyboardFocus(bool tab_stop) { PushTabStop(tab_stop); }
|
||||
static inline void PopAllowKeyboardFocus() { PopTabStop(); }
|
||||
static inline void PushAllowKeyboardFocus(bool tab_stop) { PushItemFlag(ImGuiItemFlags_NoTabStop, !tab_stop); }
|
||||
static inline void PopAllowKeyboardFocus() { PopItemFlag(); }
|
||||
// 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)
|
||||
// OBSOLETED in 1.87 (from February 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 ImGuiKey GetKeyIndex(ImGuiKey key) { IM_ASSERT(key >= ImGuiKey_NamedKey_BEGIN && key < ImGuiKey_NamedKey_END); return key; }
|
||||
// OBSOLETED in 1.87 (from February 2022 but more formally obsoleted April 2024)
|
||||
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 ImGuiKey GetKeyIndex(ImGuiKey key) { IM_ASSERT(key >= ImGuiKey_NamedKey_BEGIN && key < ImGuiKey_NamedKey_END); return key; }
|
||||
|
||||
// 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.
|
||||
//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)
|
||||
//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)
|
||||
@ -3336,8 +3418,8 @@ namespace ImGui
|
||||
|
||||
// RENAMED and MERGED both ImGuiKey_ModXXX and ImGuiModFlags_XXX into ImGuiMod_XXX (from September 2022)
|
||||
// RENAMED ImGuiKeyModFlags -> ImGuiModFlags in 1.88 (from April 2022). Exceptionally commented out ahead of obscolescence schedule to reduce confusion and because they were not meant to be used in the first place.
|
||||
typedef ImGuiKeyChord ImGuiModFlags; // == int. We generally use ImGuiKeyChord to mean "a ImGuiKey or-ed with any number of ImGuiMod_XXX value", but you may store only mods in there.
|
||||
enum ImGuiModFlags_ { ImGuiModFlags_None = 0, ImGuiModFlags_Ctrl = ImGuiMod_Ctrl, ImGuiModFlags_Shift = ImGuiMod_Shift, ImGuiModFlags_Alt = ImGuiMod_Alt, ImGuiModFlags_Super = ImGuiMod_Super };
|
||||
//typedef ImGuiKeyChord ImGuiModFlags; // == int. We generally use ImGuiKeyChord to mean "a ImGuiKey or-ed with any number of ImGuiMod_XXX value", so you may store mods in there.
|
||||
//enum ImGuiModFlags_ { ImGuiModFlags_None = 0, ImGuiModFlags_Ctrl = ImGuiMod_Ctrl, ImGuiModFlags_Shift = ImGuiMod_Shift, ImGuiModFlags_Alt = ImGuiMod_Alt, ImGuiModFlags_Super = ImGuiMod_Super };
|
||||
//typedef ImGuiKeyChord ImGuiKeyModFlags; // == int
|
||||
//enum ImGuiKeyModFlags_ { ImGuiKeyModFlags_None = 0, ImGuiKeyModFlags_Ctrl = ImGuiMod_Ctrl, ImGuiKeyModFlags_Shift = ImGuiMod_Shift, ImGuiKeyModFlags_Alt = ImGuiMod_Alt, ImGuiKeyModFlags_Super = ImGuiMod_Super };
|
||||
|
||||
|
344
external/imgui/imgui/imgui_demo.cpp
vendored
344
external/imgui/imgui/imgui_demo.cpp
vendored
@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.90.7
|
||||
// dear imgui, v1.91.0 WIP
|
||||
// (demo code)
|
||||
|
||||
// Help:
|
||||
@ -83,6 +83,7 @@ Index of this file:
|
||||
// [SECTION] Example App: Debug Console / ShowExampleAppConsole()
|
||||
// [SECTION] Example App: Debug Log / ShowExampleAppLog()
|
||||
// [SECTION] Example App: Simple Layout / ShowExampleAppLayout()
|
||||
// [SECTION] Helpers: ExampleTreeNode, ExampleMemberInfo (for use by Property Editor etc.)
|
||||
// [SECTION] Example App: Property Editor / ShowExampleAppPropertyEditor()
|
||||
// [SECTION] Example App: Long Text / ShowExampleAppLongText()
|
||||
// [SECTION] Example App: Auto Resize / ShowExampleAppAutoResize()
|
||||
@ -439,7 +440,9 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
||||
ImGui::BulletText("See the ShowDemoWindow() code in imgui_demo.cpp. <- you are here!");
|
||||
ImGui::BulletText("See comments in imgui.cpp.");
|
||||
ImGui::BulletText("See example applications in the examples/ folder.");
|
||||
ImGui::BulletText("Read the FAQ at https://www.dearimgui.com/faq/");
|
||||
ImGui::BulletText("Read the FAQ at ");
|
||||
ImGui::SameLine(0, 0);
|
||||
ImGui::TextLinkOpenURL("https://www.dearimgui.com/faq/");
|
||||
ImGui::BulletText("Set 'io.ConfigFlags |= NavEnableKeyboard' for keyboard controls.");
|
||||
ImGui::BulletText("Set 'io.ConfigFlags |= NavEnableGamepad' for gamepad controls.");
|
||||
|
||||
@ -462,19 +465,26 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
||||
ImGui::CheckboxFlags("io.ConfigFlags: NavEnableSetMousePos", &io.ConfigFlags, ImGuiConfigFlags_NavEnableSetMousePos);
|
||||
ImGui::SameLine(); HelpMarker("Instruct navigation to move the mouse cursor. See comment for ImGuiConfigFlags_NavEnableSetMousePos.");
|
||||
ImGui::CheckboxFlags("io.ConfigFlags: NoMouse", &io.ConfigFlags, ImGuiConfigFlags_NoMouse);
|
||||
ImGui::SameLine(); HelpMarker("Instruct dear imgui to disable mouse inputs and interactions.");
|
||||
|
||||
// The "NoMouse" option can get us stuck with a disabled mouse! Let's provide an alternative way to fix it:
|
||||
if (io.ConfigFlags & ImGuiConfigFlags_NoMouse)
|
||||
{
|
||||
// The "NoMouse" option can get us stuck with a disabled mouse! Let's provide an alternative way to fix it:
|
||||
if (fmodf((float)ImGui::GetTime(), 0.40f) < 0.20f)
|
||||
{
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("<<PRESS SPACE TO DISABLE>>");
|
||||
}
|
||||
if (ImGui::IsKeyPressed(ImGuiKey_Space))
|
||||
// Prevent both being checked
|
||||
if (ImGui::IsKeyPressed(ImGuiKey_Space) || (io.ConfigFlags & ImGuiConfigFlags_NoKeyboard))
|
||||
io.ConfigFlags &= ~ImGuiConfigFlags_NoMouse;
|
||||
}
|
||||
ImGui::CheckboxFlags("io.ConfigFlags: NoMouseCursorChange", &io.ConfigFlags, ImGuiConfigFlags_NoMouseCursorChange);
|
||||
|
||||
ImGui::CheckboxFlags("io.ConfigFlags: NoMouseCursorChange", &io.ConfigFlags, ImGuiConfigFlags_NoMouseCursorChange);
|
||||
ImGui::SameLine(); HelpMarker("Instruct backend to not alter mouse cursor shape and visibility.");
|
||||
ImGui::CheckboxFlags("io.ConfigFlags: NoKeyboard", &io.ConfigFlags, ImGuiConfigFlags_NoKeyboard);
|
||||
ImGui::SameLine(); HelpMarker("Instruct dear imgui to disable keyboard inputs and interactions.");
|
||||
|
||||
ImGui::Checkbox("io.ConfigInputTrickleEventQueue", &io.ConfigInputTrickleEventQueue);
|
||||
ImGui::SameLine(); HelpMarker("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.");
|
||||
ImGui::Checkbox("io.MouseDrawCursor", &io.MouseDrawCursor);
|
||||
@ -533,8 +543,9 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
||||
IMGUI_DEMO_MARKER("Configuration/Style");
|
||||
if (ImGui::TreeNode("Style"))
|
||||
{
|
||||
ImGui::Checkbox("Style Editor", &show_tool_style_editor);
|
||||
ImGui::SameLine();
|
||||
HelpMarker("The same contents can be accessed in 'Tools->Style Editor' or by calling the ShowStyleEditor() function.");
|
||||
ImGui::ShowStyleEditor();
|
||||
ImGui::TreePop();
|
||||
ImGui::Spacing();
|
||||
}
|
||||
@ -652,11 +663,11 @@ static void ShowDemoWindowWidgets()
|
||||
IMGUI_DEMO_MARKER("Widgets/Basic/Buttons (Repeating)");
|
||||
static int counter = 0;
|
||||
float spacing = ImGui::GetStyle().ItemInnerSpacing.x;
|
||||
ImGui::PushButtonRepeat(true);
|
||||
ImGui::PushItemFlag(ImGuiItemFlags_ButtonRepeat, true);
|
||||
if (ImGui::ArrowButton("##left", ImGuiDir_Left)) { counter--; }
|
||||
ImGui::SameLine(0.0f, spacing);
|
||||
if (ImGui::ArrowButton("##right", ImGuiDir_Right)) { counter++; }
|
||||
ImGui::PopButtonRepeat();
|
||||
ImGui::PopItemFlag();
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("%d", counter);
|
||||
|
||||
@ -713,18 +724,19 @@ static void ShowDemoWindowWidgets()
|
||||
|
||||
{
|
||||
IMGUI_DEMO_MARKER("Widgets/Basic/DragInt, DragFloat");
|
||||
static int i1 = 50, i2 = 42;
|
||||
static int i1 = 50, i2 = 42, i3 = 128;
|
||||
ImGui::DragInt("drag int", &i1, 1);
|
||||
ImGui::SameLine(); HelpMarker(
|
||||
"Click and drag to edit value.\n"
|
||||
"Hold SHIFT/ALT for faster/slower edit.\n"
|
||||
"Double-click or CTRL+click to input value.");
|
||||
|
||||
ImGui::DragInt("drag int 0..100", &i2, 1, 0, 100, "%d%%", ImGuiSliderFlags_AlwaysClamp);
|
||||
ImGui::DragInt("drag int wrap 100..200", &i3, 1, 100, 200, "%d", ImGuiSliderFlags_WrapAround);
|
||||
|
||||
static float f1 = 1.00f, f2 = 0.0067f;
|
||||
ImGui::DragFloat("drag float", &f1, 0.005f);
|
||||
ImGui::DragFloat("drag small float", &f2, 0.0001f, 0.0f, 0.0f, "%.06f ns");
|
||||
//ImGui::DragFloat("drag wrap -1..1", &f3, 0.005f, -1.0f, 1.0f, NULL, ImGuiSliderFlags_WrapAround);
|
||||
}
|
||||
|
||||
ImGui::SeparatorText("Sliders");
|
||||
@ -881,12 +893,11 @@ static void ShowDemoWindowWidgets()
|
||||
|
||||
// Using ImGuiHoveredFlags_ForTooltip will pull flags from 'style.HoverFlagsForTooltipMouse' or 'style.HoverFlagsForTooltipNav',
|
||||
// which default value include the ImGuiHoveredFlags_AllowWhenDisabled flag.
|
||||
// As a result, Set
|
||||
ImGui::BeginDisabled();
|
||||
ImGui::Button("Disabled item", sz);
|
||||
ImGui::EndDisabled();
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_ForTooltip))
|
||||
ImGui::SetTooltip("I am a a tooltip for a disabled item.");
|
||||
ImGui::EndDisabled();
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
@ -943,6 +954,7 @@ static void ShowDemoWindowWidgets()
|
||||
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::CheckboxFlags("ImGuiTreeNodeFlags_NavLeftJumpsBackHere", &base_flags, ImGuiTreeNodeFlags_NavLeftJumpsBackHere);
|
||||
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::Text("Hello!");
|
||||
@ -975,7 +987,7 @@ static void ShowDemoWindowWidgets()
|
||||
ImGui::Text("This is a drag and drop source");
|
||||
ImGui::EndDragDropSource();
|
||||
}
|
||||
if (i == 2)
|
||||
if (i == 2 && (base_flags & ImGuiTreeNodeFlags_SpanTextWidth))
|
||||
{
|
||||
// Item 2 has an additional inline button to help demonstrate SpanTextWidth.
|
||||
ImGui::SameLine();
|
||||
@ -984,6 +996,8 @@ static void ShowDemoWindowWidgets()
|
||||
if (node_open)
|
||||
{
|
||||
ImGui::BulletText("Blah blah\nBlah Blah");
|
||||
ImGui::SameLine();
|
||||
ImGui::SmallButton("Button");
|
||||
ImGui::TreePop();
|
||||
}
|
||||
}
|
||||
@ -1730,6 +1744,7 @@ static void ShowDemoWindowWidgets()
|
||||
ImGui::CheckboxFlags("ImGuiTabBarFlags_AutoSelectNewTabs", &tab_bar_flags, ImGuiTabBarFlags_AutoSelectNewTabs);
|
||||
ImGui::CheckboxFlags("ImGuiTabBarFlags_TabListPopupButton", &tab_bar_flags, ImGuiTabBarFlags_TabListPopupButton);
|
||||
ImGui::CheckboxFlags("ImGuiTabBarFlags_NoCloseWithMiddleMouseButton", &tab_bar_flags, ImGuiTabBarFlags_NoCloseWithMiddleMouseButton);
|
||||
ImGui::CheckboxFlags("ImGuiTabBarFlags_DrawSelectedOverline", &tab_bar_flags, ImGuiTabBarFlags_DrawSelectedOverline);
|
||||
if ((tab_bar_flags & ImGuiTabBarFlags_FittingPolicyMask_) == 0)
|
||||
tab_bar_flags |= ImGuiTabBarFlags_FittingPolicyDefault_;
|
||||
if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyResizeDown", &tab_bar_flags, ImGuiTabBarFlags_FittingPolicyResizeDown))
|
||||
@ -1738,11 +1753,13 @@ static void ShowDemoWindowWidgets()
|
||||
tab_bar_flags &= ~(ImGuiTabBarFlags_FittingPolicyMask_ ^ ImGuiTabBarFlags_FittingPolicyScroll);
|
||||
|
||||
// Tab Bar
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::Text("Opened:");
|
||||
const char* names[4] = { "Artichoke", "Beetroot", "Celery", "Daikon" };
|
||||
static bool opened[4] = { true, true, true, true }; // Persistent user state
|
||||
for (int n = 0; n < IM_ARRAYSIZE(opened); n++)
|
||||
{
|
||||
if (n > 0) { ImGui::SameLine(); }
|
||||
ImGui::SameLine();
|
||||
ImGui::Checkbox(names[n], &opened[n]);
|
||||
}
|
||||
|
||||
@ -2135,6 +2152,8 @@ static void ShowDemoWindowWidgets()
|
||||
ImGui::SameLine(); HelpMarker("Disable rounding underlying value to match precision of the format string (e.g. %.3f values are rounded to those 3 digits).");
|
||||
ImGui::CheckboxFlags("ImGuiSliderFlags_NoInput", &flags, ImGuiSliderFlags_NoInput);
|
||||
ImGui::SameLine(); HelpMarker("Disable CTRL+Click or Enter key allowing to input text directly into the widget.");
|
||||
ImGui::CheckboxFlags("ImGuiSliderFlags_WrapAround", &flags, ImGuiSliderFlags_WrapAround);
|
||||
ImGui::SameLine(); HelpMarker("Enable wrapping around from max to min and from min to max (only supported by DragXXX() functions)");
|
||||
|
||||
// Drags
|
||||
static float drag_f = 0.5f;
|
||||
@ -2149,9 +2168,10 @@ static void ShowDemoWindowWidgets()
|
||||
// Sliders
|
||||
static float slider_f = 0.5f;
|
||||
static int slider_i = 50;
|
||||
const ImGuiSliderFlags flags_for_sliders = flags & ~ImGuiSliderFlags_WrapAround;
|
||||
ImGui::Text("Underlying float value: %f", slider_f);
|
||||
ImGui::SliderFloat("SliderFloat (0 -> 1)", &slider_f, 0.0f, 1.0f, "%.3f", flags);
|
||||
ImGui::SliderInt("SliderInt (0 -> 100)", &slider_i, 0, 100, "%d", flags);
|
||||
ImGui::SliderFloat("SliderFloat (0 -> 1)", &slider_f, 0.0f, 1.0f, "%.3f", flags_for_sliders);
|
||||
ImGui::SliderInt("SliderInt (0 -> 100)", &slider_i, 0, 100, "%d", flags_for_sliders);
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
@ -2273,20 +2293,24 @@ static void ShowDemoWindowWidgets()
|
||||
|
||||
IMGUI_DEMO_MARKER("Widgets/Data Types/Inputs");
|
||||
static bool inputs_step = true;
|
||||
static ImGuiInputTextFlags flags = ImGuiInputTextFlags_None;
|
||||
ImGui::SeparatorText("Inputs");
|
||||
ImGui::Checkbox("Show step buttons", &inputs_step);
|
||||
ImGui::InputScalar("input s8", ImGuiDataType_S8, &s8_v, inputs_step ? &s8_one : NULL, NULL, "%d");
|
||||
ImGui::InputScalar("input u8", ImGuiDataType_U8, &u8_v, inputs_step ? &u8_one : NULL, NULL, "%u");
|
||||
ImGui::InputScalar("input s16", ImGuiDataType_S16, &s16_v, inputs_step ? &s16_one : NULL, NULL, "%d");
|
||||
ImGui::InputScalar("input u16", ImGuiDataType_U16, &u16_v, inputs_step ? &u16_one : NULL, NULL, "%u");
|
||||
ImGui::InputScalar("input s32", ImGuiDataType_S32, &s32_v, inputs_step ? &s32_one : NULL, NULL, "%d");
|
||||
ImGui::InputScalar("input s32 hex", ImGuiDataType_S32, &s32_v, inputs_step ? &s32_one : NULL, NULL, "%04X");
|
||||
ImGui::InputScalar("input u32", ImGuiDataType_U32, &u32_v, inputs_step ? &u32_one : NULL, NULL, "%u");
|
||||
ImGui::InputScalar("input u32 hex", ImGuiDataType_U32, &u32_v, inputs_step ? &u32_one : NULL, NULL, "%08X");
|
||||
ImGui::InputScalar("input s64", ImGuiDataType_S64, &s64_v, inputs_step ? &s64_one : NULL);
|
||||
ImGui::InputScalar("input u64", ImGuiDataType_U64, &u64_v, inputs_step ? &u64_one : NULL);
|
||||
ImGui::InputScalar("input float", ImGuiDataType_Float, &f32_v, inputs_step ? &f32_one : NULL);
|
||||
ImGui::InputScalar("input double", ImGuiDataType_Double, &f64_v, inputs_step ? &f64_one : NULL);
|
||||
ImGui::CheckboxFlags("ImGuiInputTextFlags_ReadOnly", &flags, ImGuiInputTextFlags_ReadOnly);
|
||||
ImGui::CheckboxFlags("ImGuiInputTextFlags_ParseEmptyRefVal", &flags, ImGuiInputTextFlags_ParseEmptyRefVal);
|
||||
ImGui::CheckboxFlags("ImGuiInputTextFlags_DisplayEmptyRefVal", &flags, ImGuiInputTextFlags_DisplayEmptyRefVal);
|
||||
ImGui::InputScalar("input s8", ImGuiDataType_S8, &s8_v, inputs_step ? &s8_one : NULL, NULL, "%d", flags);
|
||||
ImGui::InputScalar("input u8", ImGuiDataType_U8, &u8_v, inputs_step ? &u8_one : NULL, NULL, "%u", flags);
|
||||
ImGui::InputScalar("input s16", ImGuiDataType_S16, &s16_v, inputs_step ? &s16_one : NULL, NULL, "%d", flags);
|
||||
ImGui::InputScalar("input u16", ImGuiDataType_U16, &u16_v, inputs_step ? &u16_one : NULL, NULL, "%u", flags);
|
||||
ImGui::InputScalar("input s32", ImGuiDataType_S32, &s32_v, inputs_step ? &s32_one : NULL, NULL, "%d", flags);
|
||||
ImGui::InputScalar("input s32 hex", ImGuiDataType_S32, &s32_v, inputs_step ? &s32_one : NULL, NULL, "%04X", flags);
|
||||
ImGui::InputScalar("input u32", ImGuiDataType_U32, &u32_v, inputs_step ? &u32_one : NULL, NULL, "%u", flags);
|
||||
ImGui::InputScalar("input u32 hex", ImGuiDataType_U32, &u32_v, inputs_step ? &u32_one : NULL, NULL, "%08X", flags);
|
||||
ImGui::InputScalar("input s64", ImGuiDataType_S64, &s64_v, inputs_step ? &s64_one : NULL, NULL, NULL, flags);
|
||||
ImGui::InputScalar("input u64", ImGuiDataType_U64, &u64_v, inputs_step ? &u64_one : NULL, NULL, NULL, flags);
|
||||
ImGui::InputScalar("input float", ImGuiDataType_Float, &f32_v, inputs_step ? &f32_one : NULL, NULL, NULL, flags);
|
||||
ImGui::InputScalar("input double", ImGuiDataType_Double, &f64_v, inputs_step ? &f64_one : NULL, NULL, NULL, flags);
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
@ -2558,7 +2582,7 @@ static void ShowDemoWindowWidgets()
|
||||
ImGui::BeginDisabled(true);
|
||||
if (item_type == 0) { ImGui::Text("ITEM: Text"); } // Testing text items with no identifier/interaction
|
||||
if (item_type == 1) { ret = ImGui::Button("ITEM: Button"); } // Testing button
|
||||
if (item_type == 2) { ImGui::PushButtonRepeat(true); ret = ImGui::Button("ITEM: Button"); ImGui::PopButtonRepeat(); } // Testing button (with repeater)
|
||||
if (item_type == 2) { ImGui::PushItemFlag(ImGuiItemFlags_ButtonRepeat, true); ret = ImGui::Button("ITEM: Button"); ImGui::PopItemFlag(); } // Testing button (with repeater)
|
||||
if (item_type == 3) { ret = ImGui::Checkbox("ITEM: Checkbox", &b); } // Testing checkbox
|
||||
if (item_type == 4) { ret = ImGui::SliderFloat("ITEM: SliderFloat", &col4f[0], 0.0f, 1.0f); } // Testing basic item
|
||||
if (item_type == 5) { ret = ImGui::InputText("ITEM: InputText", &str[0], IM_ARRAYSIZE(str)); } // Testing input text (which handles tabbing)
|
||||
@ -3875,7 +3899,7 @@ static void ShowDemoWindowPopups()
|
||||
static int item = 1;
|
||||
static float color[4] = { 0.4f, 0.7f, 0.0f, 0.5f };
|
||||
ImGui::Combo("Combo", &item, "aaaa\0bbbb\0cccc\0dddd\0eeee\0\0");
|
||||
ImGui::ColorEdit4("color", color);
|
||||
ImGui::ColorEdit4("Color", color);
|
||||
|
||||
if (ImGui::Button("Add another modal.."))
|
||||
ImGui::OpenPopup("Stacked 2");
|
||||
@ -3887,6 +3911,7 @@ static void ShowDemoWindowPopups()
|
||||
if (ImGui::BeginPopupModal("Stacked 2", &unused_open))
|
||||
{
|
||||
ImGui::Text("Hello from Stacked The Second!");
|
||||
ImGui::ColorEdit4("Color", color); // Allow opening another nested popup
|
||||
if (ImGui::Button("Close"))
|
||||
ImGui::CloseCurrentPopup();
|
||||
ImGui::EndPopup();
|
||||
@ -4197,7 +4222,7 @@ static void ShowDemoWindowTables()
|
||||
PushStyleCompact();
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_RowBg", &flags, ImGuiTableFlags_RowBg);
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_Borders", &flags, ImGuiTableFlags_Borders);
|
||||
ImGui::SameLine(); HelpMarker("ImGuiTableFlags_Borders\n = ImGuiTableFlags_BordersInnerV\n | ImGuiTableFlags_BordersOuterV\n | ImGuiTableFlags_BordersInnerV\n | ImGuiTableFlags_BordersOuterH");
|
||||
ImGui::SameLine(); HelpMarker("ImGuiTableFlags_Borders\n = ImGuiTableFlags_BordersInnerV\n | ImGuiTableFlags_BordersOuterV\n | ImGuiTableFlags_BordersInnerH\n | ImGuiTableFlags_BordersOuterH");
|
||||
ImGui::Indent();
|
||||
|
||||
ImGui::CheckboxFlags("ImGuiTableFlags_BordersH", &flags, ImGuiTableFlags_BordersH);
|
||||
@ -5851,7 +5876,6 @@ static void ShowDemoWindowTables()
|
||||
|
||||
// Show data
|
||||
// FIXME-TABLE FIXME-NAV: How we can get decent up/down even though we have the buttons here?
|
||||
ImGui::PushButtonRepeat(true);
|
||||
#if 1
|
||||
// Demonstrate using clipper for large vertical lists
|
||||
ImGuiListClipper clipper;
|
||||
@ -5936,7 +5960,6 @@ static void ShowDemoWindowTables()
|
||||
ImGui::PopID();
|
||||
}
|
||||
}
|
||||
ImGui::PopButtonRepeat();
|
||||
|
||||
// Store some info to display debug details below
|
||||
table_scroll_cur = ImVec2(ImGui::GetScrollX(), ImGui::GetScrollY());
|
||||
@ -6295,7 +6318,7 @@ static void ShowDemoWindowInputs()
|
||||
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);
|
||||
flags &= ~(ImGuiInputFlags_RouteOverFocused | ImGuiInputFlags_RouteOverActive | ImGuiInputFlags_RouteUnlessBgFocused);
|
||||
|
||||
ImGui::SeparatorText("Using SetNextItemShortcut()");
|
||||
ImGui::Text("Ctrl+S");
|
||||
@ -6399,10 +6422,10 @@ static void ShowDemoWindowInputs()
|
||||
ImGui::InputText("1", buf, IM_ARRAYSIZE(buf));
|
||||
ImGui::InputText("2", buf, IM_ARRAYSIZE(buf));
|
||||
ImGui::InputText("3", buf, IM_ARRAYSIZE(buf));
|
||||
ImGui::PushTabStop(false);
|
||||
ImGui::PushItemFlag(ImGuiItemFlags_NoTabStop, true);
|
||||
ImGui::InputText("4 (tab skip)", buf, IM_ARRAYSIZE(buf));
|
||||
ImGui::SameLine(); HelpMarker("Item won't be cycled through when using TAB or Shift+Tab.");
|
||||
ImGui::PopTabStop();
|
||||
ImGui::PopItemFlag();
|
||||
ImGui::InputText("5", buf, IM_ARRAYSIZE(buf));
|
||||
ImGui::TreePop();
|
||||
}
|
||||
@ -6424,12 +6447,12 @@ static void ShowDemoWindowInputs()
|
||||
ImGui::InputText("2", buf, IM_ARRAYSIZE(buf));
|
||||
if (ImGui::IsItemActive()) has_focus = 2;
|
||||
|
||||
ImGui::PushTabStop(false);
|
||||
ImGui::PushItemFlag(ImGuiItemFlags_NoTabStop, true);
|
||||
if (focus_3) ImGui::SetKeyboardFocusHere();
|
||||
ImGui::InputText("3 (tab skip)", buf, IM_ARRAYSIZE(buf));
|
||||
if (ImGui::IsItemActive()) has_focus = 3;
|
||||
ImGui::SameLine(); HelpMarker("Item won't be cycled through when using TAB or Shift+Tab.");
|
||||
ImGui::PopTabStop();
|
||||
ImGui::PopItemFlag();
|
||||
|
||||
if (has_focus)
|
||||
ImGui::Text("Item with focus: %d", has_focus);
|
||||
@ -6494,6 +6517,17 @@ void ImGui::ShowAboutWindow(bool* p_open)
|
||||
}
|
||||
IMGUI_DEMO_MARKER("Tools/About Dear ImGui");
|
||||
ImGui::Text("Dear ImGui %s (%d)", IMGUI_VERSION, IMGUI_VERSION_NUM);
|
||||
|
||||
ImGui::TextLinkOpenURL("Homepage", "https://github.com/ocornut/imgui");
|
||||
ImGui::SameLine();
|
||||
ImGui::TextLinkOpenURL("FAQ", "https://github.com/ocornut/imgui/blob/master/docs/FAQ.md");
|
||||
ImGui::SameLine();
|
||||
ImGui::TextLinkOpenURL("Wiki", "https://github.com/ocornut/imgui/wiki");
|
||||
ImGui::SameLine();
|
||||
ImGui::TextLinkOpenURL("Releases", "https://github.com/ocornut/imgui/releases");
|
||||
ImGui::SameLine();
|
||||
ImGui::TextLinkOpenURL("Funding", "https://github.com/ocornut/imgui/wiki/Funding");
|
||||
|
||||
ImGui::Separator();
|
||||
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.");
|
||||
@ -6768,7 +6802,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
||||
ImGui::SliderFloat2("WindowTitleAlign", (float*)&style.WindowTitleAlign, 0.0f, 1.0f, "%.2f");
|
||||
int window_menu_button_position = style.WindowMenuButtonPosition + 1;
|
||||
if (ImGui::Combo("WindowMenuButtonPosition", (int*)&window_menu_button_position, "None\0Left\0Right\0"))
|
||||
style.WindowMenuButtonPosition = window_menu_button_position - 1;
|
||||
style.WindowMenuButtonPosition = (ImGuiDir)(window_menu_button_position - 1);
|
||||
ImGui::Combo("ColorButtonPosition", (int*)&style.ColorButtonPosition, "Left\0Right\0");
|
||||
ImGui::SliderFloat2("ButtonTextAlign", (float*)&style.ButtonTextAlign, 0.0f, 1.0f, "%.2f");
|
||||
ImGui::SameLine(); HelpMarker("Alignment applies when a button is larger than its text content.");
|
||||
@ -6793,7 +6827,8 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
||||
}
|
||||
|
||||
ImGui::SeparatorText("Misc");
|
||||
ImGui::SliderFloat2("DisplaySafeAreaPadding", (float*)&style.DisplaySafeAreaPadding, 0.0f, 30.0f, "%.0f"); ImGui::SameLine(); HelpMarker("Adjust if you cannot see the edges of your screen (e.g. on a TV where scaling has not been configured).");
|
||||
ImGui::SliderFloat2("DisplayWindowPadding", (float*)&style.DisplayWindowPadding, 0.0f, 30.0f, "%.0f"); ImGui::SameLine(); HelpMarker("Apply to regular windows: amount which we enforce to keep visible when moving near edges of your screen.");
|
||||
ImGui::SliderFloat2("DisplaySafeAreaPadding", (float*)&style.DisplaySafeAreaPadding, 0.0f, 30.0f, "%.0f"); ImGui::SameLine(); HelpMarker("Apply to every windows, menus, popups, tooltips: amount where we avoid displaying contents. Adjust if you cannot see the edges of your screen (e.g. on a TV where scaling has not been configured).");
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
@ -6835,7 +6870,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
||||
"Right-click to open edit options menu.");
|
||||
|
||||
ImGui::SetNextWindowSizeConstraints(ImVec2(0.0f, ImGui::GetTextLineHeightWithSpacing() * 10), ImVec2(FLT_MAX, FLT_MAX));
|
||||
ImGui::BeginChild("##colors", ImVec2(0, 0), ImGuiChildFlags_Border, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_AlwaysHorizontalScrollbar | ImGuiWindowFlags_NavFlattened);
|
||||
ImGui::BeginChild("##colors", ImVec2(0, 0), ImGuiChildFlags_Border | ImGuiChildFlags_NavFlattened, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_AlwaysHorizontalScrollbar);
|
||||
ImGui::PushItemWidth(ImGui::GetFontSize() * -12);
|
||||
for (int i = 0; i < ImGuiCol_COUNT; i++)
|
||||
{
|
||||
@ -6916,10 +6951,10 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
||||
ImGui::SetNextWindowPos(ImGui::GetCursorScreenPos());
|
||||
if (show_samples && ImGui::BeginTooltip())
|
||||
{
|
||||
ImGui::TextUnformatted("(R = radius, N = number of segments)");
|
||||
ImGui::TextUnformatted("(R = radius, N = approx number of segments)");
|
||||
ImGui::Spacing();
|
||||
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
||||
const float min_widget_width = ImGui::CalcTextSize("N: MMM\nR: MMM").x;
|
||||
const float min_widget_width = ImGui::CalcTextSize("R: MMM\nN: MMM").x;
|
||||
for (int n = 0; n < 8; n++)
|
||||
{
|
||||
const float RAD_MIN = 5.0f;
|
||||
@ -6928,6 +6963,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
||||
|
||||
ImGui::BeginGroup();
|
||||
|
||||
// N is not always exact here due to how PathArcTo() function work internally
|
||||
ImGui::Text("R: %.f\nN: %d", rad, draw_list->_CalcCircleAutoSegmentCount(rad));
|
||||
|
||||
const float canvas_width = IM_MAX(min_widget_width, rad * 2.0f);
|
||||
@ -7235,7 +7271,7 @@ struct ExampleAppConsole
|
||||
|
||||
// Reserve enough left-over height for 1 separator + 1 input text
|
||||
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_NavFlattened, ImGuiWindowFlags_HorizontalScrollbar))
|
||||
{
|
||||
if (ImGui::BeginPopupContextWindow())
|
||||
{
|
||||
@ -7709,58 +7745,188 @@ static void ShowExampleAppLayout(bool* p_open)
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Example App: Property Editor / ShowExampleAppPropertyEditor()
|
||||
// [SECTION] Helpers: ExampleTreeNode, ExampleMemberInfo (for use by Property Editor etc.)
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void ShowPlaceholderObject(const char* prefix, int uid)
|
||||
// Simple representation for a tree
|
||||
// (this is designed to be simple to understand for our demos, not to be efficient etc.)
|
||||
struct ExampleTreeNode
|
||||
{
|
||||
// Use object uid as identifier. Most commonly you could also use the object pointer as a base ID.
|
||||
ImGui::PushID(uid);
|
||||
char Name[28];
|
||||
ImGuiID UID = 0;
|
||||
ExampleTreeNode* Parent = NULL;
|
||||
ImVector<ExampleTreeNode*> Childs;
|
||||
|
||||
// Text and Tree nodes are less high than framed widgets, using AlignTextToFramePadding() we add vertical spacing to make the tree lines equal high.
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::AlignTextToFramePadding();
|
||||
bool node_open = ImGui::TreeNode("Object", "%s_%u", prefix, uid);
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImGui::Text("my sailor is rich");
|
||||
// Data
|
||||
bool HasData = false; // All leaves have data
|
||||
bool DataIsEnabled = false;
|
||||
int DataInt = 128;
|
||||
ImVec2 DataVec2 = ImVec2(0.0f, 3.141592f);
|
||||
};
|
||||
|
||||
if (node_open)
|
||||
// Simple representation of struct metadata/serialization data.
|
||||
// (this is a minimal version of what a typical advanced application may provide)
|
||||
struct ExampleMemberInfo
|
||||
{
|
||||
const char* Name;
|
||||
ImGuiDataType DataType;
|
||||
int DataCount;
|
||||
int Offset;
|
||||
};
|
||||
|
||||
// Metadata description of ExampleTreeNode struct.
|
||||
static const ExampleMemberInfo ExampleTreeNodeMemberInfos[]
|
||||
{
|
||||
{ "Enabled", ImGuiDataType_Bool, 1, offsetof(ExampleTreeNode, DataIsEnabled) },
|
||||
{ "MyInt", ImGuiDataType_S32, 1, offsetof(ExampleTreeNode, DataInt) },
|
||||
{ "MyVec2", ImGuiDataType_Float, 2, offsetof(ExampleTreeNode, DataVec2) },
|
||||
};
|
||||
|
||||
static ExampleTreeNode* ExampleTree_CreateNode(const char* name, const ImGuiID uid, ExampleTreeNode* parent)
|
||||
{
|
||||
ExampleTreeNode* node = IM_NEW(ExampleTreeNode);
|
||||
snprintf(node->Name, IM_ARRAYSIZE(node->Name), "%s", name);
|
||||
node->UID = uid;
|
||||
node->Parent = parent;
|
||||
if (parent)
|
||||
parent->Childs.push_back(node);
|
||||
return node;
|
||||
}
|
||||
|
||||
// Create example tree data
|
||||
static ExampleTreeNode* ExampleTree_CreateDemoTree()
|
||||
{
|
||||
static const char* root_names[] = { "Apple", "Banana", "Cherry", "Kiwi", "Mango", "Orange", "Pineapple", "Strawberry", "Watermelon" };
|
||||
char name_buf[32];
|
||||
ImGuiID uid = 0;
|
||||
ExampleTreeNode* node_L0 = ExampleTree_CreateNode("<ROOT>", ++uid, NULL);
|
||||
for (int idx_L0 = 0; idx_L0 < IM_ARRAYSIZE(root_names) * 2; idx_L0++)
|
||||
{
|
||||
static float placeholder_members[8] = { 0.0f, 0.0f, 1.0f, 3.1416f, 100.0f, 999.0f };
|
||||
for (int i = 0; i < 8; i++)
|
||||
snprintf(name_buf, 32, "%s %d", root_names[idx_L0 / 2], idx_L0 % 2);
|
||||
ExampleTreeNode* node_L1 = ExampleTree_CreateNode(name_buf, ++uid, node_L0);
|
||||
const int number_of_childs = (int)strlen(node_L1->Name);
|
||||
for (int idx_L1 = 0; idx_L1 < number_of_childs; idx_L1++)
|
||||
{
|
||||
ImGui::PushID(i); // Use field index as identifier.
|
||||
if (i < 2)
|
||||
snprintf(name_buf, 32, "Child %d", idx_L1);
|
||||
ExampleTreeNode* node_L2 = ExampleTree_CreateNode(name_buf, ++uid, node_L1);
|
||||
node_L2->HasData = true;
|
||||
if (idx_L1 == 0)
|
||||
{
|
||||
ShowPlaceholderObject("Child", 424242);
|
||||
snprintf(name_buf, 32, "Sub-child %d", 0);
|
||||
ExampleTreeNode* node_L3 = ExampleTree_CreateNode(name_buf, ++uid, node_L2);
|
||||
node_L3->HasData = true;
|
||||
}
|
||||
else
|
||||
}
|
||||
}
|
||||
return node_L0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Example App: Property Editor / ShowExampleAppPropertyEditor()
|
||||
//-----------------------------------------------------------------------------
|
||||
// Some of the interactions are a bit lack-luster:
|
||||
// - We would want the table scrolling window to use NavFlattened.
|
||||
// - We would want pressing validating or leaving the filter to somehow restore focus.
|
||||
// - We may want more advanced filtering (child nodes) and clipper support: both will need extra work.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
struct ExampleAppPropertyEditor
|
||||
{
|
||||
ImGuiTextFilter Filter;
|
||||
|
||||
void Draw(ExampleTreeNode* root_node)
|
||||
{
|
||||
ImGui::SetNextItemWidth(-FLT_MIN);
|
||||
ImGui::SetNextItemShortcut(ImGuiMod_Ctrl | ImGuiKey_F, ImGuiInputFlags_Tooltip);
|
||||
ImGui::PushItemFlag(ImGuiItemFlags_NoNavDefaultFocus, true);
|
||||
if (ImGui::InputTextWithHint("##Filter", "incl,-excl", Filter.InputBuf, IM_ARRAYSIZE(Filter.InputBuf), ImGuiInputTextFlags_EscapeClearsAll))
|
||||
Filter.Build();
|
||||
ImGui::PopItemFlag();
|
||||
|
||||
ImGuiTableFlags table_flags = ImGuiTableFlags_Resizable | ImGuiTableFlags_ScrollY | ImGuiTableFlags_RowBg;
|
||||
if (ImGui::BeginTable("##split", 2, table_flags))
|
||||
{
|
||||
ImGui::TableSetupColumn("Object", ImGuiTableColumnFlags_WidthStretch, 1.0f);
|
||||
ImGui::TableSetupColumn("Contents", ImGuiTableColumnFlags_WidthStretch, 2.0f); // Default twice larger
|
||||
//ImGui::TableSetupScrollFreeze(0, 1);
|
||||
//ImGui::TableHeadersRow();
|
||||
|
||||
for (ExampleTreeNode* node : root_node->Childs)
|
||||
if (Filter.PassFilter(node->Name)) // Filter root node
|
||||
DrawTreeNode(node);
|
||||
ImGui::EndTable();
|
||||
}
|
||||
}
|
||||
|
||||
void DrawTreeNode(ExampleTreeNode* node)
|
||||
{
|
||||
// Object tree node
|
||||
ImGui::PushID((int)node->UID);
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGuiTreeNodeFlags tree_flags = ImGuiTreeNodeFlags_None;
|
||||
tree_flags |= ImGuiTreeNodeFlags_SpanAllColumns | ImGuiTreeNodeFlags_AllowOverlap; // Highlight whole row for visibility
|
||||
tree_flags |= ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick; // Standard opening mode as we are likely to want to add selection afterwards
|
||||
tree_flags |= ImGuiTreeNodeFlags_NavLeftJumpsBackHere; // Left arrow support
|
||||
bool node_open = ImGui::TreeNodeEx("##Object", tree_flags, "%s", node->Name);
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImGui::TextDisabled("UID: 0x%08X", node->UID);
|
||||
|
||||
// Display child and data
|
||||
if (node_open)
|
||||
for (ExampleTreeNode* child : node->Childs)
|
||||
DrawTreeNode(child);
|
||||
if (node_open && node->HasData)
|
||||
{
|
||||
// In a typical application, the structure description would be derived from a data-driven system.
|
||||
// - We try to mimic this with our ExampleMemberInfo structure and the ExampleTreeNodeMemberInfos[] array.
|
||||
// - Limits and some details are hard-coded to simplify the demo.
|
||||
// - Text and Selectable are less high than framed widgets, using AlignTextToFramePadding() we add vertical spacing to make the selectable lines equal high.
|
||||
for (const ExampleMemberInfo& field_desc : ExampleTreeNodeMemberInfos)
|
||||
{
|
||||
// Here we use a TreeNode to highlight on hover (we could use e.g. Selectable as well)
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_Bullet;
|
||||
ImGui::TreeNodeEx("Field", flags, "Field_%d", i);
|
||||
|
||||
ImGui::PushItemFlag(ImGuiItemFlags_NoTabStop | ImGuiItemFlags_NoNav, true);
|
||||
ImGui::Selectable(field_desc.Name, false, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowOverlap);
|
||||
ImGui::PopItemFlag();
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImGui::SetNextItemWidth(-FLT_MIN);
|
||||
if (i >= 5)
|
||||
ImGui::InputFloat("##value", &placeholder_members[i], 1.0f);
|
||||
else
|
||||
ImGui::DragFloat("##value", &placeholder_members[i], 0.01f);
|
||||
ImGui::NextColumn();
|
||||
ImGui::PushID(field_desc.Name);
|
||||
void* field_ptr = (void*)(((unsigned char*)node) + field_desc.Offset);
|
||||
switch (field_desc.DataType)
|
||||
{
|
||||
case ImGuiDataType_Bool:
|
||||
{
|
||||
IM_ASSERT(field_desc.DataCount == 1);
|
||||
ImGui::Checkbox("##Editor", (bool*)field_ptr);
|
||||
break;
|
||||
}
|
||||
case ImGuiDataType_S32:
|
||||
{
|
||||
int v_min = INT_MIN, v_max = INT_MAX;
|
||||
ImGui::SetNextItemWidth(-FLT_MIN);
|
||||
ImGui::DragScalarN("##Editor", field_desc.DataType, field_ptr, field_desc.DataCount, 1.0f, &v_min, &v_max);
|
||||
break;
|
||||
}
|
||||
case ImGuiDataType_Float:
|
||||
{
|
||||
float v_min = 0.0f, v_max = 1.0f;
|
||||
ImGui::SetNextItemWidth(-FLT_MIN);
|
||||
ImGui::SliderScalarN("##Editor", field_desc.DataType, field_ptr, field_desc.DataCount, &v_min, &v_max);
|
||||
break;
|
||||
}
|
||||
}
|
||||
ImGui::PopID();
|
||||
}
|
||||
ImGui::PopID();
|
||||
}
|
||||
ImGui::TreePop();
|
||||
if (node_open)
|
||||
ImGui::TreePop();
|
||||
ImGui::PopID();
|
||||
}
|
||||
ImGui::PopID();
|
||||
}
|
||||
};
|
||||
|
||||
// Demonstrate create a simple property editor.
|
||||
// This demo is a bit lackluster nowadays, would be nice to improve.
|
||||
// Demonstrate creating a simple property editor.
|
||||
static void ShowExampleAppPropertyEditor(bool* p_open)
|
||||
{
|
||||
ImGui::SetNextWindowSize(ImVec2(430, 450), ImGuiCond_FirstUseEver);
|
||||
@ -7771,25 +7937,10 @@ static void ShowExampleAppPropertyEditor(bool* p_open)
|
||||
}
|
||||
|
||||
IMGUI_DEMO_MARKER("Examples/Property Editor");
|
||||
HelpMarker(
|
||||
"This example shows how you may implement a property editor using two columns.\n"
|
||||
"All objects/fields data are dummies here.\n");
|
||||
static ExampleAppPropertyEditor property_editor;
|
||||
static ExampleTreeNode* tree_data = ExampleTree_CreateDemoTree();
|
||||
property_editor.Draw(tree_data);
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2, 2));
|
||||
if (ImGui::BeginTable("##split", 2, ImGuiTableFlags_BordersOuter | ImGuiTableFlags_Resizable | ImGuiTableFlags_ScrollY))
|
||||
{
|
||||
ImGui::TableSetupScrollFreeze(0, 1);
|
||||
ImGui::TableSetupColumn("Object");
|
||||
ImGui::TableSetupColumn("Contents");
|
||||
ImGui::TableHeadersRow();
|
||||
|
||||
// Iterate placeholder objects (all the same data)
|
||||
for (int obj_i = 0; obj_i < 4; obj_i++)
|
||||
ShowPlaceholderObject("Object", obj_i);
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
@ -8611,6 +8762,7 @@ void ShowExampleAppDocuments(bool* p_open)
|
||||
// Submit Tab Bar and Tabs
|
||||
{
|
||||
ImGuiTabBarFlags tab_bar_flags = (opt_fitting_flags) | (opt_reorderable ? ImGuiTabBarFlags_Reorderable : 0);
|
||||
tab_bar_flags |= ImGuiTabBarFlags_DrawSelectedOverline;
|
||||
if (ImGui::BeginTabBar("##tabs", tab_bar_flags))
|
||||
{
|
||||
if (opt_reorderable)
|
||||
|
35
external/imgui/imgui/imgui_draw.cpp
vendored
35
external/imgui/imgui/imgui_draw.cpp
vendored
@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.90.7
|
||||
// dear imgui, v1.91.0 WIP
|
||||
// (drawing and font code)
|
||||
|
||||
/*
|
||||
@ -211,11 +211,13 @@ void ImGui::StyleColorsDark(ImGuiStyle* dst)
|
||||
colors[ImGuiCol_ResizeGrip] = ImVec4(0.26f, 0.59f, 0.98f, 0.20f);
|
||||
colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f);
|
||||
colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f);
|
||||
colors[ImGuiCol_Tab] = ImLerp(colors[ImGuiCol_Header], colors[ImGuiCol_TitleBgActive], 0.80f);
|
||||
colors[ImGuiCol_TabHovered] = colors[ImGuiCol_HeaderHovered];
|
||||
colors[ImGuiCol_TabActive] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f);
|
||||
colors[ImGuiCol_TabUnfocused] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
|
||||
colors[ImGuiCol_TabUnfocusedActive] = ImLerp(colors[ImGuiCol_TabActive], colors[ImGuiCol_TitleBg], 0.40f);
|
||||
colors[ImGuiCol_Tab] = ImLerp(colors[ImGuiCol_Header], colors[ImGuiCol_TitleBgActive], 0.80f);
|
||||
colors[ImGuiCol_TabSelected] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f);
|
||||
colors[ImGuiCol_TabSelectedOverline] = colors[ImGuiCol_HeaderActive];
|
||||
colors[ImGuiCol_TabDimmed] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
|
||||
colors[ImGuiCol_TabDimmedSelected] = ImLerp(colors[ImGuiCol_TabSelected], colors[ImGuiCol_TitleBg], 0.40f);
|
||||
colors[ImGuiCol_TabDimmedSelectedOverline] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f);
|
||||
colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f);
|
||||
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
|
||||
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
||||
@ -225,6 +227,7 @@ void ImGui::StyleColorsDark(ImGuiStyle* dst)
|
||||
colors[ImGuiCol_TableBorderLight] = ImVec4(0.23f, 0.23f, 0.25f, 1.00f); // Prefer using Alpha=1.0 here
|
||||
colors[ImGuiCol_TableRowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
|
||||
colors[ImGuiCol_TableRowBgAlt] = ImVec4(1.00f, 1.00f, 1.00f, 0.06f);
|
||||
colors[ImGuiCol_TextLink] = colors[ImGuiCol_HeaderActive];
|
||||
colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f);
|
||||
colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f);
|
||||
colors[ImGuiCol_NavHighlight] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
|
||||
@ -271,11 +274,13 @@ void ImGui::StyleColorsClassic(ImGuiStyle* dst)
|
||||
colors[ImGuiCol_ResizeGrip] = ImVec4(1.00f, 1.00f, 1.00f, 0.10f);
|
||||
colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.78f, 0.82f, 1.00f, 0.60f);
|
||||
colors[ImGuiCol_ResizeGripActive] = ImVec4(0.78f, 0.82f, 1.00f, 0.90f);
|
||||
colors[ImGuiCol_Tab] = ImLerp(colors[ImGuiCol_Header], colors[ImGuiCol_TitleBgActive], 0.80f);
|
||||
colors[ImGuiCol_TabHovered] = colors[ImGuiCol_HeaderHovered];
|
||||
colors[ImGuiCol_TabActive] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f);
|
||||
colors[ImGuiCol_TabUnfocused] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
|
||||
colors[ImGuiCol_TabUnfocusedActive] = ImLerp(colors[ImGuiCol_TabActive], colors[ImGuiCol_TitleBg], 0.40f);
|
||||
colors[ImGuiCol_Tab] = ImLerp(colors[ImGuiCol_Header], colors[ImGuiCol_TitleBgActive], 0.80f);
|
||||
colors[ImGuiCol_TabSelected] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f);
|
||||
colors[ImGuiCol_TabSelectedOverline] = colors[ImGuiCol_HeaderActive];
|
||||
colors[ImGuiCol_TabDimmed] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
|
||||
colors[ImGuiCol_TabDimmedSelected] = ImLerp(colors[ImGuiCol_TabSelected], colors[ImGuiCol_TitleBg], 0.40f);
|
||||
colors[ImGuiCol_TabDimmedSelectedOverline] = colors[ImGuiCol_HeaderActive];
|
||||
colors[ImGuiCol_PlotLines] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
|
||||
colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
||||
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
||||
@ -285,6 +290,7 @@ void ImGui::StyleColorsClassic(ImGuiStyle* dst)
|
||||
colors[ImGuiCol_TableBorderLight] = ImVec4(0.26f, 0.26f, 0.28f, 1.00f); // Prefer using Alpha=1.0 here
|
||||
colors[ImGuiCol_TableRowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
|
||||
colors[ImGuiCol_TableRowBgAlt] = ImVec4(1.00f, 1.00f, 1.00f, 0.07f);
|
||||
colors[ImGuiCol_TextLink] = colors[ImGuiCol_HeaderActive];
|
||||
colors[ImGuiCol_TextSelectedBg] = ImVec4(0.00f, 0.00f, 1.00f, 0.35f);
|
||||
colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f);
|
||||
colors[ImGuiCol_NavHighlight] = colors[ImGuiCol_HeaderHovered];
|
||||
@ -332,11 +338,13 @@ void ImGui::StyleColorsLight(ImGuiStyle* dst)
|
||||
colors[ImGuiCol_ResizeGrip] = ImVec4(0.35f, 0.35f, 0.35f, 0.17f);
|
||||
colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f);
|
||||
colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f);
|
||||
colors[ImGuiCol_Tab] = ImLerp(colors[ImGuiCol_Header], colors[ImGuiCol_TitleBgActive], 0.90f);
|
||||
colors[ImGuiCol_TabHovered] = colors[ImGuiCol_HeaderHovered];
|
||||
colors[ImGuiCol_TabActive] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f);
|
||||
colors[ImGuiCol_TabUnfocused] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
|
||||
colors[ImGuiCol_TabUnfocusedActive] = ImLerp(colors[ImGuiCol_TabActive], colors[ImGuiCol_TitleBg], 0.40f);
|
||||
colors[ImGuiCol_Tab] = ImLerp(colors[ImGuiCol_Header], colors[ImGuiCol_TitleBgActive], 0.90f);
|
||||
colors[ImGuiCol_TabSelected] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f);
|
||||
colors[ImGuiCol_TabSelectedOverline] = colors[ImGuiCol_HeaderActive];
|
||||
colors[ImGuiCol_TabDimmed] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
|
||||
colors[ImGuiCol_TabDimmedSelected] = ImLerp(colors[ImGuiCol_TabSelected], colors[ImGuiCol_TitleBg], 0.40f);
|
||||
colors[ImGuiCol_TabDimmedSelectedOverline] = ImVec4(0.26f, 0.59f, 1.00f, 1.00f);
|
||||
colors[ImGuiCol_PlotLines] = ImVec4(0.39f, 0.39f, 0.39f, 1.00f);
|
||||
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
|
||||
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
||||
@ -346,6 +354,7 @@ void ImGui::StyleColorsLight(ImGuiStyle* dst)
|
||||
colors[ImGuiCol_TableBorderLight] = ImVec4(0.68f, 0.68f, 0.74f, 1.00f); // Prefer using Alpha=1.0 here
|
||||
colors[ImGuiCol_TableRowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
|
||||
colors[ImGuiCol_TableRowBgAlt] = ImVec4(0.30f, 0.30f, 0.30f, 0.09f);
|
||||
colors[ImGuiCol_TextLink] = colors[ImGuiCol_HeaderActive];
|
||||
colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f);
|
||||
colors[ImGuiCol_DragDropTarget] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f);
|
||||
colors[ImGuiCol_NavHighlight] = colors[ImGuiCol_HeaderHovered];
|
||||
|
250
external/imgui/imgui/imgui_internal.h
vendored
250
external/imgui/imgui/imgui_internal.h
vendored
@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.90.7
|
||||
// dear imgui, v1.91.0 WIP
|
||||
// (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.
|
||||
@ -14,8 +14,8 @@ Index of this file:
|
||||
// [SECTION] Macros
|
||||
// [SECTION] Generic helpers
|
||||
// [SECTION] ImDrawList support
|
||||
// [SECTION] Widgets support: flags, enums, data structures
|
||||
// [SECTION] Data types support
|
||||
// [SECTION] Widgets support: flags, enums, data structures
|
||||
// [SECTION] Popup support
|
||||
// [SECTION] Inputs support
|
||||
// [SECTION] Clipper support
|
||||
@ -135,7 +135,6 @@ struct ImGuiLastItemData; // Status storage for last submitted items
|
||||
struct ImGuiLocEntry; // A localization entry.
|
||||
struct ImGuiMenuColumns; // Simple column measurement, currently used for MenuItem() only
|
||||
struct ImGuiNavItemData; // Result of a gamepad/keyboard directional navigation move query result
|
||||
struct ImGuiNavTreeNodeData; // Temporary storage for last TreeNode() being a Left arrow landing candidate.
|
||||
struct ImGuiMetricsConfig; // Storage for ShowMetricsWindow() and DebugNodeXXX() functions
|
||||
struct ImGuiNextWindowData; // Storage for SetNextWindow** functions
|
||||
struct ImGuiNextItemData; // Storage for SetNextItem** functions
|
||||
@ -154,6 +153,7 @@ 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 ImGuiTableSettings; // Storage for a table .ini settings
|
||||
struct ImGuiTableColumnsSettings; // Storage for a column .ini settings
|
||||
struct ImGuiTreeNodeStackData; // Temporary storage for TreeNode().
|
||||
struct ImGuiTypingSelectState; // Storage for GetTypingSelectRequest()
|
||||
struct ImGuiTypingSelectRequest; // Storage for GetTypingSelectRequest() (aimed to be public)
|
||||
struct ImGuiWindow; // Storage for one window
|
||||
@ -169,7 +169,6 @@ typedef int ImGuiLayoutType; // -> enum ImGuiLayoutType_ // E
|
||||
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 ImGuiFocusRequestFlags; // -> enum ImGuiFocusRequestFlags_ // Flags: for FocusWindow();
|
||||
typedef int ImGuiItemFlags; // -> enum ImGuiItemFlags_ // Flags: for PushItemFlag(), g.LastItemData.InFlags
|
||||
typedef int ImGuiItemStatusFlags; // -> enum ImGuiItemStatusFlags_ // Flags: for g.LastItemData.StatusFlags
|
||||
typedef int ImGuiOldColumnFlags; // -> enum ImGuiOldColumnFlags_ // Flags: for BeginColumns()
|
||||
typedef int ImGuiNavHighlightFlags; // -> enum ImGuiNavHighlightFlags_ // Flags: for RenderNavHighlight()
|
||||
@ -348,6 +347,7 @@ namespace ImStb
|
||||
// - Helper: ImPool<>
|
||||
// - Helper: ImChunkStream<>
|
||||
// - Helper: ImGuiTextIndex
|
||||
// - Helper: ImGuiStorage
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Helpers: Hashing
|
||||
@ -472,7 +472,7 @@ template<typename T> static inline T ImSubClampOverflow(T a, T b, T mn, T mx)
|
||||
// - Misc maths helpers
|
||||
static inline ImVec2 ImMin(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x < rhs.x ? lhs.x : rhs.x, lhs.y < rhs.y ? lhs.y : rhs.y); }
|
||||
static inline ImVec2 ImMax(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x >= rhs.x ? lhs.x : rhs.x, lhs.y >= rhs.y ? lhs.y : rhs.y); }
|
||||
static inline ImVec2 ImClamp(const ImVec2& v, const ImVec2& mn, ImVec2 mx) { return ImVec2((v.x < mn.x) ? mn.x : (v.x > mx.x) ? mx.x : v.x, (v.y < mn.y) ? mn.y : (v.y > mx.y) ? mx.y : v.y); }
|
||||
static inline ImVec2 ImClamp(const ImVec2& v, const ImVec2&mn, const ImVec2&mx) { return ImVec2((v.x < mn.x) ? mn.x : (v.x > mx.x) ? mx.x : v.x, (v.y < mn.y) ? mn.y : (v.y > mx.y) ? mx.y : v.y); }
|
||||
static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, float t) { return ImVec2(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t); }
|
||||
static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, const ImVec2& t) { return ImVec2(a.x + (b.x - a.x) * t.x, a.y + (b.y - a.y) * t.y); }
|
||||
static inline ImVec4 ImLerp(const ImVec4& a, const ImVec4& b, float t) { return ImVec4(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t, a.w + (b.w - a.w) * t); }
|
||||
@ -722,7 +722,7 @@ struct ImChunkStream
|
||||
void swap(ImChunkStream<T>& rhs) { rhs.Buf.swap(Buf); }
|
||||
};
|
||||
|
||||
// Helper: ImGuiTextIndex<>
|
||||
// Helper: ImGuiTextIndex
|
||||
// Maintain a line index for a text buffer. This is a strong candidate to be moved into the public API.
|
||||
struct ImGuiTextIndex
|
||||
{
|
||||
@ -736,6 +736,8 @@ struct ImGuiTextIndex
|
||||
void append(const char* base, int old_size, int new_size);
|
||||
};
|
||||
|
||||
// Helper: ImGuiStorage
|
||||
IMGUI_API ImGuiStoragePair* ImLowerBound(ImGuiStoragePair* in_begin, ImGuiStoragePair* in_end, ImGuiID key);
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] ImDrawList support
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -772,6 +774,7 @@ struct IMGUI_API ImDrawListSharedData
|
||||
ImVec2 TexUvWhitePixel; // UV of white pixel in the atlas
|
||||
ImFont* Font; // Current/default font (optional, for simplified AddText overload)
|
||||
float FontSize; // Current/default font size (optional, for simplified AddText overload)
|
||||
float FontScale; // Current/default font scale (== FontSize / Font->FontSize)
|
||||
float CurveTessellationTol; // Tessellation tolerance when using PathBezierCurveTo()
|
||||
float CircleSegmentMaxError; // Number of circle segments to use per pixel of radius for AddCircle() etc
|
||||
ImVec4 ClipRectFullscreen; // Value for PushClipRectFullscreen()
|
||||
@ -798,33 +801,64 @@ struct ImDrawDataBuilder
|
||||
ImDrawDataBuilder() { memset(this, 0, sizeof(*this)); }
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [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 ImGuiDataTypeStorage
|
||||
{
|
||||
ImU8 Data[8]; // Opaque storage to 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] Widgets support: flags, enums, data structures
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Flags used by upcoming items
|
||||
// Extend ImGuiItemFlags
|
||||
// - input: PushItemFlag() manipulates g.CurrentItemFlags, ItemAdd() calls may add extra flags.
|
||||
// - output: stored in g.LastItemData.InFlags
|
||||
// Current window shared by all windows.
|
||||
// This is going to be exposed in imgui.h when stabilized enough.
|
||||
enum ImGuiItemFlags_
|
||||
enum ImGuiItemFlagsPrivate_
|
||||
{
|
||||
// Controlled by user
|
||||
ImGuiItemFlags_None = 0,
|
||||
ImGuiItemFlags_NoTabStop = 1 << 0, // false // Disable keyboard tabbing. This is a "lighter" version of ImGuiItemFlags_NoNav.
|
||||
ImGuiItemFlags_ButtonRepeat = 1 << 1, // false // Button() will return true multiple times based on io.KeyRepeatDelay and io.KeyRepeatRate settings.
|
||||
ImGuiItemFlags_Disabled = 1 << 2, // false // Disable interactions but doesn't affect visuals. See BeginDisabled()/EndDisabled(). See github.com/ocornut/imgui/issues/211
|
||||
ImGuiItemFlags_NoNav = 1 << 3, // false // Disable any form of focusing (keyboard/gamepad directional navigation and SetKeyboardFocusHere() calls)
|
||||
ImGuiItemFlags_NoNavDefaultFocus = 1 << 4, // false // Disable item being a candidate for default focus (e.g. used by title bar items)
|
||||
ImGuiItemFlags_SelectableDontClosePopup = 1 << 5, // false // Disable MenuItem/Selectable() automatically closing their popup window
|
||||
ImGuiItemFlags_MixedValue = 1 << 6, // false // [BETA] Represent a mixed/indeterminate value, generally multi-selection where values differ. Currently only supported by Checkbox() (later should support all sorts of widgets)
|
||||
ImGuiItemFlags_ReadOnly = 1 << 7, // false // [ALPHA] Allow hovering interactions but underlying value is not changed.
|
||||
ImGuiItemFlags_NoWindowHoverableCheck = 1 << 8, // false // Disable hoverable check in ItemHoverable()
|
||||
ImGuiItemFlags_AllowOverlap = 1 << 9, // false // Allow being overlapped by another widget. Not-hovered to Hovered transition deferred by a frame.
|
||||
ImGuiItemFlags_Disabled = 1 << 10, // false // Disable interactions (DOES NOT affect visuals, see BeginDisabled()/EndDisabled() for full disable feature, and github #211).
|
||||
ImGuiItemFlags_ReadOnly = 1 << 11, // false // [ALPHA] Allow hovering interactions but underlying value is not changed.
|
||||
ImGuiItemFlags_MixedValue = 1 << 12, // false // [BETA] Represent a mixed/indeterminate value, generally multi-selection where values differ. Currently only supported by Checkbox() (later should support all sorts of widgets)
|
||||
ImGuiItemFlags_NoWindowHoverableCheck = 1 << 13, // false // Disable hoverable check in ItemHoverable()
|
||||
ImGuiItemFlags_AllowOverlap = 1 << 14, // false // Allow being overlapped by another widget. Not-hovered to Hovered transition deferred by a frame.
|
||||
|
||||
// Controlled by widget code
|
||||
ImGuiItemFlags_Inputable = 1 << 10, // false // [WIP] Auto-activate input mode when tab focused. Currently only used and supported by a few items before it becomes a generic feature.
|
||||
ImGuiItemFlags_HasSelectionUserData = 1 << 11, // false // Set by SetNextItemSelectionUserData()
|
||||
ImGuiItemFlags_Inputable = 1 << 20, // false // [WIP] Auto-activate input mode when tab focused. Currently only used and supported by a few items before it becomes a generic feature.
|
||||
ImGuiItemFlags_HasSelectionUserData = 1 << 21, // false // Set by SetNextItemSelectionUserData()
|
||||
|
||||
ImGuiItemFlags_Default_ = ImGuiItemFlags_AutoClosePopups, // Please don't change, use PushItemFlag() instead.
|
||||
|
||||
// Obsolete
|
||||
//ImGuiItemFlags_SelectableDontClosePopup = !ImGuiItemFlags_AutoClosePopups, // Can't have a redirect as we inverted the behavior
|
||||
};
|
||||
|
||||
// Status flags for an already submitted item
|
||||
@ -927,8 +961,8 @@ enum ImGuiSelectableFlagsPrivate_
|
||||
// Extend ImGuiTreeNodeFlags_
|
||||
enum ImGuiTreeNodeFlagsPrivate_
|
||||
{
|
||||
ImGuiTreeNodeFlags_ClipLabelForTrailingButton = 1 << 20,
|
||||
ImGuiTreeNodeFlags_UpsideDownArrow = 1 << 21,// (FIXME-WIP) Turn Down arrow into an Up arrow, but reversed trees (#6517)
|
||||
ImGuiTreeNodeFlags_ClipLabelForTrailingButton = 1 << 28,// FIXME-WIP: Hard-coded for CollapsingHeader()
|
||||
ImGuiTreeNodeFlags_UpsideDownArrow = 1 << 29,// FIXME-WIP: Turn Down arrow into an Up arrow, but reversed trees (#6517)
|
||||
};
|
||||
|
||||
enum ImGuiSeparatorFlags_
|
||||
@ -1177,6 +1211,7 @@ enum ImGuiNextItemDataFlags_
|
||||
ImGuiNextItemDataFlags_HasWidth = 1 << 0,
|
||||
ImGuiNextItemDataFlags_HasOpen = 1 << 1,
|
||||
ImGuiNextItemDataFlags_HasShortcut = 1 << 2,
|
||||
ImGuiNextItemDataFlags_HasRefVal = 1 << 3,
|
||||
};
|
||||
|
||||
struct ImGuiNextItemData
|
||||
@ -1189,7 +1224,8 @@ struct ImGuiNextItemData
|
||||
ImGuiKeyChord Shortcut; // Set by SetNextItemShortcut()
|
||||
ImGuiInputFlags ShortcutFlags; // Set by SetNextItemShortcut()
|
||||
bool OpenVal; // Set by SetNextItemOpen()
|
||||
ImGuiCond OpenCond : 8;
|
||||
ImU8 OpenCond; // Set by SetNextItemOpen()
|
||||
ImGuiDataTypeStorage RefVal; // Not exposed yet, for ImGuiInputTextFlags_ParseEmptyAsRefVal
|
||||
|
||||
ImGuiNextItemData() { memset(this, 0, sizeof(*this)); SelectionUserData = -1; }
|
||||
inline void ClearFlags() { Flags = ImGuiNextItemDataFlags_None; ItemFlags = ImGuiItemFlags_None; } // Also cleared manually by ItemAdd()!
|
||||
@ -1211,14 +1247,16 @@ struct ImGuiLastItemData
|
||||
ImGuiLastItemData() { memset(this, 0, sizeof(*this)); }
|
||||
};
|
||||
|
||||
// Store data emitted by TreeNode() for usage by TreePop() to implement ImGuiTreeNodeFlags_NavLeftJumpsBackHere.
|
||||
// This is the minimum amount of data that we need to perform the equivalent of NavApplyItemToResult() and which we can't infer in TreePop()
|
||||
// Only stored when the node is a potential candidate for landing on a Left arrow jump.
|
||||
struct ImGuiNavTreeNodeData
|
||||
// Store data emitted by TreeNode() for usage by TreePop()
|
||||
// - To implement ImGuiTreeNodeFlags_NavLeftJumpsBackHere: store the minimum amount of data
|
||||
// which we can't infer in TreePop(), to perform the equivalent of NavApplyItemToResult().
|
||||
// Only stored when the node is a potential candidate for landing on a Left arrow jump.
|
||||
struct ImGuiTreeNodeStackData
|
||||
{
|
||||
ImGuiID ID;
|
||||
ImGuiItemFlags InFlags;
|
||||
ImRect NavRect;
|
||||
ImGuiTreeNodeFlags TreeFlags;
|
||||
ImGuiItemFlags InFlags; // Used for nav landing
|
||||
ImRect NavRect; // Used for nav landing
|
||||
};
|
||||
|
||||
struct IMGUI_API ImGuiStackSizes
|
||||
@ -1243,7 +1281,8 @@ struct ImGuiWindowStackData
|
||||
{
|
||||
ImGuiWindow* Window;
|
||||
ImGuiLastItemData ParentLastItemDataBackup;
|
||||
ImGuiStackSizes StackSizesOnBegin; // Store size of various stacks for asserting
|
||||
ImGuiStackSizes StackSizesOnBegin; // Store size of various stacks for asserting
|
||||
bool DisabledOverrideReenable; // Non-child window override disabled flag
|
||||
};
|
||||
|
||||
struct ImGuiShrinkWidthItem
|
||||
@ -1262,40 +1301,6 @@ struct ImGuiPtrOrIndex
|
||||
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
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -1582,6 +1587,7 @@ enum ImGuiNavLayer
|
||||
ImGuiNavLayer_COUNT
|
||||
};
|
||||
|
||||
// Storage for navigation query/results
|
||||
struct ImGuiNavItemData
|
||||
{
|
||||
ImGuiWindow* Window; // Init,Move // Best candidate window (result->ItemWindow->RootWindowForNav == request->Window)
|
||||
@ -1592,12 +1598,13 @@ struct ImGuiNavItemData
|
||||
float DistBox; // Move // Best candidate box distance to current NavId
|
||||
float DistCenter; // Move // Best candidate center distance to current NavId
|
||||
float DistAxial; // Move // Best candidate axial distance to current NavId
|
||||
ImGuiSelectionUserData SelectionUserData;//I+Mov // Best candidate SetNextItemSelectionData() value.
|
||||
ImGuiSelectionUserData SelectionUserData;//I+Mov // Best candidate SetNextItemSelectionUserData() value. Valid if (InFlags & ImGuiItemFlags_HasSelectionUserData)
|
||||
|
||||
ImGuiNavItemData() { Clear(); }
|
||||
void Clear() { Window = NULL; ID = FocusScopeId = 0; InFlags = 0; SelectionUserData = -1; DistBox = DistCenter = DistAxial = FLT_MAX; }
|
||||
};
|
||||
|
||||
// Storage for PushFocusScope()
|
||||
struct ImGuiFocusScopeData
|
||||
{
|
||||
ImGuiID ID;
|
||||
@ -1798,6 +1805,7 @@ enum ImGuiLocKey : int
|
||||
ImGuiLocKey_WindowingMainMenuBar,
|
||||
ImGuiLocKey_WindowingPopup,
|
||||
ImGuiLocKey_WindowingUntitled,
|
||||
ImGuiLocKey_CopyLink,
|
||||
ImGuiLocKey_COUNT
|
||||
};
|
||||
|
||||
@ -1919,6 +1927,7 @@ struct ImGuiContext
|
||||
ImFont* Font; // (Shortcut) == FontStack.empty() ? IO.Font : FontStack.back()
|
||||
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 FontScale; // == FontSize / Font->FontSize
|
||||
float CurrentDpiScale; // Current window/viewport DpiScale
|
||||
ImDrawListSharedData DrawListSharedData;
|
||||
double Time;
|
||||
@ -1931,6 +1940,7 @@ struct ImGuiContext
|
||||
bool GcCompactAll; // Request full GC
|
||||
bool TestEngineHookItems; // Will call test engine hooks: ImGuiTestEngineHook_ItemAdd(), ImGuiTestEngineHook_ItemInfo(), ImGuiTestEngineHook_Log()
|
||||
void* TestEngine; // Test engine user data
|
||||
char ContextName[16]; // Storage for a context name (to facilitate debugging multi-context setups)
|
||||
|
||||
// Inputs
|
||||
ImVector<ImGuiInputEvent> InputEventsQueue; // Input events which will be trickled/written into IO structure.
|
||||
@ -1950,6 +1960,7 @@ struct ImGuiContext
|
||||
ImGuiWindow* CurrentWindow; // Window being drawn into
|
||||
ImGuiWindow* HoveredWindow; // Window the mouse is hovering. Will typically catch mouse inputs.
|
||||
ImGuiWindow* HoveredWindowUnderMovingWindow; // Hovered window ignoring MovingWindow. Only set if MovingWindow is set.
|
||||
ImGuiWindow* HoveredWindowBeforeClear; // Window the mouse is hovering. Filled even with _NoMouse. This is currently useful for multi-context compositors.
|
||||
ImGuiWindow* MovingWindow; // Track the window we clicked on (in order to preserve focus). The actual window that is moved is generally MovingWindow->RootWindow.
|
||||
ImGuiWindow* WheelingWindow; // Track the window we started mouse-wheeling on. Until a timer elapse or mouse has moved, generally keep scrolling the same window even if during the course of scrolling the mouse ends up hovering a child window.
|
||||
ImVec2 WheelingWindowRefMousePos;
|
||||
@ -1963,10 +1974,11 @@ struct ImGuiContext
|
||||
ImGuiID DebugHookIdInfo; // Will call core hooks: DebugHookIdInfo() from GetID functions, used by ID Stack Tool [next HoveredId/ActiveId to not pull in an extra cache-line]
|
||||
ImGuiID HoveredId; // Hovered widget, filled during the frame
|
||||
ImGuiID HoveredIdPreviousFrame;
|
||||
bool HoveredIdAllowOverlap;
|
||||
bool HoveredIdDisabled; // At least one widget passed the rect test, but has been discarded by disabled flag or popup inhibit. May be true even if HoveredId == 0.
|
||||
float HoveredIdTimer; // Measure contiguous hovering time
|
||||
float HoveredIdNotActiveTimer; // Measure contiguous hovering time where the item has not been active
|
||||
bool HoveredIdAllowOverlap;
|
||||
bool HoveredIdIsDisabled; // At least one widget passed the rect test, but has been discarded by disabled flag or popup inhibit. May be true even if HoveredId == 0.
|
||||
bool ItemUnclipByLog; // Disable ItemAdd() clipping, essentially a memory-locality friendly copy of LogEnabled
|
||||
ImGuiID ActiveId; // Active widget
|
||||
ImGuiID ActiveIdIsAlive; // Active widget has been seen this frame (we can't use a bool as the ActiveId may change within the frame)
|
||||
float ActiveIdTimer;
|
||||
@ -2024,7 +2036,7 @@ struct ImGuiContext
|
||||
ImVector<ImGuiGroupData> GroupStack; // Stack for BeginGroup()/EndGroup() - not inherited by Begin()
|
||||
ImVector<ImGuiPopupData> OpenPopupStack; // Which popups are open (persistent)
|
||||
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<ImGuiTreeNodeStackData>TreeNodeStack; // Stack for TreeNode()
|
||||
|
||||
// Viewports
|
||||
ImVector<ImGuiViewportP*> Viewports; // Active viewports (Size==1 in 'master' branch). Each viewports hold their copy of ImDrawData.
|
||||
@ -2033,20 +2045,17 @@ struct ImGuiContext
|
||||
ImGuiWindow* NavWindow; // Focused window for navigation. Could be called 'FocusedWindow'
|
||||
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)
|
||||
ImVector<ImGuiFocusScopeData> NavFocusRoute; // Reversed copy focus scope stack for NavId (should contains NavFocusScopeId). This essentially follow the window->ParentWindowForFocusRoute chain.
|
||||
ImGuiNavLayer NavLayer; // Focused layer (main scrolling layer, or menu/title bar layer)
|
||||
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 NavActivatePressedId; // ~~ IsKeyPressed(ImGuiKey_Space) || IsKeyPressed(ImGuiKey_Enter) || IsKeyPressed(ImGuiKey_NavGamepadActivate) ? NavId : 0 (no repeat)
|
||||
ImGuiActivateFlags NavActivateFlags;
|
||||
ImVector<ImGuiFocusScopeData> NavFocusRoute; // Reversed copy focus scope stack for NavId (should contains NavFocusScopeId). This essentially follow the window->ParentWindowForFocusRoute chain.
|
||||
ImGuiID NavHighlightActivatedId;
|
||||
float NavHighlightActivatedTimer;
|
||||
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).
|
||||
ImGuiKeyChord NavJustMovedToKeyMods;
|
||||
ImGuiID NavNextActivateId; // Set by ActivateItem(), queued until next frame.
|
||||
ImGuiActivateFlags NavNextActivateFlags;
|
||||
ImGuiInputSource NavInputSource; // Keyboard or Gamepad mode? THIS CAN ONLY BE ImGuiInputSource_Keyboard or ImGuiInputSource_Mouse
|
||||
ImGuiNavLayer NavLayer; // Layer we are navigating on. For now the system is hard-coded for 0=main contents and 1=menu/title bar, may expose layers later.
|
||||
ImGuiSelectionUserData NavLastValidSelectionUserData; // Last valid data passed to SetNextItemSelectionUser(), or -1. For current window. Not reset when focusing an item that doesn't have selection data.
|
||||
bool NavIdIsAlive; // Nav widget has been seen this frame ~~ NavRectRel is valid
|
||||
bool NavMousePosDirty; // When set we will update mouse position if (io.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) if set (NB: this not enabled by default)
|
||||
@ -2077,6 +2086,14 @@ struct ImGuiContext
|
||||
ImGuiNavItemData NavMoveResultOther; // Best move request candidate within NavWindow's flattened hierarchy (when using ImGuiWindowFlags_NavFlattened flag)
|
||||
ImGuiNavItemData NavTabbingResultFirst; // First tabbing request candidate within NavWindow and flattened hierarchy
|
||||
|
||||
// Navigation: record of last move request
|
||||
ImGuiID NavJustMovedFromFocusScopeId; // Just navigated from this focus scope 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).
|
||||
ImGuiKeyChord NavJustMovedToKeyMods;
|
||||
bool NavJustMovedToIsTabbing; // Copy of ImGuiNavMoveFlags_IsTabbing. Maybe we should store whole flags.
|
||||
bool NavJustMovedToHasSelectionData; // Copy of move result's InFlags & ImGuiItemFlags_HasSelectionUserData). Maybe we should just store ImGuiNavItemData.
|
||||
|
||||
// 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 ConfigNavWindowingKeyPrev; // = ImGuiMod_Ctrl | ImGuiMod_Shift | ImGuiKey_Tab (or ImGuiMod_Super | ImGuiMod_Shift | ImGuiKey_Tab on OS X)
|
||||
@ -2150,6 +2167,7 @@ struct ImGuiContext
|
||||
ImGuiInputTextDeactivatedState InputTextDeactivatedState;
|
||||
ImFont InputTextPasswordFont;
|
||||
ImGuiID TempInputId; // Temporary text input when CTRL+clicking on a slider, etc.
|
||||
ImGuiDataTypeStorage DataTypeZeroValue; // 0 for all data types
|
||||
int BeginMenuDepth;
|
||||
int BeginComboDepth;
|
||||
ImGuiColorEditFlags ColorEditOptions; // Store user options for color edit widgets
|
||||
@ -2162,13 +2180,14 @@ struct ImGuiContext
|
||||
ImGuiComboPreviewData ComboPreviewData;
|
||||
ImRect WindowResizeBorderExpectedRect; // Expected border rect, switch to relative edit if moving
|
||||
bool WindowResizeRelativeMode;
|
||||
short ScrollbarSeekMode; // 0: relative, -1/+1: prev/next page.
|
||||
float ScrollbarClickDeltaToGrabCenter; // Distance between mouse and center of grab box, normalized in parent space. Use storage?
|
||||
float SliderGrabClickOffset;
|
||||
float SliderCurrentAccum; // Accumulated slider delta when using navigation controls.
|
||||
bool SliderCurrentAccumDirty; // Has the accumulated slider delta changed since last time we tried to apply it?
|
||||
bool DragCurrentAccumDirty;
|
||||
float DragCurrentAccum; // Accumulator for dragging modification. Always high-precision, not rounded by end-user precision settings
|
||||
float DragSpeedDefaultRatio; // If speed == 0.0f, uses (max-min) * DragSpeedDefaultRatio
|
||||
float ScrollbarClickDeltaToGrabCenter; // Distance between mouse and center of grab box, normalized in parent space. Use storage?
|
||||
float DisabledAlphaBackup; // Backup for style.Alpha for BeginDisabled()
|
||||
short DisabledStackSize;
|
||||
short LockMarkEdited;
|
||||
@ -2179,7 +2198,7 @@ struct ImGuiContext
|
||||
|
||||
// Platform support
|
||||
ImGuiPlatformImeData PlatformImeData; // Data updated by current frame
|
||||
ImGuiPlatformImeData PlatformImeDataPrev; // Previous frame data (when changing we will call io.SetPlatformImeDataFn
|
||||
ImGuiPlatformImeData PlatformImeDataPrev; // Previous frame data. When changed we call the io.PlatformSetImeDataFn() handler.
|
||||
|
||||
// Settings
|
||||
bool SettingsLoaded;
|
||||
@ -2246,7 +2265,7 @@ struct ImGuiContext
|
||||
Initialized = false;
|
||||
FontAtlasOwnedByContext = shared_font_atlas ? false : true;
|
||||
Font = NULL;
|
||||
FontSize = FontBaseSize = CurrentDpiScale = 0.0f;
|
||||
FontSize = FontBaseSize = FontScale = CurrentDpiScale = 0.0f;
|
||||
IO.Fonts = shared_font_atlas ? shared_font_atlas : IM_NEW(ImFontAtlas)();
|
||||
Time = 0.0f;
|
||||
FrameCount = 0;
|
||||
@ -2255,6 +2274,7 @@ struct ImGuiContext
|
||||
GcCompactAll = false;
|
||||
TestEngineHookItems = false;
|
||||
TestEngine = NULL;
|
||||
memset(ContextName, 0, sizeof(ContextName));
|
||||
|
||||
InputEventsNextMouseSource = ImGuiMouseSource_Mouse;
|
||||
InputEventsNextEventId = 1;
|
||||
@ -2263,6 +2283,7 @@ struct ImGuiContext
|
||||
CurrentWindow = NULL;
|
||||
HoveredWindow = NULL;
|
||||
HoveredWindowUnderMovingWindow = NULL;
|
||||
HoveredWindowBeforeClear = NULL;
|
||||
MovingWindow = NULL;
|
||||
WheelingWindow = NULL;
|
||||
WheelingWindowStartFrame = WheelingWindowScrolledFrame = -1;
|
||||
@ -2271,8 +2292,9 @@ struct ImGuiContext
|
||||
DebugHookIdInfo = 0;
|
||||
HoveredId = HoveredIdPreviousFrame = 0;
|
||||
HoveredIdAllowOverlap = false;
|
||||
HoveredIdDisabled = false;
|
||||
HoveredIdIsDisabled = false;
|
||||
HoveredIdTimer = HoveredIdNotActiveTimer = 0.0f;
|
||||
ItemUnclipByLog = false;
|
||||
ActiveId = 0;
|
||||
ActiveIdIsAlive = 0;
|
||||
ActiveIdTimer = 0.0f;
|
||||
@ -2308,18 +2330,18 @@ struct ImGuiContext
|
||||
|
||||
NavWindow = NULL;
|
||||
NavId = NavFocusScopeId = NavActivateId = NavActivateDownId = NavActivatePressedId = 0;
|
||||
NavJustMovedToId = NavJustMovedToFocusScopeId = NavNextActivateId = 0;
|
||||
NavLayer = ImGuiNavLayer_Main;
|
||||
NavNextActivateId = 0;
|
||||
NavActivateFlags = NavNextActivateFlags = ImGuiActivateFlags_None;
|
||||
NavHighlightActivatedId = 0;
|
||||
NavHighlightActivatedTimer = 0.0f;
|
||||
NavJustMovedToKeyMods = ImGuiMod_None;
|
||||
NavInputSource = ImGuiInputSource_Keyboard;
|
||||
NavLayer = ImGuiNavLayer_Main;
|
||||
NavLastValidSelectionUserData = ImGuiSelectionUserData_Invalid;
|
||||
NavIdIsAlive = false;
|
||||
NavMousePosDirty = false;
|
||||
NavDisableHighlight = true;
|
||||
NavDisableMouseHover = false;
|
||||
|
||||
NavAnyRequest = false;
|
||||
NavInitRequest = false;
|
||||
NavInitRequestFromMove = false;
|
||||
@ -2334,6 +2356,11 @@ struct ImGuiContext
|
||||
NavTabbingDir = 0;
|
||||
NavTabbingCounter = 0;
|
||||
|
||||
NavJustMovedFromFocusScopeId = NavJustMovedToId = NavJustMovedToFocusScopeId = 0;
|
||||
NavJustMovedToKeyMods = ImGuiMod_None;
|
||||
NavJustMovedToIsTabbing = false;
|
||||
NavJustMovedToHasSelectionData = false;
|
||||
|
||||
// All platforms use Ctrl+Tab but Ctrl<>Super are swapped on Mac...
|
||||
// FIXME: Because this value is stored, it annoyingly interfere with toggling io.ConfigMacOSXBehaviors updating this..
|
||||
ConfigNavWindowingKeyNext = IO.ConfigMacOSXBehaviors ? (ImGuiMod_Super | ImGuiKey_Tab) : (ImGuiMod_Ctrl | ImGuiKey_Tab);
|
||||
@ -2370,19 +2397,21 @@ struct ImGuiContext
|
||||
MouseStationaryTimer = 0.0f;
|
||||
|
||||
TempInputId = 0;
|
||||
memset(&DataTypeZeroValue, 0, sizeof(DataTypeZeroValue));
|
||||
BeginMenuDepth = BeginComboDepth = 0;
|
||||
ColorEditOptions = ImGuiColorEditFlags_DefaultOptions_;
|
||||
ColorEditCurrentID = ColorEditSavedID = 0;
|
||||
ColorEditSavedHue = ColorEditSavedSat = 0.0f;
|
||||
ColorEditSavedColor = 0;
|
||||
WindowResizeRelativeMode = false;
|
||||
ScrollbarSeekMode = 0;
|
||||
ScrollbarClickDeltaToGrabCenter = 0.0f;
|
||||
SliderGrabClickOffset = 0.0f;
|
||||
SliderCurrentAccum = 0.0f;
|
||||
SliderCurrentAccumDirty = false;
|
||||
DragCurrentAccumDirty = false;
|
||||
DragCurrentAccum = 0.0f;
|
||||
DragSpeedDefaultRatio = 1.0f / 100.0f;
|
||||
ScrollbarClickDeltaToGrabCenter = 0.0f;
|
||||
DisabledAlphaBackup = 0.0f;
|
||||
DisabledStackSize = 0;
|
||||
LockMarkEdited = 0;
|
||||
@ -2472,7 +2501,7 @@ struct IMGUI_API ImGuiWindowTempData
|
||||
ImVec2 MenuBarOffset; // MenuBarOffset.x is sort of equivalent of a per-layer CursorPos.x, saved/restored as we switch to the menu bar. The only situation when MenuBarOffset.y is > 0 if when (SafeAreaPadding.y > FramePadding.y), often used on TVs.
|
||||
ImGuiMenuColumns MenuColumns; // Simplified columns storage for menu items measurement
|
||||
int TreeDepth; // Current tree depth.
|
||||
ImU32 TreeJumpToParentOnPopMask; // Store a copy of !g.NavIdIsAlive for TreeDepth 0..31.. Could be turned into a ImU64 if necessary.
|
||||
ImU32 TreeHasStackDataDepthMask; // Store whether given depth has ImGuiTreeNodeStackData data. Could be turned into a ImU64 if necessary.
|
||||
ImVector<ImGuiWindow*> ChildWindows;
|
||||
ImGuiStorage* StateStorage; // Current persistent per-window storage (store e.g. tree node open/close state)
|
||||
ImGuiOldColumns* CurrentColumns; // Current columns set
|
||||
@ -2507,12 +2536,14 @@ struct IMGUI_API ImGuiWindow
|
||||
ImVec2 WindowPadding; // Window padding at the time of Begin().
|
||||
float WindowRounding; // Window rounding at the time of Begin(). May be clamped lower to avoid rendering artifacts with title bar, menu bar etc.
|
||||
float WindowBorderSize; // Window border size at the time of Begin().
|
||||
float TitleBarHeight, MenuBarHeight;
|
||||
float DecoOuterSizeX1, DecoOuterSizeY1; // Left/Up offsets. Sum of non-scrolling outer decorations (X1 generally == 0.0f. Y1 generally = TitleBarHeight + MenuBarHeight). Locked during Begin().
|
||||
float DecoOuterSizeX2, DecoOuterSizeY2; // Right/Down offsets (X2 generally == ScrollbarSize.x, Y2 == ScrollbarSizes.y).
|
||||
float DecoInnerSizeX1, DecoInnerSizeY1; // Applied AFTER/OVER InnerRect. Specialized for Tables as they use specialized form of clipping and frozen rows/columns are inside InnerRect (and not part of regular decoration sizes).
|
||||
int NameBufLen; // Size of buffer storing Name. May be larger than strlen(Name)!
|
||||
ImGuiID MoveId; // == window->GetID("#MOVE")
|
||||
ImGuiID ChildId; // ID of corresponding item in parent window (for navigation to return from child window to parent window)
|
||||
ImGuiID PopupId; // ID in the popup stack when this window is used as a popup/menu (because we use generic Name/ID for recycling)
|
||||
ImVec2 Scroll;
|
||||
ImVec2 ScrollMax;
|
||||
ImVec2 ScrollTarget; // target scroll position. stored as cursor position with scrolling canceled out, so the highest point is always 0.0f. (FLT_MAX for no change)
|
||||
@ -2539,7 +2570,6 @@ struct IMGUI_API ImGuiWindow
|
||||
short BeginOrderWithinParent; // Begin() order within immediate parent window, if we are a child window. Otherwise 0.
|
||||
short BeginOrderWithinContext; // Begin() order within entire imgui context. This is mostly used for debugging submission order related issues.
|
||||
short FocusOrder; // Order within WindowsFocusOrder[], altered when windows are focused.
|
||||
ImGuiID PopupId; // ID in the popup stack when this window is used as a popup/menu (because we use generic Name/ID for recycling)
|
||||
ImS8 AutoFitFramesX, AutoFitFramesY;
|
||||
bool AutoFitOnlyGrows;
|
||||
ImGuiDir AutoPosLastDirection;
|
||||
@ -2608,10 +2638,8 @@ public:
|
||||
// We don't use g.FontSize because the window may be != g.CurrentWindow.
|
||||
ImRect Rect() const { return ImRect(Pos.x, Pos.y, Pos.x + Size.x, Pos.y + Size.y); }
|
||||
float CalcFontSize() const { ImGuiContext& g = *Ctx; float scale = g.FontBaseSize * FontWindowScale; if (ParentWindow) scale *= ParentWindow->FontWindowScale; return scale; }
|
||||
float TitleBarHeight() const { ImGuiContext& g = *Ctx; return (Flags & ImGuiWindowFlags_NoTitleBar) ? 0.0f : CalcFontSize() + g.Style.FramePadding.y * 2.0f; }
|
||||
ImRect TitleBarRect() const { return ImRect(Pos, ImVec2(Pos.x + SizeFull.x, Pos.y + TitleBarHeight())); }
|
||||
float MenuBarHeight() const { ImGuiContext& g = *Ctx; return (Flags & ImGuiWindowFlags_MenuBar) ? DC.MenuBarOffset.y + CalcFontSize() + g.Style.FramePadding.y * 2.0f : 0.0f; }
|
||||
ImRect MenuBarRect() const { float y1 = Pos.y + TitleBarHeight(); return ImRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight()); }
|
||||
ImRect TitleBarRect() const { return ImRect(Pos, ImVec2(Pos.x + SizeFull.x, Pos.y + TitleBarHeight)); }
|
||||
ImRect MenuBarRect() const { float y1 = Pos.y + TitleBarHeight; return ImRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight); }
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -2992,7 +3020,7 @@ namespace ImGui
|
||||
{
|
||||
// Windows
|
||||
// We should always have a CurrentWindow in the stack (there is an implicit "Debug" window)
|
||||
// If this ever crash because g.CurrentWindow is NULL it means that either
|
||||
// If this ever crashes because g.CurrentWindow is NULL, it means that either:
|
||||
// - ImGui::NewFrame() has never been called, which is illegal.
|
||||
// - You are calling ImGui functions after ImGui::EndFrame()/ImGui::Render() and before the next ImGui::NewFrame(), which is also illegal.
|
||||
inline ImGuiWindow* GetCurrentWindowRead() { ImGuiContext& g = *GImGui; return g.CurrentWindow; }
|
||||
@ -3121,9 +3149,9 @@ namespace ImGui
|
||||
IMGUI_API void ShrinkWidths(ImGuiShrinkWidthItem* items, int count, float width_excess);
|
||||
|
||||
// Parameter stacks (shared)
|
||||
IMGUI_API void PushItemFlag(ImGuiItemFlags option, bool enabled);
|
||||
IMGUI_API void PopItemFlag();
|
||||
IMGUI_API const ImGuiDataVarInfo* GetStyleVarInfo(ImGuiStyleVar idx);
|
||||
IMGUI_API void BeginDisabledOverrideReenable();
|
||||
IMGUI_API void EndDisabledOverrideReenable();
|
||||
|
||||
// Logging/Capture
|
||||
IMGUI_API void LogBegin(ImGuiLogType type, int auto_open_depth); // -> BeginCapture() when we design v2 api, for now stay under the radar by using the old name.
|
||||
@ -3131,16 +3159,16 @@ namespace ImGui
|
||||
IMGUI_API void LogRenderedText(const ImVec2* ref_pos, const char* text, const char* text_end = NULL);
|
||||
IMGUI_API void LogSetNextTextDecoration(const char* prefix, const char* suffix);
|
||||
|
||||
// Popups, Modals, Tooltips
|
||||
// Childs
|
||||
IMGUI_API bool BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, ImGuiChildFlags child_flags, ImGuiWindowFlags window_flags);
|
||||
|
||||
// Popups, Modals
|
||||
IMGUI_API bool BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_window_flags);
|
||||
IMGUI_API void OpenPopupEx(ImGuiID id, ImGuiPopupFlags popup_flags = ImGuiPopupFlags_None);
|
||||
IMGUI_API void ClosePopupToLevel(int remaining, bool restore_focus_to_window_under_popup);
|
||||
IMGUI_API void ClosePopupsOverWindow(ImGuiWindow* ref_window, bool restore_focus_to_window_under_popup);
|
||||
IMGUI_API void ClosePopupsExceptModals();
|
||||
IMGUI_API bool IsPopupOpen(ImGuiID id, ImGuiPopupFlags popup_flags);
|
||||
IMGUI_API bool BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags);
|
||||
IMGUI_API bool BeginTooltipEx(ImGuiTooltipFlags tooltip_flags, ImGuiWindowFlags extra_window_flags);
|
||||
IMGUI_API bool BeginTooltipHidden();
|
||||
IMGUI_API ImRect GetPopupAllowedExtentRect(ImGuiWindow* window);
|
||||
IMGUI_API ImGuiWindow* GetTopMostPopupModal();
|
||||
IMGUI_API ImGuiWindow* GetTopMostAndVisiblePopupModal();
|
||||
@ -3148,6 +3176,10 @@ namespace ImGui
|
||||
IMGUI_API ImVec2 FindBestWindowPosForPopup(ImGuiWindow* window);
|
||||
IMGUI_API ImVec2 FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& size, ImGuiDir* last_dir, const ImRect& r_outer, const ImRect& r_avoid, ImGuiPopupPositionPolicy policy);
|
||||
|
||||
// Tooltips
|
||||
IMGUI_API bool BeginTooltipEx(ImGuiTooltipFlags tooltip_flags, ImGuiWindowFlags extra_window_flags);
|
||||
IMGUI_API bool BeginTooltipHidden();
|
||||
|
||||
// Menus
|
||||
IMGUI_API bool BeginViewportSideBar(const char* name, ImGuiViewport* viewport, ImGuiDir dir, float size, ImGuiWindowFlags window_flags);
|
||||
IMGUI_API bool BeginMenuEx(const char* label, const char* icon, bool enabled = true);
|
||||
@ -3165,7 +3197,7 @@ namespace ImGui
|
||||
IMGUI_API void NavMoveRequestSubmit(ImGuiDir move_dir, ImGuiDir clip_dir, ImGuiNavMoveFlags move_flags, ImGuiScrollFlags scroll_flags);
|
||||
IMGUI_API void NavMoveRequestForward(ImGuiDir move_dir, ImGuiDir clip_dir, ImGuiNavMoveFlags move_flags, ImGuiScrollFlags scroll_flags);
|
||||
IMGUI_API void NavMoveRequestResolveWithLastItem(ImGuiNavItemData* result);
|
||||
IMGUI_API void NavMoveRequestResolveWithPastTreeNode(ImGuiNavItemData* result, ImGuiNavTreeNodeData* tree_node_data);
|
||||
IMGUI_API void NavMoveRequestResolveWithPastTreeNode(ImGuiNavItemData* result, ImGuiTreeNodeStackData* tree_node_data);
|
||||
IMGUI_API void NavMoveRequestCancel();
|
||||
IMGUI_API void NavMoveRequestApplyResult();
|
||||
IMGUI_API void NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags move_flags);
|
||||
@ -3309,7 +3341,6 @@ namespace ImGui
|
||||
IMGUI_API void TableOpenContextMenu(int column_n = -1);
|
||||
IMGUI_API void TableSetColumnWidth(int column_n, float width);
|
||||
IMGUI_API void TableSetColumnSortDirection(int column_n, ImGuiSortDirection sort_direction, bool append_to_sort_specs);
|
||||
IMGUI_API int TableGetHoveredColumn(); // May use (TableGetColumnFlags() & ImGuiTableColumnFlags_IsHovered) instead. Return hovered column. return -1 when table is not hovered. return columns_count if the unused space at the right of visible columns is hovered.
|
||||
IMGUI_API int TableGetHoveredRow(); // Retrieve *PREVIOUS FRAME* hovered row. This difference with TableGetHoveredColumn() is the reason why this is not public yet.
|
||||
IMGUI_API float TableGetHeaderRowHeight();
|
||||
IMGUI_API float TableGetHeaderAngledMaxLabelWidth();
|
||||
@ -3430,12 +3461,15 @@ namespace ImGui
|
||||
IMGUI_API bool DragBehavior(ImGuiID id, ImGuiDataType data_type, void* p_v, float v_speed, const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags);
|
||||
IMGUI_API bool SliderBehavior(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, void* p_v, const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags, ImRect* out_grab_bb);
|
||||
IMGUI_API bool SplitterBehavior(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float* size1, float* size2, float min_size1, float min_size2, float hover_extend = 0.0f, float hover_visibility_delay = 0.0f, ImU32 bg_col = 0);
|
||||
IMGUI_API bool TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end = NULL);
|
||||
IMGUI_API void TreePushOverrideID(ImGuiID id);
|
||||
IMGUI_API void TreeNodeSetOpen(ImGuiID id, bool open);
|
||||
IMGUI_API bool TreeNodeUpdateNextOpen(ImGuiID id, ImGuiTreeNodeFlags flags); // Return open state. Consume previous SetNextItemOpen() data, if any. May return true when logging.
|
||||
IMGUI_API void SetNextItemSelectionUserData(ImGuiSelectionUserData selection_user_data);
|
||||
|
||||
// Widgets: Tree Nodes
|
||||
IMGUI_API bool TreeNodeBehavior(ImGuiID id, ImGuiID storage_id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end = NULL);
|
||||
IMGUI_API void TreePushOverrideID(ImGuiID id);
|
||||
IMGUI_API bool TreeNodeGetOpen(ImGuiID storage_id);
|
||||
IMGUI_API void TreeNodeSetOpen(ImGuiID storage_id, bool open);
|
||||
IMGUI_API bool TreeNodeUpdateNextOpen(ImGuiID storage_id, ImGuiTreeNodeFlags flags); // Return open state. Consume previous SetNextItemOpen() data, if any. May return true when logging.
|
||||
|
||||
// Template functions are instantiated in imgui_widgets.cpp for a finite number of types.
|
||||
// To use them externally (for custom widget) you may need an "extern template" statement in your code in order to link to existing instances and silence Clang warnings (see #2036).
|
||||
// e.g. " extern template IMGUI_API float RoundScalarWithFormatT<float, float>(const char* format, ImGuiDataType data_type, float v); "
|
||||
@ -3450,7 +3484,7 @@ namespace ImGui
|
||||
IMGUI_API const ImGuiDataTypeInfo* DataTypeGetInfo(ImGuiDataType data_type);
|
||||
IMGUI_API int DataTypeFormatString(char* buf, int buf_size, ImGuiDataType data_type, const void* p_data, const char* format);
|
||||
IMGUI_API void DataTypeApplyOp(ImGuiDataType data_type, int op, void* output, const void* arg_1, const void* arg_2);
|
||||
IMGUI_API bool DataTypeApplyFromText(const char* buf, ImGuiDataType data_type, void* p_data, const char* format);
|
||||
IMGUI_API bool DataTypeApplyFromText(const char* buf, ImGuiDataType data_type, void* p_data, const char* format, void* p_data_when_empty = NULL);
|
||||
IMGUI_API int DataTypeCompare(ImGuiDataType data_type, const void* arg_1, const void* arg_2);
|
||||
IMGUI_API bool DataTypeClamp(ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max);
|
||||
|
||||
@ -3461,6 +3495,7 @@ namespace ImGui
|
||||
IMGUI_API bool TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* p_data, const char* format, const void* p_clamp_min = NULL, const void* p_clamp_max = NULL);
|
||||
inline bool TempInputIsActive(ImGuiID id) { ImGuiContext& g = *GImGui; return (g.ActiveId == id && g.TempInputId == id); }
|
||||
inline ImGuiInputTextState* GetInputTextState(ImGuiID id) { ImGuiContext& g = *GImGui; return (id != 0 && g.InputTextState.ID == id) ? &g.InputTextState : NULL; } // Get input text state if active
|
||||
IMGUI_API void SetNextItemRefVal(ImGuiDataType data_type, void* p_data);
|
||||
|
||||
// Color
|
||||
IMGUI_API void ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags flags);
|
||||
@ -3480,18 +3515,15 @@ namespace ImGui
|
||||
IMGUI_API void GcCompactTransientWindowBuffers(ImGuiWindow* window);
|
||||
IMGUI_API void GcAwakeTransientWindowBuffers(ImGuiWindow* window);
|
||||
|
||||
// Debug Log
|
||||
IMGUI_API void DebugLog(const char* fmt, ...) IM_FMTARGS(1);
|
||||
IMGUI_API void DebugLogV(const char* fmt, va_list args) IM_FMTLIST(1);
|
||||
IMGUI_API void DebugAllocHook(ImGuiDebugAllocInfo* info, int frame_count, void* ptr, size_t size); // size >= 0 : alloc, size = -1 : free
|
||||
|
||||
// Debug Tools
|
||||
IMGUI_API void DebugAllocHook(ImGuiDebugAllocInfo* info, int frame_count, void* ptr, size_t size); // size >= 0 : alloc, size = -1 : free
|
||||
IMGUI_API void ErrorCheckEndFrameRecover(ImGuiErrorLogCallback log_callback, void* user_data = NULL);
|
||||
IMGUI_API void ErrorCheckEndWindowRecover(ImGuiErrorLogCallback log_callback, void* user_data = NULL);
|
||||
IMGUI_API void ErrorCheckUsingSetCursorPosToExtendParentBoundaries();
|
||||
IMGUI_API void DebugDrawCursorPos(ImU32 col = IM_COL32(255, 0, 0, 255));
|
||||
IMGUI_API void DebugDrawLineExtents(ImU32 col = IM_COL32(255, 0, 0, 255));
|
||||
IMGUI_API void DebugDrawItemRect(ImU32 col = IM_COL32(255, 0, 0, 255));
|
||||
IMGUI_API void DebugTextUnformattedWithLocateItem(const char* line_begin, const char* line_end);
|
||||
IMGUI_API void DebugLocateItem(ImGuiID target_id); // Call sparingly: only 1 at the same time!
|
||||
IMGUI_API void DebugLocateItemOnHover(ImGuiID target_id); // Only call on reaction to a mouse Hover: because only 1 at the same time!
|
||||
IMGUI_API void DebugLocateItemResolveWithLastItem();
|
||||
|
29
external/imgui/imgui/imgui_tables.cpp
vendored
29
external/imgui/imgui/imgui_tables.cpp
vendored
@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.90.7
|
||||
// dear imgui, v1.91.0 WIP
|
||||
// (tables and columns code)
|
||||
|
||||
/*
|
||||
@ -412,8 +412,8 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
|
||||
SetNextWindowScroll(ImVec2(0.0f, 0.0f));
|
||||
|
||||
// Create scrolling region (without border and zero window padding)
|
||||
ImGuiWindowFlags child_flags = (flags & ImGuiTableFlags_ScrollX) ? ImGuiWindowFlags_HorizontalScrollbar : ImGuiWindowFlags_None;
|
||||
BeginChildEx(name, instance_id, outer_rect.GetSize(), false, child_flags);
|
||||
ImGuiWindowFlags child_window_flags = (flags & ImGuiTableFlags_ScrollX) ? ImGuiWindowFlags_HorizontalScrollbar : ImGuiWindowFlags_None;
|
||||
BeginChildEx(name, instance_id, outer_rect.GetSize(), ImGuiChildFlags_None, child_window_flags);
|
||||
table->InnerWindow = g.CurrentWindow;
|
||||
table->WorkRect = table->InnerWindow->WorkRect;
|
||||
table->OuterRect = table->InnerWindow->Rect();
|
||||
@ -437,6 +437,7 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
|
||||
// For non-scrolling tables, WorkRect == OuterRect == InnerRect.
|
||||
// But at this point we do NOT have a correct value for .Max.y (unless a height has been explicitly passed in). It will only be updated in EndTable().
|
||||
table->WorkRect = table->OuterRect = table->InnerRect = outer_rect;
|
||||
table->HasScrollbarYPrev = table->HasScrollbarYCurr = false;
|
||||
}
|
||||
|
||||
// Push a standardized ID for both child-using and not-child-using tables
|
||||
@ -1490,9 +1491,13 @@ void ImGui::EndTable()
|
||||
}
|
||||
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);
|
||||
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));
|
||||
// Some references for this: #7651 + tests "table_reported_size", "table_reported_size_outer" equivalent Y block
|
||||
// - Checking for ImGuiTableFlags_ScrollX/ScrollY flag makes us a frame ahead when disabling those flags.
|
||||
// - FIXME-TABLE: Would make sense to pre-compute expected scrollbar visibility/sizes to generally save a frame of feedback.
|
||||
const float inner_content_max_x = table->OuterRect.Min.x + table->ColumnsAutoFitWidth; // Slightly misleading name but used for code symmetry with inner_content_max_y
|
||||
const float decoration_size = table->TempData->AngledHeadersExtraWidth + ((table->Flags & ImGuiTableFlags_ScrollY) ? inner_window->ScrollbarSizes.x : 0.0f);
|
||||
outer_window->DC.IdealMaxPos.x = ImMax(outer_window->DC.IdealMaxPos.x, inner_content_max_x + decoration_size - temp_data->UserOuterSize.x);
|
||||
outer_window->DC.CursorMaxPos.x = ImMax(backup_outer_max_pos.x, ImMin(table->OuterRect.Max.x, inner_content_max_x + decoration_size));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1500,9 +1505,9 @@ void ImGui::EndTable()
|
||||
}
|
||||
if (temp_data->UserOuterSize.y <= 0.0f)
|
||||
{
|
||||
const float decoration_size = (table->Flags & ImGuiTableFlags_ScrollY) ? inner_window->ScrollbarSizes.y : 0.0f;
|
||||
const float decoration_size = (table->Flags & ImGuiTableFlags_ScrollX) ? inner_window->ScrollbarSizes.y : 0.0f;
|
||||
outer_window->DC.IdealMaxPos.y = ImMax(outer_window->DC.IdealMaxPos.y, inner_content_max_y + decoration_size - temp_data->UserOuterSize.y);
|
||||
outer_window->DC.CursorMaxPos.y = ImMax(backup_outer_max_pos.y, ImMin(table->OuterRect.Max.y, inner_content_max_y));
|
||||
outer_window->DC.CursorMaxPos.y = ImMax(backup_outer_max_pos.y, ImMin(table->OuterRect.Max.y, inner_content_max_y + decoration_size));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2795,7 +2800,7 @@ ImGuiTableSortSpecs* ImGui::TableGetSortSpecs()
|
||||
static inline ImGuiSortDirection TableGetColumnAvailSortDirection(ImGuiTableColumn* column, int n)
|
||||
{
|
||||
IM_ASSERT(n < column->SortDirectionsAvailCount);
|
||||
return (column->SortDirectionsAvailList >> (n << 1)) & 0x03;
|
||||
return (ImGuiSortDirection)((column->SortDirectionsAvailList >> (n << 1)) & 0x03);
|
||||
}
|
||||
|
||||
// Fix sort direction if currently set on a value which is unavailable (e.g. activating NoSortAscending/NoSortDescending)
|
||||
@ -2949,7 +2954,7 @@ void ImGui::TableSortSpecsBuild(ImGuiTable* table)
|
||||
sort_spec->ColumnUserID = column->UserID;
|
||||
sort_spec->ColumnIndex = (ImGuiTableColumnIdx)column_n;
|
||||
sort_spec->SortOrder = (ImGuiTableColumnIdx)column->SortOrder;
|
||||
sort_spec->SortDirection = column->SortDirection;
|
||||
sort_spec->SortDirection = (ImGuiSortDirection)column->SortDirection;
|
||||
}
|
||||
|
||||
table->SortSpecs.Specs = sort_specs;
|
||||
@ -3264,7 +3269,7 @@ void ImGui::TableAngledHeadersRowEx(ImGuiID row_id, float angle, float max_label
|
||||
ButtonBehavior(row_r, row_id, NULL, NULL);
|
||||
KeepAliveID(row_id);
|
||||
|
||||
const float ascent_scaled = g.Font->Ascent * (g.FontSize / g.Font->FontSize); // FIXME: Standardize those scaling factors better
|
||||
const float ascent_scaled = g.Font->Ascent * g.FontScale; // FIXME: Standardize those scaling factors better
|
||||
const float line_off_for_ascent_x = (ImMax((g.FontSize - ascent_scaled) * 0.5f, 0.0f) / -sin_a) * (flip_label ? -1.0f : 1.0f);
|
||||
const ImVec2 padding = g.Style.CellPadding; // We will always use swapped component
|
||||
const ImVec2 align = g.Style.TableAngledHeadersTextAlign;
|
||||
@ -3466,7 +3471,7 @@ void ImGui::TableDrawDefaultContextMenu(ImGuiTable* table, ImGuiTableFlags flags
|
||||
Separator();
|
||||
want_separator = true;
|
||||
|
||||
PushItemFlag(ImGuiItemFlags_SelectableDontClosePopup, true);
|
||||
PushItemFlag(ImGuiItemFlags_AutoClosePopups, false);
|
||||
for (int other_column_n = 0; other_column_n < table->ColumnsCount; other_column_n++)
|
||||
{
|
||||
ImGuiTableColumn* other_column = &table->Columns[other_column_n];
|
||||
|
435
external/imgui/imgui/imgui_widgets.cpp
vendored
435
external/imgui/imgui/imgui_widgets.cpp
vendored
@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.90.7
|
||||
// dear imgui, v1.91.0 WIP
|
||||
// (widgets code)
|
||||
|
||||
/*
|
||||
@ -422,6 +422,7 @@ void ImGui::BulletTextV(const char* fmt, va_list args)
|
||||
// - RadioButton()
|
||||
// - ProgressBar()
|
||||
// - Bullet()
|
||||
// - Hyperlink()
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
// The ButtonBehavior() function is key to many interactions and used by many/most widgets.
|
||||
@ -488,7 +489,7 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
||||
|
||||
// Default only reacts to left mouse button
|
||||
if ((flags & ImGuiButtonFlags_MouseButtonMask_) == 0)
|
||||
flags |= ImGuiButtonFlags_MouseButtonDefault_;
|
||||
flags |= ImGuiButtonFlags_MouseButtonLeft;
|
||||
|
||||
// Default behavior requires click + release inside bounding box
|
||||
if ((flags & ImGuiButtonFlags_PressedOnMask_) == 0)
|
||||
@ -834,17 +835,15 @@ bool ImGui::CloseButton(ImGuiID id, const ImVec2& pos)
|
||||
return pressed;
|
||||
|
||||
// Render
|
||||
// FIXME: Clarify this mess
|
||||
ImU32 col = GetColorU32(held ? ImGuiCol_ButtonActive : ImGuiCol_ButtonHovered);
|
||||
ImVec2 center = bb.GetCenter();
|
||||
ImU32 bg_col = GetColorU32(held ? ImGuiCol_ButtonActive : ImGuiCol_ButtonHovered);
|
||||
if (hovered)
|
||||
window->DrawList->AddCircleFilled(center, ImMax(2.0f, g.FontSize * 0.5f + 1.0f), col);
|
||||
|
||||
float cross_extent = g.FontSize * 0.5f * 0.7071f - 1.0f;
|
||||
window->DrawList->AddRectFilled(bb.Min, bb.Max, bg_col);
|
||||
RenderNavHighlight(bb, id, ImGuiNavHighlightFlags_Compact);
|
||||
ImU32 cross_col = GetColorU32(ImGuiCol_Text);
|
||||
center -= ImVec2(0.5f, 0.5f);
|
||||
window->DrawList->AddLine(center + ImVec2(+cross_extent, +cross_extent), center + ImVec2(-cross_extent, -cross_extent), cross_col, 1.0f);
|
||||
window->DrawList->AddLine(center + ImVec2(+cross_extent, -cross_extent), center + ImVec2(-cross_extent, +cross_extent), cross_col, 1.0f);
|
||||
ImVec2 cross_center = bb.GetCenter() - ImVec2(0.5f, 0.5f);
|
||||
float cross_extent = g.FontSize * 0.5f * 0.7071f - 1.0f;
|
||||
window->DrawList->AddLine(cross_center + ImVec2(+cross_extent, +cross_extent), cross_center + ImVec2(-cross_extent, -cross_extent), cross_col, 1.0f);
|
||||
window->DrawList->AddLine(cross_center + ImVec2(+cross_extent, -cross_extent), cross_center + ImVec2(-cross_extent, +cross_extent), cross_col, 1.0f);
|
||||
|
||||
return pressed;
|
||||
}
|
||||
@ -865,7 +864,8 @@ bool ImGui::CollapseButton(ImGuiID id, const ImVec2& pos)
|
||||
ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
|
||||
ImU32 text_col = GetColorU32(ImGuiCol_Text);
|
||||
if (hovered || held)
|
||||
window->DrawList->AddCircleFilled(bb.GetCenter() + ImVec2(0.0f, -0.5f), g.FontSize * 0.5f + 1.0f, bg_col);
|
||||
window->DrawList->AddRectFilled(bb.Min, bb.Max, bg_col);
|
||||
RenderNavHighlight(bb, id, ImGuiNavHighlightFlags_Compact);
|
||||
RenderArrow(window->DrawList, bb.Min, text_col, window->Collapsed ? ImGuiDir_Right : ImGuiDir_Down, 1.0f);
|
||||
|
||||
// Switch to moving the window after mouse is moved beyond the initial drag threshold
|
||||
@ -916,10 +916,10 @@ void ImGui::Scrollbar(ImGuiAxis axis)
|
||||
if (!window->ScrollbarX)
|
||||
rounding_corners |= ImDrawFlags_RoundCornersBottomRight;
|
||||
}
|
||||
float size_avail = window->InnerRect.Max[axis] - window->InnerRect.Min[axis];
|
||||
float size_visible = window->InnerRect.Max[axis] - window->InnerRect.Min[axis];
|
||||
float size_contents = window->ContentSize[axis] + window->WindowPadding[axis] * 2.0f;
|
||||
ImS64 scroll = (ImS64)window->Scroll[axis];
|
||||
ScrollbarEx(bb, id, axis, &scroll, (ImS64)size_avail, (ImS64)size_contents, rounding_corners);
|
||||
ScrollbarEx(bb, id, axis, &scroll, (ImS64)size_visible, (ImS64)size_contents, rounding_corners);
|
||||
window->Scroll[axis] = (float)scroll;
|
||||
}
|
||||
|
||||
@ -929,7 +929,7 @@ void ImGui::Scrollbar(ImGuiAxis axis)
|
||||
// - We store values as normalized ratio and in a form that allows the window content to change while we are holding on a scrollbar
|
||||
// - We handle both horizontal and vertical scrollbars, which makes the terminology not ideal.
|
||||
// Still, the code should probably be made simpler..
|
||||
bool ImGui::ScrollbarEx(const ImRect& bb_frame, ImGuiID id, ImGuiAxis axis, ImS64* p_scroll_v, ImS64 size_avail_v, ImS64 size_contents_v, ImDrawFlags flags)
|
||||
bool ImGui::ScrollbarEx(const ImRect& bb_frame, ImGuiID id, ImGuiAxis axis, ImS64* p_scroll_v, ImS64 size_visible_v, ImS64 size_contents_v, ImDrawFlags flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
@ -959,9 +959,9 @@ bool ImGui::ScrollbarEx(const ImRect& bb_frame, ImGuiID id, ImGuiAxis axis, ImS6
|
||||
|
||||
// Calculate the height of our grabbable box. It generally represent the amount visible (vs the total scrollable amount)
|
||||
// But we maintain a minimum size in pixel to allow for the user to still aim inside.
|
||||
IM_ASSERT(ImMax(size_contents_v, size_avail_v) > 0.0f); // Adding this assert to check if the ImMax(XXX,1.0f) is still needed. PLEASE CONTACT ME if this triggers.
|
||||
const ImS64 win_size_v = ImMax(ImMax(size_contents_v, size_avail_v), (ImS64)1);
|
||||
const float grab_h_pixels = ImClamp(scrollbar_size_v * ((float)size_avail_v / (float)win_size_v), style.GrabMinSize, scrollbar_size_v);
|
||||
IM_ASSERT(ImMax(size_contents_v, size_visible_v) > 0.0f); // Adding this assert to check if the ImMax(XXX,1.0f) is still needed. PLEASE CONTACT ME if this triggers.
|
||||
const ImS64 win_size_v = ImMax(ImMax(size_contents_v, size_visible_v), (ImS64)1);
|
||||
const float grab_h_pixels = ImClamp(scrollbar_size_v * ((float)size_visible_v / (float)win_size_v), style.GrabMinSize, scrollbar_size_v);
|
||||
const float grab_h_norm = grab_h_pixels / scrollbar_size_v;
|
||||
|
||||
// Handle input right away. None of the code of Begin() is relying on scrolling position before calling Scrollbar().
|
||||
@ -970,7 +970,7 @@ bool ImGui::ScrollbarEx(const ImRect& bb_frame, ImGuiID id, ImGuiAxis axis, ImS6
|
||||
ItemAdd(bb_frame, id, NULL, ImGuiItemFlags_NoNav);
|
||||
ButtonBehavior(bb, id, &hovered, &held, ImGuiButtonFlags_NoNavFocus);
|
||||
|
||||
const ImS64 scroll_max = ImMax((ImS64)1, size_contents_v - size_avail_v);
|
||||
const ImS64 scroll_max = ImMax((ImS64)1, size_contents_v - size_visible_v);
|
||||
float scroll_ratio = ImSaturate((float)*p_scroll_v / (float)scroll_max);
|
||||
float grab_v_norm = scroll_ratio * (scrollbar_size_v - grab_h_pixels) / scrollbar_size_v; // Grab position in normalized space
|
||||
if (held && allow_interaction && grab_h_norm < 1.0f)
|
||||
@ -981,29 +981,39 @@ bool ImGui::ScrollbarEx(const ImRect& bb_frame, ImGuiID id, ImGuiAxis axis, ImS6
|
||||
// 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);
|
||||
|
||||
bool seek_absolute = false;
|
||||
const int held_dir = (clicked_v_norm < grab_v_norm) ? -1 : (clicked_v_norm > grab_v_norm + grab_h_norm) ? +1 : 0;
|
||||
if (g.ActiveIdIsJustActivated)
|
||||
{
|
||||
// On initial click calculate the distance between mouse and the center of the grab
|
||||
seek_absolute = (clicked_v_norm < grab_v_norm || clicked_v_norm > grab_v_norm + grab_h_norm);
|
||||
if (seek_absolute)
|
||||
g.ScrollbarClickDeltaToGrabCenter = 0.0f;
|
||||
else
|
||||
g.ScrollbarClickDeltaToGrabCenter = clicked_v_norm - grab_v_norm - grab_h_norm * 0.5f;
|
||||
g.ScrollbarSeekMode = (short)held_dir;
|
||||
g.ScrollbarClickDeltaToGrabCenter = (g.ScrollbarSeekMode == 0.0f) ? clicked_v_norm - grab_v_norm - grab_h_norm * 0.5f : 0.0f;
|
||||
}
|
||||
|
||||
// Apply scroll (p_scroll_v will generally point on one member of window->Scroll)
|
||||
// It is ok to modify Scroll here because we are being called in Begin() after the calculation of ContentSize and before setting up our starting position
|
||||
const float scroll_v_norm = ImSaturate((clicked_v_norm - g.ScrollbarClickDeltaToGrabCenter - grab_h_norm * 0.5f) / (1.0f - grab_h_norm));
|
||||
*p_scroll_v = (ImS64)(scroll_v_norm * scroll_max);
|
||||
if (g.ScrollbarSeekMode == 0)
|
||||
{
|
||||
// Absolute seeking
|
||||
const float scroll_v_norm = ImSaturate((clicked_v_norm - g.ScrollbarClickDeltaToGrabCenter - grab_h_norm * 0.5f) / (1.0f - grab_h_norm));
|
||||
*p_scroll_v = (ImS64)(scroll_v_norm * scroll_max);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Page by page
|
||||
if (IsMouseClicked(ImGuiMouseButton_Left, ImGuiInputFlags_Repeat) && held_dir == g.ScrollbarSeekMode)
|
||||
{
|
||||
float page_dir = (g.ScrollbarSeekMode > 0.0f) ? +1.0f : -1.0f;
|
||||
*p_scroll_v = ImClamp(*p_scroll_v + (ImS64)(page_dir * size_visible_v), (ImS64)0, scroll_max);
|
||||
}
|
||||
}
|
||||
|
||||
// Update values for rendering
|
||||
scroll_ratio = ImSaturate((float)*p_scroll_v / (float)scroll_max);
|
||||
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
|
||||
if (seek_absolute)
|
||||
g.ScrollbarClickDeltaToGrabCenter = clicked_v_norm - grab_v_norm - grab_h_norm * 0.5f;
|
||||
//if (seek_absolute)
|
||||
// g.ScrollbarClickDeltaToGrabCenter = clicked_v_norm - grab_v_norm - grab_h_norm * 0.5f;
|
||||
}
|
||||
|
||||
// Render
|
||||
@ -1122,7 +1132,8 @@ bool ImGui::Checkbox(const char* label, bool* v)
|
||||
const ImVec2 pos = window->DC.CursorPos;
|
||||
const ImRect total_bb(pos, pos + ImVec2(square_sz + (label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f), label_size.y + style.FramePadding.y * 2.0f));
|
||||
ItemSize(total_bb, style.FramePadding.y);
|
||||
if (!ItemAdd(total_bb, id))
|
||||
const bool is_visible = ItemAdd(total_bb, id);
|
||||
if (!is_visible)
|
||||
{
|
||||
IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Checkable | (*v ? ImGuiItemStatusFlags_Checked : 0));
|
||||
return false;
|
||||
@ -1137,27 +1148,29 @@ bool ImGui::Checkbox(const char* label, bool* v)
|
||||
}
|
||||
|
||||
const ImRect check_bb(pos, pos + ImVec2(square_sz, square_sz));
|
||||
RenderNavHighlight(total_bb, id);
|
||||
RenderFrame(check_bb.Min, check_bb.Max, GetColorU32((held && hovered) ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg), true, style.FrameRounding);
|
||||
ImU32 check_col = GetColorU32(ImGuiCol_CheckMark);
|
||||
bool mixed_value = (g.LastItemData.InFlags & ImGuiItemFlags_MixedValue) != 0;
|
||||
if (mixed_value)
|
||||
const bool mixed_value = (g.LastItemData.InFlags & ImGuiItemFlags_MixedValue) != 0;
|
||||
if (is_visible)
|
||||
{
|
||||
// Undocumented tristate/mixed/indeterminate checkbox (#2644)
|
||||
// This may seem awkwardly designed because the aim is to make ImGuiItemFlags_MixedValue supported by all widgets (not just checkbox)
|
||||
ImVec2 pad(ImMax(1.0f, IM_TRUNC(square_sz / 3.6f)), ImMax(1.0f, IM_TRUNC(square_sz / 3.6f)));
|
||||
window->DrawList->AddRectFilled(check_bb.Min + pad, check_bb.Max - pad, check_col, style.FrameRounding);
|
||||
RenderNavHighlight(total_bb, id);
|
||||
RenderFrame(check_bb.Min, check_bb.Max, GetColorU32((held && hovered) ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg), true, style.FrameRounding);
|
||||
ImU32 check_col = GetColorU32(ImGuiCol_CheckMark);
|
||||
if (mixed_value)
|
||||
{
|
||||
// Undocumented tristate/mixed/indeterminate checkbox (#2644)
|
||||
// This may seem awkwardly designed because the aim is to make ImGuiItemFlags_MixedValue supported by all widgets (not just checkbox)
|
||||
ImVec2 pad(ImMax(1.0f, IM_TRUNC(square_sz / 3.6f)), ImMax(1.0f, IM_TRUNC(square_sz / 3.6f)));
|
||||
window->DrawList->AddRectFilled(check_bb.Min + pad, check_bb.Max - pad, check_col, style.FrameRounding);
|
||||
}
|
||||
else if (*v)
|
||||
{
|
||||
const float pad = ImMax(1.0f, IM_TRUNC(square_sz / 6.0f));
|
||||
RenderCheckMark(window->DrawList, check_bb.Min + ImVec2(pad, pad), check_col, square_sz - pad * 2.0f);
|
||||
}
|
||||
}
|
||||
else if (*v)
|
||||
{
|
||||
const float pad = ImMax(1.0f, IM_TRUNC(square_sz / 6.0f));
|
||||
RenderCheckMark(window->DrawList, check_bb.Min + ImVec2(pad, pad), check_col, square_sz - pad * 2.0f);
|
||||
}
|
||||
|
||||
ImVec2 label_pos = ImVec2(check_bb.Max.x + style.ItemInnerSpacing.x, check_bb.Min.y + style.FramePadding.y);
|
||||
const ImVec2 label_pos = ImVec2(check_bb.Max.x + style.ItemInnerSpacing.x, check_bb.Min.y + style.FramePadding.y);
|
||||
if (g.LogEnabled)
|
||||
LogRenderedText(&label_pos, mixed_value ? "[~]" : *v ? "[x]" : "[ ]");
|
||||
if (label_size.x > 0.0f)
|
||||
if (is_visible && label_size.x > 0.0f)
|
||||
RenderText(label_pos, label);
|
||||
|
||||
IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Checkable | (*v ? ImGuiItemStatusFlags_Checked : 0));
|
||||
@ -1357,6 +1370,76 @@ void ImGui::Bullet()
|
||||
SameLine(0, style.FramePadding.x * 2.0f);
|
||||
}
|
||||
|
||||
// This is provided as a convenience for being an often requested feature.
|
||||
// FIXME-STYLE: we delayed adding as there is a larger plan to revamp the styling system.
|
||||
// Because of this we currently don't provide many styling options for this widget
|
||||
// (e.g. hovered/active colors are automatically inferred from a single color).
|
||||
bool ImGui::TextLink(const char* label)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
if (window->SkipItems)
|
||||
return false;
|
||||
|
||||
ImGuiContext& g = *GImGui;
|
||||
const ImGuiID id = window->GetID(label);
|
||||
const char* label_end = FindRenderedTextEnd(label);
|
||||
|
||||
ImVec2 pos = window->DC.CursorPos;
|
||||
ImVec2 size = CalcTextSize(label, label_end, true);
|
||||
ImRect bb(pos, pos + size);
|
||||
ItemSize(size, 0.0f);
|
||||
if (!ItemAdd(bb, id))
|
||||
return false;
|
||||
|
||||
bool hovered, held;
|
||||
bool pressed = ButtonBehavior(bb, id, &hovered, &held);
|
||||
RenderNavHighlight(bb, id, ImGuiNavHighlightFlags_None);
|
||||
|
||||
ImVec4 text_colf = g.Style.Colors[ImGuiCol_TextLink];
|
||||
ImVec4 line_colf = text_colf;
|
||||
{
|
||||
// FIXME-STYLE: Read comments above. This widget is NOT written in the same style as some earlier widgets,
|
||||
// as we are currently experimenting/planning a different styling system.
|
||||
float h, s, v;
|
||||
ColorConvertRGBtoHSV(text_colf.x, text_colf.y, text_colf.z, h, s, v);
|
||||
if (held || hovered)
|
||||
{
|
||||
v = ImSaturate(v + (held ? 0.4f : 0.3f));
|
||||
h = ImFmod(h + 0.02f, 1.0f);
|
||||
}
|
||||
ColorConvertHSVtoRGB(h, s, v, text_colf.x, text_colf.y, text_colf.z);
|
||||
v = ImSaturate(v - 0.20f);
|
||||
ColorConvertHSVtoRGB(h, s, v, line_colf.x, line_colf.y, line_colf.z);
|
||||
}
|
||||
|
||||
float line_y = bb.Max.y + ImFloor(g.Font->Descent * g.FontScale * 0.20f);
|
||||
window->DrawList->AddLine(ImVec2(bb.Min.x, line_y), ImVec2(bb.Max.x, line_y), GetColorU32(line_colf)); // FIXME-TEXT: Underline mode.
|
||||
|
||||
PushStyleColor(ImGuiCol_Text, GetColorU32(text_colf));
|
||||
RenderText(bb.Min, label, label_end);
|
||||
PopStyleColor();
|
||||
|
||||
IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags);
|
||||
return pressed;
|
||||
}
|
||||
|
||||
void ImGui::TextLinkOpenURL(const char* label, const char* url)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (url == NULL)
|
||||
url = label;
|
||||
if (TextLink(label))
|
||||
if (g.IO.PlatformOpenInShellFn != NULL)
|
||||
g.IO.PlatformOpenInShellFn(&g, url);
|
||||
SetItemTooltip("%s", url); // It is more reassuring for user to _always_ display URL when we same as label
|
||||
if (BeginPopupContextItem())
|
||||
{
|
||||
if (MenuItem(LocalizeGetMsg(ImGuiLocKey_CopyLink)))
|
||||
SetClipboardText(url);
|
||||
EndPopup();
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// [SECTION] Widgets: Low-level Layout helpers
|
||||
//-------------------------------------------------------------------------
|
||||
@ -1942,28 +2025,30 @@ bool ImGui::Combo(const char* label, int* current_item, const char* (*getter)(vo
|
||||
return false;
|
||||
|
||||
// Display items
|
||||
// FIXME-OPT: Use clipper (but we need to disable it on the appearing frame to make sure our call to SetItemDefaultFocus() is processed)
|
||||
bool value_changed = false;
|
||||
for (int i = 0; i < items_count; i++)
|
||||
{
|
||||
const char* item_text = getter(user_data, i);
|
||||
if (item_text == NULL)
|
||||
item_text = "*Unknown item*";
|
||||
|
||||
PushID(i);
|
||||
const bool item_selected = (i == *current_item);
|
||||
if (Selectable(item_text, item_selected) && *current_item != i)
|
||||
ImGuiListClipper clipper;
|
||||
clipper.Begin(items_count);
|
||||
clipper.IncludeItemByIndex(*current_item);
|
||||
while (clipper.Step())
|
||||
for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
|
||||
{
|
||||
value_changed = true;
|
||||
*current_item = i;
|
||||
const char* item_text = getter(user_data, i);
|
||||
if (item_text == NULL)
|
||||
item_text = "*Unknown item*";
|
||||
|
||||
PushID(i);
|
||||
const bool item_selected = (i == *current_item);
|
||||
if (Selectable(item_text, item_selected) && *current_item != i)
|
||||
{
|
||||
value_changed = true;
|
||||
*current_item = i;
|
||||
}
|
||||
if (item_selected)
|
||||
SetItemDefaultFocus();
|
||||
PopID();
|
||||
}
|
||||
if (item_selected)
|
||||
SetItemDefaultFocus();
|
||||
PopID();
|
||||
}
|
||||
|
||||
EndCombo();
|
||||
|
||||
if (value_changed)
|
||||
MarkItemEdited(g.LastItemData.ID);
|
||||
|
||||
@ -2045,6 +2130,7 @@ static const ImGuiDataTypeInfo GDataTypeInfo[] =
|
||||
#endif
|
||||
{ sizeof(float), "float", "%.3f","%f" }, // ImGuiDataType_Float (float are promoted to double in va_arg)
|
||||
{ sizeof(double), "double","%f", "%lf" }, // ImGuiDataType_Double
|
||||
{ sizeof(bool), "bool", "%d", "%d" }, // ImGuiDataType_Bool
|
||||
};
|
||||
IM_STATIC_ASSERT(IM_ARRAYSIZE(GDataTypeInfo) == ImGuiDataType_COUNT);
|
||||
|
||||
@ -2129,17 +2215,24 @@ void ImGui::DataTypeApplyOp(ImGuiDataType data_type, int op, void* output, const
|
||||
|
||||
// User can input math operators (e.g. +100) to edit a numerical values.
|
||||
// NB: This is _not_ a full expression evaluator. We should probably add one and replace this dumb mess..
|
||||
bool ImGui::DataTypeApplyFromText(const char* buf, ImGuiDataType data_type, void* p_data, const char* format)
|
||||
bool ImGui::DataTypeApplyFromText(const char* buf, ImGuiDataType data_type, void* p_data, const char* format, void* p_data_when_empty)
|
||||
{
|
||||
// Copy the value in an opaque buffer so we can compare at the end of the function if it changed at all.
|
||||
const ImGuiDataTypeInfo* type_info = DataTypeGetInfo(data_type);
|
||||
ImGuiDataTypeStorage data_backup;
|
||||
memcpy(&data_backup, p_data, type_info->Size);
|
||||
|
||||
while (ImCharIsBlankA(*buf))
|
||||
buf++;
|
||||
if (!buf[0])
|
||||
{
|
||||
if (p_data_when_empty != NULL)
|
||||
{
|
||||
memcpy(p_data, p_data_when_empty, type_info->Size);
|
||||
return memcmp(&data_backup, p_data, type_info->Size) != 0;
|
||||
}
|
||||
return false;
|
||||
|
||||
// Copy the value in an opaque buffer so we can compare at the end of the function if it changed at all.
|
||||
const ImGuiDataTypeInfo* type_info = DataTypeGetInfo(data_type);
|
||||
ImGuiDataTypeTempStorage data_backup;
|
||||
memcpy(&data_backup, p_data, type_info->Size);
|
||||
}
|
||||
|
||||
// Sanitize format
|
||||
// - For float/double we have to ignore format with precision (e.g. "%.2f") because sscanf doesn't take them in, so force them into %f and %lf
|
||||
@ -2286,12 +2379,13 @@ bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed, const
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
const ImGuiAxis axis = (flags & ImGuiSliderFlags_Vertical) ? ImGuiAxis_Y : ImGuiAxis_X;
|
||||
const bool is_clamped = (v_min < v_max);
|
||||
const bool is_bounded = (v_min < v_max);
|
||||
const bool is_wrapped = is_bounded && (flags & ImGuiSliderFlags_WrapAround);
|
||||
const bool is_logarithmic = (flags & ImGuiSliderFlags_Logarithmic) != 0;
|
||||
const bool is_floating_point = (data_type == ImGuiDataType_Float) || (data_type == ImGuiDataType_Double);
|
||||
|
||||
// Default tweak speed
|
||||
if (v_speed == 0.0f && is_clamped && (v_max - v_min < FLT_MAX))
|
||||
if (v_speed == 0.0f && is_bounded && (v_max - v_min < FLT_MAX))
|
||||
v_speed = (float)((v_max - v_min) * g.DragSpeedDefaultRatio);
|
||||
|
||||
// Inputs accumulates into g.DragCurrentAccum, which is flushed into the current value as soon as it makes a difference with our precision settings
|
||||
@ -2325,8 +2419,8 @@ bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed, const
|
||||
|
||||
// Clear current value on activation
|
||||
// Avoid altering values and clamping when we are _already_ past the limits and heading in the same direction, so e.g. if range is 0..255, current value is 300 and we are pushing to the right side, keep the 300.
|
||||
bool is_just_activated = g.ActiveIdIsJustActivated;
|
||||
bool is_already_past_limits_and_pushing_outward = is_clamped && ((*v >= v_max && adjust_delta > 0.0f) || (*v <= v_min && adjust_delta < 0.0f));
|
||||
const bool is_just_activated = g.ActiveIdIsJustActivated;
|
||||
const bool is_already_past_limits_and_pushing_outward = is_bounded && !is_wrapped && ((*v >= v_max && adjust_delta > 0.0f) || (*v <= v_min && adjust_delta < 0.0f));
|
||||
if (is_just_activated || is_already_past_limits_and_pushing_outward)
|
||||
{
|
||||
g.DragCurrentAccum = 0.0f;
|
||||
@ -2384,13 +2478,24 @@ bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed, const
|
||||
if (v_cur == (TYPE)-0)
|
||||
v_cur = (TYPE)0;
|
||||
|
||||
// Clamp values (+ handle overflow/wrap-around for integer types)
|
||||
if (*v != v_cur && is_clamped)
|
||||
if (*v != v_cur && is_bounded)
|
||||
{
|
||||
if (v_cur < v_min || (v_cur > *v && adjust_delta < 0.0f && !is_floating_point))
|
||||
v_cur = v_min;
|
||||
if (v_cur > v_max || (v_cur < *v && adjust_delta > 0.0f && !is_floating_point))
|
||||
v_cur = v_max;
|
||||
if (is_wrapped)
|
||||
{
|
||||
// Wrap values
|
||||
if (v_cur < v_min)
|
||||
v_cur += v_max - v_min + (is_floating_point ? 0 : 1);
|
||||
if (v_cur > v_max)
|
||||
v_cur -= v_max - v_min + (is_floating_point ? 0 : 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clamp values + handle overflow/wrap-around for integer types.
|
||||
if (v_cur < v_min || (v_cur > *v && adjust_delta < 0.0f && !is_floating_point))
|
||||
v_cur = v_min;
|
||||
if (v_cur > v_max || (v_cur < *v && adjust_delta > 0.0f && !is_floating_point))
|
||||
v_cur = v_max;
|
||||
}
|
||||
}
|
||||
|
||||
// Apply result
|
||||
@ -2403,7 +2508,7 @@ bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed, const
|
||||
bool ImGui::DragBehavior(ImGuiID id, ImGuiDataType data_type, void* p_v, float v_speed, const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags)
|
||||
{
|
||||
// Read imgui.cpp "API BREAKING CHANGES" section for 1.78 if you hit this assert.
|
||||
IM_ASSERT((flags == 1 || (flags & ImGuiSliderFlags_InvalidMask_) == 0) && "Invalid ImGuiSliderFlags flags! Has the 'float power' argument been mistakenly cast to flags? Call function with ImGuiSliderFlags_Logarithmic flags instead.");
|
||||
IM_ASSERT((flags == 1 || (flags & ImGuiSliderFlags_InvalidMask_) == 0) && "Invalid ImGuiSliderFlags flags! Has the legacy 'float power' argument been mistakenly cast to flags? Call function with ImGuiSliderFlags_Logarithmic flags instead.");
|
||||
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.ActiveId == id)
|
||||
@ -2996,7 +3101,8 @@ bool ImGui::SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_typ
|
||||
bool ImGui::SliderBehavior(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, void* p_v, const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags, ImRect* out_grab_bb)
|
||||
{
|
||||
// Read imgui.cpp "API BREAKING CHANGES" section for 1.78 if you hit this assert.
|
||||
IM_ASSERT((flags == 1 || (flags & ImGuiSliderFlags_InvalidMask_) == 0) && "Invalid ImGuiSliderFlags flag! Has the 'float power' argument been mistakenly cast to flags? Call function with ImGuiSliderFlags_Logarithmic flags instead.");
|
||||
IM_ASSERT((flags == 1 || (flags & ImGuiSliderFlags_InvalidMask_) == 0) && "Invalid ImGuiSliderFlags flags! Has the legacy 'float power' argument been mistakenly cast to flags? Call function with ImGuiSliderFlags_Logarithmic flags instead.");
|
||||
IM_ASSERT((flags & ImGuiSliderFlags_WrapAround) == 0); // Not supported by SliderXXX(), only by DragXXX()
|
||||
|
||||
switch (data_type)
|
||||
{
|
||||
@ -3459,11 +3565,11 @@ bool ImGui::TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImG
|
||||
{
|
||||
// Backup old value
|
||||
size_t data_type_size = type_info->Size;
|
||||
ImGuiDataTypeTempStorage data_backup;
|
||||
ImGuiDataTypeStorage data_backup;
|
||||
memcpy(&data_backup, p_data, data_type_size);
|
||||
|
||||
// Apply new value (or operations) then clamp
|
||||
DataTypeApplyFromText(data_buf, data_type, p_data, format);
|
||||
DataTypeApplyFromText(data_buf, data_type, p_data, format, NULL);
|
||||
if (p_clamp_min || p_clamp_max)
|
||||
{
|
||||
if (p_clamp_min && p_clamp_max && DataTypeCompare(data_type, p_clamp_min, p_clamp_max) > 0)
|
||||
@ -3479,6 +3585,13 @@ bool ImGui::TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImG
|
||||
return value_changed;
|
||||
}
|
||||
|
||||
void ImGui::SetNextItemRefVal(ImGuiDataType data_type, void* p_data)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.NextItemData.Flags |= ImGuiNextItemDataFlags_HasRefVal;
|
||||
memcpy(&g.NextItemData.RefVal, p_data, DataTypeGetInfo(data_type)->Size);
|
||||
}
|
||||
|
||||
// Note: p_data, p_step, p_step_fast are _pointers_ to a memory address holding the data. For an Input widget, p_step and p_step_fast are optional.
|
||||
// Read code of e.g. InputFloat(), InputInt() etc. or examples in 'Demo->Widgets->Data Types' to understand how to use this function directly.
|
||||
bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_step, const void* p_step_fast, const char* format, ImGuiInputTextFlags flags)
|
||||
@ -3493,8 +3606,13 @@ bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* p_data
|
||||
if (format == NULL)
|
||||
format = DataTypeGetInfo(data_type)->PrintFmt;
|
||||
|
||||
void* p_data_default = (g.NextItemData.Flags & ImGuiNextItemDataFlags_HasRefVal) ? &g.NextItemData.RefVal : &g.DataTypeZeroValue;
|
||||
|
||||
char buf[64];
|
||||
DataTypeFormatString(buf, IM_ARRAYSIZE(buf), data_type, p_data, format);
|
||||
if ((flags & ImGuiInputTextFlags_DisplayEmptyRefVal) && DataTypeCompare(data_type, p_data, p_data_default) == 0)
|
||||
buf[0] = 0;
|
||||
else
|
||||
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)ImGuiInputTextFlags_LocalizeDecimalPoint;
|
||||
@ -3503,7 +3621,7 @@ bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* p_data
|
||||
if (p_step == NULL)
|
||||
{
|
||||
if (InputText(label, buf, IM_ARRAYSIZE(buf), flags))
|
||||
value_changed = DataTypeApplyFromText(buf, data_type, p_data, format);
|
||||
value_changed = DataTypeApplyFromText(buf, data_type, p_data, format, (flags & ImGuiInputTextFlags_ParseEmptyRefVal) ? p_data_default : NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -3513,7 +3631,7 @@ bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* p_data
|
||||
PushID(label);
|
||||
SetNextItemWidth(ImMax(1.0f, CalcItemWidth() - (button_size + style.ItemInnerSpacing.x) * 2));
|
||||
if (InputText("", buf, IM_ARRAYSIZE(buf), flags)) // PushId(label) + "" gives us the expected ID from outside point of view
|
||||
value_changed = DataTypeApplyFromText(buf, data_type, p_data, format);
|
||||
value_changed = DataTypeApplyFromText(buf, data_type, p_data, format, (flags & ImGuiInputTextFlags_ParseEmptyRefVal) ? p_data_default : NULL);
|
||||
IMGUI_TEST_ENGINE_ITEM_INFO(g.LastItemData.ID, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Inputable);
|
||||
|
||||
// Step buttons
|
||||
@ -3731,7 +3849,7 @@ namespace ImStb
|
||||
|
||||
static int STB_TEXTEDIT_STRINGLEN(const ImGuiInputTextState* obj) { return obj->CurLenW; }
|
||||
static ImWchar STB_TEXTEDIT_GETCHAR(const ImGuiInputTextState* obj, int idx) { IM_ASSERT(idx <= obj->CurLenW); return obj->TextW[idx]; }
|
||||
static float STB_TEXTEDIT_GETWIDTH(ImGuiInputTextState* obj, int line_start_idx, int char_idx) { ImWchar c = obj->TextW[line_start_idx + char_idx]; if (c == '\n') return IMSTB_TEXTEDIT_GETWIDTH_NEWLINE; ImGuiContext& g = *obj->Ctx; return g.Font->GetCharAdvance(c) * (g.FontSize / g.Font->FontSize); }
|
||||
static float STB_TEXTEDIT_GETWIDTH(ImGuiInputTextState* obj, int line_start_idx, int char_idx) { ImWchar c = obj->TextW[line_start_idx + char_idx]; if (c == '\n') return IMSTB_TEXTEDIT_GETWIDTH_NEWLINE; ImGuiContext& g = *obj->Ctx; return g.Font->GetCharAdvance(c) * g.FontScale; }
|
||||
static int STB_TEXTEDIT_KEYTOTEXT(int key) { return key >= 0x200000 ? 0 : key; }
|
||||
static ImWchar STB_TEXTEDIT_NEWLINE = '\n';
|
||||
static void STB_TEXTEDIT_LAYOUTROW(StbTexteditRow* r, ImGuiInputTextState* obj, int line_start_idx)
|
||||
@ -4165,7 +4283,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
||||
PushStyleVar(ImGuiStyleVar_ChildRounding, style.FrameRounding);
|
||||
PushStyleVar(ImGuiStyleVar_ChildBorderSize, style.FrameBorderSize);
|
||||
PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0)); // Ensure no clip rect so mouse hover can reach FramePadding edges
|
||||
bool child_visible = BeginChildEx(label, id, frame_bb.GetSize(), true, ImGuiWindowFlags_NoMove);
|
||||
bool child_visible = BeginChildEx(label, id, frame_bb.GetSize(), ImGuiChildFlags_Border, ImGuiWindowFlags_NoMove);
|
||||
g.NavActivateId = backup_activate_id;
|
||||
PopStyleVar(3);
|
||||
PopStyleColor();
|
||||
@ -6077,7 +6195,8 @@ bool ImGui::TreeNode(const char* label)
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
if (window->SkipItems)
|
||||
return false;
|
||||
return TreeNodeBehavior(window->GetID(label), 0, label, NULL);
|
||||
ImGuiID id = window->GetID(label);
|
||||
return TreeNodeBehavior(id, id, ImGuiTreeNodeFlags_None, label, NULL);
|
||||
}
|
||||
|
||||
bool ImGui::TreeNodeV(const char* str_id, const char* fmt, va_list args)
|
||||
@ -6095,8 +6214,8 @@ bool ImGui::TreeNodeEx(const char* label, ImGuiTreeNodeFlags flags)
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
if (window->SkipItems)
|
||||
return false;
|
||||
|
||||
return TreeNodeBehavior(window->GetID(label), flags, label, NULL);
|
||||
ImGuiID id = window->GetID(label);
|
||||
return TreeNodeBehavior(id, id, flags, label, NULL);
|
||||
}
|
||||
|
||||
bool ImGui::TreeNodeEx(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, ...)
|
||||
@ -6123,9 +6242,10 @@ bool ImGui::TreeNodeExV(const char* str_id, ImGuiTreeNodeFlags flags, const char
|
||||
if (window->SkipItems)
|
||||
return false;
|
||||
|
||||
ImGuiID id = window->GetID(str_id);
|
||||
const char* label, *label_end;
|
||||
ImFormatStringToTempBufferV(&label, &label_end, fmt, args);
|
||||
return TreeNodeBehavior(window->GetID(str_id), flags, label, label_end);
|
||||
return TreeNodeBehavior(id, id, flags, label, label_end);
|
||||
}
|
||||
|
||||
bool ImGui::TreeNodeExV(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args)
|
||||
@ -6134,24 +6254,32 @@ bool ImGui::TreeNodeExV(const void* ptr_id, ImGuiTreeNodeFlags flags, const char
|
||||
if (window->SkipItems)
|
||||
return false;
|
||||
|
||||
ImGuiID id = window->GetID(ptr_id);
|
||||
const char* label, *label_end;
|
||||
ImFormatStringToTempBufferV(&label, &label_end, fmt, args);
|
||||
return TreeNodeBehavior(window->GetID(ptr_id), flags, label, label_end);
|
||||
return TreeNodeBehavior(id, id, flags, label, label_end);
|
||||
}
|
||||
|
||||
void ImGui::TreeNodeSetOpen(ImGuiID id, bool open)
|
||||
bool ImGui::TreeNodeGetOpen(ImGuiID storage_id)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiStorage* storage = g.CurrentWindow->DC.StateStorage;
|
||||
storage->SetInt(id, open ? 1 : 0);
|
||||
return storage->GetInt(storage_id, 0) != 0;
|
||||
}
|
||||
|
||||
bool ImGui::TreeNodeUpdateNextOpen(ImGuiID id, ImGuiTreeNodeFlags flags)
|
||||
void ImGui::TreeNodeSetOpen(ImGuiID storage_id, bool open)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiStorage* storage = g.CurrentWindow->DC.StateStorage;
|
||||
storage->SetInt(storage_id, open ? 1 : 0);
|
||||
}
|
||||
|
||||
bool ImGui::TreeNodeUpdateNextOpen(ImGuiID storage_id, ImGuiTreeNodeFlags flags)
|
||||
{
|
||||
if (flags & ImGuiTreeNodeFlags_Leaf)
|
||||
return true;
|
||||
|
||||
// We only write to the tree storage if the user clicks (or explicitly use the SetNextItemOpen function)
|
||||
// We only write to the tree storage if the user clicks, or explicitly use the SetNextItemOpen function
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
ImGuiStorage* storage = window->DC.StateStorage;
|
||||
@ -6162,16 +6290,16 @@ bool ImGui::TreeNodeUpdateNextOpen(ImGuiID id, ImGuiTreeNodeFlags flags)
|
||||
if (g.NextItemData.OpenCond & ImGuiCond_Always)
|
||||
{
|
||||
is_open = g.NextItemData.OpenVal;
|
||||
TreeNodeSetOpen(id, is_open);
|
||||
TreeNodeSetOpen(storage_id, is_open);
|
||||
}
|
||||
else
|
||||
{
|
||||
// We treat ImGuiCond_Once and ImGuiCond_FirstUseEver the same because tree node state are not saved persistently.
|
||||
const int stored_value = storage->GetInt(id, -1);
|
||||
const int stored_value = storage->GetInt(storage_id, -1);
|
||||
if (stored_value == -1)
|
||||
{
|
||||
is_open = g.NextItemData.OpenVal;
|
||||
TreeNodeSetOpen(id, is_open);
|
||||
TreeNodeSetOpen(storage_id, is_open);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -6181,7 +6309,7 @@ bool ImGui::TreeNodeUpdateNextOpen(ImGuiID id, ImGuiTreeNodeFlags flags)
|
||||
}
|
||||
else
|
||||
{
|
||||
is_open = storage->GetInt(id, (flags & ImGuiTreeNodeFlags_DefaultOpen) ? 1 : 0) != 0;
|
||||
is_open = storage->GetInt(storage_id, (flags & ImGuiTreeNodeFlags_DefaultOpen) ? 1 : 0) != 0;
|
||||
}
|
||||
|
||||
// When logging is enabled, we automatically expand tree nodes (but *NOT* collapsing headers.. seems like sensible behavior).
|
||||
@ -6192,7 +6320,24 @@ bool ImGui::TreeNodeUpdateNextOpen(ImGuiID id, ImGuiTreeNodeFlags flags)
|
||||
return is_open;
|
||||
}
|
||||
|
||||
bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end)
|
||||
// Store ImGuiTreeNodeStackData for just submitted node.
|
||||
// Currently only supports 32 level deep and we are fine with (1 << Depth) overflowing into a zero, easy to increase.
|
||||
static void TreeNodeStoreStackData(ImGuiTreeNodeFlags flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
|
||||
g.TreeNodeStack.resize(g.TreeNodeStack.Size + 1);
|
||||
ImGuiTreeNodeStackData* tree_node_data = &g.TreeNodeStack.back();
|
||||
tree_node_data->ID = g.LastItemData.ID;
|
||||
tree_node_data->TreeFlags = flags;
|
||||
tree_node_data->InFlags = g.LastItemData.InFlags;
|
||||
tree_node_data->NavRect = g.LastItemData.NavRect;
|
||||
window->DC.TreeHasStackDataDepthMask |= (1 << window->DC.TreeDepth);
|
||||
}
|
||||
|
||||
// When using public API, currently 'id == storage_id' is always true, but we separate the values to facilitate advanced user code doing storage queries outside of UI loop.
|
||||
bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiID storage_id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
if (window->SkipItems)
|
||||
@ -6245,7 +6390,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
||||
}
|
||||
|
||||
// Compute open and multi-select states before ItemAdd() as it clear NextItem data.
|
||||
bool is_open = TreeNodeUpdateNextOpen(id, flags);
|
||||
bool is_open = TreeNodeUpdateNextOpen(storage_id, flags);
|
||||
bool item_add = ItemAdd(interact_bb, id);
|
||||
g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_HasDisplayRect;
|
||||
g.LastItemData.DisplayRect = frame_bb;
|
||||
@ -6260,21 +6405,19 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
||||
// Store data for the current depth to allow returning to this node from any child item.
|
||||
// For this purpose we essentially compare if g.NavIdIsAlive went from 0 to 1 between TreeNode() and TreePop().
|
||||
// It will become tempting to enable ImGuiTreeNodeFlags_NavLeftJumpsBackHere by default or move it to ImGuiStyle.
|
||||
// Currently only supports 32 level deep and we are fine with (1 << Depth) overflowing into a zero, easy to increase.
|
||||
if (is_open && !g.NavIdIsAlive && (flags & ImGuiTreeNodeFlags_NavLeftJumpsBackHere) && !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen))
|
||||
if (g.NavMoveDir == ImGuiDir_Left && g.NavWindow == window && NavMoveRequestButNoResultYet())
|
||||
{
|
||||
g.NavTreeNodeStack.resize(g.NavTreeNodeStack.Size + 1);
|
||||
ImGuiNavTreeNodeData* nav_tree_node_data = &g.NavTreeNodeStack.back();
|
||||
nav_tree_node_data->ID = id;
|
||||
nav_tree_node_data->InFlags = g.LastItemData.InFlags;
|
||||
nav_tree_node_data->NavRect = g.LastItemData.NavRect;
|
||||
window->DC.TreeJumpToParentOnPopMask |= (1 << window->DC.TreeDepth);
|
||||
}
|
||||
bool store_tree_node_stack_data = false;
|
||||
if (!(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen))
|
||||
{
|
||||
if ((flags & ImGuiTreeNodeFlags_NavLeftJumpsBackHere) && is_open && !g.NavIdIsAlive)
|
||||
if (g.NavMoveDir == ImGuiDir_Left && g.NavWindow == window && NavMoveRequestButNoResultYet())
|
||||
store_tree_node_stack_data = true;
|
||||
}
|
||||
|
||||
const bool is_leaf = (flags & ImGuiTreeNodeFlags_Leaf) != 0;
|
||||
if (!item_add)
|
||||
{
|
||||
if (store_tree_node_stack_data && is_open)
|
||||
TreeNodeStoreStackData(flags); // Call before TreePushOverrideID()
|
||||
if (is_open && !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen))
|
||||
TreePushOverrideID(id);
|
||||
IMGUI_TEST_ENGINE_ITEM_INFO(g.LastItemData.ID, label, g.LastItemData.StatusFlags | (is_leaf ? 0 : ImGuiItemStatusFlags_Openable) | (is_open ? ImGuiItemStatusFlags_Opened : 0));
|
||||
@ -6359,7 +6502,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
||||
if (toggled)
|
||||
{
|
||||
is_open = !is_open;
|
||||
window->DC.StateStorage->SetInt(id, is_open);
|
||||
window->DC.StateStorage->SetInt(storage_id, is_open);
|
||||
g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_ToggledOpen;
|
||||
}
|
||||
}
|
||||
@ -6385,7 +6528,6 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
||||
text_pos.x -= text_offset_x -padding.x;
|
||||
if (flags & ImGuiTreeNodeFlags_ClipLabelForTrailingButton)
|
||||
frame_bb.Max.x -= g.FontSize + style.FramePadding.x;
|
||||
|
||||
if (g.LogEnabled)
|
||||
LogSetNextTextDecoration("###", "###");
|
||||
}
|
||||
@ -6415,8 +6557,11 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
||||
else
|
||||
RenderText(text_pos, label, label_end, false);
|
||||
|
||||
if (store_tree_node_stack_data && is_open)
|
||||
TreeNodeStoreStackData(flags); // Call before TreePushOverrideID()
|
||||
if (is_open && !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen))
|
||||
TreePushOverrideID(id);
|
||||
TreePushOverrideID(id); // Could use TreePush(label) but this avoid computing twice
|
||||
|
||||
IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags | (is_leaf ? 0 : ImGuiItemStatusFlags_Openable) | (is_open ? ImGuiItemStatusFlags_Opened : 0));
|
||||
return is_open;
|
||||
}
|
||||
@ -6455,16 +6600,19 @@ void ImGui::TreePop()
|
||||
window->DC.TreeDepth--;
|
||||
ImU32 tree_depth_mask = (1 << window->DC.TreeDepth);
|
||||
|
||||
// Handle Left arrow to move to parent tree node (when ImGuiTreeNodeFlags_NavLeftJumpsBackHere is enabled)
|
||||
if (window->DC.TreeJumpToParentOnPopMask & tree_depth_mask) // Only set during request
|
||||
if (window->DC.TreeHasStackDataDepthMask & tree_depth_mask) // Only set during request
|
||||
{
|
||||
ImGuiNavTreeNodeData* nav_tree_node_data = &g.NavTreeNodeStack.back();
|
||||
IM_ASSERT(nav_tree_node_data->ID == window->IDStack.back());
|
||||
if (g.NavIdIsAlive && g.NavMoveDir == ImGuiDir_Left && g.NavWindow == window && NavMoveRequestButNoResultYet())
|
||||
NavMoveRequestResolveWithPastTreeNode(&g.NavMoveResultLocal, nav_tree_node_data);
|
||||
g.NavTreeNodeStack.pop_back();
|
||||
ImGuiTreeNodeStackData* data = &g.TreeNodeStack.back();
|
||||
IM_ASSERT(data->ID == window->IDStack.back());
|
||||
if (data->TreeFlags & ImGuiTreeNodeFlags_NavLeftJumpsBackHere)
|
||||
{
|
||||
// Handle Left arrow to move to parent tree node (when ImGuiTreeNodeFlags_NavLeftJumpsBackHere is enabled)
|
||||
if (g.NavIdIsAlive && g.NavMoveDir == ImGuiDir_Left && g.NavWindow == window && NavMoveRequestButNoResultYet())
|
||||
NavMoveRequestResolveWithPastTreeNode(&g.NavMoveResultLocal, data);
|
||||
}
|
||||
g.TreeNodeStack.pop_back();
|
||||
window->DC.TreeHasStackDataDepthMask &= ~tree_depth_mask;
|
||||
}
|
||||
window->DC.TreeJumpToParentOnPopMask &= tree_depth_mask - 1;
|
||||
|
||||
IM_ASSERT(window->IDStack.Size > 1); // There should always be 1 element in the IDStack (pushed during window creation). If this triggers you called TreePop/PopID too much.
|
||||
PopID();
|
||||
@ -6485,7 +6633,7 @@ void ImGui::SetNextItemOpen(bool is_open, ImGuiCond cond)
|
||||
return;
|
||||
g.NextItemData.Flags |= ImGuiNextItemDataFlags_HasOpen;
|
||||
g.NextItemData.OpenVal = is_open;
|
||||
g.NextItemData.OpenCond = cond ? cond : ImGuiCond_Always;
|
||||
g.NextItemData.OpenCond = (ImU8)(cond ? cond : ImGuiCond_Always);
|
||||
}
|
||||
|
||||
// CollapsingHeader returns true when opened but do not indent nor push into the ID stack (because of the ImGuiTreeNodeFlags_NoTreePushOnOpen flag).
|
||||
@ -6495,8 +6643,8 @@ bool ImGui::CollapsingHeader(const char* label, ImGuiTreeNodeFlags flags)
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
if (window->SkipItems)
|
||||
return false;
|
||||
|
||||
return TreeNodeBehavior(window->GetID(label), flags | ImGuiTreeNodeFlags_CollapsingHeader, label);
|
||||
ImGuiID id = window->GetID(label);
|
||||
return TreeNodeBehavior(id, id, flags | ImGuiTreeNodeFlags_CollapsingHeader, label);
|
||||
}
|
||||
|
||||
// p_visible == NULL : regular collapsing header
|
||||
@ -6516,7 +6664,7 @@ bool ImGui::CollapsingHeader(const char* label, bool* p_visible, ImGuiTreeNodeFl
|
||||
flags |= ImGuiTreeNodeFlags_CollapsingHeader;
|
||||
if (p_visible)
|
||||
flags |= ImGuiTreeNodeFlags_AllowOverlap | (ImGuiTreeNodeFlags)ImGuiTreeNodeFlags_ClipLabelForTrailingButton;
|
||||
bool is_open = TreeNodeBehavior(id, flags, label);
|
||||
bool is_open = TreeNodeBehavior(id, id, flags, label);
|
||||
if (p_visible != NULL)
|
||||
{
|
||||
// Create a small overlapping close button
|
||||
@ -6600,7 +6748,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
|
||||
}
|
||||
|
||||
const bool disabled_item = (flags & ImGuiSelectableFlags_Disabled) != 0;
|
||||
const bool item_add = ItemAdd(bb, id, NULL, disabled_item ? ImGuiItemFlags_Disabled : ImGuiItemFlags_None);
|
||||
const bool item_add = ItemAdd(bb, id, NULL, disabled_item ? (ImGuiItemFlags)ImGuiItemFlags_Disabled : ImGuiItemFlags_None);
|
||||
if (span_all_columns)
|
||||
{
|
||||
window->ClipRect.Min.x = backup_clip_rect_min_x;
|
||||
@ -6686,7 +6834,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
|
||||
RenderTextClipped(text_min, text_max, label, NULL, &label_size, style.SelectableTextAlign, &bb);
|
||||
|
||||
// Automatically close popups
|
||||
if (pressed && (window->Flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiSelectableFlags_DontClosePopups) && !(g.LastItemData.InFlags & ImGuiItemFlags_SelectableDontClosePopup))
|
||||
if (pressed && (window->Flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiSelectableFlags_NoAutoClosePopups) && (g.LastItemData.InFlags & ImGuiItemFlags_AutoClosePopups))
|
||||
CloseCurrentPopup();
|
||||
|
||||
if (disabled_item && !disabled_global)
|
||||
@ -7001,6 +7149,7 @@ bool ImGui::ListBox(const char* label, int* current_item, const char* (*getter)(
|
||||
bool value_changed = false;
|
||||
ImGuiListClipper clipper;
|
||||
clipper.Begin(items_count, GetTextLineHeightWithSpacing()); // We know exactly our line height here so we pass it as a minor optimization, but generally you don't need to.
|
||||
clipper.IncludeItemByIndex(*current_item);
|
||||
while (clipper.Step())
|
||||
for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
|
||||
{
|
||||
@ -7513,13 +7662,13 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)
|
||||
bool pressed;
|
||||
|
||||
// We use ImGuiSelectableFlags_NoSetKeyOwner to allow down on one menu item, move, up on another.
|
||||
const ImGuiSelectableFlags selectable_flags = ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_NoSetKeyOwner | ImGuiSelectableFlags_SelectOnClick | ImGuiSelectableFlags_DontClosePopups;
|
||||
const ImGuiSelectableFlags selectable_flags = ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_NoSetKeyOwner | ImGuiSelectableFlags_SelectOnClick | ImGuiSelectableFlags_NoAutoClosePopups;
|
||||
if (window->DC.LayoutType == ImGuiLayoutType_Horizontal)
|
||||
{
|
||||
// Menu inside an horizontal menu bar
|
||||
// Selectable extend their highlight by half ItemSpacing in each direction.
|
||||
// For ChildMenu, the popup position will be overwritten by the call to FindBestWindowPosForPopup() in Begin()
|
||||
popup_pos = ImVec2(pos.x - 1.0f - IM_TRUNC(style.ItemSpacing.x * 0.5f), pos.y - style.FramePadding.y + window->MenuBarHeight());
|
||||
popup_pos = ImVec2(pos.x - 1.0f - IM_TRUNC(style.ItemSpacing.x * 0.5f), pos.y - style.FramePadding.y + window->MenuBarHeight);
|
||||
window->DC.CursorPos.x += IM_TRUNC(style.ItemSpacing.x * 0.5f);
|
||||
PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(style.ItemSpacing.x * 2.0f, style.ItemSpacing.y));
|
||||
float w = label_size.x;
|
||||
@ -7889,7 +8038,9 @@ bool ImGui::BeginTabBar(const char* str_id, ImGuiTabBarFlags flags)
|
||||
tab_bar->ID = id;
|
||||
tab_bar->SeparatorMinX = tab_bar->BarRect.Min.x - IM_TRUNC(window->WindowPadding.x * 0.5f);
|
||||
tab_bar->SeparatorMaxX = tab_bar->BarRect.Max.x + IM_TRUNC(window->WindowPadding.x * 0.5f);
|
||||
return BeginTabBarEx(tab_bar, tab_bar_bb, flags | ImGuiTabBarFlags_IsFocused);
|
||||
//if (g.NavWindow && IsWindowChildOf(g.NavWindow, window, false, false))
|
||||
flags |= ImGuiTabBarFlags_IsFocused;
|
||||
return BeginTabBarEx(tab_bar, tab_bar_bb, flags);
|
||||
}
|
||||
|
||||
bool ImGui::BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& tab_bar_bb, ImGuiTabBarFlags flags)
|
||||
@ -7943,7 +8094,7 @@ bool ImGui::BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& tab_bar_bb, ImG
|
||||
|
||||
// Draw separator
|
||||
// (it would be misleading to draw this in EndTabBar() suggesting that it may be drawn over tabs, as tab bar are appendable)
|
||||
const ImU32 col = GetColorU32((flags & ImGuiTabBarFlags_IsFocused) ? ImGuiCol_TabActive : ImGuiCol_TabUnfocusedActive);
|
||||
const ImU32 col = GetColorU32((flags & ImGuiTabBarFlags_IsFocused) ? ImGuiCol_TabSelected : ImGuiCol_TabDimmedSelected);
|
||||
if (g.Style.TabBarBorderSize > 0.0f)
|
||||
{
|
||||
const float y = tab_bar->BarRect.Max.y;
|
||||
@ -8285,7 +8436,7 @@ ImGuiTabItem* ImGui::TabBarFindTabByOrder(ImGuiTabBar* tab_bar, int order)
|
||||
|
||||
ImGuiTabItem* ImGui::TabBarGetCurrentTab(ImGuiTabBar* tab_bar)
|
||||
{
|
||||
if (tab_bar->LastTabItemIdx <= 0 || tab_bar->LastTabItemIdx >= tab_bar->Tabs.Size)
|
||||
if (tab_bar->LastTabItemIdx < 0 || tab_bar->LastTabItemIdx >= tab_bar->Tabs.Size)
|
||||
return NULL;
|
||||
return &tab_bar->Tabs[tab_bar->LastTabItemIdx];
|
||||
}
|
||||
@ -8803,8 +8954,16 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
|
||||
|
||||
// Render tab shape
|
||||
ImDrawList* display_draw_list = window->DrawList;
|
||||
const ImU32 tab_col = GetColorU32((held || hovered) ? ImGuiCol_TabHovered : tab_contents_visible ? (tab_bar_focused ? ImGuiCol_TabActive : ImGuiCol_TabUnfocusedActive) : (tab_bar_focused ? ImGuiCol_Tab : ImGuiCol_TabUnfocused));
|
||||
const ImU32 tab_col = GetColorU32((held || hovered) ? ImGuiCol_TabHovered : tab_contents_visible ? (tab_bar_focused ? ImGuiCol_TabSelected : ImGuiCol_TabDimmedSelected) : (tab_bar_focused ? ImGuiCol_Tab : ImGuiCol_TabDimmed));
|
||||
TabItemBackground(display_draw_list, bb, flags, tab_col);
|
||||
if (tab_contents_visible && (tab_bar->Flags & ImGuiTabBarFlags_DrawSelectedOverline))
|
||||
{
|
||||
float x_offset = IM_TRUNC(0.4f * style.TabRounding);
|
||||
if (x_offset < 2.0f * g.CurrentDpiScale)
|
||||
x_offset = 0.0f;
|
||||
float y_offset = 1.0f * g.CurrentDpiScale;
|
||||
display_draw_list->AddLine(bb.GetTL() + ImVec2(x_offset, y_offset), bb.GetTR() + ImVec2(-x_offset, y_offset), GetColorU32(tab_bar_focused ? ImGuiCol_TabSelectedOverline : ImGuiCol_TabDimmedSelectedOverline), 2.0f * g.CurrentDpiScale);
|
||||
}
|
||||
RenderNavHighlight(bb, id);
|
||||
|
||||
// Select with right mouse button. This is so the common idiom for context menu automatically highlight the current widget.
|
||||
|
@ -357,7 +357,7 @@ namespace
|
||||
case FT_PIXEL_MODE_BGRA:
|
||||
{
|
||||
// FIXME: Converting pre-multiplied alpha to straight. Doesn't smell good.
|
||||
#define DE_MULTIPLY(color, alpha) (ImU32)(255.0f * (float)color / (float)alpha + 0.5f)
|
||||
#define DE_MULTIPLY(color, alpha) ImMin((ImU32)(255.0f * (float)color / (float)(alpha + FLT_MIN) + 0.5f), 255u)
|
||||
if (multiply_table == nullptr)
|
||||
{
|
||||
for (uint32_t y = 0; y < h; y++, src += src_pitch, dst += dst_pitch)
|
||||
|
6
external/sdl/CMakeLists.txt
vendored
6
external/sdl/CMakeLists.txt
vendored
@ -16,7 +16,11 @@ if (NOT TARGET SDL3::SDL3)
|
||||
# made changes that break imgui release 1.90.6
|
||||
#GIT_TAG 1103294d33f47ab4c697bb22a9cf27c79c658630 # tip 15-05-2024
|
||||
#GIT_TAG aacafd62336363077470f678b6217214b3b49473 # tip 28-05-2024
|
||||
GIT_TAG 5fa9432b7d1c1722de93e1ab46e7a9569a47071e # tip 27-05-2024 - before changes made breaking sdl_image
|
||||
#GIT_TAG 5fa9432b7d1c1722de93e1ab46e7a9569a47071e # tip 27-05-2024 - before changes made breaking sdl_image
|
||||
#GIT_TAG 9651ca59187c16079846918483c40d6b5c2f454c # tip 09-06-2024
|
||||
#GIT_TAG 657c0135b1ff1685afa1bad63b0417d92f4bcb46 # tip 09-06-2024
|
||||
#GIT_TAG e949f12f63cdfcef4bdf456936ee676e0a3f9de6 # tip 18-07-2024
|
||||
GIT_TAG d65a8146b950abe31b4fbf779f3e2fea731af9bd # tip 16-07-2024 - before string policy changes breaking imgui
|
||||
|
||||
FIND_PACKAGE_ARGS # for the future
|
||||
)
|
||||
|
4
external/sdl_image/CMakeLists.txt
vendored
4
external/sdl_image/CMakeLists.txt
vendored
@ -17,7 +17,9 @@ if (NOT TARGET SDL3_image::SDL3_image)
|
||||
# waiting on the imgui pr to get merged so i can update sdl <.<
|
||||
#GIT_TAG a45d6e5b84ccc0f3faae6ba7d561709ed600eee7 # tip last check
|
||||
#GIT_TAG a34ccf16f961e6d5a480045eb650fc3dddb4bfaa # tip 14-05-2024
|
||||
GIT_TAG 2fc5310a9a2700fc856663200f94edebeb5e554a # tip 28-05-2024
|
||||
#GIT_TAG 2fc5310a9a2700fc856663200f94edebeb5e554a # tip 28-05-2024
|
||||
#GIT_TAG 8eff782fa33d795c9ea1ac42dbe7e17cc9874c78 # tip 09-06-2024
|
||||
GIT_TAG 8abc07df88cc035997e797967ac2f479b0e50981 # tip 18-07-2024
|
||||
FIND_PACKAGE_ARGS # for the future
|
||||
)
|
||||
FetchContent_MakeAvailable(SDL3_image)
|
||||
|
2
external/solanaceae_contact
vendored
2
external/solanaceae_contact
vendored
Submodule external/solanaceae_contact updated: e8b069c803...2401079c1d
2
external/solanaceae_object_store
vendored
2
external/solanaceae_object_store
vendored
Submodule external/solanaceae_object_store updated: be24b3815b...a93a89c5db
2
external/solanaceae_plugin
vendored
2
external/solanaceae_plugin
vendored
Submodule external/solanaceae_plugin updated: ade1b4ea74...54cd23433d
2
external/solanaceae_util
vendored
2
external/solanaceae_util
vendored
Submodule external/solanaceae_util updated: 4bda751f76...17d2baf736
17
external/toxcore/CMakeLists.txt
vendored
17
external/toxcore/CMakeLists.txt
vendored
@ -1,21 +1,27 @@
|
||||
cmake_minimum_required(VERSION 3.9...3.16 FATAL_ERROR)
|
||||
cmake_minimum_required(VERSION 3.13...3.16 FATAL_ERROR)
|
||||
|
||||
set(EXPERIMENTAL_API ON CACHE BOOL "" FORCE)
|
||||
set(UNITTEST OFF CACHE BOOL "" FORCE)
|
||||
set(BOOTSTRAP_DAEMON OFF CACHE BOOL "" FORCE)
|
||||
#set(BUILD_TOXAV ON CACHE BOOL "")
|
||||
|
||||
add_subdirectory(./c-toxcore)
|
||||
|
||||
# the ideal case
|
||||
#add_library(toxcore ALIAS toxcore_static)
|
||||
#message("II BUILD_TOXAV: ${BUILD_TOXAV}")
|
||||
|
||||
# the sad case
|
||||
add_library(toxcore INTERFACE)
|
||||
|
||||
if (TARGET toxcore_static)
|
||||
target_link_libraries(toxcore INTERFACE toxcore_static)
|
||||
|
||||
# the ideal case
|
||||
#add_library(toxcore ALIAS toxcore_static)
|
||||
else()
|
||||
target_link_libraries(toxcore INTERFACE toxcore_shared)
|
||||
|
||||
# the ideal case
|
||||
#add_library(toxcore ALIAS toxcore_shared)
|
||||
endif()
|
||||
|
||||
# HACK: "install" api headers into binary dir
|
||||
@ -64,3 +70,8 @@ elseif(sodium_FOUND)
|
||||
else()
|
||||
message(SEND_ERROR "missing libsodium")
|
||||
endif()
|
||||
|
||||
#if(BUILD_TOXAV)
|
||||
# set_target_properties(toxcore PROPERTIES TOX_HAS_TOXAV ON)
|
||||
#endif()
|
||||
|
||||
|
24
flake.lock
generated
24
flake.lock
generated
@ -20,16 +20,16 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1713189761,
|
||||
"narHash": "sha256-MPp1dBhlY066IeBo+EPGEUN+s+aSUA+LWkvnzKh+rts=",
|
||||
"lastModified": 1720691131,
|
||||
"narHash": "sha256-CWT+KN8aTPyMIx8P303gsVxUnkinIz0a/Cmasz1jyIM=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "ff44be4d8ff33f797ff3e3f87153d4f3b6a85ffb",
|
||||
"rev": "a046c1202e11b62cbede5385ba64908feb7bfac4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "release-23.11",
|
||||
"ref": "release-24.05",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
@ -63,34 +63,34 @@
|
||||
"sdl3": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1716778470,
|
||||
"narHash": "sha256-/esw8XkLIR7/2HLXaCfsOsEy+Idf6XGsnWGC5yXJipk=",
|
||||
"lastModified": 1721156595,
|
||||
"narHash": "sha256-BamJ5xK2uEHv1Q5AM2aNYk+ZDsrKCVsyZ4ium7pTTis=",
|
||||
"owner": "libsdl-org",
|
||||
"repo": "SDL",
|
||||
"rev": "5fa9432b7d1c1722de93e1ab46e7a9569a47071e",
|
||||
"rev": "d65a8146b950abe31b4fbf779f3e2fea731af9bd",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "libsdl-org",
|
||||
"repo": "SDL",
|
||||
"rev": "5fa9432b7d1c1722de93e1ab46e7a9569a47071e",
|
||||
"rev": "d65a8146b950abe31b4fbf779f3e2fea731af9bd",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"sdl3_image": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1716394356,
|
||||
"narHash": "sha256-dQ4x7ZbQodOs4PQU90evoa870abC/u0uaVLEqU1nB8k=",
|
||||
"lastModified": 1721253495,
|
||||
"narHash": "sha256-mZjO5Tfu6TyGGC/2AduzOqKHW9NdH4oSzyVGjipW5bQ=",
|
||||
"owner": "libsdl-org",
|
||||
"repo": "SDL_image",
|
||||
"rev": "2fc5310a9a2700fc856663200f94edebeb5e554a",
|
||||
"rev": "8abc07df88cc035997e797967ac2f479b0e50981",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "libsdl-org",
|
||||
"repo": "SDL_image",
|
||||
"rev": "2fc5310a9a2700fc856663200f94edebeb5e554a",
|
||||
"rev": "8abc07df88cc035997e797967ac2f479b0e50981",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
|
12
flake.nix
12
flake.nix
@ -4,18 +4,18 @@
|
||||
# append '.?submodules=1' to the nix commands.
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/release-23.11";
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/release-24.05";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
nlohmann-json = {
|
||||
url = "github:nlohmann/json/v3.11.3"; # TODO: read version from file
|
||||
flake = false;
|
||||
};
|
||||
sdl3 = {
|
||||
url = "github:libsdl-org/SDL/5fa9432b7d1c1722de93e1ab46e7a9569a47071e"; # keep in sync this cmake
|
||||
url = "github:libsdl-org/SDL/d65a8146b950abe31b4fbf779f3e2fea731af9bd"; # keep in sync this cmake
|
||||
flake = false;
|
||||
};
|
||||
sdl3_image = {
|
||||
url = "github:libsdl-org/SDL_image/2fc5310a9a2700fc856663200f94edebeb5e554a";
|
||||
url = "github:libsdl-org/SDL_image/8abc07df88cc035997e797967ac2f479b0e50981";
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
@ -25,6 +25,7 @@
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
stdenv = (pkgs.stdenvAdapters.keepDebugInfo pkgs.stdenv);
|
||||
#stdenv = (pkgs.stdenvAdapters.withCFlags [ "-march=x86-64-v3" ] (pkgs.stdenvAdapters.keepDebugInfo pkgs.stdenv));
|
||||
in {
|
||||
#packages.default = pkgs.stdenv.mkDerivation {
|
||||
packages.default = stdenv.mkDerivation {
|
||||
@ -74,11 +75,16 @@
|
||||
#(libsodium.override { stdenv = pkgs.pkgsStatic.stdenv; })
|
||||
#pkgsStatic.libsodium
|
||||
libsodium
|
||||
libopus
|
||||
libvpx
|
||||
] ++ self.packages.${system}.default.dlopenBuildInputs;
|
||||
|
||||
cmakeFlags = [
|
||||
"-DTOMATO_ASAN=OFF"
|
||||
"-DCMAKE_BUILD_TYPE=RelWithDebInfo"
|
||||
#"-DCMAKE_BUILD_TYPE=Debug"
|
||||
#"-DCMAKE_C_FLAGS:STRING=-Og"
|
||||
#"-DCMAKE_CXX_FLAGS:STRING=-Og"
|
||||
|
||||
"-DFETCHCONTENT_SOURCE_DIR_JSON=${nlohmann-json}" # we care about the version
|
||||
# TODO: use package instead
|
||||
|
@ -13,6 +13,9 @@ target_sources(tomato PUBLIC
|
||||
./main.cpp
|
||||
./icon.rc
|
||||
|
||||
./sys_check.hpp
|
||||
./sys_check.cpp
|
||||
|
||||
./json_to_config.hpp
|
||||
./json_to_config.cpp
|
||||
|
||||
@ -64,6 +67,16 @@ target_sources(tomato PUBLIC
|
||||
|
||||
./chat_gui/theme.hpp
|
||||
./chat_gui/theme.cpp
|
||||
./chat_gui/icons/direct.hpp
|
||||
./chat_gui/icons/direct.cpp
|
||||
./chat_gui/icons/cloud.hpp
|
||||
./chat_gui/icons/cloud.cpp
|
||||
./chat_gui/icons/mail.hpp
|
||||
./chat_gui/icons/mail.cpp
|
||||
./chat_gui/icons/person.hpp
|
||||
./chat_gui/icons/person.cpp
|
||||
./chat_gui/icons/group.hpp
|
||||
./chat_gui/icons/group.cpp
|
||||
./chat_gui/contact_list.hpp
|
||||
./chat_gui/contact_list.cpp
|
||||
./chat_gui/file_selector.hpp
|
||||
@ -73,6 +86,10 @@ target_sources(tomato PUBLIC
|
||||
./chat_gui/settings_window.hpp
|
||||
./chat_gui/settings_window.cpp
|
||||
|
||||
./imgui_entt_entity_editor.hpp
|
||||
./object_store_ui.hpp
|
||||
./object_store_ui.cpp
|
||||
|
||||
./tox_ui_utils.hpp
|
||||
./tox_ui_utils.cpp
|
||||
|
||||
|
@ -1,139 +1,16 @@
|
||||
#include "./contact_list.hpp"
|
||||
|
||||
#include <solanaceae/contact/components.hpp>
|
||||
#include <solanaceae/util/utils.hpp>
|
||||
|
||||
#include <imgui/imgui.h>
|
||||
//#include <imgui/imgui_internal.h>
|
||||
|
||||
#include <array>
|
||||
|
||||
static void drawIconDirectLines(
|
||||
const ImVec2 p0,
|
||||
const ImVec2 p1_o,
|
||||
const ImU32 col,
|
||||
const float thickness
|
||||
) {
|
||||
#define PLINE(x0, y0, x1, y1) \
|
||||
ImGui::GetWindowDrawList()->AddLine( \
|
||||
{p0.x + p1_o.x*(x0), p0.y + p1_o.y*(y0)}, \
|
||||
{p0.x + p1_o.x*(x1), p0.y + p1_o.y*(y1)}, \
|
||||
col, \
|
||||
thickness \
|
||||
);
|
||||
|
||||
// arrow 1
|
||||
// (3,1) -> (9,7)
|
||||
PLINE(0.3f, 0.1f, 0.9f, 0.7f)
|
||||
// (9,7) -> (9,5)
|
||||
PLINE(0.9f, 0.7f, 0.9f, 0.5f)
|
||||
// (9,7) -> (7,7)
|
||||
PLINE(0.9f, 0.7f, 0.7f, 0.7f)
|
||||
|
||||
// arrow 2
|
||||
// (7,9) -> (1,3)
|
||||
PLINE(0.7f, 0.9f, 0.1f, 0.3f)
|
||||
// (1,3) -> (3,3)
|
||||
PLINE(0.1f, 0.3f, 0.3f, 0.3f)
|
||||
// (1,3) -> (1,5)
|
||||
PLINE(0.1f, 0.3f, 0.1f, 0.5f)
|
||||
#undef PLINE
|
||||
}
|
||||
|
||||
static void drawIconDirect(
|
||||
const ImVec2 p0,
|
||||
const ImVec2 p1_o,
|
||||
const ImU32 col_main,
|
||||
const ImU32 col_back
|
||||
) {
|
||||
// dark background
|
||||
// the circle looks bad in light mode
|
||||
//ImGui::GetWindowDrawList()->AddCircleFilled({p0.x + p1_o.x*0.5f, p0.y + p1_o.y*0.5f}, p1_o.x*0.5f, col_back);
|
||||
drawIconDirectLines(p0, p1_o, col_back, 4.0f);
|
||||
drawIconDirectLines(p0, p1_o, col_main, 1.5f);
|
||||
}
|
||||
|
||||
static void drawIconCloud(
|
||||
const ImVec2 p0,
|
||||
const ImVec2 p1_o,
|
||||
const ImU32 col_main,
|
||||
const ImU32 col_back
|
||||
) {
|
||||
std::array<ImVec2, 19> points {{
|
||||
{0.2f, 0.9f},
|
||||
{0.8f, 0.9f},
|
||||
{0.9f, 0.8f},
|
||||
{0.9f, 0.7f},
|
||||
{0.7f, 0.7f},
|
||||
{0.9f, 0.5f},
|
||||
{0.9f, 0.4f},
|
||||
{0.8f, 0.2f},
|
||||
{0.6f, 0.2f},
|
||||
{0.5f, 0.3f},
|
||||
{0.5f, 0.5f},
|
||||
{0.4f, 0.4f},
|
||||
{0.3f, 0.4f},
|
||||
{0.2f, 0.5f},
|
||||
{0.2f, 0.6f},
|
||||
{0.3f, 0.7f},
|
||||
{0.1f, 0.7f},
|
||||
{0.1f, 0.8f},
|
||||
{0.2f, 0.9f},
|
||||
}};
|
||||
for (auto& v : points) {
|
||||
v.y -= 0.1f;
|
||||
v = {p0.x + p1_o.x*v.x, p0.y + p1_o.y*v.y};
|
||||
}
|
||||
// the circle looks bad in light mode
|
||||
//ImGui::GetWindowDrawList()->AddCircleFilled({p0.x + p1_o.x*0.5f, p0.y + p1_o.y*0.5f}, p1_o.x*0.5f, col_back);
|
||||
ImGui::GetWindowDrawList()->AddPolyline(points.data(), points.size(), col_back, ImDrawFlags_None, 4.f);
|
||||
ImGui::GetWindowDrawList()->AddPolyline(points.data(), points.size(), col_main, ImDrawFlags_None, 1.5f);
|
||||
}
|
||||
|
||||
static void drawIconMailLines(
|
||||
const ImVec2 p0,
|
||||
const ImVec2 p1_o,
|
||||
const ImU32 col,
|
||||
const float thickness
|
||||
) {
|
||||
#define PLINE(x0, y0, x1, y1) \
|
||||
ImGui::GetWindowDrawList()->AddLine( \
|
||||
{p0.x + p1_o.x*(x0), p0.y + p1_o.y*(y0)}, \
|
||||
{p0.x + p1_o.x*(x1), p0.y + p1_o.y*(y1)}, \
|
||||
col, \
|
||||
thickness \
|
||||
);
|
||||
|
||||
// quad
|
||||
// (1,2) -> (1,8)
|
||||
PLINE(0.1f, 0.2f, 0.1f, 0.8f)
|
||||
// (1,8) -> (9,8)
|
||||
PLINE(0.1f, 0.8f, 0.9f, 0.8f)
|
||||
// (9,8) -> (9,2)
|
||||
PLINE(0.9f, 0.8f, 0.9f, 0.2f)
|
||||
// (9,2) -> (1,2)
|
||||
PLINE(0.9f, 0.2f, 0.1f, 0.2f)
|
||||
|
||||
// lip
|
||||
// (1,2) -> (5,5)
|
||||
PLINE(0.1f, 0.2f, 0.5f, 0.5f)
|
||||
// (5,5) -> (9,2)
|
||||
PLINE(0.5f, 0.5f, 0.9f, 0.2f)
|
||||
|
||||
#undef PLINE
|
||||
}
|
||||
|
||||
static void drawIconMail(
|
||||
const ImVec2 p0,
|
||||
const ImVec2 p1_o,
|
||||
const ImU32 col_main,
|
||||
const ImU32 col_back
|
||||
) {
|
||||
// dark background
|
||||
// the circle looks bad in light mode
|
||||
//ImGui::GetWindowDrawList()->AddCircleFilled({p0.x + p1_o.x*0.5f, p0.y + p1_o.y*0.5f}, p1_o.x*0.5f, col_back);
|
||||
drawIconMailLines(p0, p1_o, col_back, 4.0f);
|
||||
drawIconMailLines(p0, p1_o, col_main, 1.5f);
|
||||
}
|
||||
#include "./icons/direct.hpp"
|
||||
#include "./icons/cloud.hpp"
|
||||
#include "./icons/mail.hpp"
|
||||
#include "./icons/person.hpp"
|
||||
#include "./icons/group.hpp"
|
||||
|
||||
void renderAvatar(
|
||||
const Theme& th,
|
||||
@ -220,6 +97,11 @@ bool renderContactBig(
|
||||
|
||||
const auto* cstate = c.try_get<Contact::Components::ConnectionState>();
|
||||
if (ImGui::BeginItemTooltip()) {
|
||||
if (c.all_of<Contact::Components::ID>()) {
|
||||
const auto id_str = bin2hex(c.get<Contact::Components::ID>().data);
|
||||
ImGui::Text("ID: %s", id_str.c_str());
|
||||
}
|
||||
|
||||
if (cstate != nullptr) {
|
||||
ImGui::Text("Connection state: %s",
|
||||
(cstate->state == Contact::Components::ConnectionState::disconnected)
|
||||
@ -264,6 +146,9 @@ bool renderContactBig(
|
||||
ImGui::SameLine(0.f, same_line_spacing);
|
||||
ImGui::BeginGroup();
|
||||
{
|
||||
const bool is_group = c.all_of<Contact::Components::TagGroup>();
|
||||
const bool is_private = c.all_of<Contact::Components::TagPrivate>();
|
||||
|
||||
{ // line 1
|
||||
if (line_height == 1 && cstate != nullptr) {
|
||||
// icon pos
|
||||
@ -271,23 +156,52 @@ bool renderContactBig(
|
||||
p0.y += ImGui::GetStyle().FramePadding.y;
|
||||
ImVec2 p1_o = {img_y, img_y}; // img_y is 1 line_height in this case
|
||||
|
||||
const ImU32 col_back = ImGui::GetColorU32(th.getColor<ThemeCol_Contact::icon_backdrop>());
|
||||
if (cstate->state == Contact::Components::ConnectionState::direct) { // direct icon
|
||||
drawIconDirect(
|
||||
p0,
|
||||
p1_o,
|
||||
ImGui::GetColorU32(th.getColor<ThemeCol_Contact::avatar_online_direct>()),
|
||||
col_back
|
||||
);
|
||||
} else if (cstate->state == Contact::Components::ConnectionState::cloud) { // cloud icon
|
||||
drawIconCloud(
|
||||
p0,
|
||||
p1_o,
|
||||
ImGui::GetColorU32(th.getColor<ThemeCol_Contact::avatar_online_cloud>()),
|
||||
col_back
|
||||
);
|
||||
}
|
||||
ImGui::Dummy(p1_o);
|
||||
if (ImGui::IsItemVisible()) {
|
||||
const ImU32 col_back = ImGui::GetColorU32(th.getColor<ThemeCol_Contact::icon_backdrop>());
|
||||
if (cstate->state == Contact::Components::ConnectionState::direct) { // direct icon
|
||||
drawIconDirect(
|
||||
p0,
|
||||
p1_o,
|
||||
ImGui::GetColorU32(th.getColor<ThemeCol_Contact::avatar_online_direct>()),
|
||||
col_back
|
||||
);
|
||||
} else if (cstate->state == Contact::Components::ConnectionState::cloud) { // cloud icon
|
||||
drawIconCloud(
|
||||
p0,
|
||||
p1_o,
|
||||
ImGui::GetColorU32(th.getColor<ThemeCol_Contact::avatar_online_cloud>()),
|
||||
col_back
|
||||
);
|
||||
}
|
||||
}
|
||||
ImGui::SameLine(0.f, same_line_spacing);
|
||||
}
|
||||
|
||||
// we dont render group/private in 1lh mode
|
||||
if (line_height != 1 && (is_private || is_group)) {
|
||||
// icon pos
|
||||
auto p0 = ImGui::GetCursorScreenPos();
|
||||
p0.y += ImGui::GetStyle().FramePadding.y;
|
||||
const float box_hight = TEXT_BASE_HEIGHT - ImGui::GetStyle().FramePadding.y*2;
|
||||
ImVec2 p1_o = {box_hight, box_hight};
|
||||
|
||||
ImGui::Dummy(p1_o);
|
||||
if (ImGui::IsItemVisible()) {
|
||||
if (is_private) {
|
||||
drawIconPerson(
|
||||
p0,
|
||||
p1_o,
|
||||
ImGui::GetColorU32(ImGui::GetStyleColorVec4(ImGuiCol_Text))
|
||||
);
|
||||
} else if (is_group) {
|
||||
drawIconGroup(
|
||||
p0,
|
||||
p1_o,
|
||||
ImGui::GetColorU32(ImGui::GetStyleColorVec4(ImGuiCol_Text))
|
||||
);
|
||||
}
|
||||
}
|
||||
ImGui::SameLine(0.f, same_line_spacing);
|
||||
}
|
||||
|
||||
@ -327,23 +241,25 @@ bool renderContactBig(
|
||||
const float box_hight = TEXT_BASE_HEIGHT - ImGui::GetStyle().FramePadding.y*2;
|
||||
ImVec2 p1_o = {box_hight, box_hight};
|
||||
|
||||
const ImU32 col_back = ImGui::GetColorU32(th.getColor<ThemeCol_Contact::icon_backdrop>());
|
||||
if (cstate->state == Contact::Components::ConnectionState::direct) { // direct icon
|
||||
drawIconDirect(
|
||||
p0,
|
||||
p1_o,
|
||||
ImGui::GetColorU32(th.getColor<ThemeCol_Contact::avatar_online_direct>()),
|
||||
col_back
|
||||
);
|
||||
} else if (cstate->state == Contact::Components::ConnectionState::cloud) { // cloud icon
|
||||
drawIconCloud(
|
||||
p0,
|
||||
p1_o,
|
||||
ImGui::GetColorU32(th.getColor<ThemeCol_Contact::avatar_online_cloud>()),
|
||||
col_back
|
||||
);
|
||||
}
|
||||
ImGui::Dummy(p1_o);
|
||||
if (ImGui::IsItemVisible()) {
|
||||
const ImU32 col_back = ImGui::GetColorU32(th.getColor<ThemeCol_Contact::icon_backdrop>());
|
||||
if (cstate->state == Contact::Components::ConnectionState::direct) { // direct icon
|
||||
drawIconDirect(
|
||||
p0,
|
||||
p1_o,
|
||||
ImGui::GetColorU32(th.getColor<ThemeCol_Contact::avatar_online_direct>()),
|
||||
col_back
|
||||
);
|
||||
} else if (cstate->state == Contact::Components::ConnectionState::cloud) { // cloud icon
|
||||
drawIconCloud(
|
||||
p0,
|
||||
p1_o,
|
||||
ImGui::GetColorU32(th.getColor<ThemeCol_Contact::avatar_online_cloud>()),
|
||||
col_back
|
||||
);
|
||||
}
|
||||
}
|
||||
ImGui::SameLine(0.f, same_line_spacing);
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
void FileSelector::reset(void) {
|
||||
_is_valid = [](auto){ return true; };
|
||||
|
41
src/chat_gui/icons/cloud.cpp
Normal file
41
src/chat_gui/icons/cloud.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
#include "./cloud.hpp"
|
||||
|
||||
#include <array>
|
||||
|
||||
void drawIconCloud(
|
||||
const ImVec2 p0,
|
||||
const ImVec2 p1_o,
|
||||
const ImU32 col_main,
|
||||
const ImU32 col_back
|
||||
) {
|
||||
std::array<ImVec2, 19> points {{
|
||||
{0.2f, 0.9f},
|
||||
{0.8f, 0.9f},
|
||||
{0.9f, 0.8f},
|
||||
{0.9f, 0.7f},
|
||||
{0.7f, 0.7f},
|
||||
{0.9f, 0.5f},
|
||||
{0.9f, 0.4f},
|
||||
{0.8f, 0.2f},
|
||||
{0.6f, 0.2f},
|
||||
{0.5f, 0.3f},
|
||||
{0.5f, 0.5f},
|
||||
{0.4f, 0.4f},
|
||||
{0.3f, 0.4f},
|
||||
{0.2f, 0.5f},
|
||||
{0.2f, 0.6f},
|
||||
{0.3f, 0.7f},
|
||||
{0.1f, 0.7f},
|
||||
{0.1f, 0.8f},
|
||||
{0.2f, 0.9f},
|
||||
}};
|
||||
for (auto& v : points) {
|
||||
v.y -= 0.1f;
|
||||
v = {p0.x + p1_o.x*v.x, p0.y + p1_o.y*v.y};
|
||||
}
|
||||
// the circle looks bad in light mode
|
||||
//ImGui::GetWindowDrawList()->AddCircleFilled({p0.x + p1_o.x*0.5f, p0.y + p1_o.y*0.5f}, p1_o.x*0.5f, col_back);
|
||||
ImGui::GetWindowDrawList()->AddPolyline(points.data(), points.size(), col_back, ImDrawFlags_None, 4.f);
|
||||
ImGui::GetWindowDrawList()->AddPolyline(points.data(), points.size(), col_main, ImDrawFlags_None, 1.5f);
|
||||
}
|
||||
|
11
src/chat_gui/icons/cloud.hpp
Normal file
11
src/chat_gui/icons/cloud.hpp
Normal file
@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <imgui/imgui.h>
|
||||
|
||||
void drawIconCloud(
|
||||
const ImVec2 p0,
|
||||
const ImVec2 p1_o,
|
||||
const ImU32 col_main,
|
||||
const ImU32 col_back
|
||||
);
|
||||
|
49
src/chat_gui/icons/direct.cpp
Normal file
49
src/chat_gui/icons/direct.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
#include "./direct.hpp"
|
||||
|
||||
#include <array>
|
||||
|
||||
static void drawIconDirectLines(
|
||||
const ImVec2 p0,
|
||||
const ImVec2 p1_o,
|
||||
const ImU32 col,
|
||||
const float thickness
|
||||
) {
|
||||
#define PLINE(x0, y0, x1, y1) \
|
||||
ImGui::GetWindowDrawList()->AddLine( \
|
||||
{p0.x + p1_o.x*(x0), p0.y + p1_o.y*(y0)}, \
|
||||
{p0.x + p1_o.x*(x1), p0.y + p1_o.y*(y1)}, \
|
||||
col, \
|
||||
thickness \
|
||||
);
|
||||
|
||||
// arrow 1
|
||||
// (3,1) -> (9,7)
|
||||
PLINE(0.3f, 0.1f, 0.9f, 0.7f)
|
||||
// (9,7) -> (9,5)
|
||||
PLINE(0.9f, 0.7f, 0.9f, 0.5f)
|
||||
// (9,7) -> (7,7)
|
||||
PLINE(0.9f, 0.7f, 0.7f, 0.7f)
|
||||
|
||||
// arrow 2
|
||||
// (7,9) -> (1,3)
|
||||
PLINE(0.7f, 0.9f, 0.1f, 0.3f)
|
||||
// (1,3) -> (3,3)
|
||||
PLINE(0.1f, 0.3f, 0.3f, 0.3f)
|
||||
// (1,3) -> (1,5)
|
||||
PLINE(0.1f, 0.3f, 0.1f, 0.5f)
|
||||
#undef PLINE
|
||||
}
|
||||
|
||||
void drawIconDirect(
|
||||
const ImVec2 p0,
|
||||
const ImVec2 p1_o,
|
||||
const ImU32 col_main,
|
||||
const ImU32 col_back
|
||||
) {
|
||||
// dark background
|
||||
// the circle looks bad in light mode
|
||||
//ImGui::GetWindowDrawList()->AddCircleFilled({p0.x + p1_o.x*0.5f, p0.y + p1_o.y*0.5f}, p1_o.x*0.5f, col_back);
|
||||
drawIconDirectLines(p0, p1_o, col_back, 4.0f);
|
||||
drawIconDirectLines(p0, p1_o, col_main, 1.5f);
|
||||
}
|
||||
|
10
src/chat_gui/icons/direct.hpp
Normal file
10
src/chat_gui/icons/direct.hpp
Normal file
@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <imgui/imgui.h>
|
||||
|
||||
void drawIconDirect(
|
||||
const ImVec2 p0,
|
||||
const ImVec2 p1_o,
|
||||
const ImU32 col_main,
|
||||
const ImU32 col_back
|
||||
);
|
139
src/chat_gui/icons/group.cpp
Normal file
139
src/chat_gui/icons/group.cpp
Normal file
@ -0,0 +1,139 @@
|
||||
#include "./group.hpp"
|
||||
|
||||
#include <array>
|
||||
|
||||
static void drawIconGroupLines(
|
||||
const ImVec2 p0,
|
||||
const ImVec2 p1_o,
|
||||
const ImU32 col,
|
||||
const float thickness
|
||||
) {
|
||||
#define PLINE(x0, y0, x1, y1) \
|
||||
ImGui::GetWindowDrawList()->AddLine( \
|
||||
{p0.x + p1_o.x*(x0), p0.y + p1_o.y*(y0)}, \
|
||||
{p0.x + p1_o.x*(x1), p0.y + p1_o.y*(y1)}, \
|
||||
col, \
|
||||
thickness \
|
||||
);
|
||||
|
||||
// person front
|
||||
// x y
|
||||
PLINE(
|
||||
0.1f, 0.9f,
|
||||
0.6f, 0.9f
|
||||
)
|
||||
PLINE(
|
||||
0.6f, 0.9f,
|
||||
0.6f, 0.7f
|
||||
)
|
||||
PLINE(
|
||||
0.6f, 0.7f,
|
||||
0.5f, 0.6f
|
||||
)
|
||||
PLINE(
|
||||
0.5f, 0.6f,
|
||||
0.4f, 0.6f
|
||||
)
|
||||
PLINE(
|
||||
0.4f, 0.6f,
|
||||
0.5f, 0.5f
|
||||
)
|
||||
PLINE(
|
||||
0.5f, 0.5f,
|
||||
0.5f, 0.4f
|
||||
)
|
||||
PLINE(
|
||||
0.5f, 0.4f,
|
||||
0.4f, 0.3f
|
||||
)
|
||||
PLINE(
|
||||
0.4f, 0.3f,
|
||||
0.3f, 0.3f
|
||||
)
|
||||
PLINE(
|
||||
0.3f, 0.3f,
|
||||
0.2f, 0.4f
|
||||
)
|
||||
PLINE(
|
||||
0.2f, 0.4f,
|
||||
0.2f, 0.5f
|
||||
)
|
||||
PLINE(
|
||||
0.2f, 0.5f,
|
||||
0.3f, 0.6f
|
||||
)
|
||||
PLINE(
|
||||
0.3f, 0.6f,
|
||||
0.2f, 0.6f
|
||||
)
|
||||
PLINE(
|
||||
0.2f, 0.6f,
|
||||
0.1f, 0.7f
|
||||
)
|
||||
PLINE(
|
||||
0.1f, 0.7f,
|
||||
0.1f, 0.9f
|
||||
)
|
||||
|
||||
// person back
|
||||
// x y
|
||||
PLINE(
|
||||
0.7f, 0.7f,
|
||||
0.9f, 0.7f
|
||||
)
|
||||
PLINE(
|
||||
0.9f, 0.7f,
|
||||
0.9f, 0.5f
|
||||
)
|
||||
PLINE(
|
||||
0.9f, 0.5f,
|
||||
0.8f, 0.4f
|
||||
)
|
||||
PLINE(
|
||||
0.8f, 0.4f,
|
||||
0.7f, 0.4f
|
||||
)
|
||||
PLINE(
|
||||
0.7f, 0.4f,
|
||||
0.8f, 0.3f
|
||||
)
|
||||
PLINE(
|
||||
0.8f, 0.3f,
|
||||
0.8f, 0.2f
|
||||
)
|
||||
PLINE(
|
||||
0.8f, 0.2f,
|
||||
0.7f, 0.1f
|
||||
)
|
||||
PLINE(
|
||||
0.7f, 0.1f,
|
||||
0.6f, 0.1f
|
||||
)
|
||||
PLINE(
|
||||
0.6f, 0.1f,
|
||||
0.5f, 0.2f
|
||||
)
|
||||
PLINE(
|
||||
0.5f, 0.2f,
|
||||
0.5f, 0.3f
|
||||
)
|
||||
PLINE(
|
||||
0.5f, 0.3f,
|
||||
0.6f, 0.4f
|
||||
)
|
||||
|
||||
#undef PLINE
|
||||
}
|
||||
|
||||
void drawIconGroup(
|
||||
const ImVec2 p0,
|
||||
const ImVec2 p1_o,
|
||||
const ImU32 col_main
|
||||
) {
|
||||
// dark background
|
||||
// the circle looks bad in light mode
|
||||
//ImGui::GetWindowDrawList()->AddCircleFilled({p0.x + p1_o.x*0.5f, p0.y + p1_o.y*0.5f}, p1_o.x*0.5f, col_back);
|
||||
//drawIconGroupLines(p0, p1_o, col_back, 3.5f);
|
||||
drawIconGroupLines(p0, p1_o, col_main, 1.0f);
|
||||
}
|
||||
|
10
src/chat_gui/icons/group.hpp
Normal file
10
src/chat_gui/icons/group.hpp
Normal file
@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <imgui/imgui.h>
|
||||
|
||||
void drawIconGroup(
|
||||
const ImVec2 p0,
|
||||
const ImVec2 p1_o,
|
||||
const ImU32 col_main
|
||||
);
|
||||
|
50
src/chat_gui/icons/mail.cpp
Normal file
50
src/chat_gui/icons/mail.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
#include "./mail.hpp"
|
||||
|
||||
#include <array>
|
||||
|
||||
static void drawIconMailLines(
|
||||
const ImVec2 p0,
|
||||
const ImVec2 p1_o,
|
||||
const ImU32 col,
|
||||
const float thickness
|
||||
) {
|
||||
#define PLINE(x0, y0, x1, y1) \
|
||||
ImGui::GetWindowDrawList()->AddLine( \
|
||||
{p0.x + p1_o.x*(x0), p0.y + p1_o.y*(y0)}, \
|
||||
{p0.x + p1_o.x*(x1), p0.y + p1_o.y*(y1)}, \
|
||||
col, \
|
||||
thickness \
|
||||
);
|
||||
|
||||
// quad
|
||||
// (1,2) -> (1,8)
|
||||
PLINE(0.1f, 0.2f, 0.1f, 0.8f)
|
||||
// (1,8) -> (9,8)
|
||||
PLINE(0.1f, 0.8f, 0.9f, 0.8f)
|
||||
// (9,8) -> (9,2)
|
||||
PLINE(0.9f, 0.8f, 0.9f, 0.2f)
|
||||
// (9,2) -> (1,2)
|
||||
PLINE(0.9f, 0.2f, 0.1f, 0.2f)
|
||||
|
||||
// lip
|
||||
// (1,2) -> (5,5)
|
||||
PLINE(0.1f, 0.2f, 0.5f, 0.5f)
|
||||
// (5,5) -> (9,2)
|
||||
PLINE(0.5f, 0.5f, 0.9f, 0.2f)
|
||||
|
||||
#undef PLINE
|
||||
}
|
||||
|
||||
void drawIconMail(
|
||||
const ImVec2 p0,
|
||||
const ImVec2 p1_o,
|
||||
const ImU32 col_main,
|
||||
const ImU32 col_back
|
||||
) {
|
||||
// dark background
|
||||
// the circle looks bad in light mode
|
||||
//ImGui::GetWindowDrawList()->AddCircleFilled({p0.x + p1_o.x*0.5f, p0.y + p1_o.y*0.5f}, p1_o.x*0.5f, col_back);
|
||||
drawIconMailLines(p0, p1_o, col_back, 4.0f);
|
||||
drawIconMailLines(p0, p1_o, col_main, 1.5f);
|
||||
}
|
||||
|
11
src/chat_gui/icons/mail.hpp
Normal file
11
src/chat_gui/icons/mail.hpp
Normal file
@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <imgui/imgui.h>
|
||||
|
||||
void drawIconMail(
|
||||
const ImVec2 p0,
|
||||
const ImVec2 p1_o,
|
||||
const ImU32 col_main,
|
||||
const ImU32 col_back
|
||||
);
|
||||
|
101
src/chat_gui/icons/person.cpp
Normal file
101
src/chat_gui/icons/person.cpp
Normal file
@ -0,0 +1,101 @@
|
||||
#include "./person.hpp"
|
||||
|
||||
#include <array>
|
||||
|
||||
static void drawIconPersonLines(
|
||||
const ImVec2 p0,
|
||||
const ImVec2 p1_o,
|
||||
const ImU32 col,
|
||||
const float thickness
|
||||
) {
|
||||
#define PLINE(x0, y0, x1, y1) \
|
||||
ImGui::GetWindowDrawList()->AddLine( \
|
||||
{p0.x + p1_o.x*(x0), p0.y + p1_o.y*(y0)}, \
|
||||
{p0.x + p1_o.x*(x1), p0.y + p1_o.y*(y1)}, \
|
||||
col, \
|
||||
thickness \
|
||||
);
|
||||
|
||||
//// quad
|
||||
//// (1,2) -> (1,8)
|
||||
//PLINE(0.1f, 0.2f, 0.1f, 0.8f)
|
||||
//// (1,8) -> (9,8)
|
||||
//PLINE(0.1f, 0.8f, 0.9f, 0.8f)
|
||||
//// (9,8) -> (9,2)
|
||||
//PLINE(0.9f, 0.8f, 0.9f, 0.2f)
|
||||
//// (9,2) -> (1,2)
|
||||
//PLINE(0.9f, 0.2f, 0.1f, 0.2f)
|
||||
|
||||
// x y
|
||||
PLINE(
|
||||
0.2f, 0.8f,
|
||||
0.8f, 0.8f
|
||||
)
|
||||
PLINE(
|
||||
0.8f, 0.8f,
|
||||
0.8f, 0.6f
|
||||
)
|
||||
PLINE(
|
||||
0.8f, 0.6f,
|
||||
0.7f, 0.5f
|
||||
)
|
||||
PLINE(
|
||||
0.7f, 0.5f,
|
||||
0.6f, 0.5f
|
||||
)
|
||||
PLINE(
|
||||
0.6f, 0.5f,
|
||||
0.7f, 0.4f
|
||||
)
|
||||
PLINE(
|
||||
0.7f, 0.4f,
|
||||
0.7f, 0.2f
|
||||
)
|
||||
PLINE(
|
||||
0.7f, 0.2f,
|
||||
0.6f, 0.1f
|
||||
)
|
||||
PLINE(
|
||||
0.6f, 0.1f,
|
||||
0.4f, 0.1f
|
||||
)
|
||||
PLINE(
|
||||
0.4f, 0.1f,
|
||||
0.3f, 0.2f
|
||||
)
|
||||
PLINE(
|
||||
0.3f, 0.2f,
|
||||
0.3f, 0.4f
|
||||
)
|
||||
PLINE(
|
||||
0.3f, 0.4f,
|
||||
0.4f, 0.5f
|
||||
)
|
||||
PLINE(
|
||||
0.4f, 0.5f,
|
||||
0.3f, 0.5f
|
||||
)
|
||||
PLINE(
|
||||
0.3f, 0.5f,
|
||||
0.2f, 0.6f
|
||||
)
|
||||
PLINE(
|
||||
0.2f, 0.6f,
|
||||
0.2f, 0.8f
|
||||
)
|
||||
|
||||
#undef PLINE
|
||||
}
|
||||
|
||||
void drawIconPerson(
|
||||
const ImVec2 p0,
|
||||
const ImVec2 p1_o,
|
||||
const ImU32 col_main
|
||||
) {
|
||||
// dark background
|
||||
// the circle looks bad in light mode
|
||||
//ImGui::GetWindowDrawList()->AddCircleFilled({p0.x + p1_o.x*0.5f, p0.y + p1_o.y*0.5f}, p1_o.x*0.5f, col_back);
|
||||
//drawIconPersonLines(p0, p1_o, col_back, 3.5f);
|
||||
drawIconPersonLines(p0, p1_o, col_main, 1.0f);
|
||||
}
|
||||
|
10
src/chat_gui/icons/person.hpp
Normal file
10
src/chat_gui/icons/person.hpp
Normal file
@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <imgui/imgui.h>
|
||||
|
||||
void drawIconPerson(
|
||||
const ImVec2 p0,
|
||||
const ImVec2 p1_o,
|
||||
const ImU32 col_main
|
||||
);
|
||||
|
@ -63,6 +63,28 @@ static constexpr float lerp(float a, float b, float t) {
|
||||
return a + t * (b - a);
|
||||
}
|
||||
|
||||
// returns divider and places static suffix string into suffix_out
|
||||
static int64_t sizeToHumanReadable(int64_t file_size, const char*& suffix_out) {
|
||||
static const char* suffix_arr[] {
|
||||
"bytes",
|
||||
"KiB",
|
||||
"MiB",
|
||||
"GiB",
|
||||
"TiB",
|
||||
"PiB",
|
||||
// TODO: fix upper bound behaviour
|
||||
};
|
||||
int64_t divider = 1024;
|
||||
for (size_t ij = 0; ij < std::size(suffix_arr); ij++, divider *= 1024) {
|
||||
if (file_size < divider) {
|
||||
suffix_out = suffix_arr[ij];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (divider > 1024) ? (divider / 1024) : 1;
|
||||
}
|
||||
|
||||
static std::string file_path_url_escape(const std::string&& value) {
|
||||
std::ostringstream escaped;
|
||||
|
||||
@ -817,6 +839,7 @@ void ChatGui4::sendFilePath(const char* file_path) {
|
||||
void ChatGui4::renderMessageBodyText(Message3Registry& reg, const Message3 e) {
|
||||
const auto& msgtext = reg.get<Message::Components::MessageText>(e).text;
|
||||
|
||||
#if 0
|
||||
// TODO: set word wrap
|
||||
ImVec2 text_size = ImGui::CalcTextSize(msgtext.c_str(), msgtext.c_str()+msgtext.size());
|
||||
text_size.x = -FLT_MIN; // fill width (suppresses label)
|
||||
@ -849,11 +872,72 @@ void ChatGui4::renderMessageBodyText(Message3Registry& reg, const Message3 e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ImGui::MenuItem("copy")) {
|
||||
ImGui::SetClipboardText(msgtext.c_str());
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::PopStyleVar();
|
||||
#else
|
||||
|
||||
ImGui::PushTextWrapPos(0.0f);
|
||||
std::string_view msgtext_sv{msgtext};
|
||||
size_t pos_prev {0};
|
||||
size_t pos_next {msgtext_sv.find_first_of('\n')};
|
||||
ImGui::BeginGroup();
|
||||
do {
|
||||
const auto current_line = msgtext_sv.substr(pos_prev, pos_next - pos_prev);
|
||||
if (current_line.front() == '>') {
|
||||
// TODO: theming
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, {0.3f, 0.9f, 0.1f, 1.f});
|
||||
ImGui::TextUnformatted(current_line.data(), current_line.data()+current_line.size());
|
||||
ImGui::PopStyleColor();
|
||||
} else {
|
||||
ImGui::TextUnformatted(current_line.data(), current_line.data()+current_line.size());
|
||||
}
|
||||
|
||||
if (pos_next != msgtext_sv.npos) {
|
||||
pos_next += 1; // skip past
|
||||
if (pos_next < msgtext_sv.size()) {
|
||||
pos_prev = pos_next; // old end is new start
|
||||
pos_next = msgtext_sv.find_first_of('\n', pos_next);
|
||||
} else {
|
||||
pos_prev = msgtext_sv.npos;
|
||||
pos_next = msgtext_sv.npos;
|
||||
}
|
||||
} else {
|
||||
pos_prev = msgtext_sv.npos;
|
||||
}
|
||||
} while (pos_prev != msgtext_sv.npos);
|
||||
|
||||
ImGui::EndGroup();
|
||||
ImGui::PopTextWrapPos();
|
||||
|
||||
if (ImGui::BeginPopupContextItem("##text")) {
|
||||
if (ImGui::MenuItem("quote")) {
|
||||
//text_buffer.insert(0, (_cr.all_of<Contact::Components::Name>(c) ? _cr.get<Contact::Components::Name>(c).name : "<unk>") + ": ");
|
||||
if (!_text_input_buffer.empty()) {
|
||||
_text_input_buffer += "\n";
|
||||
}
|
||||
|
||||
_text_input_buffer += "> ";
|
||||
|
||||
for (const char c : msgtext) {
|
||||
_text_input_buffer += c;
|
||||
|
||||
if (c == '\n') {
|
||||
_text_input_buffer += "> ";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ImGui::MenuItem("copy")) {
|
||||
ImGui::SetClipboardText(msgtext.c_str());
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ChatGui4::renderMessageBodyFile(Message3Registry& reg, const Message3 e) {
|
||||
@ -995,8 +1079,16 @@ void ChatGui4::renderMessageBodyFile(Message3Registry& reg, const Message3 e) {
|
||||
for (size_t i = 0; i < file_list.size(); i++) {
|
||||
ImGui::PushID(i);
|
||||
|
||||
const char* byte_suffix = "???";
|
||||
int64_t byte_divider = sizeToHumanReadable(file_list[i].file_size, byte_suffix);
|
||||
|
||||
// TODO: selectable text widget ?
|
||||
ImGui::Bullet(); ImGui::Text("%s (%lu)", file_list[i].file_name.c_str(), file_list[i].file_size);
|
||||
ImGui::Bullet(); ImGui::Text("%s (%.2lf %s)", file_list[i].file_name.c_str(), double(file_list[i].file_size)/byte_divider, byte_suffix);
|
||||
if (ImGui::BeginItemTooltip()) {
|
||||
ImGui::Text("TODO: file path?");
|
||||
ImGui::Text("%lu bytes", file_list[i].file_size);
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
if (reg.all_of<Message::Components::Transfer::FileInfoLocal>(e)) {
|
||||
const auto& local_info = reg.get<Message::Components::Transfer::FileInfoLocal>(e);
|
||||
|
@ -27,6 +27,8 @@ struct ImageLoaderI {
|
||||
|
||||
// only positive values are valid
|
||||
ImageResult crop(int32_t c_x, int32_t c_y, int32_t c_w, int32_t c_h) const;
|
||||
|
||||
// TODO: scale
|
||||
};
|
||||
virtual ImageResult loadFromMemoryRGBA(const uint8_t* data, uint64_t data_size) = 0;
|
||||
};
|
||||
|
@ -33,7 +33,7 @@ ImageLoaderSDLBMP::ImageResult ImageLoaderSDLBMP::loadFromMemoryRGBA(const uint8
|
||||
return res;
|
||||
}
|
||||
|
||||
SDL_Surface* conv_surf = SDL_ConvertSurfaceFormat(surf, SDL_PIXELFORMAT_RGBA32);
|
||||
SDL_Surface* conv_surf = SDL_ConvertSurface(surf, SDL_PIXELFORMAT_RGBA32);
|
||||
SDL_DestroySurface(surf);
|
||||
if (conv_surf == nullptr) {
|
||||
return res;
|
||||
|
@ -89,7 +89,7 @@ ImageLoaderSDLImage::ImageResult ImageLoaderSDLImage::loadFromMemoryRGBA(const u
|
||||
}
|
||||
|
||||
for (int i = 0; i < anim->count; i++) {
|
||||
SDL_Surface* conv_surf = SDL_ConvertSurfaceFormat(anim->frames[i], SDL_PIXELFORMAT_RGBA32);
|
||||
SDL_Surface* conv_surf = SDL_ConvertSurface(anim->frames[i], SDL_PIXELFORMAT_RGBA32);
|
||||
if (conv_surf == nullptr) {
|
||||
return res;
|
||||
}
|
||||
|
319
src/imgui_entt_entity_editor.hpp
Normal file
319
src/imgui_entt_entity_editor.hpp
Normal file
@ -0,0 +1,319 @@
|
||||
// for the license, see the end of the file
|
||||
#pragma once
|
||||
|
||||
#include "entt/entity/fwd.hpp"
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
#include <entt/entt.hpp>
|
||||
#include <imgui.h>
|
||||
|
||||
#ifndef MM_IEEE_ASSERT
|
||||
#define MM_IEEE_ASSERT(x) assert(x)
|
||||
#endif
|
||||
|
||||
#define MM_IEEE_IMGUI_PAYLOAD_TYPE_ENTITY "MM_IEEE_ENTITY"
|
||||
|
||||
#ifndef MM_IEEE_ENTITY_WIDGET
|
||||
#define MM_IEEE_ENTITY_WIDGET ::MM::EntityWidget
|
||||
#endif
|
||||
|
||||
namespace MM {
|
||||
|
||||
template <class EntityType>
|
||||
inline void EntityWidget(EntityType& e, entt::basic_registry<EntityType>& reg, bool dropTarget = false)
|
||||
{
|
||||
ImGui::PushID(static_cast<int>(entt::to_integral(e)));
|
||||
|
||||
if (reg.valid(e)) {
|
||||
ImGui::Text("ID: %d", entt::to_integral(e));
|
||||
} else {
|
||||
ImGui::Text("Invalid Entity");
|
||||
}
|
||||
|
||||
if (reg.valid(e)) {
|
||||
if (ImGui::BeginDragDropSource(ImGuiDragDropFlags_SourceAllowNullID)) {
|
||||
ImGui::SetDragDropPayload(MM_IEEE_IMGUI_PAYLOAD_TYPE_ENTITY, &e, sizeof(e));
|
||||
ImGui::Text("ID: %d", entt::to_integral(e));
|
||||
ImGui::EndDragDropSource();
|
||||
}
|
||||
}
|
||||
|
||||
if (dropTarget && ImGui::BeginDragDropTarget()) {
|
||||
if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload(MM_IEEE_IMGUI_PAYLOAD_TYPE_ENTITY)) {
|
||||
e = *(EntityType*)payload->Data;
|
||||
}
|
||||
|
||||
ImGui::EndDragDropTarget();
|
||||
}
|
||||
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
template <class Component, class EntityType>
|
||||
void ComponentEditorWidget([[maybe_unused]] entt::basic_registry<EntityType>& registry, [[maybe_unused]] EntityType entity) {}
|
||||
|
||||
template <class Component, class EntityType>
|
||||
void ComponentAddAction(entt::basic_registry<EntityType>& registry, EntityType entity)
|
||||
{
|
||||
registry.template emplace<Component>(entity);
|
||||
}
|
||||
|
||||
template <class Component, class EntityType>
|
||||
void ComponentRemoveAction(entt::basic_registry<EntityType>& registry, EntityType entity)
|
||||
{
|
||||
registry.template remove<Component>(entity);
|
||||
}
|
||||
|
||||
template <class EntityType>
|
||||
class EntityEditor {
|
||||
public:
|
||||
using Registry = entt::basic_registry<EntityType>;
|
||||
using ComponentTypeID = entt::id_type;
|
||||
|
||||
struct ComponentInfo {
|
||||
using Callback = std::function<void(Registry&, EntityType)>;
|
||||
std::string name;
|
||||
Callback widget, create, destroy;
|
||||
};
|
||||
|
||||
bool show_window = true;
|
||||
|
||||
private:
|
||||
std::map<ComponentTypeID, ComponentInfo> component_infos;
|
||||
|
||||
bool entityHasComponent(Registry& registry, EntityType& entity, ComponentTypeID type_id)
|
||||
{
|
||||
const auto* storage_ptr = registry.storage(type_id);
|
||||
return storage_ptr != nullptr && storage_ptr->contains(entity);
|
||||
}
|
||||
|
||||
public:
|
||||
template <class Component>
|
||||
ComponentInfo& registerComponent(const ComponentInfo& component_info)
|
||||
{
|
||||
auto index = entt::type_hash<Component>::value();
|
||||
auto insert_info = component_infos.insert_or_assign(index, component_info);
|
||||
MM_IEEE_ASSERT(insert_info.second);
|
||||
return std::get<ComponentInfo>(*insert_info.first);
|
||||
}
|
||||
|
||||
template <class Component>
|
||||
ComponentInfo& registerComponent(const std::string& name, typename ComponentInfo::Callback widget)
|
||||
{
|
||||
return registerComponent<Component>(ComponentInfo{
|
||||
name,
|
||||
widget,
|
||||
ComponentAddAction<Component, EntityType>,
|
||||
ComponentRemoveAction<Component, EntityType>,
|
||||
});
|
||||
}
|
||||
|
||||
template <class Component>
|
||||
ComponentInfo& registerComponent(const std::string& name)
|
||||
{
|
||||
return registerComponent<Component>(name, ComponentEditorWidget<Component, EntityType>);
|
||||
}
|
||||
|
||||
void renderEditor(Registry& registry, EntityType& e)
|
||||
{
|
||||
ImGui::TextUnformatted("Editing:");
|
||||
ImGui::SameLine();
|
||||
|
||||
MM_IEEE_ENTITY_WIDGET(e, registry, true);
|
||||
|
||||
if (ImGui::Button("New")) {
|
||||
e = registry.create();
|
||||
}
|
||||
if (registry.valid(e)) {
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button("Clone")) {
|
||||
auto old_e = e;
|
||||
e = registry.create();
|
||||
|
||||
// create a copy of an entity component by component
|
||||
for (auto &&curr: registry.storage()) {
|
||||
if (auto &storage = curr.second; storage.contains(old_e)) {
|
||||
// TODO: do something with the return value. returns false on failure.
|
||||
storage.push(e, storage.value(old_e));
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui::SameLine();
|
||||
|
||||
ImGui::Dummy({10, 0}); // space destroy a bit, to not accidentally click it
|
||||
ImGui::SameLine();
|
||||
|
||||
// red button
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.65f, 0.15f, 0.15f, 1.f));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.8f, 0.3f, 0.3f, 1.f));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(1.f, 0.2f, 0.2f, 1.f));
|
||||
if (ImGui::Button("Destroy")) {
|
||||
registry.destroy(e);
|
||||
e = entt::null;
|
||||
}
|
||||
ImGui::PopStyleColor(3);
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (registry.valid(e)) {
|
||||
ImGui::PushID(static_cast<int>(entt::to_integral(e)));
|
||||
std::map<ComponentTypeID, ComponentInfo> has_not;
|
||||
for (auto& [component_type_id, ci] : component_infos) {
|
||||
if (entityHasComponent(registry, e, component_type_id)) {
|
||||
ImGui::PushID(component_type_id);
|
||||
if (ImGui::Button("-")) {
|
||||
ci.destroy(registry, e);
|
||||
ImGui::PopID();
|
||||
continue; // early out to prevent access to deleted data
|
||||
} else {
|
||||
ImGui::SameLine();
|
||||
}
|
||||
|
||||
if (ImGui::CollapsingHeader(ci.name.c_str())) {
|
||||
ImGui::Indent(30.f);
|
||||
ImGui::PushID("Widget");
|
||||
ci.widget(registry, e);
|
||||
ImGui::PopID();
|
||||
ImGui::Unindent(30.f);
|
||||
}
|
||||
ImGui::PopID();
|
||||
} else {
|
||||
has_not[component_type_id] = ci;
|
||||
}
|
||||
}
|
||||
|
||||
if (!has_not.empty()) {
|
||||
if (ImGui::Button("+ Add Component")) {
|
||||
ImGui::OpenPopup("Add Component");
|
||||
}
|
||||
|
||||
if (ImGui::BeginPopup("Add Component")) {
|
||||
ImGui::TextUnformatted("Available:");
|
||||
ImGui::Separator();
|
||||
|
||||
for (auto& [component_type_id, ci] : has_not) {
|
||||
ImGui::PushID(component_type_id);
|
||||
if (ImGui::Selectable(ci.name.c_str())) {
|
||||
ci.create(registry, e);
|
||||
}
|
||||
ImGui::PopID();
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
ImGui::PopID();
|
||||
}
|
||||
}
|
||||
|
||||
void renderEntityList(Registry& registry, std::set<ComponentTypeID>& comp_list)
|
||||
{
|
||||
ImGui::Text("Components Filter:");
|
||||
ImGui::SameLine();
|
||||
if (ImGui::SmallButton("clear")) {
|
||||
comp_list.clear();
|
||||
}
|
||||
|
||||
ImGui::Indent();
|
||||
|
||||
for (const auto& [component_type_id, ci] : component_infos) {
|
||||
bool is_in_list = comp_list.count(component_type_id);
|
||||
bool active = is_in_list;
|
||||
|
||||
ImGui::Checkbox(ci.name.c_str(), &active);
|
||||
|
||||
if (is_in_list && !active) { // remove
|
||||
comp_list.erase(component_type_id);
|
||||
} else if (!is_in_list && active) { // add
|
||||
comp_list.emplace(component_type_id);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::Unindent();
|
||||
ImGui::Separator();
|
||||
|
||||
if (comp_list.empty()) {
|
||||
ImGui::Text("Orphans:");
|
||||
for (EntityType e : registry.template storage<EntityType>()) {
|
||||
if (registry.orphan(e)) {
|
||||
MM_IEEE_ENTITY_WIDGET(e, registry, false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
entt::basic_runtime_view<entt::basic_sparse_set<EntityType>> view{};
|
||||
for (const auto type : comp_list) {
|
||||
auto* storage_ptr = registry.storage(type);
|
||||
if (storage_ptr != nullptr) {
|
||||
view.iterate(*storage_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: add support for exclude
|
||||
|
||||
ImGui::Text("%lu Entities Matching:", view.size_hint());
|
||||
|
||||
if (ImGui::BeginChild("entity list")) {
|
||||
for (auto e : view) {
|
||||
MM_IEEE_ENTITY_WIDGET(e, registry, false);
|
||||
}
|
||||
}
|
||||
ImGui::EndChild();
|
||||
}
|
||||
}
|
||||
|
||||
// displays both, editor and list
|
||||
// uses static internally, use only as a quick way to get going!
|
||||
void renderSimpleCombo(Registry& registry, EntityType& e)
|
||||
{
|
||||
if (show_window) {
|
||||
ImGui::SetNextWindowSize(ImVec2(550, 400), ImGuiCond_FirstUseEver);
|
||||
if (ImGui::Begin("Entity Editor", &show_window)) {
|
||||
if (ImGui::BeginChild("list", {200, 0}, true)) {
|
||||
static std::set<ComponentTypeID> comp_list;
|
||||
renderEntityList(registry, comp_list);
|
||||
}
|
||||
ImGui::EndChild();
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::BeginChild("editor")) {
|
||||
renderEditor(registry, e);
|
||||
}
|
||||
ImGui::EndChild();
|
||||
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // MM
|
||||
|
||||
// MIT License
|
||||
|
||||
// Copyright (c) 2019-2022 Erik Scholz
|
||||
// Copyright (c) 2020 Gnik Droy
|
||||
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
39
src/main.cpp
39
src/main.cpp
@ -8,6 +8,8 @@
|
||||
#include "./theme.hpp"
|
||||
#include "./chat_gui/theme.hpp"
|
||||
|
||||
#include "./sys_check.hpp"
|
||||
|
||||
#include "./start_screen.hpp"
|
||||
|
||||
#include <filesystem>
|
||||
@ -24,9 +26,11 @@ int main(int argc, char** argv) {
|
||||
args.push_back(argv[i]);
|
||||
}
|
||||
|
||||
runSysCheck();
|
||||
|
||||
#ifdef __ANDROID__
|
||||
// change current working dir to internal storage
|
||||
std::filesystem::current_path(SDL_AndroidGetInternalStoragePath());
|
||||
std::filesystem::current_path(SDL_GetAndroidInternalStoragePath());
|
||||
#endif
|
||||
|
||||
// setup hints
|
||||
@ -47,7 +51,7 @@ int main(int argc, char** argv) {
|
||||
|
||||
// more RAII
|
||||
std::unique_ptr<SDL_Window, decltype(&SDL_DestroyWindow)> window {
|
||||
SDL_CreateWindow("tomato", 1280, 720, SDL_WINDOW_RESIZABLE),
|
||||
SDL_CreateWindow("tomato", 1280, 720, SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIGH_PIXEL_DENSITY),
|
||||
&SDL_DestroyWindow
|
||||
};
|
||||
|
||||
@ -66,16 +70,19 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
SDL_SetRenderVSync(renderer.get(), SDL_RENDERER_VSYNC_ADAPTIVE);
|
||||
|
||||
{
|
||||
SDL_RendererInfo ri;
|
||||
if (SDL_GetRendererInfo(renderer.get(), &ri) == 0) {
|
||||
std::cout << "SDL Renderer: " << ri.name << "\n";
|
||||
}
|
||||
}
|
||||
std::cout << "SDL Renderer: " << SDL_GetRendererName(renderer.get()) << "\n";
|
||||
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
|
||||
// TODO: test android behaviour
|
||||
float display_scale = SDL_GetWindowDisplayScale(window.get());
|
||||
if (display_scale < 0.001f) {
|
||||
// error?
|
||||
display_scale = 1.f;
|
||||
}
|
||||
ImGui::GetStyle().ScaleAllSizes(display_scale);
|
||||
|
||||
Theme theme;
|
||||
if (SDL_GetSystemTheme() == SDL_SYSTEM_THEME_LIGHT) {
|
||||
ImGui::StyleColorsLight();
|
||||
@ -86,22 +93,6 @@ int main(int argc, char** argv) {
|
||||
theme = getDefaultThemeDark();
|
||||
}
|
||||
|
||||
{
|
||||
ImGui::GetIO().Fonts->ClearFonts();
|
||||
ImFontConfig fontcfg;
|
||||
|
||||
// upsampling to int looks almost ok
|
||||
const float font_size_scale = 1.3f;
|
||||
const float font_oversample = 4.f;
|
||||
|
||||
// default font is pixel perfect at 13
|
||||
fontcfg.SizePixels = 13.f * font_size_scale;
|
||||
fontcfg.RasterizerDensity = font_oversample/font_size_scale;
|
||||
// normally density would be set to dpi scale of the display
|
||||
|
||||
ImGui::GetIO().Fonts->AddFontDefault(&fontcfg);
|
||||
ImGui::GetIO().Fonts->Build();
|
||||
}
|
||||
|
||||
ImGui_ImplSDL3_InitForSDLRenderer(window.get(), renderer.get());
|
||||
ImGui_ImplSDLRenderer3_Init(renderer.get());
|
||||
|
@ -35,6 +35,7 @@ MainScreen::MainScreen(SimpleConfigModel&& conf_, SDL_Renderer* renderer_, Theme
|
||||
msg_tc(mil, sdlrtu),
|
||||
cg(conf, rmm, cr, sdlrtu, contact_tc, msg_tc, theme),
|
||||
sw(conf),
|
||||
osui(os),
|
||||
tuiu(tc, conf),
|
||||
tdch(tpi)
|
||||
{
|
||||
@ -192,7 +193,10 @@ bool MainScreen::handleEvent(SDL_Event& e) {
|
||||
e.type == SDL_EVENT_MOUSE_WHEEL ||
|
||||
e.type == SDL_EVENT_MOUSE_BUTTON_DOWN ||
|
||||
e.type == SDL_EVENT_MOUSE_BUTTON_UP ||
|
||||
e.type == SDL_EVENT_FINGER_DOWN ||
|
||||
e.type == SDL_EVENT_FINGER_UP ||
|
||||
e.type == SDL_EVENT_TEXT_INPUT ||
|
||||
e.type == SDL_EVENT_TEXT_EDITING ||
|
||||
e.type == SDL_EVENT_KEY_DOWN ||
|
||||
e.type == SDL_EVENT_KEY_UP ||
|
||||
e.type == SDL_EVENT_WINDOW_MOUSE_ENTER ||
|
||||
@ -245,6 +249,7 @@ Screen* MainScreen::render(float time_delta, bool&) {
|
||||
|
||||
const float cg_interval = cg.render(time_delta); // render
|
||||
sw.render(); // render
|
||||
osui.render();
|
||||
tuiu.render(); // render
|
||||
tdch.render(); // render
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
#include "./chat_gui4.hpp"
|
||||
#include "./chat_gui/settings_window.hpp"
|
||||
#include "./object_store_ui.hpp"
|
||||
#include "./tox_ui_utils.hpp"
|
||||
#include "./tox_dht_cap_histo.hpp"
|
||||
#include "./tox_friend_faux_offline_messaging.hpp"
|
||||
@ -77,6 +78,7 @@ struct MainScreen final : public Screen {
|
||||
|
||||
ChatGui4 cg;
|
||||
SettingsWindow sw;
|
||||
ObjectStoreUI osui;
|
||||
ToxUIUtils tuiu;
|
||||
ToxDHTCapHisto tdch;
|
||||
|
||||
|
104
src/object_store_ui.cpp
Normal file
104
src/object_store_ui.cpp
Normal file
@ -0,0 +1,104 @@
|
||||
#include "./object_store_ui.hpp"
|
||||
|
||||
#include <solanaceae/util/utils.hpp>
|
||||
#include <solanaceae/object_store/meta_components.hpp>
|
||||
|
||||
#include <imgui/imgui.h>
|
||||
|
||||
#include <solanaceae/message3/components.hpp>
|
||||
|
||||
namespace MM {
|
||||
|
||||
template<> void ComponentEditorWidget<ObjectStore::Components::ID>(entt::basic_registry<Object>& registry, Object entity) {
|
||||
auto& c = registry.get<ObjectStore::Components::ID>(entity);
|
||||
|
||||
const auto str = bin2hex(c.v);
|
||||
ImGui::TextUnformatted(str.c_str());
|
||||
}
|
||||
|
||||
template<> void ComponentEditorWidget<Message::Components::Transfer::FileInfo>(entt::basic_registry<Object>& registry, Object entity) {
|
||||
auto& c = registry.get<Message::Components::Transfer::FileInfo>(entity);
|
||||
|
||||
ImGui::Text("Total size: %lu", c.total_size);
|
||||
if (ImGui::BeginTable("file list", 2, ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_SizingFixedFit)) {
|
||||
ImGui::TableSetupColumn("name", ImGuiTableColumnFlags_WidthStretch);
|
||||
ImGui::TableSetupColumn("size", ImGuiTableColumnFlags_WidthFixed);
|
||||
ImGui::TableHeadersRow();
|
||||
|
||||
for (const auto& entry : c.file_list) {
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextUnformatted(entry.file_name.c_str());
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%lu", entry.file_size);
|
||||
}
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
}
|
||||
|
||||
template<> void ComponentEditorWidget<Message::Components::Transfer::FileInfoLocal>(entt::basic_registry<Object>& registry, Object entity) {
|
||||
auto& c = registry.get<Message::Components::Transfer::FileInfoLocal>(entity);
|
||||
|
||||
if (ImGui::BeginTable("file list", 1, ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_SizingFixedFit)) {
|
||||
ImGui::TableSetupColumn("name", ImGuiTableColumnFlags_WidthStretch);
|
||||
//ImGui::TableSetupColumn("size", ImGuiTableColumnFlags_WidthFixed);
|
||||
ImGui::TableHeadersRow();
|
||||
|
||||
for (const auto& entry : c.file_list) {
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextUnformatted(entry.c_str());
|
||||
}
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
}
|
||||
|
||||
template<> void ComponentEditorWidget<Message::Components::Transfer::BytesReceived>(entt::basic_registry<Object>& registry, Object entity) {
|
||||
auto& c = registry.get<Message::Components::Transfer::BytesReceived>(entity);
|
||||
ImGui::Text("total bytes received: %lu", c.total);
|
||||
}
|
||||
|
||||
template<> void ComponentEditorWidget<Message::Components::Transfer::BytesSent>(entt::basic_registry<Object>& registry, Object entity) {
|
||||
auto& c = registry.get<Message::Components::Transfer::BytesSent>(entity);
|
||||
ImGui::Text("total bytes sent: %lu", c.total);
|
||||
}
|
||||
|
||||
} // MM
|
||||
|
||||
ObjectStoreUI::ObjectStoreUI(
|
||||
ObjectStore2& os
|
||||
) : _os(os) {
|
||||
_ee.show_window = false;
|
||||
|
||||
_ee.registerComponent<ObjectStore::Components::ID>("ID");
|
||||
_ee.registerComponent<ObjectStore::Components::DataCompressionType>("DataCompressionType");
|
||||
|
||||
_ee.registerComponent<Message::Components::Transfer::FileInfo>("Transfer::FileInfo");
|
||||
_ee.registerComponent<Message::Components::Transfer::FileInfoLocal>("Transfer::FileInfoLocal");
|
||||
_ee.registerComponent<Message::Components::Transfer::BytesReceived>("Transfer::BytesReceived");
|
||||
_ee.registerComponent<Message::Components::Transfer::BytesSent>("Transfer::BytesSent");
|
||||
}
|
||||
|
||||
void ObjectStoreUI::render(void) {
|
||||
{ // main window menubar injection
|
||||
// assumes the window "tomato" was rendered already by cg
|
||||
if (ImGui::Begin("tomato")) {
|
||||
if (ImGui::BeginMenuBar()) {
|
||||
ImGui::Separator();
|
||||
if (ImGui::BeginMenu("ObjectStore")) {
|
||||
if (ImGui::MenuItem("Inspector")) {
|
||||
_ee.show_window = true;
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
static Object selected_ent {entt::null};
|
||||
_ee.renderSimpleCombo(_os.registry(), selected_ent);
|
||||
}
|
||||
|
19
src/object_store_ui.hpp
Normal file
19
src/object_store_ui.hpp
Normal file
@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <solanaceae/object_store/object_store.hpp>
|
||||
|
||||
#include "./imgui_entt_entity_editor.hpp"
|
||||
|
||||
class ObjectStoreUI {
|
||||
ObjectStore2& _os;
|
||||
|
||||
MM::EntityEditor<Object> _ee;
|
||||
|
||||
public:
|
||||
ObjectStoreUI(
|
||||
ObjectStore2& os
|
||||
);
|
||||
|
||||
void render(void);
|
||||
};
|
||||
|
@ -14,16 +14,16 @@ SDLRendererTextureUploader::SDLRendererTextureUploader(SDL_Renderer* renderer_)
|
||||
uint64_t SDLRendererTextureUploader::uploadRGBA(const uint8_t* data, uint32_t width, uint32_t height, Filter filter, Access access) {
|
||||
// TODO: test if pitch is 4 or 4*width
|
||||
SDL_Surface* surf = SDL_CreateSurfaceFrom(
|
||||
(void*)data,
|
||||
width, height,
|
||||
4*width,
|
||||
SDL_PIXELFORMAT_RGBA32 // auto big/little
|
||||
SDL_PIXELFORMAT_RGBA32, // auto big/little
|
||||
(void*)data,
|
||||
4*width
|
||||
);
|
||||
assert(surf); // TODO: add error reporting
|
||||
|
||||
SDL_Texture* tex = SDL_CreateTexture(
|
||||
renderer,
|
||||
surf->format->format,
|
||||
surf->format,
|
||||
access == Access::STREAMING ? SDL_TEXTUREACCESS_STREAMING : SDL_TEXTUREACCESS_STATIC,
|
||||
surf->w, surf->h
|
||||
);
|
||||
|
@ -50,9 +50,99 @@ StartScreen::StartScreen(const std::vector<std::string_view>& args, SDL_Renderer
|
||||
}
|
||||
}
|
||||
|
||||
{ // seed tox save path
|
||||
if (_conf.has_string("tox", "save_file_path")) {
|
||||
_tox_profile_path = _conf.get_string("tox", "save_file_path").value();
|
||||
}
|
||||
}
|
||||
|
||||
float display_scale = SDL_GetWindowDisplayScale(SDL_GetRenderWindow(renderer));
|
||||
if (display_scale < 0.001f) {
|
||||
// error?
|
||||
display_scale = 1.f;
|
||||
}
|
||||
|
||||
{
|
||||
auto* font_atlas = ImGui::GetIO().Fonts;
|
||||
font_atlas->ClearFonts();
|
||||
// for now we also always merge
|
||||
//bool has_font {false};
|
||||
|
||||
ImFontGlyphRangesBuilder glyphbld;
|
||||
ImVector<ImWchar> glyph_ranges;
|
||||
{ // build ranges
|
||||
glyphbld.AddRanges(font_atlas->GetGlyphRangesDefault());
|
||||
glyphbld.AddRanges(font_atlas->GetGlyphRangesGreek());
|
||||
glyphbld.AddRanges(font_atlas->GetGlyphRangesCyrillic());
|
||||
glyphbld.AddRanges(font_atlas->GetGlyphRangesChineseSimplifiedCommon()); // contains CJK
|
||||
glyphbld.AddText("™"); // somehow missing
|
||||
// popular emojies
|
||||
glyphbld.AddText(u8"😂❤️🤣👍😭🙏😘🥰😍😊🎉😁💕🥺😅🔥☺️🤦♥️🤷🙄😆🤗😉🎂🤔👏🙂😳🥳😎👌💜😔💪✨💖👀😋😏😢👉💗😩💯🌹💞🎈💙😃😡💐😜🙈🤞😄🤤🙌🤪❣️😀💋💀👇💔😌💓🤩🙃😬😱😴🤭😐🌞😒😇🌸😈🎶✌️🎊🥵😞💚☀️🖤💰😚👑🎁💥🙋☹️😑🥴👈💩✅👋🤮😤🤢🌟❗😥🌈💛😝😫😲🖕‼️🔴🌻🤯💃👊🤬🏃😕👁️⚡☕🍀💦⭐🦋🤨🌺😹🤘🌷💝💤🤝🐰😓💘🍻😟😣🧐😠🤠😻🌙😛🤙🙊");
|
||||
|
||||
if (const auto sv_opt = _conf.get_string("ImGuiFonts", "atlas_extra_text"); sv_opt.has_value) {
|
||||
glyphbld.AddText(sv_opt.s.start, sv_opt.s.start+sv_opt.s.extend);
|
||||
}
|
||||
glyphbld.BuildRanges(&glyph_ranges);
|
||||
}
|
||||
|
||||
ImFontConfig fontcfg;
|
||||
//fontcfg.SizePixels = 16.f*display_scale;
|
||||
fontcfg.SizePixels = _conf.get_int("ImGuiFonts", "size").value_or(13) * display_scale;
|
||||
fontcfg.RasterizerDensity = 1.f;
|
||||
fontcfg.OversampleH = 2;
|
||||
fontcfg.OversampleV = 1;
|
||||
fontcfg.MergeMode = false;
|
||||
|
||||
for (const auto [font_path, should_load] : _conf.entries_bool("ImGuiFonts", "fonts")) {
|
||||
if (!should_load) {
|
||||
continue;
|
||||
}
|
||||
|
||||
std::cout << "Font: loading '" << font_path << "'\n";
|
||||
const auto* resulting_font = font_atlas->AddFontFromFileTTF(
|
||||
font_path.c_str(),
|
||||
_conf.get_int("ImGuiFonts", "size", font_path).value_or(0) * display_scale,
|
||||
&fontcfg,
|
||||
&(glyph_ranges[0])
|
||||
);
|
||||
|
||||
if (resulting_font != nullptr) {
|
||||
//has_font = true;
|
||||
fontcfg.MergeMode = true;
|
||||
} else {
|
||||
std::cerr << "Font: failed to load '" << "path" << "' !\n";
|
||||
}
|
||||
}
|
||||
|
||||
// always append the default as a fallback (merge in)
|
||||
{
|
||||
#if 0
|
||||
ImFontConfig fontcfg;
|
||||
|
||||
// upsampling to int looks almost ok
|
||||
//const float font_size_scale = 1.3f * display_scale;
|
||||
const float font_size_scale = 1.0f * display_scale;
|
||||
const float font_oversample = 4.f;
|
||||
|
||||
// default font is pixel perfect at 13
|
||||
fontcfg.SizePixels = 13.f * font_size_scale;
|
||||
fontcfg.RasterizerDensity = font_oversample/font_size_scale;
|
||||
// normally density would be set to dpi scale of the display
|
||||
|
||||
fontcfg.MergeMode = has_font;
|
||||
#endif
|
||||
|
||||
font_atlas->AddFontDefault(&fontcfg);
|
||||
}
|
||||
|
||||
font_atlas->Build();
|
||||
}
|
||||
}
|
||||
|
||||
Screen* StartScreen::render(float, bool&) {
|
||||
const float TEXT_LOAD_WIDTH = ImGui::CalcTextSize("load").x;
|
||||
const float TEXT_BASE_HEIGHT = ImGui::GetTextLineHeightWithSpacing();
|
||||
|
||||
|
||||
// TODO: imgui tox profile selector?
|
||||
|
||||
@ -165,7 +255,7 @@ Screen* StartScreen::render(float, bool&) {
|
||||
// load but file missing
|
||||
|
||||
ImGui::BeginDisabled();
|
||||
ImGui::Button("load", {60, 25});
|
||||
ImGui::Button("load", {TEXT_LOAD_WIDTH*1.5f, TEXT_BASE_HEIGHT*1.5f});
|
||||
ImGui::EndDisabled();
|
||||
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_ForTooltip | ImGuiHoveredFlags_AllowWhenDisabled)) {
|
||||
@ -175,14 +265,14 @@ Screen* StartScreen::render(float, bool&) {
|
||||
// new but file exists
|
||||
|
||||
ImGui::BeginDisabled();
|
||||
ImGui::Button("load", {60, 25});
|
||||
ImGui::Button("load", {TEXT_LOAD_WIDTH*1.5f, TEXT_BASE_HEIGHT*1.5f});
|
||||
ImGui::EndDisabled();
|
||||
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_ForTooltip | ImGuiHoveredFlags_AllowWhenDisabled)) {
|
||||
ImGui::SetTooltip("file already exists");
|
||||
}
|
||||
} else {
|
||||
if (ImGui::Button("load", {60, 25})) {
|
||||
if (ImGui::Button("load", {TEXT_LOAD_WIDTH*1.5f, TEXT_BASE_HEIGHT*1.5f})) {
|
||||
|
||||
auto new_screen = std::make_unique<MainScreen>(std::move(_conf), _renderer, _theme, _tox_profile_path, _password, _user_name, queued_plugin_paths);
|
||||
return new_screen.release();
|
||||
|
49
src/sys_check.cpp
Normal file
49
src/sys_check.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
#include "./sys_check.hpp"
|
||||
|
||||
// use message boxes to notify the user of system failure
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#if defined(_WIN32) || defined(WIN32)
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
typedef LONG NTSTATUS, *PNTSTATUS;
|
||||
#define STATUS_SUCCESS (0x00000000)
|
||||
|
||||
void runSysCheck(void) {
|
||||
NTSTATUS(WINAPI *RtlGetVersion)(LPOSVERSIONINFOEXW);
|
||||
OSVERSIONINFOEXW osInfo;
|
||||
|
||||
HMODULE lib = GetModuleHandleW(L"ntdll.dll");
|
||||
if (lib) {
|
||||
*(FARPROC*)&RtlGetVersion = GetProcAddress(lib, "RtlGetVersion");
|
||||
|
||||
if (NULL != RtlGetVersion) {
|
||||
osInfo.dwOSVersionInfoSize = sizeof(osInfo);
|
||||
RtlGetVersion(&osInfo);
|
||||
|
||||
// check
|
||||
if (
|
||||
osInfo.dwBuildNumber >= 26000 // canary versions of 11 24H2 included
|
||||
) {
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Unsupported System", "Your version of windows is too new and endangers the privacy of all involved.", nullptr);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void runSysCheck(void) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
#endif
|
||||
|
4
src/sys_check.hpp
Normal file
4
src/sys_check.hpp
Normal file
@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
// perform system checks and potentially terminate
|
||||
void runSysCheck(void);
|
@ -80,43 +80,7 @@ ToxClient::ToxClient(std::string_view save_path, std::string_view save_password)
|
||||
// no callbacks, use events
|
||||
tox_events_init(_tox);
|
||||
|
||||
// dht bootstrap
|
||||
{
|
||||
struct DHT_node {
|
||||
const char *ip;
|
||||
uint16_t port;
|
||||
const char key_hex[TOX_PUBLIC_KEY_SIZE*2 + 1]; // 1 for null terminator
|
||||
unsigned char key_bin[TOX_PUBLIC_KEY_SIZE];
|
||||
};
|
||||
|
||||
DHT_node nodes[] =
|
||||
{
|
||||
// TODO: more/diff nodes
|
||||
// you can change or add your own bs and tcprelays here, ideally closer to you
|
||||
|
||||
//{"tox.plastiras.org", 33445, "8E8B63299B3D520FB377FE5100E65E3322F7AE5B20A0ACED2981769FC5B43725", {}}, // LU tha14
|
||||
{"104.244.74.69", 443, "8E8B63299B3D520FB377FE5100E65E3322F7AE5B20A0ACED2981769FC5B43725", {}}, // LU tha14
|
||||
{"104.244.74.69", 33445, "8E8B63299B3D520FB377FE5100E65E3322F7AE5B20A0ACED2981769FC5B43725", {}}, // LU tha14
|
||||
|
||||
//{"tox2.plastiras.org", 33445, "B6626D386BE7E3ACA107B46F48A5C4D522D29281750D44A0CBA6A2721E79C951", {}}, // DE tha14
|
||||
|
||||
//{"tox4.plastiras.org", 33445, "836D1DA2BE12FE0E669334E437BE3FB02806F1528C2B2782113E0910C7711409", {}}, // MD tha14
|
||||
{"37.221.66.161", 443, "836D1DA2BE12FE0E669334E437BE3FB02806F1528C2B2782113E0910C7711409", {}}, // MD tha14
|
||||
{"37.221.66.161", 33445, "836D1DA2BE12FE0E669334E437BE3FB02806F1528C2B2782113E0910C7711409", {}}, // MD tha14
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < sizeof(nodes)/sizeof(DHT_node); i ++) {
|
||||
sodium_hex2bin(
|
||||
nodes[i].key_bin, sizeof(nodes[i].key_bin),
|
||||
nodes[i].key_hex, sizeof(nodes[i].key_hex)-1,
|
||||
NULL, NULL, NULL
|
||||
);
|
||||
tox_bootstrap(_tox, nodes[i].ip, nodes[i].port, nodes[i].key_bin, NULL);
|
||||
// TODO: use extra tcp option to avoid error msgs
|
||||
// ... this is hardcore
|
||||
tox_add_tcp_relay(_tox, nodes[i].ip, nodes[i].port, nodes[i].key_bin, NULL);
|
||||
}
|
||||
}
|
||||
runBootstrap();
|
||||
}
|
||||
|
||||
ToxClient::~ToxClient(void) {
|
||||
@ -146,6 +110,44 @@ bool ToxClient::iterate(float time_delta) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void ToxClient::runBootstrap(void) {
|
||||
// TODO: extend and read from json?
|
||||
// TODO: seperate out relays
|
||||
struct DHT_node {
|
||||
const char *ip;
|
||||
uint16_t port;
|
||||
const char key_hex[TOX_PUBLIC_KEY_SIZE*2 + 1]; // 1 for null terminator
|
||||
unsigned char key_bin[TOX_PUBLIC_KEY_SIZE];
|
||||
};
|
||||
|
||||
DHT_node nodes[] {
|
||||
// TODO: more/diff nodes
|
||||
// you can change or add your own bs and tcprelays here, ideally closer to you
|
||||
|
||||
//{"tox.plastiras.org", 33445, "8E8B63299B3D520FB377FE5100E65E3322F7AE5B20A0ACED2981769FC5B43725", {}}, // LU tha14
|
||||
{"104.244.74.69", 443, "8E8B63299B3D520FB377FE5100E65E3322F7AE5B20A0ACED2981769FC5B43725", {}}, // LU tha14
|
||||
{"104.244.74.69", 33445, "8E8B63299B3D520FB377FE5100E65E3322F7AE5B20A0ACED2981769FC5B43725", {}}, // LU tha14
|
||||
|
||||
//{"tox2.plastiras.org", 33445, "B6626D386BE7E3ACA107B46F48A5C4D522D29281750D44A0CBA6A2721E79C951", {}}, // DE tha14
|
||||
|
||||
//{"tox4.plastiras.org", 33445, "836D1DA2BE12FE0E669334E437BE3FB02806F1528C2B2782113E0910C7711409", {}}, // MD tha14
|
||||
{"37.221.66.161", 443, "836D1DA2BE12FE0E669334E437BE3FB02806F1528C2B2782113E0910C7711409", {}}, // MD tha14
|
||||
{"37.221.66.161", 33445, "836D1DA2BE12FE0E669334E437BE3FB02806F1528C2B2782113E0910C7711409", {}}, // MD tha14
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < sizeof(nodes)/sizeof(DHT_node); i++) {
|
||||
sodium_hex2bin(
|
||||
nodes[i].key_bin, sizeof(nodes[i].key_bin),
|
||||
nodes[i].key_hex, sizeof(nodes[i].key_hex)-1,
|
||||
NULL, NULL, NULL
|
||||
);
|
||||
tox_bootstrap(_tox, nodes[i].ip, nodes[i].port, nodes[i].key_bin, NULL);
|
||||
// TODO: use extra tcp option to avoid error msgs
|
||||
// ... this is hardcore
|
||||
tox_add_tcp_relay(_tox, nodes[i].ip, nodes[i].port, nodes[i].key_bin, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void ToxClient::subscribeRaw(std::function<void(const Tox_Events*)> fn) {
|
||||
_subscriber_raw = fn;
|
||||
}
|
||||
|
@ -41,6 +41,8 @@ class ToxClient : public ToxDefaultImpl, public ToxEventProviderBase {
|
||||
void setToxProfilePath(const std::string& new_path) { _tox_profile_path = new_path; }
|
||||
void setSelfName(std::string_view new_name) { _self_name = new_name; toxSelfSetName(new_name); }
|
||||
|
||||
void runBootstrap(void);
|
||||
|
||||
public: // raw events
|
||||
void subscribeRaw(std::function<void(const Tox_Events*)> fn);
|
||||
|
||||
|
@ -1,8 +1,9 @@
|
||||
#include "./tox_ui_utils.hpp"
|
||||
|
||||
#include "./tox_client.hpp"
|
||||
|
||||
#include <tox/tox.h>
|
||||
|
||||
#include <solanaceae/toxcore/tox_interface.hpp>
|
||||
#include <solanaceae/util/utils.hpp>
|
||||
|
||||
#include <solanaceae/util/config_model.hpp>
|
||||
@ -11,9 +12,9 @@
|
||||
#include <imgui/misc/cpp/imgui_stdlib.h>
|
||||
|
||||
ToxUIUtils::ToxUIUtils(
|
||||
ToxI& t,
|
||||
ToxClient& tc,
|
||||
ConfigModelI& conf
|
||||
) : _t(t), _conf(conf) {
|
||||
) : _tc(tc), _conf(conf) {
|
||||
}
|
||||
|
||||
void ToxUIUtils::render(void) {
|
||||
@ -28,9 +29,19 @@ void ToxUIUtils::render(void) {
|
||||
if (ImGui::MenuItem("add Friend by ID")) {
|
||||
_show_add_friend_window = true;
|
||||
}
|
||||
if (ImGui::MenuItem("copy own ToxID")) {
|
||||
ImGui::SetClipboardText(_tc.toxSelfGetAddressStr().c_str());
|
||||
}
|
||||
if (ImGui::MenuItem("join Group by ID (ngc)")) {
|
||||
_show_add_group_window = true;
|
||||
}
|
||||
|
||||
ImGui::SeparatorText("DHT");
|
||||
|
||||
if (ImGui::MenuItem("rerun bootstrap")) {
|
||||
_tc.runBootstrap();
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
ImGui::EndMenuBar();
|
||||
@ -51,7 +62,7 @@ void ToxUIUtils::render(void) {
|
||||
static Tox_Err_Friend_Add err = Tox_Err_Friend_Add::TOX_ERR_FRIEND_ADD_OK;
|
||||
if (ImGui::Button("add")) {
|
||||
// TODO: add string_view variant to utils
|
||||
auto [_, err_r] = _t.toxFriendAdd(hex2bin(std::string{tox_id}), message);
|
||||
auto [_, err_r] = _tc.toxFriendAdd(hex2bin(std::string{tox_id}), message);
|
||||
err = err_r;
|
||||
}
|
||||
if (err != Tox_Err_Friend_Add::TOX_ERR_FRIEND_ADD_OK) {
|
||||
@ -78,7 +89,7 @@ void ToxUIUtils::render(void) {
|
||||
|
||||
static Tox_Err_Group_Join err = Tox_Err_Group_Join::TOX_ERR_GROUP_JOIN_OK;
|
||||
if (ImGui::Button("join")) {
|
||||
auto [_, err_r] = _t.toxGroupJoin(
|
||||
auto [_, err_r] = _tc.toxGroupJoin(
|
||||
hex2bin(std::string{chat_id}), // TODO: add string_view variant to utils
|
||||
self_name,
|
||||
password
|
||||
|
@ -1,18 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
struct ToxI;
|
||||
class ToxClient;
|
||||
struct ConfigModelI;
|
||||
|
||||
class ToxUIUtils {
|
||||
bool _show_add_friend_window {false};
|
||||
bool _show_add_group_window {false};
|
||||
|
||||
ToxI& _t;
|
||||
ToxClient& _tc;
|
||||
ConfigModelI& _conf;
|
||||
|
||||
public:
|
||||
ToxUIUtils(
|
||||
ToxI& t,
|
||||
ToxClient& tc,
|
||||
ConfigModelI& conf
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user