Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Melis <paulmelis>2020-11-06 17:42:52 +0300
committerRichard Antalik <richardantalik@gmail.com>2020-11-06 18:05:50 +0300
commit235c309e5f86e84fb08e1ff2c5c11eb0b775c388 (patch)
tree364a1ae8aa7f3feedaea7243985845f915c7a842 /source/blender/sequencer
parentf6524aaa8093bfc88c658107b8077cd09ac3e989 (diff)
Add background rectangle option to video sequencer Text strip
This adds a Box option to the Text strip's style properties, plus related Box Margin value: {F9208309} When enabled the text is placed on top of a solid-filled rectangle of a chosen color, as shown below: {F9208324} When the box option is disabled the text strip works the same as it does now. When the box option is enabled the meaning of the Shadow option changes to provide a drop-shadow on the rectangle (and not on the text itself). The latter made more sense to me. The box margin is specified as a fraction of the image width. The offset of the drop-down box shadow is fixed to a specific fraction of the image width as well. I tested this feature on a movie of a couple of minutes containing dozens of text strips (all with box background), edge cases like multi-line strings and text overlapping the image edges. Reviewed By: ISS Differential Revision: https://developer.blender.org/D9468
Diffstat (limited to 'source/blender/sequencer')
-rw-r--r--source/blender/sequencer/intern/effects.c49
1 files changed, 40 insertions, 9 deletions
diff --git a/source/blender/sequencer/intern/effects.c b/source/blender/sequencer/intern/effects.c
index 041ef1c411d..4c7b1566f68 100644
--- a/source/blender/sequencer/intern/effects.c
+++ b/source/blender/sequencer/intern/effects.c
@@ -3788,6 +3788,11 @@ static void init_text_effect(Sequence *seq)
copy_v4_fl(data->color, 1.0f);
data->shadow_color[3] = 1.0f;
+ data->box_color[0] = 0.5f;
+ data->box_color[1] = 0.5f;
+ data->box_color[2] = 0.5f;
+ data->box_color[3] = 1.0f;
+ data->box_margin = 0.01f;
BLI_strncpy(data->text, "Text", sizeof(data->text));
@@ -3929,18 +3934,18 @@ static ImBuf *do_text_effect(const SeqRenderData *context,
x = (data->loc[0] * width);
y = (data->loc[1] * height) + y_ofs;
+ /* vars for calculating wordwrap and optional box */
+ struct {
+ struct ResultBLF info;
+ rctf rect;
+ } wrap;
+
+ BLF_boundbox_ex(font, data->text, sizeof(data->text), &wrap.rect, &wrap.info);
+
if ((data->align == SEQ_TEXT_ALIGN_X_LEFT) && (data->align_y == SEQ_TEXT_ALIGN_Y_TOP)) {
y -= line_height;
}
else {
- /* vars for calculating wordwrap */
- struct {
- struct ResultBLF info;
- rctf rect;
- } wrap;
-
- BLF_boundbox_ex(font, data->text, sizeof(data->text), &wrap.rect, &wrap.info);
-
if (data->align == SEQ_TEXT_ALIGN_X_RIGHT) {
x -= BLI_rctf_size_x(&wrap.rect);
}
@@ -3959,8 +3964,34 @@ static ImBuf *do_text_effect(const SeqRenderData *context,
}
}
+ if (data->flag & SEQ_TEXT_BOX) {
+ if (out->rect) {
+ const int margin = data->box_margin * width;
+ const int minx = x + wrap.rect.xmin - margin;
+ const int maxx = x + wrap.rect.xmax + margin;
+ const int miny = y + wrap.rect.ymin - margin;
+ const int maxy = y + wrap.rect.ymax + margin;
+
+ if (data->flag & SEQ_TEXT_SHADOW) {
+ /* draw a shadow behind the box */
+ int shadow_offset = 0.005f * width;
+
+ if (shadow_offset == 0) {
+ shadow_offset = 1;
+ }
+
+ IMB_rectfill_area_replace(out,
+ data->shadow_color,
+ minx + shadow_offset,
+ miny - shadow_offset,
+ maxx + shadow_offset,
+ maxy - shadow_offset);
+ }
+ IMB_rectfill_area_replace(out, data->box_color, minx, miny, maxx, maxy);
+ }
+ }
/* BLF_SHADOW won't work with buffers, instead use cheap shadow trick */
- if (data->flag & SEQ_TEXT_SHADOW) {
+ else if (data->flag & SEQ_TEXT_SHADOW) {
int fontx, fonty;
fontx = BLF_width_max(font);
fonty = line_height;