static int change_frame_invoke(bContext *C, wmOperator *op, const wmEvent *event) { ARegion *ar = CTX_wm_region(C); if (ar->regiontype == RGN_TYPE_WINDOW) { if (event->mval[1] > 16) return OPERATOR_PASS_THROUGH; } RNA_int_set(op->ptr, "frame", frame_from_event(C, event)); change_frame_apply(C, op); /* add temp handler */ WM_event_add_modal_handler(C, op); return OPERATOR_RUNNING_MODAL; }
static void node_find_call_cb(struct bContext *C, void *UNUSED(arg1), void *arg2) { SpaceNode *snode = CTX_wm_space_node(C); bNode *active = arg2; if (active) { ARegion *ar = CTX_wm_region(C); node_select_single(C, active); /* is note outside view? */ if (active->totr.xmax < ar->v2d.cur.xmin || active->totr.xmin > ar->v2d.cur.xmax || active->totr.ymax < ar->v2d.cur.ymin || active->totr.ymin > ar->v2d.cur.ymax) { space_node_view_flag(C, snode, ar, NODE_SELECT, U.smooth_viewtx); } } }
static int outliner_toggle_selected_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceOops *soops= CTX_wm_space_outliner(C); ARegion *ar= CTX_wm_region(C); Scene *scene= CTX_data_scene(C); if (outliner_has_one_flag(soops, &soops->tree, TSE_SELECTED, 1)) outliner_set_flag(soops, &soops->tree, TSE_SELECTED, 0); else outliner_set_flag(soops, &soops->tree, TSE_SELECTED, 1); soops->storeflag |= SO_TREESTORE_REDRAW; WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); ED_region_tag_redraw(ar); return OPERATOR_FINISHED; }
/* return active operator name when mouse is in box */ static const char *wm_dropbox_active(bContext *C, wmDrag *drag, wmEvent *event) { wmWindow *win= CTX_wm_window(C); ScrArea *sa= CTX_wm_area(C); ARegion *ar= CTX_wm_region(C); const char *name; name= dropbox_active(C, &win->handlers, drag, event); if(name) return name; name= dropbox_active(C, &sa->handlers, drag, event); if(name) return name; name= dropbox_active(C, &ar->handlers, drag, event); if(name) return name; return NULL; }
static int gp_camera_view_subrect(bContext *C, rctf *subrect) { View3D *v3d = CTX_wm_view3d(C); ARegion *ar = CTX_wm_region(C); if (v3d) { RegionView3D *rv3d = ar->regiondata; /* for camera view set the subrect */ if (rv3d->persp == RV3D_CAMOB) { Scene *scene = CTX_data_scene(C); ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, subrect, true); /* no shift */ return 1; } } return 0; }
static void ui_popup_block_remove(bContext *C, uiPopupBlockHandle *handle) { wmWindow *win = CTX_wm_window(C); bScreen *sc = CTX_wm_screen(C); ui_region_temp_remove(C, sc, handle->region); /* reset to region cursor (only if there's not another menu open) */ if (BLI_listbase_is_empty(&sc->regionbase)) { ED_region_cursor_set(win, CTX_wm_area(C), CTX_wm_region(C)); /* in case cursor needs to be changed again */ WM_event_add_mousemove(C); } if (handle->scrolltimer) { WM_event_remove_timer(CTX_wm_manager(C), win, handle->scrolltimer); } }
/* /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// */ static int mat_livedb_item_openclose(bContext *C, wmOperator *op, const wmEvent *event) { ARegion *ar = CTX_wm_region(C); SpaceLDB *slivedb = CTX_wm_space_mat_livedb(C); int all = RNA_boolean_get(op->ptr, "all"); LiveDbTreeElement *te; float fmval[2]; UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval + 1); for (te = slivedb->tree.first; te; te = te->next) { if (do_mat_livedb_item_openclose(C, slivedb, te, all, fmval)) break; } ED_region_tag_redraw(ar); return OPERATOR_FINISHED; } /* mat_livedb_item_openclose() */
/* /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// */ static int mat_livedb_toggle_selected_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceLDB *slivedb = CTX_wm_space_mat_livedb(C); ARegion *ar = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); if (mat_livedb_has_one_flag(slivedb, &slivedb->tree, TE_SELECTED, 1)) mat_livedb_set_flag(slivedb, &slivedb->tree, TE_SELECTED, 0); else mat_livedb_set_flag(slivedb, &slivedb->tree, TE_SELECTED, 1); slivedb->storeflag |= LDB_TREESTORE_REDRAW; WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); ED_region_tag_redraw(ar); return OPERATOR_FINISHED; } /* mat_livedb_toggle_selected_exec() */
/* /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// */ static int mat_livedb_item_rename(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) { ARegion *ar = CTX_wm_region(C); SpaceLDB *slivedb = CTX_wm_space_mat_livedb(C); bool change = false; LiveDbTreeElement *te; float fmval[2]; UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval + 1); for (te = slivedb->tree.first; te; te = te->next) { if (do_mat_livedb_item_rename(C, ar, slivedb, te, fmval)) { change = true; break; } } return change ? OPERATOR_FINISHED : OPERATOR_PASS_THROUGH; } /* mat_livedb_item_rename() */
/*** Cursor ***/ static void paint_draw_smooth_stroke(bContext *C, int x, int y, void *customdata) { Brush *brush = paint_brush(paint_get_active(CTX_data_scene(C))); PaintStroke *stroke = customdata; glColor4ubv(paint_get_active(CTX_data_scene(C))->paint_cursor_col); glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); if(stroke && brush && (brush->flag & BRUSH_SMOOTH_STROKE)) { ARegion *ar = CTX_wm_region(C); sdrawline(x, y, (int)stroke->last_mouse_position[0] - ar->winrct.xmin, (int)stroke->last_mouse_position[1] - ar->winrct.ymin); } glDisable(GL_BLEND); glDisable(GL_LINE_SMOOTH); }
static int outliner_operation(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) { Scene *scene = CTX_data_scene(C); ARegion *ar = CTX_wm_region(C); SpaceOops *soops = CTX_wm_space_outliner(C); TreeElement *te; float fmval[2]; UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval + 1); for (te = soops->tree.first; te; te = te->next) { if (do_outliner_operation_event(C, scene, ar, soops, te, event, fmval)) { break; } } return OPERATOR_FINISHED; }
/* event can enterkey, then it opens/closes */ static int outliner_item_activate(bContext *C, wmOperator *op, wmEvent *event) { Scene *scene= CTX_data_scene(C); ARegion *ar= CTX_wm_region(C); SpaceOops *soops= CTX_wm_space_outliner(C); TreeElement *te; float fmval[2]; int extend= RNA_boolean_get(op->ptr, "extend"); UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1); if(!ELEM3(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF, SO_KEYMAP) && !(soops->flag & SO_HIDE_RESTRICTCOLS) && fmval[0] > ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX) return OPERATOR_CANCELLED; for(te= soops->tree.first; te; te= te->next) { if(do_outliner_item_activate(C, scene, ar, soops, te, extend, fmval)) break; } if(te) { ED_undo_push(C, "Outliner click event"); } else { short selecting= -1; int row; /* get row number - 100 here is just a dummy value since we don't need the column */ UI_view2d_listview_view_to_cell(&ar->v2d, 1000, UI_UNIT_Y, 0.0f, OL_Y_OFFSET, fmval[0], fmval[1], NULL, &row); /* select relevant row */ if(outliner_select(soops, &soops->tree, &row, &selecting)) { soops->storeflag |= SO_TREESTORE_REDRAW; /* no need for undo push here, only changing outliner data which is * scene level - campbell */ /* ED_undo_push(C, "Outliner selection event"); */ } } ED_region_tag_redraw(ar); return OPERATOR_FINISHED; }
static int paintcurve_slide_modal(bContext *C, wmOperator *op, const wmEvent *event) { PointSlideData *psd = op->customdata; if (event->type == psd->event && event->val == KM_RELEASE) { MEM_freeN(psd); ED_paintcurve_undo_push_begin(op->type->name); ED_paintcurve_undo_push_end(); return OPERATOR_FINISHED; } switch (event->type) { case MOUSEMOVE: { ARegion *ar = CTX_wm_region(C); wmWindow *window = CTX_wm_window(C); float diff[2] = { event->mval[0] - psd->initial_loc[0], event->mval[1] - psd->initial_loc[1]}; if (psd->select == 1) { int i; for (i = 0; i < 3; i++) add_v2_v2v2(psd->pcp->bez.vec[i], diff, psd->point_initial_loc[i]); } else { add_v2_v2(diff, psd->point_initial_loc[psd->select]); copy_v2_v2(psd->pcp->bez.vec[psd->select], diff); if (psd->align) { char opposite = (psd->select == 0) ? 2 : 0; sub_v2_v2v2(diff, psd->pcp->bez.vec[1], psd->pcp->bez.vec[psd->select]); add_v2_v2v2(psd->pcp->bez.vec[opposite], psd->pcp->bez.vec[1], diff); } } WM_paint_cursor_tag_redraw(window, ar); break; } default: break; } return OPERATOR_RUNNING_MODAL; }
static void view_zoom_init(bContext *C, wmOperator *op, const wmEvent *event) { SpaceClip *sc = CTX_wm_space_clip(C); ARegion *ar = CTX_wm_region(C); ViewZoomData *vpd; op->customdata = vpd = MEM_callocN(sizeof(ViewZoomData), "ClipViewZoomData"); WM_cursor_modal(CTX_wm_window(C), BC_NSEW_SCROLLCURSOR); vpd->x = event->x; vpd->y = event->y; vpd->zoom = sc->zoom; vpd->event_type = event->type; ED_clip_mouse_pos(sc, ar, event->mval, vpd->location); WM_event_add_modal_handler(C, op); }
/* Get frame from mouse coordinates */ static int frame_from_event(bContext *C, const wmEvent *event) { ARegion *region = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); float viewx; int frame; /* convert from region coordinates to View2D 'tot' space */ viewx = UI_view2d_region_to_view_x(®ion->v2d, event->mval[0]); /* round result to nearest int (frames are ints!) */ frame = iroundf(viewx); if (scene->r.flag & SCER_LOCK_FRAME_SELECTION) { CLAMP(frame, PSFRA, PEFRA); } return frame; }
static int mask_flood_fill_exec(bContext *C, wmOperator *op) { ARegion *ar = CTX_wm_region(C); struct Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); struct MultiresModifierData *mmd = sculpt_multires_active(scene, ob); PaintMaskFloodMode mode; float value; DerivedMesh *dm; PBVH *pbvh; PBVHNode **nodes; int totnode, i; #ifdef _OPENMP Sculpt *sd = CTX_data_tool_settings(C)->sculpt; #endif mode = RNA_enum_get(op->ptr, "mode"); value = RNA_float_get(op->ptr, "value"); ED_sculpt_mask_layers_ensure(ob, mmd); dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); pbvh = dm->getPBVH(ob, dm); ob->sculpt->pbvh = pbvh; BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode); sculpt_undo_push_begin("Mask flood fill"); #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) for (i = 0; i < totnode; i++) { PBVHVertexIter vi; sculpt_undo_push_node(ob, nodes[i], SCULPT_UNDO_MASK); BKE_pbvh_vertex_iter_begin(pbvh, nodes[i], vi, PBVH_ITER_UNIQUE) { mask_flood_fill_set_elem(vi.mask, mode, value); } BKE_pbvh_vertex_iter_end; BKE_pbvh_node_mark_redraw(nodes[i]); if (BKE_pbvh_type(pbvh) == PBVH_GRIDS) multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED); }
/* context checked on having screen, window and area */ wmGesture *WM_gesture_new(bContext *C, wmEvent *event, int type) { wmGesture *gesture= MEM_callocN(sizeof(wmGesture), "new gesture"); wmWindow *window= CTX_wm_window(C); ARegion *ar= CTX_wm_region(C); int sx, sy; BLI_addtail(&window->gesture, gesture); gesture->type= type; gesture->event_type= event->type; gesture->swinid= ar->swinid; /* means only in area-region context! */ wm_subwindow_getorigin(window, gesture->swinid, &sx, &sy); if( ELEM5(type, WM_GESTURE_RECT, WM_GESTURE_CROSS_RECT, WM_GESTURE_TWEAK, WM_GESTURE_CIRCLE, WM_GESTURE_STRAIGHTLINE)) { rcti *rect= MEM_callocN(sizeof(rcti), "gesture rect new"); gesture->customdata= rect; rect->xmin= event->x - sx; rect->ymin= event->y - sy; if(type==WM_GESTURE_CIRCLE) { #ifdef GESTURE_MEMORY rect->xmax= circle_select_size; #else rect->xmax= 25; // XXX temp #endif } else { rect->xmax= event->x - sx; rect->ymax= event->y - sy; } } else if (ELEM(type, WM_GESTURE_LINES, WM_GESTURE_LASSO)) { short *lasso; gesture->customdata= lasso= MEM_callocN(2*sizeof(short)*WM_LASSO_MIN_POINTS, "lasso points"); lasso[0] = event->x - sx; lasso[1] = event->y - sy; gesture->points= 1; gesture->size = WM_LASSO_MIN_POINTS; } return gesture; }
static int delete_exec(bContext *C, wmOperator *op) { SpaceConsole *sc= CTX_wm_space_console(C); ARegion *ar= CTX_wm_region(C); ConsoleLine *ci= console_history_verify(C); const short type= RNA_enum_get(op->ptr, "type"); int done = 0; if(ci->len==0) { return OPERATOR_CANCELLED; } switch(type) { case DEL_NEXT_CHAR: if(ci->cursor < ci->len) { memmove(ci->line + ci->cursor, ci->line + ci->cursor+1, (ci->len - ci->cursor)+1); ci->len--; done= 1; } break; case DEL_PREV_CHAR: if(ci->cursor > 0) { ci->cursor--; /* same as above */ memmove(ci->line + ci->cursor, ci->line + ci->cursor+1, (ci->len - ci->cursor)+1); ci->len--; done= 1; } break; } if(!done) { return OPERATOR_CANCELLED; } else { console_select_offset(sc, -1); } console_textview_update_rect(sc, ar); ED_area_tag_redraw(CTX_wm_area(C)); return OPERATOR_FINISHED; }
static int view_all_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); ARegion *ar = CTX_wm_region(C); SpaceClip *sc = CTX_wm_space_clip(C); View2D *v2d = &ar->v2d; ViewAllUserData userdata; float extra; userdata.max = -FLT_MAX; userdata.min = FLT_MAX; clip_graph_tracking_values_iterate(sc, (sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0, (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0, &userdata, view_all_cb, NULL, NULL); /* set extents of view to start/end frames */ v2d->cur.xmin = (float) SFRA; v2d->cur.xmax = (float) EFRA; if (userdata.min < userdata.max) { v2d->cur.ymin = userdata.min; v2d->cur.ymax = userdata.max; } else { v2d->cur.ymin = -10; v2d->cur.ymax = 10; } /* we need an extra "buffer" factor on either side so that the endpoints are visible */ extra = 0.01f * BLI_rctf_size_x(&v2d->cur); v2d->cur.xmin -= extra; v2d->cur.xmax += extra; extra = 0.01f * BLI_rctf_size_y(&v2d->cur); v2d->cur.ymin -= extra; v2d->cur.ymax += extra; ED_region_tag_redraw(ar); return OPERATOR_FINISHED; }
static void view_zoom_apply(bContext *C, ViewZoomData *vpd, wmOperator *op, const wmEvent *event) { float factor; if (U.viewzoom == USER_ZOOM_CONT) { SpaceClip *sclip = CTX_wm_space_clip(C); double time = PIL_check_seconds_timer(); float time_step = (float)(time - vpd->timer_lastdraw); float fac; float zfac; if (U.uiflag & USER_ZOOM_HORIZ) { fac = (float)(event->x - vpd->x); } else { fac = (float)(event->y - vpd->y); } if (U.uiflag & USER_ZOOM_INVERT) { fac = -fac; } zfac = 1.0f + ((fac / 20.0f) * time_step); vpd->timer_lastdraw = time; factor = (sclip->zoom * zfac) / vpd->zoom; } else { float delta = event->x - vpd->x + event->y - vpd->y; if (U.uiflag & USER_ZOOM_INVERT) { delta *= -1; } factor = 1.0f + delta / 300.0f; } RNA_float_set(op->ptr, "factor", factor); sclip_zoom_set(C, vpd->zoom * factor, vpd->location); ED_region_tag_redraw(CTX_wm_region(C)); }
static void sclip_zoom_set(const bContext *C, float zoom, float location[2]) { SpaceClip *sc = CTX_wm_space_clip(C); ARegion *ar = CTX_wm_region(C); float oldzoom = sc->zoom; int width, height; sc->zoom = zoom; if (sc->zoom < 0.1f || sc->zoom > 4.0f) { /* check zoom limits */ ED_space_clip_get_size(sc, &width, &height); width *= sc->zoom; height *= sc->zoom; if ((width < 4) && (height < 4)) sc->zoom = oldzoom; else if (BLI_rcti_size_x(&ar->winrct) <= sc->zoom) sc->zoom = oldzoom; else if (BLI_rcti_size_y(&ar->winrct) <= sc->zoom) sc->zoom = oldzoom; } if ((U.uiflag & USER_ZOOM_TO_MOUSEPOS) && location) { float dx, dy; ED_space_clip_get_size(sc, &width, &height); dx = ((location[0] - 0.5f) * width - sc->xof) * (sc->zoom - oldzoom) / sc->zoom; dy = ((location[1] - 0.5f) * height - sc->yof) * (sc->zoom - oldzoom) / sc->zoom; if (sc->flag & SC_LOCK_SELECTION) { sc->xlockof += dx; sc->ylockof += dy; } else { sc->xof += dx; sc->yof += dy; } } }
/* event can enterkey, then it opens/closes */ static int outliner_item_openclose(bContext *C, wmOperator *op, wmEvent *event) { ARegion *ar= CTX_wm_region(C); SpaceOops *soops= CTX_wm_space_outliner(C); TreeElement *te; float fmval[2]; int all= RNA_boolean_get(op->ptr, "all"); UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1); for(te= soops->tree.first; te; te= te->next) { if(do_outliner_item_openclose(C, soops, te, all, fmval)) break; } ED_region_tag_redraw(ar); return OPERATOR_FINISHED; }
/* Moves the view to the cursor location, also used to make sure the view isnt outside the file */ void text_update_cursor_moved(bContext *C) { ScrArea *sa= CTX_wm_area(C); SpaceText *st= CTX_wm_space_text(C); Text *text; ARegion *ar; int i, x, winx= 0; if(ELEM3(NULL, st, st->text, st->text->curl)) return; text= st->text; for(ar=sa->regionbase.first; ar; ar= ar->next) if(ar->regiontype==RGN_TYPE_WINDOW) winx= ar->winx; winx -= TXT_SCROLL_WIDTH; text_update_character_width(st); i= txt_get_span(text->lines.first, text->sell); if(st->wordwrap) { int offl, offc; wrap_offset(st, CTX_wm_region(C), text->sell, text->selc, &offl, &offc); i+= offl; } if(st->top+st->viewlines <= i || st->top > i) st->top= i - st->viewlines/2; if(st->wordwrap) { st->left= 0; } else { x= text_draw(st, text->sell->line, st->left, text->selc, 0, 0, 0, NULL); if(x==0 || x>winx) st->left= text->curc-0.5*winx/st->cwidth; } if(st->top < 0) st->top= 0; if(st->left <0) st->left= 0; }
static int node_border_select_invoke(bContext *C, wmOperator *op, const wmEvent *event) { const bool tweak = RNA_boolean_get(op->ptr, "tweak"); if (tweak) { /* prevent initiating the border select if the mouse is over a node */ /* this allows border select on empty space, but drag-translate on nodes */ SpaceNode *snode = CTX_wm_space_node(C); ARegion *ar = CTX_wm_region(C); float mx, my; UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &mx, &my); if (node_under_mouse_tweak(snode->edittree, mx, my)) return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH; } return WM_border_select_invoke(C, op, event); }
void ANIM_center_frame(struct bContext *C, int smooth_viewtx) { ARegion *ar = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); float w = BLI_rctf_size_x(&ar->v2d.cur); rctf newrct; int nextfra, prevfra; switch (U.view_frame_type) { case ZOOM_FRAME_MODE_SECONDS: { const float fps = FPS; newrct.xmax = scene->r.cfra + U.view_frame_seconds * fps + 1; newrct.xmin = scene->r.cfra - U.view_frame_seconds * fps - 1; newrct.ymax = ar->v2d.cur.ymax; newrct.ymin = ar->v2d.cur.ymin; break; } /* hardest case of all, look for all keyframes around frame and display those */ case ZOOM_FRAME_MODE_KEYFRAMES: if (find_prev_next_keyframes(C, &nextfra, &prevfra)) { newrct.xmax = nextfra; newrct.xmin = prevfra; newrct.ymax = ar->v2d.cur.ymax; newrct.ymin = ar->v2d.cur.ymin; break; } /* else drop through, keep range instead */ ATTR_FALLTHROUGH; case ZOOM_FRAME_MODE_KEEP_RANGE: default: newrct.xmax = scene->r.cfra + (w / 2); newrct.xmin = scene->r.cfra - (w / 2); newrct.ymax = ar->v2d.cur.ymax; newrct.ymin = ar->v2d.cur.ymin; break; } UI_view2d_smooth_view(C, ar, &newrct, smooth_viewtx); }
static int knifeproject_exec(bContext *C, wmOperator *op) { ARegion *ar = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BKE_editmesh_from_object(obedit); const bool cut_through = RNA_boolean_get(op->ptr, "cut_through"); LinkNode *polys = NULL; CTX_DATA_BEGIN (C, Object *, ob, selected_objects) { if (ob != obedit) { polys = knifeproject_poly_from_object(ar, scene, ob, polys); } } CTX_DATA_END; if (polys) { EDBM_mesh_knife(C, polys, true, cut_through); /* select only tagged faces */ BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, false); /* not essential, but switch out of vertex mode since the * selected regions wont be nicely isolated after flushing. * note: call after de-select to avoid selection flushing */ EDBM_selectmode_disable(scene, em, SCE_SELECT_VERTEX, SCE_SELECT_EDGE); BM_mesh_elem_hflag_enable_test(em->bm, BM_FACE, BM_ELEM_SELECT, true, false, BM_ELEM_TAG); BM_mesh_select_mode_flush(em->bm); BLI_linklist_freeN(polys); return OPERATOR_FINISHED; } else { BKE_report(op->reports, RPT_ERROR, "No other selected objects found to use for projection"); return OPERATOR_CANCELLED; } }
static int walk_modal(bContext *C, wmOperator *op, const wmEvent *event) { int exit_code; bool do_draw = false; WalkInfo *walk = op->customdata; RegionView3D *rv3d = walk->rv3d; Object *walk_object = ED_view3d_cameracontrol_object_get(walk->v3d_camera_control); walk->redraw = false; walkEvent(C, op, walk, event); if (walk->ndof) { /* 3D mouse overrules [2D mouse + timer] */ if (event->type == NDOF_MOTION) { walkApply_ndof(C, walk); } } else if (event->type == TIMER && event->customdata == walk->timer) { walkApply(C, op, walk); } do_draw |= walk->redraw; exit_code = walkEnd(C, walk); if (exit_code != OPERATOR_RUNNING_MODAL) do_draw = true; if (do_draw) { if (rv3d->persp == RV3D_CAMOB) { WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, walk_object); } // puts("redraw!"); // too frequent, commented with NDOF_WALK_DRAW_TOOMUCH for now ED_region_tag_redraw(CTX_wm_region(C)); } if (ELEM(exit_code, OPERATOR_FINISHED, OPERATOR_CANCELLED)) ED_area_headerprint(CTX_wm_area(C), NULL); return exit_code; }
static int outliner_one_level_exec(bContext *C, wmOperator *op) { SpaceOops *soops= CTX_wm_space_outliner(C); ARegion *ar= CTX_wm_region(C); int add= RNA_boolean_get(op->ptr, "open"); int level; level= outliner_has_one_flag(soops, &soops->tree, TSE_CLOSED, 1); if(add==1) { if(level) outliner_openclose_level(soops, &soops->tree, 1, level, 1); } else { if(level==0) level= outliner_count_levels(soops, &soops->tree, 0); if(level) outliner_openclose_level(soops, &soops->tree, 1, level-1, 0); } ED_region_tag_redraw(ar); return OPERATOR_FINISHED; }
void ED_mask_draw(const bContext *C, const char draw_flag, const char draw_type) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); Mask *mask = CTX_data_edit_mask(C); int width, height; float aspx, aspy; float xscale, yscale; if (!mask) return; ED_mask_get_size(sa, &width, &height); ED_mask_get_aspect(sa, ar, &aspx, &aspy); UI_view2d_scale_get(&ar->v2d, &xscale, &yscale); draw_masklays(C, mask, draw_flag, draw_type, width, height, xscale * aspx, yscale * aspy); }
static int sample_invoke(bContext *C, wmOperator *op, const wmEvent *event) { ARegion *ar = CTX_wm_region(C); SpaceSeq *sseq = CTX_wm_space_seq(C); ImageSampleInfo *info; if (sseq->mainb != SEQ_DRAW_IMG_IMBUF) return OPERATOR_CANCELLED; info = MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo"); info->art = ar->type; info->draw_handle = ED_region_draw_cb_activate(ar->type, sample_draw, info, REGION_DRAW_POST_PIXEL); op->customdata = info; sample_apply(C, op, event); WM_event_add_modal_handler(C, op); return OPERATOR_RUNNING_MODAL; }