This commit is contained in:
Soreepeong 2024-02-26 02:50:30 +09:00
parent eaf447164a
commit cf54a02812
5 changed files with 28 additions and 31 deletions

View file

@ -17,7 +17,7 @@ public interface IActiveNotification : INotification
/// <summary>Invoked upon clicking on the notification.</summary> /// <summary>Invoked upon clicking on the notification.</summary>
/// <remarks> /// <remarks>
/// This event is not applicable when <see cref="INotification.Interactible"/> is set to <c>false</c>. /// This event is not applicable when <see cref="INotification.Interactable"/> is set to <c>false</c>.
/// Note that this function may be called even after <see cref="Dismiss"/> has been invoked. /// Note that this function may be called even after <see cref="Dismiss"/> has been invoked.
/// Refer to <see cref="IsDismissed"/>. /// Refer to <see cref="IsDismissed"/>.
/// </remarks> /// </remarks>
@ -25,7 +25,7 @@ public interface IActiveNotification : INotification
/// <summary>Invoked when the mouse enters the notification window.</summary> /// <summary>Invoked when the mouse enters the notification window.</summary>
/// <remarks> /// <remarks>
/// This event is applicable regardless of <see cref="INotification.Interactible"/>. /// This event is applicable regardless of <see cref="INotification.Interactable"/>.
/// Note that this function may be called even after <see cref="Dismiss"/> has been invoked. /// Note that this function may be called even after <see cref="Dismiss"/> has been invoked.
/// Refer to <see cref="IsDismissed"/>. /// Refer to <see cref="IsDismissed"/>.
/// </remarks> /// </remarks>
@ -33,7 +33,7 @@ public interface IActiveNotification : INotification
/// <summary>Invoked when the mouse leaves the notification window.</summary> /// <summary>Invoked when the mouse leaves the notification window.</summary>
/// <remarks> /// <remarks>
/// This event is applicable regardless of <see cref="INotification.Interactible"/>. /// This event is applicable regardless of <see cref="INotification.Interactable"/>.
/// Note that this function may be called even after <see cref="Dismiss"/> has been invoked. /// Note that this function may be called even after <see cref="Dismiss"/> has been invoked.
/// Refer to <see cref="IsDismissed"/>. /// Refer to <see cref="IsDismissed"/>.
/// </remarks> /// </remarks>
@ -41,7 +41,7 @@ public interface IActiveNotification : INotification
/// <summary>Invoked upon drawing the action bar of the notification.</summary> /// <summary>Invoked upon drawing the action bar of the notification.</summary>
/// <remarks> /// <remarks>
/// This event is applicable regardless of <see cref="INotification.Interactible"/>. /// This event is applicable regardless of <see cref="INotification.Interactable"/>.
/// Note that this function may be called even after <see cref="Dismiss"/> has been invoked. /// Note that this function may be called even after <see cref="Dismiss"/> has been invoked.
/// Refer to <see cref="IsDismissed"/>. /// Refer to <see cref="IsDismissed"/>.
/// </remarks> /// </remarks>
@ -64,8 +64,8 @@ public interface IActiveNotification : INotification
/// <inheritdoc cref="INotification.Expiry"/> /// <inheritdoc cref="INotification.Expiry"/>
new DateTime Expiry { get; set; } new DateTime Expiry { get; set; }
/// <inheritdoc cref="INotification.Interactible"/> /// <inheritdoc cref="INotification.Interactable"/>
new bool Interactible { get; set; } new bool Interactable { get; set; }
/// <inheritdoc cref="INotification.UserDismissable"/> /// <inheritdoc cref="INotification.UserDismissable"/>
new bool UserDismissable { get; set; } new bool UserDismissable { get; set; }

View file

