From 0799e0b6608df8eeacd47beb325297b0e52a8821 Mon Sep 17 00:00:00 2001 From: Tristan Strathearn Date: Thu, 16 Jun 2022 11:49:23 +1000 Subject: [PATCH] feat: add an option to toggle the sidebar / N-panel --- __init__.py | 10 ++++++++-- interface/main_ui_panel.py | 21 ++++++++++++--------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/__init__.py b/__init__.py index 7a3cca8..e341b7f 100644 --- a/__init__.py +++ b/__init__.py @@ -107,6 +107,11 @@ class NDPreferences(AddonPreferences): default=True, ) + enable_sidebar: BoolProperty( + name="Enable the sidebar / N-panel (requires restart)", + default=True, + ) + enable_axis_helper: BoolProperty( name="Enable Axis Visualization", default=True, @@ -386,6 +391,7 @@ def draw_ui(self, box): ["mouse_value_scalar"], ["enable_quick_favourites"], ["lock_overlay_pinning"], + ["enable_sidebar"], ["enable_axis_helper"], ["axis_base_thickness", "axis_active_thickness", "axis_inactive_opacity"]] @@ -460,12 +466,12 @@ def draw_theme(self, box): def register(): lib.reload() + bpy.utils.register_class(NDPreferences) + for registerable in registerables: registerable.reload() registerable.register() - bpy.utils.register_class(NDPreferences) - version = '.'.join([str(v) for v in bl_info['version']]) prefs = lib.preferences.get_preferences() diff --git a/interface/main_ui_panel.py b/interface/main_ui_panel.py index dcefde0..f8e0272 100644 --- a/interface/main_ui_panel.py +++ b/interface/main_ui_panel.py @@ -24,6 +24,7 @@ from .. import lib from . import ops from . common import create_box, render_ops, web_link +from .. lib.preferences import get_preferences links = [ @@ -136,16 +137,18 @@ def draw(self, context): def register(): - bpy.utils.register_class(ND_PT_main_ui_panel) - bpy.utils.register_class(ND_OT_toggle_sections) - bpy.utils.register_class(MainUIPanelProps) + if get_preferences().enable_sidebar: + bpy.utils.register_class(ND_PT_main_ui_panel) + bpy.utils.register_class(ND_OT_toggle_sections) + bpy.utils.register_class(MainUIPanelProps) - bpy.types.WindowManager.nd_panel_props = PointerProperty(type=MainUIPanelProps) + bpy.types.WindowManager.nd_panel_props = PointerProperty(type=MainUIPanelProps) def unregister(): - bpy.utils.unregister_class(ND_PT_main_ui_panel) - bpy.utils.unregister_class(ND_OT_toggle_sections) - bpy.utils.unregister_class(MainUIPanelProps) - - del bpy.types.WindowManager.nd_panel_props + if get_preferences().enable_sidebar: + bpy.utils.unregister_class(ND_PT_main_ui_panel) + bpy.utils.unregister_class(ND_OT_toggle_sections) + bpy.utils.unregister_class(MainUIPanelProps) + + del bpy.types.WindowManager.nd_panel_props