浏览代码

IO: (BREAKING) moved io.PlatformLocaleDecimalPoint to platform_io.Platform_LocaleDecimalPoint. (#7389, #6719, #2278)

ocornut 1 年之前
父节点
当前提交
e54f240ea0
共有 4 个文件被更改,包括 13 次插入10 次删除
  1. 3 2
      docs/CHANGELOG.txt
  2. 4 3
      imgui.cpp
  3. 4 3
      imgui.h
  4. 2 2
      imgui_widgets.cpp

+ 3 - 2
docs/CHANGELOG.txt

@@ -42,8 +42,9 @@ HOW TO UPDATE?
 Breaking changes:
 Breaking changes:
 
 
 - IO: moved some functions from ImGuiIO to ImGuiPlatformIO:
 - IO: moved some functions from ImGuiIO to ImGuiPlatformIO:
-    - io.PlatformOpenInShellFn    -> platform_io.Platform_OpenInShellFn. (#7660)
-    - io.PlatformSetImeDataFn     -> platform_io.Platform_SetImeDataFn.
+    - io.PlatformOpenInShellFn      -> platform_io.Platform_OpenInShellFn. (#7660)
+    - io.PlatformSetImeDataFn       -> platform_io.Platform_SetImeDataFn.
+    - io.PlatformLocaleDecimalPoint -> platform_io.Platform_LocaleDecimalPoint. (#7389, #6719, #2278)
     - 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

+ 4 - 3
imgui.cpp

@@ -431,8 +431,9 @@ 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.PlatformOpenInShellFn    -> platform_io.Platform_OpenInShellFn (#7660)
-                            - io.PlatformSetImeDataFn     -> platform_io.Platform_SetImeDataFn
+                            - io.PlatformOpenInShellFn      -> platform_io.Platform_OpenInShellFn (#7660)
+                            - io.PlatformSetImeDataFn       -> platform_io.Platform_SetImeDataFn
+                            - io.PlatformLocaleDecimalPoint -> platform_io.Platform_LocaleDecimalPoint (#7389, #6719, #2278)
                             - access those via GetPlatformIO() instead of GetIO().
                             - access those via GetPlatformIO() instead of GetIO().
                          some were introduced very recently and often automatically setup by core library and backends, so for those we are exceptionally not maintaining a legacy redirection symbol.
                          some were introduced very recently and often automatically setup by core library and backends, so for those we are exceptionally not maintaining a legacy redirection symbol.
  - 2024/07/25 (1.91.0) - obsoleted GetContentRegionMax(), GetWindowContentRegionMin() and GetWindowContentRegionMax(). (see #7838 on GitHub for more info)
  - 2024/07/25 (1.91.0) - obsoleted GetContentRegionMax(), GetWindowContentRegionMin() and GetWindowContentRegionMax(). (see #7838 on GitHub for more info)
@@ -1398,7 +1399,6 @@ ImGuiIO::ImGuiIO()
     // Note: Initialize() will setup default clipboard/ime handlers.
     // Note: Initialize() will setup default clipboard/ime handlers.
     BackendPlatformName = BackendRendererName = NULL;
     BackendPlatformName = BackendRendererName = NULL;
     BackendPlatformUserData = BackendRendererUserData = BackendLanguageUserData = NULL;
     BackendPlatformUserData = BackendRendererUserData = BackendLanguageUserData = NULL;
-    PlatformLocaleDecimalPoint = '.';
 
 
     // Input (NB: we already have memset zero the entire structure!)
     // Input (NB: we already have memset zero the entire structure!)
     MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
     MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
@@ -1770,6 +1770,7 @@ ImGuiPlatformIO::ImGuiPlatformIO()
 {
 {
     // Most fields are initialized with zero
     // Most fields are initialized with zero
     memset(this, 0, sizeof(*this));
     memset(this, 0, sizeof(*this));
+    Platform_LocaleDecimalPoint = '.';
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------

+ 4 - 3
imgui.h

@@ -2295,9 +2295,6 @@ struct ImGuiIO
     void        (*SetClipboardTextFn)(void* user_data, const char* text);
     void        (*SetClipboardTextFn)(void* user_data, const char* text);
     void*       ClipboardUserData;
     void*       ClipboardUserData;
 
 
-    // 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
-
     //------------------------------------------------------------------
     //------------------------------------------------------------------
     // Input - Call before calling NewFrame()
     // Input - Call before calling NewFrame()
     //------------------------------------------------------------------
     //------------------------------------------------------------------
@@ -3496,6 +3493,10 @@ struct ImGuiPlatformIO
     void        (*Platform_SetImeDataFn)(ImGuiContext* ctx, ImGuiViewport* viewport, ImGuiPlatformImeData* data);
     void        (*Platform_SetImeDataFn)(ImGuiContext* ctx, ImGuiViewport* viewport, ImGuiPlatformImeData* data);
     void*       Platform_ImeUserData;
     void*       Platform_ImeUserData;
     //void      (*SetPlatformImeDataFn)(ImGuiViewport* viewport, ImGuiPlatformImeData* data); // [Renamed to platform_io.PlatformSetImeDataFn in 1.91.1]
     //void      (*SetPlatformImeDataFn)(ImGuiViewport* viewport, ImGuiPlatformImeData* data); // [Renamed to platform_io.PlatformSetImeDataFn in 1.91.1]
+
+    // Optional: Platform locale
+    // [Experimental] Configure decimal point e.g. '.' or ',' useful for some languages (e.g. German), generally pulled from *localeconv()->decimal_point
+    ImWchar     Platform_LocaleDecimalPoint;     // '.'
 };
 };
 
 
 // (Optional) Support for IME (Input Method Editor) via the platform_io.Platform_SetImeDataFn() function.
 // (Optional) Support for IME (Input Method Editor) via the platform_io.Platform_SetImeDataFn() function.

+ 2 - 2
imgui_widgets.cpp

@@ -4132,10 +4132,10 @@ static bool InputTextFilterCharacter(ImGuiContext* ctx, unsigned int* p_char, Im
         // The standard mandate that programs starts in the "C" locale where the decimal point is '.'.
         // The standard mandate that programs starts in the "C" locale where the decimal point is '.'.
         // We don't really intend to provide widespread support for it, but out of empathy for people stuck with using odd API, we support the bare minimum aka overriding the decimal point.
         // We don't really intend to provide widespread support for it, but out of empathy for people stuck with using odd API, we support the bare minimum aka overriding the decimal point.
         // Change the default decimal_point with:
         // Change the default decimal_point with:
-        //   ImGui::GetIO()->PlatformLocaleDecimalPoint = *localeconv()->decimal_point;
+        //   ImGui::GetPlatformIO()->Platform_LocaleDecimalPoint = *localeconv()->decimal_point;
         // Users of non-default decimal point (in particular ',') may be affected by word-selection logic (is_word_boundary_from_right/is_word_boundary_from_left) functions.
         // Users of non-default decimal point (in particular ',') may be affected by word-selection logic (is_word_boundary_from_right/is_word_boundary_from_left) functions.
         ImGuiContext& g = *ctx;
         ImGuiContext& g = *ctx;
-        const unsigned c_decimal_point = (unsigned int)g.IO.PlatformLocaleDecimalPoint;
+        const unsigned c_decimal_point = (unsigned int)g.PlatformIO.Platform_LocaleDecimalPoint;
         if (flags & (ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_CharsScientific | (ImGuiInputTextFlags)ImGuiInputTextFlags_LocalizeDecimalPoint))
         if (flags & (ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_CharsScientific | (ImGuiInputTextFlags)ImGuiInputTextFlags_LocalizeDecimalPoint))
             if (c == '.' || c == ',')
             if (c == '.' || c == ',')
                 c = c_decimal_point;
                 c = c_decimal_point;