diff options
Diffstat (limited to 'source/blender/editors/screen/area.c')
-rw-r--r-- | source/blender/editors/screen/area.c | 147 |
1 files changed, 145 insertions, 2 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 48b00376667..aeba68f7a47 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -34,6 +34,7 @@ #include "MEM_guardedalloc.h" +#include "DNA_object_types.h" #include "DNA_userdef_types.h" #include "BLI_blenlib.h" @@ -44,6 +45,8 @@ #include "BKE_context.h" #include "BKE_global.h" +#include "BKE_main.h" +#include "BKE_scene.h" #include "BKE_screen.h" #include "RNA_access.h" @@ -56,6 +59,7 @@ #include "ED_screen.h" #include "ED_screen_types.h" #include "ED_space_api.h" +#include "ED_view3d.h" #include "BIF_gl.h" #include "BIF_glutil.h" @@ -69,6 +73,9 @@ #include "UI_resources.h" #include "UI_view2d.h" +#include "IMB_imbuf.h" +#include "IMB_imbuf_types.h" + #include "screen_intern.h" extern void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3); /* xxx temp */ @@ -546,6 +553,100 @@ void ED_region_do_draw(bContext *C, ARegion *ar) * maybe silly, but let's try for now * to keep these tags protected * ********************************** */ +int ED_match_area_with_refresh(int spacetype, int refresh) +{ + switch (spacetype) { + case SPACE_TIME: + if (refresh & SPACE_TIME) + return 1; + break; + } + + return 0; +} + +int ED_match_region_with_redraws(int spacetype, int regiontype, int redraws) +{ + if (regiontype == RGN_TYPE_WINDOW) { + + switch (spacetype) { + case SPACE_VIEW3D: + if (redraws & TIME_ALL_3D_WIN) + return 1; + break; + case SPACE_IPO: + case SPACE_ACTION: + case SPACE_NLA: + if (redraws & TIME_ALL_ANIM_WIN) + return 1; + break; + case SPACE_TIME: + /* if only 1 window or 3d windows, we do timeline too */ + if (redraws & (TIME_ALL_ANIM_WIN | TIME_REGION | TIME_ALL_3D_WIN)) + return 1; + break; + case SPACE_BUTS: + if (redraws & TIME_ALL_BUTS_WIN) + return 1; + break; + case SPACE_SEQ: + if (redraws & (TIME_SEQ | TIME_ALL_ANIM_WIN)) + return 1; + break; + case SPACE_NODE: + if (redraws & (TIME_NODES)) + return 1; + break; + case SPACE_IMAGE: + if (redraws & TIME_ALL_IMAGE_WIN) + return 1; + break; + case SPACE_CLIP: + if (redraws & TIME_CLIPS) + return 1; + break; + + } + } + else if (regiontype == RGN_TYPE_CHANNELS) { + switch (spacetype) { + case SPACE_IPO: + case SPACE_ACTION: + case SPACE_NLA: + if (redraws & TIME_ALL_ANIM_WIN) + return 1; + break; + } + } + else if (regiontype == RGN_TYPE_UI) { + if (spacetype == SPACE_CLIP) { + /* Track Preview button is on Properties Editor in SpaceClip, + * and it's very common case when users want it be refreshing + * during playback, so asking people to enable special option + * for this is a bit tricky, so add exception here for refreshing + * Properties Editor for SpaceClip always */ + return 1; + } + + if (redraws & TIME_ALL_BUTS_WIN) + return 1; + } + else if (regiontype == RGN_TYPE_HEADER) { + if (spacetype == SPACE_TIME) + return 1; + } + else if (regiontype == RGN_TYPE_PREVIEW) { + switch (spacetype) { + case SPACE_SEQ: + if (redraws & (TIME_SEQ | TIME_ALL_ANIM_WIN)) + return 1; + break; + case SPACE_CLIP: + return 1; + } + } + return 0; +} void ED_region_tag_redraw(ARegion *ar) { @@ -1512,8 +1613,9 @@ void region_toggle_hidden(bContext *C, ARegion *ar, const bool do_fade) region_blend_start(C, sa, ar); } else { - if (ar->flag & RGN_FLAG_HIDDEN) + if (ar->flag & RGN_FLAG_HIDDEN) { WM_event_remove_handlers(C, &ar->handlers); + } ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa); ED_area_tag_redraw(sa); @@ -2214,7 +2316,7 @@ void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, rctf frame, float glTranslatef(x, y, 0.0f); glScalef(zoomx, zoomy, 1.0f); - BLF_size(blf_mono_font, style->widgetlabel.points * 1.5f, U.dpi); + BLF_size(blf_mono_font, style->widgetlabel.points, U.dpi); /* *** upper box*** */ @@ -2323,6 +2425,47 @@ void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy) glEnd(); } +/* uses the viewplane from the given camera and draws it as a backdrop */ +void ED_region_draw_backdrop_view3d(const bContext *C, struct Object *camera, const float alpha, + const float width, const float height, const float x, const float y, + const float zoomx, const float zoomy, const bool draw_background) +{ + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + char err_out[256] = "unknown"; + struct ImBuf *ibuf; + + BKE_scene_update_for_newframe(bmain->eval_ctx, bmain, scene, scene->lay); + ibuf = ED_view3d_draw_offscreen_imbuf_simple(scene, camera, width, height, IB_rect, + OB_SOLID, false, false, false, + R_ADDSKY, NULL, err_out); + + if (ibuf == NULL) + return; + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glPushMatrix(); + glScalef(zoomx, zoomy, 0.0f); + glTranslatef(x, y, 0.0f); + + /* draw background */ + if (draw_background) { + char col[4]; + + UI_GetThemeColorType4ubv(TH_HIGH_GRAD, SPACE_VIEW3D, col); + glColor4ub(UNPACK3(col), alpha * 255); + glRectf(0, 0, width, height); + } + /* draw the imbuf itself */ + glaDrawImBuf_glsl_ctx(C, ibuf, 0.0f, 0.0f, GL_NEAREST, alpha); + + glPopMatrix(); + glDisable(GL_BLEND); + + IMB_freeImBuf(ibuf); +} + /* If the area has overlapping regions, it returns visible rect for Region *ar */ /* rect gets returned in local region coordinates */ void ED_region_visible_rect(ARegion *ar, rcti *rect) |