Trunculate the broadcaster name in the grid view as it was overlapping into the Shell name
This commit is contained in:
@@ -350,9 +350,9 @@ public class SyncshellFinderUI : WindowMediatorSubscriberBase
|
|||||||
? shell.Group.Alias
|
? shell.Group.Alias
|
||||||
: shell.Group.GID;
|
: shell.Group.GID;
|
||||||
|
|
||||||
|
var style = ImGui.GetStyle();
|
||||||
float startX = ImGui.GetCursorPosX();
|
float startX = ImGui.GetCursorPosX();
|
||||||
float availWidth = ImGui.GetContentRegionAvail().X;
|
float availW = ImGui.GetContentRegionAvail().X;
|
||||||
float rightTextW = ImGui.CalcTextSize(broadcasterName).X;
|
|
||||||
|
|
||||||
ImGui.BeginGroup();
|
ImGui.BeginGroup();
|
||||||
|
|
||||||
@@ -364,13 +364,45 @@ public class SyncshellFinderUI : WindowMediatorSubscriberBase
|
|||||||
Mediator.Publish(new GroupProfileOpenStandaloneMessage(shell.Group));
|
Mediator.Publish(new GroupProfileOpenStandaloneMessage(shell.Group));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float nameRightX = ImGui.GetItemRectMax().X;
|
||||||
|
|
||||||
|
var regionMinScreen = ImGui.GetCursorScreenPos();
|
||||||
|
float regionRightX = regionMinScreen.X + availW;
|
||||||
|
|
||||||
|
float minBroadcasterX = nameRightX + style.ItemSpacing.X;
|
||||||
|
|
||||||
|
float maxBroadcasterWidth = regionRightX - minBroadcasterX;
|
||||||
|
|
||||||
|
string broadcasterToShow = broadcasterName;
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(broadcasterName) && maxBroadcasterWidth > 0f)
|
||||||
|
{
|
||||||
|
float bcFullWidth = ImGui.CalcTextSize(broadcasterName).X;
|
||||||
|
string toolTip;
|
||||||
|
|
||||||
|
if (bcFullWidth > maxBroadcasterWidth)
|
||||||
|
{
|
||||||
|
broadcasterToShow = TruncateTextToWidth(broadcasterName, maxBroadcasterWidth);
|
||||||
|
toolTip = broadcasterName + Environment.NewLine + Environment.NewLine + "Broadcaster of the syncshell.";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
toolTip = "Broadcaster of the syncshell.";
|
||||||
|
}
|
||||||
|
|
||||||
|
float bcWidth = ImGui.CalcTextSize(broadcasterToShow).X;
|
||||||
|
|
||||||
|
float broadX = regionRightX - bcWidth;
|
||||||
|
|
||||||
|
broadX = MathF.Max(broadX, minBroadcasterX);
|
||||||
|
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
float rightX = startX + availWidth - rightTextW;
|
var curPos = ImGui.GetCursorPos();
|
||||||
var pos = ImGui.GetCursorPos();
|
ImGui.SetCursorPos(new Vector2(broadX - regionMinScreen.X + startX, curPos.Y + 3f * ImGuiHelpers.GlobalScale));
|
||||||
ImGui.SetCursorPos(new Vector2(rightX, pos.Y + 3f * ImGuiHelpers.GlobalScale));
|
ImGui.TextUnformatted(broadcasterToShow);
|
||||||
ImGui.TextUnformatted(broadcasterName);
|
|
||||||
if (ImGui.IsItemHovered())
|
if (ImGui.IsItemHovered())
|
||||||
ImGui.SetTooltip("Broadcaster of the syncshell.");
|
ImGui.SetTooltip(toolTip);
|
||||||
|
}
|
||||||
|
|
||||||
ImGui.EndGroup();
|
ImGui.EndGroup();
|
||||||
|
|
||||||
@@ -590,6 +622,40 @@ public class SyncshellFinderUI : WindowMediatorSubscriberBase
|
|||||||
float widthUsed = cursorLocalX - baseLocal.X;
|
float widthUsed = cursorLocalX - baseLocal.X;
|
||||||
return (widthUsed, rowHeight);
|
return (widthUsed, rowHeight);
|
||||||
}
|
}
|
||||||
|
private static string TruncateTextToWidth(string text, float maxWidth)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(text))
|
||||||
|
return text;
|
||||||
|
|
||||||
|
const string ellipsis = "...";
|
||||||
|
float ellipsisWidth = ImGui.CalcTextSize(ellipsis).X;
|
||||||
|
|
||||||
|
if (maxWidth <= ellipsisWidth)
|
||||||
|
return ellipsis;
|
||||||
|
|
||||||
|
int low = 0;
|
||||||
|
int high = text.Length;
|
||||||
|
string best = ellipsis;
|
||||||
|
|
||||||
|
while (low <= high)
|
||||||
|
{
|
||||||
|
int mid = (low + high) / 2;
|
||||||
|
string candidate = string.Concat(text.AsSpan(0, mid), ellipsis);
|
||||||
|
float width = ImGui.CalcTextSize(candidate).X;
|
||||||
|
|
||||||
|
if (width <= maxWidth)
|
||||||
|
{
|
||||||
|
best = candidate;
|
||||||
|
low = mid + 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
high = mid - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return best;
|
||||||
|
}
|
||||||
|
|
||||||
private IDalamudTextureWrap? GetIconWrap(uint iconId)
|
private IDalamudTextureWrap? GetIconWrap(uint iconId)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user