UI: Object Types Visibility Popover Tweaks #111285

Merged
Harley Acheson merged 5 commits from Harley/blender:ObjectTypesVisibility into main 2023-08-25 22:17:54 +02:00
2 changed files with 76 additions and 45 deletions

View File

@ -6098,8 +6098,8 @@ class VIEW3D_PT_collections(Panel):
class VIEW3D_PT_object_type_visibility(Panel): class VIEW3D_PT_object_type_visibility(Panel):
bl_space_type = 'VIEW_3D' bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER' bl_region_type = 'HEADER'
bl_label = "View Object Types" bl_label = "Selectability & Visibility"
bl_ui_units_x = 7 bl_ui_units_x = 8
# Allows derived classes to pass view data other than context.space_data. # Allows derived classes to pass view data other than context.space_data.
# This is used by the official VR add-on, which passes XrSessionSettings # This is used by the official VR add-on, which passes XrSessionSettings
@ -6109,33 +6109,30 @@ class VIEW3D_PT_object_type_visibility(Panel):
layout.use_property_split = True layout.use_property_split = True
layout.use_property_decorate = False layout.use_property_decorate = False
layout.label(text="Object Types Visibility") layout.label(text="Selectability & Visibility")
layout.separator() layout.separator()
col = layout.column() col = layout.column(align=True)
attr_object_types = ( attr_object_types = (
# Geometry ("mesh", "Mesh", "OUTLINER_OB_MESH"),
("mesh", "Mesh"), ("curve", "Curve", "OUTLINER_OB_CURVE"),
("curve", "Curve"), ("surf", "Surface", "OUTLINER_OB_SURFACE"),
("surf", "Surface"), ("meta", "Meta", "OUTLINER_OB_META"),
("meta", "Meta"), ("font", "Text", "OUTLINER_OB_FONT"),
("font", "Text"), ("curves", "Hair Curves", "OUTLINER_OB_CURVES"),
("curves", "Hair Curves"), ("pointcloud", "Point Cloud", "OUTLINER_OB_POINTCLOUD"),
("pointcloud", "Point Cloud"), ("volume", "Volume", "OUTLINER_OB_VOLUME"),
("volume", "Volume"), ("grease_pencil", "Grease Pencil", "OUTLINER_OB_GREASEPENCIL"),
("grease_pencil", "Grease Pencil"), ("armature", "Armature", "OUTLINER_OB_ARMATURE"),
(None, None), ("lattice", "Lattice", "OUTLINER_OB_LATTICE"),
# Other ("empty", "Empty", "OUTLINER_OB_EMPTY"),
("armature", "Armature"), ("light", "Light", "OUTLINER_OB_LIGHT"),
("lattice", "Lattice"), ("light_probe", "Light Probe", "OUTLINER_OB_LIGHTPROBE"),
("empty", "Empty"), ("camera", "Camera", "OUTLINER_OB_CAMERA"),
("light", "Light"), ("speaker", "Speaker", "OUTLINER_OB_SPEAKER"),
("light_probe", "Light Probe"),
("camera", "Camera"),
("speaker", "Speaker"),
) )
for attr, attr_name in attr_object_types: for attr, attr_name, attr_icon in attr_object_types:
if attr is None: if attr is None:
col.separator() col.separator()
continue continue
@ -6149,10 +6146,7 @@ class VIEW3D_PT_object_type_visibility(Panel):
icon_v = 'HIDE_OFF' if getattr(view, attr_v) else 'HIDE_ON' icon_v = 'HIDE_OFF' if getattr(view, attr_v) else 'HIDE_ON'
row = col.row(align=True) row = col.row(align=True)
row.alignment = 'RIGHT' row.label(text=attr_name, icon=attr_icon)
row.label(text=attr_name)
row.prop(view, attr_v, text="", icon=icon_v, emboss=False)
if show_select: if show_select:
attr_s = "show_object_select_" + attr attr_s = "show_object_select_" + attr
@ -6162,6 +6156,9 @@ class VIEW3D_PT_object_type_visibility(Panel):
rowsub.active = getattr(view, attr_v) rowsub.active = getattr(view, attr_v)
rowsub.prop(view, attr_s, text="", icon=icon_s, emboss=False) rowsub.prop(view, attr_s, text="", icon=icon_s, emboss=False)
row.prop(view, attr_v, text="", icon=icon_v, emboss=False)
def draw(self, context): def draw(self, context):
view = context.space_data view = context.space_data
self.draw_ex(context, view, True) self.draw_ex(context, view, True)

View File

