Add font selection to VSE text strips
Allows users to select a font for text strips in the video sequence editor.
Related: 3610f1fc43 Sequencer: refactor clipboard copy to no longer increase user count.
Reviewed by: Brecht
Differential Revision: https://developer.blender.org/D3621
This commit is contained in:
@@ -758,6 +758,7 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel, Panel):
|
|||||||
elif strip.type == 'TEXT':
|
elif strip.type == 'TEXT':
|
||||||
col = layout.column()
|
col = layout.column()
|
||||||
col.prop(strip, "text")
|
col.prop(strip, "text")
|
||||||
|
col.template_ID(strip, "font", open="font.open", unlink="font.unlink")
|
||||||
col.prop(strip, "font_size")
|
col.prop(strip, "font_size")
|
||||||
|
|
||||||
row = col.row()
|
row = col.row()
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ void BLF_default_set(int fontid);
|
|||||||
|
|
||||||
void BLF_cache_clear(void);
|
void BLF_cache_clear(void);
|
||||||
|
|
||||||
|
/* Loads a font, or returns an already loaded font and increments its reference count. */
|
||||||
int BLF_load(const char *name) ATTR_NONNULL();
|
int BLF_load(const char *name) ATTR_NONNULL();
|
||||||
int BLF_load_mem(const char *name, const unsigned char *mem, int mem_size) ATTR_NONNULL();
|
int BLF_load_mem(const char *name, const unsigned char *mem, int mem_size) ATTR_NONNULL();
|
||||||
|
|
||||||
|
|||||||
@@ -184,7 +184,8 @@ int BLF_load(const char *name)
|
|||||||
/* check if we already load this font. */
|
/* check if we already load this font. */
|
||||||
i = blf_search(name);
|
i = blf_search(name);
|
||||||
if (i >= 0) {
|
if (i >= 0) {
|
||||||
/*font = global_font[i];*/ /*UNUSED*/
|
font = global_font[i];
|
||||||
|
font->reference_count++;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,6 +209,7 @@ int BLF_load(const char *name)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
font->reference_count = 1;
|
||||||
global_font[i] = font;
|
global_font[i] = font;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@@ -241,6 +243,7 @@ int BLF_load_unique(const char *name)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
font->reference_count = 1;
|
||||||
global_font[i] = font;
|
global_font[i] = font;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@@ -282,6 +285,7 @@ int BLF_load_mem(const char *name, const unsigned char *mem, int mem_size)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
font->reference_count = 1;
|
||||||
global_font[i] = font;
|
global_font[i] = font;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@@ -312,6 +316,7 @@ int BLF_load_mem_unique(const char *name, const unsigned char *mem, int mem_size
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
font->reference_count = 1;
|
||||||
global_font[i] = font;
|
global_font[i] = font;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@@ -325,19 +330,29 @@ void BLF_unload(const char *name)
|
|||||||
font = global_font[i];
|
font = global_font[i];
|
||||||
|
|
||||||
if (font && (STREQ(font->name, name))) {
|
if (font && (STREQ(font->name, name))) {
|
||||||
|
BLI_assert(font->reference_count > 0);
|
||||||
|
font->reference_count--;
|
||||||
|
|
||||||
|
if (font->reference_count == 0) {
|
||||||
blf_font_free(font);
|
blf_font_free(font);
|
||||||
global_font[i] = NULL;
|
global_font[i] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BLF_unload_id(int fontid)
|
void BLF_unload_id(int fontid)
|
||||||
{
|
{
|
||||||
FontBLF *font = blf_get(fontid);
|
FontBLF *font = blf_get(fontid);
|
||||||
if (font) {
|
if (font) {
|
||||||
|
BLI_assert(font->reference_count > 0);
|
||||||
|
font->reference_count--;
|
||||||
|
|
||||||
|
if (font->reference_count == 0) {
|
||||||
blf_font_free(font);
|
blf_font_free(font);
|
||||||
global_font[fontid] = NULL;
|
global_font[fontid] = NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BLF_enable(int fontid, int option)
|
void BLF_enable(int fontid, int option)
|
||||||
|
|||||||
@@ -163,6 +163,9 @@ typedef struct FontBLF {
|
|||||||
/* font name. */
|
/* font name. */
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
|
/* # of times this font was loaded */
|
||||||
|
unsigned int reference_count;
|
||||||
|
|
||||||
/* filename or NULL. */
|
/* filename or NULL. */
|
||||||
char *filename;
|
char *filename;
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ struct Sequence;
|
|||||||
struct SequenceModifierData;
|
struct SequenceModifierData;
|
||||||
struct Stereo3dFormat;
|
struct Stereo3dFormat;
|
||||||
struct StripElem;
|
struct StripElem;
|
||||||
|
struct TextVars;
|
||||||
struct bSound;
|
struct bSound;
|
||||||
|
|
||||||
struct SeqIndexBuildContext;
|
struct SeqIndexBuildContext;
|
||||||
@@ -142,7 +143,7 @@ struct SeqEffectHandle {
|
|||||||
|
|
||||||
/* load is called first time after readblenfile in
|
/* load is called first time after readblenfile in
|
||||||
* get_sequence_effect automatically */
|
* get_sequence_effect automatically */
|
||||||
void (*load)(struct Sequence *seq);
|
void (*load)(struct Sequence *seqconst);
|
||||||
|
|
||||||
/* duplicate */
|
/* duplicate */
|
||||||
void (*copy)(struct Sequence *dst, struct Sequence *src, const int flag);
|
void (*copy)(struct Sequence *dst, struct Sequence *src, const int flag);
|
||||||
@@ -298,6 +299,9 @@ void BKE_sequence_effect_speed_rebuild_map(struct Scene *scene, struct Sequence
|
|||||||
struct SeqEffectHandle BKE_sequence_get_effect(struct Sequence *seq);
|
struct SeqEffectHandle BKE_sequence_get_effect(struct Sequence *seq);
|
||||||
int BKE_sequence_effect_get_num_inputs(int seq_type);
|
int BKE_sequence_effect_get_num_inputs(int seq_type);
|
||||||
int BKE_sequence_effect_get_supports_mask(int seq_type);
|
int BKE_sequence_effect_get_supports_mask(int seq_type);
|
||||||
|
void BKE_sequencer_text_font_unload(struct TextVars *data, const bool do_id_user);
|
||||||
|
void BKE_sequencer_text_font_load(struct TextVars *data, const bool do_id_user);
|
||||||
|
|
||||||
|
|
||||||
/* **********************************************************************
|
/* **********************************************************************
|
||||||
* Sequencer editing functions
|
* Sequencer editing functions
|
||||||
|
|||||||
@@ -455,6 +455,11 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call
|
|||||||
for (SequenceModifierData *smd = seq->modifiers.first; smd; smd = smd->next) {
|
for (SequenceModifierData *smd = seq->modifiers.first; smd; smd = smd->next) {
|
||||||
CALLBACK_INVOKE(smd->mask_id, IDWALK_CB_USER);
|
CALLBACK_INVOKE(smd->mask_id, IDWALK_CB_USER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (seq->type == SEQ_TYPE_TEXT && seq->effectdata) {
|
||||||
|
TextVars *text_data = seq->effectdata;
|
||||||
|
CALLBACK_INVOKE(text_data->text_font, IDWALK_CB_USER);
|
||||||
|
}
|
||||||
} SEQ_END;
|
} SEQ_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,8 +37,10 @@
|
|||||||
#include "MEM_guardedalloc.h"
|
#include "MEM_guardedalloc.h"
|
||||||
|
|
||||||
#include "BLI_math.h" /* windows needs for M_PI */
|
#include "BLI_math.h" /* windows needs for M_PI */
|
||||||
|
#include "BLI_threads.h"
|
||||||
#include "BLI_utildefines.h"
|
#include "BLI_utildefines.h"
|
||||||
#include "BLI_rect.h"
|
#include "BLI_rect.h"
|
||||||
|
#include "BLI_path_util.h"
|
||||||
#include "BLI_string.h"
|
#include "BLI_string.h"
|
||||||
|
|
||||||
#include "DNA_scene_types.h"
|
#include "DNA_scene_types.h"
|
||||||
@@ -47,6 +49,8 @@
|
|||||||
#include "DNA_space_types.h"
|
#include "DNA_space_types.h"
|
||||||
|
|
||||||
#include "BKE_fcurve.h"
|
#include "BKE_fcurve.h"
|
||||||
|
#include "BKE_library.h"
|
||||||
|
#include "BKE_main.h"
|
||||||
#include "BKE_sequencer.h"
|
#include "BKE_sequencer.h"
|
||||||
|
|
||||||
#include "IMB_imbuf_types.h"
|
#include "IMB_imbuf_types.h"
|
||||||
@@ -3427,6 +3431,7 @@ static ImBuf *do_gaussian_blur_effect(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*********************** text *************************/
|
/*********************** text *************************/
|
||||||
|
|
||||||
static void init_text_effect(Sequence *seq)
|
static void init_text_effect(Sequence *seq)
|
||||||
{
|
{
|
||||||
TextVars *data;
|
TextVars *data;
|
||||||
@@ -3435,6 +3440,8 @@ static void init_text_effect(Sequence *seq)
|
|||||||
MEM_freeN(seq->effectdata);
|
MEM_freeN(seq->effectdata);
|
||||||
|
|
||||||
data = seq->effectdata = MEM_callocN(sizeof(TextVars), "textvars");
|
data = seq->effectdata = MEM_callocN(sizeof(TextVars), "textvars");
|
||||||
|
data->text_font = NULL;
|
||||||
|
data->text_blf_id = -1;
|
||||||
data->text_size = 30;
|
data->text_size = 30;
|
||||||
|
|
||||||
copy_v4_fl(data->color, 1.0f);
|
copy_v4_fl(data->color, 1.0f);
|
||||||
@@ -3447,6 +3454,64 @@ static void init_text_effect(Sequence *seq)
|
|||||||
data->align_y = SEQ_TEXT_ALIGN_Y_BOTTOM;
|
data->align_y = SEQ_TEXT_ALIGN_Y_BOTTOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BKE_sequencer_text_font_unload(TextVars *data, const bool do_id_user)
|
||||||
|
{
|
||||||
|
if (data) {
|
||||||
|
/* Unlink the VFont */
|
||||||
|
if (do_id_user && data->text_font != NULL) {
|
||||||
|
id_us_min(&data->text_font->id);
|
||||||
|
data->text_font = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Unload the BLF font. */
|
||||||
|
if (data->text_blf_id >= 0) {
|
||||||
|
BLF_unload_id(data->text_blf_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BKE_sequencer_text_font_load(TextVars *data, const bool do_id_user)
|
||||||
|
{
|
||||||
|
if (data->text_font != NULL) {
|
||||||
|
if (do_id_user) {
|
||||||
|
id_us_plus(&data->text_font->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
char path[FILE_MAX];
|
||||||
|
STRNCPY(path, data->text_font->name);
|
||||||
|
BLI_assert(BLI_thread_is_main());
|
||||||
|
BLI_path_abs(path, BKE_main_blendfile_path_from_global());
|
||||||
|
|
||||||
|
data->text_blf_id = BLF_load(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void free_text_effect(Sequence *seq, const bool do_id_user)
|
||||||
|
{
|
||||||
|
TextVars *data = seq->effectdata;
|
||||||
|
BKE_sequencer_text_font_unload(data, do_id_user);
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
MEM_freeN(data);
|
||||||
|
seq->effectdata = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void load_text_effect(Sequence *seq)
|
||||||
|
{
|
||||||
|
TextVars *data = seq->effectdata;
|
||||||
|
BKE_sequencer_text_font_load(data, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void copy_text_effect(Sequence *dst, Sequence *src, const int flag)
|
||||||
|
{
|
||||||
|
dst->effectdata = MEM_dupallocN(src->effectdata);
|
||||||
|
TextVars *data = dst->effectdata;
|
||||||
|
|
||||||
|
data->text_blf_id = -1;
|
||||||
|
BKE_sequencer_text_font_load(data, (flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
static int num_inputs_text(void)
|
static int num_inputs_text(void)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
@@ -3473,11 +3538,23 @@ static ImBuf *do_text_effect(
|
|||||||
int height = out->y;
|
int height = out->y;
|
||||||
struct ColorManagedDisplay *display;
|
struct ColorManagedDisplay *display;
|
||||||
const char *display_device;
|
const char *display_device;
|
||||||
const int mono = blf_mono_font_render; // XXX
|
int font = blf_mono_font_render;
|
||||||
int line_height;
|
int line_height;
|
||||||
int y_ofs, x, y;
|
int y_ofs, x, y;
|
||||||
float proxy_size_comp;
|
float proxy_size_comp;
|
||||||
|
|
||||||
|
if (data->text_blf_id == SEQ_FONT_NOT_LOADED) {
|
||||||
|
data->text_blf_id = -1;
|
||||||
|
|
||||||
|
if (data->text_font) {
|
||||||
|
data->text_blf_id = BLF_load(data->text_font->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data->text_blf_id >= 0) {
|
||||||
|
font = data->text_blf_id;
|
||||||
|
}
|
||||||
|
|
||||||
display_device = context->scene->display_settings.display_device;
|
display_device = context->scene->display_settings.display_device;
|
||||||
display = IMB_colormanagement_display_get_named(display_device);
|
display = IMB_colormanagement_display_get_named(display_device);
|
||||||
|
|
||||||
@@ -3493,18 +3570,18 @@ static ImBuf *do_text_effect(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* set before return */
|
/* set before return */
|
||||||
BLF_size(mono, proxy_size_comp * data->text_size, 72);
|
BLF_size(font, proxy_size_comp * data->text_size, 72);
|
||||||
|
|
||||||
BLF_enable(mono, BLF_WORD_WRAP);
|
BLF_enable(font, BLF_WORD_WRAP);
|
||||||
|
|
||||||
/* use max width to enable newlines only */
|
/* use max width to enable newlines only */
|
||||||
BLF_wordwrap(mono, (data->wrap_width != 0.0f) ? data->wrap_width * width : -1);
|
BLF_wordwrap(font, (data->wrap_width != 0.0f) ? data->wrap_width * width : -1);
|
||||||
|
|
||||||
BLF_buffer(mono, out->rect_float, (unsigned char *)out->rect, width, height, out->channels, display);
|
BLF_buffer(font, out->rect_float, (unsigned char *)out->rect, width, height, out->channels, display);
|
||||||
|
|
||||||
line_height = BLF_height_max(mono);
|
line_height = BLF_height_max(font);
|
||||||
|
|
||||||
y_ofs = -BLF_descender(mono);
|
y_ofs = -BLF_descender(font);
|
||||||
|
|
||||||
x = (data->loc[0] * width);
|
x = (data->loc[0] * width);
|
||||||
y = (data->loc[1] * height) + y_ofs;
|
y = (data->loc[1] * height) + y_ofs;
|
||||||
@@ -3521,7 +3598,7 @@ static ImBuf *do_text_effect(
|
|||||||
rctf rect;
|
rctf rect;
|
||||||
} wrap;
|
} wrap;
|
||||||
|
|
||||||
BLF_boundbox_ex(mono, data->text, sizeof(data->text), &wrap.rect, &wrap.info);
|
BLF_boundbox_ex(font, data->text, sizeof(data->text), &wrap.rect, &wrap.info);
|
||||||
|
|
||||||
if (data->align == SEQ_TEXT_ALIGN_X_RIGHT) {
|
if (data->align == SEQ_TEXT_ALIGN_X_RIGHT) {
|
||||||
x -= BLI_rctf_size_x(&wrap.rect);
|
x -= BLI_rctf_size_x(&wrap.rect);
|
||||||
@@ -3544,19 +3621,20 @@ static ImBuf *do_text_effect(
|
|||||||
/* BLF_SHADOW won't work with buffers, instead use cheap shadow trick */
|
/* BLF_SHADOW won't work with buffers, instead use cheap shadow trick */
|
||||||
if (data->flag & SEQ_TEXT_SHADOW) {
|
if (data->flag & SEQ_TEXT_SHADOW) {
|
||||||
int fontx, fonty;
|
int fontx, fonty;
|
||||||
fontx = BLF_width_max(mono);
|
fontx = BLF_width_max(font);
|
||||||
fonty = line_height;
|
fonty = line_height;
|
||||||
BLF_position(mono, x + max_ii(fontx / 25, 1), y + max_ii(fonty / 25, 1), 0.0f);
|
BLF_position(font, x + max_ii(fontx / 25, 1), y + max_ii(fonty / 25, 1), 0.0f);
|
||||||
BLF_buffer_col(mono, data->shadow_color);
|
BLF_buffer_col(font, data->shadow_color);
|
||||||
BLF_draw_buffer(mono, data->text, BLF_DRAW_STR_DUMMY_MAX);
|
BLF_draw_buffer(font, data->text, BLF_DRAW_STR_DUMMY_MAX);
|
||||||
}
|
}
|
||||||
BLF_position(mono, x, y, 0.0f);
|
|
||||||
BLF_buffer_col(mono, data->color);
|
|
||||||
BLF_draw_buffer(mono, data->text, BLF_DRAW_STR_DUMMY_MAX);
|
|
||||||
|
|
||||||
BLF_buffer(mono, NULL, NULL, 0, 0, 0, NULL);
|
BLF_position(font, x, y, 0.0f);
|
||||||
|
BLF_buffer_col(font, data->color);
|
||||||
|
BLF_draw_buffer(font, data->text, BLF_DRAW_STR_DUMMY_MAX);
|
||||||
|
|
||||||
BLF_disable(mono, BLF_WORD_WRAP);
|
BLF_buffer(font, NULL, NULL, 0, 0, 0, NULL);
|
||||||
|
|
||||||
|
BLF_disable(font, BLF_WORD_WRAP);
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
@@ -3803,8 +3881,9 @@ static struct SeqEffectHandle get_sequence_effect_impl(int seq_type)
|
|||||||
case SEQ_TYPE_TEXT:
|
case SEQ_TYPE_TEXT:
|
||||||
rval.num_inputs = num_inputs_text;
|
rval.num_inputs = num_inputs_text;
|
||||||
rval.init = init_text_effect;
|
rval.init = init_text_effect;
|
||||||
rval.free = free_effect_default;
|
rval.free = free_text_effect;
|
||||||
rval.copy = copy_effect_default;
|
rval.load = load_text_effect;
|
||||||
|
rval.copy = copy_text_effect;
|
||||||
rval.early_out = early_out_text;
|
rval.early_out = early_out_text;
|
||||||
rval.execute = do_text_effect;
|
rval.execute = do_text_effect;
|
||||||
break;
|
break;
|
||||||
@@ -3833,8 +3912,15 @@ struct SeqEffectHandle BKE_sequence_get_blend(Sequence *seq)
|
|||||||
struct SeqEffectHandle rval = {false, false, NULL};
|
struct SeqEffectHandle rval = {false, false, NULL};
|
||||||
|
|
||||||
if (seq->blend_mode != 0) {
|
if (seq->blend_mode != 0) {
|
||||||
|
if ((seq->flag & SEQ_EFFECT_NOT_LOADED) != 0) {
|
||||||
|
/* load the effect first */
|
||||||
|
rval = get_sequence_effect_impl(seq->type);
|
||||||
|
rval.load(seq);
|
||||||
|
}
|
||||||
|
|
||||||
rval = get_sequence_effect_impl(seq->blend_mode);
|
rval = get_sequence_effect_impl(seq->blend_mode);
|
||||||
if ((seq->flag & SEQ_EFFECT_NOT_LOADED) != 0) {
|
if ((seq->flag & SEQ_EFFECT_NOT_LOADED) != 0) {
|
||||||
|
/* now load the blend and unset unloaded flag */
|
||||||
rval.load(seq);
|
rval.load(seq);
|
||||||
seq->flag &= ~SEQ_EFFECT_NOT_LOADED;
|
seq->flag &= ~SEQ_EFFECT_NOT_LOADED;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -396,7 +396,13 @@ static void sequence_clipboard_pointers(Main *bmain, Sequence *seq, void (*callb
|
|||||||
callback(bmain, (ID **)&seq->clip);
|
callback(bmain, (ID **)&seq->clip);
|
||||||
callback(bmain, (ID **)&seq->mask);
|
callback(bmain, (ID **)&seq->mask);
|
||||||
callback(bmain, (ID **)&seq->sound);
|
callback(bmain, (ID **)&seq->sound);
|
||||||
|
|
||||||
|
if (seq->type == SEQ_TYPE_TEXT && seq->effectdata) {
|
||||||
|
TextVars *text_data = seq->effectdata;
|
||||||
|
callback(bmain, (ID **)&text_data->text_font);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* recursive versions of functions above */
|
/* recursive versions of functions above */
|
||||||
void BKE_sequencer_base_clipboard_pointers_free(ListBase *seqbase)
|
void BKE_sequencer_base_clipboard_pointers_free(ListBase *seqbase)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5864,6 +5864,10 @@ static void lib_link_scene(FileData *fd, Main *main)
|
|||||||
seq->scene_sound = BKE_sound_add_scene_sound_defaults(sce, seq);
|
seq->scene_sound = BKE_sound_add_scene_sound_defaults(sce, seq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (seq->type == SEQ_TYPE_TEXT) {
|
||||||
|
TextVars *t = seq->effectdata;
|
||||||
|
t->text_font = newlibadr_us(fd, sce->id.lib, t->text_font);
|
||||||
|
}
|
||||||
BLI_listbase_clear(&seq->anims);
|
BLI_listbase_clear(&seq->anims);
|
||||||
|
|
||||||
lib_link_sequence_modifiers(fd, sce, &seq->modifiers);
|
lib_link_sequence_modifiers(fd, sce, &seq->modifiers);
|
||||||
@@ -6116,6 +6120,11 @@ static void direct_link_scene(FileData *fd, Scene *sce)
|
|||||||
s->frameMap = NULL;
|
s->frameMap = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (seq->type == SEQ_TYPE_TEXT) {
|
||||||
|
TextVars *t = seq->effectdata;
|
||||||
|
t->text_blf_id = SEQ_FONT_NOT_LOADED;
|
||||||
|
}
|
||||||
|
|
||||||
seq->prop = newdataadr(fd, seq->prop);
|
seq->prop = newdataadr(fd, seq->prop);
|
||||||
IDP_DirectLinkGroup_OrFree(&seq->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
|
IDP_DirectLinkGroup_OrFree(&seq->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
|
||||||
|
|
||||||
@@ -9742,6 +9751,11 @@ static void expand_scene(FileData *fd, Main *mainvar, Scene *sce)
|
|||||||
if (seq->clip) expand_doit(fd, mainvar, seq->clip);
|
if (seq->clip) expand_doit(fd, mainvar, seq->clip);
|
||||||
if (seq->mask) expand_doit(fd, mainvar, seq->mask);
|
if (seq->mask) expand_doit(fd, mainvar, seq->mask);
|
||||||
if (seq->sound) expand_doit(fd, mainvar, seq->sound);
|
if (seq->sound) expand_doit(fd, mainvar, seq->sound);
|
||||||
|
|
||||||
|
if (seq->type == SEQ_TYPE_TEXT && seq->effectdata) {
|
||||||
|
TextVars *data = seq->effectdata;
|
||||||
|
expand_doit(fd, mainvar, data->text_font);
|
||||||
|
}
|
||||||
} SEQ_END;
|
} SEQ_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -678,7 +678,7 @@ static void template_ID(
|
|||||||
but = NULL;
|
but = NULL;
|
||||||
|
|
||||||
if (unlinkop) {
|
if (unlinkop) {
|
||||||
but = uiDefIconButO(block, UI_BTYPE_BUT, unlinkop, WM_OP_INVOKE_REGION_WIN, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL);
|
but = uiDefIconButO(block, UI_BTYPE_BUT, unlinkop, WM_OP_INVOKE_DEFAULT, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL);
|
||||||
/* so we can access the template from operators, font unlinking needs this */
|
/* so we can access the template from operators, font unlinking needs this */
|
||||||
UI_but_funcN_set(but, NULL, MEM_dupallocN(template_ui), NULL);
|
UI_but_funcN_set(but, NULL, MEM_dupallocN(template_ui), NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
#include "DNA_color_types.h"
|
#include "DNA_color_types.h"
|
||||||
#include "DNA_listBase.h"
|
#include "DNA_listBase.h"
|
||||||
#include "DNA_vec_types.h"
|
#include "DNA_vec_types.h"
|
||||||
|
#include "DNA_vfont_types.h"
|
||||||
|
|
||||||
struct Ipo;
|
struct Ipo;
|
||||||
struct Scene;
|
struct Scene;
|
||||||
@@ -274,13 +275,15 @@ typedef struct GaussianBlurVars {
|
|||||||
|
|
||||||
typedef struct TextVars {
|
typedef struct TextVars {
|
||||||
char text[512];
|
char text[512];
|
||||||
|
VFont *text_font;
|
||||||
|
int text_blf_id;
|
||||||
int text_size;
|
int text_size;
|
||||||
float color[4], shadow_color[4];
|
float color[4], shadow_color[4];
|
||||||
float loc[2];
|
float loc[2];
|
||||||
float wrap_width;
|
float wrap_width;
|
||||||
char flag;
|
char flag;
|
||||||
char align, align_y;
|
char align, align_y;
|
||||||
char pad[5];
|
char pad[1];
|
||||||
} TextVars;
|
} TextVars;
|
||||||
|
|
||||||
/* TextVars.flag */
|
/* TextVars.flag */
|
||||||
@@ -302,6 +305,8 @@ enum {
|
|||||||
SEQ_TEXT_ALIGN_Y_BOTTOM = 2,
|
SEQ_TEXT_ALIGN_Y_BOTTOM = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define SEQ_FONT_NOT_LOADED -2
|
||||||
|
|
||||||
typedef struct ColorMixVars {
|
typedef struct ColorMixVars {
|
||||||
int blend_effect; /* value from SEQ_TYPE_XXX enumeration */
|
int blend_effect; /* value from SEQ_TYPE_XXX enumeration */
|
||||||
float factor; /* blend factor [0.0f, 1.0f] */
|
float factor; /* blend factor [0.0f, 1.0f] */
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#include "DNA_scene_types.h"
|
#include "DNA_scene_types.h"
|
||||||
#include "DNA_sequence_types.h"
|
#include "DNA_sequence_types.h"
|
||||||
#include "DNA_movieclip_types.h"
|
#include "DNA_movieclip_types.h"
|
||||||
|
#include "DNA_vfont_types.h"
|
||||||
|
|
||||||
#include "BLI_math.h"
|
#include "BLI_math.h"
|
||||||
|
|
||||||
@@ -461,6 +462,19 @@ static void rna_SequenceCrop_update(Main *UNUSED(bmain), Scene *UNUSED(scene), P
|
|||||||
BKE_sequence_invalidate_cache(scene, seq);
|
BKE_sequence_invalidate_cache(scene, seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void rna_Sequence_text_font_set(PointerRNA *ptr, PointerRNA ptr_value)
|
||||||
|
{
|
||||||
|
Sequence *seq = ptr->data;
|
||||||
|
TextVars *data = seq->effectdata;
|
||||||
|
VFont *value = ptr_value.data;
|
||||||
|
|
||||||
|
BKE_sequencer_text_font_unload(data, true);
|
||||||
|
|
||||||
|
id_us_plus(&value->id);
|
||||||
|
data->text_blf_id = SEQ_FONT_NOT_LOADED;
|
||||||
|
data->text_font = value;
|
||||||
|
}
|
||||||
|
|
||||||
/* name functions that ignore the first two characters */
|
/* name functions that ignore the first two characters */
|
||||||
static void rna_Sequence_name_get(PointerRNA *ptr, char *value)
|
static void rna_Sequence_name_get(PointerRNA *ptr, char *value)
|
||||||
{
|
{
|
||||||
@@ -2399,6 +2413,14 @@ static void rna_def_text(StructRNA *srna)
|
|||||||
|
|
||||||
RNA_def_struct_sdna_from(srna, "TextVars", "effectdata");
|
RNA_def_struct_sdna_from(srna, "TextVars", "effectdata");
|
||||||
|
|
||||||
|
prop = RNA_def_property(srna, "font", PROP_POINTER, PROP_NONE);
|
||||||
|
RNA_def_property_pointer_sdna(prop, NULL, "text_font");
|
||||||
|
RNA_def_property_ui_icon(prop, ICON_FILE_FONT, false);
|
||||||
|
RNA_def_property_ui_text(prop, "Font", "Font of the text. Falls back to the UI font by default");
|
||||||
|
RNA_def_property_flag(prop, PROP_EDITABLE);
|
||||||
|
RNA_def_property_pointer_funcs(prop, NULL, "rna_Sequence_text_font_set", NULL, NULL);
|
||||||
|
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update");
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "font_size", PROP_INT, PROP_UNSIGNED);
|
prop = RNA_def_property(srna, "font_size", PROP_INT, PROP_UNSIGNED);
|
||||||
RNA_def_property_int_sdna(prop, NULL, "text_size");
|
RNA_def_property_int_sdna(prop, NULL, "text_size");
|
||||||
RNA_def_property_ui_text(prop, "Size", "Size of the text");
|
RNA_def_property_ui_text(prop, "Size", "Size of the text");
|
||||||
|
|||||||
Reference in New Issue
Block a user