improved settings with sounds bug fix
This commit is contained in:
@@ -21,15 +21,8 @@ public class LightlessNotificationUI : WindowMediatorSubscriberBase
|
||||
private readonly object _notificationLock = new();
|
||||
private readonly LightlessConfigService _configService;
|
||||
|
||||
private const float NotificationWidth = 350f;
|
||||
private const float NotificationMinHeight = 60f;
|
||||
private const float NotificationMaxHeight = 200f;
|
||||
private const float NotificationSpacing = 8f;
|
||||
private const float AnimationSpeed = 10f;
|
||||
|
||||
private const float EdgeXMargin = 0;
|
||||
private const float EdgeYMargin = 30f;
|
||||
private const float SlideDistance = 100f;
|
||||
private const float NotificationMaxHeight = 250f;
|
||||
|
||||
public LightlessNotificationUI(ILogger<LightlessNotificationUI> logger, LightlessMediator mediator, PerformanceCollectorService performanceCollector, LightlessConfigService configService)
|
||||
: base(logger, mediator, "Lightless Notifications##LightlessNotifications", performanceCollector)
|
||||
@@ -47,7 +40,7 @@ public class LightlessNotificationUI : WindowMediatorSubscriberBase
|
||||
|
||||
PositionCondition = ImGuiCond.Always;
|
||||
|
||||
Size = new Vector2(NotificationWidth, 100);
|
||||
Size = new Vector2(_configService.Current.NotificationWidth, 100);
|
||||
SizeCondition = ImGuiCond.FirstUseEver;
|
||||
IsOpen = false;
|
||||
RespectCloseHotkey = false;
|
||||
@@ -124,7 +117,7 @@ public class LightlessNotificationUI : WindowMediatorSubscriberBase
|
||||
var viewport = ImGui.GetMainViewport();
|
||||
|
||||
// Always position at top (choco doesnt know how to handle top positions how fitting)
|
||||
var baseX = viewport.WorkPos.X + viewport.WorkSize.X - NotificationWidth;
|
||||
var baseX = viewport.WorkPos.X + viewport.WorkSize.X - _configService.Current.NotificationWidth - _configService.Current.NotificationOffsetX;
|
||||
var baseY = viewport.WorkPos.Y;
|
||||
|
||||
// Apply Y offset
|
||||
@@ -139,7 +132,7 @@ public class LightlessNotificationUI : WindowMediatorSubscriberBase
|
||||
|
||||
if (i < _notifications.Count - 1)
|
||||
{
|
||||
ImGui.Dummy(new Vector2(0, NotificationSpacing));
|
||||
ImGui.Dummy(new Vector2(0, _configService.Current.NotificationSpacing));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -170,11 +163,11 @@ public class LightlessNotificationUI : WindowMediatorSubscriberBase
|
||||
|
||||
if (notification.IsAnimatingIn && notification.AnimationProgress < 1f)
|
||||
{
|
||||
notification.AnimationProgress = Math.Min(1f, notification.AnimationProgress + deltaTime * AnimationSpeed);
|
||||
notification.AnimationProgress = Math.Min(1f, notification.AnimationProgress + deltaTime * _configService.Current.NotificationAnimationSpeed);
|
||||
}
|
||||
else if (notification.IsAnimatingOut && notification.AnimationProgress > 0f)
|
||||
{
|
||||
notification.AnimationProgress = Math.Max(0f, notification.AnimationProgress - deltaTime * (AnimationSpeed * 0.7f));
|
||||
notification.AnimationProgress = Math.Max(0f, notification.AnimationProgress - deltaTime * (_configService.Current.NotificationAnimationSpeed * 0.7f));
|
||||
}
|
||||
else if (!notification.IsAnimatingOut && !notification.IsDismissed)
|
||||
{
|
||||
@@ -198,14 +191,10 @@ public class LightlessNotificationUI : WindowMediatorSubscriberBase
|
||||
{
|
||||
var alpha = notification.AnimationProgress;
|
||||
|
||||
if (_configService.Current.EnableNotificationAnimations && alpha <= 0f)
|
||||
if (alpha <= 0f)
|
||||
return;
|
||||
|
||||
var slideOffset = 0f;
|
||||
if (_configService.Current.EnableNotificationAnimations)
|
||||
{
|
||||
slideOffset = (1f - alpha) * SlideDistance;
|
||||
}
|
||||
var slideOffset = (1f - alpha) * 100f; // Fixed slide distance
|
||||
|
||||
var originalCursorPos = ImGui.GetCursorPos();
|
||||
ImGui.SetCursorPosX(originalCursorPos.X + slideOffset);
|
||||
@@ -215,7 +204,7 @@ public class LightlessNotificationUI : WindowMediatorSubscriberBase
|
||||
ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, Vector2.Zero);
|
||||
|
||||
using var child = ImRaii.Child($"notification_{notification.Id}",
|
||||
new Vector2(NotificationWidth - slideOffset, notificationHeight),
|
||||
new Vector2(_configService.Current.NotificationWidth - slideOffset, notificationHeight),
|
||||
false, ImGuiWindowFlags.NoScrollbar);
|
||||
|
||||
if (child.Success)
|
||||
@@ -233,16 +222,16 @@ public class LightlessNotificationUI : WindowMediatorSubscriberBase
|
||||
var windowSize = ImGui.GetWindowSize();
|
||||
|
||||
var baseOpacity = _configService.Current.NotificationOpacity;
|
||||
var finalOpacity = _configService.Current.EnableNotificationAnimations ? baseOpacity * alpha : baseOpacity;
|
||||
var finalOpacity = baseOpacity * alpha;
|
||||
var bgColor = new Vector4(30f/255f, 30f/255f, 30f/255f, finalOpacity);
|
||||
var accentColor = GetNotificationAccentColor(notification.Type);
|
||||
var progressBarColor = UIColors.Get("LightlessBlue");
|
||||
|
||||
var finalAccentAlpha = _configService.Current.EnableNotificationAnimations ? alpha : 1f;
|
||||
accentColor.W *= finalAccentAlpha;
|
||||
accentColor.W *= alpha;
|
||||
|
||||
// Draw shadow with fixed intensity
|
||||
var shadowOffset = new Vector2(1f, 1f);
|
||||
var shadowAlpha = _configService.Current.EnableNotificationAnimations ? 0.4f * alpha : 0.4f;
|
||||
var shadowAlpha = 0.4f * alpha;
|
||||
var shadowColor = new Vector4(0f, 0f, 0f, shadowAlpha);
|
||||
drawList.AddRectFilled(
|
||||
windowPos + shadowOffset,
|
||||
@@ -252,6 +241,7 @@ public class LightlessNotificationUI : WindowMediatorSubscriberBase
|
||||
);
|
||||
|
||||
var isHovered = ImGui.IsWindowHovered();
|
||||
|
||||
if (isHovered)
|
||||
{
|
||||
bgColor = bgColor * 1.1f;
|
||||
@@ -274,14 +264,17 @@ public class LightlessNotificationUI : WindowMediatorSubscriberBase
|
||||
3f
|
||||
);
|
||||
|
||||
// Draw accent bar on left side of the notif
|
||||
var accentWidth = 3f;
|
||||
drawList.AddRectFilled(
|
||||
windowPos,
|
||||
windowPos + new Vector2(accentWidth, windowSize.Y),
|
||||
ImGui.ColorConvertFloat4ToU32(accentColor),
|
||||
3f
|
||||
);
|
||||
// Draw accent bar on left side of the notif (only if width > 0)
|
||||
var accentWidth = _configService.Current.NotificationAccentBarWidth;
|
||||
if (accentWidth > 0f)
|
||||
{
|
||||
drawList.AddRectFilled(
|
||||
windowPos,
|
||||
windowPos + new Vector2(accentWidth, windowSize.Y),
|
||||
ImGui.ColorConvertFloat4ToU32(accentColor),
|
||||
3f
|
||||
);
|
||||
}
|
||||
|
||||
DrawDurationProgressBar(notification, alpha, windowPos, windowSize, progressBarColor, drawList);
|
||||
|
||||
@@ -290,8 +283,17 @@ public class LightlessNotificationUI : WindowMediatorSubscriberBase
|
||||
|
||||
private void DrawDurationProgressBar(LightlessNotification notification, float alpha, Vector2 windowPos, Vector2 windowSize, Vector4 progressBarColor, ImDrawListPtr drawList)
|
||||
{
|
||||
var elapsed = DateTime.UtcNow - notification.CreatedAt;
|
||||
var progress = Math.Min(1.0f, (float)(elapsed.TotalSeconds / notification.Duration.TotalSeconds));
|
||||
// For download notifications, use download progress instead of duration
|
||||
float progress;
|
||||
if (notification.Type == NotificationType.Download && notification.ShowProgress)
|
||||
{
|
||||
progress = Math.Clamp(notification.Progress, 0f, 1f);
|
||||
}
|
||||
else
|
||||
{
|
||||
var elapsed = DateTime.UtcNow - notification.CreatedAt;
|
||||
progress = Math.Min(1.0f, (float)(elapsed.TotalSeconds / notification.Duration.TotalSeconds));
|
||||
}
|
||||
|
||||
var progressHeight = 2f;
|
||||
var progressY = windowPos.Y + windowSize.Y - progressHeight;
|
||||
@@ -361,21 +363,10 @@ public class LightlessNotificationUI : WindowMediatorSubscriberBase
|
||||
ImGui.PopTextWrapPos();
|
||||
}
|
||||
|
||||
if (notification.ShowProgress)
|
||||
{
|
||||
ImGui.Spacing();
|
||||
var progressColor = GetNotificationAccentColor(notification.Type);
|
||||
progressColor.W *= alpha;
|
||||
using (ImRaii.PushColor(ImGuiCol.PlotHistogram, progressColor))
|
||||
{
|
||||
// Use full window width for progress bar
|
||||
ImGui.ProgressBar(notification.Progress, new Vector2(windowSize.X - padding.X * 2 - 6f, 2f), "");
|
||||
}
|
||||
}
|
||||
|
||||
if (notification.Actions.Count > 0)
|
||||
{
|
||||
ImGui.Spacing();
|
||||
var spacingHeight = ImGui.GetStyle().ItemSpacing.Y;
|
||||
ImGui.SetCursorPosY(ImGui.GetCursorPosY() + spacingHeight);
|
||||
ImGui.SetCursorPosX(contentPos.X);
|
||||
DrawNotificationActions(notification, contentSize.X, alpha);
|
||||
}
|
||||
@@ -504,8 +495,8 @@ public class LightlessNotificationUI : WindowMediatorSubscriberBase
|
||||
|
||||
private float CalculateNotificationHeight(LightlessNotification notification)
|
||||
{
|
||||
var contentWidth = NotificationWidth - 35f; // Account for padding and accent bar
|
||||
var height = 20f; // Base height for padding
|
||||
var contentWidth = _configService.Current.NotificationWidth - 35f; // Account for padding and accent bar
|
||||
var height = 12f; // Base height for padding (top + bottom)
|
||||
|
||||
var titleText = notification.Title;
|
||||
if (_configService.Current.ShowNotificationTimestamp)
|
||||
@@ -515,13 +506,14 @@ public class LightlessNotificationUI : WindowMediatorSubscriberBase
|
||||
}
|
||||
|
||||
var titleSize = ImGui.CalcTextSize(titleText, true, contentWidth);
|
||||
height += titleSize.Y + 4f; // Title height + spacing
|
||||
height += titleSize.Y; // Title height
|
||||
|
||||
// Calculate message height
|
||||
if (!string.IsNullOrEmpty(notification.Message))
|
||||
{
|
||||
var messageSize = ImGui.CalcTextSize(notification.Message, true, contentWidth);
|
||||
height += messageSize.Y + 4f; // Message height + spacing
|
||||
height += 4f; // Spacing between title and message
|
||||
var messageSize = ImGui.CalcTextSize(notification.Message, true, contentWidth); // This is cringe
|
||||
height += messageSize.Y; // Message height
|
||||
}
|
||||
|
||||
// Add height for progress bar
|
||||
@@ -533,7 +525,9 @@ public class LightlessNotificationUI : WindowMediatorSubscriberBase
|
||||
// Add height for action buttons
|
||||
if (notification.Actions.Count > 0)
|
||||
{
|
||||
height += 28f;
|
||||
height += ImGui.GetStyle().ItemSpacing.Y; // Spacing before buttons
|
||||
height += ImGui.GetFrameHeight(); // Button height
|
||||
height += 12f; // Bottom padding for buttons
|
||||
}
|
||||
|
||||
// Allow notifications to grow taller but cap at maximum height
|
||||
|
||||
Reference in New Issue
Block a user