]> git.sesse.net Git - kdenlive/commitdiff
New features: Titles can now be larger than the frame size. Then, you can add a compo...
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 1 Jun 2009 15:58:15 +0000 (15:58 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 1 Jun 2009 15:58:15 +0000 (15:58 +0000)
svn path=/trunk/kdenlive/; revision=3472

src/effectstackedit.cpp
src/geometryval.cpp
src/geometryval.h
src/mainwindow.cpp
src/titlewidget.cpp
src/widgets/titlewidget_ui.ui

index 7bd9b58e69f4ebd968debb3316d5fa6bfdd5808c..a425ebecb881ad24a99afb9176bce06fada9c745 100644 (file)
@@ -100,6 +100,20 @@ EffectStackEdit::~EffectStackEdit()
 void EffectStackEdit::setFrameSize(QPoint p)
 {
     m_frameSize = p;
+    QDomNodeList namenode = m_params.elementsByTagName("parameter");
+    for (int i = 0;i < namenode.count() ;i++) {
+        QDomNode pa = namenode.item(i);
+        QDomNode na = pa.firstChildElement("name");
+        QString type = pa.attributes().namedItem("type").nodeValue();
+        QString paramName = i18n(na.toElement().text().toUtf8().data());
+
+        if (type == "geometry") {
+            Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]);
+            geom->setFrameSize(m_frameSize);
+            break;
+        }
+    }
+
 }
 
 void EffectStackEdit::updateProjectFormat(MltVideoProfile profile, Timecode t)
index 78fd7095381c6e2cbe3736e67e256ab2de72ffc2..95eb57f04f1ffcb746df17234317d3959f125b7d 100644 (file)
@@ -547,3 +547,8 @@ void Geometryval::slotResetPosition()
         m_view->value_height->setValue(m_frameSize.y());
     }
 }
+
+void Geometryval::setFrameSize(QPoint p)
+{
+    m_frameSize = p;
+}
index a82ff75c090bfbe12f6804e465fc5f39460f026f..b99a2a5d06fdd96386b949f31444efb07cbb9b6b 100644 (file)
@@ -42,6 +42,7 @@ class Geometryval : public QWidget
 public:
     explicit Geometryval(const MltVideoProfile profile, QPoint frame_size, QWidget* parent = 0);
     QDomElement getParamDesc();
+    void setFrameSize(QPoint p);
 
 private:
     Ui::Geometryval m_ui;
index 0c862d07d69b19ecdc7c52ae0eed465937b431c6..d2bc4b018cc7bae5b23a00ceb49b49ea1591b1b0 100644 (file)
@@ -2298,6 +2298,7 @@ void MainWindow::slotShowClipProperties(DocClipBase *clip)
             //m_clipManager->slotEditTextClipFile(id, dia_ui->xml().toString());
             QMap <QString, QString> newprops;
             newprops.insert("xmldata", dia_ui->xml().toString());
+            newprops.insert("frame_size", QString::number(pix.width()) + 'x' + QString::number(pix.height()));
             EditClipCommand *command = new EditClipCommand(m_projectList, clip->getId(), clip->properties(), newprops, true);
             m_activeDocument->commandStack()->push(command);
             m_clipMonitor->refreshMonitor(true);
