]> git.mar77i.info Git - zenbook_conf/commitdiff
move FPSMixin to ui.py
authormar77i <mar77i@protonmail.ch>
Thu, 26 Dec 2024 19:36:15 +0000 (20:36 +0100)
committermar77i <mar77i@protonmail.ch>
Thu, 26 Dec 2024 19:36:15 +0000 (20:36 +0100)
ui.py
zenbook_conf.py

diff --git a/ui.py b/ui.py
index 0f0a9d5ed045ed8583f39b239d2f31aaadc56b9e..6a3715dda5ba0eb48e1fd5c096354e4194a8c097 100644 (file)
--- a/ui.py
+++ b/ui.py
@@ -61,6 +61,30 @@ class UIParent:
             self.clock.tick(60)
 
 
+class FPSMixin:
+    FPS_COLOR = "yellow"
+
+    def __init__(self, *args, **kwargs):
+        super().__init__(*args, **kwargs)
+        self.current_fps = None
+
+    def update(self):
+        super().update()
+        new_fps = int(self.clock.get_fps())
+        if self.current_fps != new_fps:
+            self.current_fps = new_fps
+            self.dirty = True
+
+    def draw(self):
+        super().draw()
+        surf_size = self.surf.get_size()
+        fs = self.font.render(f"{int(self.current_fps)} FPS", True, self.FPS_COLOR)
+        fs_size = fs.get_size()
+        self.surf.blit(
+            fs, (surf_size[0] - fs_size[0] - 7, surf_size[1] - fs_size[1] - 7)
+        )
+
+
 class UIChild:
     def __init__(self, parent):
         self.parent = parent
index 8460cd0ebbcca72eb55fabf50c3d5631c2253466..56a262be182d3510b09a48e7d299f45145b0447c 100755 (executable)
@@ -5,7 +5,7 @@ from functools import partial
 import pygame
 
 from bluetooth import BluetoothConf
-from ui import Button, Icon, IconButton, Switch, UIParent
+from ui import Button, FPSMixin, Icon, IconButton, Switch, UIParent
 from vector_assets import (
     bluetooth,
     laptop_double,
@@ -18,30 +18,6 @@ from xinput import XinputConf
 from xrandr import XrandrConf
 
 
-class FPSMixin:
-    FPS_COLOR = "yellow"
-
-    def __init__(self, *args, **kwargs):
-        super().__init__(*args, **kwargs)
-        self.current_fps = None
-
-    def update(self):
-        super().update()
-        new_fps = int(self.clock.get_fps())
-        if self.current_fps != new_fps:
-            self.current_fps = new_fps
-            self.dirty = True
-
-    def draw(self):
-        super().draw()
-        surf_size = self.surf.get_size()
-        fs = self.font.render(f"{int(self.current_fps)} FPS", True, self.FPS_COLOR)
-        fs_size = fs.get_size()
-        self.surf.blit(
-            fs, (surf_size[0] - fs_size[0] - 7, surf_size[1] - fs_size[1] - 7)
-        )
-
-
 class ZenbookConf(FPSMixin, UIParent):
     BACKGROUND_COLOR = 0x333333