Skip to content

Commit

Permalink
add show_objshow_objectsetting and show_sceneform setter
Browse files Browse the repository at this point in the history
  • Loading branch information
PingHsunTsai committed Jul 12, 2024
1 parent 8cf9b70 commit d9369e2
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions src/compas_viewer/ui/sidebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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()
Expand All @@ -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)

0 comments on commit d9369e2

Please sign in to comment.