VSE: Add color tags to strips

This patch adds color tags to VSE strips, an overlay option to toggle the colors
on and off, a section in the theme settings to define the 9 possible colors and
two ways of changing the color tag through the UI. You can change the color
through the right-click context menu, or in the strip side panel next to the
strip name.

Color tags are defined in user preferences and they can be disabled in overlay
settings.

Reviewed By: campbellbarton, ISS

Differential Revision: https://developer.blender.org/D12405
This commit is contained in:
Falk David 2021-09-29 14:29:32 +02:00 committed by Richard Antalik
parent ffb9577ac9
commit 5cebcb415e
Notes: blender-bot 2023-02-14 05:04:52 +01:00
Referenced by commit fc6228bd85, Fix T91873: Crash when opening properties panel
Referenced by issue #91873, Video editing crash
22 changed files with 417 additions and 61 deletions

View File

@ -1175,6 +1175,35 @@ const bTheme U_theme_default = {
.color = RGBA(0x7a5441ff),
},
},
.strip_color = {
{
.color = RGBA(0xe2605bff),
},
{
.color = RGBA(0xf1a355ff),
},
{
.color = RGBA(0xf1dc55ff),
},
{
.color = RGBA(0x7bcc7bff),
},
{
.color = RGBA(0x5db6eaff),
},
{
.color = RGBA(0x8d59daff),
},
{
.color = RGBA(0xc673b8ff),
},
{
.color = RGBA(0x7a5441ff),
},
{
.color = RGBA(0x5f5f5fff),
},
},
};
/* clang-format on */

View File

