Skip to content

Commit

Permalink
feat: add an option to toggle the sidebar / N-panel
Browse files Browse the repository at this point in the history
  • Loading branch information
tristan-hm committed Jun 16, 2022
1 parent 7f4892f commit 0799e0b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
10 changes: 8 additions & 2 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"]]

Expand Down Expand Up @@ -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()

Expand Down
21 changes: 12 additions & 9 deletions interface/main_ui_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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

0 comments on commit 0799e0b

Please sign in to comment.