]> git.sesse.net Git - kdenlive/commitdiff
Add GUI for MLT filter dynamic text.
authorBrian Matherly <pez4brian@yahoo.com>
Tue, 22 Nov 2011 16:30:49 +0000 (17:30 +0100)
committerTill Theato <root@ttill.de>
Tue, 22 Nov 2011 16:30:49 +0000 (17:30 +0100)
This includes the new parameter types 'font' and 'keyword'. The color
widget gets alpha channel support.

data/blacklisted_effects.txt
effects/CMakeLists.txt
effects/README
effects/dynamictext.xml [new file with mode: 0644]
src/CMakeLists.txt
src/choosecolorwidget.cpp
src/choosecolorwidget.h
src/effectstackedit.cpp
src/widgets/fontval_ui.ui [new file with mode: 0644]
src/widgets/keywordval_ui.ui [new file with mode: 0644]

index e7510c4225f36259095e53d2cbb4a629aa1e5ffd..c94871eb7df9a14ca895d6a8cd94ba5b037fd5ca 100644 (file)
@@ -98,7 +98,6 @@ resize
 resample
 mono
 
-dynamictext
 
 # Effects need extra GUI to create the resulting melt.xml with the corrected content
 videostab
index c32a199c40db763c8411a57844cceb496f412794..8aa6c04d59fe14b128e7febdba59e704aeeb0662 100644 (file)
@@ -10,6 +10,7 @@ chroma_hold.xml
 chroma.xml
 crop.xml
 dust.xml
+dynamictext.xml
 freeze.xml
 gamma.xml
 grain.xml
index 4ee6646694cab05f7b986a68bb18efe15a6eb90e..b19bba359646e952d539051ba95c7901ce468814 100644 (file)
@@ -71,15 +71,17 @@ The rest:
                 - multiple choice
                 - represented by a drop-down menu
                 - additional parameter attribute:
-                    - "paramlist": list of possible values separated by comma (no whitespaces!)
+                    - "paramlist": list of possible values separated by semicolon (no whitespaces!)
                 - addtional tag:
-                    - "paramlistdisplay": (optional) list of names to use for the values
+                    - "paramlistdisplay": (optional) list of names to use for the values separated by comma
             - "position":
                 - time stored as frame number
                 - represented by a slider
             - "color":
-                - color value, similar to representation HTML ("#rrggbb" or "0xrrggbb")
+                - color value, similar to representation HTML ("#rrggbb"/"#aarrggbb" or "0xrrggbbaa")
                 - represented by a button opening the KDE color dialog + a color picker button
+                - additional attributes:
+                    - "alpha": (default = "0") use to enable alpha support
             - "keyframe":
                 - keyframable number
                 - keyframes are opt-in (only one keyframe by default -> should be prefered over "constant" whenever possible)
@@ -112,6 +114,13 @@ The rest:
                 - cubic Bézier spline editor for the frei0r color curves filter (new version, might be reused for other filters)
             - "roto-spline":
                 - GUI for the rotoscoping filter (spline on the monitor)
+            - "keywords":
+                - Text entry with a selection of possible keywords to be inserted in the text.
+                - additional tags:
+                    - "keywords": list of possible keyword values separated by semicolon
+                    - "keywordsdisplay": list of names to use for the values separated by semicolon
+            - "fontfamily":
+                - Font typeface entry
 ==========
 
 ==========
