Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DynamicWin/DynamicWin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@
<ItemGroup>
<PackageReference Include="CsvHelper" Version="33.1.0" />
<PackageReference Include="FftSharp" Version="2.2.0" />
<PackageReference Include="LibreHardwareMonitorLib" Version="0.9.4" />
<PackageReference Include="LibreHardwareMonitorLib" Version="0.9.6" />
<PackageReference Include="MathNet.Numerics" Version="5.0.0" />
<PackageReference Include="NAudio" Version="2.2.1" />
<PackageReference Include="NAudio.Wasapi" Version="2.2.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="SkiaSharp" Version="3.119.1" />
<PackageReference Include="SkiaSharp.NativeAssets.Win32" Version="3.119.1" />
<PackageReference Include="System.Management" Version="10.0.1" />
<PackageReference Include="System.Management" Version="10.0.3" />
<PackageReference Include="Dubya.WindowsMediaController" Version="2.5.6" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions DynamicWin/Main/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public partial class DynamicWinMain : System.Windows.Application
public static MMDevice? defaultDevice;
public static MMDevice? defaultMicrophone;

public static string Version => "v1.6.1r";
public static Channel ReleaseStream => Channel.Release;
public static string Version => "v1.6.2b3";
public static Channel ReleaseStream => Channel.Canary;
public static Architecture ProcessArchitecture => RuntimeInformation.ProcessArchitecture;

[STAThread]
Expand Down
35 changes: 35 additions & 0 deletions DynamicWin/Main/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class Settings
private static int activeScreenIndex;
private static int releaseStream;
private static bool allowAutomaticUpdates = true;
private static bool reduceWorkingArea;

public static IslandObject.IslandMode IslandMode { get => islandMode; set => islandMode = value; }
public static bool AllowBlur { get => allowBlur; set => allowBlur = value; }
Expand All @@ -42,6 +43,36 @@ public class Settings
public static int ScreenIndex { get => activeScreenIndex; set => activeScreenIndex = value; }
public static int ReleaseStream { get => releaseStream; set => releaseStream = value; }
public static bool AllowAutomaticUpdates { get => allowAutomaticUpdates; set => allowAutomaticUpdates = value; }
public static bool AlwaysTopmost
{
get => reduceWorkingArea;
set
{
reduceWorkingArea = value;

try
{
if (Application.Current != null)
{
Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{
try
{
if (MainForm.Instance != null)
WindowPositionHelper.CenterWindowOnMonitor(MainForm.Instance, ScreenIndex);
}
catch { }
}));
}
else
{
if (MainForm.Instance != null)
WindowPositionHelper.CenterWindowOnMonitor(MainForm.Instance, ScreenIndex);
}
}
catch { }
}
}

public static List<string> smallWidgetsLeft;
public static List<string> smallWidgetsRight;
Expand Down Expand Up @@ -77,6 +108,8 @@ public static void InitializeSettings()

AllowAutomaticUpdates = SaveManager.Contains("settings.AllowAutomaticUpdates") ? (bool)SaveManager.Get("settings.AllowAutomaticUpdates") : true;

AlwaysTopmost = SaveManager.Contains("settings.ReduceWorkingArea") ? (bool)SaveManager.Get("settings.ReduceWorkingArea") : true;

Theme = (int)((Int64)SaveManager.Get("settings.theme"));
ScreenIndex = (int)((Int64)SaveManager.Get("settings.screenindex"));
ReleaseStream = SaveManager.Contains("settings.ReleaseStream") ? (int)((Int64)SaveManager.Get("settings.ReleaseStream")) : 0;
Expand Down Expand Up @@ -137,6 +170,7 @@ public static void InitializeSettings()

// default automatic updates enabled
AllowAutomaticUpdates = true;
AlwaysTopmost = true;

Theme = 0;

Expand Down Expand Up @@ -186,6 +220,7 @@ public static void Save()
SaveManager.Add("settings.ReleaseStream", ReleaseStream);

SaveManager.Add("settings.AllowAutomaticUpdates", AllowAutomaticUpdates);
SaveManager.Add("settings.ReduceWorkingArea", AlwaysTopmost);

SaveManager.Add("settings.theme", Theme);
SaveManager.Add("settings.screenindex", ScreenIndex);
Expand Down
23 changes: 22 additions & 1 deletion DynamicWin/UI/Menu/Menus/SettingsMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Navigation;
using System.Xml.Linq;
Expand Down Expand Up @@ -52,6 +53,7 @@ void SaveAndBack()
Settings.ToggleHomeMenuShadow = toggleHomeMenuShadow.IsChecked;
Settings.RunOnStartup = runOnStartup.IsChecked;
Settings.AllowAutomaticUpdates = allowAutomaticUpdates.IsChecked;
Settings.AlwaysTopmost = alwaysTopmost.IsChecked;

