fix icons and text of buttons being static in place

This commit is contained in:
rootdarkarchon
2023-10-17 22:33:38 +02:00
parent fdc0d4bf6f
commit 5a62012d2a

View File

@@ -360,6 +360,8 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
var cursor = ImGui.GetCursorPos(); var cursor = ImGui.GetCursorPos();
var drawList = ImGui.GetWindowDrawList(); var drawList = ImGui.GetWindowDrawList();
var pos = ImGui.GetWindowPos(); var pos = ImGui.GetWindowPos();
var scrollPosY = ImGui.GetScrollY();
var scrollPosX = ImGui.GetScrollX();
Vector2 buttonSize; Vector2 buttonSize;
var buttonSizeY = textSize.Y + padding.Y * 2; var buttonSizeY = textSize.Y + padding.Y * 2;
@@ -370,7 +372,7 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
if (width == null || width <= 0) if (width == null || width <= 0)
{ {
var buttonSizeX = (iconScaling == 1 ? iconSize.Y : (iconSize.X * iconScaling)) var buttonSizeX = (iconScaling == 1 ? iconSize.Y : (iconSize.X * iconScaling))
+ textSize.X + padding.X * 2 + spacing.X + (iconXoffset * 2); + textSize.X + padding.X * 2 + spacing.X + (iconXoffset * 2);
buttonSize = new Vector2(buttonSizeX + iconExtraSpacing, buttonSizeY); buttonSize = new Vector2(buttonSizeX + iconExtraSpacing, buttonSizeY);
} }
@@ -388,13 +390,13 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
} }
drawList.AddText(UiBuilder.IconFont, ImGui.GetFontSize() * iconScaling, drawList.AddText(UiBuilder.IconFont, ImGui.GetFontSize() * iconScaling,
new(pos.X + cursor.X + iconXoffset + padding.X, new(pos.X - scrollPosX + cursor.X + iconXoffset + padding.X,
pos.Y + cursor.Y + (buttonSizeY - (iconSize.Y * iconScaling)) / 2f), pos.Y - scrollPosY + cursor.Y + (buttonSizeY - (iconSize.Y * iconScaling)) / 2f),
ImGui.GetColorU32(ImGuiCol.Text), icon.ToIconString()); ImGui.GetColorU32(ImGuiCol.Text), icon.ToIconString());
drawList.AddText(UiBuilder.DefaultFont, ImGui.GetFontSize(), drawList.AddText(UiBuilder.DefaultFont, ImGui.GetFontSize(),
new(pos.X + cursor.X + (padding.X) + spacing.X + (iconSize.X * iconScaling) + (iconXoffset * 2) + iconExtraSpacing, new(pos.X - scrollPosX + cursor.X + (padding.X) + spacing.X + (iconSize.X * iconScaling) + (iconXoffset * 2) + iconExtraSpacing,
pos.Y + cursor.Y + ((buttonSizeY - textSize.Y) / 2f)), pos.Y - scrollPosY + cursor.Y + ((buttonSizeY - textSize.Y) / 2f)),
ImGui.GetColorU32(ImGuiCol.Text), text); ImGui.GetColorU32(ImGuiCol.Text), text);
return wasClicked; return wasClicked;