WIP: Combine X-Ray and Shading Header Buttons #106728

Draft
Lukas Sneyd wants to merge 1 commits from lcas/blender:xray-shading-header into blender-v3.5-release

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
3 changed files with 39 additions and 10 deletions

View File

@ -889,7 +889,7 @@ class VIEW3D_HT_header(Header):
sub.active = overlay.show_overlays
sub.popover(panel="VIEW3D_PT_overlay", text="")
row = layout.row()
row = layout.row(align=True)
row.active = (object_mode == 'EDIT') or (shading.type in {'WIREFRAME', 'SOLID'})
# While exposing `shading.show_xray(_wireframe)` is correct.
@ -900,15 +900,27 @@ class VIEW3D_HT_header(Header):
draw_depressed = shading.show_xray_wireframe
else:
draw_depressed = shading.show_xray
row.operator(
"view3d.toggle_xray",
text="",
icon='XRAY',
depress=draw_depressed,
)
row = layout.row(align=True)
row.prop(shading, "type", text="", expand=True)
if tool_settings.xray_shading_header:
if shading.type == 'SOLID':
shadicon = 'SHADING_SOLID'
elif shading.type == 'MATERIAL':
shadicon = 'SHADING_TEXTURE'
elif shading.type == 'RENDERED':
shadicon = 'SHADING_RENDERED'
else:
shadicon = 'SHADING_WIRE'
row.operator("view3d.toggle_xray", text="", icon=shadicon, depress=draw_depressed)
else:
row.operator(
"view3d.toggle_xray",
text="",
icon='XRAY',
depress=draw_depressed,
)
row = layout.row(align=True)
row.prop(shading, "type", text="", expand=True)
sub = row.row(align=True)
# TODO, currently render shading type ignores mesh two-side, until it's supported
# show the shading popover which shows double-sided option.
@ -5888,6 +5900,12 @@ class VIEW3D_PT_shading(Panel):
def draw(self, _context):
layout = self.layout
layout.label(text="Viewport Shading")
tool_settings = _context.tool_settings
shading = VIEW3D_PT_shading.get_shading(_context)
layout.prop(tool_settings, "xray_shading_header")
if tool_settings.xray_shading_header:
layout.prop(shading, "type", text="", expand=True)
class VIEW3D_PT_shading_lighting(Panel):

View File

@ -1682,7 +1682,10 @@ typedef struct ToolSettings {
/** Normal Editing. */
float normal_vector[3];
char _pad6[4];
/** Combine X-Ray and Shading Header **/
char xray_shading_header;
char _pad6[3];
/**
* Custom Curve Profile for bevel tool:

View File

@ -3725,6 +3725,14 @@ static void rna_def_tool_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Normal Vector", "Normal Vector used to copy, add or multiply");
RNA_def_property_ui_range(prop, -10000.0, 10000.0, 1, 3);
/* X-Ray Shading Header */
prop = RNA_def_property(srna, "xray_shading_header", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "xray_shading_header", 0);
RNA_def_property_ui_text(
prop,
"Shrink Header",
"Combine the four Shading header buttons and the X-Ray header button");
/* Unified Paint Settings */
prop = RNA_def_property(srna, "unified_paint_settings", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);