]> git.sesse.net Git - mlt/commitdiff
Force text item width and height with typewriter effect,
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 28 Dec 2012 15:34:23 +0000 (16:34 +0100)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 28 Dec 2012 15:34:23 +0000 (16:34 +0100)
fixes: http://kdenlive.org/mantis/view.php?id=2897

src/modules/qimage/kdenlivetitle_wrapper.cpp

index a4d2a0d4106b3c360ae29624d1e41acaa9fbd9be..d52b35ebe9681316782ac1c27737926a71c1b880 100755 (executable)
@@ -219,6 +219,8 @@ void loadFromXml( mlt_producer producer, QGraphicsScene *scene, const char *temp
                                        mlt_properties_set_int( producer_props, "_animated", 1 );
                                        QStringList effetData = QStringList() << "typewriter" << text << txtProperties.namedItem( "typewriter" ).nodeValue();
                                        txt->setData(0, effetData);
+                                       if ( !txtProperties.namedItem( "textwidth" ).isNull() )
+                                               txt->setData( 1, txtProperties.namedItem( "textwidth" ).nodeValue() );
                                }
                                
                                if ( txtProperties.namedItem( "alignment" ).isNull() == false )
@@ -440,16 +442,22 @@ void drawKdenliveTitle( producer_ktitle self, mlt_frame frame, int width, int he
                                    // the keystroke delay and a start offset, both in frames
                                    QStringList values = params.at( 2 ).split( ";" );
                                    int interval = qMax( 0, ( ( int ) position - values.at( 1 ).toInt()) / values.at( 0 ).toInt() );
-                                       qRegisterMetaType<QTextCursor>( "QTextCursor" );
-                                       QTextCursor cursor = titem->textCursor();
+                                   qRegisterMetaType<QTextCursor>( "QTextCursor" );
+                                   QTextCursor cursor = titem->textCursor();
                                    cursor.movePosition(QTextCursor::EndOfBlock);
                                    // get the font format
                                    QTextCharFormat format = cursor.charFormat();
                                    cursor.select(QTextCursor::Document);
                                    QString txt = params.at( 1 ).left( interval );
-                                   // If the string to insert is empty, insert a space so that we don't loose
+                                   // If the string to insert is empty, insert a space / linebreak so that we don't loose
                                    // formatting infos for the next iterations
-                                   cursor.insertText(txt.isEmpty() ? " " : txt, format);
+                                   int lines = params.at( 1 ).count( '\n' );
+                                   QString empty = " ";
+                                   for (int i = 0; i < lines; i++)
+                                           empty.append( "\n " );
+                                   cursor.insertText( txt.isEmpty() ? empty : txt, format );
+                                   if ( !titem->data( 1 ).isNull() )
+                                         titem->setTextWidth( titem->data( 1 ).toInt() );
                            }
                    }
                }