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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2015-07-10 19:17:06 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-07-10 19:30:26 +0300
commit3443686399feb4f96a9ea85f52f6750388b883a2 (patch)
tree7e4c91319ba3a2d13d4e83a43c0b690ed8e63547 /source
parent9a3dfa1f21168c19a3346bb4813b1313deb6fb18 (diff)
Sequencer: changes to text effect strip
- default alignment to lower center. - placement is now relative, so changing output size keeps correct placement. - instead of center override, add align option (left/right/center). Also don't use pixel-size for setting the font size, on new strips. Better not have UI prefs impact low level API's.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/seqeffects.c29
-rw-r--r--source/blender/makesdna/DNA_sequence_types.h18
-rw-r--r--source/blender/makesrna/intern/rna_sequencer.c32
3 files changed, 53 insertions, 26 deletions
diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c
index 2d1ea536b27..3e6edbe01e8 100644
--- a/source/blender/blenkernel/intern/seqeffects.c
+++ b/source/blender/blenkernel/intern/seqeffects.c
@@ -2888,8 +2888,11 @@ static void init_text_effect(Sequence *seq)
MEM_freeN(seq->effectdata);
data = seq->effectdata = MEM_callocN(sizeof(TextVars), "textvars");
- data->text_size = U.pixelsize * 30;
+ data->text_size = 30;
BLI_strncpy(data->text, "Text", sizeof(data->text));
+
+ data->loc[0] = 0.5f;
+ data->align = SEQ_TEXT_ALIGN_CENTER;
}
static int num_inputs_text(void)
@@ -2916,7 +2919,7 @@ static ImBuf *do_text_effect(const SeqRenderData *context, Sequence *seq, float
struct ColorManagedDisplay *display;
const char *display_device;
const int mono = blf_mono_font_render; // XXX
- int y_ofs, x, y, w;
+ int y_ofs, x, y;
display_device = context->scene->display_settings.display_device;
display = IMB_colormanagement_display_get_named(display_device);
@@ -2928,17 +2931,25 @@ static ImBuf *do_text_effect(const SeqRenderData *context, Sequence *seq, float
y_ofs = -BLF_descender(mono);
- w = BLF_width(mono, data->text, sizeof(data->text));
+ x = (data->loc[0] * width);
+ y = (data->loc[1] * height) + y_ofs;
- if (data->flags & TEXT_SEQ_AUTO_CENTER)
- x = width / 2 - w / 2;
- else
- x = (context->scene->r.size / 100.0f) * data->xpos;
+ if (data->align == SEQ_TEXT_ALIGN_LEFT) {
+ /* pass */
+ }
+ else {
+ const int w = BLF_width(mono, data->text, sizeof(data->text));
- y = y_ofs + (context->scene->r.size / 100.0f) * data->ypos;
+ if (data->align == SEQ_TEXT_ALIGN_RIGHT) {
+ x -= w;
+ }
+ else { /* SEQ_TEXT_ALIGN_CENTER */
+ x -= w / 2;
+ }
+ }
/* BLF_SHADOW won't work with buffers, instead use cheap shadow trick */
- if (data->flags & TEXT_SEQ_SHADOW) {
+ if (data->flag & SEQ_TEXT_SHADOW) {
int fontx, fonty;
fontx = BLF_width_max(mono);
fonty = BLF_height_max(mono);
diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h
index 377da2a7d82..3f3bfdfe1b1 100644
--- a/source/blender/makesdna/DNA_sequence_types.h
+++ b/source/blender/makesdna/DNA_sequence_types.h
@@ -274,14 +274,24 @@ typedef struct GaussianBlurVars {
typedef struct TextVars {
char text[512];
int text_size;
- int xpos, ypos;
- int flags;
+ float loc[2];
+ short flag;
+ char align;
+ char pad;
} TextVars;
+/* TextVars.flag */
enum {
- TEXT_SEQ_SHADOW = (1 << 0),
- TEXT_SEQ_AUTO_CENTER = (1 << 1),
+ SEQ_TEXT_SHADOW = (1 << 0),
};
+
+/* TextVars.align */
+enum {
+ SEQ_TEXT_ALIGN_LEFT = 0,
+ SEQ_TEXT_ALIGN_CENTER = 1,
+ SEQ_TEXT_ALIGN_RIGHT = 2,
+};
+
/* ***************** Sequence modifiers ****************** */
typedef struct SequenceModifierData {
diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c
index d7311b93b2f..535428e7d6a 100644
--- a/source/blender/makesrna/intern/rna_sequencer.c
+++ b/source/blender/makesrna/intern/rna_sequencer.c
@@ -2307,23 +2307,34 @@ static void rna_def_gaussian_blur(StructRNA *srna)
static void rna_def_text(StructRNA *srna)
{
+ static EnumPropertyItem text_align_items[] = {
+ {SEQ_TEXT_ALIGN_LEFT, "LEFT", 0, "Left", ""},
+ {SEQ_TEXT_ALIGN_CENTER, "CENTER", 0, "Center", ""},
+ {SEQ_TEXT_ALIGN_RIGHT, "RIGHT", 0, "Right", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
PropertyRNA *prop;
RNA_def_struct_sdna_from(srna, "TextVars", "effectdata");
- prop = RNA_def_property(srna, "text_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_ui_text(prop, "Size", "Size of the text");
RNA_def_property_ui_range(prop, 0.0f, 1000, 1, -1);
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update");
- prop = RNA_def_property(srna, "xpos", PROP_INT, PROP_NONE);
- RNA_def_property_ui_text(prop, "X Position", "X position of the text");
- RNA_def_property_ui_range(prop, -1000, 1000, 1, -1);
+ prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_NONE);
+ 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_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update");
- prop = RNA_def_property(srna, "ypos", PROP_INT, PROP_NONE);
- RNA_def_property_ui_text(prop, "Y Position", "Y position of the text");
- RNA_def_property_ui_range(prop, -1000, 1000, 1, -1);
+ prop = RNA_def_property(srna, "align", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "align");
+ RNA_def_property_enum_items(prop, text_align_items);
+ RNA_def_property_ui_text(prop, "Align", "");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update");
prop = RNA_def_property(srna, "text", PROP_STRING, PROP_NONE);
@@ -2331,14 +2342,9 @@ static void rna_def_text(StructRNA *srna)
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update");
prop = RNA_def_property(srna, "use_shadow", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flags", TEXT_SEQ_SHADOW);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_TEXT_SHADOW);
RNA_def_property_ui_text(prop, "Shadow", "draw text with shadow");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update");
-
- prop = RNA_def_property(srna, "use_autocenter", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flags", TEXT_SEQ_AUTO_CENTER);
- RNA_def_property_ui_text(prop, "Auto-Center", "draw text centered in x axis");
- RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update");
}
static EffectInfo def_effects[] = {