@ -36,12 +36,12 @@ public interface INotification
/// <remarks> /// <remarks>
/// Set this value to <c>true</c> if you want to respond to user inputs from /// Set this value to <c>true</c> if you want to respond to user inputs from
/// <see cref="IActiveNotification.DrawActions"/>. /// <see cref="IActiveNotification.DrawActions"/>.
/// Note that the close buttons for notifications are always provided and interactible. /// Note that the close buttons for notifications are always provided and interactable.
/// If set to <c>true</c>, then clicking on the notification itself will be interpreted as user-initiated dismissal, /// If set to <c>true</c>, then clicking on the notification itself will be interpreted as user-initiated dismissal,
/// unless <see cref="IActiveNotification.Click"/> is set or <see cref="UserDismissable"/> is unset. /// unless <see cref="IActiveNotification.Click"/> is set or <see cref="UserDismissable"/> is unset.
/// </remarks> /// </remarks>
bool Interactible { get; } bool Interactable { get; }
/// <summary>Gets a value indicating whether the user can dismiss the notification by themselves.</summary> /// <summary>Gets a value indicating whether the user can dismiss the notification by themselves.</summary>
/// <remarks>Consider adding a cancel button to <see cref="IActiveNotification.DrawActions"/>.</remarks> /// <remarks>Consider adding a cancel button to <see cref="IActiveNotification.DrawActions"/>.</remarks>
bool UserDismissable { get; } bool UserDismissable { get; }
@ -49,7 +49,7 @@ public interface INotification
/// <summary>Gets the new duration for this notification if mouse cursor is on the notification window.</summary> /// <summary>Gets the new duration for this notification if mouse cursor is on the notification window.</summary>
/// <remarks> /// <remarks>
/// If set to <see cref="TimeSpan.Zero"/> or less, then this feature is turned off. /// If set to <see cref="TimeSpan.Zero"/> or less, then this feature is turned off.
/// This property is applicable regardless of <see cref="Interactible"/>. /// This property is applicable regardless of <see cref="Interactable"/>.
/// </remarks> /// </remarks>
TimeSpan HoverExtendDuration { get; } TimeSpan HoverExtendDuration { get; }

View file

@ -139,15 +139,15 @@ internal sealed class ActiveNotification : IActiveNotification, IDisposable
} }
} }
/// <inheritdoc cref="IActiveNotification.Interactible"/> /// <inheritdoc cref="IActiveNotification.Interactable"/>
public bool Interactible public bool Interactable
{ {
get => this.underlyingNotification.Interactible; get => this.underlyingNotification.Interactable;
set set
{ {
if (this.IsDismissed) if (this.IsDismissed)
return; return;
this.underlyingNotification.Interactible = value; this.underlyingNotification.Interactable = value;
} }
} }
@ -407,7 +407,7 @@ internal sealed class ActiveNotification : IActiveNotification, IDisposable
$"##NotifyMainWindow{this.Id}", $"##NotifyMainWindow{this.Id}",
ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.AlwaysAutoResize |
ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoDecoration |
(this.Interactible (this.Interactable
? ImGuiWindowFlags.None ? ImGuiWindowFlags.None
: ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.NoBringToFrontOnFocus) | : ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.NoBringToFrontOnFocus) |
ImGuiWindowFlags.NoNav | ImGuiWindowFlags.NoNav |
@ -514,7 +514,7 @@ internal sealed class ActiveNotification : IActiveNotification, IDisposable
this.Type = newNotification.Type; this.Type = newNotification.Type;
this.IconSource = newNotification.IconSource; this.IconSource = newNotification.IconSource;
this.Expiry = newNotification.Expiry; this.Expiry = newNotification.Expiry;
this.Interactible = newNotification.Interactible; this.Interactable = newNotification.Interactable;
this.HoverExtendDuration = newNotification.HoverExtendDuration; this.HoverExtendDuration = newNotification.HoverExtendDuration;
this.newProgress = newNotification.Progress; this.newProgress = newNotification.Progress;
} }
@ -538,16 +538,14 @@ internal sealed class ActiveNotification : IActiveNotification, IDisposable
this.MouseEnter = RemoveNonDalamudInvocationsCore(this.MouseEnter); this.MouseEnter = RemoveNonDalamudInvocationsCore(this.MouseEnter);
this.MouseLeave = RemoveNonDalamudInvocationsCore(this.MouseLeave); this.MouseLeave = RemoveNonDalamudInvocationsCore(this.MouseLeave);
this.underlyingNotification.Interactible = false; this.Interactable = true;
this.IsInitiatorUnloaded = true; this.IsInitiatorUnloaded = true;
this.UserDismissable = true;
this.HoverExtendDuration = NotificationConstants.DefaultHoverExtendDuration;
var now = DateTime.Now; var newMaxExpiry = DateTime.Now + NotificationConstants.DefaultDisplayDuration;
var newMaxExpiry = now + NotificationConstants.DefaultDisplayDuration; if (this.Expiry > newMaxExpiry)
if (this.underlyingNotification.Expiry > newMaxExpiry) this.Expiry = newMaxExpiry;
{
this.underlyingNotification.Expiry = newMaxExpiry;
this.ExpiryRelativeToTime = now;
}
return; return;

