Geometry Nodes: Skip redo panel for node tools without inputs #112251
|
@ -438,6 +438,18 @@ static void run_node_group_ui(bContext *C, wmOperator *op)
|
|||
}
|
||||
}
|
||||
|
||||
static bool run_node_ui_poll(wmOperatorType * /*ot*/, PointerRNA *ptr)
|
||||
{
|
||||
RNA_STRUCT_BEGIN (ptr, prop) {
|
||||
int flag = RNA_property_flag(prop);
|
||||
if ((flag & PROP_HIDDEN) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
RNA_STRUCT_END;
|
||||
return false;
|
||||
}
|
||||
|
||||
static std::string run_node_group_get_name(wmOperatorType * /*ot*/, PointerRNA *ptr)
|
||||
{
|
||||
int len;
|
||||
|
@ -459,6 +471,7 @@ void GEOMETRY_OT_execute_node_group(wmOperatorType *ot)
|
|||
ot->exec = run_node_group_exec;
|
||||
ot->get_description = run_node_group_get_description;
|
||||
ot->ui = run_node_group_ui;
|
||||
ot->ui_poll = run_node_ui_poll;
|
||||
ot->get_name = run_node_group_get_name;
|
||||
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
|
|
@ -66,7 +66,7 @@ static bool last_redo_poll(const bContext *C, short region_type)
|
|||
ARegion *region_prev = CTX_wm_region(C);
|
||||
CTX_wm_region_set((bContext *)C, region_op);
|
||||
|
||||
if (WM_operator_repeat_check(C, op) && WM_operator_check_ui_empty(op->type) == false) {
|
||||
if (WM_operator_repeat_check(C, op) && WM_operator_ui_poll(op->type, op->ptr)) {
|
||||
success = WM_operator_poll((bContext *)C, op->type);
|
||||
}
|
||||
CTX_wm_region_set((bContext *)C, region_prev);
|
||||
|
|
|
@ -830,7 +830,7 @@ void WM_operator_properties_create_ptr(PointerRNA *ptr, wmOperatorType *ot);
|
|||
void WM_operator_properties_clear(PointerRNA *ptr);
|
||||
void WM_operator_properties_free(PointerRNA *ptr);
|
||||
|
||||
bool WM_operator_check_ui_empty(wmOperatorType *ot);
|
||||
bool WM_operator_ui_poll(wmOperatorType *ot, PointerRNA *ptr);
|
||||
/**
|
||||
* Return false, if the UI should be disabled.
|
||||
*/
|
||||
|
|
|
@ -982,6 +982,11 @@ struct wmOperatorType {
|
|||
|
||||
/** Optional panel for redo and repeat, auto-generated if not set. */
|
||||
void (*ui)(bContext *, wmOperator *);
|
||||
/**
|
||||
* Optional check for whether the #ui callback should be called (usually to create the redo
|
||||
* panel interface).
|
||||
*/
|
||||
bool (*ui_poll)(wmOperatorType *, PointerRNA *);
|
||||
|
||||
/**
|
||||
* Return a different name to use in the user interface, based on property values.
|
||||
|
|
|
@ -1005,35 +1005,36 @@ bool WM_operator_poll_context(bContext *C, wmOperatorType *ot, short context)
|
|||
C, ot, nullptr, nullptr, static_cast<wmOperatorCallContext>(context), true, nullptr);
|
||||
}
|
||||
|
||||
bool WM_operator_check_ui_empty(wmOperatorType *ot)
|
||||
bool WM_operator_ui_poll(wmOperatorType *ot, PointerRNA *ptr)
|
||||
{
|
||||
if (ot->macro.first != nullptr) {
|
||||
/* For macros, check all have exec() we can call. */
|
||||
LISTBASE_FOREACH (wmOperatorTypeMacro *, macro, &ot->macro) {
|
||||
wmOperatorType *otm = WM_operatortype_find(macro->idname, false);
|
||||
if (otm && !WM_operator_check_ui_empty(otm)) {
|
||||
return false;
|
||||
if (otm && WM_operator_ui_poll(otm, ptr)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ot->ui) {
|
||||
if (ot->ui_poll) {
|
||||
return ot->ui_poll(ot, ptr);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Assume a UI callback will draw something. */
|
||||
if (ot->ui) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PointerRNA ptr;
|
||||
WM_operator_properties_create_ptr(&ptr, ot);
|
||||
RNA_STRUCT_BEGIN (&ptr, prop) {
|
||||
PointerRNA op_ptr;
|
||||
WM_operator_properties_create_ptr(&op_ptr, ot);
|
||||
RNA_STRUCT_BEGIN (&op_ptr, prop) {
|
||||
int flag = RNA_property_flag(prop);
|
||||
if (flag & PROP_HIDDEN) {
|
||||
continue;
|
||||
if ((flag & PROP_HIDDEN) == 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
RNA_STRUCT_END;
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void WM_operator_region_active_win_set(bContext *C)
|
||||
|
|
Loading…
Reference in New Issue