From 764376402a1ad7559eababede6ba825e9d686be9 Mon Sep 17 00:00:00 2001 From: priera Date: Sun, 3 Dec 2023 22:03:25 +0100 Subject: [PATCH] UI: Disable cursor in sculpt mode --- scripts/startup/bl_ui/space_view3d.py | 14 +++++++++++++- source/blender/draw/intern/draw_view_c.cc | 10 +++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/scripts/startup/bl_ui/space_view3d.py b/scripts/startup/bl_ui/space_view3d.py index 88e71f994ef..f639c6fcdd9 100644 --- a/scripts/startup/bl_ui/space_view3d.py +++ b/scripts/startup/bl_ui/space_view3d.py @@ -6874,6 +6874,15 @@ class VIEW3D_PT_overlay_guides(Panel): bl_parent_id = "VIEW3D_PT_overlay" bl_label = "Guides" + @staticmethod + def _cursor_is_active(context): + mode = context.mode + if "PAINT" in mode: + return False + elif mode == "SCULPT": + return context.active_annotation_layer is not None + return True + def draw(self, context): layout = self.layout @@ -6926,7 +6935,10 @@ class VIEW3D_PT_overlay_guides(Panel): sub.prop(overlay, "show_stats", text="Statistics") sub = split.column() - sub.prop(overlay, "show_cursor", text="3D Cursor") + subrow = sub.row() + subrow.prop(overlay, "show_cursor", text="3D Cursor") + subrow.active = VIEW3D_PT_overlay_guides._cursor_is_active(context) + sub.prop(overlay, "show_annotation", text="Annotations") if shading.type == 'MATERIAL': diff --git a/source/blender/draw/intern/draw_view_c.cc b/source/blender/draw/intern/draw_view_c.cc index 8200dca4e63..a850b298c87 100644 --- a/source/blender/draw/intern/draw_view_c.cc +++ b/source/blender/draw/intern/draw_view_c.cc @@ -13,6 +13,7 @@ #include "DNA_userdef_types.h" #include "DNA_view3d_types.h" +#include "ED_gpencil_legacy.hh" #include "ED_screen.hh" #include "ED_util.hh" #include "ED_view3d.hh" @@ -66,8 +67,15 @@ static bool is_cursor_visible(const DRWContextState *draw_ctx, Scene *scene, Vie /* don't draw cursor in paint modes, but with a few exceptions */ if ((draw_ctx->object_mode & (OB_MODE_ALL_PAINT | OB_MODE_SCULPT_CURVES)) != 0) { + /* exception: object is in sculpt mode and there is some annotation */ + if ((draw_ctx->object_mode & OB_MODE_SCULPT) != 0) { + const bGPdata *gpd = ED_annotation_data_get_active(draw_ctx->evil_C); + if (gpd) { + return true; + } + } /* exception: object is in weight paint and has deforming armature in pose mode */ - if (draw_ctx->object_mode & OB_MODE_WEIGHT_PAINT) { + else if (draw_ctx->object_mode & OB_MODE_WEIGHT_PAINT) { if (BKE_object_pose_armature_get(draw_ctx->obact) != nullptr) { return true; } -- 2.30.2