diff --git a/src/gui_2.py b/src/gui_2.py index b800898..1884ce9 100644 --- a/src/gui_2.py +++ b/src/gui_2.py @@ -914,15 +914,9 @@ class App: if self.show_windows.get("Project Settings", False): with imscope.window("Project Settings", self.show_windows["Project Settings"]) as (exp, opened): self.show_windows["Project Settings"] = bool(opened) - if exp: - if imgui.begin_tab_bar('context_hub_tabs'): - if imgui.begin_tab_item('Projects')[0]: - self._render_projects_panel() - imgui.end_tab_item() - if imgui.begin_tab_item('Paths')[0]: - self._render_paths_panel() - imgui.end_tab_item() - imgui.end_tab_bar() + if exp and imscope.tab_bar('context_hub_tabs'): + if imscope.tab_item('Projects'): self._render_projects_panel() + if imscope.tab_item('Paths'): self._render_paths_panel() #endregion: Project Settings #region: Files & Media window diff --git a/src/imgui_scopes.py b/src/imgui_scopes.py index b58db45..990d8a5 100644 --- a/src/imgui_scopes.py +++ b/src/imgui_scopes.py @@ -114,3 +114,28 @@ class _ScopeId: def __exit__(self, *args): imgui.pop_id() return False + +def tab_bar(id_str: str, flags: int = 0): return _ScopeTabBar(id_str, flags) +class _ScopeTabBar: + def __init__(self, id_str: str, flags: int): + self._id = id_str + self._flags = flags + def __enter__(self): + return imgui.begin_tab_bar(self._id, self._flags) + def __exit__(self, *args): + imgui.end_tab_bar() + return False + +def tab_item(label: str, flags: int = 0): return _ScopeTabItem(label, flags) +class _ScopeTabItem: + def __init__(self, label: str, flags: int): + self._label = label + self._flags = flags + self._open = None + def __enter__(self): + self._open = imgui.begin_tab_item(self._label, self._flags) + return self._open + def __exit__(self, *args): + if self._open[0]: + imgui.end_tab_item() + return False