@ -241,6 +241,7 @@ class SEQUENCER_PT_sequencer_overlay(Panel):
layout.prop(overlay_settings, "show_strip_name", text="Name")
layout.prop(overlay_settings, "show_strip_source", text="Source")
layout.prop(overlay_settings, "show_strip_duration", text="Duration")
layout.prop(overlay_settings, "show_strip_tag_color", text="Color Tags")
layout.separator()
@ -868,6 +869,9 @@ class SEQUENCER_MT_strip(Menu):
layout.operator("sequencer.meta_make")
layout.operator("sequencer.meta_toggle", text="Toggle Meta")
layout.separator()
layout.menu("SEQUENCER_MT_color_tag_picker")
layout.separator()
layout.menu("SEQUENCER_MT_strip_lock_mute")
@ -964,6 +968,9 @@ class SEQUENCER_MT_context_menu(Menu):
layout.operator("sequencer.meta_make")
layout.operator("sequencer.meta_toggle", text="Toggle Meta")
layout.separator()
layout.menu("SEQUENCER_MT_color_tag_picker")
layout.separator()
layout.menu("SEQUENCER_MT_strip_lock_mute")
@ -996,6 +1003,41 @@ class SequencerButtonsPanel_Output:
return cls.has_preview(context)
class SEQUENCER_PT_color_tag_picker(Panel):
bl_label = "Color Tag"
bl_space_type = 'SEQUENCE_EDITOR'
bl_region_type = 'UI'
bl_category = "Strip"
bl_options = {'HIDE_HEADER', 'INSTANCED'}
@classmethod
def poll(cls, context):
return context.active_sequence_strip is not None
def draw(self, context):
layout = self.layout
row = layout.row(align=True)
row.operator("sequencer.strip_color_tag_set", icon="X").color = 'NONE'
for i in range(1, 10):
icon = 'SEQUENCE_COLOR_%02d' % i
row.operator("sequencer.strip_color_tag_set", icon=icon).color = 'COLOR_%02d' % i
class SEQUENCER_MT_color_tag_picker(Menu):
bl_label = "Set Color Tag"
@classmethod
def poll(cls, context):
return context.active_sequence_strip is not None
def draw(self, context):
layout = self.layout
row = layout.row(align=True)
row.operator_enum("sequencer.strip_color_tag_set", "color", icon_only=True)
class SEQUENCER_PT_strip(SequencerButtonsPanel, Panel):
bl_label = ""
bl_options = {'HIDE_HEADER'}
@ -1039,9 +1081,20 @@ class SEQUENCER_PT_strip(SequencerButtonsPanel, Panel):
else:
icon_header = 'SEQ_SEQUENCER'
row = layout.row()
row = layout.row(align=True)
row.use_property_decorate = False
row.label(text="", icon=icon_header)
row.separator()
row.prop(strip, "name", text="")
sub = row.row(align=True)
if strip.color_tag == 'NONE':
sub.popover(panel="SEQUENCER_PT_color_tag_picker", text="", icon='COLOR')
else:
icon = 'SEQUENCE_' + strip.color_tag
sub.popover(panel="SEQUENCER_PT_color_tag_picker", text="", icon=icon)
row.separator()
row.prop(strip, "mute", toggle=True, icon_only=True, emboss=False)
@ -2327,8 +2380,11 @@ classes = (
SEQUENCER_MT_strip_transform,
SEQUENCER_MT_strip_input,
SEQUENCER_MT_strip_lock_mute,
SEQUENCER_MT_color_tag_picker,
SEQUENCER_MT_context_menu,
SEQUENCER_PT_color_tag_picker,
SEQUENCER_PT_active_tool,
SEQUENCER_PT_strip,

View File

@ -1073,6 +1073,25 @@ class USERPREF_PT_theme_collection_colors(ThemePanel, CenterAlignMixIn, Panel):
flow.prop(ui, "color", text=iface_("Color %d") % i, translate=False)
class USERPREF_PT_theme_strip_colors(ThemePanel, CenterAlignMixIn, Panel):
bl_label = "Strip Colors"
bl_options = {'DEFAULT_CLOSED'}
def draw_header(self, _context):
layout = self.layout
layout.label(icon='SEQ_STRIP_DUPLICATE')
def draw_centered(self, context, layout):
theme = context.preferences.themes[0]
layout.use_property_split = True
flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
for i, ui in enumerate(theme.strip_color, 1):
flow.prop(ui, "color", text=iface_("Color %d") % i, translate=False)
# Base class for dynamically defined theme-space panels.
# This is not registered.
class PreferenceThemeSpacePanel:
@ -2348,6 +2367,7 @@ classes = (
USERPREF_PT_theme_text_style,
USERPREF_PT_theme_bone_color_sets,
USERPREF_PT_theme_collection_colors,
USERPREF_PT_theme_strip_colors,
USERPREF_PT_file_paths_data,
USERPREF_PT_file_paths_render,

View File

@ -39,7 +39,7 @@ extern "C" {
/* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION
#define BLENDER_FILE_SUBVERSION 30
#define BLENDER_FILE_SUBVERSION 31
/* Minimum Blender version that supports reading file written with the current
* version. Older Blender versions will test this and show a warning if the file

View File

@ -449,6 +449,12 @@ static void do_versions_sequencer_speed_effect_recursive(Scene *scene, const Lis
#undef SEQ_SPEED_COMPRESS_IPO_Y
}
static bool do_versions_sequencer_color_tags(Sequence *seq, void *UNUSED(user_data))
{
seq->color_tag = SEQUENCE_COLOR_NONE;
return true;
}
static bNodeLink *find_connected_link(bNodeTree *ntree, bNodeSocket *in_socket)
{
LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) {
@ -1614,18 +1620,7 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
/**
* Versioning code until next subversion bump goes here.
*
* \note Be sure to check when bumping the version:
* - "versioning_userdef.c", #blo_do_versions_userdef
* - "versioning_userdef.c", #do_versions_theme
*
* \note Keep this message at the bottom of the function.
*/
{
/* Keep this block, even when empty. */
if (!MAIN_VERSION_ATLEAST(bmain, 300, 31)) {
/* Swap header with the tool header so the regular header is always on the edge. */
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
@ -1650,5 +1645,37 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
/* Set strip color tags to SEQUENCE_COLOR_NONE. */
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
if (scene->ed != NULL) {
SEQ_for_each_callback(&scene->ed->seqbase, do_versions_sequencer_color_tags, NULL);
}
}
/* Show vse color tags by default. */
LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
if (sl->spacetype == SPACE_SEQ) {
SpaceSeq *sseq = (SpaceSeq *)sl;
sseq->timeline_overlay.flag |= SEQ_TIMELINE_SHOW_STRIP_COLOR_TAG;
}
}
}
}
}
/**
* Versioning code until next subversion bump goes here.
*
* \note Be sure to check when bumping the version:
* - "versioning_userdef.c", #blo_do_versions_userdef
* - "versioning_userdef.c", #do_versions_theme
*
* \note Keep this message at the bottom of the function.
*/
{
/* Keep this block, even when empty. */
}
}

View File