View file

@ -1,4 +1,3 @@
using Dalamud.Interface.ImGuiNotification.Internal;
using Dalamud.Interface.Internal.Notifications; using Dalamud.Interface.Internal.Notifications;
namespace Dalamud.Interface.ImGuiNotification; namespace Dalamud.Interface.ImGuiNotification;
@ -22,10 +21,10 @@ public sealed record Notification : INotification
public DateTime Expiry { get; set; } = DateTime.Now + NotificationConstants.DefaultDisplayDuration; public DateTime Expiry { get; set; } = DateTime.Now + NotificationConstants.DefaultDisplayDuration;
/// <inheritdoc/> /// <inheritdoc/>
public bool Interactible { get; set; } public bool Interactable { get; set; } = true;
/// <inheritdoc/> /// <inheritdoc/>
public bool UserDismissable { get; set; } public bool UserDismissable { get; set; } = true;
/// <inheritdoc/> /// <inheritdoc/>
public TimeSpan HoverExtendDuration { get; set; } = NotificationConstants.DefaultHoverExtendDuration; public TimeSpan HoverExtendDuration { get; set; } = NotificationConstants.DefaultHoverExtendDuration;

View file

@ -119,7 +119,7 @@ internal class ImGuiWidget : IDataWindowWidget
NotificationTemplate.ProgressModeTitles, NotificationTemplate.ProgressModeTitles,
NotificationTemplate.ProgressModeTitles.Length); NotificationTemplate.ProgressModeTitles.Length);
ImGui.Checkbox("Interactible", ref this.notificationTemplate.Interactible); ImGui.Checkbox("Interactable", ref this.notificationTemplate.Interactable);
ImGui.Checkbox("User Dismissable", ref this.notificationTemplate.UserDismissable); ImGui.Checkbox("User Dismissable", ref this.notificationTemplate.UserDismissable);
@ -148,7 +148,7 @@ internal class ImGuiWidget : IDataWindowWidget
Content = text, Content = text,
Title = title, Title = title,
Type = type, Type = type,
Interactible = this.notificationTemplate.Interactible, Interactable = this.notificationTemplate.Interactable,
UserDismissable = this.notificationTemplate.UserDismissable, UserDismissable = this.notificationTemplate.UserDismissable,
Expiry = duration == TimeSpan.MaxValue ? DateTime.MaxValue : DateTime.Now + duration, Expiry = duration == TimeSpan.MaxValue ? DateTime.MaxValue : DateTime.Now + duration,
Progress = this.notificationTemplate.ProgressMode switch Progress = this.notificationTemplate.ProgressMode switch
@ -331,7 +331,7 @@ internal class ImGuiWidget : IDataWindowWidget
public bool ManualType; public bool ManualType;
public int TypeInt; public int TypeInt;
public int DurationInt; public int DurationInt;
public bool Interactible; public bool Interactable;
public bool UserDismissable; public bool UserDismissable;
public bool ActionBar; public bool ActionBar;
public int ProgressMode; public int ProgressMode;
@ -348,7 +348,7 @@ internal class ImGuiWidget : IDataWindowWidget
this.ManualType = false; this.ManualType = false;
this.TypeInt = (int)NotificationType.None; this.TypeInt = (int)NotificationType.None;
this.DurationInt = 2; this.DurationInt = 2;
this.Interactible = true; this.Interactable = true;
this.UserDismissable = true; this.UserDismissable = true;
this.ActionBar = true; this.ActionBar = true;
this.ProgressMode = 0; this.ProgressMode = 0;