mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 12:08:47 +02:00
Internals: added basic localization system (#5895)
This commit is contained in:
@ -26,6 +26,7 @@ Index of this file:
|
||||
// [SECTION] Docking support
|
||||
// [SECTION] Viewport support
|
||||
// [SECTION] Settings support
|
||||
// [SECTION] Localization support
|
||||
// [SECTION] Metrics, Debug tools
|
||||
// [SECTION] Generic context hooks
|
||||
// [SECTION] ImGuiContext (main imgui context)
|
||||
@ -121,6 +122,7 @@ struct ImGuiDataTypeInfo; // Type information associated to a ImGuiDat
|
||||
struct ImGuiGroupData; // Stacked storage data for BeginGroup()/EndGroup()
|
||||
struct ImGuiInputTextState; // Internal state of the currently focused/edited text input box
|
||||
struct ImGuiLastItemData; // Status storage for last submitted items
|
||||
struct ImGuiLocEntry; // A localization entry.
|
||||
struct ImGuiMenuColumns; // Simple column measurement, currently used for MenuItem() only
|
||||
struct ImGuiNavItemData; // Result of a gamepad/keyboard directional navigation move query result
|
||||
struct ImGuiMetricsConfig; // Storage for ShowMetricsWindow() and DebugNodeXXX() functions
|
||||
@ -144,8 +146,12 @@ struct ImGuiWindow; // Storage for one window
|
||||
struct ImGuiWindowTempData; // Temporary storage for one window (that's the data which in theory we could ditch at the end of the frame, in practice we currently keep it for each window)
|
||||
struct ImGuiWindowSettings; // Storage for a window .ini settings (we keep one of those even if the actual window wasn't instanced during this session)
|
||||
|
||||
// Enumerations
|
||||
// Use your programming IDE "Go to definition" facility on the names of the center columns to find the actual flags/enum lists.
|
||||
enum ImGuiLocKey : int; // -> enum ImGuiLocKey // Enum: a localization entry for translation.
|
||||
typedef int ImGuiLayoutType; // -> enum ImGuiLayoutType_ // Enum: Horizontal or vertical
|
||||
|
||||
// Flags
|
||||
typedef int ImGuiActivateFlags; // -> enum ImGuiActivateFlags_ // Flags: for navigation/focus function (will be for ActivateItem() later)
|
||||
typedef int ImGuiDebugLogFlags; // -> enum ImGuiDebugLogFlags_ // Flags: for ShowDebugLogWindow(), g.DebugLogFlags
|
||||
typedef int ImGuiInputFlags; // -> enum ImGuiInputFlags_ // Flags: for IsKeyPressed(), IsMouseClicked(), SetKeyOwner(), SetItemKeyOwner() etc.
|
||||
@ -1608,6 +1614,30 @@ struct ImGuiSettingsHandler
|
||||
ImGuiSettingsHandler() { memset(this, 0, sizeof(*this)); }
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Localization support
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// This is experimental and not officially supported, it'll probably fall short of features, if/when it does we may backtrack.
|
||||
enum ImGuiLocKey : int
|
||||
{
|
||||
ImGuiLocKey_TableSizeOne,
|
||||
ImGuiLocKey_TableSizeAllFit,
|
||||
ImGuiLocKey_TableSizeAllDefault,
|
||||
ImGuiLocKey_TableResetOrder,
|
||||
ImGuiLocKey_WindowingMainMenuBar,
|
||||
ImGuiLocKey_WindowingPopup,
|
||||
ImGuiLocKey_WindowingUntitled,
|
||||
ImGuiLocKey_COUNT
|
||||
};
|
||||
|
||||
struct ImGuiLocEntry
|
||||
{
|
||||
ImGuiLocKey Key;
|
||||
const char* Text;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Metrics, Debug Tools
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -1938,6 +1968,9 @@ struct ImGuiContext
|
||||
ImVector<ImGuiContextHook> Hooks; // Hooks for extensions (e.g. test engine)
|
||||
ImGuiID HookIdNext; // Next available HookId
|
||||
|
||||
// Localization
|
||||
const char* LocalizationTable[ImGuiLocKey_COUNT];
|
||||
|
||||
// Capture/Logging
|
||||
bool LogEnabled; // Currently capturing
|
||||
ImGuiLogType LogType; // Capture target
|
||||
@ -2109,6 +2142,8 @@ struct ImGuiContext
|
||||
SettingsDirtyTimer = 0.0f;
|
||||
HookIdNext = 0;
|
||||
|
||||
memset(LocalizationTable, 0, sizeof(LocalizationTable));
|
||||
|
||||
LogEnabled = false;
|
||||
LogType = ImGuiLogType_None;
|
||||
LogNextPrefix = LogNextSuffix = NULL;
|
||||
@ -2725,6 +2760,10 @@ namespace ImGui
|
||||
IMGUI_API void RemoveSettingsHandler(const char* type_name);
|
||||
IMGUI_API ImGuiSettingsHandler* FindSettingsHandler(const char* type_name);
|
||||
|
||||
// Localization
|
||||
IMGUI_API void LocalizeRegisterEntries(const ImGuiLocEntry* entries, int count);
|
||||
inline const char* LocalizeGetMsg(ImGuiLocKey key) { ImGuiContext& g = *GImGui; const char* msg = g.LocalizationTable[key]; return msg ? msg : "*Missing Text*"; }
|
||||
|
||||
// Scrolling
|
||||
IMGUI_API void SetScrollX(ImGuiWindow* window, float scroll_x);
|
||||
IMGUI_API void SetScrollY(ImGuiWindow* window, float scroll_y);
|
||||
|
Reference in New Issue
Block a user