3D View: move gizmo draw options out of overlays

Gizmo's now have their own popover in preparation
for making transform gizmos accessible without having to use tools

See: T63518
This commit is contained in:
Campbell Barton 2019-04-13 12:23:07 +02:00
parent cd60843aef
commit 65b0312904
11 changed files with 44 additions and 62 deletions

View File

@ -132,6 +132,17 @@ class VIEW3D_HT_header(Header):
# Mode & Transform Settings
scene = context.scene
# Gizmo popover.
row = layout.row(align=True)
# FIXME: place-holder icon.
row.prop(view, "show_gizmo", text="", toggle=True, icon='EMPTY_DATA')
sub = row.row(align=True)
sub.active = view.show_gizmo
sub.popover(
panel="VIEW3D_PT_gizmo_display",
text="",
)
# Orientation
if object_mode in {'OBJECT', 'EDIT', 'EDIT_GPENCIL'} or has_pose_mode:
orient_slot = scene.transform_orientation_slots[0]
@ -4756,6 +4767,27 @@ class VIEW3D_PT_shading_options_ssao(Panel):
col.prop(scene.display, "matcap_ssao_attenuation")
class VIEW3D_PT_gizmo_display(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER'
bl_label = "Gizmo"
def draw(self, context):
layout = self.layout
view = context.space_data
overlay = view.overlay
col = layout.column()
col.label(text="Viewport Gizmos")
col.active = view.show_gizmo
colsub = col.column()
colsub.prop(view, "show_gizmo_navigate", text="Navigate")
colsub.prop(view, "show_gizmo_context", text="Active Object")
colsub.prop(view, "show_gizmo_tool", text="Active Tools")
class VIEW3D_PT_overlay(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER'
@ -4767,33 +4799,6 @@ class VIEW3D_PT_overlay(Panel):
layout.label(text="Viewport Overlays")
class VIEW3D_PT_overlay_gizmo(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER'
bl_parent_id = 'VIEW3D_PT_overlay'
bl_label = "Gizmo"
def draw_header(self, context):
view = context.space_data
self.layout.prop(view, "show_gizmo", text="")
def draw(self, context):
layout = self.layout
view = context.space_data
overlay = view.overlay
display_all = overlay.show_overlays
col = layout.column()
col.active = display_all
row = col.row(align=True)
row.active = view.show_gizmo
row.prop(view, "show_gizmo_navigate", text="Navigate", toggle=True)
row.prop(view, "show_gizmo_context", text="Active Object", toggle=True)
row.prop(view, "show_gizmo_tool", text="Active Tools", toggle=True)
class VIEW3D_PT_overlay_guides(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER'
@ -6045,8 +6050,8 @@ classes = (
VIEW3D_PT_shading_options,
VIEW3D_PT_shading_options_shadow,
VIEW3D_PT_shading_options_ssao,
VIEW3D_PT_gizmo_display,
VIEW3D_PT_overlay,
VIEW3D_PT_overlay_gizmo,
VIEW3D_PT_overlay_guides,
VIEW3D_PT_overlay_object,
VIEW3D_PT_overlay_geometry,

View File

@ -1581,9 +1581,7 @@ void DRW_draw_render_loop_ex(
if (DST.draw_ctx.evil_C) {
/* needed so gizmo isn't obscured */
if (((v3d->flag2 & V3D_HIDE_OVERLAYS) == 0) &&
((v3d->gizmo_flag & V3D_GIZMO_HIDE) == 0))
{
if ((v3d->gizmo_flag & V3D_GIZMO_HIDE) == 0) {
glDisable(GL_DEPTH_TEST);
DRW_draw_gizmo_3d();
}
@ -1601,7 +1599,7 @@ void DRW_draw_render_loop_ex(
GPU_depth_test(true);
}
if ((v3d->flag2 & V3D_HIDE_OVERLAYS) == 0) {
if ((v3d->gizmo_flag & V3D_GIZMO_HIDE) == 0) {
/* Draw 2D after region info so we can draw on top of the camera passepartout overlay.
* 'DRW_draw_region_info' sets the projection in pixel-space. */
GPU_depth_test(false);

View File

@ -91,9 +91,7 @@ static bool edbm_preselect_or_active(
BMElem **r_ele)
{
ARegion *ar = CTX_wm_region(C);
const bool show_gizmo = !(
(v3d->flag2 & V3D_HIDE_OVERLAYS) ||
(v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_TOOL)));
const bool show_gizmo = !((v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_TOOL)));
wmGizmoMap *gzmap = show_gizmo ? ar->gizmo_map : NULL;
wmGizmoGroup *gzgroup = gzmap ? WM_gizmomap_group_find(gzmap, "VIEW3D_GGT_mesh_preselect_elem") : NULL;

View File

@ -1324,7 +1324,6 @@ void view3d_draw_region_info(const bContext *C, ARegion *ar)
BLF_batch_draw_begin();
if ((U.uiflag & USER_SHOW_GIZMO_AXIS) ||
(v3d->flag2 & V3D_HIDE_OVERLAYS) ||
/* No need to display gizmo and this info. */
(v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_NAVIGATE)))
{

View File

@ -125,9 +125,7 @@ static void gizmo_bbone_offset_set(
static bool WIDGETGROUP_armature_spline_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt))
{
View3D *v3d = CTX_wm_view3d(C);
if ((v3d->flag2 & V3D_HIDE_OVERLAYS) ||
(v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT)))
{
if (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT)) {
return false;
}

View File

@ -61,9 +61,7 @@ struct CameraWidgetGroup {
static bool WIDGETGROUP_camera_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt))
{
View3D *v3d = CTX_wm_view3d(C);
if ((v3d->flag2 & V3D_HIDE_OVERLAYS) ||
(v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT)))
{
if (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT)) {
return false;
}
@ -374,9 +372,7 @@ static bool WIDGETGROUP_camera_view_poll(const bContext *C, wmGizmoGroupType *UN
}
View3D *v3d = CTX_wm_view3d(C);
if ((v3d->flag2 & V3D_HIDE_OVERLAYS) ||
(v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT)))
{
if (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT)) {
return false;
}

View File

@ -106,9 +106,7 @@ static bool WIDGETGROUP_empty_image_poll(const bContext *C, wmGizmoGroupType *UN
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = CTX_wm_region_view3d(C);
if ((v3d->flag2 & V3D_HIDE_OVERLAYS) ||
(v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT)))
{
if (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT)) {
return false;
}

View File

@ -49,9 +49,7 @@ static bool WIDGETGROUP_forcefield_poll(const bContext *C, wmGizmoGroupType *UNU
{
View3D *v3d = CTX_wm_view3d(C);
if ((v3d->flag2 & V3D_HIDE_OVERLAYS) ||
(v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT)))
{
if (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT)) {
return false;
}

View File

@ -51,9 +51,7 @@
static bool WIDGETGROUP_light_spot_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt))
{
View3D *v3d = CTX_wm_view3d(C);
if ((v3d->flag2 & V3D_HIDE_OVERLAYS) ||
(v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT)))
{
if (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT)) {
return false;
}

View File

@ -121,13 +121,11 @@ static bool WIDGETGROUP_navigate_poll(const bContext *C, wmGizmoGroupType *UNUSE
{
View3D *v3d = CTX_wm_view3d(C);
if (((U.uiflag & USER_SHOW_GIZMO_AXIS) == 0) ||
(v3d->flag2 & V3D_HIDE_OVERLAYS) ||
(v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_NAVIGATE)))
{
return false;
}
return true;
}
static void WIDGETGROUP_navigate_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup)

View File

@ -1042,9 +1042,7 @@ static int view3d_ruler_add_invoke(bContext *C, wmOperator *op, const wmEvent *e
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = ar->regiondata;
if ((v3d->flag2 & V3D_HIDE_OVERLAYS) ||
(v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_TOOL)))
{
if (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_TOOL)) {
BKE_report(op->reports, RPT_WARNING, "Gizmos hidden in this view");
return OPERATOR_CANCELLED;
}
@ -1107,9 +1105,7 @@ static int view3d_ruler_remove_invoke(bContext *C, wmOperator *op, const wmEvent
ARegion *ar = CTX_wm_region(C);
View3D *v3d = CTX_wm_view3d(C);
if ((v3d->flag2 & V3D_HIDE_OVERLAYS) ||
(v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_TOOL)))
{
if (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_TOOL)) {
BKE_report(op->reports, RPT_WARNING, "Gizmos hidden in this view");
return OPERATOR_CANCELLED;
}