add mouseover in main ui
This commit is contained in:
@@ -17,6 +17,7 @@ public abstract class DrawFolderBase : IDrawFolder
|
||||
private float _menuWidth = -1;
|
||||
public int OnlinePairs => DrawPairs.Count(u => u.Pair.IsOnline);
|
||||
public int TotalPairs => _allPairs.Count;
|
||||
private bool _wasHovered = false;
|
||||
|
||||
protected DrawFolderBase(string id, IImmutableList<DrawUserPair> drawPairs,
|
||||
IImmutableList<Pair> allPairs, TagHandler tagHandler, UiSharedService uiSharedService)
|
||||
@@ -36,7 +37,9 @@ public abstract class DrawFolderBase : IDrawFolder
|
||||
if (!RenderIfEmpty && !DrawPairs.Any()) return;
|
||||
|
||||
using var id = ImRaii.PushId("folder_" + _id);
|
||||
|
||||
var color = ImRaii.PushColor(ImGuiCol.ChildBg, ImGui.GetColorU32(ImGuiCol.FrameBgHovered), _wasHovered);
|
||||
using (ImRaii.Child("folder__" + _id, new System.Numerics.Vector2(UiSharedService.GetWindowContentRegionWidth() - ImGui.GetCursorPosX(), ImGui.GetFrameHeight())))
|
||||
{
|
||||
// draw opener
|
||||
var icon = _tagHandler.IsTagOpen(_id) ? FontAwesomeIcon.CaretDown : FontAwesomeIcon.CaretRight;
|
||||
|
||||
@@ -57,12 +60,18 @@ public abstract class DrawFolderBase : IDrawFolder
|
||||
// draw name
|
||||
ImGui.SameLine(leftSideEnd);
|
||||
DrawName(rightSideStart - leftSideEnd);
|
||||
}
|
||||
|
||||
_wasHovered = ImGui.IsItemHovered();
|
||||
|
||||
color.Dispose();
|
||||
|
||||
ImGui.Separator();
|
||||
|
||||
// if opened draw content
|
||||
if (_tagHandler.IsTagOpen(_id))
|
||||
{
|
||||
using var indent = ImRaii.PushIndent(_uiSharedService.GetIconData(FontAwesomeIcon.Bars).X + ImGui.GetStyle().ItemSpacing.X, false);
|
||||
using var indent = ImRaii.PushIndent(_uiSharedService.GetIconData(FontAwesomeIcon.EllipsisV).X + ImGui.GetStyle().ItemSpacing.X, false);
|
||||
if (DrawPairs.Any())
|
||||
{
|
||||
foreach (var item in DrawPairs)
|
||||
@@ -89,7 +98,7 @@ public abstract class DrawFolderBase : IDrawFolder
|
||||
|
||||
private float DrawRightSideInternal()
|
||||
{
|
||||
var barButtonSize = _uiSharedService.IconButtonSize(FontAwesomeIcon.Bars);
|
||||
var barButtonSize = _uiSharedService.IconButtonSize(FontAwesomeIcon.EllipsisV);
|
||||
var spacingX = ImGui.GetStyle().ItemSpacing.X;
|
||||
var windowEndX = ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth();
|
||||
|
||||
@@ -99,7 +108,7 @@ public abstract class DrawFolderBase : IDrawFolder
|
||||
if (RenderMenu)
|
||||
{
|
||||
ImGui.SameLine(windowEndX - barButtonSize.X);
|
||||
if (UiSharedService.IconButton(FontAwesomeIcon.Bars))
|
||||
if (UiSharedService.IconButton(FontAwesomeIcon.EllipsisV))
|
||||
{
|
||||
ImGui.OpenPopup("User Flyout Menu");
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ public class DrawGroupedGroupFolder : IDrawFolder
|
||||
private readonly IEnumerable<IDrawFolder> _groups;
|
||||
private readonly TagHandler _tagHandler;
|
||||
private readonly UiSharedService _uiSharedService;
|
||||
private bool _wasHovered = false;
|
||||
|
||||
public IImmutableList<DrawUserPair> DrawPairs => throw new NotSupportedException();
|
||||
public int OnlinePairs => _groups.SelectMany(g => g.DrawPairs).Where(g => g.Pair.IsOnline).DistinctBy(g => g.Pair.UserData.UID).Count();
|
||||
@@ -30,12 +31,16 @@ public class DrawGroupedGroupFolder : IDrawFolder
|
||||
|
||||
string _id = "__folder_syncshells";
|
||||
using var id = ImRaii.PushId(_id);
|
||||
|
||||
var color = ImRaii.PushColor(ImGuiCol.ChildBg, ImGui.GetColorU32(ImGuiCol.FrameBgHovered), _wasHovered);
|
||||
using (ImRaii.Child("folder__" + _id, new System.Numerics.Vector2(UiSharedService.GetWindowContentRegionWidth() - ImGui.GetCursorPosX(), ImGui.GetFrameHeight())))
|
||||
{
|
||||
ImGui.Dummy(new Vector2(0f, ImGui.GetFrameHeight()));
|
||||
using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, new Vector2(0f, 0f)))
|
||||
ImGui.SameLine();
|
||||
|
||||
var icon = _tagHandler.IsTagOpen(_id) ? FontAwesomeIcon.CaretDown : FontAwesomeIcon.CaretRight;
|
||||
ImGui.AlignTextToFramePadding();
|
||||
|
||||
_uiSharedService.IconText(icon);
|
||||
if (ImGui.IsItemClicked())
|
||||
{
|
||||
@@ -43,6 +48,7 @@ public class DrawGroupedGroupFolder : IDrawFolder
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGui.AlignTextToFramePadding();
|
||||
_uiSharedService.IconText(FontAwesomeIcon.UsersRectangle);
|
||||
using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, ImGui.GetStyle().ItemSpacing with { X = ImGui.GetStyle().ItemSpacing.X / 2f }))
|
||||
{
|
||||
@@ -55,6 +61,10 @@ public class DrawGroupedGroupFolder : IDrawFolder
|
||||
ImGui.SameLine();
|
||||
ImGui.AlignTextToFramePadding();
|
||||
ImGui.TextUnformatted("All Syncshells");
|
||||
}
|
||||
color.Dispose();
|
||||
_wasHovered = ImGui.IsItemHovered();
|
||||
|
||||
ImGui.Separator();
|
||||
|
||||
if (_tagHandler.IsTagOpen(_id))
|
||||
|
||||
@@ -27,6 +27,7 @@ public class DrawUserPair
|
||||
private readonly ServerConfigurationManager _serverConfigurationManager;
|
||||
private readonly UiSharedService _uiSharedService;
|
||||
private float _menuWidth = -1;
|
||||
private bool _wasHovered = false;
|
||||
|
||||
public DrawUserPair(string id, Pair entry, List<GroupFullInfoDto> syncedGroups,
|
||||
GroupFullInfoDto? currentGroup,
|
||||
@@ -53,13 +54,18 @@ public class DrawUserPair
|
||||
public void DrawPairedClient()
|
||||
{
|
||||
using var id = ImRaii.PushId(GetType() + _id);
|
||||
|
||||
var color = ImRaii.PushColor(ImGuiCol.ChildBg, ImGui.GetColorU32(ImGuiCol.FrameBgHovered), _wasHovered);
|
||||
using (ImRaii.Child(GetType() + _id, new System.Numerics.Vector2(UiSharedService.GetWindowContentRegionWidth() - ImGui.GetCursorPosX(), ImGui.GetFrameHeight())))
|
||||
{
|
||||
DrawLeftSide();
|
||||
ImGui.SameLine();
|
||||
var posX = ImGui.GetCursorPosX();
|
||||
var rightSide = DrawRightSide();
|
||||
DrawName(posX, rightSide);
|
||||
}
|
||||
_wasHovered = ImGui.IsItemHovered();
|
||||
color.Dispose();
|
||||
}
|
||||
|
||||
private void DrawCommonClientMenu()
|
||||
{
|
||||
@@ -290,14 +296,14 @@ public class DrawUserPair
|
||||
{
|
||||
var pauseIcon = _pair.UserPair!.OwnPermissions.IsPaused() ? FontAwesomeIcon.Play : FontAwesomeIcon.Pause;
|
||||
var pauseIconSize = _uiSharedService.IconButtonSize(pauseIcon);
|
||||
var barButtonSize = _uiSharedService.IconButtonSize(FontAwesomeIcon.Bars);
|
||||
var barButtonSize = _uiSharedService.IconButtonSize(FontAwesomeIcon.EllipsisV);
|
||||
var spacingX = ImGui.GetStyle().ItemSpacing.X;
|
||||
var windowEndX = ImGui.GetWindowContentRegionMin().X + UiSharedService.GetWindowContentRegionWidth();
|
||||
float currentRightSide = windowEndX - barButtonSize.X;
|
||||
|
||||
ImGui.SameLine(currentRightSide);
|
||||
ImGui.AlignTextToFramePadding();
|
||||
if (UiSharedService.IconButton(FontAwesomeIcon.Bars))
|
||||
if (UiSharedService.IconButton(FontAwesomeIcon.EllipsisV))
|
||||
{
|
||||
ImGui.OpenPopup("User Flyout Menu");
|
||||
}
|
||||
|
||||
@@ -467,7 +467,7 @@ public class TopTabMenu
|
||||
using (ImRaii.Disabled(_pairManager.GroupPairs.Select(k => k.Key).Distinct()
|
||||
.Count(g => string.Equals(g.OwnerUID, _apiController.UID, StringComparison.Ordinal)) >= _apiController.ServerInfo.MaxGroupsCreatedByUser))
|
||||
{
|
||||
if (UiSharedService.IconTextButton(FontAwesomeIcon.Plus, "Create new Syncshell"))
|
||||
if (UiSharedService.IconTextButton(FontAwesomeIcon.Plus, "Create new Syncshell", buttonX))
|
||||
{
|
||||
_mareMediator.Publish(new UiToggleMessage(typeof(CreateSyncshellUI)));
|
||||
}
|
||||
@@ -476,7 +476,7 @@ public class TopTabMenu
|
||||
|
||||
using (ImRaii.Disabled(_pairManager.GroupPairs.Select(k => k.Key).Distinct().Count() >= _apiController.ServerInfo.MaxGroupsJoinedByUser))
|
||||
{
|
||||
if (UiSharedService.IconTextButton(FontAwesomeIcon.Users, "Join existing Syncshell"))
|
||||
if (UiSharedService.IconTextButton(FontAwesomeIcon.Users, "Join existing Syncshell", buttonX))
|
||||
{
|
||||
_mareMediator.Publish(new UiToggleMessage(typeof(JoinSyncshellUI)));
|
||||
}
|
||||
|
||||
@@ -337,7 +337,8 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
|
||||
public static bool IconTextButton(FontAwesomeIcon icon, string text, float? width = null, bool isInPopup = false)
|
||||
{
|
||||
return IconTextButtonInternal(icon, text,
|
||||
isInPopup ? ColorHelpers.RgbaUintToVector4(ImGui.GetColorU32(ImGuiCol.PopupBg)) : null, width);
|
||||
isInPopup ? ColorHelpers.RgbaUintToVector4(ImGui.GetColorU32(ImGuiCol.PopupBg)) : null,
|
||||
width <= 0 ? null : width);
|
||||
}
|
||||
|
||||
public static bool IsDirectoryWritable(string dirPath, bool throwIfFails = false)
|
||||
|
||||
Reference in New Issue
Block a user