mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-30 18:34:34 +01:00
IO: (BREAKING) moved io.GetClipboardTextFn, io.SetClipboardTextFn to platform_io.Platform_GetClipboardTextFn, platform_io.Platform_SetClipboardTextFn.
This commit is contained in:
parent
e54f240ea0
commit
214977e5fd
@ -20,6 +20,9 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
|
// 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
|
||||||
|
// - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn
|
||||||
|
// - io.SetClipboardTextFn -> platform_io.Platform_SetClipboardTextFn
|
||||||
// 2022-11-30: Renderer: Restoring using al_draw_indexed_prim() when Allegro version is >= 5.2.5.
|
// 2022-11-30: Renderer: Restoring using al_draw_indexed_prim() when Allegro version is >= 5.2.5.
|
||||||
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
|
||||||
// 2022-09-26: Inputs: Renamed ImGuiKey_ModXXX introduced in 1.87 to ImGuiMod_XXX (old names still supported).
|
// 2022-09-26: Inputs: Renamed ImGuiKey_ModXXX introduced in 1.87 to ImGuiMod_XXX (old names still supported).
|
||||||
@ -291,7 +294,7 @@ void ImGui_ImplAllegro5_InvalidateDeviceObjects()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if ALLEGRO_HAS_CLIPBOARD
|
#if ALLEGRO_HAS_CLIPBOARD
|
||||||
static const char* ImGui_ImplAllegro5_GetClipboardText(void*)
|
static const char* ImGui_ImplAllegro5_GetClipboardText(ImGuiContext*)
|
||||||
{
|
{
|
||||||
ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData();
|
ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData();
|
||||||
if (bd->ClipboardTextData)
|
if (bd->ClipboardTextData)
|
||||||
@ -300,7 +303,7 @@ static const char* ImGui_ImplAllegro5_GetClipboardText(void*)
|
|||||||
return bd->ClipboardTextData;
|
return bd->ClipboardTextData;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplAllegro5_SetClipboardText(void*, const char* text)
|
static void ImGui_ImplAllegro5_SetClipboardText(ImGuiContext*, const char* text)
|
||||||
{
|
{
|
||||||
ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData();
|
ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData();
|
||||||
al_set_clipboard_text(bd->Display, text);
|
al_set_clipboard_text(bd->Display, text);
|
||||||
@ -447,9 +450,9 @@ bool ImGui_ImplAllegro5_Init(ALLEGRO_DISPLAY* display)
|
|||||||
bd->VertexDecl = al_create_vertex_decl(elems, sizeof(ImDrawVertAllegro));
|
bd->VertexDecl = al_create_vertex_decl(elems, sizeof(ImDrawVertAllegro));
|
||||||
|
|
||||||
#if ALLEGRO_HAS_CLIPBOARD
|
#if ALLEGRO_HAS_CLIPBOARD
|
||||||
io.SetClipboardTextFn = ImGui_ImplAllegro5_SetClipboardText;
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
io.GetClipboardTextFn = ImGui_ImplAllegro5_GetClipboardText;
|
platform_io.Platform_SetClipboardTextFn = ImGui_ImplAllegro5_SetClipboardText;
|
||||||
io.ClipboardUserData = nullptr;
|
platform_io.Platform_GetClipboardTextFn = ImGui_ImplAllegro5_GetClipboardText;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -20,7 +20,9 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2024-08-22: Follow up on function pointers moved from ImGuiIO to ImGuiPlatformIO:
|
// 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
|
||||||
|
// - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn
|
||||||
|
// - io.SetClipboardTextFn -> platform_io.Platform_SetClipboardTextFn
|
||||||
// - io.PlatformOpenInShellFn -> platform_io.Platform_OpenInShellFn
|
// - io.PlatformOpenInShellFn -> platform_io.Platform_OpenInShellFn
|
||||||
// 2024-07-31: Added ImGui_ImplGlfw_Sleep() helper function for usage by our examples app, since GLFW doesn't provide one.
|
// 2024-07-31: Added ImGui_ImplGlfw_Sleep() helper function for usage by our examples app, since GLFW doesn't provide one.
|
||||||
// 2024-07-08: *BREAKING* Renamed ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback to ImGui_ImplGlfw_InstallEmscriptenCallbacks(), added GLFWWindow* parameter.
|
// 2024-07-08: *BREAKING* Renamed ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback to ImGui_ImplGlfw_InstallEmscriptenCallbacks(), added GLFWWindow* parameter.
|
||||||
|
@ -29,7 +29,9 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2024-08-22: Follow up on function pointers moved from ImGuiIO to ImGuiPlatformIO:
|
// 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
|
||||||
|
// - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn
|
||||||
|
// - io.SetClipboardTextFn -> platform_io.Platform_SetClipboardTextFn
|
||||||
// - io.PlatformSetImeDataFn -> platform_io.Platform_SetImeDataFn
|
// - io.PlatformSetImeDataFn -> platform_io.Platform_SetImeDataFn
|
||||||
// 2024-07-02: Update for io.SetPlatformImeDataFn() -> io.PlatformSetImeDataFn() renaming in main library.
|
// 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-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F20 function keys. Stopped mapping F13 into PrintScreen.
|
||||||
@ -395,6 +397,7 @@ IMGUI_IMPL_API void ImGui_ImplOSX_NewFrame(void* _Nullable view) {
|
|||||||
bool ImGui_ImplOSX_Init(NSView* view)
|
bool ImGui_ImplOSX_Init(NSView* view)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
IMGUI_CHECKVERSION();
|
IMGUI_CHECKVERSION();
|
||||||
IM_ASSERT(io.BackendPlatformUserData == nullptr && "Already initialized a platform backend!");
|
IM_ASSERT(io.BackendPlatformUserData == nullptr && "Already initialized a platform backend!");
|
||||||
|
|
||||||
@ -425,14 +428,14 @@ bool ImGui_ImplOSX_Init(NSView* view)
|
|||||||
// Note that imgui.cpp also include default OSX clipboard handlers which can be enabled
|
// Note that imgui.cpp also include default OSX clipboard handlers which can be enabled
|
||||||
// by adding '#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS' in imconfig.h and adding '-framework ApplicationServices' to your linker command-line.
|
// by adding '#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS' in imconfig.h and adding '-framework ApplicationServices' to your linker command-line.
|
||||||
// Since we are already in ObjC land here, it is easy for us to add a clipboard handler using the NSPasteboard api.
|
// Since we are already in ObjC land here, it is easy for us to add a clipboard handler using the NSPasteboard api.
|
||||||
io.SetClipboardTextFn = [](void*, const char* str) -> void
|
platform_io.Platform_SetClipboardTextFn = [](ImGuiContext*, const char* str) -> void
|
||||||
{
|
{
|
||||||
NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
|
NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
|
||||||
[pasteboard declareTypes:[NSArray arrayWithObject:NSPasteboardTypeString] owner:nil];
|
[pasteboard declareTypes:[NSArray arrayWithObject:NSPasteboardTypeString] owner:nil];
|
||||||
[pasteboard setString:[NSString stringWithUTF8String:str] forType:NSPasteboardTypeString];
|
[pasteboard setString:[NSString stringWithUTF8String:str] forType:NSPasteboardTypeString];
|
||||||
};
|
};
|
||||||
|
|
||||||
io.GetClipboardTextFn = [](void*) -> const char*
|
platform_io.Platform_GetClipboardTextFn = [](ImGuiContext*) -> const char*
|
||||||
{
|
{
|
||||||
NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
|
NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
|
||||||
NSString* available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:NSPasteboardTypeString]];
|
NSString* available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:NSPasteboardTypeString]];
|
||||||
@ -467,7 +470,6 @@ bool ImGui_ImplOSX_Init(NSView* view)
|
|||||||
[view addSubview:bd->KeyEventResponder];
|
[view addSubview:bd->KeyEventResponder];
|
||||||
ImGui_ImplOSX_AddTrackingArea(view);
|
ImGui_ImplOSX_AddTrackingArea(view);
|
||||||
|
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
|
||||||
platform_io.Platform_SetImeDataFn = [](ImGuiContext*, ImGuiViewport* viewport, ImGuiPlatformImeData* data) -> void
|
platform_io.Platform_SetImeDataFn = [](ImGuiContext*, ImGuiViewport* viewport, ImGuiPlatformImeData* data) -> void
|
||||||
{
|
{
|
||||||
ImGui_ImplOSX_Data* bd = ImGui_ImplOSX_GetBackendData();
|
ImGui_ImplOSX_Data* bd = ImGui_ImplOSX_GetBackendData();
|
||||||
|
@ -21,7 +21,9 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2024-08-22: Follow up on function pointers moved from ImGuiIO to ImGuiPlatformIO:
|
// 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
|
||||||
|
// - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn
|
||||||
|
// - io.SetClipboardTextFn -> platform_io.Platform_SetClipboardTextFn
|
||||||
// - io.PlatformOpenInShellFn -> platform_io.Platform_OpenInShellFn
|
// - io.PlatformOpenInShellFn -> platform_io.Platform_OpenInShellFn
|
||||||
// - io.PlatformSetImeDataFn -> platform_io.Platform_SetImeDataFn
|
// - io.PlatformSetImeDataFn -> platform_io.Platform_SetImeDataFn
|
||||||
// 2024-08-19: Storing SDL's Uint32 WindowID inside ImGuiViewport::PlatformHandle instead of SDL_Window*.
|
// 2024-08-19: Storing SDL's Uint32 WindowID inside ImGuiViewport::PlatformHandle instead of SDL_Window*.
|
||||||
@ -146,7 +148,7 @@ static ImGui_ImplSDL2_Data* ImGui_ImplSDL2_GetBackendData()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
static const char* ImGui_ImplSDL2_GetClipboardText(void*)
|
static const char* ImGui_ImplSDL2_GetClipboardText(ImGuiContext*)
|
||||||
{
|
{
|
||||||
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
|
||||||
if (bd->ClipboardTextData)
|
if (bd->ClipboardTextData)
|
||||||
@ -155,7 +157,7 @@ static const char* ImGui_ImplSDL2_GetClipboardText(void*)
|
|||||||
return bd->ClipboardTextData;
|
return bd->ClipboardTextData;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplSDL2_SetClipboardText(void*, const char* text)
|
static void ImGui_ImplSDL2_SetClipboardText(ImGuiContext*, const char* text)
|
||||||
{
|
{
|
||||||
SDL_SetClipboardText(text);
|
SDL_SetClipboardText(text);
|
||||||
}
|
}
|
||||||
@ -462,9 +464,9 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window, SDL_Renderer* renderer, void
|
|||||||
bd->MouseCanUseGlobalState = mouse_can_use_global_state;
|
bd->MouseCanUseGlobalState = mouse_can_use_global_state;
|
||||||
|
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
io.SetClipboardTextFn = ImGui_ImplSDL2_SetClipboardText;
|
platform_io.Platform_SetClipboardTextFn = ImGui_ImplSDL2_SetClipboardText;
|
||||||
io.GetClipboardTextFn = ImGui_ImplSDL2_GetClipboardText;
|
platform_io.Platform_GetClipboardTextFn = ImGui_ImplSDL2_GetClipboardText;
|
||||||
io.ClipboardUserData = nullptr;
|
platform_io.Platform_ClipboardUserData = nullptr;
|
||||||
platform_io.Platform_SetImeDataFn = ImGui_ImplSDL2_PlatformSetImeData;
|
platform_io.Platform_SetImeDataFn = ImGui_ImplSDL2_PlatformSetImeData;
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
platform_io.Platform_OpenInShellFn = [](ImGuiContext*, const char* url) { ImGui_ImplSDL2_EmscriptenOpenURL(url); return true; };
|
platform_io.Platform_OpenInShellFn = [](ImGuiContext*, const char* url) { ImGui_ImplSDL2_EmscriptenOpenURL(url); return true; };
|
||||||
|
@ -21,7 +21,9 @@
|
|||||||
|
|
||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2024-08-22: Follow up on function pointers moved from ImGuiIO to ImGuiPlatformIO:
|
// 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
|
||||||
|
// - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn
|
||||||
|
// - io.SetClipboardTextFn -> platform_io.Platform_SetClipboardTextFn
|
||||||
// - io.PlatformSetImeDataFn -> platform_io.Platform_SetImeDataFn
|
// - io.PlatformSetImeDataFn -> platform_io.Platform_SetImeDataFn
|
||||||
// 2024-08-19: Storing SDL_WindowID inside ImGuiViewport::PlatformHandle instead of SDL_Window*.
|
// 2024-08-19: Storing SDL_WindowID inside ImGuiViewport::PlatformHandle instead of SDL_Window*.
|
||||||
// 2024-08-19: ImGui_ImplSDL3_ProcessEvent() now ignores events intended for other SDL windows. (#7853)
|
// 2024-08-19: ImGui_ImplSDL3_ProcessEvent() now ignores events intended for other SDL windows. (#7853)
|
||||||
@ -118,7 +120,7 @@ static ImGui_ImplSDL3_Data* ImGui_ImplSDL3_GetBackendData()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
static const char* ImGui_ImplSDL3_GetClipboardText(void*)
|
static const char* ImGui_ImplSDL3_GetClipboardText(ImGuiContext*)
|
||||||
{
|
{
|
||||||
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
|
||||||
if (bd->ClipboardTextData)
|
if (bd->ClipboardTextData)
|
||||||
@ -128,7 +130,7 @@ static const char* ImGui_ImplSDL3_GetClipboardText(void*)
|
|||||||
return bd->ClipboardTextData;
|
return bd->ClipboardTextData;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplSDL3_SetClipboardText(void*, const char* text)
|
static void ImGui_ImplSDL3_SetClipboardText(ImGuiContext*, const char* text)
|
||||||
{
|
{
|
||||||
SDL_SetClipboardText(text);
|
SDL_SetClipboardText(text);
|
||||||
}
|
}
|
||||||
@ -457,9 +459,8 @@ static bool ImGui_ImplSDL3_Init(SDL_Window* window, SDL_Renderer* renderer, void
|
|||||||
bd->MouseCanUseGlobalState = mouse_can_use_global_state;
|
bd->MouseCanUseGlobalState = mouse_can_use_global_state;
|
||||||
|
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
io.SetClipboardTextFn = ImGui_ImplSDL3_SetClipboardText;
|
platform_io.Platform_SetClipboardTextFn = ImGui_ImplSDL3_SetClipboardText;
|
||||||
io.GetClipboardTextFn = ImGui_ImplSDL3_GetClipboardText;
|
platform_io.Platform_GetClipboardTextFn = ImGui_ImplSDL3_GetClipboardText;
|
||||||
io.ClipboardUserData = nullptr;
|
|
||||||
platform_io.Platform_SetImeDataFn = ImGui_ImplSDL3_PlatformSetImeData;
|
platform_io.Platform_SetImeDataFn = ImGui_ImplSDL3_PlatformSetImeData;
|
||||||
|
|
||||||
// Gamepad handling
|
// Gamepad handling
|
||||||
|
@ -41,10 +41,18 @@ HOW TO UPDATE?
|
|||||||
|
|
||||||
Breaking changes:
|
Breaking changes:
|
||||||
|
|
||||||
- IO: moved some functions from ImGuiIO to ImGuiPlatformIO:
|
- IO: moved clipboard functions from ImGuiIO to ImGuiPlatformIO:
|
||||||
- io.PlatformOpenInShellFn -> platform_io.Platform_OpenInShellFn. (#7660)
|
- io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn
|
||||||
- io.PlatformSetImeDataFn -> platform_io.Platform_SetImeDataFn.
|
- io.SetClipboardTextFn -> platform_io.Platform_SetClipboardTextFn
|
||||||
- io.PlatformLocaleDecimalPoint -> platform_io.Platform_LocaleDecimalPoint. (#7389, #6719, #2278)
|
- in function signatures, changed 'void* user_data' to 'ImGuiContext* ctx' for consistency
|
||||||
|
with other functions. Pull your user data from platform_io.ClipboardUserData if used.
|
||||||
|
- as this is will affect all users of custom engines/backends, we are providing proper
|
||||||
|
legacy redirection (will obsolete).
|
||||||
|
- IO: moved other functions from ImGuiIO to ImGuiPlatformIO:
|
||||||
|
- io.PlatformOpenInShellFn -> platform_io.Platform_OpenInShellFn (#7660)
|
||||||
|
- io.PlatformSetImeDataFn -> platform_io.Platform_SetImeDataFn
|
||||||
|
- io.PlatformLocaleDecimalPoint -> platform_io.Platform_LocaleDecimalPoint (#7389, #6719, #2278)
|
||||||
|
- clipboard function signature changed:
|
||||||
- access those via GetPlatformIO() instead of GetIO().
|
- access those via GetPlatformIO() instead of GetIO().
|
||||||
(Because PlatformOpenInShellFn and PlatformSetImeDataFn were introduced very recently and
|
(Because PlatformOpenInShellFn and PlatformSetImeDataFn were introduced very recently and
|
||||||
often automatically set by core library and backends, we are exceptionally not maintaining
|
often automatically set by core library and backends, we are exceptionally not maintaining
|
||||||
@ -76,6 +84,8 @@ Other changes:
|
|||||||
- Backends: SDL2, SDL3: storing SDL_WindowID inside ImGuiViewport::PlatformHandle instead of SDL_Window*.
|
- Backends: SDL2, SDL3: storing SDL_WindowID inside ImGuiViewport::PlatformHandle instead of SDL_Window*.
|
||||||
- Backends: GLFW: passing null window to glfwGetClipboardString()/glfwSetClipboardString()
|
- Backends: GLFW: passing null window to glfwGetClipboardString()/glfwSetClipboardString()
|
||||||
since GLFW own tests are doing that and it seems unnecessary.
|
since GLFW own tests are doing that and it seems unnecessary.
|
||||||
|
- Backends: SDL2, SDL3, GLFW, OSX, Allegro: update to set function handlers in ImGuiPlatformIO
|
||||||
|
instead of ImGuiIO.
|
||||||
- Examples: GLFW (all), SDL2 (all), SDL3 (all), Win32+OpenGL3: rework examples main loop
|
- Examples: GLFW (all), SDL2 (all), SDL3 (all), Win32+OpenGL3: rework examples main loop
|
||||||
to handle minimization without burning CPU or GPU by running unthrottled code. (#7844)
|
to handle minimization without burning CPU or GPU by running unthrottled code. (#7844)
|
||||||
|
|
||||||
|
49
imgui.cpp
49
imgui.cpp
@ -431,6 +431,8 @@ CODE
|
|||||||
You can read releases logs https://github.com/ocornut/imgui/releases for more details.
|
You can read releases logs https://github.com/ocornut/imgui/releases for more details.
|
||||||
|
|
||||||
- 2024/08/22 (1.91.1) - moved some functions from ImGuiIO to ImGuiPlatformIO structure:
|
- 2024/08/22 (1.91.1) - moved some functions from ImGuiIO to ImGuiPlatformIO structure:
|
||||||
|
- io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn + changed 'void* user_data' to 'ImGuiContext* ctx'. Pull your user data from platform_io.ClipboardUserData.
|
||||||
|
- io.SetClipboardTextFn -> platform_io.Platform_SetClipboardTextFn + same as above line.
|
||||||
- io.PlatformOpenInShellFn -> platform_io.Platform_OpenInShellFn (#7660)
|
- io.PlatformOpenInShellFn -> platform_io.Platform_OpenInShellFn (#7660)
|
||||||
- io.PlatformSetImeDataFn -> platform_io.Platform_SetImeDataFn
|
- io.PlatformSetImeDataFn -> platform_io.Platform_SetImeDataFn
|
||||||
- io.PlatformLocaleDecimalPoint -> platform_io.Platform_LocaleDecimalPoint (#7389, #6719, #2278)
|
- io.PlatformLocaleDecimalPoint -> platform_io.Platform_LocaleDecimalPoint (#7389, #6719, #2278)
|
||||||
@ -1146,9 +1148,9 @@ static void WindowSettingsHandler_ReadLine(ImGuiContext*, ImGuiSetti
|
|||||||
static void WindowSettingsHandler_ApplyAll(ImGuiContext*, ImGuiSettingsHandler*);
|
static void WindowSettingsHandler_ApplyAll(ImGuiContext*, ImGuiSettingsHandler*);
|
||||||
static void WindowSettingsHandler_WriteAll(ImGuiContext*, ImGuiSettingsHandler*, ImGuiTextBuffer* buf);
|
static void WindowSettingsHandler_WriteAll(ImGuiContext*, ImGuiSettingsHandler*, ImGuiTextBuffer* buf);
|
||||||
|
|
||||||
// Platform Dependents default implementation for IO functions
|
// Platform Dependents default implementation for ImGuiPlatformIO functions
|
||||||
static const char* GetClipboardTextFn_DefaultImpl(void* user_data_ctx);
|
static const char* Platform_GetClipboardTextFn_DefaultImpl(ImGuiContext* ctx);
|
||||||
static void SetClipboardTextFn_DefaultImpl(void* user_data_ctx, const char* text);
|
static void Platform_SetClipboardTextFn_DefaultImpl(ImGuiContext* ctx, const char* text);
|
||||||
static void Platform_SetImeDataFn_DefaultImpl(ImGuiContext* ctx, ImGuiViewport* viewport, ImGuiPlatformImeData* data);
|
static void Platform_SetImeDataFn_DefaultImpl(ImGuiContext* ctx, ImGuiViewport* viewport, ImGuiPlatformImeData* data);
|
||||||
static bool Platform_OpenInShellFn_DefaultImpl(ImGuiContext* ctx, const char* path);
|
static bool Platform_OpenInShellFn_DefaultImpl(ImGuiContext* ctx, const char* path);
|
||||||
|
|
||||||
@ -3806,10 +3808,9 @@ void ImGui::Initialize()
|
|||||||
// Setup default localization table
|
// Setup default localization table
|
||||||
LocalizeRegisterEntries(GLocalizationEntriesEnUS, IM_ARRAYSIZE(GLocalizationEntriesEnUS));
|
LocalizeRegisterEntries(GLocalizationEntriesEnUS, IM_ARRAYSIZE(GLocalizationEntriesEnUS));
|
||||||
|
|
||||||
// Setup default platform clipboard/IME handlers.
|
// Setup default ImGuiPlatformIO clipboard/IME handlers.
|
||||||
g.IO.GetClipboardTextFn = GetClipboardTextFn_DefaultImpl; // Platform dependent default implementations
|
g.PlatformIO.Platform_GetClipboardTextFn = Platform_GetClipboardTextFn_DefaultImpl; // Platform dependent default implementations
|
||||||
g.IO.SetClipboardTextFn = SetClipboardTextFn_DefaultImpl;
|
g.PlatformIO.Platform_SetClipboardTextFn = Platform_SetClipboardTextFn_DefaultImpl;
|
||||||
g.IO.ClipboardUserData = (void*)&g; // Default implementation use the ImGuiContext as user data (ideally those would be arguments to the function)
|
|
||||||
g.PlatformIO.Platform_OpenInShellFn = Platform_OpenInShellFn_DefaultImpl;
|
g.PlatformIO.Platform_OpenInShellFn = Platform_OpenInShellFn_DefaultImpl;
|
||||||
g.PlatformIO.Platform_SetImeDataFn = Platform_SetImeDataFn_DefaultImpl;
|
g.PlatformIO.Platform_SetImeDataFn = Platform_SetImeDataFn_DefaultImpl;
|
||||||
|
|
||||||
@ -4451,14 +4452,14 @@ void ImGui::DebugAllocHook(ImGuiDebugAllocInfo* info, int frame_count, void* ptr
|
|||||||
const char* ImGui::GetClipboardText()
|
const char* ImGui::GetClipboardText()
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
return g.IO.GetClipboardTextFn ? g.IO.GetClipboardTextFn(g.IO.ClipboardUserData) : "";
|
return g.PlatformIO.Platform_GetClipboardTextFn ? g.PlatformIO.Platform_GetClipboardTextFn(&g) : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::SetClipboardText(const char* text)
|
void ImGui::SetClipboardText(const char* text)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
if (g.IO.SetClipboardTextFn)
|
if (g.PlatformIO.Platform_SetClipboardTextFn != NULL)
|
||||||
g.IO.SetClipboardTextFn(g.IO.ClipboardUserData, text);
|
g.PlatformIO.Platform_SetClipboardTextFn(&g, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* ImGui::GetVersion()
|
const char* ImGui::GetVersion()
|
||||||
@ -10096,6 +10097,14 @@ static void ImGui::ErrorCheckNewFrameSanityChecks()
|
|||||||
if ((g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) && g.IO.BackendUsingLegacyKeyArrays == 1)
|
if ((g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) && g.IO.BackendUsingLegacyKeyArrays == 1)
|
||||||
IM_ASSERT(g.IO.KeyMap[ImGuiKey_Space] != -1 && "ImGuiKey_Space is not mapped, required for keyboard navigation.");
|
IM_ASSERT(g.IO.KeyMap[ImGuiKey_Space] != -1 && "ImGuiKey_Space is not mapped, required for keyboard navigation.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Remap legacy clipboard handlers (OBSOLETED in 1.91.1, August 2024)
|
||||||
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
|
if (g.IO.GetClipboardTextFn != NULL && (g.PlatformIO.Platform_GetClipboardTextFn == NULL || g.PlatformIO.Platform_GetClipboardTextFn == Platform_GetClipboardTextFn_DefaultImpl))
|
||||||
|
g.PlatformIO.Platform_GetClipboardTextFn = [](ImGuiContext* ctx) { return ctx->IO.GetClipboardTextFn(ctx->IO.ClipboardUserData); };
|
||||||
|
if (g.IO.SetClipboardTextFn != NULL && (g.PlatformIO.Platform_SetClipboardTextFn == NULL || g.PlatformIO.Platform_SetClipboardTextFn == Platform_SetClipboardTextFn_DefaultImpl))
|
||||||
|
g.PlatformIO.Platform_SetClipboardTextFn = [](ImGuiContext* ctx, const char* text) { return ctx->IO.SetClipboardTextFn(ctx->IO.ClipboardUserData, text); };
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui::ErrorCheckEndFrameSanityChecks()
|
static void ImGui::ErrorCheckEndFrameSanityChecks()
|
||||||
@ -14347,9 +14356,9 @@ static void ImGui::UpdateViewportsNewFrame()
|
|||||||
|
|
||||||
// Win32 clipboard implementation
|
// Win32 clipboard implementation
|
||||||
// We use g.ClipboardHandlerData for temporary storage to ensure it is freed on Shutdown()
|
// We use g.ClipboardHandlerData for temporary storage to ensure it is freed on Shutdown()
|
||||||
static const char* GetClipboardTextFn_DefaultImpl(void* user_data_ctx)
|
static const char* Platform_GetClipboardTextFn_DefaultImpl(ImGuiContext* ctx)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *(ImGuiContext*)user_data_ctx;
|
ImGuiContext& g = *ctx;
|
||||||
g.ClipboardHandlerData.clear();
|
g.ClipboardHandlerData.clear();
|
||||||
if (!::OpenClipboard(NULL))
|
if (!::OpenClipboard(NULL))
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -14370,7 +14379,7 @@ static const char* GetClipboardTextFn_DefaultImpl(void* user_data_ctx)
|
|||||||
return g.ClipboardHandlerData.Data;
|
return g.ClipboardHandlerData.Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetClipboardTextFn_DefaultImpl(void*, const char* text)
|
static void Platform_SetClipboardTextFn_DefaultImpl(ImGuiContext*, const char* text)
|
||||||
{
|
{
|
||||||
if (!::OpenClipboard(NULL))
|
if (!::OpenClipboard(NULL))
|
||||||
return;
|
return;
|
||||||
@ -14397,7 +14406,7 @@ static PasteboardRef main_clipboard = 0;
|
|||||||
|
|
||||||
// OSX clipboard implementation
|
// OSX clipboard implementation
|
||||||
// If you enable this you will need to add '-framework ApplicationServices' to your linker command-line!
|
// If you enable this you will need to add '-framework ApplicationServices' to your linker command-line!
|
||||||
static void SetClipboardTextFn_DefaultImpl(void*, const char* text)
|
static void Platform_SetClipboardTextFn_DefaultImpl(ImGuiContext*, const char* text)
|
||||||
{
|
{
|
||||||
if (!main_clipboard)
|
if (!main_clipboard)
|
||||||
PasteboardCreate(kPasteboardClipboard, &main_clipboard);
|
PasteboardCreate(kPasteboardClipboard, &main_clipboard);
|
||||||
@ -14410,9 +14419,9 @@ static void SetClipboardTextFn_DefaultImpl(void*, const char* text)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* GetClipboardTextFn_DefaultImpl(void* user_data_ctx)
|
static const char* Platform_GetClipboardTextFn_DefaultImpl(ImGuiContext* ctx)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *(ImGuiContext*)user_data_ctx;
|
ImGuiContext& g = *ctx;
|
||||||
if (!main_clipboard)
|
if (!main_clipboard)
|
||||||
PasteboardCreate(kPasteboardClipboard, &main_clipboard);
|
PasteboardCreate(kPasteboardClipboard, &main_clipboard);
|
||||||
PasteboardSynchronize(main_clipboard);
|
PasteboardSynchronize(main_clipboard);
|
||||||
@ -14446,15 +14455,15 @@ static const char* GetClipboardTextFn_DefaultImpl(void* user_data_ctx)
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
// Local Dear ImGui-only clipboard implementation, if user hasn't defined better clipboard handlers.
|
// Local Dear ImGui-only clipboard implementation, if user hasn't defined better clipboard handlers.
|
||||||
static const char* GetClipboardTextFn_DefaultImpl(void* user_data_ctx)
|
static const char* Platform_GetClipboardTextFn_DefaultImpl(ImGuiContext* ctx)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *(ImGuiContext*)user_data_ctx;
|
ImGuiContext& g = *ctx;
|
||||||
return g.ClipboardHandlerData.empty() ? NULL : g.ClipboardHandlerData.begin();
|
return g.ClipboardHandlerData.empty() ? NULL : g.ClipboardHandlerData.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetClipboardTextFn_DefaultImpl(void* user_data_ctx, const char* text)
|
static void Platform_SetClipboardTextFn_DefaultImpl(ImGuiContext* ctx, const char* text)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *(ImGuiContext*)user_data_ctx;
|
ImGuiContext& g = *ctx;
|
||||||
g.ClipboardHandlerData.clear();
|
g.ClipboardHandlerData.clear();
|
||||||
const char* text_end = text + strlen(text);
|
const char* text_end = text + strlen(text);
|
||||||
g.ClipboardHandlerData.resize((int)(text_end - text) + 1);
|
g.ClipboardHandlerData.resize((int)(text_end - text) + 1);
|
||||||
|
20
imgui.h
20
imgui.h
@ -2289,12 +2289,6 @@ struct ImGuiIO
|
|||||||
void* BackendRendererUserData; // = NULL // User data for renderer backend
|
void* BackendRendererUserData; // = NULL // User data for renderer backend
|
||||||
void* BackendLanguageUserData; // = NULL // User data for non C++ programming language backend
|
void* BackendLanguageUserData; // = NULL // User data for non C++ programming language backend
|
||||||
|
|
||||||
// Optional: Access OS clipboard
|
|
||||||
// (default to use native Win32 clipboard on Windows, otherwise uses a private clipboard. Override to access OS clipboard on other architectures)
|
|
||||||
const char* (*GetClipboardTextFn)(void* user_data);
|
|
||||||
void (*SetClipboardTextFn)(void* user_data, const char* text);
|
|
||||||
void* ClipboardUserData;
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Input - Call before calling NewFrame()
|
// Input - Call before calling NewFrame()
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
@ -2396,6 +2390,14 @@ struct ImGuiIO
|
|||||||
//void* ImeWindowHandle; // [Obsoleted in 1.87] Set ImGuiViewport::PlatformHandleRaw instead. Set this to your HWND to get automatic IME cursor positioning.
|
//void* ImeWindowHandle; // [Obsoleted in 1.87] Set ImGuiViewport::PlatformHandleRaw instead. Set this to your HWND to get automatic IME cursor positioning.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Legacy: before 1.91.1, clipboard functions were stored in ImGuiIO instead of ImGuiPlatformIO.
|
||||||
|
// As this is will affect all users of custom engines/backends, we are providing proper legacy redirection (will obsolete).
|
||||||
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
|
const char* (*GetClipboardTextFn)(void* user_data);
|
||||||
|
void (*SetClipboardTextFn)(void* user_data, const char* text);
|
||||||
|
void* ClipboardUserData;
|
||||||
|
#endif
|
||||||
|
|
||||||
IMGUI_API ImGuiIO();
|
IMGUI_API ImGuiIO();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -3483,6 +3485,12 @@ struct ImGuiPlatformIO
|
|||||||
// Inputs - Interface with OS/backends
|
// Inputs - Interface with OS/backends
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Optional: Access OS clipboard
|
||||||
|
// (default to use native Win32 clipboard on Windows, otherwise uses a private clipboard. Override to access OS clipboard on other architectures)
|
||||||
|
const char* (*Platform_GetClipboardTextFn)(ImGuiContext* ctx);
|
||||||
|
void (*Platform_SetClipboardTextFn)(ImGuiContext* ctx, const char* text);
|
||||||
|
void* Platform_ClipboardUserData;
|
||||||
|
|
||||||
// Optional: Open link/folder/file in OS Shell
|
// Optional: Open link/folder/file in OS Shell
|
||||||
// (default to use ShellExecuteA() on Windows, system() on Linux/Mac)
|
// (default to use ShellExecuteA() on Windows, system() on Linux/Mac)
|
||||||
bool (*Platform_OpenInShellFn)(ImGuiContext* ctx, const char* path);
|
bool (*Platform_OpenInShellFn)(ImGuiContext* ctx, const char* path);
|
||||||
|
@ -4740,7 +4740,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
else if (is_cut || is_copy)
|
else if (is_cut || is_copy)
|
||||||
{
|
{
|
||||||
// Cut, Copy
|
// Cut, Copy
|
||||||
if (io.SetClipboardTextFn)
|
if (g.PlatformIO.Platform_SetClipboardTextFn != NULL)
|
||||||
{
|
{
|
||||||
const int ib = state->HasSelection() ? ImMin(state->Stb.select_start, state->Stb.select_end) : 0;
|
const int ib = state->HasSelection() ? ImMin(state->Stb.select_start, state->Stb.select_end) : 0;
|
||||||
const int ie = state->HasSelection() ? ImMax(state->Stb.select_start, state->Stb.select_end) : state->CurLenW;
|
const int ie = state->HasSelection() ? ImMax(state->Stb.select_start, state->Stb.select_end) : state->CurLenW;
|
||||||
|
Loading…
Reference in New Issue
Block a user