fix text alignment
This commit is contained in:
		| @@ -30,14 +30,12 @@ public abstract class DrawFolderBase : IDrawFolder | ||||
|         if (!RenderIfEmpty && !_drawPairs.Any()) return; | ||||
|  | ||||
|         using var id = ImRaii.PushId("folder_" + _id); | ||||
|         var originalY = ImGui.GetCursorPosY(); | ||||
|         var pauseIconSize = UiSharedService.GetIconButtonSize(FontAwesomeIcon.Bars); | ||||
|         var textSize = ImGui.CalcTextSize(_id); | ||||
|         var textPosY = originalY + pauseIconSize.Y / 2 - textSize.Y / 2; | ||||
|  | ||||
|         // draw opener | ||||
|         var icon = _tagHandler.IsTagOpen(_id) ? FontAwesomeIcon.CaretDown : FontAwesomeIcon.CaretRight; | ||||
|         ImGui.SetCursorPosY(textPosY); | ||||
|  | ||||
|         ImGui.AlignTextToFramePadding(); | ||||
|  | ||||
|         UiSharedService.FontText(icon.ToIconString(), UiBuilder.IconFont); | ||||
|         if (ImGui.IsItemClicked()) | ||||
|         { | ||||
| @@ -45,14 +43,14 @@ public abstract class DrawFolderBase : IDrawFolder | ||||
|         } | ||||
|  | ||||
|         ImGui.SameLine(); | ||||
|         var leftSideEnd = DrawIcon(textPosY, originalY); | ||||
|         var leftSideEnd = DrawIcon(); | ||||
|  | ||||
|         ImGui.SameLine(); | ||||
|         var rightSideStart = DrawRightSide(originalY); | ||||
|         var rightSideStart = DrawRightSideInternal(); | ||||
|  | ||||
|         // draw name | ||||
|         ImGui.SameLine(leftSideEnd); | ||||
|         DrawName(textPosY, rightSideStart - leftSideEnd); | ||||
|         DrawName(rightSideStart - leftSideEnd); | ||||
|         ImGui.Separator(); | ||||
|  | ||||
|         // if opened draw content | ||||
| @@ -75,15 +73,15 @@ public abstract class DrawFolderBase : IDrawFolder | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     protected abstract float DrawIcon(float textPosY, float originalY); | ||||
|     protected abstract float DrawIcon(); | ||||
|  | ||||
|     protected abstract void DrawMenu(float menuWidth); | ||||
|  | ||||
|     protected abstract void DrawName(float originalY, float width); | ||||
|     protected abstract void DrawName(float width); | ||||
|  | ||||
|     protected abstract float DrawRightSide(float originalY, float currentRightSideX); | ||||
|     protected abstract float DrawRightSide(float currentRightSideX); | ||||
|  | ||||
|     private float DrawRightSide(float originalY) | ||||
|     private float DrawRightSideInternal() | ||||
|     { | ||||
|         var barButtonSize = UiSharedService.GetIconButtonSize(FontAwesomeIcon.Bars); | ||||
|         var spacingX = ImGui.GetStyle().ItemSpacing.X; | ||||
| @@ -114,6 +112,6 @@ public abstract class DrawFolderBase : IDrawFolder | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return DrawRightSide(originalY, rightSideStart); | ||||
|         return DrawRightSide(rightSideStart); | ||||
|     } | ||||
| } | ||||
| @@ -36,9 +36,9 @@ public class DrawFolderGroup : DrawFolderBase | ||||
|     private bool IsOwner => string.Equals(_groupFullInfoDto.OwnerUID, _apiController.UID, StringComparison.Ordinal); | ||||
|     private bool IsPinned => _groupFullInfoDto.GroupUserInfo.IsPinned(); | ||||
|  | ||||
|     protected override float DrawIcon(float textPosY, float originalY) | ||||
|     protected override float DrawIcon() | ||||
|     { | ||||
|         ImGui.SetCursorPosY(textPosY); | ||||
|         ImGui.AlignTextToFramePadding(); | ||||
|  | ||||
|         using (ImRaii.PushFont(UiBuilder.IconFont)) | ||||
|             ImGui.TextUnformatted(_groupFullInfoDto.GroupPermissions.IsDisableInvites() ? FontAwesomeIcon.Lock.ToIconString() : FontAwesomeIcon.Users.ToIconString()); | ||||
| @@ -50,7 +50,8 @@ public class DrawFolderGroup : DrawFolderBase | ||||
|         using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, ImGui.GetStyle().ItemSpacing with { X = ImGui.GetStyle().ItemSpacing.X / 2f })) | ||||
|         { | ||||
|             ImGui.SameLine(); | ||||
|             ImGui.SetCursorPosY(textPosY); | ||||
|             ImGui.AlignTextToFramePadding(); | ||||
|  | ||||
|             ImGui.TextUnformatted("[" + OnlinePairs.ToString() + "]"); | ||||
|         } | ||||
|         UiSharedService.AttachToolTip(OnlinePairs + " online" + Environment.NewLine + TotalPairs + " total"); | ||||
| @@ -58,23 +59,21 @@ public class DrawFolderGroup : DrawFolderBase | ||||
|         ImGui.SameLine(); | ||||
|         if (IsOwner) | ||||
|         { | ||||
|             ImGui.SameLine(); | ||||
|             ImGui.AlignTextToFramePadding(); | ||||
|             using (ImRaii.PushFont(UiBuilder.IconFont)) | ||||
|                 ImGui.TextUnformatted(FontAwesomeIcon.Crown.ToIconString()); | ||||
|             UiSharedService.AttachToolTip("You are the owner of " + _groupFullInfoDto.GroupAliasOrGID); | ||||
|         } | ||||
|         else if (IsModerator) | ||||
|         { | ||||
|             ImGui.SameLine(); | ||||
|             ImGui.SetCursorPosY(textPosY); | ||||
|             ImGui.AlignTextToFramePadding(); | ||||
|             using (ImRaii.PushFont(UiBuilder.IconFont)) | ||||
|                 ImGui.TextUnformatted(FontAwesomeIcon.UserShield.ToIconString()); | ||||
|             UiSharedService.AttachToolTip("You are a moderator in " + _groupFullInfoDto.GroupAliasOrGID); | ||||
|         } | ||||
|         else if (IsPinned) | ||||
|         { | ||||
|             ImGui.SameLine(); | ||||
|             ImGui.SetCursorPosY(textPosY); | ||||
|             ImGui.AlignTextToFramePadding(); | ||||
|             using (ImRaii.PushFont(UiBuilder.IconFont)) | ||||
|                 ImGui.TextUnformatted(FontAwesomeIcon.Thumbtack.ToIconString()); | ||||
|             UiSharedService.AttachToolTip("You are pinned in " + _groupFullInfoDto.GroupAliasOrGID); | ||||
| @@ -166,12 +165,12 @@ public class DrawFolderGroup : DrawFolderBase | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     protected override void DrawName(float originalY, float width) | ||||
|     protected override void DrawName(float width) | ||||
|     { | ||||
|         _idDisplayHandler.DrawGroupText(_id, _groupFullInfoDto, ImGui.GetCursorPosX(), originalY, () => width); | ||||
|         _idDisplayHandler.DrawGroupText(_id, _groupFullInfoDto, ImGui.GetCursorPosX(), () => width); | ||||
|     } | ||||
|  | ||||
|     protected override float DrawRightSide(float originalY, float currentRightSideX) | ||||
|     protected override float DrawRightSide(float currentRightSideX) | ||||
|     { | ||||
|         var spacingX = ImGui.GetStyle().ItemSpacing.X; | ||||
|  | ||||
| @@ -189,6 +188,8 @@ public class DrawFolderGroup : DrawFolderBase | ||||
|  | ||||
|         ImGui.SameLine(infoIconPosDist - userCogButtonSize.X); | ||||
|  | ||||
|         ImGui.AlignTextToFramePadding(); | ||||
|  | ||||
|         using (ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudYellow, | ||||
|             _groupFullInfoDto.GroupPermissions.IsPreferDisableAnimations() != individualAnimDisabled | ||||
|             || _groupFullInfoDto.GroupPermissions.IsPreferDisableSounds() != individualSoundsDisabled | ||||
|   | ||||
| @@ -64,7 +64,7 @@ public class DrawFolderTag : DrawFolderBase | ||||
|         _ => true | ||||
|     }; | ||||
|  | ||||
|     protected override float DrawIcon(float textPosY, float originalY) | ||||
|     protected override float DrawIcon() | ||||
|     { | ||||
|         using (ImRaii.PushFont(UiBuilder.IconFont)) | ||||
|         { | ||||
| @@ -79,7 +79,7 @@ public class DrawFolderTag : DrawFolderBase | ||||
|                 _ => FontAwesomeIcon.Folder.ToIconString() | ||||
|             }; | ||||
|  | ||||
|             ImGui.SetCursorPosY(textPosY); | ||||
|             ImGui.AlignTextToFramePadding(); | ||||
|             ImGui.TextUnformatted(icon); | ||||
|         } | ||||
|         if (RenderCount) | ||||
| @@ -87,7 +87,8 @@ public class DrawFolderTag : DrawFolderBase | ||||
|             using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, ImGui.GetStyle().ItemSpacing with { X = ImGui.GetStyle().ItemSpacing.X / 2f })) | ||||
|             { | ||||
|                 ImGui.SameLine(); | ||||
|                 ImGui.SetCursorPosY(textPosY); | ||||
|                 ImGui.AlignTextToFramePadding(); | ||||
|  | ||||
|                 ImGui.TextUnformatted("[" + OnlinePairs.ToString() + "]"); | ||||
|             } | ||||
|             UiSharedService.AttachToolTip(OnlinePairs + " online" + Environment.NewLine + TotalPairs + " total"); | ||||
| @@ -112,9 +113,10 @@ public class DrawFolderTag : DrawFolderBase | ||||
|             "Note: this will not unpair with users in this Group."); | ||||
|     } | ||||
|  | ||||
|     protected override void DrawName(float originalY, float width) | ||||
|     protected override void DrawName(float width) | ||||
|     { | ||||
|         ImGui.SetCursorPosY(originalY); | ||||
|         ImGui.AlignTextToFramePadding(); | ||||
|  | ||||
|         string name = _id switch | ||||
|         { | ||||
|             TagHandler.CustomUnpairedTag => "One-sided Individual Pairs", | ||||
| @@ -129,7 +131,7 @@ public class DrawFolderTag : DrawFolderBase | ||||
|         ImGui.TextUnformatted(name); | ||||
|     } | ||||
|  | ||||
|     protected override float DrawRightSide(float originalY, float currentRightSideX) | ||||
|     protected override float DrawRightSide(float currentRightSideX) | ||||
|     { | ||||
|         if (!RenderPause) return currentRightSideX; | ||||
|  | ||||
|   | ||||
| @@ -53,12 +53,11 @@ public class DrawUserPair | ||||
|         var pauseIconSize = UiSharedService.GetIconButtonSize(FontAwesomeIcon.Bars); | ||||
|         var textSize = ImGui.CalcTextSize(_pair.UserData.AliasOrUID); | ||||
|  | ||||
|         var textPosY = originalY + pauseIconSize.Y / 2 - textSize.Y / 2; | ||||
|         DrawLeftSide(textPosY); | ||||
|         DrawLeftSide(); | ||||
|         ImGui.SameLine(); | ||||
|         var posX = ImGui.GetCursorPosX(); | ||||
|         var rightSide = DrawRightSide(originalY); | ||||
|         DrawName(originalY, posX, rightSide); | ||||
|         var rightSide = DrawRightSide(); | ||||
|         DrawName(posX, rightSide); | ||||
|     } | ||||
|  | ||||
|     private void DrawCommonClientMenu() | ||||
| @@ -180,15 +179,16 @@ public class DrawUserPair | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private void DrawLeftSide(float textPosY) | ||||
|     private void DrawLeftSide() | ||||
|     { | ||||
|         string userPairText = string.Empty; | ||||
|  | ||||
|         ImGui.SetCursorPosY(textPosY); | ||||
|         ImGui.AlignTextToFramePadding(); | ||||
|  | ||||
|         if (_pair.IsPaused) | ||||
|         { | ||||
|             ImGui.SetCursorPosY(textPosY); | ||||
|             ImGui.AlignTextToFramePadding(); | ||||
|  | ||||
|             using var _ = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudYellow); | ||||
|             using var font = ImRaii.PushFont(UiBuilder.IconFont); | ||||
|             ImGui.TextUnformatted(FontAwesomeIcon.PauseCircle.ToIconString()); | ||||
| @@ -196,7 +196,7 @@ public class DrawUserPair | ||||
|         } | ||||
|         else if (!_pair.IsOnline) | ||||
|         { | ||||
|             ImGui.SetCursorPosY(textPosY); | ||||
|             ImGui.AlignTextToFramePadding(); | ||||
|             using var _ = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudRed); | ||||
|             using var font = ImRaii.PushFont(UiBuilder.IconFont); | ||||
|             ImGui.TextUnformatted(_pair.IndividualPairStatus == API.Data.Enum.IndividualPairStatus.Bidirectional | ||||
| @@ -205,7 +205,8 @@ public class DrawUserPair | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             using var _ = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.ParsedGreen); | ||||
|             ImGui.AlignTextToFramePadding(); | ||||
|  | ||||
|             using var font = ImRaii.PushFont(UiBuilder.IconFont); | ||||
|             ImGui.TextUnformatted(_pair.IndividualPairStatus == API.Data.Enum.IndividualPairStatus.Bidirectional | ||||
|                 ? FontAwesomeIcon.User.ToIconString() : FontAwesomeIcon.Users.ToIconString()); | ||||
| @@ -235,7 +236,7 @@ public class DrawUserPair | ||||
|  | ||||
|         if (_pair.UserPair.OwnPermissions.IsSticky()) | ||||
|         { | ||||
|             ImGui.SetCursorPosY(textPosY); | ||||
|             ImGui.AlignTextToFramePadding(); | ||||
|  | ||||
|             using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, ImGui.GetStyle().ItemSpacing with { X = ImGui.GetStyle().ItemSpacing.X * 3 / 4f })) | ||||
|             using (ImRaii.PushFont(UiBuilder.IconFont)) | ||||
| @@ -249,7 +250,8 @@ public class DrawUserPair | ||||
|  | ||||
|         if (_pair.IsVisible) | ||||
|         { | ||||
|             ImGui.SetCursorPosY(textPosY); | ||||
|             ImGui.AlignTextToFramePadding(); | ||||
|  | ||||
|             using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, ImGui.GetStyle().ItemSpacing with { X = ImGui.GetStyle().ItemSpacing.X * 3 / 4f })) | ||||
|             using (ImRaii.PushFont(UiBuilder.IconFont)) | ||||
|             { | ||||
| @@ -262,9 +264,9 @@ public class DrawUserPair | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private void DrawName(float originalY, float leftSide, float rightSide) | ||||
|     private void DrawName(float leftSide, float rightSide) | ||||
|     { | ||||
|         _displayHandler.DrawPairText(_id, _pair, leftSide, originalY, () => rightSide - leftSide); | ||||
|         _displayHandler.DrawPairText(_id, _pair, leftSide, () => rightSide - leftSide); | ||||
|     } | ||||
|  | ||||
|     private void DrawPairedClientMenu() | ||||
| @@ -292,7 +294,7 @@ public class DrawUserPair | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private float DrawRightSide(float originalY) | ||||
|     private float DrawRightSide() | ||||
|     { | ||||
|         var pauseIcon = _pair.UserPair!.OwnPermissions.IsPaused() ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause; | ||||
|         var pauseIconSize = UiSharedService.GetIconButtonSize(pauseIcon); | ||||
| @@ -318,6 +320,8 @@ public class DrawUserPair | ||||
|                 infoIconDist = iconwidth.X; | ||||
|                 ImGui.SameLine(infoIconPosDist - iconwidth.X); | ||||
|  | ||||
|                 ImGui.AlignTextToFramePadding(); | ||||
|  | ||||
|                 UiSharedService.FontText(icon.ToIconString(), UiBuilder.IconFont); | ||||
|                 if (ImGui.IsItemHovered()) | ||||
|                 { | ||||
| @@ -378,7 +382,6 @@ public class DrawUserPair | ||||
|  | ||||
|         rightSideStart = windowEndX - barButtonSize.X - spacingX * 3 - pauseIconSize.X - infoIconDist; | ||||
|         ImGui.SameLine(windowEndX - barButtonSize.X - spacingX - pauseIconSize.X); | ||||
|         ImGui.SetCursorPosY(originalY); | ||||
|         if (ImGuiComponents.IconButton(pauseIcon)) | ||||
|         { | ||||
|             var perm = _pair.UserPair!.OwnPermissions; | ||||
| @@ -395,8 +398,7 @@ public class DrawUserPair | ||||
|             rightSideStart = windowEndX - barButtonSize.X; | ||||
|         } | ||||
|         ImGui.SameLine(windowEndX - barButtonSize.X); | ||||
|         ImGui.SetCursorPosY(originalY); | ||||
|  | ||||
|         ImGui.AlignTextToFramePadding(); | ||||
|         if (ImGuiComponents.IconButton(FontAwesomeIcon.Bars)) | ||||
|         { | ||||
|             ImGui.OpenPopup("User Flyout Menu"); | ||||
|   | ||||
| @@ -31,13 +31,14 @@ public class IdDisplayHandler | ||||
|         _mareConfigService = mareConfigService; | ||||
|     } | ||||
|  | ||||
|     public void DrawGroupText(string id, GroupFullInfoDto group, float textPosX, float originalY, Func<float> editBoxWidth) | ||||
|     public void DrawGroupText(string id, GroupFullInfoDto group, float textPosX, Func<float> editBoxWidth) | ||||
|     { | ||||
|         ImGui.SameLine(textPosX); | ||||
|         (bool textIsUid, string playerText) = GetGroupText(group); | ||||
|         if (!string.Equals(_editEntry, group.GID, StringComparison.Ordinal)) | ||||
|         { | ||||
|             ImGui.SetCursorPosY(originalY); | ||||
|             ImGui.AlignTextToFramePadding(); | ||||
|  | ||||
|             using (ImRaii.PushFont(UiBuilder.MonoFont, textIsUid)) | ||||
|                 ImGui.TextUnformatted(playerText); | ||||
|  | ||||
| @@ -69,7 +70,7 @@ public class IdDisplayHandler | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             ImGui.SetCursorPosY(originalY); | ||||
|             ImGui.AlignTextToFramePadding(); | ||||
|  | ||||
|             ImGui.SetNextItemWidth(editBoxWidth.Invoke()); | ||||
|             if (ImGui.InputTextWithHint("", "Name/Notes", ref _editComment, 255, ImGuiInputTextFlags.EnterReturnsTrue)) | ||||
| @@ -86,13 +87,14 @@ public class IdDisplayHandler | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public void DrawPairText(string id, Pair pair, float textPosX, float originalY, Func<float> editBoxWidth) | ||||
|     public void DrawPairText(string id, Pair pair, float textPosX, Func<float> editBoxWidth) | ||||
|     { | ||||
|         ImGui.SameLine(textPosX); | ||||
|         (bool textIsUid, string playerText) = GetPlayerText(pair); | ||||
|         if (!string.Equals(_editEntry, pair.UserData.UID, StringComparison.Ordinal)) | ||||
|         { | ||||
|             ImGui.SetCursorPosY(originalY); | ||||
|             ImGui.AlignTextToFramePadding(); | ||||
|  | ||||
|             if (textIsUid) ImGui.PushFont(UiBuilder.MonoFont); | ||||
|             ImGui.TextUnformatted(playerText); | ||||
|             if (textIsUid) ImGui.PopFont(); | ||||
| @@ -162,7 +164,7 @@ public class IdDisplayHandler | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             ImGui.SetCursorPosY(originalY); | ||||
|             ImGui.AlignTextToFramePadding(); | ||||
|  | ||||
|             ImGui.SetNextItemWidth(editBoxWidth.Invoke()); | ||||
|             if (ImGui.InputTextWithHint("", "Nick/Notes", ref _editComment, 255, ImGuiInputTextFlags.EnterReturnsTrue)) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 rootdarkarchon
					rootdarkarchon