1.12.4
All checks were successful
Tag and Release Lightless / tag-and-release (push) Successful in 35s
All checks were successful
Tag and Release Lightless / tag-and-release (push) Successful in 35s
Co-authored-by: cake <cake@noreply.git.lightless-sync.org> Co-authored-by: cake <admin@cakeandbanana.nl> Co-authored-by: azyges <229218900+azyges@users.noreply.github.com> Co-authored-by: choco <choco@patat.nl> Co-authored-by: choco <choco@noreply.git.lightless-sync.org> Co-authored-by: defnotken <itsdefnotken@gmail.com> Reviewed-on: #73
This commit was merged in pull request #73.
This commit is contained in:
@@ -45,6 +45,9 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase
|
||||
ImGuiWindowFlags.NoNav |
|
||||
ImGuiWindowFlags.NoBackground |
|
||||
ImGuiWindowFlags.NoCollapse |
|
||||
ImGuiWindowFlags.NoInputs |
|
||||
ImGuiWindowFlags.NoTitleBar |
|
||||
ImGuiWindowFlags.NoScrollbar |
|
||||
ImGuiWindowFlags.AlwaysAutoResize;
|
||||
|
||||
PositionCondition = ImGuiCond.Always;
|
||||
@@ -86,6 +89,13 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase
|
||||
existing.Progress = updated.Progress;
|
||||
existing.ShowProgress = updated.ShowProgress;
|
||||
existing.Title = updated.Title;
|
||||
|
||||
// Reset the duration timer on every update for download notifications
|
||||
if (updated.Type == NotificationType.Download)
|
||||
{
|
||||
existing.CreatedAt = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
_logger.LogDebug("Updated existing notification: {Title}", updated.Title);
|
||||
}
|
||||
|
||||
@@ -335,6 +345,13 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase
|
||||
DrawBackground(drawList, windowPos, windowSize, bgColor);
|
||||
DrawAccentBar(drawList, windowPos, windowSize, accentColor);
|
||||
DrawDurationProgressBar(notification, alpha, windowPos, windowSize, drawList);
|
||||
|
||||
// Draw download progress bar above duration bar for download notifications
|
||||
if (notification.Type == NotificationType.Download && notification.ShowProgress)
|
||||
{
|
||||
DrawDownloadProgressBar(notification, alpha, windowPos, windowSize, drawList);
|
||||
}
|
||||
|
||||
DrawNotificationText(notification, alpha);
|
||||
}
|
||||
|
||||
@@ -416,7 +433,7 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase
|
||||
|
||||
private void DrawDurationProgressBar(LightlessNotification notification, float alpha, Vector2 windowPos, Vector2 windowSize, ImDrawListPtr drawList)
|
||||
{
|
||||
var progress = CalculateProgress(notification);
|
||||
var progress = CalculateDurationProgress(notification);
|
||||
var progressBarColor = UIColors.Get("LightlessBlue");
|
||||
var progressHeight = 2f;
|
||||
var progressY = windowPos.Y + windowSize.Y - progressHeight;
|
||||
@@ -430,13 +447,26 @@ public class LightlessNotificationUi : WindowMediatorSubscriberBase
|
||||
}
|
||||
}
|
||||
|
||||
private float CalculateProgress(LightlessNotification notification)
|
||||
private void DrawDownloadProgressBar(LightlessNotification notification, float alpha, Vector2 windowPos, Vector2 windowSize, ImDrawListPtr drawList)
|
||||
{
|
||||
if (notification.Type == NotificationType.Download && notification.ShowProgress)
|
||||
{
|
||||
return Math.Clamp(notification.Progress, 0f, 1f);
|
||||
}
|
||||
var progress = Math.Clamp(notification.Progress, 0f, 1f);
|
||||
var progressBarColor = UIColors.Get("LightlessGreen");
|
||||
var progressHeight = 3f;
|
||||
// Position above the duration bar (2px duration bar + 1px spacing)
|
||||
var progressY = windowPos.Y + windowSize.Y - progressHeight - 3f;
|
||||
var progressWidth = windowSize.X * progress;
|
||||
|
||||
DrawProgressBackground(drawList, windowPos, windowSize, progressY, progressHeight, progressBarColor, alpha);
|
||||
|
||||
if (progress > 0)
|
||||
{
|
||||
DrawProgressForeground(drawList, windowPos, progressY, progressHeight, progressWidth, progressBarColor, alpha);
|
||||
}
|
||||
}
|
||||
|
||||
private float CalculateDurationProgress(LightlessNotification notification)
|
||||
{
|
||||
// Calculate duration timer progress
|
||||
var elapsed = DateTime.UtcNow - notification.CreatedAt;
|
||||
return Math.Min(1.0f, (float)(elapsed.TotalSeconds / notification.Duration.TotalSeconds));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user