// Save the selected default big menu mode
if (bigMenuModeSelector != null)
Expand Down Expand Up @@ -88,12 +90,13 @@ void SaveAndBack()
DWCheckbox antiAliasing;
DWCheckbox runOnStartup;
DWCheckbox allowAutomaticUpdates;
DWCheckbox alwaysTopmost;
DWCheckbox toggleIslandShadow;
DWCheckbox toggleHomeMenuShadow;
DWCheckbox toggleHighRefreshRate;
DWCheckbox limitRefreshRateWhenIdle;

DWText refreshRateDisclaimer1, refreshRateDisclaimer2, limitRefreshRateDisclaimer1, limitRefreshRateDisclaimer2;
DWText refreshRateDisclaimer1, refreshRateDisclaimer2, limitRefreshRateDisclaimer1, limitRefreshRateDisclaimer2, workingAreaDisclaimer1, workingAreaDisclaimer2;

UIObject bottomMask;

Expand Down Expand Up @@ -132,6 +135,24 @@ public override List<UIObject> InitializeMenu(IslandObject island)
objects.Add(islandMode);
}

workingAreaDisclaimer1 = new DWText(island, "Renders the interface to its minimum height and width possible, also improves performance.", new Vec2(25, 0), UIAlignment.TopLeft);
workingAreaDisclaimer1.Font = Res.SFProRegular;
workingAreaDisclaimer1.TextSize = 12;
workingAreaDisclaimer1.Anchor.X = 0;

workingAreaDisclaimer2 = new DWText(island, "Enabling this setting may prevent the interface from being placed correctly at the top.", new Vec2(25, 0), UIAlignment.TopLeft);
workingAreaDisclaimer2.Font = Res.SFProRegular;
workingAreaDisclaimer2.TextSize = 12;
workingAreaDisclaimer2.Anchor.X = 0;

objects.Add(workingAreaDisclaimer1);
objects.Add(workingAreaDisclaimer2);

alwaysTopmost = new DWCheckbox(island, $"Keep interface always topmost", new Vec2(25, 0), new Vec2(25, 25), () => { }, UIAlignment.TopLeft);
alwaysTopmost.IsChecked = Settings.AlwaysTopmost;
alwaysTopmost.Anchor.X = 0;
objects.Add(alwaysTopmost);

allowBlur = new DWCheckbox(island, "Toggle blur", new Vec2(25, 0), new Vec2(25, 25), () => { }, UIAlignment.TopLeft);
allowBlur.IsChecked = Settings.AllowBlur;
allowBlur.Anchor.X = 0;
Expand Down
4 changes: 2 additions & 2 deletions DynamicWin/UI/UIElements/Custom/MediaPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1360,7 +1360,7 @@ public override void Draw(SKCanvas canvas)
int save = canvas.Save();

// Shrink and dim thumbnail if paused, animated
float thumbScale = 0.6f + 0.4f * thumbnailAnim; // 0.6 (paused) to 1.0 (playing)
float thumbScale = 0.8f + 0.2f * thumbnailAnim; // 0.8 (paused) to 1.0 (playing)
float dimAlpha = (1f - thumbnailAnim) * 120f; // 0 (playing) to 120 (paused)
float centerX = thumbRect.MidX;
float centerY = thumbRect.MidY;
Expand Down Expand Up @@ -1547,7 +1547,7 @@ public override void Draw(SKCanvas canvas)
paint.IsAntialias = Settings.AntiAliasing;
paint.Color = GetColor(timelineTextColor).Value();
paint.TextSize = timelineTextSize;
paint.Typeface = Resources.Res.SFProRegular;
paint.Typeface = Res.SFProRegular;

float timelineTextY = barY + timelineHeight + timelineTextSize - 10f;
float leftX = barX - timelineSidePadding + 4f;
Expand Down
69 changes: 60 additions & 9 deletions DynamicWin/UI/Widgets/Small/MediaThumbnailWidget.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using DynamicWin.Utils;
using DynamicWin.Utils;
using DynamicWin.UI.UIElements;
using SkiaSharp;
using System;
using System.Threading.Tasks;
using System.Threading;
using System.Diagnostics;
using DynamicWin.Resources;
using DynamicWin.Main;

