diff --git a/mainwindow.cpp b/mainwindow.cpp index 15f580289..2f9397ef2 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -799,3 +799,23 @@ void MainWindow::on_actionAuto_scale_by_Default_triggered() { void MainWindow::on_actionSet_Edit_Marker_triggered() { if (sequence != NULL) panel_timeline->set_marker(); } + +void MainWindow::on_actionEnable_Disable_Clip_triggered() { + if (sequence != NULL) { + ComboAction* ca = new ComboAction(); + bool push_undo = false; + for (int i=0;iclips.size();i++) { + Clip* c = sequence->clips.at(i); + if (c != NULL && panel_timeline->is_clip_selected(c, true)) { + ca->append(new SetEnableCommand(c, !c->enabled)); + push_undo = true; + } + } + if (push_undo) { + undo_stack.push(ca); + panel_timeline->repaint_timeline(true); + } else { + delete ca; + } + } +} diff --git a/mainwindow.h b/mainwindow.h index 3c48019aa..30cb28fcf 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -188,6 +188,8 @@ private slots: void on_actionSet_Edit_Marker_triggered(); + void on_actionEnable_Disable_Clip_triggered(); + private: Ui::MainWindow *ui; void setup_layout(); diff --git a/mainwindow.ui b/mainwindow.ui index 7e9a5392e..e7829ef00 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -33,7 +33,7 @@ 0 0 653 - 16 + 20 @@ -96,6 +96,7 @@ + @@ -788,6 +789,14 @@ M + + + Enable/Disable Clip + + + Shift+E + + diff --git a/panels/project.cpp b/panels/project.cpp index 8e56d4125..3def46d78 100644 --- a/panels/project.cpp +++ b/panels/project.cpp @@ -761,6 +761,8 @@ bool Project::load_worker(QFile& f, QXmlStreamReader& stream, int type) { const QXmlStreamAttribute& attr = stream.attributes().at(j); if (attr.name() == "name") { c->name = attr.value().toString(); + } else if (attr.name() == "enabled") { + c->enabled = (attr.value() == "1"); } else if (attr.name() == "id") { c->load_id = attr.value().toInt(); } else if (attr.name() == "clipin") { @@ -1074,6 +1076,7 @@ void Project::save_folder(QXmlStreamWriter& stream, QTreeWidgetItem* parent, int if (c != NULL) { stream.writeStartElement("clip"); // clip stream.writeAttribute("id", QString::number(j)); + stream.writeAttribute("enabled", QString::number(c->enabled)); stream.writeAttribute("name", c->name); stream.writeAttribute("clipin", QString::number(c->clip_in)); stream.writeAttribute("in", QString::number(c->timeline_in)); diff --git a/project/undo.cpp b/project/undo.cpp index d89b2419a..ea582da01 100644 --- a/project/undo.cpp +++ b/project/undo.cpp @@ -1505,3 +1505,20 @@ void SetSelectionsCommand::redo() { done = true; } } + +SetEnableCommand::SetEnableCommand(Clip* c, bool enable) : + clip(c), + old_val(c->enabled), + new_val(enable), + old_project_changed(mainWindow->isWindowModified()) +{} + +void SetEnableCommand::undo() { + clip->enabled = old_val; + mainWindow->setWindowModified(old_project_changed); +} + +void SetEnableCommand::redo() { + clip->enabled = new_val; + mainWindow->setWindowModified(true); +} diff --git a/project/undo.h b/project/undo.h index bcdcc68d5..409914e1a 100644 --- a/project/undo.h +++ b/project/undo.h @@ -537,4 +537,16 @@ private: bool done; }; +class SetEnableCommand : public QUndoCommand { +public: + SetEnableCommand(Clip* c, bool enable); + void undo(); + void redo(); +private: + Clip* clip; + bool old_val; + bool new_val; + bool old_project_changed; +}; + #endif // UNDO_H diff --git a/ui/timelinewidget.cpp b/ui/timelinewidget.cpp index 7705a61a7..9bfdcc40c 100644 --- a/ui/timelinewidget.cpp +++ b/ui/timelinewidget.cpp @@ -1039,6 +1039,7 @@ void TimelineWidget::update_ghosts(QPoint& mouse_pos) { long frame_diff = panel_timeline->getTimelineFrameFromScreenPoint(mouse_pos.x()) - panel_timeline->drag_frame_start; int track_diff = ((panel_timeline->tool == TIMELINE_TOOL_SLIDE || panel_timeline->transition_select != TA_NO_TRANSITION) && !panel_timeline->importing) ? 0 : mouse_track - panel_timeline->drag_track_start; long validator; + long earliest_in_point = LONG_MAX; // first try to snap long fm; @@ -1217,6 +1218,8 @@ void TimelineWidget::update_ghosts(QPoint& mouse_pos) { g.track += track_diff; } } + + earliest_in_point = qMin(earliest_in_point, g.in); } // apply changes to selections @@ -1251,7 +1254,11 @@ void TimelineWidget::update_ghosts(QPoint& mouse_pos) { } } - QToolTip::showText(mapToGlobal(mouse_pos), ((frame_diff < 0) ? "-" : "+") + frame_to_timecode(qAbs(frame_diff), config.timecode_view, sequence->frame_rate)); + if (panel_timeline->importing) { + QToolTip::showText(mapToGlobal(mouse_pos), frame_to_timecode(earliest_in_point, config.timecode_view, sequence->frame_rate)); + } else { + QToolTip::showText(mapToGlobal(mouse_pos), ((frame_diff < 0) ? "-" : "+") + frame_to_timecode(qAbs(frame_diff), config.timecode_view, sequence->frame_rate)); + } } void TimelineWidget::mouseMoveEvent(QMouseEvent *event) { @@ -1787,7 +1794,7 @@ void TimelineWidget::paintEvent(QPaintEvent*) { QRect actual_clip_rect = clip_rect; if (actual_clip_rect.x() < 0) actual_clip_rect.setX(0); if (actual_clip_rect.right() >= width()) actual_clip_rect.setRight(width()); - p.fillRect(actual_clip_rect, QColor(clip->color_r, clip->color_g, clip->color_b)); + p.fillRect(actual_clip_rect, (clip->enabled) ? QColor(clip->color_r, clip->color_g, clip->color_b) : QColor(96, 96, 96)); int thumb_x = clip_rect.x() + 1; @@ -1944,7 +1951,9 @@ void TimelineWidget::paintEvent(QPaintEvent*) { // draw text if (text_rect.width() > MAX_TEXT_WIDTH && text_rect.right() > 0 && text_rect.left() < width()) { - if (color_brightness(clip->color_r, clip->color_g, clip->color_b) > 160) { + if (!clip->enabled) { + p.setPen(Qt::gray); + } else if (color_brightness(clip->color_r, clip->color_g, clip->color_b) > 160) { // set to black if color is bright p.setPen(Qt::black); }