background_plane_manager/preferences.py

66 lines
2.0 KiB
Python
Raw Normal View History

2023-09-28 11:34:41 +02:00
# SPDX-License-Identifier: GPL-2.0-or-later
import bpy
from pathlib import Path
from shutil import which
from bpy.props import (FloatProperty,
BoolProperty,
EnumProperty,
StringProperty,
IntProperty,
PointerProperty)
def ui_in_sidebar_update(self, _):
from .ui.panels import BPM_PT_bg_manager_panel
if hasattr(bpy.types, BPM_PT_bg_manager_panel.bl_idname):
try:
bpy.utils.unregister_class(BPM_PT_bg_manager_panel)
except:
pass
BPM_PT_bg_manager_panel.bl_category = self.category.strip()
bpy.utils.register_class(BPM_PT_bg_manager_panel)
class BPM_prefs(bpy.types.AddonPreferences):
bl_idname = __name__.split('.')[0] # or __package__
category : StringProperty(
name="Category",
description="Choose a name for the sidebar category tab",
default="View",
update=ui_in_sidebar_update)
## Object settings
edit_line_opacity : FloatProperty(
name='Default Edit Line Opacity',
description="Edit line opacity for newly created objects\
\nAdvanced users generally like it at 0 (show only selected line in edit mode)\
\nBlender default is 0.5",
default=0.0, min=0.0, max=1.0)
use_light : BoolProperty(
name='Use light',
description="Use light or not for newly created objects",
default=False)
def draw(self, context):
layout = self.layout
layout.use_property_split = True
layout.prop(self, 'category')
layout.label(text='Object Settings:', icon='GREASEPENCIL')
layout.label(text='Properties of newly created Grease pencil object:')
layout.prop(self, 'edit_line_opacity')
layout.prop(self, 'use_light')
### --- REGISTER ---
def register():
bpy.utils.register_class(BPM_prefs)
def unregister():
bpy.utils.unregister_class(BPM_prefs)