void sound_header_buttons(const bContext *C, ARegion *ar) { ScrArea *sa= CTX_wm_area(C); uiBlock *block; int xco, yco= 3; block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS); uiBlockSetHandleFunc(block, do_sound_buttons, NULL); xco= ED_area_header_standardbuttons(C, block, yco); if((sa->flag & HEADER_NO_PULLDOWN)==0) { int xmax; xmax= GetButStringLength("View"); uiDefPulldownBut(block, dummy_viewmenu, CTX_wm_area(C), "View", xco, yco-2, xmax-3, UI_UNIT_Y, ""); xco+=UI_UNIT_X+xmax; } uiBlockSetEmboss(block, UI_EMBOSS); /* always as last */ UI_view2d_totRect_set(&ar->v2d, xco+UI_UNIT_X+80, ar->v2d.tot.ymax-ar->v2d.tot.ymin); uiEndBlock(C, block); uiDrawBlock(C, block); }
void file_calc_previews(const bContext *C, ARegion *ar) { SpaceFile *sfile = CTX_wm_space_file(C); View2D *v2d = &ar->v2d; ED_fileselect_init_layout(sfile, ar); UI_view2d_totRect_set(v2d, sfile->layout->width, sfile->layout->height); }
void file_calc_previews(const bContext *C, ARegion *ar) { SpaceFile *sfile= CTX_wm_space_file(C); View2D *v2d= &ar->v2d; ED_fileselect_init_layout(sfile, ar); /* +SCROLL_HEIGHT is bad hack to work around issue in UI_view2d_totRect_set */ UI_view2d_totRect_set(v2d, sfile->layout->width, sfile->layout->height+V2D_SCROLL_HEIGHT); }
void buttons_header_buttons(const bContext *C, ARegion *ar) { SpaceButs *sbuts = CTX_wm_space_buts(C); uiBlock *block; uiBut *but; int xco, yco = 2; buttons_context_compute(C, sbuts); block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiBlockSetHandleFunc(block, do_buttons_buttons, NULL); xco = ED_area_header_switchbutton(C, block, yco); uiBlockSetEmboss(block, UI_EMBOSS); xco -= UI_UNIT_X; // Default panels uiBlockBeginAlign(block); #define BUTTON_HEADER_CTX(_ctx, _icon, _tip) \ if (sbuts->pathflag & (1 << _ctx)) { \ but = uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, _icon, xco += BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)_ctx, 0, 0, TIP_(_tip)); \ uiButClearFlag(but, UI_BUT_UNDO); \ } \ BUTTON_HEADER_CTX(BCONTEXT_RENDER, ICON_SCENE, N_("Render")) BUTTON_HEADER_CTX(BCONTEXT_SCENE, ICON_SCENE_DATA, N_("Scene")); BUTTON_HEADER_CTX(BCONTEXT_WORLD, ICON_WORLD, N_("World")); BUTTON_HEADER_CTX(BCONTEXT_OBJECT, ICON_OBJECT_DATA, N_("Object")); BUTTON_HEADER_CTX(BCONTEXT_CONSTRAINT, ICON_CONSTRAINT, N_("Object Constraints")); BUTTON_HEADER_CTX(BCONTEXT_MODIFIER, ICON_MODIFIER, N_("Object Modifiers")); BUTTON_HEADER_CTX(BCONTEXT_DATA, sbuts->dataicon, N_("Object Data")); BUTTON_HEADER_CTX(BCONTEXT_BONE, ICON_BONE_DATA, N_("Bone")); BUTTON_HEADER_CTX(BCONTEXT_BONE_CONSTRAINT, ICON_CONSTRAINT_BONE, N_("Bone Constraints")); BUTTON_HEADER_CTX(BCONTEXT_MATERIAL, ICON_MATERIAL, N_("Material")); BUTTON_HEADER_CTX(BCONTEXT_TEXTURE, ICON_TEXTURE, N_("Textures")); BUTTON_HEADER_CTX(BCONTEXT_PARTICLE, ICON_PARTICLES, N_("Particles")); BUTTON_HEADER_CTX(BCONTEXT_PHYSICS, ICON_PHYSICS, N_("Physics")); #undef BUTTON_HEADER_CTX xco += BUT_UNIT_X; uiBlockEndAlign(block); /* always as last */ UI_view2d_totRect_set(&ar->v2d, xco + (UI_UNIT_X / 2), ar->v2d.tot.ymax - ar->v2d.tot.ymin); uiEndBlock(C, block); uiDrawBlock(C, block); }
/* /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// */ void draw_mat_livedb(const bContext *C) { uiBlock *block; Main *mainvar = CTX_data_main(C); Scene *scene = CTX_data_scene(C); ARegion *ar = CTX_wm_region(C); View2D *v2d = &ar->v2d; SpaceLDB *slivedb = CTX_wm_space_mat_livedb(C); int sizey = 0, sizex = 0, sizex_rna = 0; if(!slivedb) return; if(!strlen(slivedb->server_address)) strcpy(slivedb->server_address, "127.0.0.1"); mat_livedb_build_tree(mainvar, slivedb, 0); /* always */ /* get extents of data */ mat_livedb_height(slivedb, &slivedb->tree, &sizey); mat_livedb_width(slivedb, &slivedb->tree, &sizex, 0); /* adds vertical offset */ sizey += LDB_Y_OFFSET; /* update size of tot-rect (extents of data/viewable area) */ UI_view2d_totRect_set(v2d, sizex, sizey); /* force display to pixel coords */ v2d->flag |= (V2D_PIXELOFS_X | V2D_PIXELOFS_Y); /* set matrix for 2d-view controls */ UI_view2d_view_ortho(v2d); /* draw LiveDB stuff */ block = UI_block_begin(C, ar, __func__, UI_EMBOSS); mat_livedb_draw_tree((bContext *)C, block, ar, slivedb); mat_livedb_draw_mat_preview(block, scene, ar, slivedb, &slivedb->tree); /* draw edit buttons if nessecery */ mat_draw_rename_buttons(C, block, ar, slivedb, &slivedb->tree); UI_block_end(C, block); UI_block_draw(C, block); /* clear flag that allows quick redraws */ slivedb->storeflag &= ~LDB_TREESTORE_REDRAW; } /* draw_mat_livedb() */
/* draws checkerboard background for transparent content */ static void sequencer_draw_background(const SpaceSeq *sseq, View2D *v2d, const float viewrect[2]) { /* setting up the view */ UI_view2d_totRect_set(v2d, viewrect[0] + 0.5f, viewrect[1] + 0.5f); UI_view2d_curRect_validate(v2d); UI_view2d_view_ortho(v2d); /* only draw alpha for main buffer */ if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) { if (sseq->flag & SEQ_USE_ALPHA) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); fdrawcheckerboard(v2d->tot.xmin, v2d->tot.ymin, v2d->tot.xmax, v2d->tot.ymax); glColor4f(1.0, 1.0, 1.0, 1.0); } } }
/* left hand part */ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; View2D *v2d = &ar->v2d; float y = 0.0f, height; size_t items; int i = 0; /* build list of channels to draw */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* Update max-extent of channels here (taking into account scrollers): * - this is done to allow the channel list to be scrollable, but must be done here * to avoid regenerating the list again and/or also because channels list is drawn first * - offset of ACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for * start of list offset, and the second is as a correction for the scrollers. */ height = (float)((items * ACHANNEL_STEP) + (ACHANNEL_HEIGHT * 2)); UI_view2d_totRect_set(v2d, ar->winx, height); /* loop through channels, and set up drawing depending on their type */ { /* first pass: just the standard GL-drawing for backdrop + text */ y = (float)ACHANNEL_FIRST; for (ale = anim_data.first, i = 0; ale; ale = ale->next, i++) { const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF); const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF); /* check if visible */ if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) { /* draw all channels using standard channel-drawing API */ ANIM_channel_draw(ac, ale, yminc, ymaxc); } /* adjust y-position for next one */ y -= ACHANNEL_STEP; } } { /* second pass: widgets */ uiBlock *block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); size_t channel_index = 0; y = (float)ACHANNEL_FIRST; /* set blending again, as may not be set in previous step */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); for (ale = anim_data.first, i = 0; ale; ale = ale->next, i++) { const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF); const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF); /* check if visible */ if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) { /* draw all channels using standard channel-drawing API */ ANIM_channel_draw_widgets(C, ac, ale, block, yminc, ymaxc, channel_index); } /* adjust y-position for next one */ y -= ACHANNEL_STEP; channel_index++; } uiEndBlock(C, block); uiDrawBlock(C, block); glDisable(GL_BLEND); } /* free tempolary channels */ BLI_freelistN(&anim_data); }
void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq, int cfra, int frame_ofs, int draw_overlay) { struct Main *bmain = CTX_data_main(C); struct ImBuf *ibuf = NULL; struct ImBuf *scope = NULL; struct View2D *v2d = &ar->v2d; /* int rectx, recty; */ /* UNUSED */ float viewrectx, viewrecty; float render_size = 0.0; float proxy_size = 100.0; float col[3]; GLuint texid; GLuint last_texid; void *display_buffer; void *cache_handle = NULL; const int is_imbuf = ED_space_sequencer_check_show_imbuf(sseq); int format, type; bool glsl_used = false; if (G.is_rendering == FALSE && (scene->r.seq_flag & R_SEQ_GL_PREV) == 0) { /* stop all running jobs, except screen one. currently previews frustrate Render * needed to make so sequencer's rendering doesn't conflict with compositor */ WM_jobs_kill_type(CTX_wm_manager(C), WM_JOB_TYPE_COMPOSITE); if ((scene->r.seq_flag & R_SEQ_GL_PREV) == 0) { /* in case of final rendering used for preview, kill all previews, * otherwise threading conflict will happen in rendering module */ WM_jobs_kill_type(CTX_wm_manager(C), WM_JOB_TYPE_RENDER_PREVIEW); } } render_size = sseq->render_size; if (render_size == 0) { render_size = scene->r.size; } else { proxy_size = render_size; } if (render_size < 0) { return; } viewrectx = (render_size * (float)scene->r.xsch) / 100.0f; viewrecty = (render_size * (float)scene->r.ysch) / 100.0f; /* rectx = viewrectx + 0.5f; */ /* UNUSED */ /* recty = viewrecty + 0.5f; */ /* UNUSED */ if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) { viewrectx *= scene->r.xasp / scene->r.yasp; viewrectx /= proxy_size / 100.0f; viewrecty /= proxy_size / 100.0f; } if (!draw_overlay || sseq->overlay_type == SEQ_DRAW_OVERLAY_REFERENCE) { UI_GetThemeColor3fv(TH_SEQ_PREVIEW, col); glClearColor(col[0], col[1], col[2], 0.0); glClear(GL_COLOR_BUFFER_BIT); } /* without this colors can flicker from previous opengl state */ glColor4ub(255, 255, 255, 255); UI_view2d_totRect_set(v2d, viewrectx + 0.5f, viewrecty + 0.5f); UI_view2d_curRect_validate(v2d); /* only initialize the preview if a render is in progress */ if (G.is_rendering) return; ibuf = sequencer_ibuf_get(bmain, scene, sseq, cfra, frame_ofs); if (ibuf == NULL) return; if (ibuf->rect == NULL && ibuf->rect_float == NULL) return; if (sseq->mainb != SEQ_DRAW_IMG_IMBUF || sseq->zebra != 0) { SequencerScopes *scopes = &sseq->scopes; sequencer_check_scopes(scopes, ibuf); switch (sseq->mainb) { case SEQ_DRAW_IMG_IMBUF: if (!scopes->zebra_ibuf) { ImBuf *display_ibuf = IMB_dupImBuf(ibuf); if (display_ibuf->rect_float) { IMB_colormanagement_imbuf_make_display_space(display_ibuf, &scene->view_settings, &scene->display_settings); } scopes->zebra_ibuf = make_zebra_view_from_ibuf(display_ibuf, sseq->zebra); IMB_freeImBuf(display_ibuf); } scope = scopes->zebra_ibuf; break; case SEQ_DRAW_IMG_WAVEFORM: if ((sseq->flag & SEQ_DRAW_COLOR_SEPARATED) != 0) { if (!scopes->sep_waveform_ibuf) scopes->sep_waveform_ibuf = sequencer_make_scope(scene, ibuf, make_sep_waveform_view_from_ibuf); scope = scopes->sep_waveform_ibuf; } else { if (!scopes->waveform_ibuf) scopes->waveform_ibuf = sequencer_make_scope(scene, ibuf, make_waveform_view_from_ibuf); scope = scopes->waveform_ibuf; } break; case SEQ_DRAW_IMG_VECTORSCOPE: if (!scopes->vector_ibuf) scopes->vector_ibuf = sequencer_make_scope(scene, ibuf, make_vectorscope_view_from_ibuf); scope = scopes->vector_ibuf; break; case SEQ_DRAW_IMG_HISTOGRAM: if (!scopes->histogram_ibuf) scopes->histogram_ibuf = sequencer_make_scope(scene, ibuf, make_histogram_view_from_ibuf); scope = scopes->histogram_ibuf; break; } scopes->reference_ibuf = ibuf; } /* setting up the view - actual drawing starts here */ UI_view2d_view_ortho(v2d); /* only draw alpha for main buffer */ if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) { if (sseq->flag & SEQ_USE_ALPHA) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); fdrawcheckerboard(v2d->tot.xmin, v2d->tot.ymin, v2d->tot.xmax, v2d->tot.ymax); glColor4f(1.0, 1.0, 1.0, 1.0); } } if (scope) { IMB_freeImBuf(ibuf); ibuf = scope; if (ibuf->rect_float && ibuf->rect == NULL) { IMB_rect_from_float(ibuf); } display_buffer = (unsigned char *)ibuf->rect; format = GL_RGBA; type = GL_UNSIGNED_BYTE; } else { bool force_fallback = false; force_fallback |= (U.image_draw_method != IMAGE_DRAW_METHOD_GLSL); force_fallback |= (ibuf->dither != 0.0f); if (force_fallback) { /* Fallback to CPU based color space conversion */ glsl_used = false; format = GL_RGBA; type = GL_UNSIGNED_BYTE; display_buffer = NULL; } else if (ibuf->rect_float) { display_buffer = ibuf->rect_float; if (ibuf->channels == 4) { format = GL_RGBA; } else if (ibuf->channels == 3) { format = GL_RGB; } else { BLI_assert(!"Incompatible number of channels for float buffer in sequencer"); format = GL_RGBA; display_buffer = NULL; } type = GL_FLOAT; if (ibuf->float_colorspace) { glsl_used = IMB_colormanagement_setup_glsl_draw_from_space_ctx(C, ibuf->float_colorspace, true); } else { glsl_used = IMB_colormanagement_setup_glsl_draw_ctx(C, true); } } else if (ibuf->rect) { display_buffer = ibuf->rect; format = GL_RGBA; type = GL_UNSIGNED_BYTE; glsl_used = IMB_colormanagement_setup_glsl_draw_from_space_ctx(C, ibuf->rect_colorspace, false); } else { format = GL_RGBA; type = GL_UNSIGNED_BYTE; display_buffer = NULL; } /* there's a data to be displayed, but GLSL is not initialized * properly, in this case we fallback to CPU-based display transform */ if ((ibuf->rect || ibuf->rect_float) && !glsl_used) { display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle); format = GL_RGBA; type = GL_UNSIGNED_BYTE; } } glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glColor4f(1.0, 1.0, 1.0, 1.0); last_texid = glaGetOneInteger(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D); glGenTextures(1, (GLuint *)&texid); glBindTexture(GL_TEXTURE_2D, texid); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); if (type == GL_FLOAT) glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, ibuf->x, ibuf->y, 0, format, type, display_buffer); else glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, ibuf->x, ibuf->y, 0, format, type, display_buffer); glBegin(GL_QUADS); if (draw_overlay) { if (sseq->overlay_type == SEQ_DRAW_OVERLAY_RECT) { rctf tot_clip; tot_clip.xmin = v2d->tot.xmin + (fabsf(BLI_rctf_size_x(&v2d->tot)) * scene->ed->over_border.xmin); tot_clip.ymin = v2d->tot.ymin + (fabsf(BLI_rctf_size_y(&v2d->tot)) * scene->ed->over_border.ymin); tot_clip.xmax = v2d->tot.xmin + (fabsf(BLI_rctf_size_x(&v2d->tot)) * scene->ed->over_border.xmax); tot_clip.ymax = v2d->tot.ymin + (fabsf(BLI_rctf_size_y(&v2d->tot)) * scene->ed->over_border.ymax); glTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymin); glVertex2f(tot_clip.xmin, tot_clip.ymin); glTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymax); glVertex2f(tot_clip.xmin, tot_clip.ymax); glTexCoord2f(scene->ed->over_border.xmax, scene->ed->over_border.ymax); glVertex2f(tot_clip.xmax, tot_clip.ymax); glTexCoord2f(scene->ed->over_border.xmax, scene->ed->over_border.ymin); glVertex2f(tot_clip.xmax, tot_clip.ymin); } else if (sseq->overlay_type == SEQ_DRAW_OVERLAY_REFERENCE) { glTexCoord2f(0.0f, 0.0f); glVertex2f(v2d->tot.xmin, v2d->tot.ymin); glTexCoord2f(0.0f, 1.0f); glVertex2f(v2d->tot.xmin, v2d->tot.ymax); glTexCoord2f(1.0f, 1.0f); glVertex2f(v2d->tot.xmax, v2d->tot.ymax); glTexCoord2f(1.0f, 0.0f); glVertex2f(v2d->tot.xmax, v2d->tot.ymin); } } else { glTexCoord2f(0.0f, 0.0f); glVertex2f(v2d->tot.xmin, v2d->tot.ymin); glTexCoord2f(0.0f, 1.0f); glVertex2f(v2d->tot.xmin, v2d->tot.ymax); glTexCoord2f(1.0f, 1.0f); glVertex2f(v2d->tot.xmax, v2d->tot.ymax); glTexCoord2f(1.0f, 0.0f); glVertex2f(v2d->tot.xmax, v2d->tot.ymin); } glEnd(); glBindTexture(GL_TEXTURE_2D, last_texid); glDisable(GL_TEXTURE_2D); if (sseq->mainb == SEQ_DRAW_IMG_IMBUF && sseq->flag & SEQ_USE_ALPHA) glDisable(GL_BLEND); glDeleteTextures(1, &texid); if (glsl_used) IMB_colormanagement_finish_glsl_draw(); if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) { float x1 = v2d->tot.xmin; float y1 = v2d->tot.ymin; float x2 = v2d->tot.xmax; float y2 = v2d->tot.ymax; /* border */ setlinestyle(3); UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 1.0, 0); glBegin(GL_LINE_LOOP); glVertex2f(x1 - 0.5f, y1 - 0.5f); glVertex2f(x1 - 0.5f, y2 + 0.5f); glVertex2f(x2 + 0.5f, y2 + 0.5f); glVertex2f(x2 + 0.5f, y1 - 0.5f); glEnd(); /* safety border */ if ((sseq->flag & SEQ_DRAW_SAFE_MARGINS) != 0) { float fac = 0.1; float a = fac * (x2 - x1); x1 += a; x2 -= a; a = fac * (y2 - y1); y1 += a; y2 -= a; glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); uiSetRoundBox(UI_CNR_ALL); uiDrawBox(GL_LINE_LOOP, x1, y1, x2, y2, 12.0); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } setlinestyle(0); } if (sseq->flag & SEQ_SHOW_GPENCIL) { if (is_imbuf) { /* draw grease-pencil (image aligned) */ draw_gpencil_2dimage(C); } } if (!scope) IMB_freeImBuf(ibuf); /* ortho at pixel level */ UI_view2d_view_restore(C); if (sseq->flag & SEQ_SHOW_GPENCIL) { if (is_imbuf) { /* draw grease-pencil (screen aligned) */ draw_gpencil_view2d(C, 0); } } /* NOTE: sequencer mask editing isnt finished, the draw code is working but editing not, * for now just disable drawing since the strip frame will likely be offset */ //if (sc->mode == SC_MODE_MASKEDIT) { if (0 && sseq->mainb == SEQ_DRAW_IMG_IMBUF) { Mask *mask = BKE_sequencer_mask_get(scene); if (mask) { int width, height; float aspx = 1.0f, aspy = 1.0f; // ED_mask_get_size(C, &width, &height); //Scene *scene = CTX_data_scene(C); width = (scene->r.size * scene->r.xsch) / 100; height = (scene->r.size * scene->r.ysch) / 100; ED_mask_draw_region(mask, ar, 0, 0, /* TODO */ width, height, aspx, aspy, FALSE, TRUE, NULL, C); } } if (cache_handle) IMB_display_buffer_release(cache_handle); }
void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq, int cfra, int frame_ofs) { struct Main *bmain = CTX_data_main(C); struct ImBuf *ibuf = NULL; struct ImBuf *scope = NULL; struct View2D *v2d = &ar->v2d; int rectx, recty; float viewrectx, viewrecty; float render_size = 0.0; float proxy_size = 100.0; float col[3]; GLuint texid; GLuint last_texid; SeqRenderData context; render_size = sseq->render_size; if (render_size == 0) { render_size = scene->r.size; } else { proxy_size = render_size; } if (render_size < 0) { return; } viewrectx = (render_size * (float)scene->r.xsch) / 100.0f; viewrecty = (render_size * (float)scene->r.ysch) / 100.0f; rectx = viewrectx + 0.5f; recty = viewrecty + 0.5f; if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) { viewrectx *= scene->r.xasp / scene->r.yasp; viewrectx /= proxy_size / 100.0f; viewrecty /= proxy_size / 100.0f; } if (frame_ofs == 0) { UI_GetThemeColor3fv(TH_SEQ_PREVIEW, col); glClearColor(col[0], col[1], col[2], 0.0); glClear(GL_COLOR_BUFFER_BIT); } /* without this colors can flicker from previous opengl state */ glColor4ub(255, 255, 255, 255); UI_view2d_totRect_set(v2d, viewrectx + 0.5f, viewrecty + 0.5f); UI_view2d_curRect_validate(v2d); /* only initialize the preview if a render is in progress */ if (G.rendering) return; context = seq_new_render_data(bmain, scene, rectx, recty, proxy_size); if (special_seq_update) ibuf = give_ibuf_seq_direct(context, cfra + frame_ofs, special_seq_update); else if (!U.prefetchframes) // XXX || (G.f & G_PLAYANIM) == 0) { ibuf = give_ibuf_seq(context, cfra + frame_ofs, sseq->chanshown); else ibuf = give_ibuf_seq_threaded(context, cfra + frame_ofs, sseq->chanshown); if (ibuf == NULL) return; if (ibuf->rect == NULL && ibuf->rect_float == NULL) return; switch (sseq->mainb) { case SEQ_DRAW_IMG_IMBUF: if (sseq->zebra != 0) { scope = make_zebra_view_from_ibuf(ibuf, sseq->zebra); } break; case SEQ_DRAW_IMG_WAVEFORM: if ((sseq->flag & SEQ_DRAW_COLOR_SEPARATED) != 0) { scope = make_sep_waveform_view_from_ibuf(ibuf); } else { scope = make_waveform_view_from_ibuf(ibuf); } break; case SEQ_DRAW_IMG_VECTORSCOPE: scope = make_vectorscope_view_from_ibuf(ibuf); break; case SEQ_DRAW_IMG_HISTOGRAM: scope = make_histogram_view_from_ibuf(ibuf); break; } if (scope) { IMB_freeImBuf(ibuf); ibuf = scope; } if (ibuf->rect_float && ibuf->rect == NULL) { IMB_rect_from_float(ibuf); } /* setting up the view - actual drawing starts here */ UI_view2d_view_ortho(v2d); last_texid = glaGetOneInteger(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D); glGenTextures(1, (GLuint *)&texid); glBindTexture(GL_TEXTURE_2D, texid); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, ibuf->x, ibuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); glBegin(GL_QUADS); if (frame_ofs) { rctf tot_clip; tot_clip.xmin = v2d->tot.xmin + (ABS(v2d->tot.xmax - v2d->tot.xmin) * scene->ed->over_border.xmin); tot_clip.ymin = v2d->tot.ymin + (ABS(v2d->tot.ymax - v2d->tot.ymin) * scene->ed->over_border.ymin); tot_clip.xmax = v2d->tot.xmin + (ABS(v2d->tot.xmax - v2d->tot.xmin) * scene->ed->over_border.xmax); tot_clip.ymax = v2d->tot.ymin + (ABS(v2d->tot.ymax - v2d->tot.ymin) * scene->ed->over_border.ymax); glTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymin); glVertex2f(tot_clip.xmin, tot_clip.ymin); glTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymax); glVertex2f(tot_clip.xmin, tot_clip.ymax); glTexCoord2f(scene->ed->over_border.xmax, scene->ed->over_border.ymax); glVertex2f(tot_clip.xmax, tot_clip.ymax); glTexCoord2f(scene->ed->over_border.xmax, scene->ed->over_border.ymin); glVertex2f(tot_clip.xmax, tot_clip.ymin); } else { glTexCoord2f(0.0f, 0.0f); glVertex2f(v2d->tot.xmin, v2d->tot.ymin); glTexCoord2f(0.0f, 1.0f); glVertex2f(v2d->tot.xmin, v2d->tot.ymax); glTexCoord2f(1.0f, 1.0f); glVertex2f(v2d->tot.xmax, v2d->tot.ymax); glTexCoord2f(1.0f, 0.0f); glVertex2f(v2d->tot.xmax, v2d->tot.ymin); } glEnd(); glBindTexture(GL_TEXTURE_2D, last_texid); glDisable(GL_TEXTURE_2D); glDeleteTextures(1, &texid); if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) { float x1 = v2d->tot.xmin; float y1 = v2d->tot.ymin; float x2 = v2d->tot.xmax; float y2 = v2d->tot.ymax; /* border */ setlinestyle(3); UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 1.0, 0); glBegin(GL_LINE_LOOP); glVertex2f(x1 - 0.5f, y1 - 0.5f); glVertex2f(x1 - 0.5f, y2 + 0.5f); glVertex2f(x2 + 0.5f, y2 + 0.5f); glVertex2f(x2 + 0.5f, y1 - 0.5f); glEnd(); /* safety border */ if ((sseq->flag & SEQ_DRAW_SAFE_MARGINS) != 0) { float fac = 0.1; float a = fac * (x2 - x1); x1 += a; x2 -= a; a = fac * (y2 - y1); y1 += a; y2 -= a; glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); uiSetRoundBox(UI_CNR_ALL); uiDrawBox(GL_LINE_LOOP, x1, y1, x2, y2, 12.0); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } setlinestyle(0); } /* draw grease-pencil (image aligned) */ draw_gpencil_2dimage(C); IMB_freeImBuf(ibuf); /* ortho at pixel level */ UI_view2d_view_restore(C); /* draw grease-pencil (screen aligned) */ draw_gpencil_view2d(C, 0); //if (sc->mode == SC_MODE_MASKEDIT) { if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) { Mask *mask = BKE_sequencer_mask_get(scene); if (mask) { int width, height; // ED_mask_get_size(C, &width, &height); //Scene *scene = CTX_data_scene(C); width = (scene->r.size * scene->r.xsch) / 100; height = (scene->r.size * scene->r.ysch) / 100; ED_mask_draw_region(mask, ar, 0, 0, /* TODO */ width, height, FALSE, TRUE, NULL, C); } } }
static void console_textview_update_rect(SpaceConsole *sc, ARegion *ar) { View2D *v2d = &ar->v2d; UI_view2d_totRect_set(v2d, ar->winx - 1, console_textview_height(sc, ar)); }
void action_header_buttons(const bContext *C, ARegion *ar) { ScrArea *sa= CTX_wm_area(C); SpaceAction *saction= CTX_wm_space_action(C); bAnimContext ac; uiBlock *block; int xco, yco= 3, xmax; block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS); uiBlockSetHandleFunc(block, do_action_buttons, NULL); xco= ED_area_header_standardbuttons(C, block, yco); uiBlockSetEmboss(block, UI_EMBOSS); /* get context... (also syncs data) */ ANIM_animdata_get_context(C, &ac); if ((sa->flag & HEADER_NO_PULLDOWN)==0) { xmax= GetButStringLength("View"); uiDefMenuBut(block, act_viewmenu, NULL, "View", xco, yco, xmax-3, 20, ""); xco+= xmax; xmax= GetButStringLength("Select"); uiDefMenuBut(block, act_selectmenu, NULL, "Select", xco, yco, xmax-3, 20, ""); xco+= xmax; if ( (saction->mode == SACTCONT_DOPESHEET) || ((saction->action) && (saction->mode==SACTCONT_ACTION)) ) { xmax= GetButStringLength("Channel"); uiDefMenuBut(block, act_channelmenu, NULL, "Channel", xco, yco, xmax-3, 20, ""); xco+= xmax; } else if (saction->mode==SACTCONT_GPENCIL) { xmax= GetButStringLength("Channel"); uiDefMenuBut(block, act_gplayermenu, NULL, "Channel", xco, yco, xmax-3, 20, ""); xco+= xmax; } //xmax= GetButStringLength("Marker"); //uiDefMenuBut(block, act_markermenu, NULL, "Marker", xco, yco, xmax-3, 20, ""); //xco+= xmax; if (saction->mode == SACTCONT_GPENCIL) { //xmax= GetButStringLength("Frame"); //uiDefMenuBut(block, act_selectmenu, NULL, "Frame", xco, yco, xmax-3, 20, ""); //xco+= xmax; } else { xmax= GetButStringLength("Key"); uiDefMenuBut(block, act_editmenu, NULL, "Key", xco, yco, xmax-3, 20, ""); xco+= xmax; } } uiBlockSetEmboss(block, UI_EMBOSS); /* MODE SELECTOR */ uiDefButC(block, MENU, B_MODECHANGE, "Editor Mode %t|DopeSheet %x3|Action Editor %x0|ShapeKey Editor %x1|Grease Pencil %x2", xco,yco,90,YIC, &saction->mode, 0, 1, 0, 0, "Editing modes for this editor"); xco += (90 + 8); /* SUMMARY CHANNEL */ uiDefIconTextButBitI(block, TOG, ADS_FILTER_SUMMARY, B_REDR, ICON_BORDERMOVE, "Summary", xco,yco,XIC*4,YIC, &(saction->ads.filterflag), 0, 0, 0, 0, "Include DopeSheet summary row"); // TODO: needs a better icon xco += (XIC*4.5); /*if (ac.data)*/ { /* MODE-DEPENDENT DRAWING */ if (saction->mode == SACTCONT_DOPESHEET) { /* FILTERING OPTIONS */ xco -= XIC; // XXX first button incurs this offset... xco= ANIM_headerUI_standard_buttons(C, &saction->ads, block, xco, yco); } else if (saction->mode == SACTCONT_ACTION) { uiLayout *layout; bScreen *sc= CTX_wm_screen(C); PointerRNA ptr; RNA_pointer_create(&sc->id, &RNA_SpaceDopeSheetEditor, saction, &ptr); layout= uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, xco, 20+3, 20, 1, U.uistyles.first); uiTemplateID(layout, (bContext*)C, &ptr, "action", "ACT_OT_new", NULL, NULL); uiBlockLayoutResolve(block, &xco, NULL); xco += 8; } /* draw AUTOSNAP */ if (saction->mode != SACTCONT_GPENCIL) { if (saction->flag & SACTION_DRAWTIME) { uiDefButC(block, MENU, B_REDR, "Auto-Snap Keyframes %t|No Snap %x0|Second Step %x1|Nearest Second %x2|Nearest Marker %x3", xco,yco,90,YIC, &(saction->autosnap), 0, 1, 0, 0, "Auto-snapping mode for keyframes when transforming"); } else { uiDefButC(block, MENU, B_REDR, "Auto-Snap Keyframes %t|No Snap %x0|Frame Step %x1|Nearest Frame %x2|Nearest Marker %x3", xco,yco,90,YIC, &(saction->autosnap), 0, 1, 0, 0, "Auto-snapping mode for keyframes when transforming"); } xco += (90 + 8); } /* COPY PASTE */ uiBlockBeginAlign(block); uiDefIconButO(block, BUT, "ACT_OT_copy", WM_OP_INVOKE_REGION_WIN, ICON_COPYDOWN, xco,yco,XIC,YIC, "Copies the selected keyframes to the buffer."); xco += XIC; uiDefIconButO(block, BUT, "ACT_OT_paste", WM_OP_INVOKE_REGION_WIN, ICON_PASTEDOWN, xco,yco,XIC,YIC, "Pastes the keyframes from the buffer into the selected channels."); uiBlockEndAlign(block); xco += (XIC + 8); } /* always as last */ UI_view2d_totRect_set(&ar->v2d, xco+XIC+80, (int)(ar->v2d.tot.ymax-ar->v2d.tot.ymin)); uiEndBlock(C, block); uiDrawBlock(C, block); }