Fix T73162: Modal tools cant be mapped to MMB
Also rename struct members to 'launch_event', since it's more descriptive and was called this in some places.
This commit is contained in:
@@ -95,6 +95,7 @@ typedef struct {
|
||||
uint ob_store_len;
|
||||
|
||||
/* modal only */
|
||||
int launch_event;
|
||||
float mcenter[2];
|
||||
void *draw_handle_pixel;
|
||||
short gizmo_flag;
|
||||
@@ -520,6 +521,8 @@ static int edbm_bevel_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
|
||||
opdata = op->customdata;
|
||||
|
||||
opdata->launch_event = WM_userdef_event_type_from_keymap_type(event->type);
|
||||
|
||||
/* initialize mouse values */
|
||||
if (!calculateTransformCenter(C, V3D_AROUND_CENTER_MEDIAN, center_3d, opdata->mcenter)) {
|
||||
/* in this case the tool will likely do nothing,
|
||||
@@ -710,7 +713,8 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
short eval = event->val;
|
||||
|
||||
/* When activated from toolbar, need to convert leftmouse release to confirm */
|
||||
if (etype == LEFTMOUSE && eval == KM_RELEASE && RNA_boolean_get(op->ptr, "release_confirm")) {
|
||||
if (ELEM(etype, LEFTMOUSE, opdata->launch_event) && (eval == KM_RELEASE) &&
|
||||
RNA_boolean_get(op->ptr, "release_confirm")) {
|
||||
etype = EVT_MODAL_MAP;
|
||||
eval = BEV_MODAL_CONFIRM;
|
||||
}
|
||||
|
@@ -72,6 +72,7 @@ typedef struct {
|
||||
uint ob_store_len;
|
||||
|
||||
/* modal only */
|
||||
int launch_event;
|
||||
float mcenter[2];
|
||||
void *draw_handle_pixel;
|
||||
short gizmo_flag;
|
||||
@@ -348,6 +349,8 @@ static int edbm_inset_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
|
||||
opdata = op->customdata;
|
||||
|
||||
opdata->launch_event = WM_userdef_event_type_from_keymap_type(event->type);
|
||||
|
||||
/* initialize mouse values */
|
||||
if (!calculateTransformCenter(C, V3D_AROUND_CENTER_MEDIAN, center_3d, opdata->mcenter)) {
|
||||
/* in this case the tool will likely do nothing,
|
||||
@@ -389,6 +392,12 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
}
|
||||
else if ((event->type == opdata->launch_event) && (event->val == KM_RELEASE) &&
|
||||
RNA_boolean_get(op->ptr, "release_confirm")) {
|
||||
edbm_inset_calc(op);
|
||||
edbm_inset_exit(C, op);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
else {
|
||||
bool handled = false;
|
||||
switch (event->type) {
|
||||
|
@@ -939,7 +939,7 @@ void PAINT_OT_grab_clone(wmOperatorType *ot)
|
||||
/******************** sample color operator ********************/
|
||||
typedef struct {
|
||||
bool show_cursor;
|
||||
short event_type;
|
||||
short launch_event;
|
||||
float initcolor[3];
|
||||
bool sample_palette;
|
||||
} SampleColorData;
|
||||
@@ -1000,7 +1000,7 @@ static int sample_color_invoke(bContext *C, wmOperator *op, const wmEvent *event
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
|
||||
data->event_type = event->type;
|
||||
data->launch_event = WM_userdef_event_type_from_keymap_type(event->type);
|
||||
data->show_cursor = ((paint->flags & PAINT_SHOW_BRUSH) != 0);
|
||||
copy_v3_v3(data->initcolor, BKE_brush_color_get(scene, brush));
|
||||
data->sample_palette = false;
|
||||
@@ -1036,7 +1036,7 @@ static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
Paint *paint = BKE_paint_get_active_from_context(C);
|
||||
Brush *brush = BKE_paint_brush(paint);
|
||||
|
||||
if ((event->type == data->event_type) && (event->val == KM_RELEASE)) {
|
||||
if ((event->type == data->launch_event) && (event->val == KM_RELEASE)) {
|
||||
if (data->show_cursor) {
|
||||
paint->flags |= PAINT_SHOW_BRUSH;
|
||||
}
|
||||
|
@@ -562,7 +562,7 @@ typedef struct {
|
||||
float *dim_target;
|
||||
float *rot_target;
|
||||
float *pos_target;
|
||||
short event_type;
|
||||
short launch_event;
|
||||
} StencilControlData;
|
||||
|
||||
static void stencil_set_target(StencilControlData *scd)
|
||||
@@ -626,7 +626,7 @@ static int stencil_control_invoke(bContext *C, wmOperator *op, const wmEvent *ev
|
||||
stencil_set_target(scd);
|
||||
|
||||
scd->mode = RNA_enum_get(op->ptr, "mode");
|
||||
scd->event_type = event->type;
|
||||
scd->launch_event = WM_userdef_event_type_from_keymap_type(event->type);
|
||||
scd->area_size[0] = ar->winx;
|
||||
scd->area_size[1] = ar->winy;
|
||||
|
||||
@@ -709,7 +709,7 @@ static int stencil_control_modal(bContext *C, wmOperator *op, const wmEvent *eve
|
||||
{
|
||||
StencilControlData *scd = op->customdata;
|
||||
|
||||
if (event->type == scd->event_type && event->val == KM_RELEASE) {
|
||||
if (event->type == scd->launch_event && event->val == KM_RELEASE) {
|
||||
MEM_freeN(op->customdata);
|
||||
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
||||
return OPERATOR_FINISHED;
|
||||
|
@@ -374,7 +374,7 @@ void CLIP_OT_reload(wmOperatorType *ot)
|
||||
typedef struct ViewPanData {
|
||||
float x, y;
|
||||
float xof, yof, xorig, yorig;
|
||||
int event_type;
|
||||
int launch_event;
|
||||
bool own_cursor;
|
||||
float *vec;
|
||||
} ViewPanData;
|
||||
@@ -406,7 +406,7 @@ static void view_pan_init(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
copy_v2_v2(&vpd->xof, vpd->vec);
|
||||
copy_v2_v2(&vpd->xorig, &vpd->xof);
|
||||
|
||||
vpd->event_type = event->type;
|
||||
vpd->launch_event = WM_userdef_event_type_from_keymap_type(event->type);
|
||||
|
||||
WM_event_add_modal_handler(C, op);
|
||||
}
|
||||
@@ -493,7 +493,7 @@ static int view_pan_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
default:
|
||||
if (event->type == vpd->event_type && event->val == KM_RELEASE) {
|
||||
if (event->type == vpd->launch_event && event->val == KM_RELEASE) {
|
||||
view_pan_exit(C, op, 0);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
@@ -548,7 +548,7 @@ void CLIP_OT_view_pan(wmOperatorType *ot)
|
||||
typedef struct ViewZoomData {
|
||||
float x, y;
|
||||
float zoom;
|
||||
int event_type;
|
||||
int launch_event;
|
||||
float location[2];
|
||||
wmTimer *timer;
|
||||
double timer_lastdraw;
|
||||
@@ -579,7 +579,7 @@ static void view_zoom_init(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
vpd->x = event->x;
|
||||
vpd->y = event->y;
|
||||
vpd->zoom = sc->zoom;
|
||||
vpd->event_type = event->type;
|
||||
vpd->launch_event = WM_userdef_event_type_from_keymap_type(event->type);
|
||||
|
||||
ED_clip_mouse_pos(sc, ar, event->mval, vpd->location);
|
||||
|
||||
@@ -697,7 +697,7 @@ static int view_zoom_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
view_zoom_apply(C, vpd, op, event, use_cursor_init && (U.uiflag & USER_ZOOM_TO_MOUSEPOS));
|
||||
break;
|
||||
default:
|
||||
if (event->type == vpd->event_type && event->val == KM_RELEASE) {
|
||||
if (event->type == vpd->launch_event && event->val == KM_RELEASE) {
|
||||
view_zoom_exit(C, op, 0);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
|
@@ -98,7 +98,7 @@ void CLIP_OT_create_plane_track(wmOperatorType *ot)
|
||||
/********************** Slide plane marker corner operator *********************/
|
||||
|
||||
typedef struct SlidePlaneMarkerData {
|
||||
int event_type;
|
||||
int launch_event;
|
||||
MovieTrackingPlaneTrack *plane_track;
|
||||
MovieTrackingPlaneMarker *plane_marker;
|
||||
int width, height;
|
||||
@@ -195,7 +195,7 @@ static void *slide_plane_marker_customdata(bContext *C, const wmEvent *event)
|
||||
|
||||
customdata = MEM_callocN(sizeof(SlidePlaneMarkerData), "slide plane marker data");
|
||||
|
||||
customdata->event_type = event->type;
|
||||
customdata->launch_event = WM_userdef_event_type_from_keymap_type(event->type);
|
||||
|
||||
plane_marker = BKE_tracking_plane_marker_ensure(plane_track, framenr);
|
||||
|
||||
@@ -345,7 +345,7 @@ static int slide_plane_marker_modal(bContext *C, wmOperator *op, const wmEvent *
|
||||
|
||||
case LEFTMOUSE:
|
||||
case RIGHTMOUSE:
|
||||
if (event->type == data->event_type && event->val == KM_RELEASE) {
|
||||
if (event->type == data->launch_event && event->val == KM_RELEASE) {
|
||||
/* Marker is now keyframed. */
|
||||
data->plane_marker->flag &= ~PLANE_MARKER_TRACKED;
|
||||
|
||||
|
@@ -305,7 +305,7 @@ static bool image_sample_poll(bContext *C)
|
||||
typedef struct ViewPanData {
|
||||
float x, y;
|
||||
float xof, yof;
|
||||
int event_type;
|
||||
int launch_event;
|
||||
bool own_cursor;
|
||||
} ViewPanData;
|
||||
|
||||
@@ -327,7 +327,7 @@ static void image_view_pan_init(bContext *C, wmOperator *op, const wmEvent *even
|
||||
vpd->y = event->y;
|
||||
vpd->xof = sima->xof;
|
||||
vpd->yof = sima->yof;
|
||||
vpd->event_type = event->type;
|
||||
vpd->launch_event = WM_userdef_event_type_from_keymap_type(event->type);
|
||||
|
||||
WM_event_add_modal_handler(C, op);
|
||||
}
|
||||
@@ -398,7 +398,7 @@ static int image_view_pan_modal(bContext *C, wmOperator *op, const wmEvent *even
|
||||
image_view_pan_exec(C, op);
|
||||
break;
|
||||
default:
|
||||
if (event->type == vpd->event_type && event->val == KM_RELEASE) {
|
||||
if (event->type == vpd->launch_event && event->val == KM_RELEASE) {
|
||||
image_view_pan_exit(C, op, false);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -452,7 +452,7 @@ void IMAGE_OT_view_pan(wmOperatorType *ot)
|
||||
typedef struct ViewZoomData {
|
||||
float origx, origy;
|
||||
float zoom;
|
||||
int event_type;
|
||||
int launch_event;
|
||||
float location[2];
|
||||
|
||||
/* needed for continuous zoom */
|
||||
@@ -483,7 +483,7 @@ static void image_view_zoom_init(bContext *C, wmOperator *op, const wmEvent *eve
|
||||
vpd->origx = event->x;
|
||||
vpd->origy = event->y;
|
||||
vpd->zoom = sima->zoom;
|
||||
vpd->event_type = event->type;
|
||||
vpd->launch_event = WM_userdef_event_type_from_keymap_type(event->type);
|
||||
|
||||
UI_view2d_region_to_view(
|
||||
&ar->v2d, event->mval[0], event->mval[1], &vpd->location[0], &vpd->location[1]);
|
||||
@@ -633,7 +633,7 @@ static int image_view_zoom_modal(bContext *C, wmOperator *op, const wmEvent *eve
|
||||
else if (event->type == MOUSEMOVE) {
|
||||
event_code = VIEW_APPLY;
|
||||
}
|
||||
else if (event->type == vpd->event_type && event->val == KM_RELEASE) {
|
||||
else if (event->type == vpd->launch_event && event->val == KM_RELEASE) {
|
||||
event_code = VIEW_CONFIRM;
|
||||
}
|
||||
|
||||
|
@@ -148,6 +148,7 @@ static bool interactive_value_update(ValueInteraction *inter,
|
||||
* \{ */
|
||||
|
||||
struct ObCustomData_ForEditMode {
|
||||
int launch_event;
|
||||
bool wait_for_input;
|
||||
bool is_active;
|
||||
bool is_first;
|
||||
@@ -211,6 +212,7 @@ static int op_generic_value_invoke(bContext *C, wmOperator *op, const wmEvent *e
|
||||
}
|
||||
|
||||
struct ObCustomData_ForEditMode *cd = MEM_callocN(sizeof(*cd), __func__);
|
||||
cd->launch_event = WM_userdef_event_type_from_keymap_type(event->type);
|
||||
cd->wait_for_input = RNA_boolean_get(op->ptr, "wait_for_input");
|
||||
cd->is_active = !cd->wait_for_input;
|
||||
cd->is_first = true;
|
||||
@@ -239,6 +241,15 @@ static int op_generic_value_invoke(bContext *C, wmOperator *op, const wmEvent *e
|
||||
static int op_generic_value_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
struct ObCustomData_ForEditMode *cd = op->customdata;
|
||||
|
||||
/* Special case, check if we release the event that activated this operator. */
|
||||
if ((event->type == cd->launch_event) && (event->val == KM_RELEASE)) {
|
||||
if (cd->wait_for_input == false) {
|
||||
op_generic_value_exit(op);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
}
|
||||
|
||||
switch (event->type) {
|
||||
case MOUSEMOVE:
|
||||
case LEFTCTRLKEY:
|
||||
|
Reference in New Issue
Block a user