mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Fix notification positioning when multi-monitor is enabled
This commit is contained in:
parent
df8de39098
commit
a12c63d6a2
2 changed files with 19 additions and 5 deletions
|
|
@ -38,6 +38,7 @@ internal sealed partial class ActiveNotification
|
|||
|
||||
var viewport = ImGuiHelpers.MainViewport;
|
||||
var viewportSize = viewport.WorkSize;
|
||||
var viewportPos = viewport.Pos;
|
||||
|
||||
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, opacity);
|
||||
ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 0f);
|
||||
|
|
@ -122,7 +123,7 @@ internal sealed partial class ActiveNotification
|
|||
|
||||
ImGuiHelpers.ForceNextWindowMainViewport();
|
||||
ImGui.SetNextWindowPos(
|
||||
topLeft,
|
||||
topLeft + viewportPos,
|
||||
ImGuiCond.Always,
|
||||
pivot);
|
||||
ImGui.SetNextWindowSizeConstraints(
|
||||
|
|
|
|||
|
|
@ -42,9 +42,13 @@ internal class NotificationPositionChooser
|
|||
using var style2 = ImRaii.PushStyle(ImGuiStyleVar.WindowBorderSize, 0f);
|
||||
using var color = ImRaii.PushColor(ImGuiCol.WindowBg, new Vector4(0, 0, 0, 0));
|
||||
|
||||
var viewport = ImGuiHelpers.MainViewport;
|
||||
var viewportSize = viewport.Size;
|
||||
var viewportPos = viewport.Pos;
|
||||
|
||||
ImGui.SetNextWindowFocus();
|
||||
ImGui.SetNextWindowPos(ImGuiHelpers.MainViewport.Pos);
|
||||
ImGui.SetNextWindowSize(ImGuiHelpers.MainViewport.Size);
|
||||
ImGui.SetNextWindowPos(viewportPos);
|
||||
ImGui.SetNextWindowSize(viewportSize);
|
||||
ImGuiHelpers.ForceNextWindowMainViewport();
|
||||
|
||||
ImGui.SetNextWindowBgAlpha(0.6f);
|
||||
|
|
@ -54,7 +58,8 @@ internal class NotificationPositionChooser
|
|||
ImGuiWindowFlags.NoDocking | ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoMove |
|
||||
ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoFocusOnAppearing | ImGuiWindowFlags.NoNav);
|
||||
|
||||
var mousePosUnit = ImGui.GetMousePos() / ImGuiHelpers.MainViewport.Size;
|
||||
var adjustedMousePos = ImGui.GetMousePos() - viewportPos;
|
||||
var mousePosUnit = adjustedMousePos / viewportSize;
|
||||
|
||||
// Store the offset as a Vector2
|
||||
this.currentAnchorPosition = mousePosUnit;
|
||||
|
|
@ -87,6 +92,7 @@ internal class NotificationPositionChooser
|
|||
var instructionPos = new Vector2(
|
||||
ImGuiHelpers.MainViewport.Size.X / 2 - instructionSize.X / 2,
|
||||
ImGuiHelpers.MainViewport.Size.Y / 2 - instructionSize.Y / 2 + i * instructionSize.Y);
|
||||
instructionPos += viewportPos;
|
||||
dl.AddText(instructionPos, 0xFFFFFFFF, instruction);
|
||||
}
|
||||
|
||||
|
|
@ -102,7 +108,9 @@ internal class NotificationPositionChooser
|
|||
var edgeMargin = NotificationConstants.ScaledViewportEdgeMargin;
|
||||
var spacing = 10f * ImGuiHelpers.GlobalScale;
|
||||
|
||||
var viewportSize = ImGuiHelpers.MainViewport.Size;
|
||||
var viewport = ImGuiHelpers.MainViewport;
|
||||
var viewportSize = viewport.Size;
|
||||
var viewportPos = viewport.Pos;
|
||||
var borderColor = ImGui.ColorConvertFloat4ToU32(new(1f, 1f, 1f, borderAlpha));
|
||||
var borderThickness = 4.0f * ImGuiHelpers.GlobalScale;
|
||||
var borderRounding = 4.0f * ImGuiHelpers.GlobalScale;
|
||||
|
|
@ -202,6 +210,11 @@ internal class NotificationPositionChooser
|
|||
}
|
||||
}
|
||||
|
||||
topLeft += viewportPos;
|
||||
bottomRight += viewportPos;
|
||||
smallTopLeft += viewportPos;
|
||||
smallBottomRight += viewportPos;
|
||||
|
||||
// Draw the big box
|
||||
dl.AddRectFilled(topLeft, bottomRight, ImGui.ColorConvertFloat4ToU32(backgroundColor), borderRounding, ImDrawFlags.RoundCornersAll);
|
||||
dl.AddRect(topLeft, bottomRight, borderColor, borderRounding, ImDrawFlags.RoundCornersAll, borderThickness);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue