Revert 87aa514611b9: Removal of Lock Camera Gizmo Button
Differential Revision: https://developer.blender.org/D10968 Reviewed by Julian Eisel
This commit is contained in:
parent
d851fc3ad6
commit
4baf3964ae
|
@ -67,73 +67,45 @@ enum {
|
|||
GZ_INDEX_ORTHO = 4,
|
||||
GZ_INDEX_CAMERA = 5,
|
||||
|
||||
/* overlaps GZ_INDEX_ORTHO (switch between) */
|
||||
GZ_INDEX_CAMERA_LOCK = 6,
|
||||
GZ_INDEX_CAMERA_UNLOCK = 7,
|
||||
|
||||
GZ_INDEX_TOTAL = 8,
|
||||
GZ_INDEX_TOTAL = 6,
|
||||
};
|
||||
|
||||
struct NavigateGizmoInfo {
|
||||
const char *opname;
|
||||
const char *gizmo;
|
||||
uint icon;
|
||||
void (*op_prop_fn)(PointerRNA *ptr);
|
||||
};
|
||||
|
||||
static void navigate_context_toggle_camera_lock_init(PointerRNA *ptr)
|
||||
{
|
||||
RNA_string_set(ptr, "data_path", "space_data.lock_camera");
|
||||
}
|
||||
|
||||
static struct NavigateGizmoInfo g_navigate_params[GZ_INDEX_TOTAL] = {
|
||||
{
|
||||
.opname = "VIEW3D_OT_move",
|
||||
.gizmo = "GIZMO_GT_button_2d",
|
||||
.icon = ICON_VIEW_PAN,
|
||||
.op_prop_fn = NULL,
|
||||
},
|
||||
{
|
||||
.opname = "VIEW3D_OT_rotate",
|
||||
.gizmo = "VIEW3D_GT_navigate_rotate",
|
||||
.icon = ICON_NONE,
|
||||
.op_prop_fn = NULL,
|
||||
},
|
||||
{
|
||||
.opname = "VIEW3D_OT_zoom",
|
||||
.gizmo = "GIZMO_GT_button_2d",
|
||||
.icon = ICON_VIEW_ZOOM,
|
||||
.op_prop_fn = NULL,
|
||||
},
|
||||
{
|
||||
.opname = "VIEW3D_OT_view_persportho",
|
||||
.gizmo = "GIZMO_GT_button_2d",
|
||||
.icon = ICON_VIEW_PERSPECTIVE,
|
||||
.op_prop_fn = NULL,
|
||||
},
|
||||
{
|
||||
.opname = "VIEW3D_OT_view_persportho",
|
||||
.gizmo = "GIZMO_GT_button_2d",
|
||||
.icon = ICON_VIEW_ORTHO,
|
||||
.op_prop_fn = NULL,
|
||||
},
|
||||
{
|
||||
.opname = "VIEW3D_OT_view_camera",
|
||||
.gizmo = "GIZMO_GT_button_2d",
|
||||
.icon = ICON_VIEW_CAMERA,
|
||||
.op_prop_fn = NULL,
|
||||
},
|
||||
{
|
||||
.opname = "WM_OT_context_toggle", /* GZ_INDEX_CAMERA_LOCK. Lock Camera to View. */
|
||||
.gizmo = "GIZMO_GT_button_2d",
|
||||
.icon = ICON_UNLOCKED,
|
||||
.op_prop_fn = navigate_context_toggle_camera_lock_init,
|
||||
},
|
||||
{
|
||||
.opname = "WM_OT_context_toggle", /* GZ_INDEX_CAMERA_UNLOCK. Unlock Camera to View. */
|
||||
.gizmo = "GIZMO_GT_button_2d",
|
||||
.icon = ICON_LOCKED,
|
||||
.op_prop_fn = navigate_context_toggle_camera_lock_init,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -142,9 +114,6 @@ struct NavigateWidgetGroup {
|
|||
/* Store the view state to check for changes. */
|
||||
struct {
|
||||
rcti rect_visible;
|
||||
struct {
|
||||
int flag2;
|
||||
} v3d;
|
||||
struct {
|
||||
char is_persp;
|
||||
bool is_camera;
|
||||
|
@ -216,10 +185,7 @@ static void WIDGETGROUP_navigate_setup(const bContext *C, wmGizmoGroup *gzgroup)
|
|||
}
|
||||
|
||||
wmOperatorType *ot = WM_operatortype_find(info->opname, true);
|
||||
PointerRNA *ptr = WM_gizmo_operator_set(gz, 0, ot, NULL);
|
||||
if (info->op_prop_fn != NULL) {
|
||||
info->op_prop_fn(ptr);
|
||||
}
|
||||
WM_gizmo_operator_set(gz, 0, ot, NULL);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -229,13 +195,7 @@ static void WIDGETGROUP_navigate_setup(const bContext *C, wmGizmoGroup *gzgroup)
|
|||
|
||||
/* Click only buttons (not modal). */
|
||||
{
|
||||
int gz_ids[] = {
|
||||
GZ_INDEX_PERSP,
|
||||
GZ_INDEX_ORTHO,
|
||||
GZ_INDEX_CAMERA,
|
||||
GZ_INDEX_CAMERA_LOCK,
|
||||
GZ_INDEX_CAMERA_UNLOCK,
|
||||
};
|
||||
int gz_ids[] = {GZ_INDEX_PERSP, GZ_INDEX_ORTHO, GZ_INDEX_CAMERA};
|
||||
for (int i = 0; i < ARRAY_SIZE(gz_ids); i++) {
|
||||
wmGizmo *gz = navgroup->gz_array[gz_ids[i]];
|
||||
RNA_boolean_set(gz->ptr, "show_drag", false);
|
||||
|
@ -283,8 +243,6 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmGizmoGroup *g
|
|||
struct NavigateWidgetGroup *navgroup = gzgroup->customdata;
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
const RegionView3D *rv3d = region->regiondata;
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
const int v3d_flag2_test = V3D_LOCK_CAMERA;
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
copy_v3_v3(navgroup->gz_array[GZ_INDEX_ROTATE]->matrix_offset[i], rv3d->viewmat[i]);
|
||||
|
@ -293,12 +251,10 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmGizmoGroup *g
|
|||
const rcti *rect_visible = ED_region_visible_rect(region);
|
||||
|
||||
/* Ensure types match so bits are never lost on assignment. */
|
||||
CHECK_TYPE_PAIR(navgroup->state.v3d.flag2, v3d->flag2);
|
||||
CHECK_TYPE_PAIR(navgroup->state.rv3d.viewlock, rv3d->viewlock);
|
||||
|
||||
if ((navgroup->state.rect_visible.xmax == rect_visible->xmax) &&
|
||||
(navgroup->state.rect_visible.ymax == rect_visible->ymax) &&
|
||||
(navgroup->state.v3d.flag2 == (v3d->flag2 & v3d_flag2_test)) &&
|
||||
(navgroup->state.rv3d.is_persp == rv3d->is_persp) &&
|
||||
(navgroup->state.rv3d.is_camera == (rv3d->persp == RV3D_CAMOB)) &&
|
||||
(navgroup->state.rv3d.viewlock == RV3D_LOCK_FLAGS(rv3d))) {
|
||||
|
@ -306,7 +262,6 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmGizmoGroup *g
|
|||
}
|
||||
|
||||
navgroup->state.rect_visible = *rect_visible;
|
||||
navgroup->state.v3d.flag2 = v3d->flag2 & v3d_flag2_test;
|
||||
navgroup->state.rv3d.is_persp = rv3d->is_persp;
|
||||
navgroup->state.rv3d.is_camera = (rv3d->persp == RV3D_CAMOB);
|
||||
navgroup->state.rv3d.viewlock = RV3D_LOCK_FLAGS(rv3d);
|
||||
|
@ -381,14 +336,6 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmGizmoGroup *g
|
|||
WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (navgroup->state.rv3d.is_camera == true) {
|
||||
gz = navgroup->gz_array[(v3d->flag2 & V3D_LOCK_CAMERA) ? GZ_INDEX_CAMERA_UNLOCK :
|
||||
GZ_INDEX_CAMERA_LOCK];
|
||||
gz->matrix_basis[3][0] = roundf(co[0]);
|
||||
gz->matrix_basis[3][1] = roundf(co[1] - (icon_offset_mini * icon_mini_slot++));
|
||||
WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue