fix: account for global scale

This commit is contained in:
Anna 2022-01-15 13:55:43 -05:00
parent 31c0110085
commit e835ad088b
Signed by: anna
GPG Key ID: 0B391D8F06FCD9E0
3 changed files with 12 additions and 9 deletions

View File

@ -6,6 +6,7 @@ using ChatTwo.Util;
using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Interface;
using Dalamud.Logging;
using Dalamud.Utility;
using ImGuiNET;
@ -85,9 +86,11 @@ internal sealed class PayloadHandler {
}
internal void Hover(Payload payload) {
var hoverSize = 250f * ImGuiHelpers.GlobalScale;
switch (payload) {
case StatusPayload status: {
this.DoHover(() => this.HoverStatus(status), 250f);
this.DoHover(() => this.HoverStatus(status), hoverSize);
break;
}
case ItemPayload item: {
@ -105,7 +108,7 @@ internal sealed class PayloadHandler {
break;
}
this.DoHover(() => this.HoverItem(item), 250f);
this.DoHover(() => this.HoverItem(item), hoverSize);
break;
}
}
@ -131,9 +134,10 @@ internal sealed class PayloadHandler {
var lineHeight = ImGui.CalcTextSize("A").Y;
var cursor = ImGui.GetCursorPos();
ImGui.Image(icon.ImGuiHandle, new Vector2(icon.Width, icon.Height));
var size = new Vector2(icon.Width, icon.Height) * ImGuiHelpers.GlobalScale;
ImGui.Image(icon.ImGuiHandle, size);
ImGui.SameLine();
ImGui.SetCursorPos(cursor + new Vector2(icon.Width + 4, (float) icon.Height / 2 - lineHeight / 2));
ImGui.SetCursorPos(cursor + new Vector2(size.X + 4, size.Y / 2 - lineHeight / 2));
}
private void HoverStatus(StatusPayload status) {

View File

@ -351,7 +351,7 @@ internal sealed class ChatLog : IUiComponent {
ImGui.PushID($"tab-context-menu-{i}");
ImGui.SetNextItemWidth(250f);
ImGui.SetNextItemWidth(250f * ImGuiHelpers.GlobalScale);
if (ImGui.InputText("##tab-name", ref tab.Name, 128)) {
anyChanged = true;
}
@ -474,7 +474,7 @@ internal sealed class ChatLog : IUiComponent {
var texSize = new Vector2(this._fontIcon.Width, this._fontIcon.Height);
var sizeRatio = this.Ui.Plugin.Config.FontSize / bounds.Value.W;
var size = new Vector2(bounds.Value.Z, bounds.Value.W) * sizeRatio;
var size = new Vector2(bounds.Value.Z, bounds.Value.W) * sizeRatio * ImGuiHelpers.GlobalScale;
var uv0 = new Vector2(bounds.Value.X, bounds.Value.Y - 2) / texSize;
var uv1 = new Vector2(bounds.Value.X + bounds.Value.Z, bounds.Value.Y - 2 + bounds.Value.W) / texSize;

View File

@ -52,9 +52,8 @@ internal static class ImGuiUtil {
return;
}
const float scale = 1.0f;
var widthLeft = ImGui.GetContentRegionAvail().X;
var endPrevLine = ImGuiNative.ImFont_CalcWordWrapPositionA(ImGui.GetFont().NativePtr, scale, text, textEnd, widthLeft);
var endPrevLine = ImGuiNative.ImFont_CalcWordWrapPositionA(ImGui.GetFont().NativePtr, ImGuiHelpers.GlobalScale, text, textEnd, widthLeft);
if (endPrevLine == null) {
return;
}
@ -68,7 +67,7 @@ internal static class ImGuiUtil {
++text;
} // skip a space at start of line
endPrevLine = ImGuiNative.ImFont_CalcWordWrapPositionA(ImGui.GetFont().NativePtr, scale, text, textEnd, widthLeft);
endPrevLine = ImGuiNative.ImFont_CalcWordWrapPositionA(ImGui.GetFont().NativePtr, ImGuiHelpers.GlobalScale, text, textEnd, widthLeft);
if (endPrevLine == null) {
ImGui.TextUnformatted("");
ImGui.TextUnformatted("");