Movie Clip Editor: Show preview range
Overall the goal of the PR is to show the preview range in the clip editor's dopesheet and graph mode. To accomplish this, some cleanup and refactor were needed: - Clip editor had a nearly 1:1 copy paste of the timeline draw code, which has been replaced with `ANIM_draw_framerange`. - Preview range draw code required `bContext`, which was only used to access scene. Now scene is passed explicitly, without need to know the context. - The macro to access the preview range was removed. This is because the code is within `PRVRANGEON` check, so `PSFRA`/`PEFRA` were doing redundant checks. Pull Request: https://projects.blender.org/blender/blender/pulls/138678
This commit is contained in:
@@ -998,6 +998,7 @@ const bTheme U_theme_default = {
|
||||
.strip = RGBA(0xffffff80),
|
||||
.strip_select = RGBA(0xff8c00ff),
|
||||
.cframe = RGBA(0x4772b3ff),
|
||||
.anim_preview_range = RGBA(0xa14d0066),
|
||||
.time_scrub_background = RGBA(0x181818ff),
|
||||
.time_marker_line = RGBA(0xffffff4d),
|
||||
.time_marker_line_selected = RGBA(0xffffffb3),
|
||||
|
||||
@@ -1245,6 +1245,7 @@
|
||||
path_keyframe_before="#ffc4c4"
|
||||
path_keyframe_after="#c4c4ff"
|
||||
frame_current="#5680c2"
|
||||
preview_range="#a14d0066"
|
||||
time_scrub_background="#292929e6"
|
||||
time_marker_line="#00000060"
|
||||
time_marker_line_selected="#ffffff60"
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
/* Blender file format version. */
|
||||
#define BLENDER_FILE_VERSION BLENDER_VERSION
|
||||
#define BLENDER_FILE_SUBVERSION 81
|
||||
#define BLENDER_FILE_SUBVERSION 82
|
||||
|
||||
/* Minimum Blender version that supports reading file written with the current
|
||||
* version. Older Blender versions will test this and cancel loading the file, showing a warning to
|
||||
|
||||
@@ -235,6 +235,10 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme)
|
||||
FROM_DEFAULT_V4_UCHAR(space_node.node_zone_closure);
|
||||
}
|
||||
|
||||
if (!USER_VERSION_ATLEAST(405, 82)) {
|
||||
FROM_DEFAULT_V4_UCHAR(space_clip.anim_preview_range);
|
||||
}
|
||||
|
||||
/**
|
||||
* Always bump subversion in BKE_blender_version.h when adding versioning
|
||||
* code here, and wrap it inside a USER_VERSION_ATLEAST check.
|
||||
|
||||
@@ -72,11 +72,9 @@ void ANIM_draw_cfra(const bContext *C, View2D *v2d, short flag)
|
||||
/* PREVIEW RANGE 'CURTAINS' */
|
||||
/* NOTE: 'Preview Range' tools are defined in `anim_ops.cc`. */
|
||||
|
||||
void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width)
|
||||
void ANIM_draw_previewrange(const Scene *scene, View2D *v2d, int end_frame_width)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
|
||||
/* only draw this if preview range is set */
|
||||
/* Only draw this if preview range is set. */
|
||||
if (PRVRANGEON) {
|
||||
GPU_blend(GPU_BLEND_ALPHA);
|
||||
|
||||
@@ -85,13 +83,15 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width)
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
immUniformThemeColorShadeAlpha(TH_ANIM_PREVIEW_RANGE, -25, -30);
|
||||
/* XXX: Fix this hardcoded color (anim_active) */
|
||||
// immUniformColor4f(0.8f, 0.44f, 0.1f, 0.2f);
|
||||
|
||||
/* only draw two separate 'curtains' if there's no overlap between them */
|
||||
if (PSFRA < PEFRA + end_frame_width) {
|
||||
immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, float(PSFRA), v2d->cur.ymax);
|
||||
immRectf(pos, float(PEFRA + end_frame_width), v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
|
||||
/* Only draw two separate 'curtains' if there's no overlap between them. */
|
||||
if (scene->r.psfra < scene->r.pefra + end_frame_width) {
|
||||
immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, float(scene->r.psfra), v2d->cur.ymax);
|
||||
immRectf(pos,
|
||||
float(scene->r.pefra + end_frame_width),
|
||||
v2d->cur.ymin,
|
||||
v2d->cur.xmax,
|
||||
v2d->cur.ymax);
|
||||
}
|
||||
else {
|
||||
immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
|
||||
|
||||
@@ -862,7 +862,7 @@ void ANIM_draw_cfra(const bContext *C, View2D *v2d, short flag);
|
||||
/**
|
||||
* Draw preview range 'curtains' for highlighting where the animation data is.
|
||||
*/
|
||||
void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width);
|
||||
void ANIM_draw_previewrange(const Scene *scene, View2D *v2d, int end_frame_width);
|
||||
|
||||
/** \} */
|
||||
|
||||
@@ -874,8 +874,6 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width)
|
||||
|
||||
/**
|
||||
* Draw frame range guides (for scene frame range) in background.
|
||||
*
|
||||
* TODO: Should we still show these when preview range is enabled?
|
||||
*/
|
||||
void ANIM_draw_framerange(Scene *scene, View2D *v2d);
|
||||
|
||||
|
||||
@@ -252,7 +252,7 @@ static void action_main_region_draw(const bContext *C, ARegion *region)
|
||||
|
||||
/* preview range */
|
||||
UI_view2d_view_ortho(v2d);
|
||||
ANIM_draw_previewrange(C, v2d, 0);
|
||||
ANIM_draw_previewrange(scene, v2d, 0);
|
||||
|
||||
/* callback */
|
||||
UI_view2d_view_ortho(v2d);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "BKE_context.hh"
|
||||
#include "BKE_movieclip.h"
|
||||
|
||||
#include "ED_anim_api.hh"
|
||||
#include "ED_clip.hh"
|
||||
#include "ED_screen.hh"
|
||||
|
||||
@@ -99,8 +100,10 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *region, Scene *scene)
|
||||
MovieClip *clip = ED_space_clip_get_clip(sc);
|
||||
View2D *v2d = ®ion->v2d;
|
||||
|
||||
/* frame range */
|
||||
clip_draw_sfra_efra(v2d, scene);
|
||||
/* Frame and preview range. */
|
||||
UI_view2d_view_ortho(v2d);
|
||||
ANIM_draw_framerange(scene, v2d);
|
||||
ANIM_draw_previewrange(scene, v2d, 0);
|
||||
|
||||
if (clip) {
|
||||
MovieTracking *tracking = &clip->tracking;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "BKE_movieclip.h"
|
||||
#include "BKE_tracking.h"
|
||||
|
||||
#include "ED_anim_api.hh"
|
||||
#include "ED_clip.hh"
|
||||
|
||||
#include "GPU_immediate.hh"
|
||||
@@ -270,6 +271,8 @@ void clip_draw_graph(SpaceClip *sc, ARegion *region, Scene *scene)
|
||||
immUnbindProgram();
|
||||
}
|
||||
|
||||
/* frame range */
|
||||
clip_draw_sfra_efra(v2d, scene);
|
||||
/* Frame and preview range. */
|
||||
UI_view2d_view_ortho(v2d);
|
||||
ANIM_draw_framerange(scene, v2d);
|
||||
ANIM_draw_previewrange(scene, v2d, 0);
|
||||
}
|
||||
|
||||
@@ -179,8 +179,6 @@ bool clip_view_calculate_view_selection(
|
||||
*/
|
||||
bool clip_view_has_locked_selection(const bContext *C);
|
||||
|
||||
void clip_draw_sfra_efra(View2D *v2d, Scene *scene);
|
||||
|
||||
/* tracking_ops.cc */
|
||||
|
||||
/* Find track which can be slid in a proximity of the given event.
|
||||
|
||||
@@ -600,34 +600,3 @@ bool clip_view_has_locked_selection(const bContext *C)
|
||||
|
||||
return mask_has_selection(C);
|
||||
}
|
||||
|
||||
void clip_draw_sfra_efra(View2D *v2d, Scene *scene)
|
||||
{
|
||||
UI_view2d_view_ortho(v2d);
|
||||
|
||||
/* currently clip editor supposes that editing clip length is equal to scene frame range */
|
||||
GPU_blend(GPU_BLEND_ALPHA);
|
||||
|
||||
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
|
||||
immUniformColor4f(0.0f, 0.0f, 0.0f, 0.4f);
|
||||
immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, float(scene->r.sfra), v2d->cur.ymax);
|
||||
immRectf(pos, float(scene->r.efra), v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
|
||||
|
||||
GPU_blend(GPU_BLEND_NONE);
|
||||
|
||||
immUniformThemeColorShade(TH_BACK, -60);
|
||||
|
||||
/* thin lines where the actual frames are */
|
||||
GPU_line_width(1.0f);
|
||||
|
||||
immBegin(GPU_PRIM_LINES, 4);
|
||||
immVertex2f(pos, float(scene->r.sfra), v2d->cur.ymin);
|
||||
immVertex2f(pos, float(scene->r.sfra), v2d->cur.ymax);
|
||||
immVertex2f(pos, float(scene->r.efra), v2d->cur.ymin);
|
||||
immVertex2f(pos, float(scene->r.efra), v2d->cur.ymax);
|
||||
immEnd();
|
||||
|
||||
immUnbindProgram();
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ static void graph_main_region_draw(const bContext *C, ARegion *region)
|
||||
/* preview range */
|
||||
if (sipo->mode != SIPO_MODE_DRIVERS) {
|
||||
UI_view2d_view_ortho(v2d);
|
||||
ANIM_draw_previewrange(C, v2d, 0);
|
||||
ANIM_draw_previewrange(scene, v2d, 0);
|
||||
}
|
||||
|
||||
/* callback */
|
||||
|
||||
@@ -285,7 +285,7 @@ static void nla_main_region_draw(const bContext *C, ARegion *region)
|
||||
|
||||
/* preview range */
|
||||
UI_view2d_view_ortho(v2d);
|
||||
ANIM_draw_previewrange(C, v2d, 0);
|
||||
ANIM_draw_previewrange(scene, v2d, 0);
|
||||
|
||||
/* callback */
|
||||
UI_view2d_view_ortho(v2d);
|
||||
|
||||
@@ -1881,7 +1881,7 @@ void draw_timeline_seq(const bContext *C, ARegion *region)
|
||||
draw_seq_strips(&ctx, strips_batch);
|
||||
draw_timeline_markers(&ctx);
|
||||
UI_view2d_view_ortho(ctx.v2d);
|
||||
ANIM_draw_previewrange(C, ctx.v2d, 1);
|
||||
ANIM_draw_previewrange(ctx.scene, ctx.v2d, 1);
|
||||
draw_timeline_gizmos(&ctx);
|
||||
draw_timeline_post_view_callbacks(&ctx);
|
||||
ED_time_scrub_draw(region, ctx.scene, !(ctx.sseq->flag & SEQ_DRAWFRAMES), true);
|
||||
|
||||
@@ -4443,6 +4443,12 @@ static void rna_def_userdef_theme_space_clip(BlenderRNA *brna)
|
||||
RNA_def_property_ui_text(prop, "Metadata Text", "");
|
||||
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
|
||||
|
||||
prop = RNA_def_property(srna, "preview_range", PROP_FLOAT, PROP_COLOR_GAMMA);
|
||||
RNA_def_property_float_sdna(prop, nullptr, "anim_preview_range");
|
||||
RNA_def_property_array(prop, 4);
|
||||
RNA_def_property_ui_text(prop, "Preview Range", "Color of preview range overlay");
|
||||
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
|
||||
|
||||
rna_def_userdef_theme_spaces_curves(srna, false, false, false, true);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user