From 4c096c1ed4e3a611402b5ea26156fcf7948b802a Mon Sep 17 00:00:00 2001 From: xPumaa <35280763+xPumaa@users.noreply.github.com> Date: Fri, 8 Jul 2022 18:14:16 +0200 Subject: [PATCH 1/4] Centering of the UID --- MareSynchronos/UI/CompactUI.cs | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/MareSynchronos/UI/CompactUI.cs b/MareSynchronos/UI/CompactUI.cs index 93ddad4..68129c9 100644 --- a/MareSynchronos/UI/CompactUI.cs +++ b/MareSynchronos/UI/CompactUI.cs @@ -423,17 +423,31 @@ namespace MareSynchronos.UI { ImGui.PushID("header"); var uidText = GetUidText(); + var buttonSizeX = 0f; if (_uiShared.UidFontBuilt) ImGui.PushFont(_uiShared.UidFont); var uidTextSize = ImGui.CalcTextSize(uidText); if (_uiShared.UidFontBuilt) ImGui.PopFont(); - var originalPos = ImGui.GetCursorPosY(); + var originalPos = ImGui.GetCursorPos(); ImGui.SetWindowFontScale(1.5f); var buttonSize = GetIconButtonSize(FontAwesomeIcon.Cog); + buttonSizeX -= buttonSize.X - ImGui.GetStyle().ItemSpacing.X * 2; + ImGui.SameLine(ImGui.GetWindowContentRegionMin().X + ImGui.GetWindowContentRegionWidth() - buttonSize.X); + ImGui.SetCursorPosY(originalPos.Y + uidTextSize.Y / 2 - buttonSize.Y / 2); + if (ImGuiComponents.IconButton(FontAwesomeIcon.Cog)) + { + OpenSettingsUi?.Invoke(); + } + AttachToolTip("Open the Mare Synchronos Settings"); + + ImGui.SameLine(); //Important to draw the uidText consistently + ImGui.SetCursorPos(originalPos); + if (_apiController.ServerState is ServerState.Connected) { - ImGui.SetCursorPosY(originalPos + uidTextSize.Y / 2 - buttonSize.Y / 2); + buttonSizeX += GetIconButtonSize(FontAwesomeIcon.Copy).X - ImGui.GetStyle().ItemSpacing.X * 2; + ImGui.SetCursorPosY(originalPos.Y + uidTextSize.Y / 2 - buttonSize.Y / 2); if (ImGuiComponents.IconButton(FontAwesomeIcon.Copy)) { ImGui.SetClipboardText(_apiController.UID); @@ -443,23 +457,12 @@ namespace MareSynchronos.UI } ImGui.SetWindowFontScale(1f); - ImGui.SetCursorPosY(originalPos - uidTextSize.Y / 8); + ImGui.SetCursorPosY(originalPos.Y + buttonSize.Y / 2 - uidTextSize.Y / 2 - ImGui.GetStyle().ItemSpacing.Y / 2); + ImGui.SetCursorPosX((ImGui.GetWindowContentRegionMax().X + ImGui.GetWindowContentRegionMin().X) / 2 + buttonSizeX - uidTextSize.X / 2); if (_uiShared.UidFontBuilt) ImGui.PushFont(_uiShared.UidFont); ImGui.TextColored(GetUidColor(), uidText); if (_uiShared.UidFontBuilt) ImGui.PopFont(); - ImGui.SetWindowFontScale(1.5f); - - ImGui.SameLine(ImGui.GetWindowContentRegionMin().X + ImGui.GetWindowContentRegionWidth() - buttonSize.X); - ImGui.SetCursorPosY(originalPos + uidTextSize.Y / 2 - buttonSize.Y / 2); - if (ImGuiComponents.IconButton(FontAwesomeIcon.Cog)) - { - OpenSettingsUi?.Invoke(); - } - AttachToolTip("Open the Mare Synchronos Settings"); - - ImGui.SetWindowFontScale(1f); - if (_apiController.ServerState is not ServerState.Connected) { UiShared.ColorTextWrapped(GetServerError(), GetUidColor()); From 98e608d852881f34980c256e444d839761d4f437 Mon Sep 17 00:00:00 2001 From: xPumaa <35280763+xPumaa@users.noreply.github.com> Date: Fri, 8 Jul 2022 18:16:09 +0200 Subject: [PATCH 2/4] Spacing with GlobalScale --- MareSynchronos/UI/CompactUI.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MareSynchronos/UI/CompactUI.cs b/MareSynchronos/UI/CompactUI.cs index 68129c9..274d09c 100644 --- a/MareSynchronos/UI/CompactUI.cs +++ b/MareSynchronos/UI/CompactUI.cs @@ -369,7 +369,7 @@ namespace MareSynchronos.UI ImGui.PushFont(UiBuilder.IconFont); ImGui.Text(FontAwesomeIcon.Upload.ToIconString()); ImGui.PopFont(); - ImGui.SameLine(35); + ImGui.SameLine(35 * ImGuiHelpers.GlobalScale); if (currentUploads.Any()) { @@ -394,7 +394,7 @@ namespace MareSynchronos.UI ImGui.PushFont(UiBuilder.IconFont); ImGui.Text(FontAwesomeIcon.Download.ToIconString()); ImGui.PopFont(); - ImGui.SameLine(35); + ImGui.SameLine(35 * ImGuiHelpers.GlobalScale); if (currentDownloads.Any()) { From 5a3ae5154c0e415f00688516cede26888b1f25ff Mon Sep 17 00:00:00 2001 From: xPumaa <35280763+xPumaa@users.noreply.github.com> Date: Fri, 8 Jul 2022 20:44:09 +0200 Subject: [PATCH 3/4] Resized nick field --- MareSynchronos/UI/CompactUI.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/MareSynchronos/UI/CompactUI.cs b/MareSynchronos/UI/CompactUI.cs index 274d09c..8212dcc 100644 --- a/MareSynchronos/UI/CompactUI.cs +++ b/MareSynchronos/UI/CompactUI.cs @@ -145,6 +145,7 @@ namespace MareSynchronos.UI var trashButtonSize = GetIconButtonSize(FontAwesomeIcon.Trash); var textSize = ImGui.CalcTextSize(entry.OtherUID); var originalY = ImGui.GetCursorPosY(); + var buttonSizes = buttonSize.Y + trashButtonSize.Y; var textPos = originalY + buttonSize.Y / 2 - textSize.Y / 2; ImGui.SetCursorPosY(textPos); @@ -226,8 +227,8 @@ namespace MareSynchronos.UI { ImGui.SetCursorPosY(originalY); - ImGui.InputTextWithHint("", "Nick/Notes", ref _editCharComment, 255); - if (ImGui.GetIO().KeysDown[(int)ImGuiKey.Enter]) + ImGui.SetNextItemWidth(ImGui.GetWindowContentRegionWidth() - ImGui.GetCursorPosX() - buttonSizes - ImGui.GetStyle().ItemSpacing.X * 2); + if (ImGui.InputTextWithHint("", "Nick/Notes", ref _editCharComment, 255, ImGuiInputTextFlags.EnterReturnsTrue)) { _configuration.SetCurrentServerUidComment(entry.OtherUID, _editCharComment); _configuration.Save(); From 0f81d5d99dc562fae0100e4e11e8fa372e49217f Mon Sep 17 00:00:00 2001 From: xPumaa <35280763+xPumaa@users.noreply.github.com> Date: Fri, 8 Jul 2022 21:31:30 +0200 Subject: [PATCH 4/4] Right click to cancel nick change --- MareSynchronos/UI/CompactUI.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/MareSynchronos/UI/CompactUI.cs b/MareSynchronos/UI/CompactUI.cs index 8212dcc..010df66 100644 --- a/MareSynchronos/UI/CompactUI.cs +++ b/MareSynchronos/UI/CompactUI.cs @@ -234,7 +234,12 @@ namespace MareSynchronos.UI _configuration.Save(); _editNickEntry = string.Empty; } - AttachToolTip("Hit ENTER to save"); + + if (ImGui.IsItemClicked(ImGuiMouseButton.Right)) + { + _editNickEntry = string.Empty; + } + AttachToolTip("Hit ENTER to save\nRight click to cancel"); } ImGui.SameLine(ImGui.GetWindowContentRegionMin().X + ImGui.GetWindowContentRegionWidth() - buttonSize.X);