index b338bd599191b8e4186ff7a2df0187b8c33d5b78..e3d1f8251405bc17c9033068787b8267aa88aa71 100644 (file)
@@ -768,12 +768,18 @@ void TitleWidget::saveTitle(KUrl url)
 
 QDomDocument TitleWidget::xml()
 {
-    return m_titledocument.xml(m_startViewport, m_endViewport);
+    QDomDocument doc = m_titledocument.xml(m_startViewport, m_endViewport);
+    if (cropImage->isChecked()) {
+        doc.documentElement().setAttribute("crop", 1);
+    }
+    return doc;
 }
 
 void TitleWidget::setXml(QDomDocument doc)
 {
     m_count = m_titledocument.loadFromXml(doc, m_startViewport, m_endViewport);
+    QDomElement e = doc.documentElement();
+    cropImage->setChecked(e.hasAttribute("crop"));
     m_transformations.clear();
     QList <QGraphicsItem *> items = graphicsView->scene()->items();
     const double PI = 4.0 * atan(1.0);
@@ -800,7 +806,27 @@ void TitleWidget::setXml(QDomDocument doc)
 
 QImage TitleWidget::renderedPixmap()
 {
-    QImage pix(m_frameWidth, m_frameHeight, QImage::Format_ARGB32);
+    int minX = 0;
+    int minY = 0;
+    int maxX = m_frameWidth;
+    int maxY = m_frameHeight;
+    if (!cropImage->isChecked()) {
+        m_scene->removeItem(m_startViewport);
+        m_scene->removeItem(m_endViewport);
+        QRect boundingRect = m_scene->itemsBoundingRect().toRect();
+        if (boundingRect.left() < 0) minX = boundingRect.left();
+        if (boundingRect.top() < 0) minY = boundingRect.top();
+        if (boundingRect.right() > maxX) maxX = boundingRect.right();
+        if (boundingRect.bottom() > maxY) maxY = boundingRect.bottom();
+        if (minX < 0) {
+            maxX = maxX - minX;
+        }
+        if (minY < 0) {
+            maxY = maxY - minY;
+        }
+    }
+
+    QImage pix(maxX, maxY, QImage::Format_ARGB32);
     pix.fill(Qt::transparent);
     QPainter painter(&pix);
     painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::HighQualityAntialiasing);
@@ -811,7 +837,7 @@ QImage TitleWidget::renderedPixmap()
     m_endViewport->setVisible(false);
     m_frameImage->setVisible(false);
 
-    m_scene->render(&painter, QRectF(), QRectF(0, 0, m_frameWidth, m_frameHeight));
+    m_scene->render(&painter, QRectF(), QRectF(minX, minY, maxX - minX, maxY - minY));
     painter.end();
     m_frameBorder->setPen(framepen);
     m_startViewport->setVisible(true);
@@ -850,6 +876,8 @@ void TitleWidget::writeChoices()
 
     titleConfig.writeEntry("background_color", kcolorbutton->color());
     titleConfig.writeEntry("background_alpha", horizontalSlider->value());
+
+    titleConfig.writeEntry("crop_image", cropImage->isChecked());
     //! \todo Not sure if I should sync - it is probably safe to do it
     config->sync();
 
@@ -878,5 +906,7 @@ void TitleWidget::readChoices()
 
     kcolorbutton->setColor(titleConfig.readEntry("background_color", kcolorbutton->color()));
     horizontalSlider->setValue(titleConfig.readEntry("background_alpha", horizontalSlider->value()));
+
+    cropImage->setChecked(titleConfig.readEntry("crop_image", cropImage->isChecked()));
 }
 
index 21a61de71be493e080d39c68c35825e98ba5c1b4..5e37104a953c1b1bdcdf4ecc7d82543ff493f766 100644 (file)
@@ -20,7 +20,7 @@
    <string>Title Clip</string>
   </property>
   <layout class="QGridLayout" name="gridLayout_2">
-   <item row="5" column="7">
+   <item row="5" column="8">
     <spacer name="horizontalSpacer_3">
      <property name="orientation">
       <enum>Qt::Horizontal</enum>
@@ -33,7 +33,7 @@
      </property>
     </spacer>
    </item>
-   <item row="2" column="1" colspan="8">
+   <item row="2" column="1" colspan="9">
     <widget class="QFrame" name="rect_properties">
      <property name="frameShape">
       <enum>QFrame::StyledPanel</enum>
      </layout>
     </widget>
    </item>
-   <item row="3" column="1" colspan="8">
+   <item row="3" column="1" colspan="9">
     <widget class="QFrame" name="text_properties">
      <property name="frameShape">
       <enum>QFrame::StyledPanel</enum>
      </layout>
     </widget>
    </item>
-   <item row="4" column="1" colspan="8">
+   <item row="4" column="1" colspan="9">
     <widget class="QSplitter" name="splitter">
      <property name="sizePolicy">
       <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
         <rect>
          <x>0</x>
          <y>0</y>
-         <width>358</width>
-         <height>178</height>
+         <width>94</width>
+         <height>65</height>
         </rect>
        </property>
        <attribute name="label">
         <rect>
          <x>0</x>
          <y>0</y>
-         <width>341</width>
+         <width>232</width>
          <height>198</height>
         </rect>
        </property>
      </property>
     </widget>
    </item>
-   <item row="5" column="8">
+   <item row="5" column="9">
     <widget class="QDialogButtonBox" name="buttonBox">
      <property name="orientation">
       <enum>Qt::Horizontal</enum>
      </property>
     </widget>
    </item>
-   <item row="0" column="6" colspan="3">
+   <item row="0" column="6" colspan="4">
     <widget class="QFrame" name="frame_properties">
      <property name="sizePolicy">
       <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
      </property>
     </widget>
    </item>
+   <item row="5" column="7">
+    <widget class="QCheckBox" name="cropImage">
+     <property name="text">
+      <string>Crop to frame size</string>
+     </property>
+    </widget>
+   </item>
   </layout>
  </widget>
  <customwidgets>