Remove from Local View operator
This was the old, obscure, little known, M shortcut operator when in local view back in the 2.7x days.
This commit is contained in:
parent
8f8c238659
commit
a687d98e67
|
@ -869,6 +869,7 @@ def km_view3d(params):
|
|||
# Visibility.
|
||||
("view3d.localview", {"type": 'NUMPAD_SLASH', "value": 'PRESS'}, None),
|
||||
("view3d.localview", {"type": 'SLASH', "value": 'PRESS'}, None),
|
||||
("view3d.localview_remove_from", {"type": 'M', "value": 'PRESS'}, None),
|
||||
# Navigation.
|
||||
("view3d.rotate", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None),
|
||||
("view3d.move", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "shift": True}, None),
|
||||
|
|
|
@ -596,7 +596,7 @@ class VIEW3D_MT_view(Menu):
|
|||
|
||||
layout.operator("view3d.view_all", text="Frame All").center = False
|
||||
layout.operator("view3d.view_persportho", text="Perspective/Orthographic")
|
||||
layout.operator("view3d.localview")
|
||||
layout.menu("VIEW3D_MT_view_local")
|
||||
|
||||
layout.separator()
|
||||
|
||||
|
@ -626,6 +626,17 @@ class VIEW3D_MT_view(Menu):
|
|||
layout.menu("INFO_MT_area")
|
||||
|
||||
|
||||
class VIEW3D_MT_view_local(Menu):
|
||||
bl_label = "Local View"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
view = context.space_data
|
||||
|
||||
layout.operator("view3d.localview", text="Toggle Local View")
|
||||
layout.operator("view3d.localview_remove_from")
|
||||
|
||||
|
||||
class VIEW3D_MT_view_cameras(Menu):
|
||||
bl_label = "Cameras"
|
||||
|
||||
|
@ -1723,6 +1734,7 @@ class VIEW3D_MT_object_specials(Menu):
|
|||
def draw(self, context):
|
||||
|
||||
layout = self.layout
|
||||
view = context.space_data
|
||||
|
||||
obj = context.object
|
||||
is_eevee = context.scene.render.engine == 'BLENDER_EEVEE'
|
||||
|
@ -1762,7 +1774,6 @@ class VIEW3D_MT_object_specials(Menu):
|
|||
props.header_text = "Camera Lens Scale: %.3f"
|
||||
|
||||
if not obj.data.dof_object:
|
||||
view = context.space_data
|
||||
if view and view.camera == obj and view.region_3d.view_perspective == 'CAMERA':
|
||||
props = layout.operator("ui.eyedropper_depth", text="DOF Distance (Pick)")
|
||||
else:
|
||||
|
@ -1771,7 +1782,6 @@ class VIEW3D_MT_object_specials(Menu):
|
|||
props.data_path_item = "data.dof_distance"
|
||||
props.input_scale = 0.02
|
||||
props.header_text = "DOF Distance: %.3f"
|
||||
del view
|
||||
|
||||
if obj.type in {'CURVE', 'FONT'}:
|
||||
layout.operator_context = 'INVOKE_REGION_WIN'
|
||||
|
@ -1874,7 +1884,11 @@ class VIEW3D_MT_object_specials(Menu):
|
|||
layout.menu("VIEW3D_MT_snap")
|
||||
layout.menu("VIEW3D_MT_object_parent")
|
||||
layout.operator_context = 'INVOKE_REGION_WIN'
|
||||
layout.operator("object.move_to_collection")
|
||||
|
||||
if view and view.local_view:
|
||||
layout.operator("view3d.localview_remove_from")
|
||||
else:
|
||||
layout.operator("object.move_to_collection")
|
||||
|
||||
layout.separator()
|
||||
|
||||
|
@ -5419,6 +5433,7 @@ classes = (
|
|||
VIEW3D_MT_uv_map,
|
||||
VIEW3D_MT_edit_proportional,
|
||||
VIEW3D_MT_view,
|
||||
VIEW3D_MT_view_local,
|
||||
VIEW3D_MT_view_cameras,
|
||||
VIEW3D_MT_view_navigation,
|
||||
VIEW3D_MT_view_align,
|
||||
|
|
|
@ -1834,6 +1834,12 @@ static bool move_to_collection_poll(bContext *C)
|
|||
return ED_outliner_collections_editor_poll(C);
|
||||
}
|
||||
else {
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
|
||||
if (v3d && v3d->localvd) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return ED_operator_object_active_editable(C);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -177,6 +177,7 @@ void VIEW3D_OT_camera_to_view(struct wmOperatorType *ot);
|
|||
void VIEW3D_OT_camera_to_view_selected(struct wmOperatorType *ot);
|
||||
void VIEW3D_OT_object_as_camera(struct wmOperatorType *ot);
|
||||
void VIEW3D_OT_localview(struct wmOperatorType *ot);
|
||||
void VIEW3D_OT_localview_remove_from(struct wmOperatorType *ot);
|
||||
|
||||
bool ED_view3d_boundbox_clip_ex(const RegionView3D *rv3d, const struct BoundBox *bb, float obmat[4][4]);
|
||||
bool ED_view3d_boundbox_clip(RegionView3D *rv3d, const struct BoundBox *bb);
|
||||
|
|
|
@ -205,6 +205,7 @@ void view3d_operatortypes(void)
|
|||
WM_operatortype_append(VIEW3D_OT_camera_to_view_selected);
|
||||
WM_operatortype_append(VIEW3D_OT_object_as_camera);
|
||||
WM_operatortype_append(VIEW3D_OT_localview);
|
||||
WM_operatortype_append(VIEW3D_OT_localview_remove_from);
|
||||
WM_operatortype_append(VIEW3D_OT_fly);
|
||||
WM_operatortype_append(VIEW3D_OT_walk);
|
||||
WM_operatortype_append(VIEW3D_OT_navigate);
|
||||
|
|
|
@ -1412,6 +1412,63 @@ void VIEW3D_OT_localview(wmOperatorType *ot)
|
|||
ot->poll = ED_operator_view3d_active;
|
||||
}
|
||||
|
||||
static int localview_remove_from_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
ViewLayer *view_layer = CTX_data_view_layer(C);
|
||||
bool changed = false;
|
||||
|
||||
for (Base *base = FIRSTBASE(view_layer); base; base = base->next) {
|
||||
if (TESTBASE(v3d, base)) {
|
||||
base->local_view_bits &= ~v3d->local_view_uuid;
|
||||
ED_object_base_select(base, BA_DESELECT);
|
||||
|
||||
if (base == BASACT(view_layer)) {
|
||||
view_layer->basact = NULL;
|
||||
}
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
DEG_on_visible_update(bmain, false);
|
||||
DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
|
||||
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
|
||||
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
else {
|
||||
BKE_report(op->reports, RPT_ERROR, "No object selected");
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
}
|
||||
|
||||
static bool localview_remove_from_poll(bContext *C)
|
||||
{
|
||||
if (CTX_data_edit_object(C) != NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
return v3d && v3d->localvd;
|
||||
}
|
||||
|
||||
void VIEW3D_OT_localview_remove_from(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name = "Remove from Local View";
|
||||
ot->description = "Move selected objects out of local view";
|
||||
ot->idname = "VIEW3D_OT_localview_remove_from";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec = localview_remove_from_exec;
|
||||
ot->invoke = WM_operator_confirm;
|
||||
ot->poll = localview_remove_from_poll;
|
||||
ot->flag = OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
|
Loading…
Reference in New Issue