Manipulator: limit UI for locked views
authorCampbell Barton <ideasman42@gmail.com>
Tue, 23 Jan 2018 06:11:13 +0000 (17:11 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 23 Jan 2018 06:11:13 +0000 (17:11 +1100)
source/blender/blenloader/intern/writefile.c
source/blender/editors/space_view3d/view3d_manipulator_navigate.c

index 80d77870614099bbcf3dd3e6b998fc9e6ebb5ed3..f0d479e1d71cbe8e3b3ecbe753955d6b43ab9d16 100644 (file)
@@ -3866,6 +3866,7 @@ static void write_global(WriteData *wd, int fileflags, Main *mainvar)
        memset(fg.pad, 0, sizeof(fg.pad));
        memset(fg.filename, 0, sizeof(fg.filename));
        memset(fg.build_hash, 0, sizeof(fg.build_hash));
+       fg.pad1 = NULL;
 
        current_screen_compat(mainvar, is_undo, &screen, &scene, &render_layer);
 
index 0f7df8fe6aa37dd66d99decb6f5e4699fd67ec37..4b87310791189ba65a5d9f84eed1c8f4d76a5cb9 100644 (file)
@@ -163,6 +163,16 @@ struct NavigateManipulatorInfo g_navigate_params[MPR_TOTAL] = {
 
 struct NavigateWidgetGroup {
        wmManipulator *mpr_array[MPR_TOTAL];
+       /* Store the view state to check for changes. */
+       struct {
+               struct {
+                       short winx, winy;
+               } ar;
+               struct {
+                       char is_persp;
+                       char viewlock;
+               } rv3d;
+       } state;
        int region_size[2];
        bool is_persp;
 };
@@ -248,16 +258,19 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmManipulatorGr
                copy_v3_v3(navgroup->mpr_array[MPR_ROTATE]->matrix_offset[i], rv3d->viewmat[i]);
        }
 
-       if ((navgroup->region_size[0] == ar->winx) &&
-           (navgroup->region_size[1] == ar->winy) &&
-           (navgroup->is_persp == rv3d->is_persp))
+       if ((navgroup->state.ar.winx == ar->winx) &&
+           (navgroup->state.ar.winy == ar->winy) &&
+           (navgroup->state.rv3d.is_persp == rv3d->is_persp) &&
+           (navgroup->state.rv3d.viewlock == rv3d->viewlock))
        {
                return;
        }
 
-       navgroup->region_size[0] = ar->winx;
-       navgroup->region_size[1] = ar->winy;
-       navgroup->is_persp = rv3d->is_persp;
+
+       navgroup->state.ar.winx = ar->winx;
+       navgroup->state.ar.winy = ar->winy;
+       navgroup->state.rv3d.is_persp = rv3d->is_persp;
+       navgroup->state.rv3d.viewlock = rv3d->viewlock;
 
 
        const float icon_size = MANIPULATOR_SIZE;
@@ -266,36 +279,50 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmManipulatorGr
        const float co[2] = {ar->winx - icon_offset, ar->winy - icon_offset};
 
        wmManipulator *mpr;
-       mpr = navgroup->mpr_array[MPR_ROTATE];
-       mpr->matrix_basis[3][0] = co[0];
-       mpr->matrix_basis[3][1] = co[1];
 
-       mpr = navgroup->mpr_array[MPR_MOVE];
-       mpr->matrix_basis[3][0] = co[0] + icon_offset_mini;
-       mpr->matrix_basis[3][1] = co[1] - icon_offset_mini;
+       for (uint i = 0; i < ARRAY_SIZE(navgroup->mpr_array); i++) {
+               mpr = navgroup->mpr_array[i];
+               WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true);
+       }
+
+       if ((rv3d->viewlock & RV3D_LOCKED) == 0) {
+               mpr = navgroup->mpr_array[MPR_ROTATE];
+               mpr->matrix_basis[3][0] = co[0];
+               mpr->matrix_basis[3][1] = co[1];
+               WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false);
 
-       mpr = navgroup->mpr_array[MPR_ZOOM];
-       mpr->matrix_basis[3][0] = co[0] - icon_offset_mini;
-       mpr->matrix_basis[3][1] = co[1] - icon_offset_mini;
+               mpr = navgroup->mpr_array[MPR_MOVE];
+               mpr->matrix_basis[3][0] = co[0] + icon_offset_mini;
+               mpr->matrix_basis[3][1] = co[1] - icon_offset_mini;
+               WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false);
 
-       if (rv3d->is_persp) {
-               mpr = navgroup->mpr_array[MPR_PERSP];
-               WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true);
-               mpr = navgroup->mpr_array[MPR_ORTHO];
+               mpr = navgroup->mpr_array[MPR_ZOOM];
+               mpr->matrix_basis[3][0] = co[0] - icon_offset_mini;
+               mpr->matrix_basis[3][1] = co[1] - icon_offset_mini;
+               WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false);
+
+               mpr = navgroup->mpr_array[rv3d->is_persp ? MPR_ORTHO : MPR_PERSP];
+               mpr->matrix_basis[3][0] = co[0] + icon_offset_mini;
+               mpr->matrix_basis[3][1] = co[1] + icon_offset_mini;
+               WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false);
+
+               mpr = navgroup->mpr_array[MPR_CAMERA];
+               mpr->matrix_basis[3][0] = co[0] - icon_offset_mini;
+               mpr->matrix_basis[3][1] = co[1] + icon_offset_mini;
                WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false);
        }
        else {
-               mpr = navgroup->mpr_array[MPR_ORTHO];
-               WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true);
-               mpr = navgroup->mpr_array[MPR_PERSP];
+               /* RV3D_LOCKED: only show supported buttons. */
+               mpr = navgroup->mpr_array[MPR_MOVE];
+               mpr->matrix_basis[3][0] = co[0] + icon_offset_mini;
+               mpr->matrix_basis[3][1] = co[1] + icon_offset_mini;
                WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false);
-       }
-       mpr->matrix_basis[3][0] = co[0] + icon_offset_mini;
-       mpr->matrix_basis[3][1] = co[1] + icon_offset_mini;
 
-       mpr = navgroup->mpr_array[MPR_CAMERA];
-       mpr->matrix_basis[3][0] = co[0] - icon_offset_mini;
-       mpr->matrix_basis[3][1] = co[1] + icon_offset_mini;
+               mpr = navgroup->mpr_array[MPR_ZOOM];
+               mpr->matrix_basis[3][0] = co[0];
+               mpr->matrix_basis[3][1] = co[1] + icon_offset_mini;
+               WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false);
+       }
 }
 
 void VIEW3D_WGT_navigate(wmManipulatorGroupType *wgt)