Fix UI scaling issues

This commit is contained in:
Liza 2024-03-27 19:21:41 +01:00
parent ec5e3968ca
commit 6c040389ac
Signed by: liza
GPG Key ID: 7199F8D727D55F67
2 changed files with 21 additions and 14 deletions

View File

@ -93,9 +93,9 @@ internal sealed class MainWindow : LWindow
IDalamudTextureWrap? icon = _iconCache.GetIcon(currentCraft.IconId); IDalamudTextureWrap? icon = _iconCache.GetIcon(currentCraft.IconId);
if (icon != null) if (icon != null)
{ {
ImGui.Image(icon.ImGuiHandle, new Vector2(23, 23)); ImGui.Image(icon.ImGuiHandle, new Vector2(ImGui.GetFrameHeight()));
ImGui.SameLine(0, 3); ImGui.SameLine(0, ImGui.GetStyle().ItemInnerSpacing.X);
ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 3); ImGui.SetCursorPosY(ImGui.GetCursorPosY() + (ImGui.GetFrameHeight() - ImGui.GetTextLineHeight()) / 2);
} }
ImGui.TextUnformatted($"{currentCraft.Name}"); ImGui.TextUnformatted($"{currentCraft.Name}");
@ -195,11 +195,11 @@ internal sealed class MainWindow : LWindow
IDalamudTextureWrap? icon = _iconCache.GetIcon(craft.IconId); IDalamudTextureWrap? icon = _iconCache.GetIcon(craft.IconId);
if (icon != null) if (icon != null)
{ {
ImGui.Image(icon.ImGuiHandle, new Vector2(23, 23)); ImGui.Image(icon.ImGuiHandle, new Vector2(ImGui.GetFrameHeight()));
ImGui.SameLine(0, 3); ImGui.SameLine(0, ImGui.GetStyle().ItemInnerSpacing.X);
} }
ImGui.SetNextItemWidth(100); ImGui.SetNextItemWidth(Math.Max(100 * ImGui.GetIO().FontGlobalScale, 4 * (ImGui.GetFrameHeight() + ImGui.GetStyle().FramePadding.X)));
int quantity = item.Quantity; int quantity = item.Quantity;
if (ImGui.InputInt(craft.Name, ref quantity)) if (ImGui.InputInt(craft.Name, ref quantity))
{ {
@ -236,14 +236,14 @@ internal sealed class MainWindow : LWindow
.OrderBy(x => x.WorkshopItemId)) .OrderBy(x => x.WorkshopItemId))
{ {
IDalamudTextureWrap? icon = _iconCache.GetIcon(craft.IconId); IDalamudTextureWrap? icon = _iconCache.GetIcon(craft.IconId);
Vector2 pos = ImGui.GetCursorPos();
Vector2 iconSize = new Vector2(ImGui.GetTextLineHeight() + ImGui.GetStyle().ItemSpacing.Y);
if (icon != null) if (icon != null)
{ {
ImGui.Image(icon.ImGuiHandle, new Vector2(23, 23)); ImGui.SetCursorPos(pos + new Vector2(iconSize.X + ImGui.GetStyle().FramePadding.X, ImGui.GetStyle().ItemSpacing.Y / 2));
ImGui.SameLine();
ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 3);
} }
if (ImGui.Selectable($"{craft.Name}##SelectCraft{craft.WorkshopItemId}")) if (ImGui.Selectable($"{craft.Name}##SelectCraft{craft.WorkshopItemId}", false, ImGuiSelectableFlags.SpanAllColumns))
{ {
_configuration.ItemQueue.Add(new Configuration.QueuedItem _configuration.ItemQueue.Add(new Configuration.QueuedItem
{ {
@ -252,6 +252,13 @@ internal sealed class MainWindow : LWindow
}); });
Save(); Save();
} }
if (icon != null)
{
ImGui.SameLine(0, 0);
ImGui.SetCursorPos(pos);
ImGui.Image(icon.ImGuiHandle, iconSize);
}
} }
ImGui.EndCombo(); ImGui.EndCombo();
@ -535,9 +542,9 @@ internal sealed class MainWindow : LWindow
IDalamudTextureWrap? icon = _iconCache.GetIcon(item.IconId); IDalamudTextureWrap? icon = _iconCache.GetIcon(item.IconId);
if (icon != null) if (icon != null)
{ {
ImGui.Image(icon.ImGuiHandle, new Vector2(23, 23)); ImGui.Image(icon.ImGuiHandle, new Vector2(ImGui.GetFrameHeight()));
ImGui.SameLine(0, 3); ImGui.SameLine(0, ImGui.GetStyle().ItemInnerSpacing.X);
ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 3); ImGui.SetCursorPosY(ImGui.GetCursorPosY() + (ImGui.GetFrameHeight() - ImGui.GetTextLineHeight()) / 2);
} }
ImGui.TextColored(inInventory >= item.TotalQuantity ? ImGuiColors.HealerGreen : ImGuiColors.DalamudRed, ImGui.TextColored(inInventory >= item.TotalQuantity ? ImGuiColors.HealerGreen : ImGuiColors.DalamudRed,

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework> <TargetFramework>net8.0-windows</TargetFramework>
<Version>5.1</Version> <Version>5.2</Version>
<LangVersion>11.0</LangVersion> <LangVersion>11.0</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>