[Bf-blender-cvs] [d08312463b2] master: Preferences: changes to navigation gizmo
Campbell Barton
noreply at git.blender.org
Tue Jun 25 14:56:59 CEST 2019
Commit: d08312463b27651171be1c487633804f6ea98d65
Author: Campbell Barton
Date: Tue Jun 25 21:34:21 2019 +1000
Branches: master
https://developer.blender.org/rBd08312463b27651171be1c487633804f6ea98d65
Preferences: changes to navigation gizmo
- Add 'Navigation Buttons' preference, used for 2D views
(previously this couldn't be disabled).
- Add "Off" option for 3D view axis.
- Support minimal axis with navigation buttons.
===================================================================
M release/scripts/startup/bl_ui/space_userpref.py
M source/blender/blenloader/intern/versioning_userdef.c
M source/blender/editors/interface/view2d_gizmo_navigate.c
M source/blender/editors/space_view3d/view3d_draw.c
M source/blender/editors/space_view3d/view3d_gizmo_navigate.c
M source/blender/makesdna/DNA_userdef_types.h
M source/blender/makesrna/intern/rna_userdef.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 8da5237b7f9..4fc54de7c4d 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -263,6 +263,7 @@ class USERPREF_PT_interface_editors(PreferencePanel, Panel):
flow.prop(system, "use_region_overlap")
flow.prop(view, "show_layout_ui", text="Corner Splitting")
+ flow.prop(view, "show_navigate_ui")
flow.prop(view, "color_picker_type")
flow.row().prop(view, "header_align")
flow.prop(view, "factor_display_type")
@@ -639,10 +640,8 @@ class USERPREF_PT_viewport_display(PreferencePanel, Panel):
col.prop(view, "mini_axis_type", text="3D Viewport Axis")
if view.mini_axis_type == 'MINIMAL':
- sub = col.column()
- sub.active = view.mini_axis_type == 'MINIMAL'
- sub.prop(view, "mini_axis_size", text="Size")
- sub.prop(view, "mini_axis_brightness", text="Brightness")
+ col.prop(view, "mini_axis_size", text="Size")
+ col.prop(view, "mini_axis_brightness", text="Brightness")
class USERPREF_PT_viewport_quality(PreferencePanel, Panel):
diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c
index 7ff9dd70379..709e6dc17b6 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -253,7 +253,7 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
if (userdef->rvisize == 0) {
userdef->rvisize = 15;
userdef->rvibright = 8;
- userdef->uiflag |= USER_SHOW_GIZMO_AXIS;
+ userdef->uiflag |= USER_SHOW_GIZMO_NAVIGATE;
}
}
if (!USER_VERSION_ATLEAST(244, 0)) {
diff --git a/source/blender/editors/interface/view2d_gizmo_navigate.c b/source/blender/editors/interface/view2d_gizmo_navigate.c
index 1ae8dddb75b..1558d0d835f 100644
--- a/source/blender/editors/interface/view2d_gizmo_navigate.c
+++ b/source/blender/editors/interface/view2d_gizmo_navigate.c
@@ -126,6 +126,14 @@ struct NavigateWidgetGroup {
int region_size[2];
};
+static bool WIDGETGROUP_navigate_poll(const bContext *UNUSED(C), wmGizmoGroupType *UNUSED(gzgt))
+{
+ if ((U.uiflag & USER_SHOW_GIZMO_NAVIGATE) == 0) {
+ return false;
+ }
+ return true;
+}
+
static void WIDGETGROUP_navigate_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup)
{
struct NavigateWidgetGroup *navgroup = MEM_callocN(sizeof(struct NavigateWidgetGroup), __func__);
@@ -242,6 +250,7 @@ void VIEW2D_GGT_navigate_impl(wmGizmoGroupType *gzgt, const char *idname)
gzgt->flag |= (WM_GIZMOGROUPTYPE_PERSISTENT | WM_GIZMOGROUPTYPE_SCALE |
WM_GIZMOGROUPTYPE_DRAW_MODAL_ALL);
+ gzgt->poll = WIDGETGROUP_navigate_poll;
gzgt->setup = WIDGETGROUP_navigate_setup;
gzgt->draw_prepare = WIDGETGROUP_navigate_draw_prepare;
}
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 5731da18511..d14a6870a6c 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -1374,13 +1374,19 @@ void view3d_draw_region_info(const bContext *C, ARegion *ar)
BLF_batch_draw_begin();
- if ((U.uiflag & USER_SHOW_GIZMO_AXIS) ||
- /* No need to display gizmo and this info. */
- (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_NAVIGATE))) {
+ if (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_NAVIGATE)) {
/* pass */
}
else {
- draw_view_axis(rv3d, &rect);
+ switch ((eUserpref_MiniAxisType)U.mini_axis_type) {
+ case USER_MINI_AXIS_TYPE_GIZMO:
+ /* The gizmo handles it's own drawing. */
+ break;
+ case USER_MINI_AXIS_TYPE_MINIMAL:
+ draw_view_axis(rv3d, &rect);
+ case USER_MINI_AXIS_TYPE_NONE:
+ break;
+ }
}
int xoffset = rect.xmin + U.widget_unit;
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate.c b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c
index 2a7120e29b1..1724a8bd86d 100644
--- a/source/blender/editors/space_view3d/view3d_gizmo_navigate.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c
@@ -124,7 +124,8 @@ struct NavigateWidgetGroup {
static bool WIDGETGROUP_navigate_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt))
{
View3D *v3d = CTX_wm_view3d(C);
- if (((U.uiflag & USER_SHOW_GIZMO_AXIS) == 0) ||
+ if ((((U.uiflag & USER_SHOW_GIZMO_NAVIGATE) == 0) &&
+ (U.mini_axis_type != USER_MINI_AXIS_TYPE_GIZMO)) ||
(v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_NAVIGATE))) {
return false;
}
@@ -265,8 +266,8 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmGizmoGroup *g
navgroup->state.rv3d.is_camera = (rv3d->persp == RV3D_CAMOB);
navgroup->state.rv3d.viewlock = rv3d->viewlock;
- const bool show_rotate = (rv3d->viewlock & RV3D_LOCKED) == 0;
- const bool show_fixed_offset = navgroup->state.rv3d.is_camera;
+ const bool show_navigate = (U.uiflag & USER_SHOW_GIZMO_NAVIGATE) != 0;
+ const bool show_rotate_gizmo = (U.mini_axis_type == USER_MINI_AXIS_TYPE_GIZMO);
const float icon_size = GIZMO_SIZE;
const float icon_offset = (icon_size * 0.52f) * GIZMO_OFFSET_FAC * UI_DPI_FAC;
const float icon_offset_mini = icon_size * GIZMO_MINI_OFFSET_FAC * UI_DPI_FAC;
@@ -274,9 +275,22 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmGizmoGroup *g
rect_visible.xmax - icon_offset,
rect_visible.ymax - icon_offset,
};
+
+ float icon_offset_from_axis = 0.0f;
+ switch ((eUserpref_MiniAxisType)U.mini_axis_type) {
+ case USER_MINI_AXIS_TYPE_GIZMO:
+ icon_offset_from_axis = icon_offset * 2.0f;
+ break;
+ case USER_MINI_AXIS_TYPE_MINIMAL:
+ icon_offset_from_axis = (UI_UNIT_X * 2.5) + ((U.rvisize * U.pixelsize * 2.0f));
+ break;
+ case USER_MINI_AXIS_TYPE_NONE:
+ icon_offset_from_axis = icon_offset_mini * 0.75f;
+ break;
+ }
+
const float co[2] = {
- rect_visible.xmax -
- ((show_rotate || show_fixed_offset) ? (icon_offset * 2.0f) : (icon_offset_mini * 0.75f)),
+ rect_visible.xmax - icon_offset_from_axis,
rect_visible.ymax - icon_offset_mini * 0.75f,
};
@@ -288,36 +302,37 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmGizmoGroup *g
}
/* RV3D_LOCKED or Camera: only show supported buttons. */
- if (show_rotate) {
+ if (show_rotate_gizmo) {
gz = navgroup->gz_array[GZ_INDEX_ROTATE];
gz->matrix_basis[3][0] = co_rotate[0];
gz->matrix_basis[3][1] = co_rotate[1];
WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false);
}
- int icon_mini_slot = 0;
-
- gz = navgroup->gz_array[GZ_INDEX_ZOOM];
- gz->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++);
- gz->matrix_basis[3][1] = co[1];
- WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false);
-
- gz = navgroup->gz_array[GZ_INDEX_MOVE];
- gz->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++);
- gz->matrix_basis[3][1] = co[1];
- WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false);
+ if (show_navigate) {
+ int icon_mini_slot = 0;
+ gz = navgroup->gz_array[GZ_INDEX_ZOOM];
+ gz->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++);
+ gz->matrix_basis[3][1] = co[1];
+ WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false);
- if ((rv3d->viewlock & RV3D_LOCKED) == 0) {
- gz = navgroup->gz_array[GZ_INDEX_CAMERA];
+ gz = navgroup->gz_array[GZ_INDEX_MOVE];
gz->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++);
gz->matrix_basis[3][1] = co[1];
WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false);
- if (navgroup->state.rv3d.is_camera == false) {
- gz = navgroup->gz_array[rv3d->is_persp ? GZ_INDEX_PERSP : GZ_INDEX_ORTHO];
+ if ((rv3d->viewlock & RV3D_LOCKED) == 0) {
+ gz = navgroup->gz_array[GZ_INDEX_CAMERA];
gz->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++);
gz->matrix_basis[3][1] = co[1];
WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false);
+
+ if (navgroup->state.rv3d.is_camera == false) {
+ gz = navgroup->gz_array[rv3d->is_persp ? GZ_INDEX_PERSP : GZ_INDEX_ORTHO];
+ gz->matrix_basis[3][0] = co[0] - (icon_offset_mini * icon_mini_slot++);
+ gz->matrix_basis[3][1] = co[1];
+ WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false);
+ }
}
}
}
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 3fbdbbb6afa..894dbc05c54 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -591,7 +591,8 @@ typedef struct UserDef {
short dbl_click_time;
char _pad0[2];
- short wheellinescroll;
+ char wheellinescroll;
+ char mini_axis_type;
/** #eUserpref_UI_Flag. */
int uiflag;
/** #eUserpref_UI_Flag2. */
@@ -891,6 +892,13 @@ typedef enum eViewNavigation_Method {
VIEW_NAVIGATION_FLY = 1,
} eViewNavigation_Method;
+/** #UserDef.uiflag */
+typedef enum eUserpref_MiniAxisType {
+ USER_MINI_AXIS_TYPE_GIZMO = 0,
+ USER_MINI_AXIS_TYPE_MINIMAL = 1,
+ USER_MINI_AXIS_TYPE_NONE = 2,
+} eUserpref_MiniAxisType;
+
/** #UserDef.flag */
typedef enum eWalkNavigation_Flag {
USER_WALK_GRAVITY = (1 << 0),
@@ -917,7 +925,7 @@ typedef enum eUserpref_UI_Flag {
USER_ORBIT_SELECTION = (1 << 14),
USER_DEPTH_NAVIGATE = (1 << 15),
USER_HIDE_DOT = (1 << 16),
- USER_SHOW_GIZMO_AXIS = (1 << 17),
+ USER_SHOW_GIZMO_NAVIGATE = (1 << 17),
USER_SHOW_VIEWPORTNAME = (1 << 18),
USER_CAM_LOCK_NO_PARENT = (1 << 19),
USER_ZOOM_TO_MOUSEPOS = (1 << 20),
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 5815a78eac8..f14a668b2d9 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -230,6 +230,13 @@ static void rna_userdef_theme_update(Main *bmain, Scene *scene, PointerRNA *ptr)
rna_userdef_update(bmain, scene, ptr);
}
+static void rna_userdef_g
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list