Make it functional

This commit is contained in:
pancakes 2025-08-26 15:23:49 +10:00
parent 0fbf4aa619
commit 8e063f09e7
Signed by: pancakes
SSH key fingerprint: SHA256:yrp4c4hhaPoPG07fb4QyQIgAdlbUdsJvUAydJEWnfTw
3 changed files with 69 additions and 4 deletions

View file

@ -15,4 +15,10 @@
<ProjectReference Include="..\ZwlrLayerShell\ZwlrLayerShell\ZwlrLayerShell.csproj" /> <ProjectReference Include="..\ZwlrLayerShell\ZwlrLayerShell\ZwlrLayerShell.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Content Include="style.css">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project> </Project>

View file

@ -1,8 +1,12 @@
using Gio; using Gdk;
using Gio;
using GLib; using GLib;
using Gtk; using Gtk;
using Pango;
using ZwlrLayerShell; using ZwlrLayerShell;
using Application = Gtk.Application; using Application = Gtk.Application;
using TimeSpan = System.TimeSpan;
using Variant = GLib.Variant;
if (!LayerShell.IsSupported()) if (!LayerShell.IsSupported())
{ {
@ -40,11 +44,14 @@ application.OnActivate += (sender, eventArgs) =>
LayerShell.SetNamespace(window, "deltatune-wls"); LayerShell.SetNamespace(window, "deltatune-wls");
LayerShell.SetLayer(window, Layer.Top); LayerShell.SetLayer(window, Layer.Top);
LayerShell.SetAnchor(window, Edge.Left, true); LayerShell.SetAnchor(window, Edge.Left, true);
LayerShell.SetAnchor(window, Edge.Right, true);
LayerShell.SetAnchor(window, Edge.Top, true); LayerShell.SetAnchor(window, Edge.Top, true);
LayerShell.SetMargin(window, 15); LayerShell.SetMargin(window, 15);
LayerShell.SetMargin(window, Edge.Left, 55);
var label = Label.New(null); var label = Label.New(null);
label.Halign = Align.Start; label.Halign = Align.Start;
label.Ellipsize = EllipsizeMode.End;
window.SetChild(label); window.SetChild(label);
@ -59,7 +66,15 @@ application.OnActivate += (sender, eventArgs) =>
if (newTitle != title) if (newTitle != title)
{ {
simpleAction.SetState(signalArgs.Parameter); simpleAction.SetState(signalArgs.Parameter);
label.SetLabel($"♪ - {newTitle}"); label.SetLabel($"♪ ~ {newTitle}");
if (!label.HasCssClass("fade-in"))
{
label.AddCssClass("fade-in");
GLib.Functions.TimeoutAddSeconds(GLib.Constants.PRIORITY_DEFAULT, 9, () => {
label.RemoveCssClass("fade-in");
return false;
});
}
} }
}; };
window.AddAction(action); window.AddAction(action);
@ -67,4 +82,9 @@ application.OnActivate += (sender, eventArgs) =>
window.Present(); window.Present();
}; };
var css = CssProvider.New();
css.LoadFromPath("style.css");
StyleContext.AddProviderForDisplay(Display.GetDefault()!, css,
Gtk.Constants.STYLE_PROVIDER_PRIORITY_APPLICATION);
return application.RunWithSynchronizationContext(null); return application.RunWithSynchronizationContext(null);

39
DeltatuneWls/style.css Normal file
View file

@ -0,0 +1,39 @@
window {
background-color: transparent;
}
window label {
font-size: x-large;
color: white;
text-shadow: -1px -1px 0 #15249a, 1px -1px 0 #15249a, -1px 1px 0 #15249a, 1px 1px 0 #15249a;;
opacity: 0;
}
.fade-in {
animation: 8s fade-in ease-in-out both;
}
@keyframes fade-in {
0% {
transform: translateX(80px);
opacity: 0;
}
5% {
transform: translateX(50px);
opacity: 1;
}
80% {
opacity: 1;
}
85% {
transform: translateX(50px);
}
100% {
transform: translateX(0);
opacity: 0;
}
}