Popupmodal to normal popup and some UI shenanigans (#37)
* Button height now adjusts to the font size * Popup now adjusts to the font size Popup is now centered when opened * ui shenanigans * PopupModal to normal Popup
This commit is contained in:
@@ -117,7 +117,7 @@ public class CompactUi : Window, IDisposable
|
||||
{
|
||||
ImGui.PushStyleColor(ImGuiCol.Button, ImGui.GetStyle().Colors[(int)ImGuiCol.ButtonHovered]);
|
||||
}
|
||||
if (ImGui.Button(FontAwesomeIcon.User.ToIconString(), new Vector2((UiShared.GetWindowContentRegionWidth() - ImGui.GetWindowContentRegionMin().X) / 2, 30)))
|
||||
if (ImGui.Button(FontAwesomeIcon.User.ToIconString(), new Vector2((UiShared.GetWindowContentRegionWidth() - ImGui.GetWindowContentRegionMin().X) / 2, 30 * ImGuiHelpers.GlobalScale)))
|
||||
{
|
||||
showSyncShells = false;
|
||||
}
|
||||
@@ -135,7 +135,7 @@ public class CompactUi : Window, IDisposable
|
||||
{
|
||||
ImGui.PushStyleColor(ImGuiCol.Button, ImGui.GetStyle().Colors[(int)ImGuiCol.ButtonHovered]);
|
||||
}
|
||||
if (ImGui.Button(FontAwesomeIcon.UserFriends.ToIconString(), new Vector2((UiShared.GetWindowContentRegionWidth() - ImGui.GetWindowContentRegionMin().X) / 2, 30)))
|
||||
if (ImGui.Button(FontAwesomeIcon.UserFriends.ToIconString(), new Vector2((UiShared.GetWindowContentRegionWidth() - ImGui.GetWindowContentRegionMin().X) / 2, 30 * ImGuiHelpers.GlobalScale)))
|
||||
{
|
||||
showSyncShells = true;
|
||||
}
|
||||
@@ -313,12 +313,11 @@ public class CompactUi : Window, IDisposable
|
||||
{
|
||||
var pauseIcon = entry.IsPaused ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause;
|
||||
var pauseIconSize = UiShared.GetIconButtonSize(pauseIcon);
|
||||
var trashButtonSize = UiShared.GetIconButtonSize(FontAwesomeIcon.Trash);
|
||||
var barButtonSize = UiShared.GetIconButtonSize(FontAwesomeIcon.Bars);
|
||||
var entryUID = string.IsNullOrEmpty(entry.VanityUID) ? entry.OtherUID : entry.VanityUID;
|
||||
var textSize = ImGui.CalcTextSize(entryUID);
|
||||
var originalY = ImGui.GetCursorPosY();
|
||||
var buttonSizes = pauseIconSize.Y + trashButtonSize.Y + barButtonSize.Y;
|
||||
var buttonSizes = pauseIconSize.Y + barButtonSize.Y;
|
||||
var spacingX = ImGui.GetStyle().ItemSpacing.X;
|
||||
var windowEndX = ImGui.GetWindowContentRegionMin().X + UiShared.GetWindowContentRegionWidth();
|
||||
|
||||
@@ -402,7 +401,7 @@ public class CompactUi : Window, IDisposable
|
||||
{
|
||||
ImGui.SetCursorPosY(originalY);
|
||||
|
||||
ImGui.SetNextItemWidth(UiShared.GetWindowContentRegionWidth() - ImGui.GetCursorPosX() - buttonSizes - ImGui.GetStyle().ItemSpacing.X * 3);
|
||||
ImGui.SetNextItemWidth(UiShared.GetWindowContentRegionWidth() - ImGui.GetCursorPosX() - buttonSizes - ImGui.GetStyle().ItemSpacing.X * 2);
|
||||
if (ImGui.InputTextWithHint("", "Nick/Notes", ref EditUserComment, 255, ImGuiInputTextFlags.EnterReturnsTrue))
|
||||
{
|
||||
_configuration.SetCurrentServerUidComment(entry.OtherUID, EditUserComment);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Components;
|
||||
using Dalamud.Utility;
|
||||
@@ -15,12 +16,6 @@ public class SelectGroupForPairUi
|
||||
/// </summary>
|
||||
private bool _show;
|
||||
|
||||
/// <summary>
|
||||
/// Has the panel already been opened?
|
||||
/// This is used to prevent double opening
|
||||
/// </summary>
|
||||
private bool _opened;
|
||||
|
||||
/// <summary>
|
||||
/// The group UI is always open for a specific pair. This defines which pair the UI is open for.
|
||||
/// </summary>
|
||||
@@ -61,29 +56,32 @@ public class SelectGroupForPairUi
|
||||
return;
|
||||
}
|
||||
|
||||
// Is the popup not supposed to show? Set _opened to false so we can re-open it.
|
||||
if (!_show)
|
||||
{
|
||||
_opened = false;
|
||||
}
|
||||
|
||||
var name = PairName(showUidForEntry, _pair.OtherUID, _pair.VanityUID);
|
||||
var popupName = $"Choose Groups for {name}";
|
||||
// Is the popup supposed to show but did not open yet? Open it
|
||||
if (_show && !_opened)
|
||||
if (_show)
|
||||
{
|
||||
ImGui.OpenPopup(popupName);
|
||||
_opened = true;
|
||||
_show = false;
|
||||
}
|
||||
|
||||
if (ImGui.BeginPopupModal(popupName, ref _show, UiShared.PopupWindowFlags))
|
||||
if (ImGui.BeginPopup(popupName))
|
||||
{
|
||||
var tags = _tagHandler.GetAllTagsSorted();
|
||||
var childHeight = tags.Count != 0 ? tags.Count * 25 : 1;
|
||||
var childSize = new Vector2(0, childHeight > 100 ? 100 : childHeight) * ImGuiHelpers.GlobalScale;
|
||||
|
||||
UiShared.FontText($"Select the groups you want {name} to be in.", UiBuilder.DefaultFont);
|
||||
foreach (var tag in _tagHandler.GetAllTagsSorted())
|
||||
if (ImGui.BeginChild(name + "##listGroups", childSize))
|
||||
{
|
||||
foreach (var tag in tags)
|
||||
{
|
||||
UiShared.DrawWithID($"groups-pair-{_pair.OtherUID}-{tag}", () => DrawGroupName(_pair, tag));
|
||||
}
|
||||
ImGui.EndChild();
|
||||
}
|
||||
|
||||
ImGui.Separator();
|
||||
UiShared.FontText($"Create a new group for {name}.", UiBuilder.DefaultFont);
|
||||
if (ImGuiComponents.IconButton(FontAwesomeIcon.Plus))
|
||||
{
|
||||
@@ -97,19 +95,14 @@ public class SelectGroupForPairUi
|
||||
HandleAddTag();
|
||||
}
|
||||
}
|
||||
UiShared.SetScaledWindowSize(375);
|
||||
ImGui.EndPopup();
|
||||
}
|
||||
else
|
||||
{
|
||||
_show = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawGroupName(ClientPairDto pair, string name)
|
||||
{
|
||||
bool hasTagBefore = _tagHandler.HasTag(pair, name);
|
||||
bool hasTag = hasTagBefore;
|
||||
var hasTagBefore = _tagHandler.HasTag(pair, name);
|
||||
var hasTag = hasTagBefore;
|
||||
if (ImGui.Checkbox(name, ref hasTag))
|
||||
{
|
||||
if (hasTag)
|
||||
|
||||
@@ -33,6 +33,10 @@ public class SelectPairForGroupUi
|
||||
|
||||
public void Draw(List<ClientPairDto> pairs, Dictionary<string, bool> showUidForEntry)
|
||||
{
|
||||
var workHeight = ImGui.GetMainViewport().WorkSize.Y / ImGuiHelpers.GlobalScale;
|
||||
var minSize = new Vector2(300, workHeight < 400 ? workHeight : 400) * ImGuiHelpers.GlobalScale;
|
||||
var maxSize = new Vector2(300, 1000) * ImGuiHelpers.GlobalScale;
|
||||
|
||||
var popupName = $"Choose Users for Group {_tag}";
|
||||
|
||||
if (!_show)
|
||||
@@ -42,12 +46,13 @@ public class SelectPairForGroupUi
|
||||
|
||||
if (_show && !_opened)
|
||||
{
|
||||
ImGui.SetNextWindowSize(new Vector2(300, 400));
|
||||
ImGui.SetNextWindowSize(minSize);
|
||||
UiShared.CenterNextWindow(minSize.X, minSize.Y, ImGuiCond.Always);
|
||||
ImGui.OpenPopup(popupName);
|
||||
_opened = true;
|
||||
}
|
||||
|
||||
ImGui.SetNextWindowSizeConstraints(new Vector2(300, 400), new Vector2(300, 1000));
|
||||
ImGui.SetNextWindowSizeConstraints(minSize, maxSize);
|
||||
if (ImGui.BeginPopupModal(popupName, ref _show, ImGuiWindowFlags.Popup | ImGuiWindowFlags.Modal))
|
||||
{
|
||||
UiShared.FontText($"Select users for group {_tag}", UiBuilder.DefaultFont);
|
||||
@@ -70,6 +75,7 @@ public class SelectPairForGroupUi
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui.EndPopup();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -274,7 +274,8 @@ namespace MareSynchronos.UI
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.SetNextItemWidth(UiShared.GetWindowContentRegionWidth() - ImGui.GetCursorPosX());
|
||||
var buttonSizes = UiShared.GetIconButtonSize(FontAwesomeIcon.Bars).X + UiShared.GetIconSize(FontAwesomeIcon.LockOpen).X;
|
||||
ImGui.SetNextItemWidth(UiShared.GetWindowContentRegionWidth() - ImGui.GetCursorPosX() - buttonSizes - ImGui.GetStyle().ItemSpacing.X * 2);
|
||||
if (ImGui.InputTextWithHint("", "Comment/Notes", ref _editGroupComment, 255, ImGuiInputTextFlags.EnterReturnsTrue))
|
||||
{
|
||||
_configuration.SetCurrentServerGidComment(group.GID, _editGroupComment);
|
||||
@@ -560,11 +561,10 @@ namespace MareSynchronos.UI
|
||||
var entryUID = string.IsNullOrEmpty(entry.UserAlias) ? entry.UserUID : entry.UserAlias;
|
||||
var textSize = ImGui.CalcTextSize(entryUID);
|
||||
var originalY = ImGui.GetCursorPosY();
|
||||
var buttonSizes = plusButtonSize.Y;
|
||||
var userIsMod = entry.IsModerator ?? false;
|
||||
var userIsOwner = string.Equals(entryUID, ownerUid, StringComparison.Ordinal);
|
||||
|
||||
var textPos = originalY + plusButtonSize.Y / 2 - textSize.Y / 2;
|
||||
var textPos = originalY + barButtonSize.Y / 2 - textSize.Y / 2;
|
||||
ImGui.SetCursorPosY(textPos);
|
||||
if (isPausedByYou || (entry.IsPaused ?? false))
|
||||
{
|
||||
@@ -629,6 +629,8 @@ namespace MareSynchronos.UI
|
||||
playerText = entryUID;
|
||||
}
|
||||
|
||||
bool plusButtonShown = !_apiController.PairedClients.Any(p => string.Equals(p.OtherUID, entry.UserUID, StringComparison.Ordinal));
|
||||
|
||||
ImGui.SameLine();
|
||||
if (!string.Equals(_mainUi.EditNickEntry, entry.UserUID, StringComparison.Ordinal))
|
||||
{
|
||||
@@ -662,8 +664,10 @@ namespace MareSynchronos.UI
|
||||
else
|
||||
{
|
||||
ImGui.SetCursorPosY(originalY);
|
||||
var buttonSizes = (plusButtonShown ? plusButtonSize.X : 0) + barButtonSize.X;
|
||||
var buttons = plusButtonShown ? 2 : 1;
|
||||
|
||||
ImGui.SetNextItemWidth(UiShared.GetWindowContentRegionWidth() - ImGui.GetCursorPosX() - buttonSizes - ImGui.GetStyle().ItemSpacing.X * 2);
|
||||
ImGui.SetNextItemWidth(UiShared.GetWindowContentRegionWidth() - ImGui.GetCursorPosX() - buttonSizes - ImGui.GetStyle().ItemSpacing.X * buttons);
|
||||
if (ImGui.InputTextWithHint("", "Nick/Notes", ref _mainUi.EditUserComment, 255, ImGuiInputTextFlags.EnterReturnsTrue))
|
||||
{
|
||||
_configuration.SetCurrentServerUidComment(entry.UserUID, _mainUi.EditUserComment);
|
||||
@@ -678,15 +682,13 @@ namespace MareSynchronos.UI
|
||||
UiShared.AttachToolTip("Hit ENTER to save\nRight click to cancel");
|
||||
}
|
||||
|
||||
bool plusButtonShown = !_apiController.PairedClients.Any(p => string.Equals(p.OtherUID, entry.UserUID, StringComparison.Ordinal));
|
||||
|
||||
if (plusButtonShown)
|
||||
{
|
||||
ImGui.SetCursorPosY(originalY);
|
||||
var barWidth = isOwner || (isModerator && !userIsMod && !userIsOwner)
|
||||
? barButtonSize.X + ImGui.GetStyle().ItemSpacing.X
|
||||
: 0;
|
||||
ImGui.SameLine(ImGui.GetWindowContentRegionMin().X + UiShared.GetWindowContentRegionWidth() - plusButtonSize.X - barWidth);
|
||||
ImGui.SetCursorPosY(originalY);
|
||||
|
||||
if (ImGuiComponents.IconButton(FontAwesomeIcon.Plus))
|
||||
{
|
||||
@@ -697,8 +699,8 @@ namespace MareSynchronos.UI
|
||||
|
||||
if (isOwner || (isModerator && !userIsMod && !userIsOwner))
|
||||
{
|
||||
ImGui.SetCursorPosY(originalY);
|
||||
ImGui.SameLine(ImGui.GetWindowContentRegionMin().X + UiShared.GetWindowContentRegionWidth() - barButtonSize.X);
|
||||
ImGui.SetCursorPosY(originalY);
|
||||
|
||||
if (ImGuiComponents.IconButton(FontAwesomeIcon.Bars))
|
||||
{
|
||||
|
||||
@@ -107,33 +107,37 @@ public class UiShared : IDisposable
|
||||
var newLineHeight = ImGui.GetCursorPosY();
|
||||
ImGui.NewLine();
|
||||
newLineHeight = ImGui.GetCursorPosY() - newLineHeight;
|
||||
var x = width * ImGuiHelpers.GlobalScale;
|
||||
var y = ImGui.GetCursorPos().Y + ImGui.GetWindowContentRegionMin().Y - newLineHeight * 2 - ImGui.GetStyle().ItemSpacing.Y;
|
||||
|
||||
if (centerWindow)
|
||||
{
|
||||
var center = ImGui.GetMainViewport().GetCenter();
|
||||
ImGui.SetWindowPos(new Vector2(center.X - x / 2, center.Y - y / 2));
|
||||
SetScaledWindowSize(width, y, centerWindow, scaledHeight: true);
|
||||
}
|
||||
|
||||
ImGui.SetWindowSize(new Vector2(x, y));
|
||||
}
|
||||
|
||||
public static void SetScaledWindowSize(float width, float height, bool centerWindow = true)
|
||||
public static void SetScaledWindowSize(float width, float height, bool centerWindow = true, bool scaledHeight = false)
|
||||
{
|
||||
ImGui.SameLine();
|
||||
var x = width * ImGuiHelpers.GlobalScale;
|
||||
var y = height * ImGuiHelpers.GlobalScale;
|
||||
var y = scaledHeight ? height : height * ImGuiHelpers.GlobalScale;
|
||||
|
||||
if (centerWindow)
|
||||
{
|
||||
var center = ImGui.GetMainViewport().GetCenter();
|
||||
ImGui.SetWindowPos(new Vector2(center.X - x / 2, center.Y - y / 2));
|
||||
CenterWindow(x, y);
|
||||
}
|
||||
|
||||
ImGui.SetWindowSize(new Vector2(x, y));
|
||||
}
|
||||
|
||||
private static void CenterWindow(float width, float height, ImGuiCond cond = ImGuiCond.None)
|
||||
{
|
||||
var center = ImGui.GetMainViewport().GetCenter();
|
||||
ImGui.SetWindowPos(new Vector2(center.X - width / 2, center.Y - height / 2), cond);
|
||||
}
|
||||
|
||||
public static void CenterNextWindow(float width, float height, ImGuiCond cond = ImGuiCond.None)
|
||||
{
|
||||
var center = ImGui.GetMainViewport().GetCenter();
|
||||
ImGui.SetNextWindowPos(new Vector2(center.X - width / 2, center.Y - height / 2), cond);
|
||||
}
|
||||
|
||||
public static void DrawWithID(string id, Action drawSubSection)
|
||||
{
|
||||
ImGui.PushID(id);
|
||||
|
||||
Reference in New Issue
Block a user