2012-04-30 16:19:20 +00:00
|
|
|
/*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2012 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup spclip
|
2012-04-30 16:19:20 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "DNA_movieclip_types.h"
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
|
|
|
#include "BLI_math.h"
|
2012-08-20 23:06:17 +00:00
|
|
|
#include "BLI_rect.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_utildefines.h"
|
2012-04-30 16:19:20 +00:00
|
|
|
|
2013-04-05 17:56:54 +00:00
|
|
|
#include "BKE_context.h"
|
|
|
|
#include "BKE_movieclip.h"
|
|
|
|
|
2012-04-30 16:19:20 +00:00
|
|
|
#include "ED_clip.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "ED_screen.h"
|
2012-04-30 16:19:20 +00:00
|
|
|
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
|
|
#include "UI_interface.h"
|
|
|
|
#include "UI_resources.h"
|
|
|
|
#include "UI_view2d.h"
|
|
|
|
|
|
|
|
#include "BLF_api.h"
|
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
|
2017-02-01 22:42:50 -05:00
|
|
|
#include "GPU_immediate.h"
|
2018-06-27 19:07:23 -06:00
|
|
|
#include "GPU_state.h"
|
2017-02-01 22:42:50 -05:00
|
|
|
|
2012-06-10 19:59:02 +00:00
|
|
|
#include "clip_intern.h" /* own include */
|
2012-04-30 16:19:20 +00:00
|
|
|
|
2020-08-07 22:56:13 +10:00
|
|
|
static void track_channel_color(MovieTrackingTrack *track,
|
|
|
|
const float default_color[3],
|
|
|
|
float color[3])
|
2012-04-30 16:19:20 +00:00
|
|
|
{
|
|
|
|
if (track->flag & TRACK_CUSTOMCOLOR) {
|
|
|
|
float bg[3];
|
|
|
|
UI_GetThemeColor3fv(TH_HEADER, bg);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-30 16:19:20 +00:00
|
|
|
interp_v3_v3v3(color, track->color, bg, 0.5);
|
|
|
|
}
|
|
|
|
else {
|
2019-04-22 09:19:45 +10:00
|
|
|
if (default_color) {
|
2012-04-30 16:19:20 +00:00
|
|
|
copy_v3_v3(color, default_color);
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
|
|
|
else {
|
2012-04-30 16:19:20 +00:00
|
|
|
UI_GetThemeColor3fv(TH_HEADER, color);
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2012-04-30 16:19:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-11 00:24:59 -05:00
|
|
|
static void draw_keyframe_shape(
|
2020-04-03 16:21:24 +11:00
|
|
|
float x, float y, bool sel, float alpha, uint pos_id, uint color_id)
|
2012-04-30 16:19:20 +00:00
|
|
|
{
|
2017-02-11 00:24:59 -05:00
|
|
|
float color[4] = {0.91f, 0.91f, 0.91f, alpha};
|
|
|
|
if (sel) {
|
|
|
|
UI_GetThemeColorShadeAlpha4fv(TH_STRIP_SELECT, 50, -255 * (1.0f - alpha), color);
|
|
|
|
}
|
2012-04-30 16:19:20 +00:00
|
|
|
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr4fv(color_id, color);
|
2017-02-11 00:24:59 -05:00
|
|
|
immVertex2f(pos_id, x, y);
|
2012-04-30 16:19:20 +00:00
|
|
|
}
|
|
|
|
|
2020-04-03 16:21:24 +11:00
|
|
|
static void clip_draw_dopesheet_background(ARegion *region, MovieClip *clip, uint pos_id)
|
2013-02-22 10:13:15 +00:00
|
|
|
{
|
2020-03-06 16:56:42 +01:00
|
|
|
View2D *v2d = ®ion->v2d;
|
2013-02-22 10:13:15 +00:00
|
|
|
MovieTracking *tracking = &clip->tracking;
|
|
|
|
MovieTrackingDopesheet *dopesheet = &tracking->dopesheet;
|
|
|
|
MovieTrackingDopesheetCoverageSegment *coverage_segment;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-02-22 10:13:15 +00:00
|
|
|
for (coverage_segment = dopesheet->coverage_segments.first; coverage_segment;
|
|
|
|
coverage_segment = coverage_segment->next) {
|
|
|
|
if (coverage_segment->coverage < TRACKING_COVERAGE_OK) {
|
|
|
|
int start_frame = BKE_movieclip_remap_clip_to_scene_frame(clip,
|
|
|
|
coverage_segment->start_frame);
|
|
|
|
int end_frame = BKE_movieclip_remap_clip_to_scene_frame(clip, coverage_segment->end_frame);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-02-13 18:31:02 +06:00
|
|
|
if (coverage_segment->coverage == TRACKING_COVERAGE_BAD) {
|
2017-02-01 22:42:50 -05:00
|
|
|
immUniformColor4f(1.0f, 0.0f, 0.0f, 0.07f);
|
2014-02-13 18:31:02 +06:00
|
|
|
}
|
2017-02-11 00:24:59 -05:00
|
|
|
else {
|
2017-02-01 22:42:50 -05:00
|
|
|
immUniformColor4f(1.0f, 1.0f, 0.0f, 0.07f);
|
2017-02-11 00:24:59 -05:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-11 00:24:59 -05:00
|
|
|
immRectf(pos_id, start_frame, v2d->cur.ymin, end_frame, v2d->cur.ymax);
|
2013-02-22 10:13:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *region, Scene *scene)
|
2012-04-30 16:19:20 +00:00
|
|
|
{
|
2012-06-19 14:26:29 +00:00
|
|
|
MovieClip *clip = ED_space_clip_get_clip(sc);
|
2020-03-06 16:56:42 +01:00
|
|
|
View2D *v2d = ®ion->v2d;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-30 16:19:20 +00:00
|
|
|
/* frame range */
|
|
|
|
clip_draw_sfra_efra(v2d, scene);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-30 16:19:20 +00:00
|
|
|
if (clip) {
|
|
|
|
MovieTracking *tracking = &clip->tracking;
|
|
|
|
MovieTrackingDopesheet *dopesheet = &tracking->dopesheet;
|
|
|
|
MovieTrackingDopesheetChannel *channel;
|
|
|
|
float strip[4], selected_strip[4];
|
2020-06-18 12:21:38 +10:00
|
|
|
float height = (dopesheet->tot_channel * CHANNEL_STEP) + CHANNEL_HEIGHT;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-08 13:19:10 +02:00
|
|
|
uint keyframe_len = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
GPUVertFormat *format = immVertexFormat();
|
|
|
|
uint pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2017-02-11 00:24:59 -05:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-12 14:59:36 +00:00
|
|
|
/* don't use totrect set, as the width stays the same
|
|
|
|
* (NOTE: this is ok here, the configuration is pretty straightforward)
|
|
|
|
*/
|
|
|
|
v2d->tot.ymin = (float)(-height);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-11 00:24:59 -05:00
|
|
|
float y = (float)CHANNEL_FIRST;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-30 16:19:20 +00:00
|
|
|
/* setup colors for regular and selected strips */
|
|
|
|
UI_GetThemeColor3fv(TH_STRIP, strip);
|
|
|
|
UI_GetThemeColor3fv(TH_STRIP_SELECT, selected_strip);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-30 16:19:20 +00:00
|
|
|
strip[3] = 0.5f;
|
|
|
|
selected_strip[3] = 1.0f;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
clip_draw_dopesheet_background(region, clip, pos_id);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-30 16:19:20 +00:00
|
|
|
for (channel = dopesheet->channels.first; channel; channel = channel->next) {
|
|
|
|
float yminc = (float)(y - CHANNEL_HEIGHT_HALF);
|
|
|
|
float ymaxc = (float)(y + CHANNEL_HEIGHT_HALF);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-30 16:19:20 +00:00
|
|
|
/* check if visible */
|
|
|
|
if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
|
|
|
|
IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax)) {
|
|
|
|
MovieTrackingTrack *track = channel->track;
|
2014-03-31 15:31:28 +06:00
|
|
|
int i;
|
|
|
|
bool sel = (track->flag & TRACK_DOPE_SEL) != 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-30 16:19:20 +00:00
|
|
|
/* selection background */
|
|
|
|
if (sel) {
|
|
|
|
float color[4] = {0.0f, 0.0f, 0.0f, 0.3f};
|
|
|
|
float default_color[4] = {0.8f, 0.93f, 0.8f, 0.3f};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-30 16:19:20 +00:00
|
|
|
track_channel_color(track, default_color, color);
|
2017-02-01 22:42:50 -05:00
|
|
|
immUniformColor4fv(color);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-11 00:24:59 -05:00
|
|
|
immRectf(pos_id,
|
|
|
|
v2d->cur.xmin,
|
|
|
|
(float)y - CHANNEL_HEIGHT_HALF,
|
|
|
|
v2d->cur.xmax + EXTRA_SCROLL_PAD,
|
|
|
|
(float)y + CHANNEL_HEIGHT_HALF);
|
2012-04-30 16:19:20 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-30 16:19:20 +00:00
|
|
|
/* tracked segments */
|
2012-05-03 17:52:34 +00:00
|
|
|
for (i = 0; i < channel->tot_segment; i++) {
|
2012-06-10 17:09:35 +00:00
|
|
|
int start_frame = BKE_movieclip_remap_clip_to_scene_frame(clip,
|
|
|
|
channel->segments[2 * i]);
|
|
|
|
int end_frame = BKE_movieclip_remap_clip_to_scene_frame(clip,
|
|
|
|
channel->segments[2 * i + 1]);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-11 00:24:59 -05:00
|
|
|
immUniformColor4fv(sel ? selected_strip : strip);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-03 17:52:34 +00:00
|
|
|
if (start_frame != end_frame) {
|
2017-02-11 00:24:59 -05:00
|
|
|
immRectf(pos_id,
|
|
|
|
start_frame,
|
|
|
|
(float)y - STRIP_HEIGHT_HALF,
|
|
|
|
end_frame,
|
|
|
|
(float)y + STRIP_HEIGHT_HALF);
|
2018-07-08 13:19:10 +02:00
|
|
|
keyframe_len += 2;
|
2012-05-03 17:52:34 +00:00
|
|
|
}
|
|
|
|
else {
|
2018-07-08 13:19:10 +02:00
|
|
|
keyframe_len++;
|
2012-04-30 16:19:20 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2012-04-30 16:19:20 +00:00
|
|
|
/* keyframes */
|
|
|
|
i = 0;
|
|
|
|
while (i < track->markersnr) {
|
|
|
|
MovieTrackingMarker *marker = &track->markers[i];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-10 17:09:35 +00:00
|
|
|
if ((marker->flag & (MARKER_DISABLED | MARKER_TRACKED)) == 0) {
|
2018-07-08 13:19:10 +02:00
|
|
|
keyframe_len++;
|
2012-06-10 17:09:35 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-30 16:19:20 +00:00
|
|
|
i++;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2012-04-30 16:19:20 +00:00
|
|
|
/* adjust y-position for next one */
|
|
|
|
y -= CHANNEL_STEP;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-11 00:24:59 -05:00
|
|
|
immUnbindProgram();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-08 13:19:10 +02:00
|
|
|
if (keyframe_len > 0) {
|
2017-02-11 00:24:59 -05:00
|
|
|
/* draw keyframe markers */
|
|
|
|
format = immVertexFormat();
|
2018-07-18 00:12:21 +02:00
|
|
|
pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
|
|
|
uint size_id = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
|
|
|
|
uint color_id = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
|
|
|
|
uint outline_color_id = GPU_vertformat_attr_add(
|
|
|
|
format, "outlineColor", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
|
Dope Sheet: new option to display keyframe interpolation mode and extremes.
With the new automatic handle algorithm, it is possible to do a lot
of the animation via keyframes without touching the curves. It is
however necessary to change the keyframe interpolation and handle
types in certain cases. Currently the dopesheet/action editor
allows changing the types, but does not show them in any way.
To fix, add a new menu option to display this information. For handle
type, it is represented using the shape of the key icons: diamond for
Free, clipped diamond for Aligned, square for Vector, circle for Auto
Clamp, and cirle with dot for Automatic.
Non-bezier interpolation is a property of intervals between keys,
so it is marked by drawing lines, similar to holds. In this initial
version, only the fact of non-bezier interpolation is displayed,
without distinguishing types. For summaries, the line is drawn at
half alpha if not all curves in the group are non-bezier.
In addition, it is sometimes helpful to know the general direction
of change of the curve, and which keys are extremes. This commit
also adds an option to highlight extremes, based on comparing the
keyed values with adjacent keys. Half-intensity display is used
for overshot bezier extremes, or non-uniform summaries.
Reviewers: brecht, aligorith, billreynish
Differential Revision: https://developer.blender.org/D3788
2018-10-19 18:55:19 +03:00
|
|
|
uint flags_id = GPU_vertformat_attr_add(format, "flags", GPU_COMP_U32, 1, GPU_FETCH_INT);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-28 17:14:22 +02:00
|
|
|
GPU_program_point_size(true);
|
2019-08-22 11:10:11 +02:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND);
|
|
|
|
immUniform1f("outline_scale", 1.0f);
|
Dope Sheet: new option to display keyframe interpolation mode and extremes.
With the new automatic handle algorithm, it is possible to do a lot
of the animation via keyframes without touching the curves. It is
however necessary to change the keyframe interpolation and handle
types in certain cases. Currently the dopesheet/action editor
allows changing the types, but does not show them in any way.
To fix, add a new menu option to display this information. For handle
type, it is represented using the shape of the key icons: diamond for
Free, clipped diamond for Aligned, square for Vector, circle for Auto
Clamp, and cirle with dot for Automatic.
Non-bezier interpolation is a property of intervals between keys,
so it is marked by drawing lines, similar to holds. In this initial
version, only the fact of non-bezier interpolation is displayed,
without distinguishing types. For summaries, the line is drawn at
half alpha if not all curves in the group are non-bezier.
In addition, it is sometimes helpful to know the general direction
of change of the curve, and which keys are extremes. This commit
also adds an option to highlight extremes, based on comparing the
keyed values with adjacent keys. Half-intensity display is used
for overshot bezier extremes, or non-uniform summaries.
Reviewers: brecht, aligorith, billreynish
Differential Revision: https://developer.blender.org/D3788
2018-10-19 18:55:19 +03:00
|
|
|
immUniform2f(
|
|
|
|
"ViewportSize", BLI_rcti_size_x(&v2d->mask) + 1, BLI_rcti_size_y(&v2d->mask) + 1);
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_POINTS, keyframe_len);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-11 00:24:59 -05:00
|
|
|
/* all same size with black outline */
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr1f(size_id, 2.0f * STRIP_HEIGHT_HALF);
|
|
|
|
immAttr4ub(outline_color_id, 0, 0, 0, 255);
|
Dope Sheet: new option to display keyframe interpolation mode and extremes.
With the new automatic handle algorithm, it is possible to do a lot
of the animation via keyframes without touching the curves. It is
however necessary to change the keyframe interpolation and handle
types in certain cases. Currently the dopesheet/action editor
allows changing the types, but does not show them in any way.
To fix, add a new menu option to display this information. For handle
type, it is represented using the shape of the key icons: diamond for
Free, clipped diamond for Aligned, square for Vector, circle for Auto
Clamp, and cirle with dot for Automatic.
Non-bezier interpolation is a property of intervals between keys,
so it is marked by drawing lines, similar to holds. In this initial
version, only the fact of non-bezier interpolation is displayed,
without distinguishing types. For summaries, the line is drawn at
half alpha if not all curves in the group are non-bezier.
In addition, it is sometimes helpful to know the general direction
of change of the curve, and which keys are extremes. This commit
also adds an option to highlight extremes, based on comparing the
keyed values with adjacent keys. Half-intensity display is used
for overshot bezier extremes, or non-uniform summaries.
Reviewers: brecht, aligorith, billreynish
Differential Revision: https://developer.blender.org/D3788
2018-10-19 18:55:19 +03:00
|
|
|
immAttr1u(flags_id, 0);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-11 00:24:59 -05:00
|
|
|
y = (float)CHANNEL_FIRST; /* start again at the top */
|
|
|
|
for (channel = dopesheet->channels.first; channel; channel = channel->next) {
|
|
|
|
float yminc = (float)(y - CHANNEL_HEIGHT_HALF);
|
|
|
|
float ymaxc = (float)(y + CHANNEL_HEIGHT_HALF);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-11 00:24:59 -05:00
|
|
|
/* check if visible */
|
|
|
|
if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
|
2017-10-07 15:57:14 +11:00
|
|
|
IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax)) {
|
2017-02-11 00:24:59 -05:00
|
|
|
MovieTrackingTrack *track = channel->track;
|
|
|
|
int i;
|
|
|
|
bool sel = (track->flag & TRACK_DOPE_SEL) != 0;
|
|
|
|
float alpha = (track->flag & TRACK_LOCKED) ? 0.5f : 1.0f;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-11 00:24:59 -05:00
|
|
|
/* tracked segments */
|
|
|
|
for (i = 0; i < channel->tot_segment; i++) {
|
|
|
|
int start_frame = BKE_movieclip_remap_clip_to_scene_frame(clip,
|
|
|
|
channel->segments[2 * i]);
|
|
|
|
int end_frame = BKE_movieclip_remap_clip_to_scene_frame(clip,
|
|
|
|
channel->segments[2 * i + 1]);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-11 00:24:59 -05:00
|
|
|
if (start_frame != end_frame) {
|
|
|
|
draw_keyframe_shape(start_frame, y, sel, alpha, pos_id, color_id);
|
|
|
|
draw_keyframe_shape(end_frame, y, sel, alpha, pos_id, color_id);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
draw_keyframe_shape(start_frame, y, sel, alpha, pos_id, color_id);
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2017-02-11 00:24:59 -05:00
|
|
|
/* keyframes */
|
|
|
|
i = 0;
|
|
|
|
while (i < track->markersnr) {
|
|
|
|
MovieTrackingMarker *marker = &track->markers[i];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-11 00:24:59 -05:00
|
|
|
if ((marker->flag & (MARKER_DISABLED | MARKER_TRACKED)) == 0) {
|
|
|
|
int framenr = BKE_movieclip_remap_clip_to_scene_frame(clip, marker->framenr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-11 00:24:59 -05:00
|
|
|
draw_keyframe_shape(framenr, y, sel, alpha, pos_id, color_id);
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-11 00:24:59 -05:00
|
|
|
i++;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2017-02-11 00:24:59 -05:00
|
|
|
/* adjust y-position for next one */
|
|
|
|
y -= CHANNEL_STEP;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-11 00:24:59 -05:00
|
|
|
immEnd();
|
2019-05-28 17:14:22 +02:00
|
|
|
GPU_program_point_size(false);
|
2017-02-11 00:24:59 -05:00
|
|
|
immUnbindProgram();
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
2012-04-30 16:19:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
void clip_draw_dopesheet_channels(const bContext *C, ARegion *region)
|
2012-04-30 16:19:20 +00:00
|
|
|
{
|
2020-04-03 13:25:03 +02:00
|
|
|
ScrArea *area = CTX_wm_area(C);
|
2012-04-30 16:19:20 +00:00
|
|
|
SpaceClip *sc = CTX_wm_space_clip(C);
|
2020-03-06 16:56:42 +01:00
|
|
|
View2D *v2d = ®ion->v2d;
|
2012-06-19 14:26:29 +00:00
|
|
|
MovieClip *clip = ED_space_clip_get_clip(sc);
|
2020-03-15 17:32:25 +11:00
|
|
|
const uiStyle *style = UI_style_get();
|
2012-04-30 16:19:20 +00:00
|
|
|
int fontid = style->widget.uifont_id;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:19:45 +10:00
|
|
|
if (!clip) {
|
2012-04-30 16:19:20 +00:00
|
|
|
return;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-11 00:24:59 -05:00
|
|
|
MovieTracking *tracking = &clip->tracking;
|
|
|
|
MovieTrackingDopesheet *dopesheet = &tracking->dopesheet;
|
2020-06-18 12:21:38 +10:00
|
|
|
int height = (dopesheet->tot_channel * CHANNEL_STEP) + CHANNEL_HEIGHT;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-09-15 11:48:20 +00:00
|
|
|
if (height > BLI_rcti_size_y(&v2d->mask)) {
|
2012-05-03 17:52:34 +00:00
|
|
|
/* don't use totrect set, as the width stays the same
|
|
|
|
* (NOTE: this is ok here, the configuration is pretty straightforward)
|
2012-04-30 16:19:20 +00:00
|
|
|
*/
|
|
|
|
v2d->tot.ymin = (float)(-height);
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-15 23:24:20 +11:00
|
|
|
/* need to do a view-sync here, so that the keys area doesn't jump around
|
|
|
|
* (it must copy this) */
|
2020-04-03 13:25:03 +02:00
|
|
|
UI_view2d_sync(NULL, area, v2d, V2D_LOCK_COPY);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-30 16:19:20 +00:00
|
|
|
/* loop through channels, and set up drawing depending on their type
|
|
|
|
* first pass: just the standard GL-drawing for backdrop + text
|
|
|
|
*/
|
2017-02-11 00:24:59 -05:00
|
|
|
float y = (float)CHANNEL_FIRST;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
GPUVertFormat *format = immVertexFormat();
|
|
|
|
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-11 00:24:59 -05:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-11 00:24:59 -05:00
|
|
|
MovieTrackingDopesheetChannel *channel;
|
2012-04-30 16:19:20 +00:00
|
|
|
for (channel = dopesheet->channels.first; channel; channel = channel->next) {
|
|
|
|
float yminc = (float)(y - CHANNEL_HEIGHT_HALF);
|
|
|
|
float ymaxc = (float)(y + CHANNEL_HEIGHT_HALF);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-30 16:19:20 +00:00
|
|
|
/* check if visible */
|
|
|
|
if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
|
|
|
|
IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax)) {
|
|
|
|
MovieTrackingTrack *track = channel->track;
|
2017-02-11 00:24:59 -05:00
|
|
|
float color[3];
|
2012-04-30 16:19:20 +00:00
|
|
|
track_channel_color(track, NULL, color);
|
2017-02-01 22:42:50 -05:00
|
|
|
immUniformColor3fv(color);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-01 22:42:50 -05:00
|
|
|
immRectf(pos,
|
|
|
|
v2d->cur.xmin,
|
|
|
|
(float)y - CHANNEL_HEIGHT_HALF,
|
2017-02-11 00:24:59 -05:00
|
|
|
v2d->cur.xmax + EXTRA_SCROLL_PAD,
|
|
|
|
(float)y + CHANNEL_HEIGHT_HALF);
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-11 00:24:59 -05:00
|
|
|
/* adjust y-position for next one */
|
|
|
|
y -= CHANNEL_STEP;
|
|
|
|
}
|
|
|
|
immUnbindProgram();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-11 00:24:59 -05:00
|
|
|
/* second pass: text */
|
|
|
|
y = (float)CHANNEL_FIRST;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-11 00:24:59 -05:00
|
|
|
BLF_size(fontid, 11.0f * U.pixelsize, U.dpi);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-11 00:24:59 -05:00
|
|
|
for (channel = dopesheet->channels.first; channel; channel = channel->next) {
|
|
|
|
float yminc = (float)(y - CHANNEL_HEIGHT_HALF);
|
|
|
|
float ymaxc = (float)(y + CHANNEL_HEIGHT_HALF);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-11 00:24:59 -05:00
|
|
|
/* check if visible */
|
|
|
|
if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
|
|
|
|
IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax)) {
|
|
|
|
MovieTrackingTrack *track = channel->track;
|
|
|
|
bool sel = (track->flag & TRACK_DOPE_SEL) != 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-07 20:53:20 -02:00
|
|
|
UI_FontThemeColor(fontid, sel ? TH_TEXT_HI : TH_TEXT);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-11 00:24:59 -05:00
|
|
|
float font_height = BLF_height(fontid, channel->name, sizeof(channel->name));
|
2012-04-30 16:19:20 +00:00
|
|
|
BLF_position(fontid, v2d->cur.xmin + CHANNEL_PAD, y - font_height / 2.0f, 0.0f);
|
2012-06-12 17:11:00 +00:00
|
|
|
BLF_draw(fontid, channel->name, strlen(channel->name));
|
2012-04-30 16:19:20 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-30 16:19:20 +00:00
|
|
|
/* adjust y-position for next one */
|
|
|
|
y -= CHANNEL_STEP;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-11 00:24:59 -05:00
|
|
|
/* third pass: widgets */
|
2020-03-06 16:56:42 +01:00
|
|
|
uiBlock *block = UI_block_begin(C, region, __func__, UI_EMBOSS);
|
2012-04-30 16:19:20 +00:00
|
|
|
y = (float)CHANNEL_FIRST;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-01-17 08:37:45 +11:00
|
|
|
/* get RNA properties (once) */
|
2017-02-11 00:24:59 -05:00
|
|
|
PropertyRNA *chan_prop_lock = RNA_struct_type_find_property(&RNA_MovieTrackingTrack, "lock");
|
2014-01-17 08:37:45 +11:00
|
|
|
BLI_assert(chan_prop_lock);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2012-04-30 16:19:20 +00:00
|
|
|
for (channel = dopesheet->channels.first; channel; channel = channel->next) {
|
|
|
|
float yminc = (float)(y - CHANNEL_HEIGHT_HALF);
|
|
|
|
float ymaxc = (float)(y + CHANNEL_HEIGHT_HALF);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-30 16:19:20 +00:00
|
|
|
/* check if visible */
|
|
|
|
if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
|
|
|
|
IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax)) {
|
|
|
|
MovieTrackingTrack *track = channel->track;
|
2012-05-26 22:21:56 +00:00
|
|
|
const int icon = (track->flag & TRACK_LOCKED) ? ICON_LOCKED : ICON_UNLOCKED;
|
2012-04-30 16:19:20 +00:00
|
|
|
PointerRNA ptr;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-30 16:19:20 +00:00
|
|
|
RNA_pointer_create(&clip->id, &RNA_MovieTrackingTrack, track, &ptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(block, UI_EMBOSS_NONE);
|
|
|
|
uiDefIconButR_prop(block,
|
|
|
|
UI_BTYPE_ICON_TOGGLE,
|
|
|
|
1,
|
|
|
|
icon,
|
2014-01-17 08:37:45 +11:00
|
|
|
v2d->cur.xmax - UI_UNIT_X - CHANNEL_PAD,
|
|
|
|
y - UI_UNIT_Y / 2.0f,
|
|
|
|
UI_UNIT_X,
|
|
|
|
UI_UNIT_Y,
|
|
|
|
&ptr,
|
|
|
|
chan_prop_lock,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
NULL);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(block, UI_EMBOSS);
|
2012-04-30 16:19:20 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-30 16:19:20 +00:00
|
|
|
/* adjust y-position for next one */
|
|
|
|
y -= CHANNEL_STEP;
|
|
|
|
}
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_end(C, block);
|
|
|
|
UI_block_draw(C, block);
|
2012-04-30 16:19:20 +00:00
|
|
|
}
|