Skip to content

Commit

Permalink
Set lower ordered notifications content opacity to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikReider committed Dec 12, 2023
1 parent 216522e commit fc73f1a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/notificationGroup/notificationGroup.vala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace SwayNotificationCenter {
public class NotificationGroup : Gtk.ListBoxRow {
const string STYLE_CLASS_URGENT = "critical";
const string STYLE_CLASS_COLLAPSED = "collapsed";

public string name_id;

Expand Down Expand Up @@ -89,7 +90,13 @@ namespace SwayNotificationCenter {

group = new ExpandableGroup (Constants.ANIMATION_DURATION, (state) => {
revealer.set_reveal_child (state);

// Change CSS Class
if (parent != null) {
set_classes ();
}
});
set_classes ();
box.add (group);
add (box);

Expand Down Expand Up @@ -146,6 +153,16 @@ namespace SwayNotificationCenter {
});
}

private void set_classes () {
unowned Gtk.StyleContext ctx = get_style_context ();
ctx.remove_class (STYLE_CLASS_COLLAPSED);
if (!group.is_expanded) {
if (!ctx.has_class (STYLE_CLASS_COLLAPSED)) {
ctx.add_class (STYLE_CLASS_COLLAPSED);
}
}
}

/// Returns if there's more than one notification
public bool only_single_notification () {
unowned Gtk.Widget ? widget = group.widgets.nth_data (1);
Expand Down Expand Up @@ -255,7 +272,7 @@ namespace SwayNotificationCenter {

private class ExpandableGroup : Gtk.Container {
const int NUM_STACKED_NOTIFICATIONS = 3;
const int COLLAPSED_NOTIFICATION_OFFSET = 6;
const int COLLAPSED_NOTIFICATION_OFFSET = 8;

public bool is_expanded { get; private set; default = true; }

Expand Down
7 changes: 7 additions & 0 deletions src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
.notification-group {
}

/* Set lower stacked notifications opacity to 0 */
.notification-group.collapsed .notification-row:not(:last-child) .notification-action *,
.notification-group.collapsed .notification-row:not(:last-child) .notification-default-action * {
transition: opacity 400ms ease-in-out;
opacity: 0;
}

.notification-group-buttons,
.notification-group-headers {
margin: 0 16px;
Expand Down

0 comments on commit fc73f1a

Please sign in to comment.