diff --git a/NEWS b/NEWS index ccc204c1e..fca4aa20c 100644 --- a/NEWS +++ b/NEWS @@ -84,6 +84,8 @@ Modules - Fixed `crop` with hardware decode+scale plus preview scale. - Fixed subtitle filter rendering one frame past the end time, and `subtitle_feed` end-frame calculation. + - Added a keyframable `bg_radius` property for rounded backgrounds to + `qtext` and the text services that delegate to it. - Fixed file-name buffer overflows in `gpsgraphic` and `gpstext`. Other diff --git a/src/modules/plus/filter_dynamictext.c b/src/modules/plus/filter_dynamictext.c index 287ef5039..6104034e4 100644 --- a/src/modules/plus/filter_dynamictext.c +++ b/src/modules/plus/filter_dynamictext.c @@ -269,7 +269,8 @@ static mlt_frame filter_process(mlt_filter filter, mlt_frame frame) free(result); mlt_properties_pass_list(text_filter_properties, properties, - "geometry family size weight style fgcolour bgcolour olcolour pad " + "geometry family size weight style fgcolour bgcolour bg_radius " + "olcolour pad " "halign valign outline underline strikethrough opacity"); mlt_filter_set_in_and_out(text_filter, mlt_filter_get_in(filter), mlt_filter_get_out(filter)); return mlt_filter_process(text_filter, frame); @@ -311,6 +312,7 @@ mlt_filter filter_dynamictext_init(mlt_profile profile, mlt_properties_set_string(my_properties, "style", "normal"); mlt_properties_set_string(my_properties, "fgcolour", "0x000000ff"); mlt_properties_set_string(my_properties, "bgcolour", "0x00000020"); + mlt_properties_set_double(my_properties, "bg_radius", 0.0); mlt_properties_set_string(my_properties, "olcolour", "0x00000000"); mlt_properties_set_string(my_properties, "pad", "0"); mlt_properties_set_string(my_properties, "halign", "left"); diff --git a/src/modules/plus/filter_dynamictext.yml b/src/modules/plus/filter_dynamictext.yml index 69e03cf09..ccb425b1d 100644 --- a/src/modules/plus/filter_dynamictext.yml +++ b/src/modules/plus/filter_dynamictext.yml @@ -2,7 +2,7 @@ schema_version: 7.2 type: filter identifier: dynamictext title: Dynamic text -version: 6 +version: 7 copyright: Meltytech, LLC license: LGPLv2.1 language: en @@ -119,6 +119,21 @@ parameters: mutable: yes widget: color + - identifier: bg_radius + title: Background corner radius + type: float + description: > + The corner radius in pixels of the background rectangle. Values larger + than half the rectangle's shortest side are clamped. Only supported when + the qtext filter is available. + default: 0 + minimum: 0 + readonly: no + mutable: yes + animation: yes + widget: spinner + unit: pixels + - identifier: olcolour title: Outline color type: string diff --git a/src/modules/plus/filter_subtitle.cpp b/src/modules/plus/filter_subtitle.cpp index 61ceddd51..4511e669b 100644 --- a/src/modules/plus/filter_subtitle.cpp +++ b/src/modules/plus/filter_subtitle.cpp @@ -163,7 +163,8 @@ static mlt_frame filter_process(mlt_filter filter, mlt_frame frame) mlt_properties_set_string(text_filter_properties, "argument", text); mlt_properties_pass_list(text_filter_properties, properties, - "geometry family size weight style fgcolour bgcolour olcolour pad " + "geometry family size weight style fgcolour bgcolour bg_radius " + "olcolour pad " "halign valign outline underline strikethrough opacity " "typewriter typewriter.step_length typewriter.step_sigma " "typewriter.random_seed typewriter.macro_type typewriter.cursor " @@ -203,6 +204,7 @@ mlt_filter filter_subtitle_init(mlt_profile profile, mlt_properties_set_string(properties, "style", "normal"); mlt_properties_set_string(properties, "fgcolour", "0x000000ff"); mlt_properties_set_string(properties, "bgcolour", "0x00000020"); + mlt_properties_set_double(properties, "bg_radius", 0.0); mlt_properties_set_string(properties, "olcolour", "0x00000000"); mlt_properties_set_string(properties, "pad", "0"); mlt_properties_set_string(properties, "halign", "left"); diff --git a/src/modules/plus/filter_subtitle.yml b/src/modules/plus/filter_subtitle.yml index a620d94d7..8e0852cf6 100644 --- a/src/modules/plus/filter_subtitle.yml +++ b/src/modules/plus/filter_subtitle.yml @@ -2,7 +2,7 @@ schema_version: 7.2 type: filter identifier: subtitle title: Subtitle -version: 5 +version: 6 copyright: Meltytech, LLC license: LGPLv2.1 language: en @@ -113,6 +113,21 @@ parameters: mutable: yes widget: color + - identifier: bg_radius + title: Background corner radius + type: float + description: > + The corner radius in pixels of the background rectangle. Values larger + than half the rectangle's shortest side are clamped. Only supported when + the qtext filter is available. + default: 0 + minimum: 0 + readonly: no + mutable: yes + animation: yes + widget: spinner + unit: pixels + - identifier: olcolour title: Outline color type: string diff --git a/src/modules/plus/filter_timer.c b/src/modules/plus/filter_timer.c index c3b37a24c..56afac865 100644 --- a/src/modules/plus/filter_timer.c +++ b/src/modules/plus/filter_timer.c @@ -112,7 +112,8 @@ static mlt_frame filter_process(mlt_filter filter, mlt_frame frame) free(result); mlt_properties_pass_list(text_filter_properties, properties, - "geometry family size weight style fgcolour bgcolour olcolour pad " + "geometry family size weight style fgcolour bgcolour bg_radius " + "olcolour pad " "halign valign outline underline strikethrough opacity"); mlt_filter_set_in_and_out(text_filter, mlt_filter_get_in(filter), mlt_filter_get_out(filter)); return mlt_filter_process(text_filter, frame); @@ -156,6 +157,7 @@ mlt_filter filter_timer_init(mlt_profile profile, mlt_service_type type, const c mlt_properties_set(my_properties, "style", "normal"); mlt_properties_set(my_properties, "fgcolour", "0x000000ff"); mlt_properties_set(my_properties, "bgcolour", "0x00000020"); + mlt_properties_set_double(my_properties, "bg_radius", 0.0); mlt_properties_set(my_properties, "olcolour", "0x00000000"); mlt_properties_set(my_properties, "pad", "0"); mlt_properties_set(my_properties, "halign", "left"); diff --git a/src/modules/plus/filter_timer.yml b/src/modules/plus/filter_timer.yml index dd66820c0..8822bbc41 100644 --- a/src/modules/plus/filter_timer.yml +++ b/src/modules/plus/filter_timer.yml @@ -2,7 +2,7 @@ schema_version: 7.2 type: filter identifier: timer title: Timer -version: 5 +version: 6 copyright: Meltytech, LLC license: LGPLv2.1 language: en @@ -175,6 +175,21 @@ parameters: mutable: yes widget: color + - identifier: bg_radius + title: Background corner radius + type: float + description: > + The corner radius in pixels of the background rectangle. Values larger + than half the rectangle's shortest side are clamped. Only supported when + the qtext filter is available. + default: 0 + minimum: 0 + readonly: no + mutable: yes + animation: yes + widget: spinner + unit: pixels + - identifier: olcolour title: Outline color type: string diff --git a/src/modules/plus/producer_subtitle.c b/src/modules/plus/producer_subtitle.c index a16c67042..eacf028cb 100644 --- a/src/modules/plus/producer_subtitle.c +++ b/src/modules/plus/producer_subtitle.c @@ -49,7 +49,7 @@ static int producer_get_frame(mlt_producer producer, mlt_frame_ptr frame, int in mlt_properties_pass_list( MLT_FILTER_PROPERTIES(sub_filter), producer_properties, - "resource geometry family size weight style fgcolour bgcolour " + "resource geometry family size weight style fgcolour bgcolour bg_radius " "olcolour pad halign valign outline underline strikethrough opacity"); mlt_filter_process(sub_filter, *frame); } @@ -89,6 +89,7 @@ mlt_producer producer_subtitle_init(mlt_profile profile, mlt_properties_set_string(producer_properties, "style", "normal"); mlt_properties_set_string(producer_properties, "fgcolour", "0xffffffff"); mlt_properties_set_string(producer_properties, "bgcolour", "0x00000020"); + mlt_properties_set_double(producer_properties, "bg_radius", 0.0); mlt_properties_set_string(producer_properties, "olcolour", "0x00000000"); mlt_properties_set_string(producer_properties, "pad", "0"); mlt_properties_set_string(producer_properties, "halign", "left"); diff --git a/src/modules/plus/producer_subtitle.yml b/src/modules/plus/producer_subtitle.yml index 94539a4c0..7a62becfe 100644 --- a/src/modules/plus/producer_subtitle.yml +++ b/src/modules/plus/producer_subtitle.yml @@ -2,7 +2,7 @@ schema_version: 7.2 type: producer identifier: subtitle title: Subtitle -version: 3 +version: 4 copyright: Meltytech, LLC license: LGPLv2.1 language: en @@ -96,6 +96,21 @@ parameters: mutable: yes widget: color + - identifier: bg_radius + title: Background corner radius + type: float + description: > + The corner radius in pixels of the background rectangle. Values larger + than half the rectangle's shortest side are clamped. Only supported when + the qtext filter is available. + default: 0 + minimum: 0 + readonly: no + mutable: yes + animation: yes + widget: spinner + unit: pixels + - identifier: olcolour title: Outline color type: string diff --git a/src/modules/qt/filter_gpstext.cpp b/src/modules/qt/filter_gpstext.cpp index 5dde7b7a2..bd3a9ae31 100644 --- a/src/modules/qt/filter_gpstext.cpp +++ b/src/modules/qt/filter_gpstext.cpp @@ -592,7 +592,8 @@ static mlt_frame filter_process(mlt_filter filter, mlt_frame frame) mlt_properties_pass_list(text_filter_properties, properties, - "geometry family size weight style fgcolour bgcolour olcolour pad " + "geometry family size weight style fgcolour bgcolour bg_radius " + "olcolour pad " "halign valign outline underline strikethrough opacity"); mlt_filter_set_in_and_out(text_filter, mlt_filter_get_in(filter), mlt_filter_get_out(filter)); return mlt_filter_process(text_filter, frame); @@ -659,6 +660,7 @@ mlt_filter filter_gpstext_init(mlt_profile profile, mlt_service_type type, const mlt_properties_set_string(my_properties, "style", "normal"); mlt_properties_set_string(my_properties, "fgcolour", "0xffffffff"); mlt_properties_set_string(my_properties, "bgcolour", "0x00000000"); + mlt_properties_set_double(my_properties, "bg_radius", 0.0); mlt_properties_set_string(my_properties, "olcolour", "0x000000ff"); mlt_properties_set_string(my_properties, "pad", "5"); mlt_properties_set_string(my_properties, "halign", "left"); diff --git a/src/modules/qt/filter_gpstext.yml b/src/modules/qt/filter_gpstext.yml index 6e6f57a79..60b4d2098 100644 --- a/src/modules/qt/filter_gpstext.yml +++ b/src/modules/qt/filter_gpstext.yml @@ -2,7 +2,7 @@ schema_version: 7.2 type: filter identifier: gpstext title: GPS Text -version: 8 +version: 9 copyright: Meltytech, LLC creator: Daniel F license: LGPLv2.1 @@ -264,6 +264,21 @@ parameters: mutable: yes widget: color + - identifier: bg_radius + title: Background corner radius + type: float + description: > + The corner radius in pixels of the background rectangle. Values larger + than half the rectangle's shortest side are clamped. Only supported when + the qtext filter is available. + default: 0 + minimum: 0 + readonly: no + mutable: yes + animation: yes + widget: spinner + unit: pixels + - identifier: olcolour title: Outline color type: string diff --git a/src/modules/qt/filter_qtext.cpp b/src/modules/qt/filter_qtext.cpp index 7cb6b97de..107a02e64 100644 --- a/src/modules/qt/filter_qtext.cpp +++ b/src/modules/qt/filter_qtext.cpp @@ -351,11 +351,22 @@ static void paint_background(QPainter *painter, QRectF path_rect, mlt_properties filter_properties, mlt_properties frame_properties, + double radius_scale, int position, int length) { QColor bg_color = get_qcolor(filter_properties, "bgcolour", frame_properties, position, length); - painter->fillRect(path_rect, bg_color); + qreal radius = mlt_properties_anim_get_double(filter_properties, "bg_radius", position, length) + * radius_scale; + if (radius <= 0.0) { + painter->fillRect(path_rect, bg_color); + return; + } + + radius = qMin(radius, qMin(path_rect.width(), path_rect.height()) / 2.0); + QPainterPath background_path; + background_path.addRoundedRect(path_rect, radius, radius); + painter->fillPath(background_path, bg_color); } static void paint_text(QPainter *painter, @@ -545,6 +556,7 @@ static int filter_get_image(mlt_frame frame, path_rect, filter_properties, frame_properties, + pixel_ratio, position, length); doc->drawContents(&painter, drawRect); @@ -562,6 +574,7 @@ static int filter_get_image(mlt_frame frame, path_rect, filter_properties, frame_properties, + scale, position, length); paint_text(&painter, &text_path, filter_properties, frame_properties, position, length); @@ -641,6 +654,7 @@ mlt_filter filter_qtext_init(mlt_profile profile, mlt_service_type type, const c mlt_properties_set_string(filter_properties, "style", "normal"); mlt_properties_set_string(filter_properties, "fgcolour", "0x000000ff"); mlt_properties_set_string(filter_properties, "bgcolour", "0x00000020"); + mlt_properties_set_double(filter_properties, "bg_radius", 0.0); mlt_properties_set_string(filter_properties, "olcolour", "0x00000000"); mlt_properties_set_string(filter_properties, "pad", "0"); mlt_properties_set_string(filter_properties, "halign", "left"); diff --git a/src/modules/qt/filter_qtext.yml b/src/modules/qt/filter_qtext.yml index 8d0fd9703..e0405fbf6 100644 --- a/src/modules/qt/filter_qtext.yml +++ b/src/modules/qt/filter_qtext.yml @@ -2,7 +2,7 @@ schema_version: 7.2 type: filter identifier: qtext title: QText -version: 8 +version: 9 copyright: Meltytech, LLC license: LGPLv2.1 language: en @@ -93,6 +93,19 @@ parameters: widget: color animation: yes + - identifier: bg_radius + title: Background corner radius + type: float + description: > + The corner radius in pixels of the background rectangle. Values larger + than half the rectangle's shortest side are clamped. + default: 0 + minimum: 0 + mutable: yes + animation: yes + widget: spinner + unit: pixels + - identifier: olcolour title: Outline color type: color @@ -180,9 +193,9 @@ parameters: type: string description: > Render rich text from a string containing a subset of HTML 4. - The only other properties that can be used with this are geometry and - bgcolour. The geometry width and height defines the page or block size - while its X and Y coordinates determine its position. + The only other properties that can be used with this are geometry, + bgcolour, and bg_radius. The geometry width and height defines the page + or block size while its X and Y coordinates determine its position. This property has a higher priority than argument; argument is ignored if this property is set. mutable: yes @@ -192,9 +205,9 @@ parameters: type: string description: > Render rich text from a file containing a subset of HTML 4. - The only other properties that can be used with this are geometry and - bgcolour. The geometry width and height defines the page or block size - while its X and Y coordinates determine its position. + The only other properties that can be used with this are geometry, + bgcolour, and bg_radius. The geometry width and height defines the page + or block size while its X and Y coordinates determine its position. This property has a higher priority than both argument and html; argument and html are ignored if this property is set. mutable: yes