diff --git a/effects/dynamictext.xml b/effects/dynamictext.xml
new file mode 100644 (file)
index 0000000..dcfbbb1
--- /dev/null
@@ -0,0 +1,46 @@
+<!DOCTYPE kpartgui>
+<effect tag="dynamictext" id="dynamictext">
+    <name>Dynamic Text</name>
+    <description>Overlay text with keywords replaced</description>
+    <author>Brian Matherly</author>
+    <parameter type="geometry" name="geometry" default="0%/0%:100%x100%:100" fixed="0">
+        <name>Geometry</name>
+    </parameter>
+    <parameter type="fontfamily" name="family" default="Sans">
+        <name>Font Family</name>
+    </parameter>
+    <parameter type="constant" name="size" max="200" min="8" default="48">
+        <name>Font Size</name>
+    </parameter>
+    <parameter type="constant" name="weight" max="900" min="100" default="400">
+        <name>Font Weight</name>
+    </parameter>
+    <parameter type="color" name="fgcolour" default="0x000000ff" alpha="1">
+        <name>Foreground Color</name>
+    </parameter>
+    <parameter type="color" name="bgcolour" default="0x00000020" alpha="1">
+        <name>Background Color</name>
+    </parameter>
+    <parameter type="color" name="olcolour" default="0x00000000" alpha="1">
+        <name>Outline Color</name>
+    </parameter>
+    <parameter type="constant" name="outline" max="3" min="0" default="0">
+        <name>Outline Width</name>
+    </parameter>
+    <parameter type="constant" name="pad" max="500" min="0" default="0">
+        <name>Padding</name>
+    </parameter>
+    <parameter type="list" name="halign" default="left" paramlist="left;centre;right">
+        <paramlistdisplay>Left,Center,Right</paramlistdisplay>
+        <name>Horizontal Alignment</name>
+    </parameter>
+    <parameter type="list" name="valign" default="top" paramlist="top;middle;bottom">
+        <paramlistdisplay>Top,Middle,Bottom</paramlistdisplay>
+        <name>Vertical Alignment</name>
+    </parameter>
+    <parameter type="keywords" name="argument" default="#timecode#">
+        <name>Text</name>
+        <keywords>#timecode#;#frame#;#filedate#;#meta.media.0.stream.frame_rate#;#meta.media.0.codec.name#;#meta.media.0.codec.bit_rate#;#meta.media.width#;#meta.media.height#;#meta.attr.comment.markup#</keywords>
+        <keywordsdisplay>timecode;frame;file date;source frame rate;source codec;source bit rate;source width;source height;source comment</keywordsdisplay>
+    </parameter>
+</effect>
index 8fdcd8cc8fb452854947e710ccd05d900195086f..2783549438a22935127fe30b0b314ce3fa9e506a 100644 (file)
@@ -251,6 +251,8 @@ kde4_add_ui_files(kdenlive_UIS
   widgets/wizardextra_ui.ui
   widgets/wizardmltcheck_ui.ui
   widgets/wizardstandard_ui.ui
+  widgets/keywordval_ui.ui
+  widgets/fontval_ui.ui
 )
 
 if(OPENGL_FOUND)
index 1b81ca3123536d11f667a43adeaa75d088df1299..aa154b6ed9f935f4906ac6afdca2c3ad01d85455 100644 (file)
 #include <KColorButton>
 #include <KLocalizedString>
 
