From d9369e2bbe5da214fba75623c3bab9dd1dfbc483 Mon Sep 17 00:00:00 2001 From: PingHsunTsai <47770211+PingHsunTsai@users.noreply.github.com> Date: Fri, 12 Jul 2024 17:40:59 +0200 Subject: [PATCH] add show_objshow_objectsetting and show_sceneform setter --- src/compas_viewer/ui/sidebar.py | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/compas_viewer/ui/sidebar.py b/src/compas_viewer/ui/sidebar.py index f29df4b3a..0fe5b52f8 100644 --- a/src/compas_viewer/ui/sidebar.py +++ b/src/compas_viewer/ui/sidebar.py @@ -19,7 +19,6 @@ def __init__(self, ui: "UI", show: bool, items: list[dict[str, Callable]]) -> No self.show = show self.hide_widget = True self.items = items - self.sceneform = None def add_items(self) -> None: if not self.items: @@ -32,13 +31,18 @@ def add_items(self) -> None: columns = item.get("columns", None) if columns is None: raise ValueError("Please setup config for Sceneform") - self.widget.addWidget(Sceneform(columns=columns)) + self.sceneform = Sceneform(columns=columns) + self.widget.addWidget(self.sceneform) elif itemtype == "ObjectSetting": items = item.get("items", None) if items is None: raise ValueError("Please setup config for ObjectSetting") - self.widget.addWidget(ObjectSetting(viewer=self.ui.viewer, items=items)) + self.object_setting = ObjectSetting(viewer=self.ui.viewer, items=items) + self.widget.addWidget(self.object_setting) + + self.show_sceneform = True + self.show_objectsetting = True def update(self): self.widget.update() @@ -51,7 +55,20 @@ def show(self): @show.setter def show(self, value: bool): - if value: - self.widget.setVisible(True) - elif not value: - self.widget.setHidden(True) + self.widget.setVisible(value) + + @property + def show_sceneform(self): + return self.sceneform.isVisible() + + @show_sceneform.setter + def show_sceneform(self, value: bool): + self.sceneform.setVisible(value) + + @property + def show_objectsetting(self): + return self.object_setting.isVisible() + + @show_objectsetting.setter + def show_objectsetting(self, value: bool): + self.object_setting.setVisible(value)