namespace DynamicWin.UI.Widgets.Small
{
Expand Down Expand Up @@ -52,6 +53,9 @@ public class MediaThumbnailWidget : SmallWidgetBase

public MediaThumbnailWidget(UIObject? parent, Vec2 position, UIAlignment alignment = UIAlignment.TopCenter) : base(parent, position, alignment)
{
// Ensure shared setting loaded
try { RegisterSmallVisualiserWidgetSettings.SharedMediaSettings.Load(); } catch { }

MediaThumbnailService.Instance.ThumbnailChanged += OnThumbnailChanged;

// Try to initialise from service canonical bitmap (fast path)
Expand All @@ -70,7 +74,23 @@ public MediaThumbnailWidget(UIObject? parent, Vec2 position, UIAlignment alignme
thumbnailBitmap = bmp;
try { currentBitmapFingerprint = BitmapUtils.GetBitmapFingerprint(bmp); } catch { currentBitmapFingerprint = null; }
hasMedia = true;
collapseProgress = 1f;

// Respect shared hide-when-idle setting: if enabled and media has been paused for longer than 30 seconds, start collapsed
bool hideWhenIdle = false;
try { hideWhenIdle = RegisterSmallVisualiserWidgetSettings.SharedMediaSettings.HideMediaWhenIdle; } catch { hideWhenIdle = false; }
if (hideWhenIdle)
{
try
{
bool pausedLong = MediaThumbnailService.Instance.IsPausedLongerThan(TimeSpan.FromSeconds(30));
collapseProgress = pausedLong ? 0f : 1f;
}
catch { collapseProgress = 1f; }
}
else
{
collapseProgress = 1f;
}
}
}
catch { }
Expand All @@ -88,10 +108,41 @@ private void OnThumbnailChanged(object? sender, MediaChangedEventArgs e)
// Adopt metadata immediately and ensure widget expanded when media exists
lock (mediaLock)
{
// If shared setting requests hiding media when idle, only expand when playback active
bool hideWhenIdle = false;
try { hideWhenIdle = RegisterSmallVisualiserWidgetSettings.SharedMediaSettings.HideMediaWhenIdle; } catch { hideWhenIdle = false; }

if (e.Media != null)
{
hasMedia = true;
BeginInvokeUI(() => StartCollapseOrExpand(true));

// If hideWhenIdle is enabled, determine expand state based on playback status and pause duration
if (hideWhenIdle)
{
try
{
var status = DynamicWin.Utils.MediaThumbnailService.Instance?.LastPlaybackStatus;
bool playing = status.HasValue && status.Value == Windows.Media.Control.GlobalSystemMediaTransportControlsSessionPlaybackStatus.Playing;

// If not playing, check if paused longer than 30 seconds
bool shouldExpand = playing;
if (!playing)
{
bool pausedLong = MediaThumbnailService.Instance.IsPausedLongerThan(TimeSpan.FromSeconds(30));
shouldExpand = !pausedLong;
}

BeginInvokeUI(() => StartCollapseOrExpand(shouldExpand));
}
catch
{
BeginInvokeUI(() => StartCollapseOrExpand(true));
}
}
else
{
BeginInvokeUI(() => StartCollapseOrExpand(true));
}
}
else
{
Expand Down Expand Up @@ -250,7 +301,7 @@ public override void Update(float deltaTime)
bool isPaused = false;
try
{
var status = DynamicWin.Utils.MediaThumbnailService.Instance?.LastPlaybackStatus;
var status = MediaThumbnailService.Instance?.LastPlaybackStatus;
if (status.HasValue)
{
isPaused = status.Value != Windows.Media.Control.GlobalSystemMediaTransportControlsSessionPlaybackStatus.Playing;
Expand Down Expand Up @@ -318,7 +369,7 @@ public override void Draw(SKCanvas canvas)
float flipScale = animator.GetFlipScale();
bool doFlip = animator.IsFlipping;

float thumbScale = 0.6f + 0.4f * thumbnailAnim;
float thumbScale = 0.8f + 0.2f * thumbnailAnim;
float dimAlpha = (1f - thumbnailAnim) * 120f;
float centerX = thumbRect.MidX;
float centerY = thumbRect.MidY;
Expand All @@ -333,9 +384,9 @@ public override void Draw(SKCanvas canvas)
var localRect = SKRect.Create(-thumbRect.Width / 2f, -thumbRect.Height / 2f, thumbRect.Width, thumbRect.Height);
var localPath = BuildSuperellipsePath(localRect, 7f, 1f);
canvas.Save();
canvas.ClipPath(localPath, antialias: true);
canvas.ClipPath(localPath, antialias: Settings.AntiAliasing);
var paint = GetPaint();
paint.IsAntialias = true;
paint.IsAntialias = Settings.AntiAliasing;
paint.ImageFilter = animator.BlurAmount > 0f ? SKImageFilter.CreateBlur(animator.BlurAmount, animator.BlurAmount) : null;
if (bmp != null)
{
Expand All @@ -361,9 +412,9 @@ public override void Draw(SKCanvas canvas)
canvas.Translate(centerX, centerY);
canvas.Scale(thumbScale, thumbScale);
canvas.Translate(-centerX, -centerY);
canvas.ClipPath(path, antialias: true);
canvas.ClipPath(path, antialias: Settings.AntiAliasing);
var paint = GetPaint();
paint.IsAntialias = true;
paint.IsAntialias = Settings.AntiAliasing;
paint.ImageFilter = animator.BlurAmount > 0f ? SKImageFilter.CreateBlur(animator.BlurAmount, animator.BlurAmount) : null;
if (bmp != null)
{
Expand Down
Loading
Loading