]> git.mar77i.info Git - zenbook_conf/commitdiff
vectors.X.draw() takes color for the second arg, not pos. add icon and window title
authormar77i <mar77i@protonmail.ch>
Thu, 26 Dec 2024 19:11:35 +0000 (20:11 +0100)
committermar77i <mar77i@protonmail.ch>
Thu, 26 Dec 2024 19:11:35 +0000 (20:11 +0100)
vectors.py
zenbook_conf.py

index 55a024c46597948c77df4e704d4e0fae54c0ef1e..6db406ef76f1998554167a653afff4e56648c239 100644 (file)
@@ -189,9 +189,6 @@ class StrokeRoundLine(Polygon):
             self.width * max(unit),
         )
 
-    def draw(self, surf, pos):
-        super().draw(surf, pos)
-
 
 class Shapes(Shape):
     def __init__(self, shapes):
@@ -202,9 +199,9 @@ class Shapes(Shape):
             raise NotImplementedError
         return Shapes([s.fit(pos, unit) for s in self.shapes])
 
-    def draw(self, surf, pos):
+    def draw(self, surf, color):
         for shape in self.shapes:
-            shape.draw(surf, pos)
+            shape.draw(surf, color)
 
 
 class StrokePath:
@@ -270,9 +267,6 @@ class StrokeCircle(StrokePath):
             self.width * max(unit),
         )
 
-    def draw(self, surf, pos):
-        super().draw(surf, pos)
-
 
 class StrokeCircleSegment(StrokeCircle):
     def __init__(self, center, radius, start_angle, end_angle, width):
index 8a399835a8e96692e67478dc13d2a8332b97976a..8460cd0ebbcca72eb55fabf50c3d5631c2253466 100755 (executable)
@@ -47,8 +47,11 @@ class ZenbookConf(FPSMixin, UIParent):
 
     def __init__(self):
         pygame.init()
+        pygame.display.set_icon(self.get_icon())
+        pygame.display.set_caption("Zenbook Config")
+        window_size = (1536, 1200)
         super().__init__(
-            pygame.display.set_mode((1536, 1200)), pygame.font.Font(None, size=96),
+            pygame.display.set_mode(window_size), pygame.font.Font(None, size=96),
         )
         self.xrandr_conf = XrandrConf()
         self.xinput_conf = XinputConf(self.xrandr_conf)
@@ -143,9 +146,22 @@ class ZenbookConf(FPSMixin, UIParent):
                     "Re-apply",
                     partial(self.xinput_conf.reapply_by_type, "stylus")
                 ),
+                Button(
+                    self,
+                    pygame.Rect((window_size[0] - 128, 0), (128, 64)),
+                    "×",
+                    self.quit,
+                ),
             )
         )
 
+    def get_icon(self):
+        surf = pygame.Surface((512, 512), pygame.SRCALPHA, 32)
+        surf.fill(0x0)
+        v = 512 // 22
+        laptop_single.fit((0, 0), (v, v)).draw(surf, "white")
+        return pygame.transform.scale(surf, (32, 32))
+
     def laptop_cb(self, name, bt_switch, touch_switch, stylus_switch):
         self.xrandr_conf.update(name)
         if name != "single":
@@ -163,6 +179,9 @@ class ZenbookConf(FPSMixin, UIParent):
     def laptop_is_active(self, name):
         return self.xrandr_conf.is_active(name)
 
+    def quit(self):
+        self.running = False
+
 
 if __name__ == "__main__":
     ZenbookConf().run()