UI: Changes to Small Operator Confirmations #118346

Merged
Harley Acheson merged 5 commits from Harley/blender:SmallConfirmations into main 2024-03-12 23:12:56 +01:00
20 changed files with 368 additions and 44 deletions

View File

@ -1680,6 +1680,20 @@ static int ed_marker_delete_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
static int ed_marker_delete_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
if (RNA_boolean_get(op->ptr, "confirm")) {
return WM_operator_confirm_ex(C,
op,
IFACE_("Delete selected markers?"),
nullptr,
IFACE_("Delete"),
ALERT_ICON_NONE,
false);
}
return ed_marker_delete_exec(C, op);
}
static void MARKER_OT_delete(wmOperatorType *ot)
{
/* identifiers */
@ -1688,7 +1702,7 @@ static void MARKER_OT_delete(wmOperatorType *ot)
ot->idname = "MARKER_OT_delete";
/* api callbacks */
ot->invoke = WM_operator_confirm_or_exec;
ot->invoke = ed_marker_delete_invoke;
ot->exec = ed_marker_delete_exec;
ot->poll = ed_markers_poll_selected_no_locked_markers;

View File

@ -713,6 +713,20 @@ static int clear_anim_v3d_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
static int clear_anim_v3d_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
if (RNA_boolean_get(op->ptr, "confirm")) {
return WM_operator_confirm_ex(C,
op,
IFACE_("Remove animation from selected objects?"),
nullptr,
IFACE_("Remove"),
ALERT_ICON_NONE,
false);
}
return clear_anim_v3d_exec(C, op);
}
void ANIM_OT_keyframe_clear_v3d(wmOperatorType *ot)
{
/* identifiers */
@ -721,7 +735,7 @@ void ANIM_OT_keyframe_clear_v3d(wmOperatorType *ot)
ot->idname = "ANIM_OT_keyframe_clear_v3d";
/* callbacks */
ot->invoke = WM_operator_confirm_or_exec;
ot->invoke = clear_anim_v3d_invoke;
ot->exec = clear_anim_v3d_exec;
ot->poll = ED_operator_areaactive;
@ -855,6 +869,20 @@ static int delete_key_v3d_exec(bContext *C, wmOperator *op)
return delete_key_using_keying_set(C, op, ks);
}
static int delete_key_v3d_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
if (RNA_boolean_get(op->ptr, "confirm")) {
return WM_operator_confirm_ex(C,
op,
IFACE_("Delete keyframes from selected objects?"),
nullptr,
IFACE_("Delete"),
ALERT_ICON_NONE,
false);
}
return delete_key_v3d_exec(C, op);
}
void ANIM_OT_keyframe_delete_v3d(wmOperatorType *ot)
{
/* identifiers */
@ -863,7 +891,7 @@ void ANIM_OT_keyframe_delete_v3d(wmOperatorType *ot)
ot->idname = "ANIM_OT_keyframe_delete_v3d";
/* callbacks */
ot->invoke = WM_operator_confirm_or_exec;
ot->invoke = delete_key_v3d_invoke;
ot->exec = delete_key_v3d_exec;
ot->poll = ED_operator_areaactive;

View File

@ -36,6 +36,8 @@
#include "RNA_access.hh"
#include "RNA_define.hh"
#include "UI_interface_icons.hh"
#include "WM_api.hh"
#include "WM_types.hh"
@ -1263,6 +1265,20 @@ static int armature_delete_selected_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
static int armature_delete_selected_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
if (RNA_boolean_get(op->ptr, "confirm")) {
return WM_operator_confirm_ex(C,
op,
IFACE_("Delete selected bones?"),
nullptr,
IFACE_("Delete"),
ALERT_ICON_NONE,
false);
}
return armature_delete_selected_exec(C, op);
}
void ARMATURE_OT_delete(wmOperatorType *ot)
{
/* identifiers */
@ -1271,7 +1287,7 @@ void ARMATURE_OT_delete(wmOperatorType *ot)
ot->description = "Remove selected bones from the armature";
/* api callbacks */
ot->invoke = WM_operator_confirm_or_exec;
ot->invoke = armature_delete_selected_invoke;
ot->exec = armature_delete_selected_exec;
ot->poll = ED_operator_editarmature;

View File

@ -774,6 +774,20 @@ static int separate_armature_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
static int separate_armature_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
if (RNA_boolean_get(op->ptr, "confirm")) {
return WM_operator_confirm_ex(C,
op,
IFACE_("Move selected bones to a separate armature?"),
nullptr,
IFACE_("Separate"),
ALERT_ICON_NONE,
false);
}
return separate_armature_exec(C, op);
}
void ARMATURE_OT_separate(wmOperatorType *ot)
{
/* identifiers */
@ -782,7 +796,7 @@ void ARMATURE_OT_separate(wmOperatorType *ot)
ot->description = "Isolate selected bones into a separate armature";
/* callbacks */
ot->invoke = WM_operator_confirm_or_exec;
ot->invoke = separate_armature_invoke;
ot->exec = separate_armature_exec;
ot->poll = ED_operator_editarmature;

View File

@ -1455,6 +1455,20 @@ static int separate_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
static int separate_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
if (RNA_boolean_get(op->ptr, "confirm")) {
return WM_operator_confirm_ex(C,
op,
IFACE_("Move selected points to a new object?"),
nullptr,
IFACE_("Separate"),
ALERT_ICON_NONE,
false);
}
return separate_exec(C, op);
}
void CURVE_OT_separate(wmOperatorType *ot)
{
/* identifiers */
@ -1463,7 +1477,7 @@ void CURVE_OT_separate(wmOperatorType *ot)
ot->description = "Separate selected points from connected unselected points into a new object";
/* api callbacks */
ot->invoke = WM_operator_confirm_or_exec;
ot->invoke = separate_invoke;
ot->exec = separate_exec;
ot->poll = ED_operator_editsurfcurve;

View File

@ -5,6 +5,7 @@
set(INC
../include
../../blenkernel
../../blentranslation
../../gpu
../../makesrna
../../windowmanager

View File

@ -15,6 +15,8 @@
#include "BKE_context.hh"
#include "BKE_mask.h"
#include "BLT_translation.hh"
#include "DEG_depsgraph.hh"
#include "DEG_depsgraph_query.hh"
@ -32,6 +34,8 @@
#include "ANIM_keyframing.hh"
#include "UI_interface_icons.hh"
#include "RNA_access.hh"
#include "RNA_define.hh"
@ -1498,6 +1502,20 @@ static int delete_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
static int delete_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
if (RNA_boolean_get(op->ptr, "confirm")) {
return WM_operator_confirm_ex(C,
op,
IFACE_("Delete selected control points and splines?"),
nullptr,
IFACE_("Delete"),
ALERT_ICON_NONE,
false);
}
return delete_exec(C, op);
}
void MASK_OT_delete(wmOperatorType *ot)
{
/* identifiers */
@ -1506,7 +1524,7 @@ void MASK_OT_delete(wmOperatorType *ot)
ot->idname = "MASK_OT_delete";
/* api callbacks */
ot->invoke = WM_operator_confirm_or_exec;
ot->invoke = delete_invoke;
ot->exec = delete_exec;
ot->poll = ED_maskedit_mask_visible_splines_poll;

View File

@ -5,6 +5,7 @@
set(INC
../include
../../blenkernel
../../blentranslation
../../gpu
../../makesrna
../../render

View File

@ -33,6 +33,8 @@
#include "BKE_object.hh"
#include "BKE_object_types.hh"
#include "BLT_translation.hh"
#include "DEG_depsgraph.hh"
#include "GPU_select.hh"
@ -46,6 +48,8 @@
#include "WM_api.hh"
#include "WM_types.hh"
#include "UI_interface_icons.hh"
#include "mball_intern.h"
using blender::Span;
@ -609,6 +613,20 @@ static int delete_metaelems_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
static int delete_metaelems_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
if (RNA_boolean_get(op->ptr, "confirm")) {
return WM_operator_confirm_ex(C,
op,
IFACE_("Delete selected metaball elements?"),
nullptr,
IFACE_("Delete"),
ALERT_ICON_NONE,
false);
}
return delete_metaelems_exec(C, op);
}
void MBALL_OT_delete_metaelems(wmOperatorType *ot)
{
/* identifiers */
@ -617,7 +635,7 @@ void MBALL_OT_delete_metaelems(wmOperatorType *ot)
ot->idname = "MBALL_OT_delete_metaelems";
/* callback functions */
ot->invoke = WM_operator_confirm_or_exec;
ot->invoke = delete_metaelems_invoke;
ot->exec = delete_metaelems_exec;
ot->poll = ED_operator_editmball;

View File

@ -2612,6 +2612,20 @@ static int object_delete_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
static int object_delete_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
if (RNA_boolean_get(op->ptr, "confirm")) {
return WM_operator_confirm_ex(C,
op,
IFACE_("Delete selected objects?"),
nullptr,
IFACE_("Delete"),
ALERT_ICON_NONE,
false);
}
return object_delete_exec(C, op);
}
void OBJECT_OT_delete(wmOperatorType *ot)
{
/* identifiers */
@ -2620,7 +2634,7 @@ void OBJECT_OT_delete(wmOperatorType *ot)
ot->idname = "OBJECT_OT_delete";
/* api callbacks */
ot->invoke = WM_operator_confirm_or_exec;
ot->invoke = object_delete_invoke;
ot->exec = object_delete_exec;
ot->poll = ED_operator_objectmode;

View File

@ -12,6 +12,8 @@
#include "BLI_string.h"
#include "BLI_vector.hh"
#include "BLT_translation.hh"
#include "WM_api.hh"
#include "WM_types.hh"
@ -663,7 +665,13 @@ static int bake_simulation_invoke(bContext *C, wmOperator *op, const wmEvent * /
return OPERATOR_CANCELLED;
}
if (has_existing_bake_data) {
return WM_operator_confirm_message(C, op, "Overwrite existing bake data");
return WM_operator_confirm_ex(C,
op,
IFACE_("Overwrite existing bake data?"),
nullptr,
IFACE_("Bake"),
ALERT_ICON_NONE,
false);
}
Vector<NodeBakeRequest> requests = bake_simulation_gather_requests(C, op);
return start_bake_job(C, std::move(requests), op, BakeRequestsMode::Async);

View File

@ -286,6 +286,20 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
#undef INDEX_UNSET
}
static int vertex_parent_set_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
if (RNA_boolean_get(op->ptr, "confirm")) {
return WM_operator_confirm_ex(C,
op,
IFACE_("Parent selected objects to the selected vertices?"),
nullptr,
IFACE_("Parent"),
ALERT_ICON_NONE,
false);
}
return vertex_parent_set_exec(C, op);
}
void OBJECT_OT_vertex_parent_set(wmOperatorType *ot)
{
/* identifiers */
@ -294,7 +308,7 @@ void OBJECT_OT_vertex_parent_set(wmOperatorType *ot)
ot->idname = "OBJECT_OT_vertex_parent_set";
/* api callbacks */
ot->invoke = WM_operator_confirm_or_exec;
ot->invoke = vertex_parent_set_invoke;
ot->poll = vertex_parent_set_poll;
ot->exec = vertex_parent_set_exec;
@ -1107,6 +1121,20 @@ static int parent_noinv_set_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
static int parent_noinv_set_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
if (RNA_boolean_get(op->ptr, "confirm")) {
return WM_operator_confirm_ex(C,
op,
IFACE_("Make Parent without inverse correction?"),
nullptr,
IFACE_("Parent"),
ALERT_ICON_NONE,
false);
}
return parent_noinv_set_exec(C, op);
}
void OBJECT_OT_parent_no_inverse_set(wmOperatorType *ot)
{
/* identifiers */
@ -1115,7 +1143,7 @@ void OBJECT_OT_parent_no_inverse_set(wmOperatorType *ot)
ot->idname = "OBJECT_OT_parent_no_inverse_set";
/* api callbacks */
ot->invoke = WM_operator_confirm_or_exec;
ot->invoke = parent_noinv_set_invoke;
ot->exec = parent_noinv_set_exec;
ot->poll = ED_operator_object_active_editable;

View File

@ -37,6 +37,7 @@
#include "BKE_nla.h"
#include "BKE_report.hh"
#include "UI_interface_icons.hh"
#include "UI_view2d.hh"
#include "ANIM_animdata.hh"
@ -1147,6 +1148,20 @@ static int actkeys_delete_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
static int actkeys_delete_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
if (RNA_boolean_get(op->ptr, "confirm")) {
return WM_operator_confirm_ex(C,
op,
IFACE_("Delete selected keyframes?"),
nullptr,
IFACE_("Delete"),
ALERT_ICON_NONE,
false);
}
return actkeys_delete_exec(C, op);
}
void ACTION_OT_delete(wmOperatorType *ot)
{
/* identifiers */
@ -1155,7 +1170,7 @@ void ACTION_OT_delete(wmOperatorType *ot)
ot->description = "Remove all selected keyframes";
/* api callbacks */
ot->invoke = WM_operator_confirm_or_exec;
ot->invoke = actkeys_delete_invoke;
ot->exec = actkeys_delete_exec;
ot->poll = ED_operator_action_active;

View File

@ -13,11 +13,15 @@
#include "BLI_rect.h"
#include "BLI_utildefines.h"
#include "BLT_translation.hh"
#include "BKE_context.hh"
#include "BKE_tracking.h"
#include "DEG_depsgraph.hh"
#include "UI_interface_icons.hh"
#include "WM_api.hh"
#include "WM_types.hh"
@ -526,6 +530,20 @@ static int delete_curve_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
static int delete_curve_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
if (RNA_boolean_get(op->ptr, "confirm")) {
return WM_operator_confirm_ex(C,
op,
IFACE_("Delete track corresponding to the selected curve?"),
nullptr,
IFACE_("Delete"),
ALERT_ICON_NONE,
false);
}
return delete_curve_exec(C, op);
}
void CLIP_OT_graph_delete_curve(wmOperatorType *ot)
{
/* identifiers */
@ -534,7 +552,7 @@ void CLIP_OT_graph_delete_curve(wmOperatorType *ot)
ot->idname = "CLIP_OT_graph_delete_curve";
/* api callbacks */
ot->invoke = WM_operator_confirm_or_exec;
ot->invoke = delete_curve_invoke;
ot->exec = delete_curve_exec;
ot->poll = clip_graph_knots_poll;

View File

@ -24,6 +24,8 @@
#include "DEG_depsgraph.hh"
#include "UI_interface_icons.hh"
#include "WM_api.hh"
#include "WM_types.hh"
@ -243,6 +245,20 @@ static int delete_track_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
static int delete_track_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
if (RNA_boolean_get(op->ptr, "confirm")) {
return WM_operator_confirm_ex(C,
op,
IFACE_("Delete selected tracks?"),
nullptr,
IFACE_("Delete"),
ALERT_ICON_NONE,
false);
}
return delete_track_exec(C, op);
}
void CLIP_OT_delete_track(wmOperatorType *ot)
{
/* identifiers */
@ -251,7 +267,7 @@ void CLIP_OT_delete_track(wmOperatorType *ot)
ot->description = "Delete selected tracks";
/* api callbacks */
ot->invoke = WM_operator_confirm_or_exec;
ot->invoke = delete_track_invoke;
ot->exec = delete_track_exec;
ot->poll = ED_space_clip_tracking_poll;
@ -309,6 +325,20 @@ static int delete_marker_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
static int delete_marker_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
if (RNA_boolean_get(op->ptr, "confirm")) {
return WM_operator_confirm_ex(C,
op,
IFACE_("Delete marker for current frame from selected tracks?"),
nullptr,
IFACE_("Delete"),
ALERT_ICON_NONE,
false);
}
return delete_marker_exec(C, op);
}
void CLIP_OT_delete_marker(wmOperatorType *ot)
{
/* identifiers */
@ -317,7 +347,7 @@ void CLIP_OT_delete_marker(wmOperatorType *ot)
ot->description = "Delete marker for current frame from selected tracks";
/* api callbacks */
ot->invoke = WM_operator_confirm_or_exec;
ot->invoke = delete_marker_invoke;
ot->exec = delete_marker_exec;
ot->poll = ED_space_clip_tracking_poll;

View File

@ -2698,6 +2698,15 @@ static int file_directory_new_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
static int file_directory_new_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
if (RNA_boolean_get(op->ptr, "confirm")) {
return WM_operator_confirm_ex(
C, op, IFACE_("Create new directory?"), nullptr, IFACE_("Create"), ALERT_ICON_NONE, false);
}
return file_directory_new_exec(C, op);
}
void FILE_OT_directory_new(wmOperatorType *ot)
{
PropertyRNA *prop;
@ -2708,7 +2717,7 @@ void FILE_OT_directory_new(wmOperatorType *ot)
ot->idname = "FILE_OT_directory_new";
/* api callbacks */
ot->invoke = WM_operator_confirm_or_exec;
ot->invoke = file_directory_new_invoke;
ot->exec = file_directory_new_exec;
/* File browsing only operator (not asset browsing). */
ot->poll = ED_operator_file_browsing_active; /* <- important, handler is on window level */
@ -3186,6 +3195,12 @@ static int file_delete_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
static int file_delete_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
return WM_operator_confirm_ex(
C, op, IFACE_("Delete selected files?"), nullptr, IFACE_("Delete"), ALERT_ICON_NONE, false);
}
void FILE_OT_delete(wmOperatorType *ot)
{
/* identifiers */
@ -3194,7 +3209,7 @@ void FILE_OT_delete(wmOperatorType *ot)
ot->idname = "FILE_OT_delete";
/* api callbacks */
ot->invoke = WM_operator_confirm;
ot->invoke = file_delete_invoke;
ot->exec = file_delete_exec;
ot->poll = file_delete_poll; /* <- important, handler is on window level */
}

View File

@ -43,6 +43,7 @@
#include "DEG_depsgraph_build.hh"
#include "UI_interface_icons.hh"
#include "UI_view2d.hh"
#include "ANIM_animdata.hh"
@ -801,6 +802,20 @@ static int graphkeys_delete_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
static int graphkeys_delete_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
if (RNA_boolean_get(op->ptr, "confirm")) {
return WM_operator_confirm_ex(C,
op,
IFACE_("Delete selected keyframes?"),
nullptr,
IFACE_("Delete"),
ALERT_ICON_NONE,
false);
}
return graphkeys_delete_exec(C, op);
}
void GRAPH_OT_delete(wmOperatorType *ot)
{
/* Identifiers */
@ -809,7 +824,7 @@ void GRAPH_OT_delete(wmOperatorType *ot)
ot->description = "Remove all selected keyframes";
/* API callbacks */
ot->invoke = WM_operator_confirm_or_exec;
ot->invoke = graphkeys_delete_invoke;
ot->exec = graphkeys_delete_exec;
ot->poll = graphop_editable_keyframes_poll;
@ -967,6 +982,20 @@ static int graphkeys_keys_to_samples_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
static int graphkeys_keys_to_samples_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
if (RNA_boolean_get(op->ptr, "confirm")) {
return WM_operator_confirm_ex(C,
op,
IFACE_("Convert selected keys to samples?"),
nullptr,
IFACE_("Convert"),
ALERT_ICON_NONE,
false);
}
return graphkeys_keys_to_samples_exec(C, op);
}
void GRAPH_OT_keys_to_samples(wmOperatorType *ot)
{
/* Identifiers */
@ -976,7 +1005,7 @@ void GRAPH_OT_keys_to_samples(wmOperatorType *ot)
"Convert selected channels to an uneditable set of samples to save storage space";
/* API callbacks */
ot->invoke = WM_operator_confirm_or_exec;
ot->invoke = graphkeys_keys_to_samples_invoke;
ot->exec = graphkeys_keys_to_samples_exec;
ot->poll = graphop_selected_fcurve_poll;

View File

@ -37,6 +37,8 @@
#include "RNA_enum_types.hh"
#include "RNA_prototypes.h"
#include "UI_interface_icons.hh"
#include "WM_api.hh"
#include "WM_types.hh"
@ -2090,6 +2092,20 @@ static int nlaedit_make_single_user_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
static int nlaedit_make_single_user_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
if (RNA_boolean_get(op->ptr, "confirm")) {
return WM_operator_confirm_ex(C,
op,
IFACE_("Make each action single-user in the selected strips?"),
nullptr,
IFACE_("Make Single"),
ALERT_ICON_NONE,
false);
}
return nlaedit_make_single_user_exec(C, op);
}
void NLA_OT_make_single_user(wmOperatorType *ot)
{
/* identifiers */
@ -2098,7 +2114,7 @@ void NLA_OT_make_single_user(wmOperatorType *ot)
ot->description = "Ensure that each action is only used once in the set of strips selected";
/* api callbacks */
ot->invoke = WM_operator_confirm_or_exec;
ot->invoke = nlaedit_make_single_user_invoke;
ot->exec = nlaedit_make_single_user_exec;
ot->poll = nlaop_poll_tweakmode_off;

View File

@ -540,6 +540,17 @@ static int text_reload_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
static int text_reload_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
return WM_operator_confirm_ex(C,
op,
IFACE_("Reload active text file?"),
nullptr,
IFACE_("Reload"),
ALERT_ICON_NONE,
false);
}
void TEXT_OT_reload(wmOperatorType *ot)
{
/* identifiers */
@ -549,7 +560,7 @@ void TEXT_OT_reload(wmOperatorType *ot)
/* api callbacks */
ot->exec = text_reload_exec;
ot->invoke = WM_operator_confirm;
ot->invoke = text_reload_invoke;
ot->poll = text_edit_poll;
}
@ -591,6 +602,17 @@ static int text_unlink_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
static int text_unlink_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
return WM_operator_confirm_ex(C,
op,
IFACE_("Delete active text file?"),
nullptr,
IFACE_("Delete"),
ALERT_ICON_NONE,
false);
}
void TEXT_OT_unlink(wmOperatorType *ot)
{
/* identifiers */
@ -600,7 +622,7 @@ void TEXT_OT_unlink(wmOperatorType *ot)
/* api callbacks */
ot->exec = text_unlink_exec;
ot->invoke = WM_operator_confirm;
ot->invoke = text_unlink_invoke;
ot->poll = text_unlink_poll;
/* flags */

View File

@ -1160,42 +1160,47 @@ int WM_operator_confirm_message_ex(bContext *C,
const char *title,
const int icon,
const char *message,
const wmOperatorCallContext opcontext)
const wmOperatorCallContext /*opcontext*/)
{
IDProperty *properties = static_cast<IDProperty *>(op->ptr->data);
if (properties && properties->len) {
properties = IDP_CopyProperty(static_cast<const IDProperty *>(op->ptr->data));
int alert_icon = ALERT_ICON_QUESTION;
switch (icon) {
case ICON_NONE:
alert_icon = ALERT_ICON_NONE;
break;
case ICON_ERROR:
alert_icon = ALERT_ICON_WARNING;
break;
case ICON_QUESTION:
alert_icon = ALERT_ICON_QUESTION;
break;
case ICON_CANCEL:
alert_icon = ALERT_ICON_ERROR;
break;
case ICON_INFO:
alert_icon = ALERT_ICON_INFO;
break;
}
else {
properties = nullptr;
}
uiPopupMenu *pup = UI_popup_menu_begin(C, title, icon);
uiLayout *layout = UI_popup_menu_layout(pup);
uiItemFullO_ptr(
layout, op->type, message, ICON_NONE, properties, opcontext, UI_ITEM_O_DEPRESS, nullptr);
UI_popup_menu_end(C, pup);
return OPERATOR_INTERFACE;
return WM_operator_confirm_ex(C, op, IFACE_(title), nullptr, IFACE_(message), alert_icon, false);
}
int WM_operator_confirm_message(bContext *C, wmOperator *op, const char *message)
{
return WM_operator_confirm_message_ex(
C, op, IFACE_("OK?"), ICON_QUESTION, message, WM_OP_EXEC_REGION_WIN);
return WM_operator_confirm_ex(
C, op, IFACE_(message), nullptr, IFACE_("OK"), ALERT_ICON_NONE, false);
}
int WM_operator_confirm(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
return WM_operator_confirm_message(C, op, nullptr);
return WM_operator_confirm_ex(
C, op, IFACE_(op->type->name), nullptr, IFACE_("OK"), ALERT_ICON_NONE, false);
}
int WM_operator_confirm_or_exec(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
const bool confirm = RNA_boolean_get(op->ptr, "confirm");
if (confirm) {
return WM_operator_confirm_message(C, op, nullptr);
return WM_operator_confirm_ex(
C, op, IFACE_(op->type->name), nullptr, IFACE_("OK"), ALERT_ICON_NONE, false);
}
return op->type->exec(C, op);
}
@ -1535,7 +1540,7 @@ static uiBlock *wm_block_dialog_create(bContext *C, ARegion *region, void *user_
uiTemplateOperatorPropertyButs(C, layout, op, UI_BUT_LABEL_ALIGN_SPLIT_COLUMN, 0);
}
uiItemS_ex(layout, small ? 0.4f : 2.0f);
uiItemS_ex(layout, small ? 0.1f : 2.0f);
/* Clear so the OK button is left alone. */
UI_block_func_set(block, nullptr, nullptr, nullptr);