From 8dd1656fc2e3fce6c83bcdf376f5c789abdf91e6 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Fri, 1 Aug 2025 09:57:52 +0545 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(notification):=20?= =?UTF-8?q?improve=20notification=20animation=20and=20limit=20count?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../icons/applets/network-wired-offline.svg | 30 +++++++++++++++++++ config/assets/icons/applets/network-wired.svg | 4 +++ modules/notification.py | 16 ++++++++-- modules/panel/components/indicators.py | 8 ++--- widgets/customrevealer.py | 17 ++++++----- 5 files changed, 61 insertions(+), 14 deletions(-) create mode 100644 config/assets/icons/applets/network-wired-offline.svg create mode 100644 config/assets/icons/applets/network-wired.svg diff --git a/config/assets/icons/applets/network-wired-offline.svg b/config/assets/icons/applets/network-wired-offline.svg new file mode 100644 index 0000000..391a3de --- /dev/null +++ b/config/assets/icons/applets/network-wired-offline.svg @@ -0,0 +1,30 @@ + + + + + + image/svg+xml + + + + + + + + diff --git a/config/assets/icons/applets/network-wired.svg b/config/assets/icons/applets/network-wired.svg new file mode 100644 index 0000000..bde1145 --- /dev/null +++ b/config/assets/icons/applets/network-wired.svg @@ -0,0 +1,4 @@ + + + + diff --git a/modules/notification.py b/modules/notification.py index 9bbb755..b7ec033 100644 --- a/modules/notification.py +++ b/modules/notification.py @@ -28,7 +28,7 @@ NOTIFICATION_IMAGE_SIZE = 48 # Improved animation smoothness and consistent behavior for rapid notifications. -def smooth_revealer_animation(revealer: SlideRevealer, duration: int = 250): +def smooth_revealer_animation(revealer: SlideRevealer, duration: int = 600): revealer.duration = duration @@ -207,7 +207,7 @@ class NotificationRevealer(SlideRevealer): super().__init__( child=self.event_box, direction="right", - duration=250, + duration=600, ) smooth_revealer_animation(self) @@ -283,6 +283,7 @@ class ModusNoti(Window): self.notifications = Box( v_expand=True, h_expand=True, + title="Notification Center", style="margin: 1px 0px 1px 1px;", orientation="v", spacing=5, @@ -317,8 +318,17 @@ class ModusNoti(Window): current_children.insert(0, new_box) self.notifications.children = current_children - # This ensures each notification's container is fully laid out before animation + + if len(current_children) >= 4: + # Animate close for the oldest notification if we exceed the limit + oldest_notification = current_children[-1] + if hasattr(oldest_notification, 'notification'): + # Trigger the close animation by closing the underlying notification + # This will use the same slide animation as auto-dismiss (left-to-right) + oldest_notification.notification.close("expired") + current_children.pop() + def start_animation(): if new_box.get_parent(): # Only animate if still in the tree new_box.reveal() diff --git a/modules/panel/components/indicators.py b/modules/panel/components/indicators.py index 68dab62..e4d9ee9 100644 --- a/modules/panel/components/indicators.py +++ b/modules/panel/components/indicators.py @@ -15,7 +15,7 @@ class BluetoothIndicator(Box): self.bluetooth = BluetoothClient() self.bt_icon = Svg( name="bt-icon", - size=20, + size=25, svg_file=get_relative_path( "../../../config/assets/icons/applets/bluetooth-clear.svg" ), @@ -211,15 +211,15 @@ class NetworkIndicator(Box): elif primary_device == "wired" and self.network_service.ethernet_device: ethernet = self.network_service.ethernet_device if ethernet.internet == "activated": - icon_file = "ethernet.svg" + icon_file = "network-wired.svg" tooltip = "Ethernet connected" if hasattr(ethernet, "speed") and ethernet.speed > 0: tooltip += f" ({ethernet.speed} Mbps)" elif ethernet.internet == "activating": - icon_file = "wifi-clear.svg" + icon_file = "network-wired.svg" tooltip = "Ethernet connecting..." else: - icon_file = "wifi-off-clear.svg" + icon_file = "network-wired-offline.svg" tooltip = "Ethernet disconnected" self.network_icon.set_from_file( diff --git a/widgets/customrevealer.py b/widgets/customrevealer.py index eb289ba..9576137 100644 --- a/widgets/customrevealer.py +++ b/widgets/customrevealer.py @@ -63,13 +63,15 @@ class AnimationManager: """Calculate optimal frame interval based on widget count""" widget_count = len(self._animating_widgets) if widget_count <= 1: - return 22 # 45 FPS for single widget - elif widget_count <= 3: - return 33 # 30 FPS for 2-3 widgets + return 16 # 60 FPS + elif widget_count <= 2: + return 16 # 60 FPS + elif widget_count <= 4: + return 22 # 45 FPS elif widget_count <= 6: - return 50 # 20 FPS for 4-6 widgets + return 33 # 30 FPS else: - return 67 # 15 FPS for 7+ widgets + return 50 # 20 FPS def _start_timer(self): interval = self._get_optimal_interval() @@ -166,9 +168,10 @@ class SlideRevealer(Gtk.Overlay): t = min(elapsed / self.duration, 1.0) if self._show_animation: - eased = 1 - (1 - t) ** 3 # Inline ease_out_cubic + # Ease out quadratic (no bounce/overshoot) + eased = 1 - (1 - t) ** 2 else: - eased = t**3 # Ease in cubic for hide animation + eased = t**2 # Ease in quadratic for hide animation self._pending_position = self._get_position_at_progress_cached(eased)