@ -160,7 +160,8 @@ static void blo_update_defaults_screen(bScreen *screen,
seq->flag |= SEQ_SHOW_MARKERS | SEQ_ZOOM_TO_FIT | SEQ_USE_PROXIES | SEQ_SHOW_OVERLAY;
seq->render_size = SEQ_RENDER_SIZE_PROXY_100;
seq->timeline_overlay.flag |= SEQ_TIMELINE_SHOW_STRIP_SOURCE | SEQ_TIMELINE_SHOW_STRIP_NAME |
SEQ_TIMELINE_SHOW_STRIP_DURATION | SEQ_TIMELINE_SHOW_GRID;
SEQ_TIMELINE_SHOW_STRIP_DURATION | SEQ_TIMELINE_SHOW_GRID |
SEQ_TIMELINE_SHOW_STRIP_COLOR_TAG;
seq->preview_overlay.flag |= SEQ_PREVIEW_SHOW_OUTLINE_SELECTED;
}
else if (area->spacetype == SPACE_TEXT) {

View File

@ -295,6 +295,12 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme)
FROM_DEFAULT_V4_UCHAR(space_node.wire);
}
if (!USER_VERSION_ATLEAST(300, 31)) {
for (int i = 0; i < SEQUENCE_COLOR_TOT; ++i) {
FROM_DEFAULT_V4_UCHAR(strip_color[i].color);
}
}
/**
* Versioning code until next subversion bump goes here.
*

View File

@ -989,6 +989,16 @@ DEF_ICON_VECTOR(COLLECTION_COLOR_06)
DEF_ICON_VECTOR(COLLECTION_COLOR_07)
DEF_ICON_VECTOR(COLLECTION_COLOR_08)
DEF_ICON_VECTOR(SEQUENCE_COLOR_01)
DEF_ICON_VECTOR(SEQUENCE_COLOR_02)
DEF_ICON_VECTOR(SEQUENCE_COLOR_03)
DEF_ICON_VECTOR(SEQUENCE_COLOR_04)
DEF_ICON_VECTOR(SEQUENCE_COLOR_05)
DEF_ICON_VECTOR(SEQUENCE_COLOR_06)
DEF_ICON_VECTOR(SEQUENCE_COLOR_07)
DEF_ICON_VECTOR(SEQUENCE_COLOR_08)
DEF_ICON_VECTOR(SEQUENCE_COLOR_09)
/* Events. */
DEF_ICON_COLOR(EVENT_A)
DEF_ICON_COLOR(EVENT_B)

View File

