Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_sequencer/sequencer_view.c
| Show First 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| struct Depsgraph *depsgraph = CTX_data_depsgraph(C); | struct Depsgraph *depsgraph = CTX_data_depsgraph(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SpaceSeq *sseq = (SpaceSeq *) CTX_wm_space_data(C); | SpaceSeq *sseq = (SpaceSeq *) CTX_wm_space_data(C); | ||||
| ARegion *ar = CTX_wm_region(C); | ARegion *ar = CTX_wm_region(C); | ||||
| ImBuf *ibuf = sequencer_ibuf_get(bmain, depsgraph, scene, sseq, CFRA, 0, NULL); | ImBuf *ibuf = sequencer_ibuf_get(bmain, depsgraph, scene, sseq, CFRA, 0, NULL); | ||||
| ImageSampleInfo *info = op->customdata; | ImageSampleInfo *info = op->customdata; | ||||
| float fx, fy; | |||||
| if (ibuf == NULL) { | if (ibuf == NULL) { | ||||
| IMB_freeImBuf(ibuf); | IMB_freeImBuf(ibuf); | ||||
| info->draw = 0; | info->draw = 0; | ||||
| return; | return; | ||||
| } | } | ||||
| short scene_scale_size = sseq->render_size ? 100 : scene->r.size; | |||||
| float rectx = (float) scene->r.xsch * ((float) scene_scale_size / 100.0f); | |||||
| float recty = (float) scene->r.ysch * ((float) scene_scale_size / 100.0f); | |||||
| float scale_x = (float) ibuf->x / rectx; | |||||
| float scale_y = (float) ibuf->y / recty; | |||||
| float fx, fy; | |||||
| /* max coords are +/- (rect* / 2) | |||||
| */ | |||||
| UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fx, &fy); | UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fx, &fy); | ||||
| fx += (float) ibuf->x / 2.0f; | fx += rectx / 2.0f; | ||||
| fy += (float) ibuf->y / 2.0f; | fy += recty / 2.0f; | ||||
| /* to get ibuf coords we have to scale by (ibuf->* / rect*) | |||||
| */ | |||||
| fx *= scale_x; | |||||
| fy *= scale_y; | |||||
| if (fx >= 0.0f && fy >= 0.0f && fx < ibuf->x && fy < ibuf->y) { | if (fx >= 0.0f && fy >= 0.0f && fx < ibuf->x && fy < ibuf->y) { | ||||
| const float *fp; | const float *fp; | ||||
| unsigned char *cp; | unsigned char *cp; | ||||
| int x = (int) fx, y = (int) fy; | int x = (int) fx, y = (int) fy; | ||||
| info->x = x; | /* we will report mouse position on unscaled image */ | ||||
| info->y = y; | info->x = 1 + x / scale_x; | ||||
| info->y = 1 + y / scale_y; | |||||
| info->draw = 1; | info->draw = 1; | ||||
| info->channels = ibuf->channels; | info->channels = ibuf->channels; | ||||
| info->colp = NULL; | info->colp = NULL; | ||||
| info->colfp = NULL; | info->colfp = NULL; | ||||
| if (ibuf->rect) { | if (ibuf->rect) { | ||||
| cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x); | cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x); | ||||
| ▲ Show 20 Lines • Show All 117 Lines • Show Last 20 Lines | |||||