Added cancel callbacks to modal operators which allocates memory

in invoke callback. This prevents unfreed memory blocks when quiting
Bledner with modal operator running.
This commit is contained in:
2011-06-06 11:04:54 +00:00
parent 4d0026f7b9
commit a43309e8d4
26 changed files with 242 additions and 19 deletions

View File

@@ -1881,6 +1881,7 @@ static void ANIM_OT_channels_select_border(wmOperatorType *ot)
ot->invoke= WM_border_select_invoke;
ot->exec= animchannels_borderselect_exec;
ot->modal= WM_border_select_modal;
ot->cancel= WM_border_select_cancel;
ot->poll= animedit_poll_channels_nla_tweakmode_off;

View File

@@ -717,7 +717,7 @@ static void ed_marker_move_apply(wmOperator *op)
}
/* only for modal */
static void ed_marker_move_cancel(bContext *C, wmOperator *op)
static int ed_marker_move_cancel(bContext *C, wmOperator *op)
{
RNA_int_set(op->ptr, "frames", 0);
ed_marker_move_apply(op);
@@ -725,6 +725,8 @@ static void ed_marker_move_cancel(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL);
WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL);
return OPERATOR_CANCELLED;
}
@@ -886,6 +888,7 @@ static void MARKER_OT_move(wmOperatorType *ot)
ot->invoke= ed_marker_move_invoke_wrapper;
ot->modal= ed_marker_move_modal;
ot->poll= ed_markers_poll_selected_markers;
ot->cancel= ed_marker_move_cancel;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER;
@@ -980,6 +983,7 @@ static void MARKER_OT_duplicate(wmOperatorType *ot)
ot->invoke= ed_marker_duplicate_invoke_wrapper;
ot->modal= ed_marker_move_modal;
ot->poll= ed_markers_poll_selected_markers;
ot->cancel= ed_marker_move_cancel;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1185,6 +1189,7 @@ static void MARKER_OT_select_border(wmOperatorType *ot)
ot->exec= ed_marker_border_select_exec;
ot->invoke= ed_marker_select_border_invoke_wrapper;
ot->modal= WM_border_select_modal;
ot->cancel= WM_border_select_cancel;
ot->poll= ed_markers_poll_markers_exist;

View File

@@ -224,6 +224,7 @@ static void ANIM_OT_previewrange_set(wmOperatorType *ot)
ot->invoke= WM_border_select_invoke;
ot->exec= previewrange_define_exec;
ot->modal= WM_border_select_modal;
ot->cancel= WM_border_select_cancel;
ot->poll= ED_operator_animview_active;

View File

@@ -876,6 +876,13 @@ static void view_zoomdrag_exit(bContext *C, wmOperator *op)
}
}
static int view_zoomdrag_cancel(bContext *C, wmOperator *op)
{
view_zoomdrag_exit(C, op);
return OPERATOR_CANCELLED;
}
/* for 'redo' only, with no user input */
static int view_zoomdrag_exec(bContext *C, wmOperator *op)
{
@@ -1065,6 +1072,7 @@ static void VIEW2D_OT_zoom(wmOperatorType *ot)
ot->exec= view_zoomdrag_exec;
ot->invoke= view_zoomdrag_invoke;
ot->modal= view_zoomdrag_modal;
ot->cancel= view_zoomdrag_cancel;
ot->poll= view_zoom_poll;
@@ -1165,6 +1173,7 @@ static void VIEW2D_OT_zoom_border(wmOperatorType *ot)
ot->invoke= WM_border_select_invoke;
ot->exec= view_borderzoom_exec;
ot->modal= WM_border_select_modal;
ot->cancel= WM_border_select_cancel;
ot->poll= view_zoom_poll;
@@ -1352,7 +1361,14 @@ static void scroller_activate_exit(bContext *C, wmOperator *op)
ED_region_tag_redraw(CTX_wm_region(C));
}
}
}
static int scroller_activate_cancel(bContext *C, wmOperator *op)
{
scroller_activate_exit(C, op);
return OPERATOR_CANCELLED;
}
/* apply transform to view (i.e. adjust 'cur' rect) */
static void scroller_activate_apply(bContext *C, wmOperator *op)
@@ -1561,6 +1577,8 @@ static void VIEW2D_OT_scroller_activate(wmOperatorType *ot)
/* api callbacks */
ot->invoke= scroller_activate_invoke;
ot->modal= scroller_activate_modal;
ot->cancel= scroller_activate_cancel;
ot->poll= view2d_poll;
}

