Skip to content

Commit

Permalink
feat: users list of the selected room now has its own panel
Browse files Browse the repository at this point in the history
  • Loading branch information
jatubi committed Apr 15, 2021
1 parent 3a0299d commit cdb8d16
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 18 deletions.
44 changes: 27 additions & 17 deletions mixer/bl_panels.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ def redraw_if(condition: bool):

def update_ui_lists():
update_room_list(do_redraw=False)
props = get_mixer_props()
if len(props.rooms):
if props.room_index >= len(props.rooms):
props.room_index = max(0, len(props.rooms) - 1)
else:
props.room_index = 0
update_user_list()


Expand Down Expand Up @@ -538,6 +544,27 @@ def user_belongs_to_selected_room(user: UserItem):
return user.room == mixer_props.rooms[mixer_props.room_index].name
return False

layout.separator(factor=0.5)
# row = box.row()
# row.separator(factor=2)
collapsable_panel(layout, mixer_prefs, "users_list_panel_opened", text="Users in the Room")
if mixer_prefs.users_list_panel_opened:
box = layout.box()
col = box.column()

users_in_room = [user for user in mixer_props.users if user_belongs_to_selected_room(user)]

if not len(users_in_room):
col.label(text="No users in the room")
else:
for user in users_in_room:
user_split = col.split()
sub_row = user_split.row()
user_sub_split = sub_row.split(factor=0.8)
user_sub_split.label(text=f"{user.name}", icon="USER" if user.is_me else "BLANK1")
user_sub_split.prop(user, "color", text="")
sub_row.label(text=f"{user.ip_port}")

layout.separator(factor=0.5)
collapsable_panel(layout, mixer_prefs, "display_selected_room_properties", text="Selected Room Properties")
if mixer_prefs.display_selected_room_properties:
Expand Down Expand Up @@ -617,23 +644,6 @@ def _display_property(layout, name, value, has_warning=False):

split.prop(current_room, "keep_open", text="")

row = box.row()
row.separator(factor=2)
collapsable_panel(row, mixer_prefs, "users_list_panel_opened", text="Users in the Room")
if mixer_prefs.users_list_panel_opened:
sub_row = box.row()
sub_row.separator(factor=7)
sub_box = sub_row.box()
col = sub_box.column()

for user in (user for user in mixer_props.users if user_belongs_to_selected_room(user)):
user_split = col.split()
sub_row = user_split.row()
user_sub_split = sub_row.split(factor=0.8)
user_sub_split.label(text=f"{user.name}", icon="USER" if user.is_me else "BLANK1")
user_sub_split.prop(user, "color", text="")
sub_row.label(text=f"{user.ip_port}")


class VRtistSettingsPanel(bpy.types.Panel):
bl_label = f"VRtist V. {display_version or '(Unknown version)'}"
Expand Down
2 changes: 1 addition & 1 deletion mixer/bl_preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def on_user_color_changed(self, context):
name="Room Properties", description="Display the properties of the selected room", default=False
)
users_list_panel_opened: bpy.props.BoolProperty(
name="Users List", description="Display the list of the users in the selected room", default=False
name="Users List", description="Display the list of the users in the selected room", default=True
)

def get_log_level(self):
Expand Down

0 comments on commit cdb8d16

Please sign in to comment.