implemented auto-scaling
This commit is contained in:
+7
-2
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
+6
-1
@@ -294,7 +294,7 @@ void MainWindow::openSpeedDialog() {
|
||||
SpeedDialog s(this);
|
||||
for (int i=0;i<sequence->clips.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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
+10
-1
@@ -37,7 +37,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>653</width>
|
||||
<height>20</height>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menu_File">
|
||||
@@ -176,6 +176,7 @@
|
||||
<addaction name="actionScroll_Wheel_Zooms"/>
|
||||
<addaction name="actionRectified_Waveforms"/>
|
||||
<addaction name="actionEnable_Drag_Files_to_Timeline"/>
|
||||
<addaction name="actionAuto_scale_by_Default"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionPreferences"/>
|
||||
<addaction name="actionCrash"/>
|
||||
@@ -770,6 +771,14 @@
|
||||
<string>Enable Drag Files to Timeline</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAuto_scale_by_Default">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Auto-scale by Default</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources>
|
||||
|
||||
+9
-1
@@ -782,7 +782,11 @@ bool Project::load_worker(QFile& f, QXmlStreamReader& stream, int type) {
|
||||
//<clip id="0" name="Brock_Drying_Pan.gif" clipin="0" in="44" out="144" track="-1" r="192" g="128" b="128" media="2" stream="0">
|
||||
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;j<stream.attributes().size();j++) {
|
||||
const QXmlStreamAttribute& attr = stream.attributes().at(j);
|
||||
if (attr.name() == "name") {
|
||||
@@ -803,6 +807,8 @@ bool Project::load_worker(QFile& f, QXmlStreamReader& stream, int type) {
|
||||
c->color_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:
|
||||
|
||||
+3
-1
@@ -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;i<effects.size();i++) {
|
||||
copy->effects.append(effects.at(i)->copy(copy));
|
||||
|
||||
@@ -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;i<clips.size();i++) {
|
||||
clips.at(i)->autoscale = !clips.at(i)->autoscale;
|
||||
}
|
||||
panel_viewer->viewer_widget->update();
|
||||
}
|
||||
|
||||
void SetAutoscaleAction::redo() {
|
||||
for (int i=0;i<clips.size();i++) {
|
||||
clips.at(i)->autoscale = !clips.at(i)->autoscale;
|
||||
}
|
||||
panel_viewer->viewer_widget->update();
|
||||
}
|
||||
|
||||
@@ -441,4 +441,11 @@ private:
|
||||
bool done;
|
||||
};
|
||||
|
||||
class SetAutoscaleAction : public QUndoCommand {
|
||||
public:
|
||||
void undo();
|
||||
void redo();
|
||||
QVector<Clip*> clips;
|
||||
};
|
||||
|
||||
#endif // UNDO_H
|
||||
|
||||
@@ -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;i<sequence->clips.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;i<sequence->clips.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);
|
||||
}
|
||||
|
||||
+1
-1
@@ -58,7 +58,6 @@ private:
|
||||
QVector<Clip*> 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
|
||||
|
||||
Reference in New Issue
Block a user