/* mark menu-regions to redraw if overlapped with rect */ static void wm_flush_regions_up(bScreen *screen, rcti *dirty) { ARegion *ar; for(ar= screen->regionbase.first; ar; ar= ar->next) { if(BLI_isect_rcti(dirty, &ar->winrct, NULL)) { ar->do_draw= RGN_DRAW; memset(&ar->drawrct, 0, sizeof(ar->drawrct)); ar->swap= WIN_NONE_OK; } } }
static int file_border_select_exec(bContext *C, wmOperator *op) { ARegion *ar= CTX_wm_region(C); rcti rect; FileSelect ret; short select= (RNA_int_get(op->ptr, "gesture_mode")==GESTURE_MODAL_SELECT); rect.xmin= RNA_int_get(op->ptr, "xmin"); rect.ymin= RNA_int_get(op->ptr, "ymin"); rect.xmax= RNA_int_get(op->ptr, "xmax"); rect.ymax= RNA_int_get(op->ptr, "ymax"); BLI_isect_rcti(&(ar->v2d.mask), &rect, &rect); ret = file_select(C, &rect, select ? FILE_SEL_ADD : FILE_SEL_REMOVE, 0); if (FILE_SELECT_DIR == ret) { WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); } else if (FILE_SELECT_FILE == ret) { WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_PARAMS, NULL); } return OPERATOR_FINISHED; }
static int file_border_select_modal(bContext *C, wmOperator *op, wmEvent *event) { ARegion *ar= CTX_wm_region(C); SpaceFile *sfile= CTX_wm_space_file(C); FileSelectParams *params = ED_fileselect_get_params(sfile); FileSelection sel; rcti rect; int result; result= WM_border_select_modal(C, op, event); if(result==OPERATOR_RUNNING_MODAL) { rect.xmin= RNA_int_get(op->ptr, "xmin"); rect.ymin= RNA_int_get(op->ptr, "ymin"); rect.xmax= RNA_int_get(op->ptr, "xmax"); rect.ymax= RNA_int_get(op->ptr, "ymax"); BLI_isect_rcti(&(ar->v2d.mask), &rect, &rect); sel = file_selection_get(C, &rect, 0); if ( (sel.first != params->sel_first) || (sel.last != params->sel_last) ) { file_deselect_all(sfile, HILITED_FILE); filelist_select(sfile->files, &sel, FILE_SEL_ADD, HILITED_FILE, CHECK_ALL); WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_PARAMS, NULL); } params->sel_first = sel.first; params->sel_last = sel.last; }else { params->active_file = -1; params->sel_first = params->sel_last = -1; file_deselect_all(sfile, HILITED_FILE); WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_PARAMS, NULL); } return result; }
void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect) { CurveMapping *cumap; CurveMap *cuma; CurveMapPoint *cmp; float fx, fy, fac[2], zoomx, zoomy, offsx, offsy; GLint scissor[4]; rcti scissor_new; int a; cumap= (CurveMapping *)(but->editcumap? but->editcumap: but->poin); cuma= cumap->cm+cumap->cur; /* need scissor test, curve can draw outside of boundary */ glGetIntegerv(GL_VIEWPORT, scissor); scissor_new.xmin= ar->winrct.xmin + rect->xmin; scissor_new.ymin= ar->winrct.ymin + rect->ymin; scissor_new.xmax= ar->winrct.xmin + rect->xmax; scissor_new.ymax= ar->winrct.ymin + rect->ymax; BLI_isect_rcti(&scissor_new, &ar->winrct, &scissor_new); glScissor(scissor_new.xmin, scissor_new.ymin, scissor_new.xmax-scissor_new.xmin, scissor_new.ymax-scissor_new.ymin); /* calculate offset and zoom */ zoomx= (rect->xmax-rect->xmin-2.0f*but->aspect)/(cumap->curr.xmax - cumap->curr.xmin); zoomy= (rect->ymax-rect->ymin-2.0f*but->aspect)/(cumap->curr.ymax - cumap->curr.ymin); offsx= cumap->curr.xmin-but->aspect/zoomx; offsy= cumap->curr.ymin-but->aspect/zoomy; /* backdrop */ if(cumap->flag & CUMA_DO_CLIP) { glColor3ubvShade((unsigned char *)wcol->inner, -20); glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax); glColor3ubv((unsigned char*)wcol->inner); glRectf(rect->xmin + zoomx*(cumap->clipr.xmin-offsx), rect->ymin + zoomy*(cumap->clipr.ymin-offsy), rect->xmin + zoomx*(cumap->clipr.xmax-offsx), rect->ymin + zoomy*(cumap->clipr.ymax-offsy)); } else { glColor3ubv((unsigned char*)wcol->inner); glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax); } /* grid, every .25 step */ glColor3ubvShade((unsigned char *)wcol->inner, -16); ui_draw_but_curve_grid(rect, zoomx, zoomy, offsx, offsy, 0.25f); /* grid, every 1.0 step */ glColor3ubvShade((unsigned char *)wcol->inner, -24); ui_draw_but_curve_grid(rect, zoomx, zoomy, offsx, offsy, 1.0f); /* axes */ glColor3ubvShade((unsigned char *)wcol->inner, -50); glBegin(GL_LINES); glVertex2f(rect->xmin, rect->ymin + zoomy*(-offsy)); glVertex2f(rect->xmax, rect->ymin + zoomy*(-offsy)); glVertex2f(rect->xmin + zoomx*(-offsx), rect->ymin); glVertex2f(rect->xmin + zoomx*(-offsx), rect->ymax); glEnd(); /* magic trigger for curve backgrounds */ if (but->a1 != -1) { if (but->a1 == UI_GRAD_H) { rcti grid; float col[3]= {0.0f, 0.0f, 0.0f}; /* dummy arg */ grid.xmin = rect->xmin + zoomx*(-offsx); grid.xmax = rect->xmax + zoomx*(-offsx); grid.ymin = rect->ymin + zoomy*(-offsy); grid.ymax = rect->ymax + zoomy*(-offsy); glEnable(GL_BLEND); ui_draw_gradient(&grid, col, UI_GRAD_H, 0.5f); glDisable(GL_BLEND); } } /* cfra option */ /* XXX 2.48 if(cumap->flag & CUMA_DRAW_CFRA) { glColor3ub(0x60, 0xc0, 0x40); glBegin(GL_LINES); glVertex2f(rect->xmin + zoomx*(cumap->sample[0]-offsx), rect->ymin); glVertex2f(rect->xmin + zoomx*(cumap->sample[0]-offsx), rect->ymax); glEnd(); }*/ /* sample option */ /* XXX 2.48 * if(cumap->flag & CUMA_DRAW_SAMPLE) { if(cumap->cur==3) { float lum= cumap->sample[0]*0.35f + cumap->sample[1]*0.45f + cumap->sample[2]*0.2f; glColor3ub(240, 240, 240); glBegin(GL_LINES); glVertex2f(rect->xmin + zoomx*(lum-offsx), rect->ymin); glVertex2f(rect->xmin + zoomx*(lum-offsx), rect->ymax); glEnd(); } else { if(cumap->cur==0) glColor3ub(240, 100, 100); else if(cumap->cur==1) glColor3ub(100, 240, 100); else glColor3ub(100, 100, 240); glBegin(GL_LINES); glVertex2f(rect->xmin + zoomx*(cumap->sample[cumap->cur]-offsx), rect->ymin); glVertex2f(rect->xmin + zoomx*(cumap->sample[cumap->cur]-offsx), rect->ymax); glEnd(); } }*/ /* the curve */ glColor3ubv((unsigned char*)wcol->item); glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); glBegin(GL_LINE_STRIP); if(cuma->table==NULL) curvemapping_changed(cumap, 0); /* 0 = no remove doubles */ cmp= cuma->table; /* first point */ if((cuma->flag & CUMA_EXTEND_EXTRAPOLATE)==0) glVertex2f(rect->xmin, rect->ymin + zoomy*(cmp[0].y-offsy)); else { fx= rect->xmin + zoomx*(cmp[0].x-offsx + cuma->ext_in[0]); fy= rect->ymin + zoomy*(cmp[0].y-offsy + cuma->ext_in[1]); glVertex2f(fx, fy); } for(a=0; a<=CM_TABLE; a++) { fx= rect->xmin + zoomx*(cmp[a].x-offsx); fy= rect->ymin + zoomy*(cmp[a].y-offsy); glVertex2f(fx, fy); } /* last point */ if((cuma->flag & CUMA_EXTEND_EXTRAPOLATE)==0) glVertex2f(rect->xmax, rect->ymin + zoomy*(cmp[CM_TABLE].y-offsy)); else { fx= rect->xmin + zoomx*(cmp[CM_TABLE].x-offsx - cuma->ext_out[0]); fy= rect->ymin + zoomy*(cmp[CM_TABLE].y-offsy - cuma->ext_out[1]); glVertex2f(fx, fy); } glEnd(); glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); /* the points, use aspect to make them visible on edges */ cmp= cuma->curve; glPointSize(3.0f); bglBegin(GL_POINTS); for(a=0; a<cuma->totpoint; a++) { if(cmp[a].flag & SELECT) UI_ThemeColor(TH_TEXT_HI); else UI_ThemeColor(TH_TEXT); fac[0]= rect->xmin + zoomx*(cmp[a].x-offsx); fac[1]= rect->ymin + zoomy*(cmp[a].y-offsy); bglVertex2fv(fac); } bglEnd(); glPointSize(1.0f); /* restore scissortest */ glScissor(scissor[0], scissor[1], scissor[2], scissor[3]); /* outline */ glColor3ubv((unsigned char*)wcol->outline); fdrawbox(rect->xmin, rect->ymin, rect->xmax, rect->ymax); }
static int game_engine_exec(bContext *C, wmOperator *op) { #ifdef WITH_GAMEENGINE Scene *startscene = CTX_data_scene(C); ScrArea /* *sa, */ /* UNUSED */ *prevsa= CTX_wm_area(C); ARegion *ar, *prevar= CTX_wm_region(C); wmWindow *prevwin= CTX_wm_window(C); RegionView3D *rv3d; rcti cam_frame; (void)op; /* unused */ // bad context switch .. if(!ED_view3d_context_activate(C)) return OPERATOR_CANCELLED; /* redraw to hide any menus/popups, we don't go back to the window manager until after this operator exits */ WM_redraw_windows(C); rv3d= CTX_wm_region_view3d(C); /* sa= CTX_wm_area(C); */ /* UNUSED */ ar= CTX_wm_region(C); view3d_operator_needs_opengl(C); game_set_commmandline_options(&startscene->gm); if((rv3d->persp == RV3D_CAMOB) && (startscene->gm.framing.type == SCE_GAMEFRAMING_BARS) && (startscene->gm.stereoflag != STEREO_DOME)) { /* Letterbox */ rctf cam_framef; ED_view3d_calc_camera_border(startscene, ar, CTX_wm_view3d(C), rv3d, &cam_framef, FALSE); cam_frame.xmin = cam_framef.xmin + ar->winrct.xmin; cam_frame.xmax = cam_framef.xmax + ar->winrct.xmin; cam_frame.ymin = cam_framef.ymin + ar->winrct.ymin; cam_frame.ymax = cam_framef.ymax + ar->winrct.ymin; BLI_isect_rcti(&ar->winrct, &cam_frame, &cam_frame); } else { cam_frame.xmin = ar->winrct.xmin; cam_frame.xmax = ar->winrct.xmax; cam_frame.ymin = ar->winrct.ymin; cam_frame.ymax = ar->winrct.ymax; } SaveState(C, prevwin); StartKetsjiShell(C, ar, &cam_frame, 1); /* window wasnt closed while the BGE was running */ if(BLI_findindex(&CTX_wm_manager(C)->windows, prevwin) == -1) { prevwin= NULL; CTX_wm_window_set(C, NULL); } ED_area_tag_redraw(CTX_wm_area(C)); if(prevwin) { /* restore context, in case it changed in the meantime, for example by working in another window or closing it */ CTX_wm_region_set(C, prevar); CTX_wm_window_set(C, prevwin); CTX_wm_area_set(C, prevsa); } RestoreState(C, prevwin); //XXX restore_all_scene_cfra(scene_cfra_store); set_scene_bg(CTX_data_main(C), startscene); //XXX scene_update_for_newframe(bmain, scene, scene->lay); return OPERATOR_FINISHED; #else (void)C; /* unused */ BKE_report(op->reports, RPT_ERROR, "Game engine is disabled in this build"); return OPERATOR_CANCELLED; #endif }