feat: custom panel category
This commit is contained in:
parent
4f02134b6c
commit
2e60bb985f
@ -20,11 +20,12 @@ import logging
|
|||||||
import bpy
|
import bpy
|
||||||
import string
|
import string
|
||||||
|
|
||||||
from . import utils, bl_types, environment, addon_updater_ops, presence
|
from . import utils, bl_types, environment, addon_updater_ops, presence, ui
|
||||||
from .libs.replication.replication.constants import RP_COMMON
|
from .libs.replication.replication.constants import RP_COMMON
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def randomColor():
|
def randomColor():
|
||||||
"""Generate a random color """
|
"""Generate a random color """
|
||||||
r = random.random()
|
r = random.random()
|
||||||
@ -39,6 +40,12 @@ def random_string_digits(stringLength=6):
|
|||||||
return ''.join(random.choices(lettersAndDigits, k=stringLength))
|
return ''.join(random.choices(lettersAndDigits, k=stringLength))
|
||||||
|
|
||||||
|
|
||||||
|
def update_panel_category(self, context):
|
||||||
|
ui.unregister()
|
||||||
|
ui.SESSION_PT_settings.bl_category = self.panel_category
|
||||||
|
ui.register()
|
||||||
|
|
||||||
|
|
||||||
class ReplicatedDatablock(bpy.types.PropertyGroup):
|
class ReplicatedDatablock(bpy.types.PropertyGroup):
|
||||||
type_name: bpy.props.StringProperty()
|
type_name: bpy.props.StringProperty()
|
||||||
bl_name: bpy.props.StringProperty()
|
bl_name: bpy.props.StringProperty()
|
||||||
@ -142,6 +149,11 @@ class SessionPrefs(bpy.types.AddonPreferences):
|
|||||||
description="cache",
|
description="cache",
|
||||||
default=False
|
default=False
|
||||||
)
|
)
|
||||||
|
conf_session_ui_expanded: bpy.props.BoolProperty(
|
||||||
|
name="Interface",
|
||||||
|
description="Interface",
|
||||||
|
default=False
|
||||||
|
)
|
||||||
|
|
||||||
auto_check_update: bpy.props.BoolProperty(
|
auto_check_update: bpy.props.BoolProperty(
|
||||||
name="Auto-check for Update",
|
name="Auto-check for Update",
|
||||||
@ -176,6 +188,12 @@ class SessionPrefs(bpy.types.AddonPreferences):
|
|||||||
max=59
|
max=59
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Custom panel
|
||||||
|
panel_category: bpy.props.StringProperty(
|
||||||
|
description="Choose a name for the category of the panel",
|
||||||
|
default="Multiuser",
|
||||||
|
update=update_panel_category)
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
|
|
||||||
@ -249,6 +267,15 @@ class SessionPrefs(bpy.types.AddonPreferences):
|
|||||||
if self.conf_session_cache_expanded:
|
if self.conf_session_cache_expanded:
|
||||||
box.row().prop(self, "cache_directory", text="Cache directory")
|
box.row().prop(self, "cache_directory", text="Cache directory")
|
||||||
|
|
||||||
|
# INTERFACE SETTINGS
|
||||||
|
box = grid.box()
|
||||||
|
box.prop(
|
||||||
|
self, "conf_session_ui_expanded", text="Interface",
|
||||||
|
icon='DISCLOSURE_TRI_DOWN' if self.conf_session_ui_expanded else 'DISCLOSURE_TRI_RIGHT',
|
||||||
|
emboss=False)
|
||||||
|
if self.conf_session_ui_expanded:
|
||||||
|
box.row().prop(self, "panel_category", text="Panel category", expand=True)
|
||||||
|
|
||||||
if self.category == 'UPDATE':
|
if self.category == 'UPDATE':
|
||||||
from . import addon_updater_ops
|
from . import addon_updater_ops
|
||||||
addon_updater_ops.update_settings_ui_condensed(self, context)
|
addon_updater_ops.update_settings_ui_condensed(self, context)
|
||||||
@ -353,6 +380,7 @@ class SessionProps(bpy.types.PropertyGroup):
|
|||||||
default=False
|
default=False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
SessionUser,
|
SessionUser,
|
||||||
SessionProps,
|
SessionProps,
|
||||||
|
@ -150,7 +150,6 @@ class SESSION_PT_settings_network(bpy.types.Panel):
|
|||||||
bl_label = "Network"
|
bl_label = "Network"
|
||||||
bl_space_type = 'VIEW_3D'
|
bl_space_type = 'VIEW_3D'
|
||||||
bl_region_type = 'UI'
|
bl_region_type = 'UI'
|
||||||
bl_category = "Multiuser"
|
|
||||||
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -199,7 +198,6 @@ class SESSION_PT_settings_user(bpy.types.Panel):
|
|||||||
bl_label = "User"
|
bl_label = "User"
|
||||||
bl_space_type = 'VIEW_3D'
|
bl_space_type = 'VIEW_3D'
|
||||||
bl_region_type = 'UI'
|
bl_region_type = 'UI'
|
||||||
bl_category = "Multiuser"
|
|
||||||
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -227,7 +225,6 @@ class SESSION_PT_settings_replication(bpy.types.Panel):
|
|||||||
bl_label = "Advanced"
|
bl_label = "Advanced"
|
||||||
bl_space_type = 'VIEW_3D'
|
bl_space_type = 'VIEW_3D'
|
||||||
bl_region_type = 'UI'
|
bl_region_type = 'UI'
|
||||||
bl_category = "Multiuser"
|
|
||||||
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
||||||
bl_options = {'DEFAULT_CLOSED'}
|
bl_options = {'DEFAULT_CLOSED'}
|
||||||
|
|
||||||
@ -276,7 +273,6 @@ class SESSION_PT_user(bpy.types.Panel):
|
|||||||
bl_label = "Online users"
|
bl_label = "Online users"
|
||||||
bl_space_type = 'VIEW_3D'
|
bl_space_type = 'VIEW_3D'
|
||||||
bl_region_type = 'UI'
|
bl_region_type = 'UI'
|
||||||
bl_category = "Multiuser"
|
|
||||||
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -355,7 +351,6 @@ class SESSION_PT_presence(bpy.types.Panel):
|
|||||||
bl_label = "Presence overlay"
|
bl_label = "Presence overlay"
|
||||||
bl_space_type = 'VIEW_3D'
|
bl_space_type = 'VIEW_3D'
|
||||||
bl_region_type = 'UI'
|
bl_region_type = 'UI'
|
||||||
bl_category = "Multiuser"
|
|
||||||
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
||||||
bl_options = {'DEFAULT_CLOSED'}
|
bl_options = {'DEFAULT_CLOSED'}
|
||||||
|
|
||||||
@ -385,7 +380,6 @@ class SESSION_PT_services(bpy.types.Panel):
|
|||||||
bl_label = "Services"
|
bl_label = "Services"
|
||||||
bl_space_type = 'VIEW_3D'
|
bl_space_type = 'VIEW_3D'
|
||||||
bl_region_type = 'UI'
|
bl_region_type = 'UI'
|
||||||
bl_category = "Multiuser"
|
|
||||||
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
||||||
bl_options = {'DEFAULT_CLOSED'}
|
bl_options = {'DEFAULT_CLOSED'}
|
||||||
|
|
||||||
@ -408,7 +402,6 @@ class SESSION_PT_services(bpy.types.Panel):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def draw_property(context, parent, property_uuid, level=0):
|
def draw_property(context, parent, property_uuid, level=0):
|
||||||
settings = utils.get_preferences()
|
settings = utils.get_preferences()
|
||||||
runtime_settings = context.window_manager.session
|
runtime_settings = context.window_manager.session
|
||||||
@ -477,7 +470,7 @@ class SESSION_PT_outliner(bpy.types.Panel):
|
|||||||
bl_label = "Properties"
|
bl_label = "Properties"
|
||||||
bl_space_type = 'VIEW_3D'
|
bl_space_type = 'VIEW_3D'
|
||||||
bl_region_type = 'UI'
|
bl_region_type = 'UI'
|
||||||
bl_category = "Multiuser"
|
bl_parent_id = 'MULTIUSER_SETTINGS_PT_panel'
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
@ -537,8 +530,9 @@ classes = (
|
|||||||
SESSION_PT_presence,
|
SESSION_PT_presence,
|
||||||
SESSION_PT_settings_replication,
|
SESSION_PT_settings_replication,
|
||||||
SESSION_PT_user,
|
SESSION_PT_user,
|
||||||
|
SESSION_PT_services,
|
||||||
SESSION_PT_outliner,
|
SESSION_PT_outliner,
|
||||||
SESSION_PT_services
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user