View File

@@ -716,6 +716,7 @@ void MESH_OT_knife_cut(wmOperatorType *ot)
ot->invoke= WM_gesture_lines_invoke;
ot->modal= WM_gesture_lines_modal;
ot->exec= knife_cut_exec;
ot->cancel= WM_gesture_lines_cancel;
ot->poll= EM_view3d_poll;

View File

@@ -627,6 +627,13 @@ static int actionzone_modal(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
static int actionzone_cancel(bContext *UNUSED(C), wmOperator *op)
{
actionzone_exit(op);
return OPERATOR_CANCELLED;
}
static void SCREEN_OT_actionzone(wmOperatorType *ot)
{
/* identifiers */
@@ -637,6 +644,7 @@ static void SCREEN_OT_actionzone(wmOperatorType *ot)
ot->invoke= actionzone_invoke;
ot->modal= actionzone_modal;
ot->poll= actionzone_area_poll;
ot->cancel= actionzone_cancel;
ot->flag= OPTYPE_BLOCKING;
@@ -759,6 +767,7 @@ static void SCREEN_OT_area_swap(wmOperatorType *ot)
ot->invoke= area_swap_invoke;
ot->modal= area_swap_modal;
ot->poll= ED_operator_areaactive;
ot->cancel= area_swap_cancel;
ot->flag= OPTYPE_BLOCKING;
}
@@ -1494,6 +1503,7 @@ static void SCREEN_OT_area_split(wmOperatorType *ot)
ot->exec= area_split_exec;
ot->invoke= area_split_invoke;
ot->modal= area_split_modal;
ot->cancel= area_split_cancel;
ot->poll= screen_active_editable;
ot->flag= OPTYPE_BLOCKING;
@@ -1693,6 +1703,13 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
int region_scale_cancel(bContext *UNUSED(C), wmOperator *op)
{
MEM_freeN(op->customdata);
op->customdata = NULL;
return OPERATOR_CANCELLED;
}
static void SCREEN_OT_region_scale(wmOperatorType *ot)
{
@@ -1703,6 +1720,7 @@ static void SCREEN_OT_region_scale(wmOperatorType *ot)
ot->invoke= region_scale_invoke;
ot->modal= region_scale_modal;
ot->cancel= region_scale_cancel;
ot->poll= ED_operator_areaactive;
@@ -2257,6 +2275,7 @@ static void SCREEN_OT_area_join(wmOperatorType *ot)
ot->invoke= area_join_invoke;
ot->modal= area_join_modal;
ot->poll= screen_active_editable;
ot->cancel= area_join_cancel;
ot->flag= OPTYPE_BLOCKING;
@@ -3053,6 +3072,7 @@ static void SCREEN_OT_border_select(wmOperatorType *ot)
ot->exec= border_select_do;
ot->invoke= WM_border_select_invoke;
ot->modal= WM_border_select_modal;
ot->cancel= WM_border_select_cancel;
ot->poll= ED_operator_areaactive;

View File

@@ -65,6 +65,7 @@ int paint_space_stroke_enabled(struct Brush *br);
int paint_stroke_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
int paint_stroke_exec(struct bContext *C, struct wmOperator *op);
int paint_stroke_cancel(struct bContext *C, struct wmOperator *op);
struct ViewContext *paint_stroke_view_context(struct PaintStroke *stroke);
void *paint_stroke_mode_data(struct PaintStroke *stroke);
void paint_stroke_set_mode_data(struct PaintStroke *stroke, void *mode_data);

View File

@@ -916,6 +916,19 @@ int paint_stroke_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
int paint_stroke_cancel(bContext *C, wmOperator *op)
{
PaintStroke *stroke = op->customdata;
if(stroke->done)
stroke->done(C, stroke);
MEM_freeN(stroke);
op->customdata = NULL;
return OPERATOR_CANCELLED;
}
ViewContext *paint_stroke_view_context(PaintStroke *stroke)
{
return &stroke->vc;

View File

@@ -1600,6 +1600,13 @@ static int wpaint_invoke(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
static int wpaint_cancel(bContext *C, wmOperator *op)
{
paint_stroke_cancel(C, op);
return OPERATOR_CANCELLED;
}
void PAINT_OT_weight_paint(wmOperatorType *ot)
{
@@ -1612,6 +1619,7 @@ void PAINT_OT_weight_paint(wmOperatorType *ot)
ot->modal= paint_stroke_modal;
/* ot->exec= vpaint_exec; <-- needs stroke property */
ot->poll= weight_paint_poll;
ot->cancel= wpaint_cancel;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
@@ -1892,6 +1900,13 @@ static int vpaint_invoke(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
static int vpaint_cancel(bContext *C, wmOperator *op)
{
paint_stroke_cancel(C, op);
return OPERATOR_CANCELLED;
}
void PAINT_OT_vertex_paint(wmOperatorType *ot)
{
/* identifiers */
@@ -1903,6 +1918,7 @@ void PAINT_OT_vertex_paint(wmOperatorType *ot)
ot->modal= paint_stroke_modal;
/* ot->exec= vpaint_exec; <-- needs stroke property */
ot->poll= vertex_paint_poll;
ot->cancel= vpaint_cancel;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;

View File

@@ -3559,6 +3559,24 @@ static int sculpt_brush_stroke_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
static int sculpt_brush_stroke_cacel(bContext *C, wmOperator *op)
{
Object *ob= CTX_data_active_object(C);
SculptSession *ss = ob->sculpt;
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
paint_stroke_cancel(C, op);
if(ss->cache) {
sculpt_cache_free(ss->cache);
ss->cache = NULL;
}
sculpt_brush_exit_tex(sd);
return OPERATOR_CANCELLED;
}
static void SCULPT_OT_brush_stroke(wmOperatorType *ot)
{
static EnumPropertyItem stroke_mode_items[] = {
@@ -3577,6 +3595,7 @@ static void SCULPT_OT_brush_stroke(wmOperatorType *ot)
ot->modal= paint_stroke_modal;
ot->exec= sculpt_brush_stroke_exec;
ot->poll= sculpt_poll;
ot->cancel= sculpt_brush_stroke_cacel;
/* flags (sculpt does own undo? (ton) */
ot->flag= OPTYPE_BLOCKING;

View File

@@ -332,6 +332,7 @@ void ACTION_OT_select_border(wmOperatorType *ot)
ot->invoke= WM_border_select_invoke;
ot->exec= actkeys_borderselect_exec;
ot->modal= WM_border_select_modal;
ot->cancel= WM_border_select_cancel;
ot->poll= ED_operator_action_active;

View File

@@ -301,6 +301,7 @@ void FILE_OT_select_border(wmOperatorType *ot)
ot->exec= file_border_select_exec;
ot->modal= file_border_select_modal;
ot->poll= ED_operator_file_active;
ot->cancel= WM_border_select_cancel;
/* rna */
WM_operator_properties_gesture_border(ot, 0);

View File

@@ -344,6 +344,7 @@ void GRAPH_OT_select_border(wmOperatorType *ot)
ot->invoke= WM_border_select_invoke;
ot->exec= graphkeys_borderselect_exec;
ot->modal= WM_border_select_modal;
ot->cancel= WM_border_select_cancel;
ot->poll= graphop_visible_keyframes_poll;

View File

@@ -1925,6 +1925,7 @@ void IMAGE_OT_sample_line(wmOperatorType *ot)
ot->modal= WM_gesture_straightline_modal;
ot->exec= sample_line_exec;
ot->poll= space_image_main_area_poll;
ot->cancel= WM_gesture_straightline_cancel;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;

View File

@@ -302,6 +302,7 @@ void INFO_OT_select_border(wmOperatorType *ot)
ot->invoke= WM_border_select_invoke;
ot->exec= borderselect_exec;
ot->modal= WM_border_select_modal;
ot->cancel= WM_border_select_cancel;
ot->poll= ED_operator_info_active;

View File

@@ -206,6 +206,7 @@ void LOGIC_OT_links_cut(wmOperatorType *ot)
ot->invoke= WM_gesture_lines_invoke;
ot->modal= WM_gesture_lines_modal;
ot->exec= cut_links_exec;
ot->cancel= WM_gesture_lines_cancel;
ot->poll= ED_operator_logic_active;

View File

@@ -333,6 +333,7 @@ void NLA_OT_select_border(wmOperatorType *ot)
ot->invoke= WM_border_select_invoke;
ot->exec= nlaedit_borderselect_exec;
ot->modal= WM_border_select_modal;
ot->cancel= WM_border_select_cancel;
ot->poll= nlaop_poll_tweakmode_off;

View File

@@ -1086,6 +1086,13 @@ static int snode_bg_viewmove_invoke(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
static int snode_bg_viewmove_cancel(bContext *UNUSED(C), wmOperator *op)
{
MEM_freeN(op->customdata);
op->customdata= NULL;
return OPERATOR_CANCELLED;
}
void NODE_OT_backimage_move(wmOperatorType *ot)
{
@@ -1098,6 +1105,7 @@ void NODE_OT_backimage_move(wmOperatorType *ot)
ot->invoke= snode_bg_viewmove_invoke;
ot->modal= snode_bg_viewmove_modal;
ot->poll= composite_node_active;
ot->cancel= snode_bg_viewmove_cancel;
/* flags */
ot->flag= OPTYPE_BLOCKING;
@@ -1384,6 +1392,14 @@ static int node_resize_invoke(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_CANCELLED|OPERATOR_PASS_THROUGH;
}
static int node_resize_cancel(bContext *UNUSED(C), wmOperator *op)
{
MEM_freeN(op->customdata);
op->customdata= NULL;
return OPERATOR_CANCELLED;
}
void NODE_OT_resize(wmOperatorType *ot)
{
/* identifiers */
@@ -1394,6 +1410,7 @@ void NODE_OT_resize(wmOperatorType *ot)
ot->invoke= node_resize_invoke;
ot->modal= node_resize_modal;
ot->poll= ED_operator_node_active;
ot->cancel= node_resize_cancel;
/* flags */
ot->flag= OPTYPE_BLOCKING;
@@ -2279,6 +2296,18 @@ static int node_link_invoke(bContext *C, wmOperator *op, wmEvent *event)
}
}
static int node_link_cancel(bContext *C, wmOperator *op)
{
SpaceNode *snode= CTX_wm_space_node(C);
bNodeLinkDrag *nldrag= op->customdata;
nodeRemLink(snode->edittree, nldrag->link);
BLI_remlink(&snode->linkdrag, nldrag);
MEM_freeN(nldrag);
return OPERATOR_CANCELLED;
}
void NODE_OT_link(wmOperatorType *ot)
{
/* identifiers */
@@ -2290,6 +2319,7 @@ void NODE_OT_link(wmOperatorType *ot)
ot->modal= node_link_modal;
// ot->exec= node_link_exec;
ot->poll= ED_operator_node_active;
ot->cancel= node_link_cancel;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
@@ -2402,6 +2432,7 @@ void NODE_OT_links_cut(wmOperatorType *ot)
ot->invoke= WM_gesture_lines_invoke;
ot->modal= WM_gesture_lines_modal;
ot->exec= cut_links_exec;
ot->cancel= WM_gesture_lines_cancel;
ot->poll= ED_operator_node_active;

View File

@@ -215,6 +215,7 @@ void NODE_OT_select_border(wmOperatorType *ot)
ot->invoke= node_border_select_invoke;
ot->exec= node_borderselect_exec;
ot->modal= WM_border_select_modal;
ot->cancel= WM_border_select_cancel;
ot->poll= ED_operator_node_active;

View File

@@ -2817,6 +2817,7 @@ void SEQUENCER_OT_view_ghost_border(wmOperatorType *ot)
ot->exec= view_ghost_border_exec;
ot->modal= WM_border_select_modal;
ot->poll= sequencer_view_poll;
ot->cancel= WM_border_select_cancel;
/* flags */
ot->flag= 0;

View File

@@ -871,6 +871,7 @@ void SEQUENCER_OT_select_border(wmOperatorType *ot)
ot->invoke= WM_border_select_invoke;
ot->exec= sequencer_borderselect_exec;
ot->modal= WM_border_select_modal;
ot->cancel= WM_border_select_cancel;
ot->poll= ED_operator_sequencer_active;

View File

@@ -904,6 +904,13 @@ static int view3d_camera_active_poll(bContext *C)
return 0;
}
static int viewrotate_cancel(bContext *C, wmOperator *op)
{
viewops_data_free(C, op);
return OPERATOR_CANCELLED;
}
void VIEW3D_OT_rotate(wmOperatorType *ot)
{
@@ -916,6 +923,7 @@ void VIEW3D_OT_rotate(wmOperatorType *ot)
ot->invoke= viewrotate_invoke;
ot->modal= viewrotate_modal;
ot->poll= ED_operator_region_view3d_active;
ot->cancel= viewrotate_cancel;
/* flags */
ot->flag= OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER;
@@ -1058,6 +1066,13 @@ static int viewmove_invoke(bContext *C, wmOperator *op, wmEvent *event)
}
}
static int viewmove_cancel(bContext *C, wmOperator *op)
{
viewops_data_free(C, op);
return OPERATOR_CANCELLED;
}
void VIEW3D_OT_move(wmOperatorType *ot)
{
@@ -1070,6 +1085,7 @@ void VIEW3D_OT_move(wmOperatorType *ot)
ot->invoke= viewmove_invoke;
ot->modal= viewmove_modal;
ot->poll= ED_operator_view3d_active;
ot->cancel= viewmove_cancel;
/* flags */
ot->flag= OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER;
@@ -1414,6 +1430,12 @@ static int viewzoom_invoke(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_FINISHED;
}
static int viewzoom_cancel(bContext *C, wmOperator *op)
{
viewops_data_free(C, op);
return OPERATOR_CANCELLED;
}
void VIEW3D_OT_zoom(wmOperatorType *ot)
{
@@ -1427,6 +1449,7 @@ void VIEW3D_OT_zoom(wmOperatorType *ot)
ot->exec= viewzoom_exec;
ot->modal= viewzoom_modal;
ot->poll= ED_operator_region_view3d_active;
ot->cancel= viewzoom_cancel;
/* flags */
ot->flag= OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER;
@@ -1641,6 +1664,13 @@ static int viewdolly_poll(bContext *C)
return 0;
}
static int viewdolly_cancel(bContext *C, wmOperator *op)
{
viewops_data_free(C, op);
return OPERATOR_CANCELLED;
}
void VIEW3D_OT_dolly(wmOperatorType *ot)
{
/* identifiers */
@@ -1653,6 +1683,7 @@ void VIEW3D_OT_dolly(wmOperatorType *ot)
ot->exec= viewdolly_exec;
ot->modal= viewdolly_modal;
ot->poll= viewdolly_poll;
ot->cancel= viewdolly_cancel;
/* flags */
ot->flag= OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER;
@@ -2046,6 +2077,7 @@ void VIEW3D_OT_render_border(wmOperatorType *ot)
ot->invoke= WM_border_select_invoke;
ot->exec= render_border_exec;
ot->modal= WM_border_select_modal;
ot->cancel= WM_border_select_cancel;
ot->poll= view3d_camera_active_poll;
@@ -2201,6 +2233,7 @@ void VIEW3D_OT_zoom_border(wmOperatorType *ot)
ot->invoke= view3d_zoom_border_invoke;
ot->exec= view3d_zoom_border_exec;
ot->modal= WM_border_select_modal;
ot->cancel= WM_border_select_cancel;
ot->poll= ED_operator_region_view3d_active;
@@ -2839,6 +2872,7 @@ void VIEW3D_OT_clip_border(wmOperatorType *ot)
ot->invoke= view3d_clipping_invoke;
ot->exec= view3d_clipping_exec;
ot->modal= WM_border_select_modal;
ot->cancel= WM_border_select_cancel;
ot->poll= ED_operator_region_view3d_active;

View File

@@ -875,6 +875,7 @@ void VIEW3D_OT_select_lasso(wmOperatorType *ot)
ot->modal= WM_gesture_lasso_modal;
ot->exec= view3d_lasso_select_exec;
ot->poll= view3d_selectable_data;
ot->cancel= WM_gesture_lasso_cancel;
/* flags */
ot->flag= OPTYPE_UNDO;
@@ -1829,6 +1830,7 @@ void VIEW3D_OT_select_border(wmOperatorType *ot)
ot->exec= view3d_borderselect_exec;
ot->modal= WM_border_select_modal;
ot->poll= view3d_selectable_data;
ot->cancel= WM_border_select_cancel;
/* flags */
ot->flag= OPTYPE_UNDO;
@@ -2308,6 +2310,7 @@ void VIEW3D_OT_select_circle(wmOperatorType *ot)
ot->modal= WM_gesture_circle_modal;
ot->exec= view3d_circle_select_exec;
ot->poll= view3d_selectable_data;
ot->cancel= WM_gesture_circle_cancel;
/* flags */
ot->flag= OPTYPE_UNDO;

View File

@@ -2221,6 +2221,7 @@ static void UV_OT_select_border(wmOperatorType *ot)
ot->exec= border_select_exec;
ot->modal= WM_border_select_modal;
ot->poll= ED_operator_image_active; /* requires space image */;
ot->cancel= WM_border_select_cancel;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -2310,6 +2311,7 @@ static void UV_OT_circle_select(wmOperatorType *ot)
ot->modal= WM_gesture_circle_modal;
ot->exec= circle_select_exec;
ot->poll= ED_operator_image_active; /* requires space image */;
ot->cancel= WM_gesture_circle_cancel;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;

View File

@@ -278,14 +278,19 @@ void WM_menutype_free(void);
/* default operator callbacks for border/circle/lasso */
int WM_border_select_invoke (struct bContext *C, struct wmOperator *op, struct wmEvent *event);
int WM_border_select_modal (struct bContext *C, struct wmOperator *op, struct wmEvent *event);
int WM_border_select_cancel(struct bContext *C, struct wmOperator *op);
int WM_gesture_circle_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
int WM_gesture_circle_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
int WM_gesture_circle_cancel(struct bContext *C, struct wmOperator *op);
int WM_gesture_lines_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
int WM_gesture_lines_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
int WM_gesture_lines_cancel(struct bContext *C, struct wmOperator *op);
int WM_gesture_lasso_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
int WM_gesture_lasso_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
int WM_gesture_lasso_cancel(struct bContext *C, struct wmOperator *op);
int WM_gesture_straightline_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
int WM_gesture_straightline_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event);
int WM_gesture_straightline_cancel(struct bContext *C, struct wmOperator *op);
/* default operator for arearegions, generates event */
void WM_OT_tweak_gesture(struct wmOperatorType *ot);

View File

@@ -2244,6 +2244,13 @@ int WM_border_select_modal(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
int WM_border_select_cancel(bContext *C, wmOperator *op)
{
wm_gesture_end(C, op);
return OPERATOR_CANCELLED;
}
/* **************** circle gesture *************** */
/* works now only for selection or modal paint stuff, calls exec while hold mouse, exit on release */
@@ -2340,6 +2347,13 @@ int WM_gesture_circle_modal(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
int WM_gesture_circle_cancel(bContext *C, wmOperator *op)
{
wm_gesture_end(C, op);
return OPERATOR_CANCELLED;
}
#if 0
/* template to copy from */
void WM_OT_circle_gesture(wmOperatorType *ot)
@@ -2556,6 +2570,20 @@ int WM_gesture_lines_modal(bContext *C, wmOperator *op, wmEvent *event)
return WM_gesture_lasso_modal(C, op, event);
}
int WM_gesture_lasso_cancel(bContext *C, wmOperator *op)
{
wm_gesture_end(C, op);
return OPERATOR_CANCELLED;
}
int WM_gesture_lines_cancel(bContext *C, wmOperator *op)
{
wm_gesture_end(C, op);
return OPERATOR_CANCELLED;
}
#if 0
/* template to copy from */
@@ -2677,6 +2705,13 @@ int WM_gesture_straightline_modal(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
int WM_gesture_straightline_cancel(bContext *C, wmOperator *op)
{
wm_gesture_end(C, op);
return OPERATOR_CANCELLED;
}
#if 0
/* template to copy from */
void WM_OT_straightline_gesture(wmOperatorType *ot)
@@ -3060,6 +3095,28 @@ static void radial_control_set_value(RadialControl *rc, float val)
}
}
static int radial_control_cancel(bContext *C, wmOperator *op)
{
RadialControl *rc = op->customdata;
wmWindowManager *wm = CTX_wm_manager(C);
WM_paint_cursor_end(wm, rc->cursor);
/* restore original paint cursors */
wm->paintcursors = rc->orig_paintcursors;
/* not sure if this is a good notifier to use;
intended purpose is to update the UI so that the
new value is displayed in sliders/numfields */
WM_event_add_notifier(C, NC_WINDOW, NULL);
glDeleteTextures(1, &rc->gltex);
MEM_freeN(rc);
return OPERATOR_CANCELLED;
}
static int radial_control_modal(bContext *C, wmOperator *op, wmEvent *event)
{
RadialControl *rc = op->customdata;
@@ -3125,23 +3182,8 @@ static int radial_control_modal(bContext *C, wmOperator *op, wmEvent *event)
ED_region_tag_redraw(CTX_wm_region(C));
if(ret != OPERATOR_RUNNING_MODAL) {
wm = CTX_wm_manager(C);
WM_paint_cursor_end(wm, rc->cursor);
/* restore original paint cursors */
wm->paintcursors = rc->orig_paintcursors;
/* not sure if this is a good notifier to use;
intended purpose is to update the UI so that the
new value is displayed in sliders/numfields */
WM_event_add_notifier(C, NC_WINDOW, NULL);
glDeleteTextures(1, &rc->gltex);
MEM_freeN(rc);
}
if(ret != OPERATOR_RUNNING_MODAL)
radial_control_cancel(C, op);
return ret;
}
@@ -3153,6 +3195,7 @@ static void WM_OT_radial_control(wmOperatorType *ot)
ot->invoke= radial_control_invoke;
ot->modal= radial_control_modal;
ot->cancel= radial_control_cancel;
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;