From e686d1b38acac540edb8fa91ff7d55918f2e6557 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Sat, 1 Jun 2024 08:45:36 -0400 Subject: [PATCH] Sculpt: Improve Set Pivot Position UI - Don't show the "Mouse X" and "Mouse Y" properties in the redo panel for all the modes that don't use them. - Use the recently added dynamic version of the "depends on cursor" setting to only wait for mouse click for the "cursor surface" mode. Arguably these should be different operators anyway. --- .../editors/sculpt_paint/sculpt_transform.cc | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/sculpt_paint/sculpt_transform.cc b/source/blender/editors/sculpt_paint/sculpt_transform.cc index b86520e0738..90958689419 100644 --- a/source/blender/editors/sculpt_paint/sculpt_transform.cc +++ b/source/blender/editors/sculpt_paint/sculpt_transform.cc @@ -370,6 +370,15 @@ static EnumPropertyItem prop_sculpt_pivot_position_types[] = { {0, nullptr, 0, nullptr, nullptr}, }; +static bool set_pivot_depends_on_cursor(bContext & /*C*/, wmOperatorType & /*ot*/, PointerRNA *ptr) +{ + if (!ptr) { + return true; + } + const PivotPositionMode mode = PivotPositionMode(RNA_enum_get(ptr, "mode")); + return mode == PivotPositionMode::CursorSurface; +} + static int set_pivot_position_exec(bContext *C, wmOperator *op) { Object &ob = *CTX_data_active_object(C); @@ -474,6 +483,17 @@ static int set_pivot_position_invoke(bContext *C, wmOperator *op, const wmEvent return set_pivot_position_exec(C, op); } +static bool set_pivot_position_poll_property(const bContext * /*C*/, + wmOperator *op, + const PropertyRNA *prop) +{ + if (STRPREFIX(RNA_property_identifier(prop), "mouse_")) { + const PivotPositionMode mode = PivotPositionMode(RNA_enum_get(op->ptr, "mode")); + return mode == PivotPositionMode::CursorSurface; + } + return true; +} + void SCULPT_OT_set_pivot_position(wmOperatorType *ot) { ot->name = "Set Pivot Position"; @@ -483,8 +503,10 @@ void SCULPT_OT_set_pivot_position(wmOperatorType *ot) ot->invoke = set_pivot_position_invoke; ot->exec = set_pivot_position_exec; ot->poll = SCULPT_mode_poll; + ot->depends_on_cursor = set_pivot_depends_on_cursor; + ot->poll_property = set_pivot_position_poll_property; - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_DEPENDS_ON_CURSOR; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, "mode", prop_sculpt_pivot_position_types,