From 1c095203c275f84e6b024e09203ca228d19b8070 Mon Sep 17 00:00:00 2001 From: Peter Fog Date: Sat, 20 Mar 2021 00:43:40 +0100 Subject: VSE: Text strip improvements - Position text in center of image - Increase default font size so it's more visible - Increase font size limit - Increase limit for location, so text can be scolled off screen - Wrap text by default - Tweak default box and shadow color - Change text shadow position - Text box no longer casts shadow Reviewed By: ISS Differential Revision: https://developer.blender.org/D10571 --- source/blender/makesrna/intern/rna_sequencer.c | 4 +-- source/blender/sequencer/intern/effects.c | 36 ++++++++------------------ 2 files changed, 13 insertions(+), 27 deletions(-) diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index 54ac7860108..24d051fecc8 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -2865,7 +2865,7 @@ static void rna_def_text(StructRNA *srna) RNA_def_property_int_sdna(prop, NULL, "text_size"); RNA_def_property_ui_text(prop, "Size", "Size of the text"); RNA_def_property_range(prop, 0.0, 2000); - RNA_def_property_ui_range(prop, 0.0f, 1000, 1, -1); + RNA_def_property_ui_range(prop, 0.0f, 2000, 1, -1); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update"); prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA); @@ -2887,7 +2887,7 @@ static void rna_def_text(StructRNA *srna) RNA_def_property_float_sdna(prop, NULL, "loc"); RNA_def_property_ui_text(prop, "Location", "Location of the text"); RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); - RNA_def_property_ui_range(prop, 0.0, 1.0, 1, -1); + RNA_def_property_ui_range(prop, -10.0, 10.0, 1, -1); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_raw_update"); prop = RNA_def_property(srna, "wrap_width", PROP_FLOAT, PROP_NONE); diff --git a/source/blender/sequencer/intern/effects.c b/source/blender/sequencer/intern/effects.c index 017c2ec8ec5..7b030d6408b 100644 --- a/source/blender/sequencer/intern/effects.c +++ b/source/blender/sequencer/intern/effects.c @@ -3806,21 +3806,23 @@ static void init_text_effect(Sequence *seq) data = seq->effectdata = MEM_callocN(sizeof(TextVars), "textvars"); data->text_font = NULL; data->text_blf_id = -1; - data->text_size = 30; + data->text_size = 60; 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->shadow_color[3] = 0.7f; + data->box_color[0] = 0.2f; + data->box_color[1] = 0.2f; + data->box_color[2] = 0.2f; + data->box_color[3] = 0.7f; data->box_margin = 0.01f; BLI_strncpy(data->text, "Text", sizeof(data->text)); data->loc[0] = 0.5f; + data->loc[1] = 0.5f; data->align = SEQ_TEXT_ALIGN_X_CENTER; - data->align_y = SEQ_TEXT_ALIGN_Y_BOTTOM; + data->align_y = SEQ_TEXT_ALIGN_Y_CENTER; + data->wrap_width = 1.0f; } void SEQ_effect_text_font_unload(TextVars *data, const bool do_id_user) @@ -4001,31 +4003,15 @@ static ImBuf *do_text_effect(const SeqRenderData *context, 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 */ - else if (data->flag & SEQ_TEXT_SHADOW) { + if (data->flag & SEQ_TEXT_SHADOW) { int fontx, fonty; fontx = BLF_width_max(font); fonty = line_height; - BLF_position(font, x + max_ii(fontx / 25, 1), y + max_ii(fonty / 25, 1), 0.0f); + BLF_position(font, x + max_ii(fontx / 55, 1), y - max_ii(fonty / 30, 1), 0.0f); BLF_buffer_col(font, data->shadow_color); BLF_draw_buffer(font, data->text, BLF_DRAW_STR_DUMMY_MAX); } -- cgit v1.2.3