(Breaking) IO, IME: renamed platform IME hook io.SetPlatformImeDataFn() -> io.PlatformSetImeDataFn() and added explicit context.
This commit is contained in:
parent
8f36798035
commit
fb799bba7f
@ -29,6 +29,7 @@
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2024-07-02: Update for io.SetPlatformImeDataFn() -> io.PlatformSetImeDataFn() renaming in main library.
|
||||
// 2023-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F20 function keys. Stopped mapping F13 into PrintScreen.
|
||||
// 2023-04-09: Inputs: Added support for io.AddMouseSourceEvent() to discriminate ImGuiMouseSource_Mouse/ImGuiMouseSource_Pen.
|
||||
// 2023-02-01: Fixed scroll wheel scaling for devices emitting events with hasPreciseScrollingDeltas==false (e.g. non-Apple mices).
|
||||
@ -464,7 +465,7 @@ bool ImGui_ImplOSX_Init(NSView* view)
|
||||
[view addSubview:bd->KeyEventResponder];
|
||||
ImGui_ImplOSX_AddTrackingArea(view);
|
||||
|
||||
io.SetPlatformImeDataFn = [](ImGuiViewport* viewport, ImGuiPlatformImeData* data) -> void
|
||||
io.PlatformSetImeDataFn = [](ImGuiContext*, ImGuiViewport* viewport, ImGuiPlatformImeData* data) -> void
|
||||
{
|
||||
ImGui_ImplOSX_Data* bd = ImGui_ImplOSX_GetBackendData();
|
||||
if (data->WantVisible)
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2024-07-02: Update for io.SetPlatformImeDataFn() -> io.PlatformSetImeDataFn() renaming in main library.
|
||||
// 2024-02-14: Inputs: Handle gamepad disconnection. Added ImGui_ImplSDL2_SetGamepadMode().
|
||||
// 2023-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F24 function keys, app back/forward keys.
|
||||
// 2023-04-06: Inputs: Avoid calling SDL_StartTextInput()/SDL_StopTextInput() as they don't only pertain to IME. It's unclear exactly what their relation is to IME. (#6306)
|
||||
@ -150,7 +151,7 @@ static void ImGui_ImplSDL2_SetClipboardText(void*, const char* text)
|
||||
}
|
||||
|
||||
// Note: native IME will only display if user calls SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1") _before_ SDL_CreateWindow().
|
||||
static void ImGui_ImplSDL2_SetPlatformImeData(ImGuiViewport*, ImGuiPlatformImeData* data)
|
||||
static void ImGui_ImplSDL2_PlatformSetImeData(ImGuiContext*, ImGuiViewport*, ImGuiPlatformImeData* data)
|
||||
{
|
||||
if (data->WantVisible)
|
||||
{
|
||||
@ -430,7 +431,7 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window, SDL_Renderer* renderer, void
|
||||
io.SetClipboardTextFn = ImGui_ImplSDL2_SetClipboardText;
|
||||
io.GetClipboardTextFn = ImGui_ImplSDL2_GetClipboardText;
|
||||
io.ClipboardUserData = nullptr;
|
||||
io.SetPlatformImeDataFn = ImGui_ImplSDL2_SetPlatformImeData;
|
||||
io.PlatformSetImeDataFn = ImGui_ImplSDL2_PlatformSetImeData;
|
||||
|
||||
// Gamepad handling
|
||||
bd->GamepadMode = ImGui_ImplSDL2_GamepadMode_AutoFirst;
|
||||
|
@ -124,7 +124,7 @@ static void ImGui_ImplSDL3_SetClipboardText(void*, const char* text)
|
||||
SDL_SetClipboardText(text);
|
||||
}
|
||||
|
||||
static void ImGui_ImplSDL3_SetPlatformImeData(ImGuiViewport* viewport, ImGuiPlatformImeData* data)
|
||||
static void ImGui_ImplSDL3_PlatformSetImeData(ImGuiContext*, ImGuiViewport* viewport, ImGuiPlatformImeData* data)
|
||||
{
|
||||
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
||||
SDL_Window* window = (SDL_Window*)viewport->PlatformHandle;
|
||||
@ -425,7 +425,7 @@ static bool ImGui_ImplSDL3_Init(SDL_Window* window, SDL_Renderer* renderer, void
|
||||
io.SetClipboardTextFn = ImGui_ImplSDL3_SetClipboardText;
|
||||
io.GetClipboardTextFn = ImGui_ImplSDL3_GetClipboardText;
|
||||
io.ClipboardUserData = nullptr;
|
||||
io.SetPlatformImeDataFn = ImGui_ImplSDL3_SetPlatformImeData;
|
||||
io.PlatformSetImeDataFn = ImGui_ImplSDL3_PlatformSetImeData;
|
||||
|
||||
// Gamepad handling
|
||||
bd->GamepadMode = ImGui_ImplSDL3_GamepadMode_AutoFirst;
|
||||
|
@ -41,6 +41,12 @@ HOW TO UPDATE?
|
||||
|
||||
Breaking changes:
|
||||
|
||||
- IO, IME: renamed platform IME hook and added explicit context for consistency and future-proofness.
|
||||
- old: io.SetPlatformImeDataFn(ImGuiViewport* viewport, ImGuiPlatformImeData* data);
|
||||
- new: io.PlatformSetImeDataFn(ImGuiContext* ctx, ImGuiViewport* viewport, ImGuiPlatformImeData* data);
|
||||
It is expected that for a vast majority of users this is automatically set by core
|
||||
library and/or platform backend so it won't have any effect.
|
||||
|
||||
Other changes:
|
||||
|
||||
- IO: added io.PlatformOpenInShellFn handler to open a link/folder/file in OS shell. (#7660)
|
||||
@ -51,6 +57,7 @@ Other changes:
|
||||
other configurable locations. Always call IMGUI_DEBUG_LOG() for maximum stripping in caller code.
|
||||
- Debug Tools: Debug Log: Added "Configure Outputs.." button. (#5855)
|
||||
- Backends: SDL3: Update for API changes: SDLK_x renames and SDLK_KP_x removals (#7761, #7762)
|
||||
- Backends: SDL2,SDL3,OSX: Update for io.SetPlatformImeDataFn() -> io.PlatformSetImeDataFn() rename.
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
|
@ -639,7 +639,7 @@ The applications in examples/ are doing that.
|
||||
Windows: you can use the WM_CHAR or WM_UNICHAR or WM_IME_CHAR message (depending if your app is built using Unicode or MultiByte mode).
|
||||
You may also use `MultiByteToWideChar()` or `ToUnicode()` to retrieve Unicode codepoints from MultiByte characters or keyboard state.
|
||||
Windows: if your language is relying on an Input Method Editor (IME), you can write your HWND to ImGui::GetMainViewport()->PlatformHandleRaw
|
||||
for the default implementation of io.SetPlatformImeDataFn() to set your Microsoft IME position correctly.
|
||||
for the default implementation of io.PlatformSetImeDataFn() to set your Microsoft IME position correctly.
|
||||
|
||||
##### [Return to Index](#index)
|
||||
|
||||
|
17
imgui.cpp
17
imgui.cpp
@ -430,6 +430,9 @@ CODE
|
||||
When you are not sure about an old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all imgui files.
|
||||
You can read releases logs https://github.com/ocornut/imgui/releases for more details.
|
||||
|
||||
- 2024/07/02 (1.91.0) - IO, IME: renamed platform IME hook and added explicit context for consistency and future-proofness.
|
||||
- old: io.SetPlatformImeDataFn(ImGuiViewport* viewport, ImGuiPlatformImeData* data);
|
||||
- new: io.PlatformSetImeDataFn(ImGuiContext* ctx, ImGuiViewport* viewport, ImGuiPlatformImeData* data);
|
||||
- 2024/06/21 (1.90.9) - BeginChild: added ImGuiChildFlags_NavFlattened as a replacement for the window flag ImGuiWindowFlags_NavFlattened: the feature only ever made sense for BeginChild() anyhow.
|
||||
- old: BeginChild("Name", size, 0, ImGuiWindowFlags_NavFlattened);
|
||||
- new: BeginChild("Name", size, ImGuiChildFlags_NavFlattened, 0);
|
||||
@ -1124,7 +1127,7 @@ static void WindowSettingsHandler_WriteAll(ImGuiContext*, ImGuiSetti
|
||||
// Platform Dependents default implementation for IO functions
|
||||
static const char* GetClipboardTextFn_DefaultImpl(void* user_data_ctx);
|
||||
static void SetClipboardTextFn_DefaultImpl(void* user_data_ctx, const char* text);
|
||||
static void SetPlatformImeDataFn_DefaultImpl(ImGuiViewport* viewport, ImGuiPlatformImeData* data);
|
||||
static void PlatformSetImeDataFn_DefaultImpl(ImGuiContext* ctx, ImGuiViewport* viewport, ImGuiPlatformImeData* data);
|
||||
static void PlatformOpenInShellFn_DefaultImpl(ImGuiContext* ctx, const char* path);
|
||||
|
||||
namespace ImGui
|
||||
@ -3716,7 +3719,7 @@ void ImGui::Initialize()
|
||||
g.IO.SetClipboardTextFn = SetClipboardTextFn_DefaultImpl;
|
||||
g.IO.ClipboardUserData = (void*)&g; // Default implementation use the ImGuiContext as user data (ideally those would be arguments to the function)
|
||||
g.IO.PlatformOpenInShellFn = PlatformOpenInShellFn_DefaultImpl;
|
||||
g.IO.SetPlatformImeDataFn = SetPlatformImeDataFn_DefaultImpl;
|
||||
g.IO.PlatformSetImeDataFn = PlatformSetImeDataFn_DefaultImpl;
|
||||
|
||||
// Create default viewport
|
||||
ImGuiViewportP* viewport = IM_NEW(ImGuiViewportP)();
|
||||
@ -5138,11 +5141,11 @@ void ImGui::EndFrame()
|
||||
|
||||
// Notify Platform/OS when our Input Method Editor cursor has moved (e.g. CJK inputs using Microsoft IME)
|
||||
ImGuiPlatformImeData* ime_data = &g.PlatformImeData;
|
||||
if (g.IO.SetPlatformImeDataFn && memcmp(ime_data, &g.PlatformImeDataPrev, sizeof(ImGuiPlatformImeData)) != 0)
|
||||
if (g.IO.PlatformSetImeDataFn != NULL && memcmp(ime_data, &g.PlatformImeDataPrev, sizeof(ImGuiPlatformImeData)) != 0)
|
||||
{
|
||||
IMGUI_DEBUG_LOG_IO("[io] Calling io.SetPlatformImeDataFn(): WantVisible: %d, InputPos (%.2f,%.2f)\n", ime_data->WantVisible, ime_data->InputPos.x, ime_data->InputPos.y);
|
||||
IMGUI_DEBUG_LOG_IO("[io] Calling io.PlatformSetImeDataFn(): WantVisible: %d, InputPos (%.2f,%.2f)\n", ime_data->WantVisible, ime_data->InputPos.x, ime_data->InputPos.y);
|
||||
ImGuiViewport* viewport = GetMainViewport();
|
||||
g.IO.SetPlatformImeDataFn(viewport, ime_data);
|
||||
g.IO.PlatformSetImeDataFn(&g, viewport, ime_data);
|
||||
}
|
||||
|
||||
// Hide implicit/fallback "Debug" window if it hasn't been used
|
||||
@ -14372,7 +14375,7 @@ static void PlatformOpenInShellFn_DefaultImpl(ImGuiContext*, const char*) {}
|
||||
#pragma comment(lib, "imm32")
|
||||
#endif
|
||||
|
||||
static void SetPlatformImeDataFn_DefaultImpl(ImGuiViewport* viewport, ImGuiPlatformImeData* data)
|
||||
static void PlatformSetImeDataFn_DefaultImpl(ImGuiContext*, ImGuiViewport* viewport, ImGuiPlatformImeData* data)
|
||||
{
|
||||
// Notify OS Input Method Editor of text input position
|
||||
HWND hwnd = (HWND)viewport->PlatformHandleRaw;
|
||||
@ -14398,7 +14401,7 @@ static void SetPlatformImeDataFn_DefaultImpl(ImGuiViewport* viewport, ImGuiPlatf
|
||||
|
||||
#else
|
||||
|
||||
static void SetPlatformImeDataFn_DefaultImpl(ImGuiViewport*, ImGuiPlatformImeData*) {}
|
||||
static void PlatformSetImeDataFn_DefaultImpl(ImGuiContext*, ImGuiViewport*, ImGuiPlatformImeData*) {}
|
||||
|
||||
#endif // Default IME handlers
|
||||
|
||||
|
7
imgui.h
7
imgui.h
@ -176,7 +176,7 @@ struct ImGuiKeyData; // Storage for ImGuiIO and IsKeyDown(), IsKe
|
||||
struct ImGuiListClipper; // Helper to manually clip large list of items
|
||||
struct ImGuiOnceUponAFrame; // Helper for running a block of code not more than once a frame
|
||||
struct ImGuiPayload; // User data payload for drag and drop operations
|
||||
struct ImGuiPlatformImeData; // Platform IME data for io.SetPlatformImeDataFn() function.
|
||||
struct ImGuiPlatformImeData; // Platform IME data for io.PlatformSetImeDataFn() function.
|
||||
struct ImGuiSizeCallbackData; // Callback data when using SetNextWindowSizeConstraints() (rare/advanced use)
|
||||
struct ImGuiStorage; // Helper for key->value storage (container sorted by key)
|
||||
struct ImGuiStoragePair; // Helper for key->value storage (pair)
|
||||
@ -2247,7 +2247,8 @@ struct ImGuiIO
|
||||
|
||||
// Optional: Notify OS Input Method Editor of the screen position of your cursor for text input position (e.g. when using Japanese/Chinese IME on Windows)
|
||||
// (default to use native imm32 api on Windows)
|
||||
void (*SetPlatformImeDataFn)(ImGuiViewport* viewport, ImGuiPlatformImeData* data);
|
||||
void (*PlatformSetImeDataFn)(ImGuiContext* ctx, ImGuiViewport* viewport, ImGuiPlatformImeData* data);
|
||||
//void (*SetPlatformImeDataFn)(ImGuiViewport* viewport, ImGuiPlatformImeData* data); // [Renamed to io.PlatformSetImeDataFn in 1.91.0]
|
||||
|
||||
// Optional: Platform locale
|
||||
ImWchar PlatformLocaleDecimalPoint; // '.' // [Experimental] Configure decimal point e.g. '.' or ',' useful for some languages (e.g. German), generally pulled from *localeconv()->decimal_point
|
||||
@ -3276,7 +3277,7 @@ struct ImGuiViewport
|
||||
// [SECTION] Platform Dependent Interfaces
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// (Optional) Support for IME (Input Method Editor) via the io.SetPlatformImeDataFn() function.
|
||||
// (Optional) Support for IME (Input Method Editor) via the io.PlatformSetImeDataFn() function.
|
||||
struct ImGuiPlatformImeData
|
||||
{
|
||||
bool WantVisible; // A widget wants the IME to be visible
|
||||
|
@ -2197,7 +2197,7 @@ struct ImGuiContext
|
||||
|
||||
// Platform support
|
||||
ImGuiPlatformImeData PlatformImeData; // Data updated by current frame
|
||||
ImGuiPlatformImeData PlatformImeDataPrev; // Previous frame data (when changing we will call io.SetPlatformImeDataFn
|
||||
ImGuiPlatformImeData PlatformImeDataPrev; // Previous frame data. When changed we call the io.PlatformSetImeDataFn() handler.
|
||||
|
||||
// Settings
|
||||
bool SettingsLoaded;
|
||||
|
Loading…
Reference in New Issue
Block a user