@ -47,6 +47,7 @@
#include "DNA_gpencil_types.h"
#include "DNA_object_types.h"
#include "DNA_screen_types.h"
#include "DNA_sequence_types.h"
#include "DNA_space_types.h"
#include "RNA_access.h"
@ -480,6 +481,35 @@ DEF_ICON_COLLECTION_COLOR_DRAW(08, COLLECTION_COLOR_08);
# undef DEF_ICON_COLLECTION_COLOR_DRAW
static void vicon_strip_color_draw(
short color_tag, int x, int y, int w, int UNUSED(h), float UNUSED(alpha))
{
bTheme *btheme = UI_GetTheme();
const ThemeStripColor *strip_color = &btheme->strip_color[color_tag];
const float aspect = (float)ICON_DEFAULT_WIDTH / (float)w;
UI_icon_draw_ex(x, y, ICON_SNAP_FACE, aspect, 1.0f, 0.0f, strip_color->color, true);
}
# define DEF_ICON_STRIP_COLOR_DRAW(index, color) \
static void vicon_strip_color_draw_##index(int x, int y, int w, int h, float alpha) \
{ \
vicon_strip_color_draw(color, x, y, w, h, alpha); \
}
DEF_ICON_STRIP_COLOR_DRAW(01, SEQUENCE_COLOR_01);
DEF_ICON_STRIP_COLOR_DRAW(02, SEQUENCE_COLOR_02);
DEF_ICON_STRIP_COLOR_DRAW(03, SEQUENCE_COLOR_03);
DEF_ICON_STRIP_COLOR_DRAW(04, SEQUENCE_COLOR_04);
DEF_ICON_STRIP_COLOR_DRAW(05, SEQUENCE_COLOR_05);
DEF_ICON_STRIP_COLOR_DRAW(06, SEQUENCE_COLOR_06);
DEF_ICON_STRIP_COLOR_DRAW(07, SEQUENCE_COLOR_07);
DEF_ICON_STRIP_COLOR_DRAW(08, SEQUENCE_COLOR_08);
DEF_ICON_STRIP_COLOR_DRAW(09, SEQUENCE_COLOR_09);
# undef DEF_ICON_STRIP_COLOR_DRAW
/* Dynamically render icon instead of rendering a plain color to a texture/buffer
* This is not strictly a "vicon", as it needs access to icon->obj to get the color info,
* but it works in a very similar way.
@ -995,6 +1025,16 @@ static void init_internal_icons(void)
def_internal_vicon(ICON_COLLECTION_COLOR_06, vicon_collection_color_draw_06);
def_internal_vicon(ICON_COLLECTION_COLOR_07, vicon_collection_color_draw_07);
def_internal_vicon(ICON_COLLECTION_COLOR_08, vicon_collection_color_draw_08);
def_internal_vicon(ICON_SEQUENCE_COLOR_01, vicon_strip_color_draw_01);
def_internal_vicon(ICON_SEQUENCE_COLOR_02, vicon_strip_color_draw_02);
def_internal_vicon(ICON_SEQUENCE_COLOR_03, vicon_strip_color_draw_03);
def_internal_vicon(ICON_SEQUENCE_COLOR_04, vicon_strip_color_draw_04);
def_internal_vicon(ICON_SEQUENCE_COLOR_05, vicon_strip_color_draw_05);
def_internal_vicon(ICON_SEQUENCE_COLOR_06, vicon_strip_color_draw_06);
def_internal_vicon(ICON_SEQUENCE_COLOR_07, vicon_strip_color_draw_07);
def_internal_vicon(ICON_SEQUENCE_COLOR_08, vicon_strip_color_draw_08);
def_internal_vicon(ICON_SEQUENCE_COLOR_09, vicon_strip_color_draw_09);
}
static void init_iconfile_list(struct ListBase *list)

View File

@ -107,36 +107,53 @@
static Sequence *special_seq_update = NULL;
void color3ubv_from_seq(Scene *curscene, Sequence *seq, uchar col[3])
void color3ubv_from_seq(const Scene *curscene,
const Sequence *seq,
const bool show_strip_color_tag,
uchar r_col[3])
{
if (show_strip_color_tag && (uint)seq->color_tag < SEQUENCE_COLOR_TOT &&
seq->color_tag != SEQUENCE_COLOR_NONE) {
bTheme *btheme = UI_GetTheme();
const ThemeStripColor *strip_color = &btheme->strip_color[seq->color_tag];
copy_v3_v3_uchar(r_col, strip_color->color);
return;
}
uchar blendcol[3];
/* Sometimes the active theme is not the sequencer theme, e.g. when an operator invokes the file
* browser. This makes sure we get the right color values for the theme. */
struct bThemeState theme_state;
UI_Theme_Store(&theme_state);
UI_SetTheme(SPACE_SEQ, RGN_TYPE_WINDOW);
switch (seq->type) {
case SEQ_TYPE_IMAGE:
UI_GetThemeColor3ubv(TH_SEQ_IMAGE, col);
UI_GetThemeColor3ubv(TH_SEQ_IMAGE, r_col);
break;
case SEQ_TYPE_META:
UI_GetThemeColor3ubv(TH_SEQ_META, col);
UI_GetThemeColor3ubv(TH_SEQ_META, r_col);
break;
case SEQ_TYPE_MOVIE:
UI_GetThemeColor3ubv(TH_SEQ_MOVIE, col);
UI_GetThemeColor3ubv(TH_SEQ_MOVIE, r_col);
break;
case SEQ_TYPE_MOVIECLIP:
UI_GetThemeColor3ubv(TH_SEQ_MOVIECLIP, col);
UI_GetThemeColor3ubv(TH_SEQ_MOVIECLIP, r_col);
break;
case SEQ_TYPE_MASK:
UI_GetThemeColor3ubv(TH_SEQ_MASK, col);
UI_GetThemeColor3ubv(TH_SEQ_MASK, r_col);
break;
case SEQ_TYPE_SCENE:
UI_GetThemeColor3ubv(TH_SEQ_SCENE, col);
UI_GetThemeColor3ubv(TH_SEQ_SCENE, r_col);
if (seq->scene == curscene) {
UI_GetColorPtrShade3ubv(col, col, 20);
UI_GetColorPtrShade3ubv(r_col, r_col, 20);
}
break;
@ -144,9 +161,9 @@ void color3ubv_from_seq(Scene *curscene, Sequence *seq, uchar col[3])
case SEQ_TYPE_CROSS:
case SEQ_TYPE_GAMCROSS:
case SEQ_TYPE_WIPE:
col[0] = 130;
col[1] = 130;
col[2] = 130;
r_col[0] = 130;
r_col[1] = 130;
r_col[2] = 130;
break;
/* Effects. */
@ -163,72 +180,74 @@ void color3ubv_from_seq(Scene *curscene, Sequence *seq, uchar col[3])
case SEQ_TYPE_ADJUSTMENT:
case SEQ_TYPE_GAUSSIAN_BLUR:
case SEQ_TYPE_COLORMIX:
UI_GetThemeColor3ubv(TH_SEQ_EFFECT, col);
UI_GetThemeColor3ubv(TH_SEQ_EFFECT, r_col);
/* Slightly offset hue to distinguish different effects. */
if (seq->type == SEQ_TYPE_ADD) {
rgb_byte_set_hue_float_offset(col, 0.03);
rgb_byte_set_hue_float_offset(r_col, 0.03);
}
else if (seq->type == SEQ_TYPE_SUB) {
rgb_byte_set_hue_float_offset(col, 0.06);
rgb_byte_set_hue_float_offset(r_col, 0.06);
}
else if (seq->type == SEQ_TYPE_MUL) {
rgb_byte_set_hue_float_offset(col, 0.13);
rgb_byte_set_hue_float_offset(r_col, 0.13);
}
else if (seq->type == SEQ_TYPE_ALPHAOVER) {
rgb_byte_set_hue_float_offset(col, 0.16);
rgb_byte_set_hue_float_offset(r_col, 0.16);
}
else if (seq->type == SEQ_TYPE_ALPHAUNDER) {
rgb_byte_set_hue_float_offset(col, 0.23);
rgb_byte_set_hue_float_offset(r_col, 0.23);
}
else if (seq->type == SEQ_TYPE_OVERDROP) {
rgb_byte_set_hue_float_offset(col, 0.26);
rgb_byte_set_hue_float_offset(r_col, 0.26);
}
else if (seq->type == SEQ_TYPE_COLORMIX) {
rgb_byte_set_hue_float_offset(col, 0.33);
rgb_byte_set_hue_float_offset(r_col, 0.33);
}
else if (seq->type == SEQ_TYPE_GAUSSIAN_BLUR) {
rgb_byte_set_hue_float_offset(col, 0.43);
rgb_byte_set_hue_float_offset(r_col, 0.43);
}
else if (seq->type == SEQ_TYPE_GLOW) {
rgb_byte_set_hue_float_offset(col, 0.46);
rgb_byte_set_hue_float_offset(r_col, 0.46);
}
else if (seq->type == SEQ_TYPE_ADJUSTMENT) {
rgb_byte_set_hue_float_offset(col, 0.55);
rgb_byte_set_hue_float_offset(r_col, 0.55);
}
else if (seq->type == SEQ_TYPE_SPEED) {
rgb_byte_set_hue_float_offset(col, 0.65);
rgb_byte_set_hue_float_offset(r_col, 0.65);
}
else if (seq->type == SEQ_TYPE_TRANSFORM) {
rgb_byte_set_hue_float_offset(col, 0.75);
rgb_byte_set_hue_float_offset(r_col, 0.75);
}
else if (seq->type == SEQ_TYPE_MULTICAM) {
rgb_byte_set_hue_float_offset(col, 0.85);
rgb_byte_set_hue_float_offset(r_col, 0.85);
}
break;
case SEQ_TYPE_COLOR:
UI_GetThemeColor3ubv(TH_SEQ_COLOR, col);
UI_GetThemeColor3ubv(TH_SEQ_COLOR, r_col);
break;
case SEQ_TYPE_SOUND_RAM:
UI_GetThemeColor3ubv(TH_SEQ_AUDIO, col);
UI_GetThemeColor3ubv(TH_SEQ_AUDIO, r_col);
blendcol[0] = blendcol[1] = blendcol[2] = 128;
if (seq->flag & SEQ_MUTE) {
UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.5, 20);
UI_GetColorPtrBlendShade3ubv(r_col, blendcol, r_col, 0.5, 20);
}
break;
case SEQ_TYPE_TEXT:
UI_GetThemeColor3ubv(TH_SEQ_TEXT, col);
UI_GetThemeColor3ubv(TH_SEQ_TEXT, r_col);
break;
default:
col[0] = 10;
col[1] = 255;
col[2] = 40;
r_col[0] = 10;
r_col[1] = 255;
r_col[2] = 40;
break;
}
UI_Theme_Restore(&theme_state);
}
typedef struct WaveVizData {
@ -558,7 +577,13 @@ static void draw_seq_waveform_overlay(View2D *v2d,
}
}
static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, float x2, float y2)
static void drawmeta_contents(Scene *scene,
Sequence *seqm,
float x1,
float y1,
float x2,
float y2,
const bool show_strip_color_tag)
{
Sequence *seq;
uchar col[4];
@ -614,7 +639,7 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1,
rgb_float_to_uchar(col, colvars->col);
}
else {
color3ubv_from_seq(scene, seq, col);
color3ubv_from_seq(scene, seq, show_strip_color_tag, col);
}
if ((seqm->flag & SEQ_MUTE) || (seq->flag & SEQ_MUTE)) {
@ -953,7 +978,8 @@ static void draw_seq_text_overlay(View2D *v2d,
UI_view2d_text_cache_add_rectf(v2d, &rect, overlay_string, overlay_string_len, col);
}
static void draw_sequence_extensions_overlay(Scene *scene, Sequence *seq, uint pos, float pixely)
static void draw_sequence_extensions_overlay(
Scene *scene, Sequence *seq, uint pos, float pixely, const bool show_strip_color_tag)
{
float x1, x2, y1, y2;
uchar col[4], blend_col[3];
@ -966,7 +992,7 @@ static void draw_sequence_extensions_overlay(Scene *scene, Sequence *seq, uint p
GPU_blend(GPU_BLEND_ALPHA);
color3ubv_from_seq(scene, seq, col);
color3ubv_from_seq(scene, seq, show_strip_color_tag, col);
if (seq->flag & SELECT) {
UI_GetColorPtrShade3ubv(col, col, 50);
}
@ -1036,7 +1062,8 @@ static void draw_seq_background(Scene *scene,
float x2,
float y1,
float y2,
bool is_single_image)
bool is_single_image,
bool show_strip_color_tag)
{
uchar col[4];
GPU_blend(GPU_BLEND_ALPHA);
@ -1049,11 +1076,11 @@ static void draw_seq_background(Scene *scene,
rgb_float_to_uchar(col, colvars->col);
}
else {
color3ubv_from_seq(scene, seq1, col);
color3ubv_from_seq(scene, seq1, show_strip_color_tag, col);
}
}
else {
color3ubv_from_seq(scene, seq, col);
color3ubv_from_seq(scene, seq, show_strip_color_tag, col);
}
/* Draw muted strips semi-transparent. */
@ -1108,7 +1135,7 @@ static void draw_seq_background(Scene *scene,
rgb_float_to_uchar(col, colvars->col);
}
else {
color3ubv_from_seq(scene, seq2, col);
color3ubv_from_seq(scene, seq2, show_strip_color_tag, col);
/* If the transition inputs are of the same type, draw the right side slightly darker. */
if (seq1->type == seq2->type) {
UI_GetColorPtrShade3ubv(col, col, -15);
@ -1822,6 +1849,10 @@ static void draw_seq_strip(const bContext *C,
/* Check if we are doing "solo preview". */
bool is_single_image = (char)SEQ_transform_single_image_check(seq);
/* Use the seq->color_tag to display the tag color. */
const bool show_strip_color_tag = (sseq->timeline_overlay.flag &
SEQ_TIMELINE_SHOW_STRIP_COLOR_TAG);
/* Draw strip body. */
x1 = (seq->startstill) ? seq->start : seq->startdisp;
y1 = seq->machine + SEQ_STRIP_OFSBOTTOM;
@ -1852,7 +1883,7 @@ static void draw_seq_strip(const bContext *C,
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
draw_seq_background(scene, seq, pos, x1, x2, y1, y2, is_single_image);
draw_seq_background(scene, seq, pos, x1, x2, y1, y2, is_single_image, show_strip_color_tag);
/* Draw a color band inside color strip. */
if (seq->type == SEQ_TYPE_COLOR && y_threshold) {
@ -1864,7 +1895,7 @@ static void draw_seq_strip(const bContext *C,
if (!is_single_image && (seq->startofs || seq->endofs) && pixely > 0) {
if ((sseq->timeline_overlay.flag & SEQ_TIMELINE_SHOW_STRIP_OFFSETS) ||
(seq == special_seq_update)) {
draw_sequence_extensions_overlay(scene, seq, pos, pixely);
draw_sequence_extensions_overlay(scene, seq, pos, pixely, show_strip_color_tag);
}
}
}
@ -1875,7 +1906,7 @@ static void draw_seq_strip(const bContext *C,
if ((seq->type == SEQ_TYPE_META) ||
((seq->type == SEQ_TYPE_SCENE) && (seq->flag & SEQ_SCENE_STRIPS))) {
drawmeta_contents(scene, seq, x1, y1, x2, y2);
drawmeta_contents(scene, seq, x1, y1, x2, y2, show_strip_color_tag);
}
if ((sseq->flag & SEQ_SHOW_OVERLAY) &&

View File

@ -63,6 +63,7 @@
#include "WM_types.h"
#include "RNA_define.h"
#include "RNA_enum_types.h"
/* For menu, popup, icons, etc. */
#include "ED_numinput.h"
@ -3322,4 +3323,38 @@ void SEQUENCER_OT_strip_transform_fit(struct wmOperatorType *ot)
"Scale fit fit_method");
}
static int sequencer_strip_color_tag_set_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
const Editing *ed = SEQ_editing_get(scene);
const short color_tag = RNA_enum_get(op->ptr, "color");
LISTBASE_FOREACH (Sequence *, seq, &ed->seqbase) {
if (seq->flag & SELECT) {
seq->color_tag = color_tag;
}
}
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
void SEQUENCER_OT_strip_color_tag_set(struct wmOperatorType *ot)
{
/* Identifiers. */
ot->name = "Set Color Tag";
ot->idname = "SEQUENCER_OT_strip_color_tag_set";
ot->description = "Set a color tag for the selected strips";
/* Api callbacks. */
ot->exec = sequencer_strip_color_tag_set_exec;
ot->poll = sequencer_edit_poll;
/* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_enum(
ot->srna, "color", rna_enum_strip_color_items, SEQUENCE_COLOR_NONE, "Color Tag", "");
}
/** \} */

View File

@ -51,7 +51,10 @@ void sequencer_draw_preview(const struct bContext *C,
int offset,
bool draw_overlay,
bool draw_backdrop);
void color3ubv_from_seq(struct Scene *curscene, struct Sequence *seq, unsigned char col[3]);
void color3ubv_from_seq(const struct Scene *curscene,
const struct Sequence *seq,
const bool show_strip_color_tag,
uchar r_col[3]);
void sequencer_special_update_set(Sequence *seq);
float sequence_handle_size_get_clamped(struct Sequence *seq, const float pixelx);
@ -148,6 +151,8 @@ void SEQUENCER_OT_set_range_to_strips(struct wmOperatorType *ot);
void SEQUENCER_OT_strip_transform_clear(struct wmOperatorType *ot);
void SEQUENCER_OT_strip_transform_fit(struct wmOperatorType *ot);
void SEQUENCER_OT_strip_color_tag_set(struct wmOperatorType *ot);
/* sequencer_select.c */
void SEQUENCER_OT_select_all(struct wmOperatorType *ot);
void SEQUENCER_OT_select(struct wmOperatorType *ot);

View File

@ -79,6 +79,8 @@ void sequencer_operatortypes(void)
WM_operatortype_append(SEQUENCER_OT_strip_transform_clear);
WM_operatortype_append(SEQUENCER_OT_strip_transform_fit);
WM_operatortype_append(SEQUENCER_OT_strip_color_tag_set);
/* sequencer_select.c */
WM_operatortype_append(SEQUENCER_OT_select_all);
WM_operatortype_append(SEQUENCER_OT_select);

View File

@ -104,7 +104,7 @@ static SpaceLink *sequencer_create(const ScrArea *UNUSED(area), const Scene *sce
sseq->preview_overlay.flag = SEQ_PREVIEW_SHOW_GPENCIL | SEQ_PREVIEW_SHOW_OUTLINE_SELECTED;
sseq->timeline_overlay.flag = SEQ_TIMELINE_SHOW_STRIP_NAME | SEQ_TIMELINE_SHOW_STRIP_SOURCE |
SEQ_TIMELINE_SHOW_STRIP_DURATION | SEQ_TIMELINE_SHOW_GRID |
SEQ_TIMELINE_SHOW_FCURVES;
SEQ_TIMELINE_SHOW_FCURVES | SEQ_TIMELINE_SHOW_STRIP_COLOR_TAG;
BLI_rctf_init(&sseq->runtime.last_thumbnail_area, 0.0f, 0.0f, 0.0f, 0.0f);
sseq->runtime.last_displayed_thumbnails = NULL;

View File

@ -232,6 +232,10 @@ typedef struct Sequence {
int blend_mode;
float blend_opacity;
/* Tag color showed if `SEQ_TIMELINE_SHOW_STRIP_COLOR_TAG` is set. */
int16_t color_tag;
char _pad4[6];
/* is sfra needed anymore? - it looks like its only used in one place */
/** Starting frame according to the timeline of the scene. */
int sfra;
@ -727,6 +731,22 @@ enum {
SEQ_CACHE_STORE_THUMBNAIL = (1 << 12),
};
/* Sequence->color_tag. */
typedef enum SequenceColorTag {
SEQUENCE_COLOR_NONE = -1,
SEQUENCE_COLOR_01,
SEQUENCE_COLOR_02,
SEQUENCE_COLOR_03,
SEQUENCE_COLOR_04,
SEQUENCE_COLOR_05,
SEQUENCE_COLOR_06,
SEQUENCE_COLOR_07,
SEQUENCE_COLOR_08,
SEQUENCE_COLOR_09,
SEQUENCE_COLOR_TOT,
} SequenceColorTag;
#ifdef __cplusplus
}
#endif

View File

@ -599,6 +599,7 @@ typedef struct SequencerTimelineOverlay {
typedef enum eSpaceSeq_SequencerTimelineOverlay_Flag {
SEQ_TIMELINE_SHOW_STRIP_OFFSETS = (1 << 1),
SEQ_TIMELINE_SHOW_THUMBNAILS = (1 << 2),
SEQ_TIMELINE_SHOW_STRIP_COLOR_TAG = (1 << 3), /* use Sequence->color_tag */
SEQ_TIMELINE_SHOW_FCURVES = (1 << 5),
SEQ_TIMELINE_ALL_WAVEFORMS = (1 << 7), /* draw all waveforms */
SEQ_TIMELINE_NO_WAVEFORMS = (1 << 8), /* draw no waveforms */

View File

@ -458,6 +458,10 @@ typedef struct ThemeCollectionColor {
unsigned char color[4];
} ThemeCollectionColor;
typedef struct ThemeStripColor {
unsigned char color[4];
} ThemeStripColor;
/**
* A theme.
*
@ -500,8 +504,10 @@ typedef struct bTheme {
/* See COLLECTION_COLOR_TOT for the number of collection colors. */
ThemeCollectionColor collection_color[8];
/* See SEQUENCE_COLOR_TOT for the total number of strip colors. */
ThemeStripColor strip_color[9];
int active_theme_area;
char _pad0[4];
} bTheme;
#define UI_THEMESPACE_START(btheme) \

View File

@ -211,6 +211,7 @@ DEF_ENUM(rna_enum_attribute_domain_items)
DEF_ENUM(rna_enum_attribute_domain_with_auto_items)
DEF_ENUM(rna_enum_collection_color_items)
DEF_ENUM(rna_enum_strip_color_items)
DEF_ENUM(rna_enum_subdivision_uv_smooth_items)
DEF_ENUM(rna_enum_subdivision_boundary_smooth_items)

View File

@ -81,6 +81,20 @@ const EnumPropertyItem rna_enum_sequence_modifier_type_items[] = {
{0, NULL, 0, NULL, NULL},
};
const EnumPropertyItem rna_enum_strip_color_items[] = {
{SEQUENCE_COLOR_NONE, "NONE", ICON_X, "None", "Assign no color tag to the collection"},
{SEQUENCE_COLOR_01, "COLOR_01", ICON_SEQUENCE_COLOR_01, "Color 01", ""},
{SEQUENCE_COLOR_02, "COLOR_02", ICON_SEQUENCE_COLOR_02, "Color 02", ""},
{SEQUENCE_COLOR_03, "COLOR_03", ICON_SEQUENCE_COLOR_03, "Color 03", ""},
{SEQUENCE_COLOR_04, "COLOR_04", ICON_SEQUENCE_COLOR_04, "Color 04", ""},
{SEQUENCE_COLOR_05, "COLOR_05", ICON_SEQUENCE_COLOR_05, "Color 05", ""},
{SEQUENCE_COLOR_06, "COLOR_06", ICON_SEQUENCE_COLOR_06, "Color 06", ""},
{SEQUENCE_COLOR_07, "COLOR_07", ICON_SEQUENCE_COLOR_07, "Color 07", ""},
{SEQUENCE_COLOR_08, "COLOR_08", ICON_SEQUENCE_COLOR_08, "Color 08", ""},
{SEQUENCE_COLOR_09, "COLOR_09", ICON_SEQUENCE_COLOR_09, "Color 09", ""},
{0, NULL, 0, NULL, NULL},
};
#ifdef RNA_RUNTIME
# include "BKE_global.h"
@ -1000,6 +1014,18 @@ static void rna_Sequence_opacity_set(PointerRNA *ptr, float value)
seq->blend_opacity = value * 100.0f;
}
static int rna_Sequence_color_tag_get(PointerRNA *ptr)
{
Sequence *seq = (Sequence *)(ptr->data);
return seq->color_tag;
}
static void rna_Sequence_color_tag_set(PointerRNA *ptr, int value)
{
Sequence *seq = (Sequence *)(ptr->data);
seq->color_tag = value;
}
static bool colbalance_seq_cmp_fn(Sequence *seq, void *arg_pt)
{
SequenceSearchData *data = arg_pt;
@ -1938,6 +1964,14 @@ static void rna_def_sequence(BlenderRNA *brna)
RNA_def_property_update(
prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_preprocessed_update");
prop = RNA_def_property(srna, "color_tag", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "color_tag");
RNA_def_property_enum_funcs(
prop, "rna_Sequence_color_tag_get", "rna_Sequence_color_tag_set", NULL);
RNA_def_property_enum_items(prop, rna_enum_strip_color_items);
RNA_def_property_ui_text(prop, "Strip Color", "Color tag for a strip");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
/* modifiers */
prop = RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "SequenceModifier");

View File

@ -5500,6 +5500,12 @@ static void rna_def_space_sequencer_timeline_overlay(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_TIMELINE_SHOW_THUMBNAILS);
RNA_def_property_ui_text(prop, "Show Thumbnails", "Show strip thumbnails");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL);
prop = RNA_def_property(srna, "show_strip_tag_color", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_TIMELINE_SHOW_STRIP_COLOR_TAG);
RNA_def_property_ui_text(
prop, "Show Color Tags", "Display the strip color tags in the sequencer");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL);
}
static void rna_def_space_sequencer(BlenderRNA *brna)

View File

@ -3680,6 +3680,23 @@ static void rna_def_userdef_theme_collection_color(BlenderRNA *brna)
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
}
static void rna_def_userdef_theme_strip_color(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
srna = RNA_def_struct(brna, "ThemeStripColor", NULL);
RNA_def_struct_sdna(srna, "ThemeStripColor");
RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
RNA_def_struct_ui_text(srna, "Theme Strip Color", "Theme settings for strip colors");
prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "color");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Color", "Strip Color");
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
}
static void rna_def_userdef_theme_space_clip(BlenderRNA *brna)
{
StructRNA *srna;
@ -4029,6 +4046,12 @@ static void rna_def_userdef_themes(BlenderRNA *brna)
RNA_def_property_collection_sdna(prop, NULL, "collection_color", "");
RNA_def_property_struct_type(prop, "ThemeCollectionColor");
RNA_def_property_ui_text(prop, "Collection Color", "");
prop = RNA_def_property(srna, "strip_color", PROP_COLLECTION, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_collection_sdna(prop, NULL, "strip_color", "");
RNA_def_property_struct_type(prop, "ThemeStripColor");
RNA_def_property_ui_text(prop, "Strip Color", "");
}
static void rna_def_userdef_addon(BlenderRNA *brna)
@ -4272,6 +4295,7 @@ static void rna_def_userdef_dothemes(BlenderRNA *brna)
rna_def_userdef_theme_space_spreadsheet(brna);
rna_def_userdef_theme_colorset(brna);
rna_def_userdef_theme_collection_color(brna);
rna_def_userdef_theme_strip_color(brna);
rna_def_userdef_themes(brna);
}

View File

@ -144,6 +144,8 @@ Sequence *SEQ_sequence_alloc(ListBase *lb, int timeline_frame, int machine, int
seq->strip = seq_strip_alloc(type);
seq->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Sequence Stereo Format");
seq->color_tag = SEQUENCE_COLOR_NONE;
SEQ_relations_session_uuid_generate(seq);
return seq;