]> skyeroc.xyz Git - obs-ctl/commitdiff
add "warning" property to BoolControl
authorsbkelley <sb24kelley@gmail.com>
Sun, 7 Dec 2025 19:37:20 +0000 (14:37 -0500)
committersbkelley <sb24kelley@gmail.com>
Sun, 7 Dec 2025 19:37:20 +0000 (14:37 -0500)
src/obs_ctl/interface/element/bool_control.py

index d65b3b5447703cfa5dc516695556f7330b4219ab..b3e5b56479d2bcc307df93b0cdbabd193e817b19 100644 (file)
@@ -40,11 +40,20 @@ class BoolControl(containers.Container):
         bool_control--buttonbox (Center)
     """
     DEFAULT_CSS = """
-        RadioButton {
-            min-width:16 !important;
-            text-align:center !important;
+        .bool_control--light{
+            min-width:16;
+            text-align: center;
+        }
+        .-warning {
+            # background:$warning;
+            .bool_control--light{
+                .toggle--button {
+                    color:$text-warning;
+                }
+            }
         }
     """
+
     COMPONENT_CLASSES = {
         "bool_control--light",
         "bool_control--true_button",
@@ -53,6 +62,8 @@ class BoolControl(containers.Container):
         "bool_control--light_box",
         "bool_control--buttons_box",
     }
+    warning: reactive[bool] = reactive(False)
+    """Updates color from whatever it is to yellow"""
     value: reactive[bool] = reactive(False)
     """Updates the control's value; turns on or off the light."""
     label: reactive[str] = reactive("Status")
@@ -148,12 +159,16 @@ class BoolControl(containers.Container):
 
 
     @on(Button.Pressed, "#false")
-    def false_pressed(self, event: Button.Pressed):
+    def false_pressed(self, event: Button.Pressed, _debug=False):
+        if _debug:
+            self.value = False
         self.post_message(self.SetFalse(self))
 
 
     @on(Button.Pressed, "#true")
-    def true_pressed(self, event: Button.Pressed):
+    def true_pressed(self, event: Button.Pressed, _debug=False):
+        if _debug:
+            self.value = True
         self.post_message(self.SetTrue(self))
 
 
@@ -191,6 +206,9 @@ class BoolControl(containers.Container):
         light.compact = value
         true.compact = value
         false.compact = value
+    
+    def watch_warning(self, value: bool):
+        self.set_class(value, "-warning")
 
     def get_true_button(self):
         return typing.cast(Button, self.query_exactly_one("#true"))