Merge branch '134-revamp-session-status-ui-widget' into 'develop'
Resolve "Revamp session status UI widget" See merge request slumber/multi-user!67
This commit is contained in:
commit
3573db0969
@ -238,6 +238,31 @@ class SessionPrefs(bpy.types.AddonPreferences):
|
||||
set=set_log_level,
|
||||
get=get_log_level
|
||||
)
|
||||
presence_hud_scale: bpy.props.FloatProperty(
|
||||
name="Text scale",
|
||||
description="Adjust the session widget text scale",
|
||||
min=7,
|
||||
max=90,
|
||||
default=15,
|
||||
)
|
||||
presence_hud_hpos: bpy.props.FloatProperty(
|
||||
name="Horizontal position",
|
||||
description="Adjust the session widget horizontal position",
|
||||
min=1,
|
||||
max=90,
|
||||
default=10,
|
||||
step=1,
|
||||
subtype='PERCENTAGE',
|
||||
)
|
||||
presence_hud_vpos: bpy.props.FloatProperty(
|
||||
name="Vertical position",
|
||||
description="Adjust the session widget vertical position",
|
||||
min=1,
|
||||
max=94,
|
||||
default=10,
|
||||
step=1,
|
||||
subtype='PERCENTAGE',
|
||||
)
|
||||
conf_session_identity_expanded: bpy.props.BoolProperty(
|
||||
name="Identity",
|
||||
description="Identity",
|
||||
@ -412,6 +437,15 @@ class SessionPrefs(bpy.types.AddonPreferences):
|
||||
emboss=False)
|
||||
if self.conf_session_ui_expanded:
|
||||
box.row().prop(self, "panel_category", text="Panel category", expand=True)
|
||||
row = box.row()
|
||||
row.label(text="Session widget:")
|
||||
|
||||
col = box.column(align=True)
|
||||
col.prop(self, "presence_hud_scale", expand=True)
|
||||
|
||||
|
||||
col.prop(self, "presence_hud_hpos", expand=True)
|
||||
col.prop(self, "presence_hud_vpos", expand=True)
|
||||
|
||||
if self.category == 'UPDATE':
|
||||
from . import addon_updater_ops
|
||||
|
@ -35,7 +35,7 @@ from replication.constants import (STATE_ACTIVE, STATE_AUTH, STATE_CONFIG,
|
||||
STATE_SYNCING, STATE_WAITING)
|
||||
from replication.interface import session
|
||||
|
||||
from .utils import find_from_attr, get_state_str
|
||||
from .utils import find_from_attr, get_state_str, get_preferences
|
||||
|
||||
# Helper functions
|
||||
|
||||
@ -384,6 +384,9 @@ class UserNameWidget(Widget):
|
||||
class SessionStatusWidget(Widget):
|
||||
draw_type = 'POST_PIXEL'
|
||||
|
||||
def __init__(self):
|
||||
self.preferences = get_preferences()
|
||||
|
||||
@property
|
||||
def settings(self):
|
||||
return getattr(bpy.context.window_manager, 'session', None)
|
||||
@ -393,6 +396,8 @@ class SessionStatusWidget(Widget):
|
||||
self.settings.enable_presence
|
||||
|
||||
def draw(self):
|
||||
text_scale = self.preferences.presence_hud_scale
|
||||
ui_scale = bpy.context.preferences.view.ui_scale
|
||||
color = [1, 1, 0, 1]
|
||||
state = session.state.get('STATE')
|
||||
state_str = f"{get_state_str(state)}"
|
||||
@ -401,9 +406,11 @@ class SessionStatusWidget(Widget):
|
||||
color = [0, 1, 0, 1]
|
||||
elif state == STATE_INITIAL:
|
||||
color = [1, 0, 0, 1]
|
||||
hpos = (self.preferences.presence_hud_hpos*bpy.context.area.width)/100
|
||||
vpos = (self.preferences.presence_hud_vpos*bpy.context.area.height)/100
|
||||
|
||||
blf.position(0, 10, 20, 0)
|
||||
blf.size(0, 16, 45)
|
||||
blf.position(0, hpos, vpos, 0)
|
||||
blf.size(0, int(text_scale*ui_scale), 72)
|
||||
blf.color(0, color[0], color[1], color[2], color[3])
|
||||
blf.draw(0, state_str)
|
||||
|
||||
|
@ -448,9 +448,17 @@ class SESSION_PT_presence(bpy.types.Panel):
|
||||
layout = self.layout
|
||||
|
||||
settings = context.window_manager.session
|
||||
pref = get_preferences()
|
||||
layout.active = settings.enable_presence
|
||||
col = layout.column()
|
||||
col.prop(settings, "presence_show_session_status")
|
||||
row = col.column()
|
||||
row.active = settings.presence_show_session_status
|
||||
row.prop(pref, "presence_hud_scale", expand=True)
|
||||
row = col.column(align=True)
|
||||
row.active = settings.presence_show_session_status
|
||||
row.prop(pref, "presence_hud_hpos", expand=True)
|
||||
row.prop(pref, "presence_hud_vpos", expand=True)
|
||||
col.prop(settings, "presence_show_selected")
|
||||
col.prop(settings, "presence_show_user")
|
||||
row = layout.column()
|
||||
@ -622,7 +630,7 @@ class VIEW3D_PT_overlay_session(bpy.types.Panel):
|
||||
col.prop(settings, "presence_show_session_status")
|
||||
col.prop(settings, "presence_show_selected")
|
||||
col.prop(settings, "presence_show_user")
|
||||
|
||||
|
||||
row = layout.column()
|
||||
row.active = settings.presence_show_user
|
||||
row.prop(settings, "presence_show_far_user")
|
||||
|
Loading…
Reference in New Issue
Block a user