Skip to content

Commit

Permalink
Bump to 1.0.41;
Browse files Browse the repository at this point in the history
Fix bottom/right-aligned TableLayout's;
Optimize LocalizedString;
  • Loading branch information
onepiecefreak3 committed Nov 22, 2023
1 parent 3ccd362 commit 94cbd4b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
6 changes: 5 additions & 1 deletion ImGui.Forms/Controls/Layouts/TableLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion ImGui.Forms/ImGui.Forms.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<ItemGroup>
<PackageReference Include="ImGui.NET-newest" Version="1.82.0" />
<PackageReference Include="System.Drawing.Common" Version="5.0.3" />
<PackageReference Include="Veldrid.StartupUtilities" Version="4.9.0-beta2" />
<PackageReference Include="Veldrid.StartupUtilities" Version="4.9.0" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions ImGui.Forms/ImGui.Forms.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>Imgui.Forms</id>
<version>1.0.40</version>
<version>1.0.41</version>
<description>A WinForms-inspired object-oriented framework around Dear ImGui (https://github.com/ocornut/imgui)</description>

<authors>onepiecefreak</authors>
Expand All @@ -21,7 +21,7 @@
<group targetFramework="netstandard2.1">
<dependency id="ImGui.NET-newest" version="1.82.0" />
<dependency id="System.Drawing.Common" version="5.0.3" />
<dependency id="Veldrid.StartupUtilities" version="4.9.0-beta2" />
<dependency id="Veldrid.StartupUtilities" version="4.9.0" />
</group>
</dependencies>
</metadata>
Expand Down
15 changes: 13 additions & 2 deletions ImGui.Forms/Localization/LocalizedString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public struct LocalizedString

private readonly string _fixedText;

private string _locale;
private string _localizedText;

/// <summary>
/// Determines, if this localized string has localization information set.
/// </summary>
Expand All @@ -36,6 +39,9 @@ public LocalizedString(string id, params Func<object>[] args) : this(id, null, a

private LocalizedString(string id, string fixedText, Func<object>[] args)
{
_locale = null;
_localizedText = null;

_args = args;

if (fixedText != null)
Expand All @@ -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<Func<object>>());
Expand Down

0 comments on commit 94cbd4b

Please sign in to comment.