From 94cbd4b6b861d2774888caa44c13b5e63ee9f7ce Mon Sep 17 00:00:00 2001 From: onepiecefreak3 Date: Wed, 22 Nov 2023 23:57:32 +0100 Subject: [PATCH] Bump to 1.0.41; Fix bottom/right-aligned TableLayout's; Optimize LocalizedString; --- ImGui.Forms/Controls/Layouts/TableLayout.cs | 6 +++++- ImGui.Forms/ImGui.Forms.csproj | 2 +- ImGui.Forms/ImGui.Forms.nuspec | 4 ++-- ImGui.Forms/Localization/LocalizedString.cs | 15 +++++++++++++-- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/ImGui.Forms/Controls/Layouts/TableLayout.cs b/ImGui.Forms/Controls/Layouts/TableLayout.cs index d78b99d..b9272b9 100644 --- a/ImGui.Forms/Controls/Layouts/TableLayout.cs +++ b/ImGui.Forms/Controls/Layouts/TableLayout.cs @@ -88,9 +88,13 @@ protected override void UpdateInternal(Rectangle contentRect) if (ImGuiNET.ImGui.BeginChild($"{Id}", contentRect.Size, false, childFlags)) { + var (x, y) = GetInitPoint(localWidths, localHeights, contentRect); + ImGuiNET.ImGui.SetCursorPosX(x); + ImGuiNET.ImGui.SetCursorPosY(y); + if (ImGuiNET.ImGui.BeginChild($"{Id}-in", new Vector2(totalWidth, totalHeight), false, ImGuiWindowFlags.NoScrollbar)) { - var (x, y) = GetInitPoint(localWidths, localHeights, contentRect); + (x, y) = (0, 0); var origX = x; var localCells = Rows.Select(r => r.Cells).ToArray(); diff --git a/ImGui.Forms/ImGui.Forms.csproj b/ImGui.Forms/ImGui.Forms.csproj index 71f0243..f058ede 100644 --- a/ImGui.Forms/ImGui.Forms.csproj +++ b/ImGui.Forms/ImGui.Forms.csproj @@ -80,7 +80,7 @@ - + diff --git a/ImGui.Forms/ImGui.Forms.nuspec b/ImGui.Forms/ImGui.Forms.nuspec index d5ebd12..ec42841 100644 --- a/ImGui.Forms/ImGui.Forms.nuspec +++ b/ImGui.Forms/ImGui.Forms.nuspec @@ -2,7 +2,7 @@ Imgui.Forms - 1.0.40 + 1.0.41 A WinForms-inspired object-oriented framework around Dear ImGui (https://github.com/ocornut/imgui) onepiecefreak @@ -21,7 +21,7 @@ - + diff --git a/ImGui.Forms/Localization/LocalizedString.cs b/ImGui.Forms/Localization/LocalizedString.cs index 5d7f2b3..cf91c66 100644 --- a/ImGui.Forms/Localization/LocalizedString.cs +++ b/ImGui.Forms/Localization/LocalizedString.cs @@ -14,6 +14,9 @@ public struct LocalizedString private readonly string _fixedText; + private string _locale; + private string _localizedText; + /// /// Determines, if this localized string has localization information set. /// @@ -36,6 +39,9 @@ public LocalizedString(string id, params Func[] args) : this(id, null, a private LocalizedString(string id, string fixedText, Func[] args) { + _locale = null; + _localizedText = null; + _args = args; if (fixedText != null) @@ -59,8 +65,13 @@ public override string ToString() if (app?.Localizer == null || _id == null || _args == null) return string.Empty; - var args = _args.Select(x => x?.Invoke() ?? string.Empty).ToArray(); - return app.Localizer.Localize(_id, args); + if (app.Localizer.CurrentLocale == _locale) + return _localizedText; + + _locale = app.Localizer.CurrentLocale; + + object[] args = _args.Select(x => x?.Invoke() ?? string.Empty).ToArray(); + return _localizedText = app.Localizer.Localize(_id, args); } public static implicit operator LocalizedString(string s) => new LocalizedString(null, s ?? string.Empty, Array.Empty>());