diff --git a/io/config.cpp b/io/config.cpp index df6139342..57ed45d8b 100644 --- a/io/config.cpp +++ b/io/config.cpp @@ -22,7 +22,8 @@ Config::Config() show_title_safe_area(false), use_custom_title_safe_ratio(false), custom_title_safe_ratio(1), - enable_drag_files_to_timeline(false) + enable_drag_files_to_timeline(false), + autoscale_by_default(false) { } @@ -80,7 +81,10 @@ void Config::load(QString path) { } else if (stream.name() == "EnableDragFilesToTimeline") { stream.readNext(); enable_drag_files_to_timeline = (stream.text() == "1");; - } + } else if (stream.name() == "AutoscaleByDefault") { + stream.readNext(); + autoscale_by_default = (stream.text() == "1");; + } } } if (stream.hasError()) { @@ -141,6 +145,7 @@ void Config::save(QString path) { stream.writeTextElement("UseCustomTitleSafeRatio", QString::number(use_custom_title_safe_ratio)); stream.writeTextElement("CustomTitleSafeRatio", QString::number(custom_title_safe_ratio)); stream.writeTextElement("EnableDragFilesToTimeline", QString::number(enable_drag_files_to_timeline)); + stream.writeTextElement("AutoscaleByDefault", QString::number(autoscale_by_default)); stream.writeEndElement(); stream.writeEndDocument(); // doc diff --git a/io/config.h b/io/config.h index c9e06e420..941793e5e 100644 --- a/io/config.h +++ b/io/config.h @@ -26,6 +26,7 @@ struct Config { bool use_custom_title_safe_ratio; double custom_title_safe_ratio; bool enable_drag_files_to_timeline; + bool autoscale_by_default; void load(QString path); void save(QString path); diff --git a/mainwindow.cpp b/mainwindow.cpp index 2bab9482a..4808601cc 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -294,7 +294,7 @@ void MainWindow::openSpeedDialog() { SpeedDialog s(this); for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL & panel_timeline->is_clip_selected(c, true)) { + if (c != NULL && panel_timeline->is_clip_selected(c, true)) { s.clips.append(c); } } @@ -604,6 +604,7 @@ void MainWindow::toolMenu_About_To_Be_Shown() { ui->actionScroll_Wheel_Zooms->setChecked(config.scroll_zooms); ui->actionRectified_Waveforms->setChecked(config.rectified_waveforms); ui->actionEnable_Drag_Files_to_Timeline->setChecked(config.enable_drag_files_to_timeline); + ui->actionAuto_scale_by_Default->setChecked(config.autoscale_by_default); } void MainWindow::on_actionEdit_Tool_Selects_Links_triggered() { @@ -788,3 +789,7 @@ void MainWindow::on_actionCustom_triggered() { void MainWindow::on_actionEnable_Drag_Files_to_Timeline_triggered() { config.enable_drag_files_to_timeline = !config.enable_drag_files_to_timeline; } + +void MainWindow::on_actionAuto_scale_by_Default_triggered() { + config.autoscale_by_default = !config.autoscale_by_default; +} diff --git a/mainwindow.h b/mainwindow.h index 6152ae102..5442d9db0 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -184,6 +184,8 @@ private slots: void on_actionEnable_Drag_Files_to_Timeline_triggered(); + void on_actionAuto_scale_by_Default_triggered(); + private: Ui::MainWindow *ui; void setup_layout(); diff --git a/mainwindow.ui b/mainwindow.ui index 5134a1e93..d6ac96579 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -37,7 +37,7 @@ 0 0 653 - 20 + 16 @@ -176,6 +176,7 @@ + @@ -770,6 +771,14 @@ Enable Drag Files to Timeline + + + true + + + Auto-scale by Default + + diff --git a/panels/project.cpp b/panels/project.cpp index 26fc61c59..e22d317b6 100644 --- a/panels/project.cpp +++ b/panels/project.cpp @@ -782,7 +782,11 @@ bool Project::load_worker(QFile& f, QXmlStreamReader& stream, int type) { // int media_id, stream_id; Clip* c = new Clip(s); - c->media = NULL; + + // backwards compatibility code + c->autoscale = false; + + c->media = NULL; for (int j=0;jcolor_g = attr.value().toInt(); } else if (attr.name() == "b") { c->color_b = attr.value().toInt(); + } else if (attr.name() == "autoscale") { + c->autoscale = (attr.value() == "1"); } else if (attr.name() == "type") { c->media_type = attr.value().toInt(); } else if (attr.name() == "media") { @@ -1107,6 +1113,8 @@ void Project::save_folder(QXmlStreamWriter& stream, QTreeWidgetItem* parent, int stream.writeAttribute("g", QString::number(c->color_g)); stream.writeAttribute("b", QString::number(c->color_b)); + stream.writeAttribute("autoscale", QString::number(c->autoscale)); + stream.writeAttribute("type", QString::number(c->media_type)); switch (c->media_type) { case MEDIA_TYPE_FOOTAGE: diff --git a/project/clip.cpp b/project/clip.cpp index 5c5c02cab..ee8bc1c43 100644 --- a/project/clip.cpp +++ b/project/clip.cpp @@ -3,6 +3,7 @@ #include "effects/effect.h" #include "effects/transition.h" #include "io/media.h" +#include "io/config.h" #include "playback/playback.h" #include "playback/cacher.h" #include "panels/project.h" @@ -30,7 +31,7 @@ Clip::Clip(Sequence* s) : replaced(false), texture(NULL), fbo(NULL), - autoscale(false) + autoscale(config.autoscale_by_default) { reset(); } @@ -51,6 +52,7 @@ Clip* Clip::copy(Sequence* s) { copy->media = media; copy->media_type = media_type; copy->media_stream = media_stream; + copy->autoscale = autoscale; for (int i=0;ieffects.append(effects.at(i)->copy(copy)); diff --git a/project/undo.cpp b/project/undo.cpp index b4b8d9ae9..2ad9ee96a 100644 --- a/project/undo.cpp +++ b/project/undo.cpp @@ -10,6 +10,7 @@ #include "panels/panels.h" #include "panels/project.h" #include "panels/effectcontrols.h" +#include "panels/viewer.h" #include "playback/playback.h" #include "ui/sourcetable.h" #include "effects/effect.h" @@ -17,6 +18,7 @@ #include "playback/cacher.h" #include "effects/transition.h" #include "ui/labelslider.h" +#include "ui/viewerwidget.h" QUndoStack undo_stack; @@ -1318,3 +1320,17 @@ void EffectFieldUndo::redo() { field->set_current_data(new_val); } } + +void SetAutoscaleAction::undo() { + for (int i=0;iautoscale = !clips.at(i)->autoscale; + } + panel_viewer->viewer_widget->update(); +} + +void SetAutoscaleAction::redo() { + for (int i=0;iautoscale = !clips.at(i)->autoscale; + } + panel_viewer->viewer_widget->update(); +} diff --git a/project/undo.h b/project/undo.h index 4a4cc4542..4e7ef9103 100644 --- a/project/undo.h +++ b/project/undo.h @@ -441,4 +441,11 @@ private: bool done; }; +class SetAutoscaleAction : public QUndoCommand { +public: + void undo(); + void redo(); + QVector clips; +}; + #endif // UNDO_H diff --git a/ui/timelinewidget.cpp b/ui/timelinewidget.cpp index e41e86b24..9e42c509e 100644 --- a/ui/timelinewidget.cpp +++ b/ui/timelinewidget.cpp @@ -63,11 +63,37 @@ void TimelineWidget::show_context_menu(const QPoint& pos) { menu.addSeparator(); QAction* speedAction = menu.addAction("&Speed/Duration"); connect(speedAction, SIGNAL(triggered(bool)), mainWindow, SLOT(openSpeedDialog())); + QAction* autoscaleAction = menu.addAction("Auto-s&cale"); + autoscaleAction->setCheckable(true); + connect(autoscaleAction, SIGNAL(triggered(bool)), this, SLOT(toggle_autoscale())); + + for (int i=0;iclips.size();i++) { + Clip* c = sequence->clips.at(i); + if (c != NULL && panel_timeline->is_clip_selected(c, true)) { + autoscaleAction->setChecked(c->autoscale); + break; + } + } } menu.exec(mapToGlobal(pos)); } +void TimelineWidget::toggle_autoscale() { + SetAutoscaleAction* action = new SetAutoscaleAction(); + for (int i=0;iclips.size();i++) { + Clip* c = sequence->clips.at(i); + if (c != NULL && panel_timeline->is_clip_selected(c, true)) { + action->clips.append(c); + } + } + if (action->clips.size() > 0) { + undo_stack.push(action); + } else { + delete action; + } +} + bool same_sign(int a, int b) { return (a < 0) == (b < 0); } diff --git a/ui/timelinewidget.h b/ui/timelinewidget.h index 3db08c7d1..7ee1d3a2a 100644 --- a/ui/timelinewidget.h +++ b/ui/timelinewidget.h @@ -58,7 +58,6 @@ private: QVector post_clips; QPixmap clip_pixmap; -// QPixmap selection_pixmap; int predicted_video_width; int predicted_video_height; @@ -71,6 +70,7 @@ public slots: private slots: void show_context_menu(const QPoint& pos); + void toggle_autoscale(); }; #endif // TIMELINEWIDGET_H