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.
This commit is contained in:
parent
f472ac391c
commit
d08312463b
Notes:
blender-bot
2023-02-14 07:36:17 +01:00
Referenced by issue #64752, Render automatically sets scene camera when there is none
|
@ -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):
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 ((rv3d->viewlock & RV3D_LOCKED) == 0) {
|
||||
gz = navgroup->gz_array[GZ_INDEX_CAMERA];
|
||||
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 (navgroup->state.rv3d.is_camera == false) {
|
||||
gz = navgroup->gz_array[rv3d->is_persp ? GZ_INDEX_PERSP : GZ_INDEX_ORTHO];
|
||||
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 ((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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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_gizmo_update(Main *bmain, Scene *scene, PointerRNA *ptr)
|
||||
{
|
||||
WM_reinit_gizmomap_all(bmain);
|
||||
|
||||
rna_userdef_update(bmain, scene, ptr);
|
||||
}
|
||||
|
||||
static void rna_userdef_theme_update_icons(Main *bmain, Scene *scene, PointerRNA *ptr)
|
||||
{
|
||||
UI_icons_reload_internal_textures();
|
||||
|
@ -4118,6 +4125,14 @@ static void rna_def_userdef_view(BlenderRNA *brna)
|
|||
prop, "Editor Corner Splitting", "Split and join editors by dragging from corners");
|
||||
RNA_def_property_update(prop, 0, "rna_userdef_screen_update");
|
||||
|
||||
prop = RNA_def_property(srna, "show_navigate_ui", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_SHOW_GIZMO_NAVIGATE);
|
||||
RNA_def_property_ui_text(
|
||||
prop,
|
||||
"Navigation Buttons",
|
||||
"Show navigation buttons in 2D & 3D views which do not have scroll bars");
|
||||
RNA_def_property_update(prop, 0, "rna_userdef_gizmo_update");
|
||||
|
||||
/* menus */
|
||||
prop = RNA_def_property(srna, "use_mouse_over_open", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_MENUOPENAUTO);
|
||||
|
@ -4229,24 +4244,24 @@ static void rna_def_userdef_view(BlenderRNA *brna)
|
|||
|
||||
/* mini axis */
|
||||
static const EnumPropertyItem mini_axis_type_items[] = {
|
||||
{0, "MINIMAL", 0, "Simple Axis", ""},
|
||||
{USER_SHOW_GIZMO_AXIS, "GIZMO", 0, "Interactive Navigation", ""},
|
||||
{USER_MINI_AXIS_TYPE_NONE, "NONE", 0, "Off", ""},
|
||||
{USER_MINI_AXIS_TYPE_MINIMAL, "MINIMAL", 0, "Simple Axis", ""},
|
||||
{USER_MINI_AXIS_TYPE_GIZMO, "GIZMO", 0, "Interactive Navigation", ""},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
prop = RNA_def_property(srna, "mini_axis_type", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_items(prop, mini_axis_type_items);
|
||||
RNA_def_property_enum_bitflag_sdna(prop, NULL, "uiflag");
|
||||
RNA_def_property_ui_text(prop,
|
||||
"Mini Axes Type",
|
||||
"Show a small rotating 3D axes in the top right corner of the 3D View");
|
||||
RNA_def_property_update(prop, 0, "rna_userdef_update");
|
||||
RNA_def_property_update(prop, 0, "rna_userdef_gizmo_update");
|
||||
|
||||
prop = RNA_def_property(srna, "mini_axis_size", PROP_INT, PROP_PIXEL);
|
||||
RNA_def_property_int_sdna(prop, NULL, "rvisize");
|
||||
RNA_def_property_range(prop, 10, 64);
|
||||
RNA_def_property_ui_text(prop, "Mini Axes Size", "The axes icon's size");
|
||||
RNA_def_property_update(prop, 0, "rna_userdef_update");
|
||||
RNA_def_property_update(prop, 0, "rna_userdef_gizmo_update");
|
||||
|
||||
prop = RNA_def_property(srna, "mini_axis_brightness", PROP_INT, PROP_NONE);
|
||||
RNA_def_property_int_sdna(prop, NULL, "rvibright");
|
||||
|
|
Loading…
Reference in New Issue