mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 20:07:01 +00:00
Merge branch 'master' into docking + remove two _PopUnusedDrawCmd() from docking branch, following 718daa1
# Conflicts: # backends/imgui_impl_glfw.cpp # backends/imgui_impl_sdl.cpp # backends/imgui_impl_win32.cpp # imgui.cpp # imgui_internal.h
This commit is contained in:
commit
d5f0d45ae4
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2022-01-26: Inputs: replaced short-lived io.AddKeyModsEvent() (added two weeks ago)with io.AddKeyEvent() using ImGuiKey_ModXXX flags. Sorry for the confusion.
|
||||||
// 2022-01-17: Inputs: calling new io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() API (1.87+).
|
// 2022-01-17: Inputs: calling new io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() API (1.87+).
|
||||||
// 2022-01-17: Inputs: always calling io.AddKeyModsEvent() next and before key event (not in NewFrame) to fix input queue with very low framerates.
|
// 2022-01-17: Inputs: always calling io.AddKeyModsEvent() next and before key event (not in NewFrame) to fix input queue with very low framerates.
|
||||||
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
|
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
|
||||||
@ -448,12 +449,10 @@ static void ImGui_ImplAllegro5_UpdateKeyModifiers()
|
|||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
ALLEGRO_KEYBOARD_STATE keys;
|
ALLEGRO_KEYBOARD_STATE keys;
|
||||||
al_get_keyboard_state(&keys);
|
al_get_keyboard_state(&keys);
|
||||||
ImGuiKeyModFlags key_mods =
|
io.AddKeyEvent(ImGuiKey_ModCtrl, al_key_down(&keys, ALLEGRO_KEY_LCTRL) || al_key_down(&keys, ALLEGRO_KEY_RCTRL));
|
||||||
((al_key_down(&keys, ALLEGRO_KEY_LCTRL) || al_key_down(&keys, ALLEGRO_KEY_RCTRL)) ? ImGuiKeyModFlags_Ctrl : 0) |
|
io.AddKeyEvent(ImGuiKey_ModShift, al_key_down(&keys, ALLEGRO_KEY_LSHIFT) || al_key_down(&keys, ALLEGRO_KEY_RSHIFT));
|
||||||
((al_key_down(&keys, ALLEGRO_KEY_LSHIFT) || al_key_down(&keys, ALLEGRO_KEY_RSHIFT)) ? ImGuiKeyModFlags_Shift : 0) |
|
io.AddKeyEvent(ImGuiKey_ModAlt, al_key_down(&keys, ALLEGRO_KEY_ALT) || al_key_down(&keys, ALLEGRO_KEY_ALTGR));
|
||||||
((al_key_down(&keys, ALLEGRO_KEY_ALT) || al_key_down(&keys, ALLEGRO_KEY_ALTGR)) ? ImGuiKeyModFlags_Alt : 0) |
|
io.AddKeyEvent(ImGuiKey_ModSuper, al_key_down(&keys, ALLEGRO_KEY_LWIN) || al_key_down(&keys, ALLEGRO_KEY_RWIN));
|
||||||
((al_key_down(&keys, ALLEGRO_KEY_LWIN) || al_key_down(&keys, ALLEGRO_KEY_RWIN)) ? ImGuiKeyModFlags_Super : 0);
|
|
||||||
io.AddKeyModsEvent(key_mods);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2022-01-26: Inputs: replaced short-lived io.AddKeyModsEvent() (added two weeks ago)with io.AddKeyEvent() using ImGuiKey_ModXXX flags. Sorry for the confusion.
|
||||||
// 2022-01-17: Inputs: calling new io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() API (1.87+).
|
// 2022-01-17: Inputs: calling new io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() API (1.87+).
|
||||||
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
|
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
|
||||||
// 2021-03-04: Initial version.
|
// 2021-03-04: Initial version.
|
||||||
@ -26,29 +27,15 @@
|
|||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
#include "imgui_impl_android.h"
|
#include "imgui_impl_android.h"
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <map>
|
|
||||||
#include <queue>
|
|
||||||
#include <android/native_window.h>
|
#include <android/native_window.h>
|
||||||
#include <android/input.h>
|
#include <android/input.h>
|
||||||
#include <android/keycodes.h>
|
#include <android/keycodes.h>
|
||||||
#include <android/log.h>
|
#include <android/log.h>
|
||||||
|
|
||||||
struct KeyEvent
|
|
||||||
{
|
|
||||||
ImGuiKey Key;
|
|
||||||
bool Down;
|
|
||||||
int NativeKeycode;
|
|
||||||
int NativeScancode;
|
|
||||||
|
|
||||||
KeyEvent(): Key(ImGuiKey_None), Down(false), NativeKeycode(-1), NativeScancode(-1) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Android data
|
// Android data
|
||||||
static double g_Time = 0.0;
|
static double g_Time = 0.0;
|
||||||
static ANativeWindow* g_Window;
|
static ANativeWindow* g_Window;
|
||||||
static char g_LogTag[] = "ImGuiExample";
|
static char g_LogTag[] = "ImGuiExample";
|
||||||
static std::map<ImGuiKey, std::queue<KeyEvent>> g_KeyEventQueues; // FIXME: Remove dependency on map and queue once we use upcoming input queue.
|
|
||||||
static ImGuiKeyModFlags g_KeyModFlags = ImGuiKeyModFlags_None;
|
|
||||||
|
|
||||||
static ImGuiKey ImGui_ImplAndroid_KeyCodeToImGuiKey(int32_t key_code)
|
static ImGuiKey ImGui_ImplAndroid_KeyCodeToImGuiKey(int32_t key_code)
|
||||||
{
|
{
|
||||||
@ -176,15 +163,10 @@ int32_t ImGui_ImplAndroid_HandleInputEvent(AInputEvent* input_event)
|
|||||||
int32_t event_action = AKeyEvent_getAction(input_event);
|
int32_t event_action = AKeyEvent_getAction(input_event);
|
||||||
int32_t event_meta_state = AKeyEvent_getMetaState(input_event);
|
int32_t event_meta_state = AKeyEvent_getMetaState(input_event);
|
||||||
|
|
||||||
g_KeyModFlags = ImGuiKeyModFlags_None;
|
io.AddKeyEvent(ImGuiKey_ModCtrl, (event_meta_state & AMETA_CTRL_ON) != 0);
|
||||||
if ((event_meta_state & AMETA_CTRL_ON) != 0)
|
io.AddKeyEvent(ImGuiKey_ModShift, (event_meta_state & AMETA_SHIFT_ON) != 0);
|
||||||
g_KeyModFlags |= ImGuiKeyModFlags_Ctrl;
|
io.AddKeyEvent(ImGuiKey_ModAlt, (event_meta_state & AMETA_ALT_ON) != 0);
|
||||||
if ((event_meta_state & AMETA_SHIFT_ON) != 0)
|
io.AddKeyEvent(ImGuiKey_ModSuper, (event_meta_state & AMETA_META_ON) != 0);
|
||||||
g_KeyModFlags |= ImGuiKeyModFlags_Shift;
|
|
||||||
if ((event_meta_state & AMETA_ALT_ON) != 0)
|
|
||||||
g_KeyModFlags |= ImGuiKeyModFlags_Alt;
|
|
||||||
if ((event_meta_state & AMETA_META_ON) != 0)
|
|
||||||
g_KeyModFlags |= ImGuiKeyModFlags_Super;
|
|
||||||
|
|
||||||
switch (event_action)
|
switch (event_action)
|
||||||
{
|
{
|
||||||
@ -197,13 +179,8 @@ int32_t ImGui_ImplAndroid_HandleInputEvent(AInputEvent* input_event)
|
|||||||
ImGuiKey key = ImGui_ImplAndroid_KeyCodeToImGuiKey(event_key_code);
|
ImGuiKey key = ImGui_ImplAndroid_KeyCodeToImGuiKey(event_key_code);
|
||||||
if (key != ImGuiKey_None && (event_action == AKEY_EVENT_ACTION_DOWN || event_action == AKEY_EVENT_ACTION_UP))
|
if (key != ImGuiKey_None && (event_action == AKEY_EVENT_ACTION_DOWN || event_action == AKEY_EVENT_ACTION_UP))
|
||||||
{
|
{
|
||||||
KeyEvent io_event;
|
io.AddKeyEvent(key, event_action == AKEY_EVENT_ACTION_DOWN);
|
||||||
io_event.Key = key;
|
io.SetKeyEventNativeData(key, event_key_code, event_scan_code);
|
||||||
io_event.Down = event_action == AKEY_EVENT_ACTION_DOWN;
|
|
||||||
io_event.NativeKeycode = event_key_code;
|
|
||||||
io_event.NativeScancode = event_scan_code;
|
|
||||||
|
|
||||||
g_KeyEventQueues[key].push(io_event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -280,20 +257,6 @@ void ImGui_ImplAndroid_NewFrame()
|
|||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
// Process queued key events
|
|
||||||
// FIXME: This is a workaround for multiple key event actions occurring at once (see above) and can be removed once we use upcoming input queue.
|
|
||||||
for (auto& key_queue : g_KeyEventQueues)
|
|
||||||
{
|
|
||||||
if (key_queue.second.empty())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
auto& key_event = key_queue.second.front();
|
|
||||||
io.AddKeyEvent(key_event.Key, key_event.Down);
|
|
||||||
io.SetKeyEventNativeData(key_event.Key, key_event.NativeKeycode, key_event.NativeScancode); // To support legacy indexing (<1.87 user code)
|
|
||||||
key_queue.second.pop();
|
|
||||||
}
|
|
||||||
io.AddKeyModsEvent(g_KeyModFlags);
|
|
||||||
|
|
||||||
// Setup display size (every frame to accommodate for window resizing)
|
// Setup display size (every frame to accommodate for window resizing)
|
||||||
int32_t window_width = ANativeWindow_getWidth(g_Window);
|
int32_t window_width = ANativeWindow_getWidth(g_Window);
|
||||||
int32_t window_height = ANativeWindow_getHeight(g_Window);
|
int32_t window_height = ANativeWindow_getHeight(g_Window);
|
||||||
|
@ -21,9 +21,10 @@
|
|||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2022-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
// 2022-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
|
// 2022-01-26: Inputs: replaced short-lived io.AddKeyModsEvent() (added two weeks ago)with io.AddKeyEvent() using ImGuiKey_ModXXX flags. Sorry for the confusion.
|
||||||
// 2021-01-20: Inputs: calling new io.AddKeyAnalogEvent() for gamepad support, instead of writing directly to io.NavInputs[].
|
// 2021-01-20: Inputs: calling new io.AddKeyAnalogEvent() for gamepad support, instead of writing directly to io.NavInputs[].
|
||||||
// 2022-01-17: Inputs: calling new io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() API (1.87+).
|
// 2022-01-17: Inputs: calling new io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() API (1.87+).
|
||||||
// 2022-01-17: Inputs: always calling io.AddKeyModsEvent() next and before key event (not in NewFrame) to fix input queue with very low framerates.
|
// 2022-01-17: Inputs: always update key mods next and before key event (not in NewFrame) to fix input queue with very low framerates.
|
||||||
// 2022-01-12: *BREAKING CHANGE*: Now using glfwSetCursorPosCallback(). If you called ImGui_ImplGlfw_InitXXX() with install_callbacks = false, you MUST install glfwSetCursorPosCallback() and forward it to the backend via ImGui_ImplGlfw_CursorPosCallback().
|
// 2022-01-12: *BREAKING CHANGE*: Now using glfwSetCursorPosCallback(). If you called ImGui_ImplGlfw_InitXXX() with install_callbacks = false, you MUST install glfwSetCursorPosCallback() and forward it to the backend via ImGui_ImplGlfw_CursorPosCallback().
|
||||||
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
|
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
|
||||||
// 2022-01-05: Inputs: Converting GLFW untranslated keycodes back to translated keycodes (in the ImGui_ImplGlfw_KeyCallback() function) in order to match the behavior of every other backend, and facilitate the use of GLFW with lettered-shortcuts API.
|
// 2022-01-05: Inputs: Converting GLFW untranslated keycodes back to translated keycodes (in the ImGui_ImplGlfw_KeyCallback() function) in order to match the behavior of every other backend, and facilitate the use of GLFW with lettered-shortcuts API.
|
||||||
@ -270,12 +271,10 @@ static ImGuiKey ImGui_ImplGlfw_KeyToImGuiKey(int key)
|
|||||||
static void ImGui_ImplGlfw_UpdateKeyModifiers(int mods)
|
static void ImGui_ImplGlfw_UpdateKeyModifiers(int mods)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
ImGuiKeyModFlags key_mods =
|
io.AddKeyEvent(ImGuiKey_ModCtrl, (mods & GLFW_MOD_CONTROL) != 0);
|
||||||
((mods & GLFW_MOD_CONTROL) ? ImGuiKeyModFlags_Ctrl : 0) |
|
io.AddKeyEvent(ImGuiKey_ModShift, (mods & GLFW_MOD_SHIFT) != 0);
|
||||||
((mods & GLFW_MOD_SHIFT) ? ImGuiKeyModFlags_Shift : 0) |
|
io.AddKeyEvent(ImGuiKey_ModAlt, (mods & GLFW_MOD_ALT) != 0);
|
||||||
((mods & GLFW_MOD_ALT) ? ImGuiKeyModFlags_Alt : 0) |
|
io.AddKeyEvent(ImGuiKey_ModSuper, (mods & GLFW_MOD_SUPER) != 0);
|
||||||
((mods & GLFW_MOD_SUPER) ? ImGuiKeyModFlags_Super : 0);
|
|
||||||
io.AddKeyModsEvent(key_mods);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods)
|
void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods)
|
||||||
@ -312,7 +311,7 @@ static int ImGui_ImplGlfw_TranslateUntranslatedKey(int key, int scancode)
|
|||||||
const char* key_name = glfwGetKeyName(key, scancode);
|
const char* key_name = glfwGetKeyName(key, scancode);
|
||||||
if (key_name && key_name[0] != 0 && key_name[1] == 0)
|
if (key_name && key_name[0] != 0 && key_name[1] == 0)
|
||||||
{
|
{
|
||||||
const char char_names[] = "'-=[]\\,;\'./";
|
const char char_names[] = "`-=[]\\,;\'./";
|
||||||
const int char_keys[] = { GLFW_KEY_GRAVE_ACCENT, GLFW_KEY_MINUS, GLFW_KEY_EQUAL, GLFW_KEY_LEFT_BRACKET, GLFW_KEY_RIGHT_BRACKET, GLFW_KEY_BACKSLASH, GLFW_KEY_COMMA, GLFW_KEY_SEMICOLON, GLFW_KEY_APOSTROPHE, GLFW_KEY_PERIOD, GLFW_KEY_SLASH, 0 };
|
const int char_keys[] = { GLFW_KEY_GRAVE_ACCENT, GLFW_KEY_MINUS, GLFW_KEY_EQUAL, GLFW_KEY_LEFT_BRACKET, GLFW_KEY_RIGHT_BRACKET, GLFW_KEY_BACKSLASH, GLFW_KEY_COMMA, GLFW_KEY_SEMICOLON, GLFW_KEY_APOSTROPHE, GLFW_KEY_PERIOD, GLFW_KEY_SLASH, 0 };
|
||||||
IM_ASSERT(IM_ARRAYSIZE(char_names) == IM_ARRAYSIZE(char_keys));
|
IM_ASSERT(IM_ARRAYSIZE(char_names) == IM_ARRAYSIZE(char_keys));
|
||||||
if (key_name[0] >= '0' && key_name[0] <= '9') { key = GLFW_KEY_0 + (key_name[0] - '0'); }
|
if (key_name[0] >= '0' && key_name[0] <= '9') { key = GLFW_KEY_0 + (key_name[0] - '0'); }
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2022-01-26: Inputs: replaced short-lived io.AddKeyModsEvent() (added two weeks ago) with io.AddKeyEvent() using ImGuiKey_ModXXX flags. Sorry for the confusion.
|
||||||
// 2022-01-17: Inputs: calling new io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() API (1.87+).
|
// 2022-01-17: Inputs: calling new io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() API (1.87+).
|
||||||
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
|
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
|
||||||
// 2019-04-03: Misc: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h.
|
// 2019-04-03: Misc: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h.
|
||||||
@ -207,11 +208,9 @@ static void ImGui_ImplGLUT_UpdateKeyModifiers()
|
|||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
int glut_key_mods = glutGetModifiers();
|
int glut_key_mods = glutGetModifiers();
|
||||||
ImGuiKeyModFlags key_mods =
|
io.AddKeyEvent(ImGuiKey_ModCtrl, (glut_key_mods & GLUT_ACTIVE_CTRL) != 0);
|
||||||
((glut_key_mods & GLUT_ACTIVE_CTRL) ? ImGuiKeyModFlags_Ctrl : 0) |
|
io.AddKeyEvent(ImGuiKey_ModShift, (glut_key_mods & GLUT_ACTIVE_SHIFT) != 0);
|
||||||
((glut_key_mods & GLUT_ACTIVE_SHIFT) ? ImGuiKeyModFlags_Shift : 0) |
|
io.AddKeyEvent(ImGuiKey_ModAlt, (glut_key_mods & GLUT_ACTIVE_ALT) != 0);
|
||||||
((glut_key_mods & GLUT_ACTIVE_ALT) ? ImGuiKeyModFlags_Alt : 0);
|
|
||||||
io.AddKeyModsEvent(key_mods);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplGLUT_AddKeyEvent(ImGuiKey key, bool down, int native_keycode)
|
static void ImGui_ImplGLUT_AddKeyEvent(ImGuiKey key, bool down, int native_keycode)
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2022-01-26: Inputs: replaced short-lived io.AddKeyModsEvent() (added two weeks ago)with io.AddKeyEvent() using ImGuiKey_ModXXX flags. Sorry for the confusion.
|
||||||
// 2021-01-20: Inputs: calling new io.AddKeyAnalogEvent() for gamepad support, instead of writing directly to io.NavInputs[].
|
// 2021-01-20: Inputs: calling new io.AddKeyAnalogEvent() for gamepad support, instead of writing directly to io.NavInputs[].
|
||||||
// 2022-01-17: Inputs: calling new io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() API (1.87+).
|
// 2022-01-17: Inputs: calling new io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() API (1.87+).
|
||||||
// 2022-01-12: Inputs: Added basic Platform IME support, hooking the io.SetPlatformImeDataFn() function.
|
// 2022-01-12: Inputs: Added basic Platform IME support, hooking the io.SetPlatformImeDataFn() function.
|
||||||
@ -666,18 +667,12 @@ bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view)
|
|||||||
if (event.type == NSEventTypeFlagsChanged)
|
if (event.type == NSEventTypeFlagsChanged)
|
||||||
{
|
{
|
||||||
unsigned short key_code = [event keyCode];
|
unsigned short key_code = [event keyCode];
|
||||||
unsigned int flags = [event modifierFlags] & NSEventModifierFlagDeviceIndependentFlagsMask;
|
NSEventModifierFlags modifier_flags = [event modifierFlags];
|
||||||
|
|
||||||
ImGuiKeyModFlags imgui_key_mods = ImGuiKeyModFlags_None;
|
io.AddKeyEvent(ImGuiKey_ModShift, (modifier_flags & NSEventModifierFlagShift) != 0);
|
||||||
if (flags & NSEventModifierFlagShift)
|
io.AddKeyEvent(ImGuiKey_ModCtrl, (modifier_flags & NSEventModifierFlagControl) != 0);
|
||||||
imgui_key_mods |= ImGuiKeyModFlags_Shift;
|
io.AddKeyEvent(ImGuiKey_ModAlt, (modifier_flags & NSEventModifierFlagOption) != 0);
|
||||||
if (flags & NSEventModifierFlagControl)
|
io.AddKeyEvent(ImGuiKey_ModSuper, (modifier_flags & NSEventModifierFlagCommand) != 0);
|
||||||
imgui_key_mods |= ImGuiKeyModFlags_Ctrl;
|
|
||||||
if (flags & NSEventModifierFlagOption)
|
|
||||||
imgui_key_mods |= ImGuiKeyModFlags_Alt;
|
|
||||||
if (flags & NSEventModifierFlagCommand)
|
|
||||||
imgui_key_mods |= ImGuiKeyModFlags_Super;
|
|
||||||
io.AddKeyModsEvent(imgui_key_mods);
|
|
||||||
|
|
||||||
ImGuiKey key = ImGui_ImplOSX_KeyCodeToImGuiKey(key_code);
|
ImGuiKey key = ImGui_ImplOSX_KeyCodeToImGuiKey(key_code);
|
||||||
if (key != ImGuiKey_None)
|
if (key != ImGuiKey_None)
|
||||||
@ -686,28 +681,22 @@ bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view)
|
|||||||
// to use hardware dependent masks to extract that information.
|
// to use hardware dependent masks to extract that information.
|
||||||
// 'imgui_mask' is left as a fallback.
|
// 'imgui_mask' is left as a fallback.
|
||||||
NSEventModifierFlags mask = 0;
|
NSEventModifierFlags mask = 0;
|
||||||
ImGuiKeyModFlags imgui_mask = ImGuiKeyModFlags_None;
|
switch (key)
|
||||||
switch (key_code)
|
|
||||||
{
|
{
|
||||||
case kVK_Control: mask = 0x0001; imgui_mask = ImGuiKeyModFlags_Ctrl; break;
|
case ImGuiKey_LeftCtrl: mask = 0x0001; break;
|
||||||
case kVK_RightControl: mask = 0x2000; imgui_mask = ImGuiKeyModFlags_Ctrl; break;
|
case ImGuiKey_RightCtrl: mask = 0x2000; break;
|
||||||
case kVK_Shift: mask = 0x0002; imgui_mask = ImGuiKeyModFlags_Shift; break;
|
case ImGuiKey_LeftShift: mask = 0x0002; break;
|
||||||
case kVK_RightShift: mask = 0x0004; imgui_mask = ImGuiKeyModFlags_Shift; break;
|
case ImGuiKey_RightShift: mask = 0x0004; break;
|
||||||
case kVK_Command: mask = 0x0008; imgui_mask = ImGuiKeyModFlags_Super; break;
|
case ImGuiKey_LeftSuper: mask = 0x0008; break;
|
||||||
case kVK_RightCommand: mask = 0x0010; imgui_mask = ImGuiKeyModFlags_Super; break;
|
case ImGuiKey_RightSuper: mask = 0x0010; break;
|
||||||
case kVK_Option: mask = 0x0020; imgui_mask = ImGuiKeyModFlags_Alt; break;
|
case ImGuiKey_LeftAlt: mask = 0x0020; break;
|
||||||
case kVK_RightOption: mask = 0x0040; imgui_mask = ImGuiKeyModFlags_Alt; break;
|
case ImGuiKey_RightAlt: mask = 0x0040; break;
|
||||||
|
default:
|
||||||
|
return io.WantCaptureKeyboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mask)
|
|
||||||
{
|
|
||||||
NSEventModifierFlags modifier_flags = [event modifierFlags];
|
NSEventModifierFlags modifier_flags = [event modifierFlags];
|
||||||
io.AddKeyEvent(key, (modifier_flags & mask) != 0);
|
io.AddKeyEvent(key, (modifier_flags & mask) != 0);
|
||||||
}
|
|
||||||
else if (imgui_mask)
|
|
||||||
{
|
|
||||||
io.AddKeyEvent(key, (imgui_key_mods & imgui_mask) != 0);
|
|
||||||
}
|
|
||||||
io.SetKeyEventNativeData(key, key_code, -1); // To support legacy indexing (<1.87 user code)
|
io.SetKeyEventNativeData(key, key_code, -1); // To support legacy indexing (<1.87 user code)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,9 +21,10 @@
|
|||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2022-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
// 2022-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
|
// 2022-01-26: Inputs: replaced short-lived io.AddKeyModsEvent() (added two weeks ago)with io.AddKeyEvent() using ImGuiKey_ModXXX flags. Sorry for the confusion.
|
||||||
// 2021-01-20: Inputs: calling new io.AddKeyAnalogEvent() for gamepad support, instead of writing directly to io.NavInputs[].
|
// 2021-01-20: Inputs: calling new io.AddKeyAnalogEvent() for gamepad support, instead of writing directly to io.NavInputs[].
|
||||||
// 2022-01-17: Inputs: calling new io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() API (1.87+).
|
// 2022-01-17: Inputs: calling new io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() API (1.87+).
|
||||||
// 2022-01-17: Inputs: always calling io.AddKeyModsEvent() next and before key event (not in NewFrame) to fix input queue with very low framerates.
|
// 2022-01-17: Inputs: always update key mods next and before key event (not in NewFrame) to fix input queue with very low framerates.
|
||||||
// 2022-01-12: Update mouse inputs using SDL_MOUSEMOTION/SDL_WINDOWEVENT_LEAVE + fallback to provide it when focused but not hovered/captured. More standard and will allow us to pass it to future input queue API.
|
// 2022-01-12: Update mouse inputs using SDL_MOUSEMOTION/SDL_WINDOWEVENT_LEAVE + fallback to provide it when focused but not hovered/captured. More standard and will allow us to pass it to future input queue API.
|
||||||
// 2022-01-12: Maintain our own copy of MouseButtonsDown mask instead of using ImGui::IsAnyMouseDown() which will be obsoleted.
|
// 2022-01-12: Maintain our own copy of MouseButtonsDown mask instead of using ImGui::IsAnyMouseDown() which will be obsoleted.
|
||||||
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
|
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
|
||||||
@ -189,7 +190,7 @@ static ImGuiKey ImGui_ImplSDL2_KeycodeToImGuiKey(int keycode)
|
|||||||
case SDLK_RSHIFT: return ImGuiKey_RightShift;
|
case SDLK_RSHIFT: return ImGuiKey_RightShift;
|
||||||
case SDLK_RALT: return ImGuiKey_RightAlt;
|
case SDLK_RALT: return ImGuiKey_RightAlt;
|
||||||
case SDLK_RGUI: return ImGuiKey_RightSuper;
|
case SDLK_RGUI: return ImGuiKey_RightSuper;
|
||||||
case SDLK_MENU: return ImGuiKey_Menu;
|
case SDLK_APPLICATION: return ImGuiKey_Menu;
|
||||||
case SDLK_0: return ImGuiKey_0;
|
case SDLK_0: return ImGuiKey_0;
|
||||||
case SDLK_1: return ImGuiKey_1;
|
case SDLK_1: return ImGuiKey_1;
|
||||||
case SDLK_2: return ImGuiKey_2;
|
case SDLK_2: return ImGuiKey_2;
|
||||||
@ -245,12 +246,10 @@ static ImGuiKey ImGui_ImplSDL2_KeycodeToImGuiKey(int keycode)
|
|||||||
static void ImGui_ImplSDL2_UpdateKeyModifiers(SDL_Keymod sdl_key_mods)
|
static void ImGui_ImplSDL2_UpdateKeyModifiers(SDL_Keymod sdl_key_mods)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
ImGuiKeyModFlags key_mods =
|
io.AddKeyEvent(ImGuiKey_ModCtrl, (sdl_key_mods & KMOD_CTRL) != 0);
|
||||||
((sdl_key_mods & KMOD_CTRL) ? ImGuiKeyModFlags_Ctrl : 0) |
|
io.AddKeyEvent(ImGuiKey_ModShift, (sdl_key_mods & KMOD_SHIFT) != 0);
|
||||||
((sdl_key_mods & KMOD_SHIFT) ? ImGuiKeyModFlags_Shift : 0) |
|
io.AddKeyEvent(ImGuiKey_ModAlt, (sdl_key_mods & KMOD_ALT) != 0);
|
||||||
((sdl_key_mods & KMOD_ALT) ? ImGuiKeyModFlags_Alt : 0) |
|
io.AddKeyEvent(ImGuiKey_ModSuper, (sdl_key_mods & KMOD_GUI) != 0);
|
||||||
((sdl_key_mods & KMOD_GUI) ? ImGuiKeyModFlags_Super : 0);
|
|
||||||
io.AddKeyModsEvent(key_mods);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
||||||
|
@ -36,9 +36,10 @@ typedef DWORD (WINAPI *PFN_XInputGetState)(DWORD, XINPUT_STATE*);
|
|||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2022-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
// 2022-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
|
// 2022-01-26: Inputs: replaced short-lived io.AddKeyModsEvent() (added two weeks ago)with io.AddKeyEvent() using ImGuiKey_ModXXX flags. Sorry for the confusion.
|
||||||
// 2021-01-20: Inputs: calling new io.AddKeyAnalogEvent() for gamepad support, instead of writing directly to io.NavInputs[].
|
// 2021-01-20: Inputs: calling new io.AddKeyAnalogEvent() for gamepad support, instead of writing directly to io.NavInputs[].
|
||||||
// 2022-01-17: Inputs: calling new io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() API (1.87+).
|
// 2022-01-17: Inputs: calling new io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() API (1.87+).
|
||||||
// 2022-01-17: Inputs: always calling io.AddKeyModsEvent() next and before a key event (not in NewFrame) to fix input queue with very low framerates.
|
// 2022-01-17: Inputs: always update key mods next and before a key event (not in NewFrame) to fix input queue with very low framerates.
|
||||||
// 2022-01-12: Inputs: Update mouse inputs using WM_MOUSEMOVE/WM_MOUSELEAVE + fallback to provide it when focused but not hovered/captured. More standard and will allow us to pass it to future input queue API.
|
// 2022-01-12: Inputs: Update mouse inputs using WM_MOUSEMOVE/WM_MOUSELEAVE + fallback to provide it when focused but not hovered/captured. More standard and will allow us to pass it to future input queue API.
|
||||||
// 2022-01-12: Inputs: Maintain our own copy of MouseButtonsDown mask instead of using ImGui::IsAnyMouseDown() which will be obsoleted.
|
// 2022-01-12: Inputs: Maintain our own copy of MouseButtonsDown mask instead of using ImGui::IsAnyMouseDown() which will be obsoleted.
|
||||||
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
|
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
|
||||||
@ -253,12 +254,10 @@ static void ImGui_ImplWin32_ProcessKeyEventsWorkarounds()
|
|||||||
static void ImGui_ImplWin32_UpdateKeyModifiers()
|
static void ImGui_ImplWin32_UpdateKeyModifiers()
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
ImGuiKeyModFlags key_mods =
|
io.AddKeyEvent(ImGuiKey_ModCtrl, IsVkDown(VK_CONTROL));
|
||||||
((IsVkDown(VK_CONTROL)) ? ImGuiKeyModFlags_Ctrl : 0) |
|
io.AddKeyEvent(ImGuiKey_ModShift, IsVkDown(VK_SHIFT));
|
||||||
((IsVkDown(VK_SHIFT) ) ? ImGuiKeyModFlags_Shift : 0) |
|
io.AddKeyEvent(ImGuiKey_ModAlt, IsVkDown(VK_MENU));
|
||||||
((IsVkDown(VK_MENU)) ? ImGuiKeyModFlags_Alt : 0) |
|
io.AddKeyEvent(ImGuiKey_ModSuper, IsVkDown(VK_APPS));
|
||||||
((IsVkDown(VK_APPS)) ? ImGuiKeyModFlags_Super : 0);
|
|
||||||
io.AddKeyModsEvent(key_mods);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This code supports multi-viewports (multiple OS Windows mapped into different Dear ImGui viewports)
|
// This code supports multi-viewports (multiple OS Windows mapped into different Dear ImGui viewports)
|
||||||
|
@ -105,16 +105,14 @@ Other changes:
|
|||||||
Breaking Changes:
|
Breaking Changes:
|
||||||
|
|
||||||
- Removed support for pre-C++11 compilers. We'll stop supporting VS2010. (#4537)
|
- Removed support for pre-C++11 compilers. We'll stop supporting VS2010. (#4537)
|
||||||
- Removed support for legacy arithmetic operators (+,+-,*,/) when inputing text into a slider/drag. (#4917, #3184)
|
- Reworked IO mouse input API: (#4921, #4858) [@thedmd, @ocornut]
|
||||||
This doesn't break any api/code but a feature that was accessible by end-users (which seemingly no one used).
|
|
||||||
(Instead you may implement custom expression evaluators to provide a better version of this).
|
|
||||||
- Reworked IO mouse input API: (#4858) [@thedmd, @ocornut]
|
|
||||||
- Added io.AddMousePosEvent(), AddMouseButtonEvent(), AddMouseWheelEvent() functions,
|
- Added io.AddMousePosEvent(), AddMouseButtonEvent(), AddMouseWheelEvent() functions,
|
||||||
obsoleting writing directly to io.MousePos, io.MouseDown[], io.MouseWheel, etc.
|
obsoleting writing directly to io.MousePos, io.MouseDown[], io.MouseWheel, etc.
|
||||||
- This enable input queue trickling to support low framerates. (#2787, #1992, #3383, #2525, #1320)
|
- This enable input queue trickling to support low framerates. (#2787, #1992, #3383, #2525, #1320)
|
||||||
- Reworked IO keyboard input API: (#2625, #3724) [@thedmd, @ocornut]
|
- Reworked IO keyboard input API: (#4921, #2625, #3724) [@thedmd, @ocornut]
|
||||||
- Added io.AddKeyEvent() function, obsoleting writing directly to io.KeyMap[], io.KeysDown[] arrays.
|
- Added io.AddKeyEvent() function, obsoleting writing directly to io.KeyMap[], io.KeysDown[] arrays.
|
||||||
- Added io.AddKeyModsEvent() function, obsoleting writing directly to io.KeyCtrl, io.KeyShift etc.
|
- For keyboard modifiers, you can call io.AddKeyEvent() with ImGuiKey_ModXXX values,
|
||||||
|
obsoleting writing directly to io.KeyCtrl, io.KeyShift etc.
|
||||||
- Added io.SetKeyEventNativeData() function (optional) to pass native and old legacy indices.
|
- Added io.SetKeyEventNativeData() function (optional) to pass native and old legacy indices.
|
||||||
- Added full range of key enums in ImGuiKey (e.g. ImGuiKey_F1).
|
- Added full range of key enums in ImGuiKey (e.g. ImGuiKey_F1).
|
||||||
- Added GetKeyName() helper function.
|
- Added GetKeyName() helper function.
|
||||||
@ -138,16 +136,21 @@ Breaking Changes:
|
|||||||
- Basically the trick we took advantage of is that we previously only supported native keycode from 0 to 511,
|
- Basically the trick we took advantage of is that we previously only supported native keycode from 0 to 511,
|
||||||
so ImGuiKey values can still express a legacy native keycode, and new named keys are all >= 512.
|
so ImGuiKey values can still express a legacy native keycode, and new named keys are all >= 512.
|
||||||
- This will enable a few things in the future:
|
- This will enable a few things in the future:
|
||||||
- Access to portable keys allows for backed-agnostic keyboard input code. Until now it was difficult to
|
- Access to portable keys allows for backend-agnostic keyboard input code. Until now it was difficult
|
||||||
share code using keyboard accross project because of this gap. (#2625, #3724)
|
to share code using keyboard accross project because of this gap. (#2625, #3724)
|
||||||
- Access to full key ranges will allow us to develop a proper keyboard shortcut system. (#456)
|
- Access to full key ranges will allow us to develop a proper keyboard shortcut system. (#456)
|
||||||
- io.AddKeyEvent() will later be turned into a trickling IO queue (for all inputs) to handle very low framerate better. (#2525, #2787, #3383)
|
- io.AddKeyEvent() will later be turned into a trickling IO queue (for all inputs) to handle very low framerate better. (#2525, #2787, #3383)
|
||||||
- io.SetKeyEventNativeData() include native keycode/scancode which will later be exposed. (#3141, #2959)
|
- io.SetKeyEventNativeData() include native keycode/scancode which will later be exposed. (#3141, #2959)
|
||||||
- Reworked IO nav/gamepad input API and unifying inputs sources: (#4858, #787)
|
- Reworked IO nav/gamepad input API and unifying inputs sources: (#4921, #4858, #787)
|
||||||
- Added full range of ImGuiKey_GamepadXXXX enums (e.g. ImGuiKey_GamepadDpadUp, ImGuiKey_GamepadR2) to use with
|
- Added full range of ImGuiKey_GamepadXXXX enums (e.g. ImGuiKey_GamepadDpadUp, ImGuiKey_GamepadR2) to use with
|
||||||
io.AddKeyEvent(), io.AddKeyAnalogEvent().
|
io.AddKeyEvent(), io.AddKeyAnalogEvent().
|
||||||
- Added io.AddKeyAnalogEvent() function, obsoleting writing directly to io.NavInputs[] arrays.
|
- Added io.AddKeyAnalogEvent() function, obsoleting writing directly to io.NavInputs[] arrays.
|
||||||
- Renamed ImGuiKey_KeyPadEnter to ImGuiKey_KeypadEnter to align with new symbols. Kept redirection enum. (#2625)
|
- Renamed ImGuiKey_KeyPadEnter to ImGuiKey_KeypadEnter to align with new symbols. Kept redirection enum. (#2625)
|
||||||
|
- Moved ImGuiKeyModsFlags definition from imgui.h to imgui_internal.h. Was never advertised and used in a place
|
||||||
|
marked "private" in comments. Will still be used internally.
|
||||||
|
- Removed support for legacy arithmetic operators (+,+-,*,/) when inputing text into a slider/drag. (#4917, #3184)
|
||||||
|
This doesn't break any api/code but a feature that was accessible by end-users (which seemingly no one used).
|
||||||
|
(Instead you may implement custom expression evaluators to provide a better version of this).
|
||||||
- Backends: GLFW: backend now uses glfwSetCursorPosCallback().
|
- Backends: GLFW: backend now uses glfwSetCursorPosCallback().
|
||||||
- If calling ImGui_ImplGlfw_InitXXX with install_callbacks=true: nothing to do. is already done for you.
|
- If calling ImGui_ImplGlfw_InitXXX with install_callbacks=true: nothing to do. is already done for you.
|
||||||
- If calling ImGui_ImplGlfw_InitXXX with install_callbacks=false: you WILL NEED to register the GLFW callback
|
- If calling ImGui_ImplGlfw_InitXXX with install_callbacks=false: you WILL NEED to register the GLFW callback
|
||||||
@ -171,15 +174,19 @@ Other Changes:
|
|||||||
- IO: Added event based input queue API, which now trickles events to support low framerates. [@thedmd, @ocornut]
|
- IO: Added event based input queue API, which now trickles events to support low framerates. [@thedmd, @ocornut]
|
||||||
Previously the most common issue case (button presses in low framerates) was handled by backend. This is now
|
Previously the most common issue case (button presses in low framerates) was handled by backend. This is now
|
||||||
handled by core automatically for all kind of inputs. (#4858, #2787, #1992, #3383, #2525, #1320)
|
handled by core automatically for all kind of inputs. (#4858, #2787, #1992, #3383, #2525, #1320)
|
||||||
- New IO functions for keyboard/gamepad: AddKeyEvent(), AddKeyAnalogEvent(), AddKeyModsEvent().
|
- New IO functions for keyboard/gamepad: AddKeyEvent(), AddKeyAnalogEvent().
|
||||||
- New IO functions for mouse: AddMousePosEvent(), AddMouseButtonEvent(), AddMouseWheelEvent().
|
- New IO functions for mouse: AddMousePosEvent(), AddMouseButtonEvent(), AddMouseWheelEvent().
|
||||||
|
- Fixed CTRL+Tab into an empty window causing artefacts on the highlight rectangle due to bad reordering on ImDrawCmd.
|
||||||
- Fixed a situation where CTRL+Tab or Modal can occasionally lead to the creation of ImDrawCmd with zero triangles,
|
- Fixed a situation where CTRL+Tab or Modal can occasionally lead to the creation of ImDrawCmd with zero triangles,
|
||||||
which would makes the draw operation of some backends assert (e.g. Metal with debugging). (#4857)
|
which would makes the draw operation of some backends assert (e.g. Metal with debugging). (#4857)
|
||||||
- Popups: Fixed a regression crash when a new window is created after a modal on the same frame. (#4920) [@rokups]
|
- Popups: Fixed a regression crash when a new window is created after a modal on the same frame. (#4920) [@rokups]
|
||||||
|
- Popups: Fixed an issue when reopening a same popup multiple times would offset them by 1 pixel on the right. (#4936)
|
||||||
- Tables, ImDrawListSplitter: Fixed erroneously stripping trailing ImDrawList::AddCallback() when submitted in
|
- Tables, ImDrawListSplitter: Fixed erroneously stripping trailing ImDrawList::AddCallback() when submitted in
|
||||||
last column or last channel and when there are no other drawing operation. (#4843, #4844) [@hoffstadt]
|
last column or last channel and when there are no other drawing operation. (#4843, #4844) [@hoffstadt]
|
||||||
- Tables: Fixed positioning of Sort icon on right-most column with some settings (not resizable + no borders). (#4918).
|
- Tables: Fixed positioning of Sort icon on right-most column with some settings (not resizable + no borders). (#4918).
|
||||||
|
- Nav: Fixed gamepad navigation in wrapping popups not wrapping all the way. (#4365)
|
||||||
- Sliders, Drags: Fixed text input of values with a leading sign, common when using a format enforcing sign. (#4917)
|
- Sliders, Drags: Fixed text input of values with a leading sign, common when using a format enforcing sign. (#4917)
|
||||||
|
- Demo: draw a section of keyboard in "Inputs > Keyboard, Gamepad & Navigation state" to visualize keys. [@thedmd]
|
||||||
- Platform IME: changed io.ImeSetInputScreenPosFn() to io.SetPlatformImeDataFn() API,
|
- Platform IME: changed io.ImeSetInputScreenPosFn() to io.SetPlatformImeDataFn() API,
|
||||||
now taking a ImGuiPlatformImeData structure which we can more easily extend in the future.
|
now taking a ImGuiPlatformImeData structure which we can more easily extend in the future.
|
||||||
- Platform IME: moved io.ImeWindowHandle to GetMainViewport()->PlatformHandleRaw.
|
- Platform IME: moved io.ImeWindowHandle to GetMainViewport()->PlatformHandleRaw.
|
||||||
@ -191,32 +198,34 @@ Other Changes:
|
|||||||
other backend, and facilitate the use of GLFW with lettered-shortcuts API. (#456, #2625)
|
other backend, and facilitate the use of GLFW with lettered-shortcuts API. (#456, #2625)
|
||||||
- Backends: GLFW: Submit keys using io.AddKeyEvent(). Submit keymods using io.AddKeyModsEvent() at the same time. (#2625)
|
- Backends: GLFW: Submit keys using io.AddKeyEvent(). Submit keymods using io.AddKeyModsEvent() at the same time. (#2625)
|
||||||
- Backends: GLFW: Submit mouse data using io.AddMousePosEvent(), AddMouseButtonEvent(), AddMouseWheelEvent() functions. (#4858)
|
- Backends: GLFW: Submit mouse data using io.AddMousePosEvent(), AddMouseButtonEvent(), AddMouseWheelEvent() functions. (#4858)
|
||||||
- Backends: GLFW: Update mouse position using glfwSetCursorPosCallback() + fallback when focused but not hovered/captured.
|
- Backends: GLFW: Retrieve mouse position using glfwSetCursorPosCallback() + fallback when focused but not hovered/captured.
|
||||||
- Backends: GLFW: Submit gamepad data using io.AddKeyEvent/AddKeyAnalogEvent() functions, stopped writing to io.NavInputs[]. (#4858)
|
- Backends: GLFW: Submit gamepad data using io.AddKeyEvent/AddKeyAnalogEvent() functions, stopped writing to io.NavInputs[]. (#4858)
|
||||||
- Backends: Win32: Submit keys using io.AddKeyEvent(). Submit keymods using io.AddKeyModsEvent() at the same time. (#2625)
|
- Backends: Win32: Submit keys using io.AddKeyEvent(). Submit keymods using io.AddKeyModsEvent() at the same time. (#2625)
|
||||||
- Backends: Win32: Update mouse position using WM_MOUSEMOVE/WM_MOUSELEAVE + fallback when focused but not hovered/captured.
|
- Backends: Win32: Retrieve mouse position using WM_MOUSEMOVE/WM_MOUSELEAVE + fallback when focused but not hovered/captured.
|
||||||
- Backends: Win32: Submit mouse data using io.AddMousePosEvent(), AddMouseButtonEvent(), AddMouseWheelEvent() functions. (#4858)
|
- Backends: Win32: Submit mouse data using io.AddMousePosEvent(), AddMouseButtonEvent(), AddMouseWheelEvent() functions. (#4858)
|
||||||
- Backends: Win32: Maintain a MouseButtonsDown mask instead of using ImGui::IsAnyMouseDown() which will be obsoleted.
|
- Backends: Win32: Maintain a MouseButtonsDown mask instead of using ImGui::IsAnyMouseDown() which will be obsoleted.
|
||||||
- Backends: Win32: Submit gamepad data using io.AddKeyEvent/AddKeyAnalogEvent() functions, stopped writing to io.NavInputs[]. (#4858)
|
- Backends: Win32: Submit gamepad data using io.AddKeyEvent/AddKeyAnalogEvent() functions, stopped writing to io.NavInputs[]. (#4858)
|
||||||
- Backends: SDL: Pass localized keys (matching keyboard layout). Fix e.g. CTRL+A, CTRL+Z, CTRL+Y shortcuts.
|
- Backends: SDL: Pass localized keys (matching keyboard layout). Fix e.g. CTRL+A, CTRL+Z, CTRL+Y shortcuts.
|
||||||
- Backends: SDL: Submit keys using io.AddKeyEvent(). Submit keymods using io.AddKeyModsEvent() at the same time. (#2625)
|
- Backends: SDL: Submit key data using io.AddKeyEvent(). Submit keymods using io.AddKeyModsEvent() at the same time. (#2625)
|
||||||
- Backends: SDL: Update mouse position using SDL_MOUSEMOTION/SDL_WINDOWEVENT_LEAVE + fallback when focused but not hovered/captured.
|
- Backends: SDL: Retrieve mouse position using SDL_MOUSEMOTION/SDL_WINDOWEVENT_LEAVE + fallback when focused but not hovered/captured.
|
||||||
- Backends: SDL: Submit mouse data using io.AddMousePosEvent(), AddMouseButtonEvent(), AddMouseWheelEvent() functions. (#4858)
|
- Backends: SDL: Submit mouse data using io.AddMousePosEvent(), AddMouseButtonEvent(), AddMouseWheelEvent() functions. (#4858)
|
||||||
- Backends: SDL: Maintain a MouseButtonsDown mask instead of using ImGui::IsAnyMouseDown() which will be obsoleted.
|
- Backends: SDL: Maintain a MouseButtonsDown mask instead of using ImGui::IsAnyMouseDown() which will be obsoleted.
|
||||||
- Backends: SDL: Submit gamepad data using io.AddKeyEvent/AddKeyAnalogEvent() functions, stopped writing to io.NavInputs[]. (#4858)
|
- Backends: SDL: Submit gamepad data using io.AddKeyEvent/AddKeyAnalogEvent() functions, stopped writing to io.NavInputs[]. (#4858)
|
||||||
- Backends: Allegro5: Submit keys using io.AddKeyEvent(). Submit keymods using io.AddKeyModsEvent() at the same time. (#2625)
|
- Backends: Allegro5: Submit keys using io.AddKeyEvent(). Submit keymods using io.AddKeyModsEvent() at the same time. (#2625)
|
||||||
- Backends: Allegro5: Submit mouse data using io.AddMousePosEvent(), AddMouseButtonEvent(), AddMouseWheelEvent() functions. (#4858)
|
- Backends: Allegro5: Submit mouse data using io.AddMousePosEvent(), AddMouseButtonEvent(), AddMouseWheelEvent() functions. (#4858)
|
||||||
|
- Backends: OSX: Submit keys using io.AddKeyEvent(). Submit keymods using io.AddKeyModsEvent() at the same time. (#2625)
|
||||||
|
- Backends: OSX: Submit mouse data using io.AddMousePosEvent(), AddMouseButtonEvent(), AddMouseWheelEvent() functions. (#4858)
|
||||||
- Backends: OSX: Submit gamepad data using io.AddKeyEvent/AddKeyAnalogEvent() functions, stopped writing to io.NavInputs[]. (#4858)
|
- Backends: OSX: Submit gamepad data using io.AddKeyEvent/AddKeyAnalogEvent() functions, stopped writing to io.NavInputs[]. (#4858)
|
||||||
- Backends: Android, GLUT, OSX: Submit keys using io.AddKeyEvent(). Submit keymods using io.AddKeyModsEvent() at the same time. (#2625)
|
- Backends: OSX: Added basic Platform IME support. (#3108, #2598) [@liuliu]
|
||||||
- Backends: Android, GLUT, OSX: Submit mouse data using io.AddMousePosEvent(), AddMouseButtonEvent(), AddMouseWheelEvent() functions. (#4858)
|
- Backends: OSX: Fix Game Controller nav mapping to use shoulder for both focusing and tweak speed. (#4759)
|
||||||
|
- Backends: Android, GLUT: Submit keys using io.AddKeyEvent(). Submit keymods using io.AddKeyModsEvent() at the same time. (#2625)
|
||||||
|
- Backends: Android, GLUT: Submit mouse data using io.AddMousePosEvent(), AddMouseButtonEvent(), AddMouseWheelEvent() functions. (#4858)
|
||||||
- Backends: OpenGL3: Fixed a buffer overflow in imgui_impl_opengl3_loader.h init (added in 1.86). (#4468, #4830) [@dymk]
|
- Backends: OpenGL3: Fixed a buffer overflow in imgui_impl_opengl3_loader.h init (added in 1.86). (#4468, #4830) [@dymk]
|
||||||
It would generally not have noticeable side-effect at runtime but would be detected by runtime checkers.
|
It would generally not have noticeable side-effect at runtime but would be detected by runtime checkers.
|
||||||
- Backends: Metal: Added Apple Metal C++ API support. (#4824, #4746) [@luigifcruz]
|
- Backends: Metal: Added Apple Metal C++ API support. (#4824, #4746) [@luigifcruz]
|
||||||
Enable with '#define IMGUI_IMPL_METAL_CPP' in your imconfig.h file.
|
Enable with '#define IMGUI_IMPL_METAL_CPP' in your imconfig.h file.
|
||||||
- Backends: Metal: Ignore ImDrawCmd where ElemCount == 0, which are normally not emitted by the library but
|
- Backends: Metal: Ignore ImDrawCmd where ElemCount == 0, which are normally not emitted by the library but
|
||||||
can theorically be created by user code manipulating a ImDrawList. (#4857)
|
can theorically be created by user code manipulating a ImDrawList. (#4857)
|
||||||
- Backends: OSX: Added basic Platform IME support. (#3108, #2598) [@liuliu]
|
|
||||||
- Backends: OSX: Fix Game Controller nav mapping to use shoulder for both focusing and tweak speed. (#4759)
|
|
||||||
- Backends: Vulkan: Added support for ImTextureID as VkDescriptorSet, add ImGui_ImplVulkan_AddTexture(). (#914) [@martty]
|
- Backends: Vulkan: Added support for ImTextureID as VkDescriptorSet, add ImGui_ImplVulkan_AddTexture(). (#914) [@martty]
|
||||||
- Backends: WebGPU: Fixed incorrect size parameters in wgpuRenderPassEncoderSetIndexBuffer() and
|
- Backends: WebGPU: Fixed incorrect size parameters in wgpuRenderPassEncoderSetIndexBuffer() and
|
||||||
wgpuRenderPassEncoderSetVertexBuffer() calls. (#4891) [@FeepsDev]
|
wgpuRenderPassEncoderSetVertexBuffer() calls. (#4891) [@FeepsDev]
|
||||||
|
@ -139,7 +139,7 @@ void MyLowLevelMouseButtonHandler(int button, bool down)
|
|||||||
- The gamepad/keyboard navigation is fairly functional and keeps being improved. The initial focus was to support game controllers, but keyboard is becoming increasingly and decently usable. Gamepad support is particularly useful to use Dear ImGui on a game console (e.g. PS4, Switch, XB1) without a mouse connected!
|
- The gamepad/keyboard navigation is fairly functional and keeps being improved. The initial focus was to support game controllers, but keyboard is becoming increasingly and decently usable. Gamepad support is particularly useful to use Dear ImGui on a game console (e.g. PS4, Switch, XB1) without a mouse connected!
|
||||||
- Keyboard: set `io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard` to enable.
|
- Keyboard: set `io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard` to enable.
|
||||||
- Gamepad: set `io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad` to enable (with a supporting backend).
|
- Gamepad: set `io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad` to enable (with a supporting backend).
|
||||||
- See [Control Sheets for Gamepads](http://www.dearimgui.org/controls_sheets) (reference PNG/PSD for for PS4, XB1, Switch gamepads).
|
- See [Control Sheets for Gamepads](http://www.dearimgui.org/controls_sheets) (reference PNG/PSD for PS4, XB1, Switch gamepads).
|
||||||
- See `USING GAMEPAD/KEYBOARD NAVIGATION CONTROLS` section of [imgui.cpp](https://github.com/ocornut/imgui/blob/master/imgui.cpp) for more details.
|
- See `USING GAMEPAD/KEYBOARD NAVIGATION CONTROLS` section of [imgui.cpp](https://github.com/ocornut/imgui/blob/master/imgui.cpp) for more details.
|
||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
@ -463,7 +463,7 @@ draw_list->AddCircleFilled(ImVec2(p.x + 50, p.y + 50), 30.0f, IM_COL32(255, 0, 0
|
|||||||
// Draw a 3 pixel thick yellow line
|
// Draw a 3 pixel thick yellow line
|
||||||
draw_list->AddLine(ImVec2(p.x, p.y), ImVec2(p.x + 100.0f, p.y + 100.0f), IM_COL32(255, 255, 0, 255), 3.0f);
|
draw_list->AddLine(ImVec2(p.x, p.y), ImVec2(p.x + 100.0f, p.y + 100.0f), IM_COL32(255, 255, 0, 255), 3.0f);
|
||||||
|
|
||||||
// Advance the ImGui cursor to claim space in the window (otherwise the window will appears small and needs to be resized)
|
// Advance the ImGui cursor to claim space in the window (otherwise the window will appear small and needs to be resized)
|
||||||
ImGui::Dummy(ImVec2(200, 200));
|
ImGui::Dummy(ImVec2(200, 200));
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
@ -292,8 +292,8 @@ for (int rect_n = 0; rect_n < IM_ARRAYSIZE(rect_ids); rect_n++)
|
|||||||
## Using Font Data Embedded In Source Code
|
## Using Font Data Embedded In Source Code
|
||||||
|
|
||||||
- Compile and use [binary_to_compressed_c.cpp](https://github.com/ocornut/imgui/blob/master/misc/fonts/binary_to_compressed_c.cpp) to create a compressed C style array that you can embed in source code.
|
- Compile and use [binary_to_compressed_c.cpp](https://github.com/ocornut/imgui/blob/master/misc/fonts/binary_to_compressed_c.cpp) to create a compressed C style array that you can embed in source code.
|
||||||
- See the documentation in [binary_to_compressed_c.cpp](https://github.com/ocornut/imgui/blob/master/misc/fonts/binary_to_compressed_c.cpp) for instruction on how to use the tool.
|
- See the documentation in [binary_to_compressed_c.cpp](https://github.com/ocornut/imgui/blob/master/misc/fonts/binary_to_compressed_c.cpp) for instructions on how to use the tool.
|
||||||
- You may find a precompiled version binary_to_compressed_c.exe for Windows instead of demo binaries package (see [README](https://github.com/ocornut/imgui/blob/master/docs/README.md)).
|
- You may find a precompiled version binary_to_compressed_c.exe for Windows inside the demo binaries package (see [README](https://github.com/ocornut/imgui/blob/master/docs/README.md)).
|
||||||
- The tool can optionally output Base85 encoding to reduce the size of _source code_ but the read-only arrays in the actual binary will be about 20% bigger.
|
- The tool can optionally output Base85 encoding to reduce the size of _source code_ but the read-only arrays in the actual binary will be about 20% bigger.
|
||||||
|
|
||||||
Then load the font with:
|
Then load the font with:
|
||||||
|
139
imgui.cpp
139
imgui.cpp
@ -392,6 +392,7 @@ CODE
|
|||||||
- likewise io.MousePos and GetMousePos() will use OS coordinates.
|
- likewise io.MousePos and GetMousePos() will use OS coordinates.
|
||||||
If you query mouse positions to interact with non-imgui coordinates you will need to offset them, e.g. subtract GetWindowViewport()->Pos.
|
If you query mouse positions to interact with non-imgui coordinates you will need to offset them, e.g. subtract GetWindowViewport()->Pos.
|
||||||
|
|
||||||
|
- 2022/01/26 (1.87) - inputs: moved ImGuiKeyModsFlags definition from imgui.h to imgui_internal.h. Was never advertised and used in a place marked "private" in comments. Will still be used internally.
|
||||||
- 2022/01/20 (1.87) - inputs: reworded gamepad IO.
|
- 2022/01/20 (1.87) - inputs: reworded gamepad IO.
|
||||||
- Backend writing to io.NavInputs[] -> backend should call io.AddKeyEvent()/io.AddKeyAnalogEvent() with ImGuiKey_GamepadXXX values.
|
- Backend writing to io.NavInputs[] -> backend should call io.AddKeyEvent()/io.AddKeyAnalogEvent() with ImGuiKey_GamepadXXX values.
|
||||||
- 2022/01/19 (1.87) - sliders, drags: removed support for legacy arithmetic operators (+,+-,*,/) when inputing text. This doesn't break any api/code but a feature that used to be accessible by end-users (which seemingly no one used).
|
- 2022/01/19 (1.87) - sliders, drags: removed support for legacy arithmetic operators (+,+-,*,/) when inputing text. This doesn't break any api/code but a feature that used to be accessible by end-users (which seemingly no one used).
|
||||||
@ -399,13 +400,14 @@ CODE
|
|||||||
- Backend writing to io.MousePos -> backend should call io.AddMousePosEvent()
|
- Backend writing to io.MousePos -> backend should call io.AddMousePosEvent()
|
||||||
- Backend writing to io.MouseDown[] -> backend should call io.AddMouseButtonEvent()
|
- Backend writing to io.MouseDown[] -> backend should call io.AddMouseButtonEvent()
|
||||||
- Backend writing to io.MouseWheel -> backend should call io.AddMouseWheelEvent()
|
- Backend writing to io.MouseWheel -> backend should call io.AddMouseWheelEvent()
|
||||||
- Backend writing to io.MouseHoveredViewpot -> backend should call io.AddMouseViewportEvent() [Docking branch only]
|
- Backend writing to io.MouseHoveredViewport -> backend should call io.AddMouseViewportEvent() [Docking branch w/ multi-viewports only]
|
||||||
- 2022/01/10 (1.87) - inputs: reworked keyboard IO. Removed io.KeyMap[], io.KeysDown[] in favor of calling io.AddKeyEvent(). Removed GetKeyIndex(), now unecessary. All IsKeyXXX() functions now take ImGuiKey values. All features are still functional until IMGUI_DISABLE_OBSOLETE_KEYIO is defined. Read Changelog and Release Notes for details.
|
- 2022/01/10 (1.87) - inputs: reworked keyboard IO. Removed io.KeyMap[], io.KeysDown[] in favor of calling io.AddKeyEvent(). Removed GetKeyIndex(), now unecessary. All IsKeyXXX() functions now take ImGuiKey values. All features are still functional until IMGUI_DISABLE_OBSOLETE_KEYIO is defined. Read Changelog and Release Notes for details.
|
||||||
- IsKeyPressed(MY_NATIVE_KEY_XXX) -> use IsKeyPressed(ImGuiKey_XXX)
|
- IsKeyPressed(MY_NATIVE_KEY_XXX) -> use IsKeyPressed(ImGuiKey_XXX)
|
||||||
- IsKeyPressed(GetKeyIndex(ImGuiKey_XXX)) -> use IsKeyPressed(ImGuiKey_XXX)
|
- IsKeyPressed(GetKeyIndex(ImGuiKey_XXX)) -> use IsKeyPressed(ImGuiKey_XXX)
|
||||||
- Backend writing to io.KeyMap[],io.KeysDown[] -> backend should call io.AddKeyEvent()
|
- Backend writing to io.KeyMap[],io.KeysDown[] -> backend should call io.AddKeyEvent()
|
||||||
|
- Backend writing to io.KeyCtrl, io.KeyShift.. -> backend should call io.AddKeyEvent() with ImGuiKey_ModXXX values. *IF YOU PULLED CODE BETWEEN 2021/01/10 and 2021/01/27: We used to have a io.AddKeyModsEvent() function which was now replaced by io.AddKeyEvent() with ImGuiKey_ModXXX values.*
|
||||||
- one case won't work with backward compatibility: if your custom backend used ImGuiKey as mock native indices (e.g. "io.KeyMap[ImGuiKey_A] = ImGuiKey_A") because those values are now larger than the legacy KeyDown[] array. Will assert.
|
- one case won't work with backward compatibility: if your custom backend used ImGuiKey as mock native indices (e.g. "io.KeyMap[ImGuiKey_A] = ImGuiKey_A") because those values are now larger than the legacy KeyDown[] array. Will assert.
|
||||||
- inputs: added io.AddKeyModsEvent() instead of writing directly to io.KeyCtrl, io.KeyShift, io.KeyAlt, io.KeySuper.
|
- inputs: added ImGuiKey_ModCtrl/ImGuiKey_ModShift/ImGuiKey_ModAlt/ImGuiKey_ModSuper values to submit keyboard modifiers using io.AddKeyEvent(), instead of writing directly to io.KeyCtrl, io.KeyShift, io.KeyAlt, io.KeySuper.
|
||||||
- 2022/01/05 (1.87) - inputs: renamed ImGuiKey_KeyPadEnter to ImGuiKey_KeypadEnter to align with new symbols. Kept redirection enum.
|
- 2022/01/05 (1.87) - inputs: renamed ImGuiKey_KeyPadEnter to ImGuiKey_KeypadEnter to align with new symbols. Kept redirection enum.
|
||||||
- 2022/01/05 (1.87) - removed io.ImeSetInputScreenPosFn() in favor of more flexible io.SetPlatformImeDataFn(). Removed 'void* io.ImeWindowHandle' in favor of writing to 'void* ImGuiViewport::PlatformHandleRaw'.
|
- 2022/01/05 (1.87) - removed io.ImeSetInputScreenPosFn() in favor of more flexible io.SetPlatformImeDataFn(). Removed 'void* io.ImeWindowHandle' in favor of writing to 'void* ImGuiViewport::PlatformHandleRaw'.
|
||||||
- 2022/01/01 (1.87) - commented out redirecting functions/enums names that were marked obsolete in 1.69, 1.70, 1.71, 1.72 (March-July 2019)
|
- 2022/01/01 (1.87) - commented out redirecting functions/enums names that were marked obsolete in 1.69, 1.70, 1.71, 1.72 (March-July 2019)
|
||||||
@ -1314,6 +1316,19 @@ void ImGuiIO::AddKeyAnalogEvent(ImGuiKey key, bool down, float analog_value)
|
|||||||
if (ImGui::IsGamepadKey(key))
|
if (ImGui::IsGamepadKey(key))
|
||||||
BackendUsingLegacyNavInputArray = false;
|
BackendUsingLegacyNavInputArray = false;
|
||||||
|
|
||||||
|
// Partial filter of duplicates (not strictly needed, but makes data neater in particular for key mods and gamepad values which are most commonly spmamed)
|
||||||
|
ImGuiKeyData* key_data = ImGui::GetKeyData(key);
|
||||||
|
if (key_data->Down == down && key_data->AnalogValue == analog_value)
|
||||||
|
{
|
||||||
|
bool found = false;
|
||||||
|
for (int n = g.InputEventsQueue.Size - 1; n >= 0 && !found; n--)
|
||||||
|
if (g.InputEventsQueue[n].Type == ImGuiInputEventType_Key && g.InputEventsQueue[n].Key.Key == key)
|
||||||
|
found = true;
|
||||||
|
if (!found)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add event
|
||||||
ImGuiInputEvent e;
|
ImGuiInputEvent e;
|
||||||
e.Type = ImGuiInputEventType_Key;
|
e.Type = ImGuiInputEventType_Key;
|
||||||
e.Source = ImGui::IsGamepadKey(key) ? ImGuiInputSource_Gamepad : ImGuiInputSource_Keyboard;
|
e.Source = ImGui::IsGamepadKey(key) ? ImGuiInputSource_Gamepad : ImGuiInputSource_Keyboard;
|
||||||
@ -1351,18 +1366,6 @@ void ImGuiIO::SetKeyEventNativeData(ImGuiKey key, int native_keycode, int native
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGuiIO::AddKeyModsEvent(ImGuiKeyModFlags modifiers)
|
|
||||||
{
|
|
||||||
ImGuiContext& g = *GImGui;
|
|
||||||
IM_ASSERT(&g.IO == this && "Can only add events to current context.");
|
|
||||||
|
|
||||||
ImGuiInputEvent e;
|
|
||||||
e.Type = ImGuiInputEventType_KeyMods;
|
|
||||||
e.Source = ImGuiInputSource_Keyboard;
|
|
||||||
e.KeyMods.Mods = modifiers;
|
|
||||||
g.InputEventsQueue.push_back(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Queue a mouse move event
|
// Queue a mouse move event
|
||||||
void ImGuiIO::AddMousePosEvent(float x, float y)
|
void ImGuiIO::AddMousePosEvent(float x, float y)
|
||||||
{
|
{
|
||||||
@ -4090,6 +4093,13 @@ static void ImGui::UpdateKeyboardInputs()
|
|||||||
io.KeysData[key].Down = io.KeysDown[n];
|
io.KeysData[key].Down = io.KeysDown[n];
|
||||||
io.BackendUsingLegacyKeyArrays = 1;
|
io.BackendUsingLegacyKeyArrays = 1;
|
||||||
}
|
}
|
||||||
|
if (io.BackendUsingLegacyKeyArrays == 1)
|
||||||
|
{
|
||||||
|
io.KeysData[ImGuiKey_ModCtrl].Down = io.KeyCtrl;
|
||||||
|
io.KeysData[ImGuiKey_ModShift].Down = io.KeyShift;
|
||||||
|
io.KeysData[ImGuiKey_ModAlt].Down = io.KeyAlt;
|
||||||
|
io.KeysData[ImGuiKey_ModSuper].Down = io.KeySuper;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -4485,6 +4495,11 @@ void ImGui::NewFrame()
|
|||||||
// Update keyboard input state
|
// Update keyboard input state
|
||||||
UpdateKeyboardInputs();
|
UpdateKeyboardInputs();
|
||||||
|
|
||||||
|
//IM_ASSERT(g.IO.KeyCtrl == IsKeyDown(ImGuiKey_LeftCtrl) || IsKeyDown(ImGuiKey_RightCtrl));
|
||||||
|
//IM_ASSERT(g.IO.KeyShift == IsKeyDown(ImGuiKey_LeftShift) || IsKeyDown(ImGuiKey_RightShift));
|
||||||
|
//IM_ASSERT(g.IO.KeyAlt == IsKeyDown(ImGuiKey_LeftAlt) || IsKeyDown(ImGuiKey_RightAlt));
|
||||||
|
//IM_ASSERT(g.IO.KeySuper == IsKeyDown(ImGuiKey_LeftSuper) || IsKeyDown(ImGuiKey_RightSuper));
|
||||||
|
|
||||||
// Update gamepad/keyboard navigation
|
// Update gamepad/keyboard navigation
|
||||||
NavUpdate();
|
NavUpdate();
|
||||||
|
|
||||||
@ -4729,11 +4744,10 @@ static void AddWindowToSortBuffer(ImVector<ImGuiWindow*>* out_sorted_windows, Im
|
|||||||
|
|
||||||
static void AddDrawListToDrawData(ImVector<ImDrawList*>* out_list, ImDrawList* draw_list)
|
static void AddDrawListToDrawData(ImVector<ImDrawList*>* out_list, ImDrawList* draw_list)
|
||||||
{
|
{
|
||||||
// Remove trailing command if unused.
|
|
||||||
// Technically we could return directly instead of popping, but this make things looks neat in Metrics/Debugger window as well.
|
|
||||||
draw_list->_PopUnusedDrawCmd();
|
|
||||||
if (draw_list->CmdBuffer.Size == 0)
|
if (draw_list->CmdBuffer.Size == 0)
|
||||||
return;
|
return;
|
||||||
|
if (draw_list->CmdBuffer.Size == 1 && draw_list->CmdBuffer[0].ElemCount == 0 && draw_list->CmdBuffer[0].UserCallback == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
// Draw list sanity check. Detect mismatch between PrimReserve() calls and incrementing _VtxCurrentIdx, _VtxWritePtr etc.
|
// Draw list sanity check. Detect mismatch between PrimReserve() calls and incrementing _VtxCurrentIdx, _VtxWritePtr etc.
|
||||||
// May trigger for you if you are using PrimXXX functions incorrectly.
|
// May trigger for you if you are using PrimXXX functions incorrectly.
|
||||||
@ -4830,8 +4844,10 @@ static void SetupViewportDrawData(ImGuiViewportP* viewport, ImVector<ImDrawList*
|
|||||||
draw_data->OwnerViewport = viewport;
|
draw_data->OwnerViewport = viewport;
|
||||||
for (int n = 0; n < draw_lists->Size; n++)
|
for (int n = 0; n < draw_lists->Size; n++)
|
||||||
{
|
{
|
||||||
draw_data->TotalVtxCount += draw_lists->Data[n]->VtxBuffer.Size;
|
ImDrawList* draw_list = draw_lists->Data[n];
|
||||||
draw_data->TotalIdxCount += draw_lists->Data[n]->IdxBuffer.Size;
|
draw_list->_PopUnusedDrawCmd();
|
||||||
|
draw_data->TotalVtxCount += draw_list->VtxBuffer.Size;
|
||||||
|
draw_data->TotalIdxCount += draw_list->IdxBuffer.Size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4875,6 +4891,7 @@ static void ImGui::RenderDimmedBackgroundBehindWindow(ImGuiWindow* window, ImU32
|
|||||||
{
|
{
|
||||||
// We've already called AddWindowToDrawData() which called DrawList->ChannelsMerge() on DockNodeHost windows,
|
// We've already called AddWindowToDrawData() which called DrawList->ChannelsMerge() on DockNodeHost windows,
|
||||||
// and draw list have been trimmed already, hence the explicit recreation of a draw command if missing.
|
// and draw list have been trimmed already, hence the explicit recreation of a draw command if missing.
|
||||||
|
// FIXME: This is creating complication, might be simpler if we could inject a drawlist in drawdata at a given position and not attempt to manipulate ImDrawCmd order.
|
||||||
ImDrawList* draw_list = window->RootWindowDockTree->DrawList;
|
ImDrawList* draw_list = window->RootWindowDockTree->DrawList;
|
||||||
if (draw_list->CmdBuffer.Size == 0)
|
if (draw_list->CmdBuffer.Size == 0)
|
||||||
draw_list->AddDrawCmd();
|
draw_list->AddDrawCmd();
|
||||||
@ -4885,7 +4902,7 @@ static void ImGui::RenderDimmedBackgroundBehindWindow(ImGuiWindow* window, ImU32
|
|||||||
draw_list->CmdBuffer.pop_back();
|
draw_list->CmdBuffer.pop_back();
|
||||||
draw_list->CmdBuffer.push_front(cmd);
|
draw_list->CmdBuffer.push_front(cmd);
|
||||||
draw_list->PopClipRect();
|
draw_list->PopClipRect();
|
||||||
draw_list->_PopUnusedDrawCmd(); // Since are past the calls to AddDrawListToDrawData() we don't have a _PopUnusedDrawCmd() running on commands.
|
draw_list->AddDrawCmd(); // We need to create a command as CmdBuffer.back().IdxOffset won't be correct if we append to same command.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw over sibling docking nodes in a same docking tree
|
// Draw over sibling docking nodes in a same docking tree
|
||||||
@ -4897,7 +4914,6 @@ static void ImGui::RenderDimmedBackgroundBehindWindow(ImGuiWindow* window, ImU32
|
|||||||
draw_list->PushClipRect(viewport_rect.Min, viewport_rect.Max, false);
|
draw_list->PushClipRect(viewport_rect.Min, viewport_rect.Max, false);
|
||||||
RenderRectFilledWithHole(draw_list, window->RootWindowDockTree->Rect(), window->RootWindow->Rect(), col, 0.0f);// window->RootWindowDockTree->WindowRounding);
|
RenderRectFilledWithHole(draw_list, window->RootWindowDockTree->Rect(), window->RootWindow->Rect(), col, 0.0f);// window->RootWindowDockTree->WindowRounding);
|
||||||
draw_list->PopClipRect();
|
draw_list->PopClipRect();
|
||||||
draw_list->_PopUnusedDrawCmd();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4922,6 +4938,8 @@ static void ImGui::RenderDimmedBackgrounds()
|
|||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiWindow* modal_window = GetTopMostAndVisiblePopupModal();
|
ImGuiWindow* modal_window = GetTopMostAndVisiblePopupModal();
|
||||||
|
if (g.DimBgRatio <= 0.0f && g.NavWindowingHighlightAlpha <= 0.0f)
|
||||||
|
return;
|
||||||
const bool dim_bg_for_modal = (modal_window != NULL);
|
const bool dim_bg_for_modal = (modal_window != NULL);
|
||||||
const bool dim_bg_for_window_list = (g.NavWindowingTargetAnim != NULL && g.NavWindowingTargetAnim->Active);
|
const bool dim_bg_for_window_list = (g.NavWindowingTargetAnim != NULL && g.NavWindowingTargetAnim->Active);
|
||||||
if (!dim_bg_for_modal && !dim_bg_for_window_list)
|
if (!dim_bg_for_modal && !dim_bg_for_window_list)
|
||||||
@ -4957,7 +4975,6 @@ static void ImGui::RenderDimmedBackgrounds()
|
|||||||
window->DrawList->PushClipRect(viewport->Pos, viewport->Pos + viewport->Size);
|
window->DrawList->PushClipRect(viewport->Pos, viewport->Pos + viewport->Size);
|
||||||
window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_NavWindowingHighlight, g.NavWindowingHighlightAlpha), window->WindowRounding, 0, 3.0f);
|
window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_NavWindowingHighlight, g.NavWindowingHighlightAlpha), window->WindowRounding, 0, 3.0f);
|
||||||
window->DrawList->PopClipRect();
|
window->DrawList->PopClipRect();
|
||||||
window->DrawList->_PopUnusedDrawCmd(); // Since are past the calls to AddDrawListToDrawData() we don't have a _PopUnusedDrawCmd() running on commands.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw dimming background on _other_ viewports than the ones our windows are in
|
// Draw dimming background on _other_ viewports than the ones our windows are in
|
||||||
@ -4971,7 +4988,6 @@ static void ImGui::RenderDimmedBackgrounds()
|
|||||||
ImDrawList* draw_list = GetForegroundDrawList(viewport);
|
ImDrawList* draw_list = GetForegroundDrawList(viewport);
|
||||||
const ImU32 dim_bg_col = GetColorU32(dim_bg_for_modal ? ImGuiCol_ModalWindowDimBg : ImGuiCol_NavWindowingDimBg, g.DimBgRatio);
|
const ImU32 dim_bg_col = GetColorU32(dim_bg_for_modal ? ImGuiCol_ModalWindowDimBg : ImGuiCol_NavWindowingDimBg, g.DimBgRatio);
|
||||||
draw_list->AddRectFilled(viewport->Pos, viewport->Pos + viewport->Size, dim_bg_col);
|
draw_list->AddRectFilled(viewport->Pos, viewport->Pos + viewport->Size, dim_bg_col);
|
||||||
draw_list->_PopUnusedDrawCmd();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6476,6 +6492,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
{
|
{
|
||||||
// Initialize
|
// Initialize
|
||||||
const bool window_is_child_tooltip = (flags & ImGuiWindowFlags_ChildWindow) && (flags & ImGuiWindowFlags_Tooltip); // FIXME-WIP: Undocumented behavior of Child+Tooltip for pinned tooltip (#1345)
|
const bool window_is_child_tooltip = (flags & ImGuiWindowFlags_ChildWindow) && (flags & ImGuiWindowFlags_Tooltip); // FIXME-WIP: Undocumented behavior of Child+Tooltip for pinned tooltip (#1345)
|
||||||
|
const bool window_just_appearing_after_hidden_for_resize = (window->HiddenFramesCannotSkipItems > 0);
|
||||||
window->Active = true;
|
window->Active = true;
|
||||||
window->HasCloseButton = (p_open != NULL);
|
window->HasCloseButton = (p_open != NULL);
|
||||||
window->ClipRect = ImVec4(-FLT_MAX, -FLT_MAX, +FLT_MAX, +FLT_MAX);
|
window->ClipRect = ImVec4(-FLT_MAX, -FLT_MAX, +FLT_MAX, +FLT_MAX);
|
||||||
@ -6509,7 +6526,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
// UPDATE CONTENTS SIZE, UPDATE HIDDEN STATUS
|
// UPDATE CONTENTS SIZE, UPDATE HIDDEN STATUS
|
||||||
|
|
||||||
// Update contents size from last frame for auto-fitting (or use explicit size)
|
// Update contents size from last frame for auto-fitting (or use explicit size)
|
||||||
const bool window_just_appearing_after_hidden_for_resize = (window->HiddenFramesCannotSkipItems > 0);
|
|
||||||
CalcWindowContentSizes(window, &window->ContentSize, &window->ContentSizeIdeal);
|
CalcWindowContentSizes(window, &window->ContentSize, &window->ContentSizeIdeal);
|
||||||
|
|
||||||
// FIXME: These flags are decremented before they are used. This means that in order to have these fields produce their intended behaviors
|
// FIXME: These flags are decremented before they are used. This means that in order to have these fields produce their intended behaviors
|
||||||
@ -8110,7 +8126,8 @@ static const char* const GKeyNames[] =
|
|||||||
"GamepadDpadUp", "GamepadDpadDown", "GamepadDpadLeft", "GamepadDpadRight",
|
"GamepadDpadUp", "GamepadDpadDown", "GamepadDpadLeft", "GamepadDpadRight",
|
||||||
"GamepadL1", "GamepadR1", "GamepadL2", "GamepadR2", "GamepadL3", "GamepadR3",
|
"GamepadL1", "GamepadR1", "GamepadL2", "GamepadR2", "GamepadL3", "GamepadR3",
|
||||||
"GamepadLStickUp", "GamepadLStickDown", "GamepadLStickLeft", "GamepadLStickRight",
|
"GamepadLStickUp", "GamepadLStickDown", "GamepadLStickLeft", "GamepadLStickRight",
|
||||||
"GamepadRStickUp", "GamepadRStickDown", "GamepadRStickLeft", "GamepadRStickRight"
|
"GamepadRStickUp", "GamepadRStickDown", "GamepadRStickLeft", "GamepadRStickRight",
|
||||||
|
"ModCtrl", "ModShift", "ModAlt", "ModSuper"
|
||||||
};
|
};
|
||||||
IM_STATIC_ASSERT(ImGuiKey_NamedKey_COUNT == IM_ARRAYSIZE(GKeyNames));
|
IM_STATIC_ASSERT(ImGuiKey_NamedKey_COUNT == IM_ARRAYSIZE(GKeyNames));
|
||||||
|
|
||||||
@ -8355,7 +8372,7 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
|
|||||||
ImGuiIO& io = g.IO;
|
ImGuiIO& io = g.IO;
|
||||||
|
|
||||||
bool mouse_moved = false, mouse_wheeled = false, key_changed = false, text_inputed = false;
|
bool mouse_moved = false, mouse_wheeled = false, key_changed = false, text_inputed = false;
|
||||||
int mouse_button_changed = 0x00, key_mods_changed = 0x00;
|
int mouse_button_changed = 0x00;
|
||||||
ImBitArray<ImGuiKey_KeysData_SIZE> key_changed_mask;
|
ImBitArray<ImGuiKey_KeysData_SIZE> key_changed_mask;
|
||||||
|
|
||||||
int event_n = 0;
|
int event_n = 0;
|
||||||
@ -8370,7 +8387,7 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
|
|||||||
if (io.MousePos.x != event_pos.x || io.MousePos.y != event_pos.y)
|
if (io.MousePos.x != event_pos.x || io.MousePos.y != event_pos.y)
|
||||||
{
|
{
|
||||||
// Trickling Rule: Stop processing queued events if we already handled a mouse button change
|
// Trickling Rule: Stop processing queued events if we already handled a mouse button change
|
||||||
if (trickle_fast_inputs && (mouse_button_changed != 0 || mouse_wheeled || key_changed || key_mods_changed || text_inputed))
|
if (trickle_fast_inputs && (mouse_button_changed != 0 || mouse_wheeled || key_changed || text_inputed))
|
||||||
break;
|
break;
|
||||||
io.MousePos = event_pos;
|
io.MousePos = event_pos;
|
||||||
mouse_moved = true;
|
mouse_moved = true;
|
||||||
@ -8407,8 +8424,9 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
|
|||||||
}
|
}
|
||||||
else if (e->Type == ImGuiInputEventType_Key)
|
else if (e->Type == ImGuiInputEventType_Key)
|
||||||
{
|
{
|
||||||
IM_ASSERT(e->Key.Key != ImGuiKey_None);
|
ImGuiKey key = e->Key.Key;
|
||||||
const int keydata_index = (e->Key.Key - ImGuiKey_KeysData_OFFSET);
|
IM_ASSERT(key != ImGuiKey_None);
|
||||||
|
const int keydata_index = (key - ImGuiKey_KeysData_OFFSET);
|
||||||
ImGuiKeyData* keydata = &io.KeysData[keydata_index];
|
ImGuiKeyData* keydata = &io.KeysData[keydata_index];
|
||||||
if (keydata->Down != e->Key.Down || keydata->AnalogValue != e->Key.AnalogValue)
|
if (keydata->Down != e->Key.Down || keydata->AnalogValue != e->Key.AnalogValue)
|
||||||
{
|
{
|
||||||
@ -8419,23 +8437,15 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
|
|||||||
keydata->AnalogValue = e->Key.AnalogValue;
|
keydata->AnalogValue = e->Key.AnalogValue;
|
||||||
key_changed = true;
|
key_changed = true;
|
||||||
key_changed_mask.SetBit(keydata_index);
|
key_changed_mask.SetBit(keydata_index);
|
||||||
}
|
|
||||||
}
|
if (key == ImGuiKey_ModCtrl || key == ImGuiKey_ModShift || key == ImGuiKey_ModAlt || key == ImGuiKey_ModSuper)
|
||||||
else if (e->Type == ImGuiInputEventType_KeyMods)
|
|
||||||
{
|
{
|
||||||
const ImGuiKeyModFlags modifiers = e->KeyMods.Mods;
|
if (key == ImGuiKey_ModCtrl) { io.KeyCtrl = keydata->Down; }
|
||||||
if (io.KeyMods != modifiers)
|
if (key == ImGuiKey_ModShift) { io.KeyShift = keydata->Down; }
|
||||||
{
|
if (key == ImGuiKey_ModAlt) { io.KeyAlt = keydata->Down; }
|
||||||
// Trickling Rule: Stop processing queued events if we got multiple action on the same button
|
if (key == ImGuiKey_ModSuper) { io.KeySuper = keydata->Down; }
|
||||||
ImGuiKeyModFlags modifiers_that_are_changing = (io.KeyMods ^ modifiers);
|
io.KeyMods = GetMergedKeyModFlags();
|
||||||
if (trickle_fast_inputs && (key_mods_changed & modifiers_that_are_changing) != 0)
|
}
|
||||||
break;
|
|
||||||
io.KeyMods = modifiers;
|
|
||||||
io.KeyCtrl = (modifiers & ImGuiKeyModFlags_Ctrl) != 0;
|
|
||||||
io.KeyShift = (modifiers & ImGuiKeyModFlags_Shift) != 0;
|
|
||||||
io.KeyAlt = (modifiers & ImGuiKeyModFlags_Alt) != 0;
|
|
||||||
io.KeySuper = (modifiers & ImGuiKeyModFlags_Super) != 0;
|
|
||||||
key_mods_changed |= modifiers_that_are_changing;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (e->Type == ImGuiInputEventType_Char)
|
else if (e->Type == ImGuiInputEventType_Char)
|
||||||
@ -9827,7 +9837,8 @@ bool ImGui::BeginPopup(const char* str_id, ImGuiWindowFlags flags)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
flags |= ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings;
|
flags |= ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings;
|
||||||
return BeginPopupEx(g.CurrentWindow->GetID(str_id), flags);
|
ImGuiID id = g.CurrentWindow->GetID(str_id);
|
||||||
|
return BeginPopupEx(id, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If 'p_open' is specified for a modal popup window, the popup will have a regular close button which will close the popup.
|
// If 'p_open' is specified for a modal popup window, the popup will have a regular close button which will close the popup.
|
||||||
@ -9906,7 +9917,7 @@ void ImGui::OpenPopupOnItemClick(const char* str_id, ImGuiPopupFlags popup_flags
|
|||||||
// - You may want to handle the whole on user side if you have specific needs (e.g. tweaking IsItemHovered() parameters).
|
// - You may want to handle the whole on user side if you have specific needs (e.g. tweaking IsItemHovered() parameters).
|
||||||
// This is essentially the same as:
|
// This is essentially the same as:
|
||||||
// id = str_id ? GetID(str_id) : GetItemID();
|
// id = str_id ? GetID(str_id) : GetItemID();
|
||||||
// OpenPopupOnItemClick(str_id);
|
// OpenPopupOnItemClick(str_id, ImGuiPopupFlags_MouseButtonRight);
|
||||||
// return BeginPopup(id);
|
// return BeginPopup(id);
|
||||||
// Which is essentially the same as:
|
// Which is essentially the same as:
|
||||||
// id = str_id ? GetID(str_id) : GetItemID();
|
// id = str_id ? GetID(str_id) : GetItemID();
|
||||||
@ -10077,8 +10088,7 @@ ImVec2 ImGui::FindBestWindowPosForPopup(ImGuiWindow* window)
|
|||||||
}
|
}
|
||||||
if (window->Flags & ImGuiWindowFlags_Popup)
|
if (window->Flags & ImGuiWindowFlags_Popup)
|
||||||
{
|
{
|
||||||
ImRect r_avoid = ImRect(window->Pos.x - 1, window->Pos.y - 1, window->Pos.x + 1, window->Pos.y + 1);
|
return FindBestWindowPosForPopupEx(window->Pos, window->Size, &window->AutoPosLastDirection, r_outer, ImRect(window->Pos, window->Pos), ImGuiPopupPositionPolicy_Default); // Ideally we'd disable r_avoid here
|
||||||
return FindBestWindowPosForPopupEx(window->Pos, window->Size, &window->AutoPosLastDirection, r_outer, r_avoid, ImGuiPopupPositionPolicy_Default);
|
|
||||||
}
|
}
|
||||||
if (window->Flags & ImGuiWindowFlags_Tooltip)
|
if (window->Flags & ImGuiWindowFlags_Tooltip)
|
||||||
{
|
{
|
||||||
@ -10591,9 +10601,10 @@ static ImVec2 ImGui::NavCalcPreferredRefPos()
|
|||||||
if (g.NavDisableHighlight || !g.NavDisableMouseHover || !window)
|
if (g.NavDisableHighlight || !g.NavDisableMouseHover || !window)
|
||||||
{
|
{
|
||||||
// Mouse (we need a fallback in case the mouse becomes invalid after being used)
|
// Mouse (we need a fallback in case the mouse becomes invalid after being used)
|
||||||
if (IsMousePosValid(&g.IO.MousePos))
|
// The +1.0f offset when stored by OpenPopupEx() allows reopening this or another popup (same or another mouse button) while not moving the mouse, it is pretty standard.
|
||||||
return g.IO.MousePos;
|
// In theory we could move that +1.0f offset in OpenPopupEx()
|
||||||
return g.MouseLastValidPos;
|
ImVec2 p = IsMousePosValid(&g.IO.MousePos) ? g.IO.MousePos : g.MouseLastValidPos;
|
||||||
|
return ImVec2(p.x + 1.0f, p.y);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -10946,15 +10957,21 @@ void ImGui::NavUpdateCreateMoveRequest()
|
|||||||
// When using gamepad, we project the reference nav bounding box into window visible area.
|
// When using gamepad, we project the reference nav bounding box into window visible area.
|
||||||
// This is to allow resuming navigation inside the visible area after doing a large amount of scrolling, since with gamepad every movements are relative
|
// This is to allow resuming navigation inside the visible area after doing a large amount of scrolling, since with gamepad every movements are relative
|
||||||
// (can't focus a visible object like we can with the mouse).
|
// (can't focus a visible object like we can with the mouse).
|
||||||
if (g.NavMoveSubmitted && g.NavInputSource == ImGuiInputSource_Gamepad && g.NavLayer == ImGuiNavLayer_Main && window != NULL)
|
if (g.NavMoveSubmitted && g.NavInputSource == ImGuiInputSource_Gamepad && g.NavLayer == ImGuiNavLayer_Main && window != NULL)// && (g.NavMoveFlags & ImGuiNavMoveFlags_Forwarded))
|
||||||
{
|
{
|
||||||
ImRect window_rect_rel = WindowRectAbsToRel(window, ImRect(window->InnerRect.Min - ImVec2(1, 1), window->InnerRect.Max + ImVec2(1, 1)));
|
bool clamp_x = (g.NavMoveFlags & (ImGuiNavMoveFlags_LoopX | ImGuiNavMoveFlags_WrapX)) == 0;
|
||||||
if (!window_rect_rel.Contains(window->NavRectRel[g.NavLayer]))
|
bool clamp_y = (g.NavMoveFlags & (ImGuiNavMoveFlags_LoopY | ImGuiNavMoveFlags_WrapY)) == 0;
|
||||||
|
ImRect inner_rect_rel = WindowRectAbsToRel(window, ImRect(window->InnerRect.Min - ImVec2(1, 1), window->InnerRect.Max + ImVec2(1, 1)));
|
||||||
|
if ((clamp_x || clamp_y) && !inner_rect_rel.Contains(window->NavRectRel[g.NavLayer]))
|
||||||
{
|
{
|
||||||
IMGUI_DEBUG_LOG_NAV("[nav] NavMoveRequest: clamp NavRectRel\n");
|
IMGUI_DEBUG_LOG_NAV("[nav] NavMoveRequest: clamp NavRectRel for gamepad move\n");
|
||||||
float pad = window->CalcFontSize() * 0.5f;
|
float pad_x = ImMin(inner_rect_rel.GetWidth(), window->CalcFontSize() * 0.5f);
|
||||||
window_rect_rel.Expand(ImVec2(-ImMin(window_rect_rel.GetWidth(), pad), -ImMin(window_rect_rel.GetHeight(), pad))); // Terrible approximation for the intent of starting navigation from first fully visible item
|
float pad_y = ImMin(inner_rect_rel.GetHeight(), window->CalcFontSize() * 0.5f); // Terrible approximation for the intent of starting navigation from first fully visible item
|
||||||
window->NavRectRel[g.NavLayer].ClipWithFull(window_rect_rel);
|
inner_rect_rel.Min.x = clamp_x ? (inner_rect_rel.Min.x + pad_x) : -FLT_MAX;
|
||||||
|
inner_rect_rel.Max.x = clamp_x ? (inner_rect_rel.Max.x - pad_x) : +FLT_MAX;
|
||||||
|
inner_rect_rel.Min.y = clamp_y ? (inner_rect_rel.Min.y + pad_y) : -FLT_MAX;
|
||||||
|
inner_rect_rel.Max.y = clamp_y ? (inner_rect_rel.Max.y - pad_y) : +FLT_MAX;
|
||||||
|
window->NavRectRel[g.NavLayer].ClipWithFull(inner_rect_rel);
|
||||||
g.NavId = g.NavFocusScopeId = 0;
|
g.NavId = g.NavFocusScopeId = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -17900,8 +17917,8 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||||||
Text("ActiveIdWindow: '%s'", g.ActiveIdWindow ? g.ActiveIdWindow->Name : "NULL");
|
Text("ActiveIdWindow: '%s'", g.ActiveIdWindow ? g.ActiveIdWindow->Name : "NULL");
|
||||||
|
|
||||||
int active_id_using_key_input_count = 0;
|
int active_id_using_key_input_count = 0;
|
||||||
for (int n = 0; n < g.ActiveIdUsingKeyInputMask.Size; n++)
|
for (int n = 0; n < ImGuiKey_NamedKey_COUNT; n++)
|
||||||
active_id_using_key_input_count += g.ActiveIdUsingKeyInputMask.TestBit(n) ? 1 : 0;
|
active_id_using_key_input_count += g.ActiveIdUsingKeyInputMask[n] ? 1 : 0;
|
||||||
Text("ActiveIdUsing: Wheel: %d, NavDirMask: %X, NavInputMask: %X, KeyInputMask: %d key(s)", g.ActiveIdUsingMouseWheel, g.ActiveIdUsingNavDirMask, g.ActiveIdUsingNavInputMask, active_id_using_key_input_count);
|
Text("ActiveIdUsing: Wheel: %d, NavDirMask: %X, NavInputMask: %X, KeyInputMask: %d key(s)", g.ActiveIdUsingMouseWheel, g.ActiveIdUsingNavDirMask, g.ActiveIdUsingNavInputMask, active_id_using_key_input_count);
|
||||||
Text("HoveredId: 0x%08X (%.2f sec), AllowOverlap: %d", g.HoveredIdPreviousFrame, g.HoveredIdTimer, g.HoveredIdAllowOverlap); // Not displaying g.HoveredId as it is update mid-frame
|
Text("HoveredId: 0x%08X (%.2f sec), AllowOverlap: %d", g.HoveredIdPreviousFrame, g.HoveredIdTimer, g.HoveredIdAllowOverlap); // Not displaying g.HoveredId as it is update mid-frame
|
||||||
Text("DragDrop: %d, SourceId = 0x%08X, Payload \"%s\" (%d bytes)", g.DragDropActive, g.DragDropPayload.SourceId, g.DragDropPayload.DataType, g.DragDropPayload.DataSize);
|
Text("DragDrop: %d, SourceId = 0x%08X, Payload \"%s\" (%d bytes)", g.DragDropActive, g.DragDropPayload.SourceId, g.DragDropPayload.DataType, g.DragDropPayload.DataSize);
|
||||||
|
44
imgui.h
44
imgui.h
@ -65,7 +65,7 @@ Index of this file:
|
|||||||
// Version
|
// Version
|
||||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
|
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
|
||||||
#define IMGUI_VERSION "1.87 WIP"
|
#define IMGUI_VERSION "1.87 WIP"
|
||||||
#define IMGUI_VERSION_NUM 18612
|
#define IMGUI_VERSION_NUM 18614
|
||||||
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
|
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
|
||||||
#define IMGUI_HAS_TABLE
|
#define IMGUI_HAS_TABLE
|
||||||
#define IMGUI_HAS_VIEWPORT // Viewport WIP branch
|
#define IMGUI_HAS_VIEWPORT // Viewport WIP branch
|
||||||
@ -103,7 +103,7 @@ Index of this file:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Disable some of MSVC most aggressive Debug runtime checks in function header/footer (used in some simple/low-level functions)
|
// Disable some of MSVC most aggressive Debug runtime checks in function header/footer (used in some simple/low-level functions)
|
||||||
#if defined(_MSC_VER) && !defined(__clang__) && !defined(IMGUI_DEBUG_PARANOID)
|
#if defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER) && !defined(IMGUI_DEBUG_PARANOID)
|
||||||
#define IM_MSVC_RUNTIME_CHECKS_OFF __pragma(runtime_checks("",off)) __pragma(check_stack(off)) __pragma(strict_gs_check(push,off))
|
#define IM_MSVC_RUNTIME_CHECKS_OFF __pragma(runtime_checks("",off)) __pragma(check_stack(off)) __pragma(strict_gs_check(push,off))
|
||||||
#define IM_MSVC_RUNTIME_CHECKS_RESTORE __pragma(runtime_checks("",restore)) __pragma(check_stack()) __pragma(strict_gs_check(pop))
|
#define IM_MSVC_RUNTIME_CHECKS_RESTORE __pragma(runtime_checks("",restore)) __pragma(check_stack()) __pragma(strict_gs_check(pop))
|
||||||
#else
|
#else
|
||||||
@ -690,6 +690,7 @@ namespace ImGui
|
|||||||
// - CloseCurrentPopup() is called by default by Selectable()/MenuItem() when activated (FIXME: need some options).
|
// - CloseCurrentPopup() is called by default by Selectable()/MenuItem() when activated (FIXME: need some options).
|
||||||
// - Use ImGuiPopupFlags_NoOpenOverExistingPopup to avoid opening a popup if there's already one at the same level. This is equivalent to e.g. testing for !IsAnyPopupOpen() prior to OpenPopup().
|
// - Use ImGuiPopupFlags_NoOpenOverExistingPopup to avoid opening a popup if there's already one at the same level. This is equivalent to e.g. testing for !IsAnyPopupOpen() prior to OpenPopup().
|
||||||
// - Use IsWindowAppearing() after BeginPopup() to tell if a window just opened.
|
// - Use IsWindowAppearing() after BeginPopup() to tell if a window just opened.
|
||||||
|
// - IMPORTANT: Notice that for OpenPopupOnItemClick() we exceptionally default flags to 1 (== ImGuiPopupFlags_MouseButtonRight) for backward compatibility with older API taking 'int mouse_button = 1' parameter
|
||||||
IMGUI_API void OpenPopup(const char* str_id, ImGuiPopupFlags popup_flags = 0); // call to mark popup as open (don't call every frame!).
|
IMGUI_API void OpenPopup(const char* str_id, ImGuiPopupFlags popup_flags = 0); // call to mark popup as open (don't call every frame!).
|
||||||
IMGUI_API void OpenPopup(ImGuiID id, ImGuiPopupFlags popup_flags = 0); // id overload to facilitate calling from nested stacks
|
IMGUI_API void OpenPopup(ImGuiID id, ImGuiPopupFlags popup_flags = 0); // id overload to facilitate calling from nested stacks
|
||||||
IMGUI_API void OpenPopupOnItemClick(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // helper to open popup when clicked on last item. Default to ImGuiPopupFlags_MouseButtonRight == 1. (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors)
|
IMGUI_API void OpenPopupOnItemClick(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // helper to open popup when clicked on last item. Default to ImGuiPopupFlags_MouseButtonRight == 1. (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors)
|
||||||
@ -699,7 +700,7 @@ namespace ImGui
|
|||||||
// - Helpers to do OpenPopup+BeginPopup where the Open action is triggered by e.g. hovering an item and right-clicking.
|
// - Helpers to do OpenPopup+BeginPopup where the Open action is triggered by e.g. hovering an item and right-clicking.
|
||||||
// - They are convenient to easily create context menus, hence the name.
|
// - They are convenient to easily create context menus, hence the name.
|
||||||
// - IMPORTANT: Notice that BeginPopupContextXXX takes ImGuiPopupFlags just like OpenPopup() and unlike BeginPopup(). For full consistency, we may add ImGuiWindowFlags to the BeginPopupContextXXX functions in the future.
|
// - IMPORTANT: Notice that BeginPopupContextXXX takes ImGuiPopupFlags just like OpenPopup() and unlike BeginPopup(). For full consistency, we may add ImGuiWindowFlags to the BeginPopupContextXXX functions in the future.
|
||||||
// - IMPORTANT: we exceptionally default their flags to 1 (== ImGuiPopupFlags_MouseButtonRight) for backward compatibility with older API taking 'int mouse_button = 1' parameter, so if you add other flags remember to re-add the ImGuiPopupFlags_MouseButtonRight.
|
// - IMPORTANT: Notice that we exceptionally default their flags to 1 (== ImGuiPopupFlags_MouseButtonRight) for backward compatibility with older API taking 'int mouse_button = 1' parameter, so if you add other flags remember to re-add the ImGuiPopupFlags_MouseButtonRight.
|
||||||
IMGUI_API bool BeginPopupContextItem(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // open+begin popup when clicked on last item. Use str_id==NULL to associate the popup to previous item. If you want to use that on a non-interactive item such as Text() you need to pass in an explicit ID here. read comments in .cpp!
|
IMGUI_API bool BeginPopupContextItem(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // open+begin popup when clicked on last item. Use str_id==NULL to associate the popup to previous item. If you want to use that on a non-interactive item such as Text() you need to pass in an explicit ID here. read comments in .cpp!
|
||||||
IMGUI_API bool BeginPopupContextWindow(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1);// open+begin popup when clicked on current window.
|
IMGUI_API bool BeginPopupContextWindow(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1);// open+begin popup when clicked on current window.
|
||||||
IMGUI_API bool BeginPopupContextVoid(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // open+begin popup when clicked in void (where there are no windows).
|
IMGUI_API bool BeginPopupContextVoid(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // open+begin popup when clicked in void (where there are no windows).
|
||||||
@ -1404,6 +1405,7 @@ enum ImGuiSortDirection_
|
|||||||
|
|
||||||
enum ImGuiKey_
|
enum ImGuiKey_
|
||||||
{
|
{
|
||||||
|
// Keyboard
|
||||||
ImGuiKey_None = 0,
|
ImGuiKey_None = 0,
|
||||||
ImGuiKey_Tab = 512, // == ImGuiKey_NamedKey_BEGIN
|
ImGuiKey_Tab = 512, // == ImGuiKey_NamedKey_BEGIN
|
||||||
ImGuiKey_LeftArrow,
|
ImGuiKey_LeftArrow,
|
||||||
@ -1455,7 +1457,7 @@ enum ImGuiKey_
|
|||||||
ImGuiKey_KeypadEnter,
|
ImGuiKey_KeypadEnter,
|
||||||
ImGuiKey_KeypadEqual,
|
ImGuiKey_KeypadEqual,
|
||||||
|
|
||||||
// Gamepad (some of those are expected to be analog values from 0.0f to 1.0f) ..............// NAVIGATION action
|
// Gamepad (some of those are analog values, 0.0f to 1.0f) // NAVIGATION action
|
||||||
ImGuiKey_GamepadStart, // Menu (Xbox) + (Switch) Start/Options (PS) // --
|
ImGuiKey_GamepadStart, // Menu (Xbox) + (Switch) Start/Options (PS) // --
|
||||||
ImGuiKey_GamepadBack, // View (Xbox) - (Switch) Share (PS) // --
|
ImGuiKey_GamepadBack, // View (Xbox) - (Switch) Share (PS) // --
|
||||||
ImGuiKey_GamepadFaceUp, // Y (Xbox) X (Switch) Triangle (PS) // -> ImGuiNavInput_Input
|
ImGuiKey_GamepadFaceUp, // Y (Xbox) X (Switch) Triangle (PS) // -> ImGuiNavInput_Input
|
||||||
@ -1481,40 +1483,39 @@ enum ImGuiKey_
|
|||||||
ImGuiKey_GamepadRStickLeft, // [Analog]
|
ImGuiKey_GamepadRStickLeft, // [Analog]
|
||||||
ImGuiKey_GamepadRStickRight, // [Analog]
|
ImGuiKey_GamepadRStickRight, // [Analog]
|
||||||
|
|
||||||
|
// Keyboard Modifiers
|
||||||
|
// - This is mirroring the data also written to io.KeyCtrl, io.KeyShift, io.KeyAlt, io.KeySuper, in a format allowing
|
||||||
|
// them to be accessed via standard key API, allowing calls such as IsKeyPressed(), IsKeyReleased(), querying duration etc.
|
||||||
|
// - Code polling every keys (e.g. an interface to detect a key press for input mapping) might want to ignore those
|
||||||
|
// and prefer using the real keys (e.g. ImGuiKey_LeftCtrl, ImGuiKey_RightCtrl instead of ImGuiKey_ModCtrl).
|
||||||
|
// - In theory the value of keyboard modifiers should be roughly equivalent to a logical or of the equivalent left/right keys.
|
||||||
|
// In practice: it's complicated; mods are often provided from different sources. Keyboard layout, IME, sticky keys and
|
||||||
|
// backends tend to interfere and break that equivalence. The safer decision is to relay that ambiguity down to the end-user...
|
||||||
|
ImGuiKey_ModCtrl,
|
||||||
|
ImGuiKey_ModShift,
|
||||||
|
ImGuiKey_ModAlt,
|
||||||
|
ImGuiKey_ModSuper,
|
||||||
|
|
||||||
ImGuiKey_COUNT, // No valid ImGuiKey is ever greater than this value
|
ImGuiKey_COUNT, // No valid ImGuiKey is ever greater than this value
|
||||||
|
|
||||||
// Legacy range used by legacy io.KeyMap[]. Prior to 1.87 we required user to fill io.KeysDown[512] using their own native index.
|
// [Internal] Prior to 1.87 we required user to fill io.KeysDown[512] using their own native index + a io.KeyMap[] array.
|
||||||
// We are ditching this method but keeping a legacy path for user code doing e.g. IsKeyPressed(MY_NATIVE_KEY_CODE)
|
// We are ditching this method but keeping a legacy path for user code doing e.g. IsKeyPressed(MY_NATIVE_KEY_CODE)
|
||||||
ImGuiKey_LegacyNativeKey_BEGIN = 0,
|
|
||||||
ImGuiKey_LegacyNativeKey_END = 512,
|
|
||||||
ImGuiKey_NamedKey_BEGIN = 512,
|
ImGuiKey_NamedKey_BEGIN = 512,
|
||||||
ImGuiKey_NamedKey_END = ImGuiKey_COUNT,
|
ImGuiKey_NamedKey_END = ImGuiKey_COUNT,
|
||||||
ImGuiKey_NamedKey_COUNT = ImGuiKey_NamedKey_END - ImGuiKey_NamedKey_BEGIN,
|
ImGuiKey_NamedKey_COUNT = ImGuiKey_NamedKey_END - ImGuiKey_NamedKey_BEGIN,
|
||||||
#ifdef IMGUI_DISABLE_OBSOLETE_KEYIO
|
#ifdef IMGUI_DISABLE_OBSOLETE_KEYIO
|
||||||
ImGuiKey_KeysData_SIZE = ImGuiKey_NamedKey_COUNT, // Size of KeysData[]: only hold named keys
|
ImGuiKey_KeysData_SIZE = ImGuiKey_NamedKey_COUNT, // Size of KeysData[]: only hold named keys
|
||||||
ImGuiKey_KeysData_OFFSET = ImGuiKey_NamedKey_BEGIN, // First key stored in KeysData[0]
|
ImGuiKey_KeysData_OFFSET = ImGuiKey_NamedKey_BEGIN // First key stored in KeysData[0]
|
||||||
#else
|
#else
|
||||||
ImGuiKey_KeysData_SIZE = ImGuiKey_COUNT, // Size of KeysData[]: hold legacy 0..512 keycodes + named keys
|
ImGuiKey_KeysData_SIZE = ImGuiKey_COUNT, // Size of KeysData[]: hold legacy 0..512 keycodes + named keys
|
||||||
ImGuiKey_KeysData_OFFSET = ImGuiKey_LegacyNativeKey_BEGIN, // First key stored in KeysData[0]
|
ImGuiKey_KeysData_OFFSET = 0 // First key stored in KeysData[0]
|
||||||
#endif
|
#endif
|
||||||
ImGuiKey_Gamepad_BEGIN = ImGuiKey_GamepadStart,
|
|
||||||
ImGuiKey_Gamepad_END = ImGuiKey_GamepadRStickRight + 1
|
|
||||||
|
|
||||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
, ImGuiKey_KeyPadEnter = ImGuiKey_KeypadEnter // Renamed in 1.87
|
, ImGuiKey_KeyPadEnter = ImGuiKey_KeypadEnter // Renamed in 1.87
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
// To test io.KeyMods (which is a combination of individual fields io.KeyCtrl, io.KeyShift, io.KeyAlt set by user/backend)
|
|
||||||
enum ImGuiKeyModFlags_
|
|
||||||
{
|
|
||||||
ImGuiKeyModFlags_None = 0,
|
|
||||||
ImGuiKeyModFlags_Ctrl = 1 << 0,
|
|
||||||
ImGuiKeyModFlags_Shift = 1 << 1,
|
|
||||||
ImGuiKeyModFlags_Alt = 1 << 2,
|
|
||||||
ImGuiKeyModFlags_Super = 1 << 3 // Cmd/Super/Windows key
|
|
||||||
};
|
|
||||||
|
|
||||||
// Gamepad/Keyboard navigation
|
// Gamepad/Keyboard navigation
|
||||||
// Keyboard: Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard to enable. NewFrame() will automatically fill io.NavInputs[] based on your io.AddKeyEvent() calls.
|
// Keyboard: Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard to enable. NewFrame() will automatically fill io.NavInputs[] based on your io.AddKeyEvent() calls.
|
||||||
// Gamepad: Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad to enable. Backend: set ImGuiBackendFlags_HasGamepad and fill the io.NavInputs[] fields before calling NewFrame(). Note that io.NavInputs[] is cleared by EndFrame().
|
// Gamepad: Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad to enable. Backend: set ImGuiBackendFlags_HasGamepad and fill the io.NavInputs[] fields before calling NewFrame(). Note that io.NavInputs[] is cleared by EndFrame().
|
||||||
@ -2049,7 +2050,6 @@ struct ImGuiIO
|
|||||||
// Input Functions
|
// Input Functions
|
||||||
IMGUI_API void AddKeyEvent(ImGuiKey key, bool down); // Queue a new key down/up event. Key should be "translated" (as in, generally ImGuiKey_A matches the key end-user would use to emit an 'A' character)
|
IMGUI_API void AddKeyEvent(ImGuiKey key, bool down); // Queue a new key down/up event. Key should be "translated" (as in, generally ImGuiKey_A matches the key end-user would use to emit an 'A' character)
|
||||||
IMGUI_API void AddKeyAnalogEvent(ImGuiKey key, bool down, float v); // Queue a new key down/up event for analog values (e.g. ImGuiKey_Gamepad_ values). Dead-zones should be handled by the backend.
|
IMGUI_API void AddKeyAnalogEvent(ImGuiKey key, bool down, float v); // Queue a new key down/up event for analog values (e.g. ImGuiKey_Gamepad_ values). Dead-zones should be handled by the backend.
|
||||||
IMGUI_API void AddKeyModsEvent(ImGuiKeyModFlags modifiers); // Queue a change of Ctrl/Shift/Alt/Super modifiers
|
|
||||||
IMGUI_API void AddMousePosEvent(float x, float y); // Queue a mouse position update. Use -FLT_MAX,-FLT_MAX to signify no mouse (e.g. app not focused and not hovered)
|
IMGUI_API void AddMousePosEvent(float x, float y); // Queue a mouse position update. Use -FLT_MAX,-FLT_MAX to signify no mouse (e.g. app not focused and not hovered)
|
||||||
IMGUI_API void AddMouseButtonEvent(int button, bool down); // Queue a mouse button change
|
IMGUI_API void AddMouseButtonEvent(int button, bool down); // Queue a mouse button change
|
||||||
IMGUI_API void AddMouseWheelEvent(float wh_x, float wh_y); // Queue a mouse wheel update
|
IMGUI_API void AddMouseWheelEvent(float wh_x, float wh_y); // Queue a mouse wheel update
|
||||||
|
@ -5772,19 +5772,64 @@ static void ShowDemoWindowMisc()
|
|||||||
// We iterate both legacy native range and named ImGuiKey ranges, which is a little odd but this allow displaying the data for old/new backends.
|
// We iterate both legacy native range and named ImGuiKey ranges, which is a little odd but this allow displaying the data for old/new backends.
|
||||||
// User code should never have to go through such hoops: old code may use native keycodes, new code may use ImGuiKey codes.
|
// User code should never have to go through such hoops: old code may use native keycodes, new code may use ImGuiKey codes.
|
||||||
#ifdef IMGUI_DISABLE_OBSOLETE_KEYIO
|
#ifdef IMGUI_DISABLE_OBSOLETE_KEYIO
|
||||||
struct funcs { static bool IsNativeDupe(ImGuiKey) { return false; } };
|
struct funcs { static bool IsLegacyNativeDupe(ImGuiKey) { return false; } };
|
||||||
const ImGuiKey key_first = ImGuiKey_NamedKey_BEGIN;
|
const ImGuiKey key_first = ImGuiKey_NamedKey_BEGIN;
|
||||||
#else
|
#else
|
||||||
struct funcs { static bool IsNativeDupe(ImGuiKey key) { return key < ImGuiKey_LegacyNativeKey_END && ImGui::GetIO().KeyMap[key] != -1; } }; // Hide Native<>ImGuiKey duplicates when both exists in the array
|
struct funcs { static bool IsLegacyNativeDupe(ImGuiKey key) { return key < 512 && ImGui::GetIO().KeyMap[key] != -1; } }; // Hide Native<>ImGuiKey duplicates when both exists in the array
|
||||||
const ImGuiKey key_first = 0;
|
const ImGuiKey key_first = 0;
|
||||||
#endif
|
#endif
|
||||||
ImGui::Text("Keys down:"); for (ImGuiKey key = key_first; key < ImGuiKey_COUNT; key++) { if (funcs::IsNativeDupe(key)) continue; if (ImGui::IsKeyDown(key)) { ImGui::SameLine(); ImGui::Text("\"%s\" %d (%.02f secs)", ImGui::GetKeyName(key), key, ImGui::GetKeyData(key)->DownDuration); } }
|
ImGui::Text("Keys down:"); for (ImGuiKey key = key_first; key < ImGuiKey_COUNT; key++) { if (funcs::IsLegacyNativeDupe(key)) continue; if (ImGui::IsKeyDown(key)) { ImGui::SameLine(); ImGui::Text("\"%s\" %d (%.02f secs)", ImGui::GetKeyName(key), key, ImGui::GetKeyData(key)->DownDuration); } }
|
||||||
ImGui::Text("Keys pressed:"); for (ImGuiKey key = key_first; key < ImGuiKey_COUNT; key++) { if (funcs::IsNativeDupe(key)) continue; if (ImGui::IsKeyPressed(key)) { ImGui::SameLine(); ImGui::Text("\"%s\" %d", ImGui::GetKeyName(key), key); } }
|
ImGui::Text("Keys pressed:"); for (ImGuiKey key = key_first; key < ImGuiKey_COUNT; key++) { if (funcs::IsLegacyNativeDupe(key)) continue; if (ImGui::IsKeyPressed(key)) { ImGui::SameLine(); ImGui::Text("\"%s\" %d", ImGui::GetKeyName(key), key); } }
|
||||||
ImGui::Text("Keys released:"); for (ImGuiKey key = key_first; key < ImGuiKey_COUNT; key++) { if (funcs::IsNativeDupe(key)) continue; if (ImGui::IsKeyReleased(key)) { ImGui::SameLine(); ImGui::Text("\"%s\" %d", ImGui::GetKeyName(key), key); } }
|
ImGui::Text("Keys released:"); for (ImGuiKey key = key_first; key < ImGuiKey_COUNT; key++) { if (funcs::IsLegacyNativeDupe(key)) continue; if (ImGui::IsKeyReleased(key)) { ImGui::SameLine(); ImGui::Text("\"%s\" %d", ImGui::GetKeyName(key), key); } }
|
||||||
ImGui::Text("Keys mods: %s%s%s%s", io.KeyCtrl ? "CTRL " : "", io.KeyShift ? "SHIFT " : "", io.KeyAlt ? "ALT " : "", io.KeySuper ? "SUPER " : "");
|
ImGui::Text("Keys mods: %s%s%s%s", io.KeyCtrl ? "CTRL " : "", io.KeyShift ? "SHIFT " : "", io.KeyAlt ? "ALT " : "", io.KeySuper ? "SUPER " : "");
|
||||||
ImGui::Text("Chars queue:"); for (int i = 0; i < io.InputQueueCharacters.Size; i++) { ImWchar c = io.InputQueueCharacters[i]; ImGui::SameLine(); ImGui::Text("\'%c\' (0x%04X)", (c > ' ' && c <= 255) ? (char)c : '?', c); } // FIXME: We should convert 'c' to UTF-8 here but the functions are not public.
|
ImGui::Text("Chars queue:"); for (int i = 0; i < io.InputQueueCharacters.Size; i++) { ImWchar c = io.InputQueueCharacters[i]; ImGui::SameLine(); ImGui::Text("\'%c\' (0x%04X)", (c > ' ' && c <= 255) ? (char)c : '?', c); } // FIXME: We should convert 'c' to UTF-8 here but the functions are not public.
|
||||||
ImGui::Text("NavInputs down:"); for (int i = 0; i < IM_ARRAYSIZE(io.NavInputs); i++) if (io.NavInputs[i] > 0.0f) { ImGui::SameLine(); ImGui::Text("[%d] %.2f (%.02f secs)", i, io.NavInputs[i], io.NavInputsDownDuration[i]); }
|
ImGui::Text("NavInputs down:"); for (int i = 0; i < IM_ARRAYSIZE(io.NavInputs); i++) if (io.NavInputs[i] > 0.0f) { ImGui::SameLine(); ImGui::Text("[%d] %.2f (%.02f secs)", i, io.NavInputs[i], io.NavInputsDownDuration[i]); }
|
||||||
ImGui::Text("NavInputs pressed:"); for (int i = 0; i < IM_ARRAYSIZE(io.NavInputs); i++) if (io.NavInputsDownDuration[i] == 0.0f) { ImGui::SameLine(); ImGui::Text("[%d]", i); }
|
ImGui::Text("NavInputs pressed:"); for (int i = 0; i < IM_ARRAYSIZE(io.NavInputs); i++) if (io.NavInputsDownDuration[i] == 0.0f) { ImGui::SameLine(); ImGui::Text("[%d]", i); }
|
||||||
|
|
||||||
|
// Draw an arbitrary US keyboard layout to visualize translated keys
|
||||||
|
{
|
||||||
|
const ImVec2 key_size = ImVec2(35.0f, 35.0f);
|
||||||
|
const float key_rounding = 3.0f;
|
||||||
|
const ImVec2 key_face_size = ImVec2(25.0f, 25.0f);
|
||||||
|
const ImVec2 key_face_pos = ImVec2(5.0f, 3.0f);
|
||||||
|
const float key_face_rounding = 2.0f;
|
||||||
|
const ImVec2 key_label_pos = ImVec2(7.0f, 4.0f);
|
||||||
|
const ImVec2 key_step = ImVec2(key_size.x - 1.0f, key_size.y - 1.0f);
|
||||||
|
const float key_row_offset = 9.0f;
|
||||||
|
|
||||||
|
ImVec2 board_min = ImGui::GetCursorScreenPos();
|
||||||
|
ImVec2 board_max = ImVec2(board_min.x + 3 * key_step.x + 2 * key_row_offset + 10.0f, board_min.y + 3 * key_step.y + 10.0f);
|
||||||
|
ImVec2 start_pos = ImVec2(board_min.x + 5.0f - key_step.x, board_min.y);
|
||||||
|
|
||||||
|
struct KeyLayoutData { int Row, Col; const char* Label; ImGuiKey Key; };
|
||||||
|
const KeyLayoutData keys_to_display[] =
|
||||||
|
{
|
||||||
|
{ 0, 0, "", ImGuiKey_Tab }, { 0, 1, "Q", ImGuiKey_Q }, { 0, 2, "W", ImGuiKey_W }, { 0, 3, "E", ImGuiKey_E }, { 0, 4, "R", ImGuiKey_R },
|
||||||
|
{ 1, 0, "", ImGuiKey_CapsLock }, { 1, 1, "A", ImGuiKey_A }, { 1, 2, "S", ImGuiKey_S }, { 1, 3, "D", ImGuiKey_D }, { 1, 4, "F", ImGuiKey_F },
|
||||||
|
{ 2, 0, "", ImGuiKey_LeftShift },{ 2, 1, "Z", ImGuiKey_Z }, { 2, 2, "X", ImGuiKey_X }, { 2, 3, "C", ImGuiKey_C }, { 2, 4, "V", ImGuiKey_V }
|
||||||
|
};
|
||||||
|
|
||||||
|
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
||||||
|
draw_list->PushClipRect(board_min, board_max, true);
|
||||||
|
for (int n = 0; n < IM_ARRAYSIZE(keys_to_display); n++)
|
||||||
|
{
|
||||||
|
const KeyLayoutData* key_data = &keys_to_display[n];
|
||||||
|
ImVec2 key_min = ImVec2(start_pos.x + key_data->Col * key_step.x + key_data->Row * key_row_offset, start_pos.y + key_data->Row * key_step.y);
|
||||||
|
ImVec2 key_max = ImVec2(key_min.x + key_size.x, key_min.y + key_size.y);
|
||||||
|
draw_list->AddRectFilled(key_min, key_max, IM_COL32(204, 204, 204, 255), key_rounding);
|
||||||
|
draw_list->AddRect(key_min, key_max, IM_COL32(24, 24, 24, 255), key_rounding);
|
||||||
|
ImVec2 face_min = ImVec2(key_min.x + key_face_pos.x, key_min.y + key_face_pos.y);
|
||||||
|
ImVec2 face_max = ImVec2(face_min.x + key_face_size.x, face_min.y + key_face_size.y);
|
||||||
|
draw_list->AddRect(face_min, face_max, IM_COL32(193, 193, 193, 255), key_face_rounding, ImDrawFlags_None, 2.0f);
|
||||||
|
draw_list->AddRectFilled(face_min, face_max, IM_COL32(252, 252, 252, 255), key_face_rounding);
|
||||||
|
ImVec2 label_min = ImVec2(key_min.x + key_label_pos.x, key_min.y + key_label_pos.y);
|
||||||
|
draw_list->AddText(label_min, IM_COL32(64, 64, 64, 255), key_data->Label);
|
||||||
|
if (ImGui::IsKeyDown(key_data->Key))
|
||||||
|
draw_list->AddRectFilled(key_min, key_max, IM_COL32(255, 0, 0, 128), key_rounding);
|
||||||
|
}
|
||||||
|
draw_list->PopClipRect();
|
||||||
|
ImGui::Dummy(ImVec2(board_max.x - board_min.x, board_max.y - board_min.y));
|
||||||
|
}
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7622,8 +7667,8 @@ static void ShowExampleAppCustomRendering(bool* p_open)
|
|||||||
|
|
||||||
// Context menu (under default mouse threshold)
|
// Context menu (under default mouse threshold)
|
||||||
ImVec2 drag_delta = ImGui::GetMouseDragDelta(ImGuiMouseButton_Right);
|
ImVec2 drag_delta = ImGui::GetMouseDragDelta(ImGuiMouseButton_Right);
|
||||||
if (opt_enable_context_menu && ImGui::IsMouseReleased(ImGuiMouseButton_Right) && drag_delta.x == 0.0f && drag_delta.y == 0.0f)
|
if (opt_enable_context_menu && drag_delta.x == 0.0f && drag_delta.y == 0.0f)
|
||||||
ImGui::OpenPopupOnItemClick("context");
|
ImGui::OpenPopupOnItemClick("context", ImGuiPopupFlags_MouseButtonRight);
|
||||||
if (ImGui::BeginPopup("context"))
|
if (ImGui::BeginPopup("context"))
|
||||||
{
|
{
|
||||||
if (adding_line)
|
if (adding_line)
|
||||||
|
@ -499,6 +499,7 @@ void ImDrawList::AddCallback(ImDrawCallback callback, void* callback_data)
|
|||||||
#define ImDrawCmd_HeaderSize (IM_OFFSETOF(ImDrawCmd, VtxOffset) + sizeof(unsigned int))
|
#define ImDrawCmd_HeaderSize (IM_OFFSETOF(ImDrawCmd, VtxOffset) + sizeof(unsigned int))
|
||||||
#define ImDrawCmd_HeaderCompare(CMD_LHS, CMD_RHS) (memcmp(CMD_LHS, CMD_RHS, ImDrawCmd_HeaderSize)) // Compare ClipRect, TextureId, VtxOffset
|
#define ImDrawCmd_HeaderCompare(CMD_LHS, CMD_RHS) (memcmp(CMD_LHS, CMD_RHS, ImDrawCmd_HeaderSize)) // Compare ClipRect, TextureId, VtxOffset
|
||||||
#define ImDrawCmd_HeaderCopy(CMD_DST, CMD_SRC) (memcpy(CMD_DST, CMD_SRC, ImDrawCmd_HeaderSize)) // Copy ClipRect, TextureId, VtxOffset
|
#define ImDrawCmd_HeaderCopy(CMD_DST, CMD_SRC) (memcpy(CMD_DST, CMD_SRC, ImDrawCmd_HeaderSize)) // Copy ClipRect, TextureId, VtxOffset
|
||||||
|
#define ImDrawCmd_AreSequentialIdxOffset(CMD_0, CMD_1) (CMD_0->IdxOffset + CMD_0->ElemCount == CMD_1->IdxOffset)
|
||||||
|
|
||||||
// Try to merge two last draw commands
|
// Try to merge two last draw commands
|
||||||
void ImDrawList::_TryMergeDrawCmds()
|
void ImDrawList::_TryMergeDrawCmds()
|
||||||
@ -506,7 +507,7 @@ void ImDrawList::_TryMergeDrawCmds()
|
|||||||
IM_ASSERT_PARANOID(CmdBuffer.Size > 0);
|
IM_ASSERT_PARANOID(CmdBuffer.Size > 0);
|
||||||
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
|
||||||
ImDrawCmd* prev_cmd = curr_cmd - 1;
|
ImDrawCmd* prev_cmd = curr_cmd - 1;
|
||||||
if (ImDrawCmd_HeaderCompare(curr_cmd, prev_cmd) == 0 && curr_cmd->UserCallback == NULL && prev_cmd->UserCallback == NULL)
|
if (ImDrawCmd_HeaderCompare(curr_cmd, prev_cmd) == 0 && ImDrawCmd_AreSequentialIdxOffset(prev_cmd, curr_cmd) && curr_cmd->UserCallback == NULL && prev_cmd->UserCallback == NULL)
|
||||||
{
|
{
|
||||||
prev_cmd->ElemCount += curr_cmd->ElemCount;
|
prev_cmd->ElemCount += curr_cmd->ElemCount;
|
||||||
CmdBuffer.pop_back();
|
CmdBuffer.pop_back();
|
||||||
@ -529,7 +530,7 @@ void ImDrawList::_OnChangedClipRect()
|
|||||||
|
|
||||||
// Try to merge with previous command if it matches, else use current command
|
// Try to merge with previous command if it matches, else use current command
|
||||||
ImDrawCmd* prev_cmd = curr_cmd - 1;
|
ImDrawCmd* prev_cmd = curr_cmd - 1;
|
||||||
if (curr_cmd->ElemCount == 0 && CmdBuffer.Size > 1 && ImDrawCmd_HeaderCompare(&_CmdHeader, prev_cmd) == 0 && prev_cmd->UserCallback == NULL)
|
if (curr_cmd->ElemCount == 0 && CmdBuffer.Size > 1 && ImDrawCmd_HeaderCompare(&_CmdHeader, prev_cmd) == 0 && ImDrawCmd_AreSequentialIdxOffset(prev_cmd, curr_cmd) && prev_cmd->UserCallback == NULL)
|
||||||
{
|
{
|
||||||
CmdBuffer.pop_back();
|
CmdBuffer.pop_back();
|
||||||
return;
|
return;
|
||||||
@ -552,7 +553,7 @@ void ImDrawList::_OnChangedTextureID()
|
|||||||
|
|
||||||
// Try to merge with previous command if it matches, else use current command
|
// Try to merge with previous command if it matches, else use current command
|
||||||
ImDrawCmd* prev_cmd = curr_cmd - 1;
|
ImDrawCmd* prev_cmd = curr_cmd - 1;
|
||||||
if (curr_cmd->ElemCount == 0 && CmdBuffer.Size > 1 && ImDrawCmd_HeaderCompare(&_CmdHeader, prev_cmd) == 0 && prev_cmd->UserCallback == NULL)
|
if (curr_cmd->ElemCount == 0 && CmdBuffer.Size > 1 && ImDrawCmd_HeaderCompare(&_CmdHeader, prev_cmd) == 0 && ImDrawCmd_AreSequentialIdxOffset(prev_cmd, curr_cmd) && prev_cmd->UserCallback == NULL)
|
||||||
{
|
{
|
||||||
CmdBuffer.pop_back();
|
CmdBuffer.pop_back();
|
||||||
return;
|
return;
|
||||||
@ -1746,6 +1747,8 @@ void ImDrawListSplitter::Merge(ImDrawList* draw_list)
|
|||||||
|
|
||||||
if (ch._CmdBuffer.Size > 0 && last_cmd != NULL)
|
if (ch._CmdBuffer.Size > 0 && last_cmd != NULL)
|
||||||
{
|
{
|
||||||
|
// Do not include ImDrawCmd_AreSequentialIdxOffset() in the compare as we rebuild IdxOffset values ourselves.
|
||||||
|
// Manipulating IdxOffset (e.g. by reordering draw commands like done by RenderDimmedBackgroundBehindWindow()) is not supported within a splitter.
|
||||||
ImDrawCmd* next_cmd = &ch._CmdBuffer[0];
|
ImDrawCmd* next_cmd = &ch._CmdBuffer[0];
|
||||||
if (ImDrawCmd_HeaderCompare(last_cmd, next_cmd) == 0 && last_cmd->UserCallback == NULL && next_cmd->UserCallback == NULL)
|
if (ImDrawCmd_HeaderCompare(last_cmd, next_cmd) == 0 && last_cmd->UserCallback == NULL && next_cmd->UserCallback == NULL)
|
||||||
{
|
{
|
||||||
|
176
imgui_internal.h
176
imgui_internal.h
@ -18,6 +18,7 @@ Index of this file:
|
|||||||
// [SECTION] Generic helpers
|
// [SECTION] Generic helpers
|
||||||
// [SECTION] ImDrawList support
|
// [SECTION] ImDrawList support
|
||||||
// [SECTION] Widgets support: flags, enums, data structures
|
// [SECTION] Widgets support: flags, enums, data structures
|
||||||
|
// [SECTION] Inputs support
|
||||||
// [SECTION] Clipper support
|
// [SECTION] Clipper support
|
||||||
// [SECTION] Navigation support
|
// [SECTION] Navigation support
|
||||||
// [SECTION] Columns support
|
// [SECTION] Columns support
|
||||||
@ -551,21 +552,19 @@ inline void ImBitArraySetBitRange(ImU32* arr, int n, int n2) // Works on ran
|
|||||||
|
|
||||||
// Helper: ImBitArray class (wrapper over ImBitArray functions)
|
// Helper: ImBitArray class (wrapper over ImBitArray functions)
|
||||||
// Store 1-bit per value.
|
// Store 1-bit per value.
|
||||||
template<int BITCOUNT>
|
template<int BITCOUNT, int OFFSET = 0>
|
||||||
struct IMGUI_API ImBitArray
|
struct IMGUI_API ImBitArray
|
||||||
{
|
{
|
||||||
static const int Size = BITCOUNT;
|
|
||||||
ImU32 Storage[(BITCOUNT + 31) >> 5];
|
ImU32 Storage[(BITCOUNT + 31) >> 5];
|
||||||
ImBitArray() { ClearAllBits(); }
|
ImBitArray() { ClearAllBits(); }
|
||||||
void ClearAllBits() { memset(Storage, 0, sizeof(Storage)); }
|
void ClearAllBits() { memset(Storage, 0, sizeof(Storage)); }
|
||||||
void SetAllBits() { memset(Storage, 255, sizeof(Storage)); }
|
void SetAllBits() { memset(Storage, 255, sizeof(Storage)); }
|
||||||
bool TestBit(int n) const { IM_ASSERT(n < BITCOUNT); return ImBitArrayTestBit(Storage, n); }
|
bool TestBit(int n) const { IM_ASSERT(n + OFFSET < BITCOUNT); return ImBitArrayTestBit(Storage, n + OFFSET); }
|
||||||
void SetBit(int n) { IM_ASSERT(n < BITCOUNT); ImBitArraySetBit(Storage, n); }
|
void SetBit(int n) { IM_ASSERT(n + OFFSET < BITCOUNT); ImBitArraySetBit(Storage, n + OFFSET); }
|
||||||
void ClearBit(int n) { IM_ASSERT(n < BITCOUNT); ImBitArrayClearBit(Storage, n); }
|
void ClearBit(int n) { IM_ASSERT(n + OFFSET < BITCOUNT); ImBitArrayClearBit(Storage, n + OFFSET); }
|
||||||
void SetBitRange(int n, int n2) { ImBitArraySetBitRange(Storage, n, n2); } // Works on range [n..n2)
|
void SetBitRange(int n, int n2) { ImBitArraySetBitRange(Storage, n + OFFSET, n2 + OFFSET); } // Works on range [n..n2)
|
||||||
|
bool operator[](int n) const { IM_ASSERT(n + OFFSET < BITCOUNT); return ImBitArrayTestBit(Storage, n + OFFSET); }
|
||||||
};
|
};
|
||||||
template<int BITCOUNT>
|
|
||||||
const int ImBitArray<BITCOUNT>::Size;
|
|
||||||
|
|
||||||
// Helper: ImBitVector
|
// Helper: ImBitVector
|
||||||
// Store 1-bit per value.
|
// Store 1-bit per value.
|
||||||
@ -911,73 +910,6 @@ enum ImGuiPlotType
|
|||||||
ImGuiPlotType_Histogram
|
ImGuiPlotType_Histogram
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ImGuiInputEventType
|
|
||||||
{
|
|
||||||
ImGuiInputEventType_None = 0,
|
|
||||||
ImGuiInputEventType_MousePos,
|
|
||||||
ImGuiInputEventType_MouseWheel,
|
|
||||||
ImGuiInputEventType_MouseButton,
|
|
||||||
ImGuiInputEventType_MouseViewport,
|
|
||||||
ImGuiInputEventType_Key,
|
|
||||||
ImGuiInputEventType_KeyMods,
|
|
||||||
ImGuiInputEventType_Char,
|
|
||||||
ImGuiInputEventType_Focus,
|
|
||||||
ImGuiInputEventType_COUNT
|
|
||||||
};
|
|
||||||
|
|
||||||
enum ImGuiInputSource
|
|
||||||
{
|
|
||||||
ImGuiInputSource_None = 0,
|
|
||||||
ImGuiInputSource_Mouse,
|
|
||||||
ImGuiInputSource_Keyboard,
|
|
||||||
ImGuiInputSource_Gamepad,
|
|
||||||
ImGuiInputSource_Clipboard, // Currently only used by InputText()
|
|
||||||
ImGuiInputSource_Nav, // Stored in g.ActiveIdSource only
|
|
||||||
ImGuiInputSource_COUNT
|
|
||||||
};
|
|
||||||
|
|
||||||
// FIXME: Structures in the union below need to be declared as anonymous unions appears to be an extension?
|
|
||||||
// Using ImVec2() would fail on Clang 'union member 'MousePos' has a non-trivial default constructor'
|
|
||||||
struct ImGuiInputEventMousePos { float PosX, PosY; };
|
|
||||||
struct ImGuiInputEventMouseWheel { float WheelX, WheelY; };
|
|
||||||
struct ImGuiInputEventMouseButton { int Button; bool Down; };
|
|
||||||
struct ImGuiInputEventMouseViewport { ImGuiID HoveredViewportID; };
|
|
||||||
struct ImGuiInputEventKey { ImGuiKey Key; bool Down; float AnalogValue; };
|
|
||||||
struct ImGuiInputEventKeyMods { ImGuiKeyModFlags Mods; };
|
|
||||||
struct ImGuiInputEventText { unsigned int Char; };
|
|
||||||
struct ImGuiInputEventAppFocused { bool Focused; };
|
|
||||||
|
|
||||||
struct ImGuiInputEvent
|
|
||||||
{
|
|
||||||
ImGuiInputEventType Type;
|
|
||||||
ImGuiInputSource Source;
|
|
||||||
union
|
|
||||||
{
|
|
||||||
ImGuiInputEventMousePos MousePos; // if Type == ImGuiInputEventType_MousePos
|
|
||||||
ImGuiInputEventMouseWheel MouseWheel; // if Type == ImGuiInputEventType_MouseWheel
|
|
||||||
ImGuiInputEventMouseButton MouseButton; // if Type == ImGuiInputEventType_MouseButton
|
|
||||||
ImGuiInputEventMouseViewport MouseViewport; // if Type == ImGuiInputEventType_MouseViewport
|
|
||||||
ImGuiInputEventKey Key; // if Type == ImGuiInputEventType_Key
|
|
||||||
ImGuiInputEventKeyMods KeyMods; // if Type == ImGuiInputEventType_Modifiers
|
|
||||||
ImGuiInputEventText Text; // if Type == ImGuiInputEventType_Text
|
|
||||||
ImGuiInputEventAppFocused AppFocused; // if Type == ImGuiInputEventType_Focus
|
|
||||||
};
|
|
||||||
bool AddedByTestEngine;
|
|
||||||
|
|
||||||
ImGuiInputEvent() { memset(this, 0, sizeof(*this)); }
|
|
||||||
};
|
|
||||||
|
|
||||||
// FIXME-NAV: Clarify/expose various repeat delay/rate
|
|
||||||
enum ImGuiInputReadMode
|
|
||||||
{
|
|
||||||
ImGuiInputReadMode_Down,
|
|
||||||
ImGuiInputReadMode_Pressed,
|
|
||||||
ImGuiInputReadMode_Released,
|
|
||||||
ImGuiInputReadMode_Repeat,
|
|
||||||
ImGuiInputReadMode_RepeatSlow,
|
|
||||||
ImGuiInputReadMode_RepeatFast
|
|
||||||
};
|
|
||||||
|
|
||||||
enum ImGuiPopupPositionPolicy
|
enum ImGuiPopupPositionPolicy
|
||||||
{
|
{
|
||||||
ImGuiPopupPositionPolicy_Default,
|
ImGuiPopupPositionPolicy_Default,
|
||||||
@ -1238,6 +1170,94 @@ struct ImGuiPtrOrIndex
|
|||||||
ImGuiPtrOrIndex(int index) { Ptr = NULL; Index = index; }
|
ImGuiPtrOrIndex(int index) { Ptr = NULL; Index = index; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// [SECTION] Inputs support
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
typedef ImBitArray<ImGuiKey_NamedKey_COUNT, -ImGuiKey_NamedKey_BEGIN> ImBitArrayForNamedKeys;
|
||||||
|
|
||||||
|
enum ImGuiKeyPrivate_
|
||||||
|
{
|
||||||
|
ImGuiKey_LegacyNativeKey_BEGIN = 0,
|
||||||
|
ImGuiKey_LegacyNativeKey_END = 512,
|
||||||
|
ImGuiKey_Gamepad_BEGIN = ImGuiKey_GamepadStart,
|
||||||
|
ImGuiKey_Gamepad_END = ImGuiKey_GamepadRStickRight + 1
|
||||||
|
};
|
||||||
|
|
||||||
|
// Helper to store all mods easily. Stored in e.g. io.KeyMods.
|
||||||
|
enum ImGuiKeyModFlags_
|
||||||
|
{
|
||||||
|
ImGuiKeyModFlags_None = 0,
|
||||||
|
ImGuiKeyModFlags_Ctrl = 1 << 0,
|
||||||
|
ImGuiKeyModFlags_Shift = 1 << 1,
|
||||||
|
ImGuiKeyModFlags_Alt = 1 << 2,
|
||||||
|
ImGuiKeyModFlags_Super = 1 << 3 // Cmd/Super/Windows key
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ImGuiInputEventType
|
||||||
|
{
|
||||||
|
ImGuiInputEventType_None = 0,
|
||||||
|
ImGuiInputEventType_MousePos,
|
||||||
|
ImGuiInputEventType_MouseWheel,
|
||||||
|
ImGuiInputEventType_MouseButton,
|
||||||
|
ImGuiInputEventType_MouseViewport,
|
||||||
|
ImGuiInputEventType_Key,
|
||||||
|
ImGuiInputEventType_Char,
|
||||||
|
ImGuiInputEventType_Focus,
|
||||||
|
ImGuiInputEventType_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ImGuiInputSource
|
||||||
|
{
|
||||||
|
ImGuiInputSource_None = 0,
|
||||||
|
ImGuiInputSource_Mouse,
|
||||||
|
ImGuiInputSource_Keyboard,
|
||||||
|
ImGuiInputSource_Gamepad,
|
||||||
|
ImGuiInputSource_Clipboard, // Currently only used by InputText()
|
||||||
|
ImGuiInputSource_Nav, // Stored in g.ActiveIdSource only
|
||||||
|
ImGuiInputSource_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
|
// FIXME: Structures in the union below need to be declared as anonymous unions appears to be an extension?
|
||||||
|
// Using ImVec2() would fail on Clang 'union member 'MousePos' has a non-trivial default constructor'
|
||||||
|
struct ImGuiInputEventMousePos { float PosX, PosY; };
|
||||||
|
struct ImGuiInputEventMouseWheel { float WheelX, WheelY; };
|
||||||
|
struct ImGuiInputEventMouseButton { int Button; bool Down; };
|
||||||
|
struct ImGuiInputEventMouseViewport { ImGuiID HoveredViewportID; };
|
||||||
|
struct ImGuiInputEventKey { ImGuiKey Key; bool Down; float AnalogValue; };
|
||||||
|
struct ImGuiInputEventText { unsigned int Char; };
|
||||||
|
struct ImGuiInputEventAppFocused { bool Focused; };
|
||||||
|
|
||||||
|
struct ImGuiInputEvent
|
||||||
|
{
|
||||||
|
ImGuiInputEventType Type;
|
||||||
|
ImGuiInputSource Source;
|
||||||
|
union
|
||||||
|
{
|
||||||
|
ImGuiInputEventMousePos MousePos; // if Type == ImGuiInputEventType_MousePos
|
||||||
|
ImGuiInputEventMouseWheel MouseWheel; // if Type == ImGuiInputEventType_MouseWheel
|
||||||
|
ImGuiInputEventMouseButton MouseButton; // if Type == ImGuiInputEventType_MouseButton
|
||||||
|
ImGuiInputEventMouseViewport MouseViewport; // if Type == ImGuiInputEventType_MouseViewport
|
||||||
|
ImGuiInputEventKey Key; // if Type == ImGuiInputEventType_Key
|
||||||
|
ImGuiInputEventText Text; // if Type == ImGuiInputEventType_Text
|
||||||
|
ImGuiInputEventAppFocused AppFocused; // if Type == ImGuiInputEventType_Focus
|
||||||
|
};
|
||||||
|
bool AddedByTestEngine;
|
||||||
|
|
||||||
|
ImGuiInputEvent() { memset(this, 0, sizeof(*this)); }
|
||||||
|
};
|
||||||
|
|
||||||
|
// FIXME-NAV: Clarify/expose various repeat delay/rate
|
||||||
|
enum ImGuiInputReadMode
|
||||||
|
{
|
||||||
|
ImGuiInputReadMode_Down,
|
||||||
|
ImGuiInputReadMode_Pressed,
|
||||||
|
ImGuiInputReadMode_Released,
|
||||||
|
ImGuiInputReadMode_Repeat,
|
||||||
|
ImGuiInputReadMode_RepeatSlow,
|
||||||
|
ImGuiInputReadMode_RepeatFast
|
||||||
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Clipper support
|
// [SECTION] Clipper support
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -1780,7 +1800,7 @@ struct ImGuiContext
|
|||||||
bool ActiveIdUsingMouseWheel; // Active widget will want to read mouse wheel. Blocks scrolling the underlying window.
|
bool ActiveIdUsingMouseWheel; // Active widget will want to read mouse wheel. Blocks scrolling the underlying window.
|
||||||
ImU32 ActiveIdUsingNavDirMask; // Active widget will want to read those nav move requests (e.g. can activate a button and move away from it)
|
ImU32 ActiveIdUsingNavDirMask; // Active widget will want to read those nav move requests (e.g. can activate a button and move away from it)
|
||||||
ImU32 ActiveIdUsingNavInputMask; // Active widget will want to read those nav inputs.
|
ImU32 ActiveIdUsingNavInputMask; // Active widget will want to read those nav inputs.
|
||||||
ImBitArray<ImGuiKey_NamedKey_COUNT> ActiveIdUsingKeyInputMask; // Active widget will want to read those key inputs. When we grow the ImGuiKey enum we'll need to either to order the enum to make useful keys come first, either redesign this into e.g. a small array.
|
ImBitArrayForNamedKeys ActiveIdUsingKeyInputMask; // Active widget will want to read those key inputs. When we grow the ImGuiKey enum we'll need to either to order the enum to make useful keys come first, either redesign this into e.g. a small array.
|
||||||
ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
|
ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
|
||||||
ImGuiWindow* ActiveIdWindow;
|
ImGuiWindow* ActiveIdWindow;
|
||||||
ImGuiInputSource ActiveIdSource; // Activating with mouse or nav (gamepad/keyboard)
|
ImGuiInputSource ActiveIdSource; // Activating with mouse or nav (gamepad/keyboard)
|
||||||
@ -2883,8 +2903,8 @@ namespace ImGui
|
|||||||
IMGUI_API void SetActiveIdUsingNavAndKeys();
|
IMGUI_API void SetActiveIdUsingNavAndKeys();
|
||||||
inline bool IsActiveIdUsingNavDir(ImGuiDir dir) { ImGuiContext& g = *GImGui; return (g.ActiveIdUsingNavDirMask & (1 << dir)) != 0; }
|
inline bool IsActiveIdUsingNavDir(ImGuiDir dir) { ImGuiContext& g = *GImGui; return (g.ActiveIdUsingNavDirMask & (1 << dir)) != 0; }
|
||||||
inline bool IsActiveIdUsingNavInput(ImGuiNavInput input) { ImGuiContext& g = *GImGui; return (g.ActiveIdUsingNavInputMask & (1 << input)) != 0; }
|
inline bool IsActiveIdUsingNavInput(ImGuiNavInput input) { ImGuiContext& g = *GImGui; return (g.ActiveIdUsingNavInputMask & (1 << input)) != 0; }
|
||||||
inline bool IsActiveIdUsingKey(ImGuiKey key) { IM_ASSERT(IsNamedKey(key)); ImGuiContext& g = *GImGui; return g.ActiveIdUsingKeyInputMask.TestBit(key - ImGuiKey_NamedKey_BEGIN); }
|
inline bool IsActiveIdUsingKey(ImGuiKey key) { ImGuiContext& g = *GImGui; return g.ActiveIdUsingKeyInputMask[key]; }
|
||||||
inline void SetActiveIdUsingKey(ImGuiKey key) { IM_ASSERT(IsNamedKey(key)); ImGuiContext& g = *GImGui; g.ActiveIdUsingKeyInputMask.SetBit(key - ImGuiKey_NamedKey_BEGIN); }
|
inline void SetActiveIdUsingKey(ImGuiKey key) { ImGuiContext& g = *GImGui; g.ActiveIdUsingKeyInputMask.SetBit(key); }
|
||||||
IMGUI_API bool IsMouseDragPastThreshold(ImGuiMouseButton button, float lock_threshold = -1.0f);
|
IMGUI_API bool IsMouseDragPastThreshold(ImGuiMouseButton button, float lock_threshold = -1.0f);
|
||||||
inline bool IsNavInputDown(ImGuiNavInput n) { ImGuiContext& g = *GImGui; return g.IO.NavInputs[n] > 0.0f; }
|
inline bool IsNavInputDown(ImGuiNavInput n) { ImGuiContext& g = *GImGui; return g.IO.NavInputs[n] > 0.0f; }
|
||||||
inline bool IsNavInputTest(ImGuiNavInput n, ImGuiInputReadMode rm) { return (GetNavInputAmount(n, rm) > 0.0f); }
|
inline bool IsNavInputTest(ImGuiNavInput n, ImGuiInputReadMode rm) { return (GetNavInputAmount(n, rm) > 0.0f); }
|
||||||
|
@ -4933,7 +4933,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|||||||
value_changed |= DragInt(ids[n], &i[n], 1.0f, 0, hdr ? 0 : 255, fmt_table_int[fmt_idx][n]);
|
value_changed |= DragInt(ids[n], &i[n], 1.0f, 0, hdr ? 0 : 255, fmt_table_int[fmt_idx][n]);
|
||||||
}
|
}
|
||||||
if (!(flags & ImGuiColorEditFlags_NoOptions))
|
if (!(flags & ImGuiColorEditFlags_NoOptions))
|
||||||
OpenPopupOnItemClick("context");
|
OpenPopupOnItemClick("context", ImGuiPopupFlags_MouseButtonRight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((flags & ImGuiColorEditFlags_DisplayHex) != 0 && (flags & ImGuiColorEditFlags_NoInputs) == 0)
|
else if ((flags & ImGuiColorEditFlags_DisplayHex) != 0 && (flags & ImGuiColorEditFlags_NoInputs) == 0)
|
||||||
@ -4961,7 +4961,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|||||||
IM_UNUSED(r); // Fixes C6031: Return value ignored: 'sscanf'.
|
IM_UNUSED(r); // Fixes C6031: Return value ignored: 'sscanf'.
|
||||||
}
|
}
|
||||||
if (!(flags & ImGuiColorEditFlags_NoOptions))
|
if (!(flags & ImGuiColorEditFlags_NoOptions))
|
||||||
OpenPopupOnItemClick("context");
|
OpenPopupOnItemClick("context", ImGuiPopupFlags_MouseButtonRight);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGuiWindow* picker_active_window = NULL;
|
ImGuiWindow* picker_active_window = NULL;
|
||||||
@ -4978,11 +4978,11 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|||||||
// Store current color and open a picker
|
// Store current color and open a picker
|
||||||
g.ColorPickerRef = col_v4;
|
g.ColorPickerRef = col_v4;
|
||||||
OpenPopup("picker");
|
OpenPopup("picker");
|
||||||
SetNextWindowPos(g.LastItemData.Rect.GetBL() + ImVec2(-1, style.ItemSpacing.y));
|
SetNextWindowPos(g.LastItemData.Rect.GetBL() + ImVec2(0.0f, style.ItemSpacing.y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!(flags & ImGuiColorEditFlags_NoOptions))
|
if (!(flags & ImGuiColorEditFlags_NoOptions))
|
||||||
OpenPopupOnItemClick("context");
|
OpenPopupOnItemClick("context", ImGuiPopupFlags_MouseButtonRight);
|
||||||
|
|
||||||
if (BeginPopup("picker"))
|
if (BeginPopup("picker"))
|
||||||
{
|
{
|
||||||
@ -5196,7 +5196,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!(flags & ImGuiColorEditFlags_NoOptions))
|
if (!(flags & ImGuiColorEditFlags_NoOptions))
|
||||||
OpenPopupOnItemClick("context");
|
OpenPopupOnItemClick("context", ImGuiPopupFlags_MouseButtonRight);
|
||||||
}
|
}
|
||||||
else if (flags & ImGuiColorEditFlags_PickerHueBar)
|
else if (flags & ImGuiColorEditFlags_PickerHueBar)
|
||||||
{
|
{
|
||||||
@ -5213,7 +5213,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
|||||||
value_changed = value_changed_sv = true;
|
value_changed = value_changed_sv = true;
|
||||||
}
|
}
|
||||||
if (!(flags & ImGuiColorEditFlags_NoOptions))
|
if (!(flags & ImGuiColorEditFlags_NoOptions))
|
||||||
OpenPopupOnItemClick("context");
|
OpenPopupOnItemClick("context", ImGuiPopupFlags_MouseButtonRight);
|
||||||
|
|
||||||
// Hue bar logic
|
// Hue bar logic
|
||||||
SetCursorScreenPos(ImVec2(bar0_pos_x, picker_pos.y));
|
SetCursorScreenPos(ImVec2(bar0_pos_x, picker_pos.y));
|
||||||
@ -6898,6 +6898,7 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)
|
|||||||
BeginDisabled();
|
BeginDisabled();
|
||||||
const ImGuiMenuColumns* offsets = &window->DC.MenuColumns;
|
const ImGuiMenuColumns* offsets = &window->DC.MenuColumns;
|
||||||
bool pressed;
|
bool pressed;
|
||||||
|
const ImGuiSelectableFlags selectable_flags = ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_SelectOnClick | ImGuiSelectableFlags_DontClosePopups;
|
||||||
if (window->DC.LayoutType == ImGuiLayoutType_Horizontal)
|
if (window->DC.LayoutType == ImGuiLayoutType_Horizontal)
|
||||||
{
|
{
|
||||||
// Menu inside an horizontal menu bar
|
// Menu inside an horizontal menu bar
|
||||||
@ -6908,7 +6909,7 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)
|
|||||||
PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(style.ItemSpacing.x * 2.0f, style.ItemSpacing.y));
|
PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(style.ItemSpacing.x * 2.0f, style.ItemSpacing.y));
|
||||||
float w = label_size.x;
|
float w = label_size.x;
|
||||||
ImVec2 text_pos(window->DC.CursorPos.x + offsets->OffsetLabel, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset);
|
ImVec2 text_pos(window->DC.CursorPos.x + offsets->OffsetLabel, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset);
|
||||||
pressed = Selectable("", menu_is_open, ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_SelectOnClick | ImGuiSelectableFlags_DontClosePopups, ImVec2(w, 0.0f));
|
pressed = Selectable("", menu_is_open, selectable_flags, ImVec2(w, 0.0f));
|
||||||
RenderText(text_pos, label);
|
RenderText(text_pos, label);
|
||||||
PopStyleVar();
|
PopStyleVar();
|
||||||
window->DC.CursorPos.x += IM_FLOOR(style.ItemSpacing.x * (-1.0f + 0.5f)); // -1 spacing to compensate the spacing added when Selectable() did a SameLine(). It would also work to call SameLine() ourselves after the PopStyleVar().
|
window->DC.CursorPos.x += IM_FLOOR(style.ItemSpacing.x * (-1.0f + 0.5f)); // -1 spacing to compensate the spacing added when Selectable() did a SameLine(). It would also work to call SameLine() ourselves after the PopStyleVar().
|
||||||
@ -6924,7 +6925,7 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)
|
|||||||
float min_w = window->DC.MenuColumns.DeclColumns(icon_w, label_size.x, 0.0f, checkmark_w); // Feedback to next frame
|
float min_w = window->DC.MenuColumns.DeclColumns(icon_w, label_size.x, 0.0f, checkmark_w); // Feedback to next frame
|
||||||
float extra_w = ImMax(0.0f, GetContentRegionAvail().x - min_w);
|
float extra_w = ImMax(0.0f, GetContentRegionAvail().x - min_w);
|
||||||
ImVec2 text_pos(window->DC.CursorPos.x + offsets->OffsetLabel, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset);
|
ImVec2 text_pos(window->DC.CursorPos.x + offsets->OffsetLabel, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset);
|
||||||
pressed = Selectable("", menu_is_open, ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_SelectOnClick | ImGuiSelectableFlags_DontClosePopups | ImGuiSelectableFlags_SpanAvailWidth, ImVec2(min_w, 0.0f));
|
pressed = Selectable("", menu_is_open, selectable_flags | ImGuiSelectableFlags_SpanAvailWidth, ImVec2(min_w, 0.0f));
|
||||||
RenderText(text_pos, label);
|
RenderText(text_pos, label);
|
||||||
if (icon_w > 0.0f)
|
if (icon_w > 0.0f)
|
||||||
RenderText(pos + ImVec2(offsets->OffsetIcon, 0.0f), icon);
|
RenderText(pos + ImVec2(offsets->OffsetIcon, 0.0f), icon);
|
||||||
|
Loading…
Reference in New Issue
Block a user