@ -130,39 +130,72 @@ void rna_def_object_type_visibility_flags_common(StructRNA *srna,
const char *name; const char *name;
int type_mask; int type_mask;
const char *identifier[2]; const char *identifier[2];
const char *description[2];
} info[] = { } info[] = {
{"Mesh", (1 << OB_MESH), {"show_object_viewport_mesh", "show_object_select_mesh"}}, {"Mesh",
(1 << OB_MESH),
{"show_object_viewport_mesh", "show_object_select_mesh"},
{"Show mesh objects", "Allow selection of mesh objects"}},
{"Curve", {"Curve",
(1 << OB_CURVES_LEGACY), (1 << OB_CURVES_LEGACY),
{"show_object_viewport_curve", "show_object_select_curve"}}, {"show_object_viewport_curve", "show_object_select_curve"},
{"Surface", (1 << OB_SURF), {"show_object_viewport_surf", "show_object_select_surf"}}, {"Show curves", "Allow selection of curves"}},
{"Meta", (1 << OB_MBALL), {"show_object_viewport_meta", "show_object_select_meta"}}, {"Surface",
{"Font", (1 << OB_FONT), {"show_object_viewport_font", "show_object_select_font"}}, (1 << OB_SURF),
{"show_object_viewport_surf", "show_object_select_surf"},
{"Show surfaces", "Allow selection of surfaces"}},
{"Meta",
(1 << OB_MBALL),
{"show_object_viewport_meta", "show_object_select_meta"},
{"Show metaballs", "Allow selection of metaballs"}},
{"Font",
(1 << OB_FONT),
{"show_object_viewport_font", "show_object_select_font"},
{"Show text objects", "Allow selection of text objects"}},
{"Hair Curves", {"Hair Curves",
(1 << OB_CURVES), (1 << OB_CURVES),
{"show_object_viewport_curves", "show_object_select_curves"}}, {"show_object_viewport_curves", "show_object_select_curves"},
{"Show hair curves", "Allow selection of hair curves"}},
{"Point Cloud", {"Point Cloud",
(1 << OB_POINTCLOUD), (1 << OB_POINTCLOUD),
{"show_object_viewport_pointcloud", "show_object_select_pointcloud"}}, {"show_object_viewport_pointcloud", "show_object_select_pointcloud"},
{"Volume", (1 << OB_VOLUME), {"show_object_viewport_volume", "show_object_select_volume"}}, {"Show point clouds", "Allow selection of point clouds"}},
{"Volume",
(1 << OB_VOLUME),
{"show_object_viewport_volume", "show_object_select_volume"},
{"Show volumes", "Allow selection of volumes"}},
{"Armature", {"Armature",
(1 << OB_ARMATURE), (1 << OB_ARMATURE),
{"show_object_viewport_armature", "show_object_select_armature"}}, {"show_object_viewport_armature", "show_object_select_armature"},
{"Show armatures", "Allow selection of armatures"}},
{"Lattice", {"Lattice",
(1 << OB_LATTICE), (1 << OB_LATTICE),
{"show_object_viewport_lattice", "show_object_select_lattice"}}, {"show_object_viewport_lattice", "show_object_select_lattice"},
{"Empty", (1 << OB_EMPTY), {"show_object_viewport_empty", "show_object_select_empty"}}, {"Show lattices", "Allow selection of lattices"}},
{"Empty",
(1 << OB_EMPTY),
{"show_object_viewport_empty", "show_object_select_empty"},
{"Show empties", "Allow selection of empties"}},
{"Grease Pencil", {"Grease Pencil",
(1 << OB_GPENCIL_LEGACY), (1 << OB_GPENCIL_LEGACY),
{"show_object_viewport_grease_pencil", "show_object_select_grease_pencil"}}, {"show_object_viewport_grease_pencil", "show_object_select_grease_pencil"},
{"Camera", (1 << OB_CAMERA), {"show_object_viewport_camera", "show_object_select_camera"}}, {"Show grease pencil objects", "Allow selection of grease pencil objects"}},
{"Light", (1 << OB_LAMP), {"show_object_viewport_light", "show_object_select_light"}}, {"Camera",
(1 << OB_CAMERA),
{"show_object_viewport_camera", "show_object_select_camera"},
{"Show cameras", "Allow selection of cameras"}},
{"Light",
(1 << OB_LAMP),
{"show_object_viewport_light", "show_object_select_light"},
{"Show lights", "Allow selection of lights"}},
{"Speaker", {"Speaker",
(1 << OB_SPEAKER), (1 << OB_SPEAKER),
{"show_object_viewport_speaker", "show_object_select_speaker"}}, {"show_object_viewport_speaker", "show_object_select_speaker"},
{"Show speakers", "Allow selection of speakers"}},
{"Light Probe", {"Light Probe",
(1 << OB_LIGHTPROBE), (1 << OB_LIGHTPROBE),
{"show_object_viewport_light_probe", "show_object_select_light_probe"}}, {"show_object_viewport_light_probe", "show_object_select_light_probe"},
{"Show light probes", "Allow selection of light probes"}},
}; };
const char *view_mask_member[2] = { const char *view_mask_member[2] = {
@ -175,7 +208,8 @@ void rna_def_object_type_visibility_flags_common(StructRNA *srna,
srna, info[type_index].identifier[mask_index], PROP_BOOLEAN, PROP_NONE); srna, info[type_index].identifier[mask_index], PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna( RNA_def_property_boolean_negative_sdna(
prop, nullptr, view_mask_member[mask_index], info[type_index].type_mask); prop, nullptr, view_mask_member[mask_index], info[type_index].type_mask);
RNA_def_property_ui_text(prop, info[type_index].name, ""); RNA_def_property_ui_text(
prop, info[type_index].name, info[type_index].description[mask_index]);
RNA_def_property_update(prop, noteflag, update_func); RNA_def_property_update(prop, noteflag, update_func);
} }
} }