Viewport: change Z key to shading pie menu to switch mode, X-ray and overlays.
This lets us do the most common shading switching with one shortcut. We keep alt+Z and shift+Z for quickly toggling to lookdev and rendered mode and back, it's debatable which settings deserve a dedicated shortcut like this. The downside is that switching X-ray is a little slower, and that there is some risk of accidentally going to lookdev or rendered mode which can be slow to cancel.
This commit is contained in:
@@ -3792,6 +3792,25 @@ class VIEW3D_MT_view_pie(Menu):
|
||||
pie.operator("view3d.view_selected", text="View Selected", icon='ZOOM_SELECTED')
|
||||
|
||||
|
||||
class VIEW3D_MT_shading_pie(Menu):
|
||||
bl_label = "Shading"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
view = context.space_data
|
||||
|
||||
pie = layout.menu_pie()
|
||||
pie.prop(view.shading, "type", expand=True)
|
||||
pie.prop(view.overlay, "show_overlays", icon='OVERLAY')
|
||||
if context.mode == 'POSE':
|
||||
pie.prop(view.overlay, "show_bone_select", icon='ORTHO')
|
||||
elif context.mode == 'EDIT_MESH':
|
||||
pie.prop(view.shading, "show_xray", icon='ORTHO')
|
||||
elif view.shading.type in {'SOLID', 'WIREFRAME'}:
|
||||
pie.prop(view.shading, "show_xray", icon='ORTHO')
|
||||
|
||||
|
||||
# ********** Panel **********
|
||||
|
||||
|
||||
@@ -5195,6 +5214,7 @@ classes = (
|
||||
VIEW3D_MT_edit_gpencil_interpolate,
|
||||
VIEW3D_MT_object_mode_pie,
|
||||
VIEW3D_MT_view_pie,
|
||||
VIEW3D_MT_shading_pie,
|
||||
VIEW3D_PT_view3d_properties,
|
||||
VIEW3D_PT_view3d_camera_lock,
|
||||
VIEW3D_PT_view3d_cursor,
|
||||
|
||||
@@ -4863,7 +4863,8 @@ void VIEW3D_OT_cursor3d(wmOperatorType *ot)
|
||||
* \{ */
|
||||
|
||||
static const EnumPropertyItem prop_shading_type_items[] = {
|
||||
{OB_SOLID, "SOLID", 0, "Solid and X-Ray", "Toggle solid and X-ray shading"},
|
||||
{OB_WIRE, "WIREFRAME", 0, "Wireframe", "Toggle wireframe shading"},
|
||||
{OB_SOLID, "SOLID", 0, "Solid", "Toggle solid shading"},
|
||||
{OB_MATERIAL, "MATERIAL", 0, "LookDev", "Toggle lookdev shading"},
|
||||
{OB_RENDER, "RENDERED", 0, "Rendered", "Toggle rendered shading"},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
@@ -4876,31 +4877,25 @@ static int toggle_shading_exec(bContext *C, wmOperator *op)
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
int type = RNA_enum_get(op->ptr, "type");
|
||||
|
||||
if (type == OB_SOLID) {
|
||||
if (v3d->shading.type == OB_SOLID) {
|
||||
/* Toggle X-Ray if already in solid mode. */
|
||||
v3d->shading.flag ^= V3D_SHADING_XRAY;
|
||||
if (ELEM(type, OB_WIRE, OB_SOLID)) {
|
||||
if (v3d->shading.type != type) {
|
||||
v3d->shading.type = type;
|
||||
}
|
||||
else {
|
||||
/* Go to solid mode. */
|
||||
v3d->shading.type = OB_SOLID;
|
||||
}
|
||||
}
|
||||
else if (type == OB_MATERIAL) {
|
||||
if (v3d->shading.type == OB_MATERIAL) {
|
||||
else if (v3d->shading.type == OB_WIRE) {
|
||||
v3d->shading.type = OB_SOLID;
|
||||
}
|
||||
else {
|
||||
v3d->shading.type = OB_MATERIAL;
|
||||
v3d->shading.type = OB_WIRE;
|
||||
}
|
||||
}
|
||||
else if (type == OB_RENDER) {
|
||||
if (v3d->shading.type == OB_RENDER) {
|
||||
else {
|
||||
|
||||
if (v3d->shading.type == type) {
|
||||
v3d->shading.type = v3d->shading.prev_type;
|
||||
}
|
||||
else {
|
||||
v3d->shading.prev_type = v3d->shading.type;
|
||||
v3d->shading.type = OB_RENDER;
|
||||
v3d->shading.type = type;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -418,8 +418,7 @@ void view3d_keymap(wmKeyConfig *keyconf)
|
||||
#endif /* WITH_INPUT_NDOF */
|
||||
|
||||
/* drawtype */
|
||||
kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_toggle_shading", ZKEY, KM_PRESS, 0, 0);
|
||||
RNA_enum_set(kmi->ptr, "type", OB_SOLID);
|
||||
WM_keymap_add_menu_pie(keymap, "VIEW3D_MT_shading_pie", ZKEY, KM_PRESS, 0, 0);
|
||||
kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_toggle_shading", ZKEY, KM_PRESS, KM_ALT, 0);
|
||||
RNA_enum_set(kmi->ptr, "type", OB_MATERIAL);
|
||||
kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_toggle_shading", ZKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
|
||||
Reference in New Issue
Block a user