+static QColor stringToColor(QString strColor)
+{
+    bool ok = false;
+    QColor color("black");
+    int intval = 0;
+
+    if (strColor.startsWith("0x")) {
+        // Format must be 0xRRGGBBAA
+        intval = strColor.toUInt(&ok, 16);
+        color.setRgb( ( intval >> 24 ) & 0xff,   // r
+                      ( intval >> 16 ) & 0xff,   // g
+                      ( intval >>  8 ) & 0xff,   // b
+                      ( intval )       & 0xff ); // a
+    } else if (strColor.startsWith("#") && strColor.length() == 9) {
+        // Format must be #AARRGGBB
+        strColor = strColor.replace('#', "0x");
+        intval = strColor.toUInt(&ok, 16);
+        color.setRgb( ( intval >> 16 ) & 0xff,   // r
+                      ( intval >>  8 ) & 0xff,   // g
+                      ( intval       ) & 0xff,   // b
+                      ( intval >> 24 ) & 0xff ); // a
+    } else if (strColor.startsWith("#") && strColor.length() == 7) {
+        // Format must be #RRGGBB
+        strColor = strColor.replace('#', "0x");
+        intval = strColor.toUInt(&ok, 16);
+        color.setRgb( ( intval >> 16 ) & 0xff,   // r
+                      ( intval >>  8 ) & 0xff,   // g
+                      ( intval       ) & 0xff,   // b
+                      0xff );                    // a
+    }
+
+    return color;
+}
+
+static QString colorToString(QColor color, bool alpha)
+{
+    QString colorStr;
+    QTextStream stream(&colorStr);
+    stream << "#";
+    stream.setIntegerBase(16);
+    stream.setFieldWidth(2);
+    stream.setFieldAlignment(QTextStream::AlignRight);
+    stream.setPadChar('0');
+    if(alpha)
+    {
+        stream << color.alpha();
+    }
+    stream <<  color.red() << color.green() << color.blue();
 
-ChooseColorWidget::ChooseColorWidget(QString text, QColor color, QWidget *parent) :
+    return colorStr;
+}
+
+ChooseColorWidget::ChooseColorWidget(QString text, QString color, QWidget *parent) :
         QWidget(parent)
 {
     QHBoxLayout *layout = new QHBoxLayout(this);
@@ -36,7 +87,7 @@ ChooseColorWidget::ChooseColorWidget(QString text, QColor color, QWidget *parent
     layout->setSpacing(0);
 
     QLabel *label = new QLabel(text, this);
-    m_button = new KColorButton(color, this);
+    m_button = new KColorButton(stringToColor(color), this);
     m_button->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
     ColorPickerWidget *picker = new ColorPickerWidget(this);
 
@@ -49,9 +100,14 @@ ChooseColorWidget::ChooseColorWidget(QString text, QColor color, QWidget *parent
     connect(m_button, SIGNAL(changed(QColor)), this, SIGNAL(modified()));
 }
 
-QColor ChooseColorWidget::getColor()
+QString ChooseColorWidget::getColor()
+{
+    return colorToString(m_button->color(), m_button->isAlphaChannelEnabled());
+}
+
+void ChooseColorWidget::setAlphaChannelEnabled(bool enabled)
 {
-    return m_button->color();
+    m_button->setAlphaChannelEnabled(enabled);
 }
 
 void ChooseColorWidget::setColor(QColor color)
index deac2b818b9039c06195d1c87517e6694c3e0bc8..4c2c2ff2bb46246043e7b3e57457d0b4c8438687 100644 (file)
@@ -39,10 +39,13 @@ public:
     /** @brief Sets up the widget.
     * @param text (optional) What the color will be used for
     * @param color (optional) initial color */
-    ChooseColorWidget(QString text = QString(), QColor color = QColor(), QWidget* parent = 0);
+    ChooseColorWidget(QString text = QString(), QString color = "0xffffffff", QWidget* parent = 0);
 
     /** @brief Gets the choosen color. */
-    QColor getColor();
+    QString getColor();
+    /** @brief Enable the use of alpha channel.
+    * @param enabled (required) whether alpha is enabled or disabled */
+    void setAlphaChannelEnabled(bool enabled);
 
 private:
     KColorButton *m_button;
index 2a9566795d7bd50f28b933843867ecb6ad5b7039..7efab0f218314f9592ec2efe3a8bcfcd2c325180 100644 (file)
@@ -20,6 +20,8 @@
 #include "ui_boolval_ui.h"
 #include "ui_wipeval_ui.h"
 #include "ui_urlval_ui.h"
+#include "ui_keywordval_ui.h"
+#include "ui_fontval_ui.h"
 #include "complexparameter.h"
 #include "geometryval.h"
 #include "positionedit.h"
@@ -70,6 +72,14 @@ class Urlval: public QWidget, public Ui::Urlval_UI
 {
 };
 
+class Keywordval: public QWidget, public Ui::Keywordval_UI
+{
+};
+
+class Fontval: public QWidget, public Ui::Fontval_UI
+{
+};
+
 QMap<QString, QImage> EffectStackEdit::iconCache;
 
 EffectStackEdit::EffectStackEdit(Monitor *monitor, QWidget *parent) :
@@ -391,10 +401,8 @@ void EffectStackEdit::transferParamDesc(const QDomElement &d, ItemInfo info, boo
                 m_keyframeEditor->addParameter(pa);
             }
         } else if (type == "color") {
-            if (value.startsWith('#'))
-                value = value.replace('#', "0x");
-            bool ok;
-            ChooseColorWidget *choosecolor = new ChooseColorWidget(paramName, QColor(value.toUInt(&ok, 16)), this);
+            ChooseColorWidget *choosecolor = new ChooseColorWidget(paramName, value, this);
+            choosecolor->setAlphaChannelEnabled(pa.attribute("alpha") == "1");
             m_vbox->addWidget(choosecolor);
             m_valueItems[paramName] = choosecolor;
             connect(choosecolor, SIGNAL(displayMessage(const QString&, int)), this, SIGNAL(displayMessage(const QString&, int)));
@@ -534,6 +542,41 @@ void EffectStackEdit::transferParamDesc(const QDomElement &d, ItemInfo info, boo
             connect(cval->urlwidget, SIGNAL(returnPressed()) , this, SLOT(collectAllParameters()));
             connect(cval->urlwidget, SIGNAL(urlSelected(const KUrl&)) , this, SLOT(collectAllParameters()));
             m_uiItems.append(cval);
+        } else if (type == "keywords") {
+            Keywordval* kval = new Keywordval;
+            kval->setupUi(toFillin);
+            kval->label->setText(paramName);
+            kval->lineeditwidget->setText(value);
+            QDomElement klistelem = pa.firstChildElement("keywords");
+            QDomElement kdisplaylistelem = pa.firstChildElement("keywordsdisplay");
+            QStringList keywordlist;
+            QStringList keyworddisplaylist;
+            if (!klistelem.isNull()) {
+                keywordlist = klistelem.text().split(';');
+                keyworddisplaylist = i18n(kdisplaylistelem.text().toUtf8().data()).split(';');
+            }
+            if (keyworddisplaylist.count() != keywordlist.count()) {
+                keyworddisplaylist = keywordlist;
+            }
+            for (int i = 0; i < keywordlist.count(); i++) {
+                kval->comboboxwidget->addItem(keyworddisplaylist.at(i), keywordlist.at(i));
+            }
+            // Add disabled user prompt at index 0
+            kval->comboboxwidget->insertItem(0, i18n("<select a keyword>"), "");
+            kval->comboboxwidget->model()->setData( kval->comboboxwidget->model()->index(0,0), QVariant(Qt::NoItemFlags), Qt::UserRole -1);
+            kval->comboboxwidget->setCurrentIndex(0);
+            m_valueItems[paramName] = kval;
+            connect(kval->lineeditwidget, SIGNAL(editingFinished()) , this, SLOT(collectAllParameters()));
+            connect(kval->comboboxwidget, SIGNAL(activated (const QString&)), this, SLOT(collectAllParameters()));
+            m_uiItems.append(kval);
+        } else if (type == "fontfamily") {
+            Fontval* fval = new Fontval;
+            fval->setupUi(toFillin);
+            fval->name->setText(paramName);
+            fval->fontfamilywidget->setCurrentFont(QFont(value));
+            m_valueItems[paramName] = fval;
+            connect(fval->fontfamilywidget, SIGNAL(currentFontChanged(const QFont &)), this, SLOT(collectAllParameters())) ;
+            m_uiItems.append(fval);
         } else {
             delete toFillin;
             toFillin = NULL;
@@ -685,7 +728,7 @@ void EffectStackEdit::collectAllParameters()
             setValue = box->checkState() == Qt::Checked ? "1" : "0" ;
         } else if (type == "color") {
             ChooseColorWidget *choosecolor = ((ChooseColorWidget*)m_valueItems.value(paramName));
-            setValue = choosecolor->getColor().name();
+            setValue = choosecolor->getColor();
         } else if (type == "complex") {
             ComplexParameter *complex = ((ComplexParameter*)m_valueItems.value(paramName));
             namenode.item(i) = complex->getParamDesc();
@@ -801,6 +844,19 @@ void EffectStackEdit::collectAllParameters()
         } else if (type == "url") {
             KUrlRequester *req = ((Urlval*)m_valueItems.value(paramName))->urlwidget;
             setValue = req->url().path();
+        } else if (type == "keywords"){
+            QLineEdit *line = ((Keywordval*)m_valueItems.value(paramName))->lineeditwidget;
+            QComboBox *combo = ((Keywordval*)m_valueItems.value(paramName))->comboboxwidget;
+            if(combo->currentIndex())
+            {
+                QString comboval = combo->itemData(combo->currentIndex()).toString();
+                line->insert(comboval);
+                combo->setCurrentIndex(0);
+            }
+            setValue = line->text();
+        } else if (type == "fontfamily") {
+            QFontComboBox* fontfamily = ((Fontval*)m_valueItems.value(paramName))->fontfamilywidget;
+            setValue = fontfamily->currentFont().family();
         }
 
         if (!setValue.isNull())
diff --git a/src/widgets/fontval_ui.ui b/src/widgets/fontval_ui.ui
new file mode 100644 (file)
index 0000000..b1a4937
--- /dev/null
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Fontval_UI</class>
+ <widget class="QWidget" name="Fontval_UI">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>200</width>
+    <height>60</height>
+   </rect>
+  </property>
+  <layout class="QGridLayout">
+   <property name="margin">
+    <number>0</number>
+   </property>
+   <property name="spacing">
+    <number>0</number>
+   </property>
+   <item row="0" column="0">
+    <widget class="QLabel" name="name">
+     <property name="text">
+      <string>TextLabel</string>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="1">
+    <widget class="QFontComboBox" name="fontfamilywidget"/>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src/widgets/keywordval_ui.ui b/src/widgets/keywordval_ui.ui
new file mode 100644 (file)
index 0000000..b177dc0
--- /dev/null
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Keywordval_UI</class>
+ <widget class="QWidget" name="Keywordval_UI">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>194</width>
+    <height>42</height>
+   </rect>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <property name="verticalSpacing">
+    <number>0</number>
+   </property>
+   <property name="margin">
+    <number>0</number>
+   </property>
+   <item row="0" column="0" colspan="2">
+    <widget class="QLabel" name="label">
+     <property name="text">
+      <string>Param</string>
+     </property>
+     <property name="alignment">
+      <set>Qt::AlignCenter</set>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="0">
+    <widget class="QLineEdit" name="lineeditwidget"/>
+   </item>
+   <item row="2" column="0">
+    <widget class="QComboBox" name="comboboxwidget"/>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>