/* Modal event handling of frame changing */ static int change_frame_modal(bContext *C, wmOperator *op, const wmEvent *event) { int ret = OPERATOR_RUNNING_MODAL; /* execute the events */ switch (event->type) { case ESCKEY: ret = OPERATOR_FINISHED; break; case MOUSEMOVE: RNA_int_set(op->ptr, "frame", frame_from_event(C, event)); change_frame_apply(C, op); break; case LEFTMOUSE: case RIGHTMOUSE: case MIDDLEMOUSE: /* we check for either mouse-button to end, as checking for ACTIONMOUSE (which is used to init * the modal op) doesn't work for some reason */ if (event->val == KM_RELEASE) ret = OPERATOR_FINISHED; break; case LEFTCTRLKEY: case RIGHTCTRLKEY: if (event->val == KM_RELEASE) { RNA_boolean_set(op->ptr, "snap", false); } else if (event->val == KM_PRESS) { RNA_boolean_set(op->ptr, "snap", true); } break; } if (ret != OPERATOR_RUNNING_MODAL) { change_frame_seq_preview_end(C); } return ret; }
/* Modal event handling of frame changing */ static int change_frame_modal(bContext *C, wmOperator *op, const wmEvent *event) { int ret = OPERATOR_RUNNING_MODAL; /* execute the events */ switch (event->type) { case ESCKEY: ret = OPERATOR_FINISHED; break; case MOUSEMOVE: RNA_float_set(op->ptr, "frame", frame_from_event(C, event)); change_frame_apply(C, op); break; case LEFTMOUSE: case RIGHTMOUSE: case MIDDLEMOUSE: /* We check for either mouse-button to end, to work with all user keymaps. */ if (event->val == KM_RELEASE) { ret = OPERATOR_FINISHED; } break; case LEFTCTRLKEY: case RIGHTCTRLKEY: if (event->val == KM_RELEASE) { RNA_boolean_set(op->ptr, "snap", false); } else if (event->val == KM_PRESS) { RNA_boolean_set(op->ptr, "snap", true); } break; } if (ret != OPERATOR_RUNNING_MODAL) { change_frame_seq_preview_end(C); } return ret; }
static void change_frame_cancel(bContext *C, wmOperator *UNUSED(op)) { change_frame_seq_preview_end(C); }