timeline: show timecode on block items and started copy function
This commit is contained in:
@@ -120,6 +120,26 @@ void TimelinePanel::ToggleLinks()
|
||||
static_cast<TimelineWidget*>(GetTimeBasedWidget())->ToggleLinksOnSelected();
|
||||
}
|
||||
|
||||
void TimelinePanel::CutSelected()
|
||||
{
|
||||
static_cast<TimelineWidget*>(GetTimeBasedWidget())->CopySelected(true);
|
||||
}
|
||||
|
||||
void TimelinePanel::CopySelected()
|
||||
{
|
||||
static_cast<TimelineWidget*>(GetTimeBasedWidget())->CopySelected(false);
|
||||
}
|
||||
|
||||
void TimelinePanel::Paste()
|
||||
{
|
||||
static_cast<TimelineWidget*>(GetTimeBasedWidget())->Paste(false);
|
||||
}
|
||||
|
||||
void TimelinePanel::PasteInsert()
|
||||
{
|
||||
static_cast<TimelineWidget*>(GetTimeBasedWidget())->Paste(true);
|
||||
}
|
||||
|
||||
void TimelinePanel::InsertFootageAtPlayhead(const QList<Footage *> &footage)
|
||||
{
|
||||
static_cast<TimelineWidget*>(GetTimeBasedWidget())->InsertFootageAtPlayhead(footage);
|
||||
|
||||
@@ -63,6 +63,14 @@ public:
|
||||
|
||||
virtual void ToggleLinks() override;
|
||||
|
||||
virtual void CutSelected() override;
|
||||
|
||||
virtual void CopySelected() override;
|
||||
|
||||
virtual void Paste() override;
|
||||
|
||||
virtual void PasteInsert() override;
|
||||
|
||||
void InsertFootageAtPlayhead(const QList<Footage *> &footage);
|
||||
|
||||
void OverwriteFootageAtPlayhead(const QList<Footage *> &footage);
|
||||
|
||||
@@ -153,6 +153,14 @@ void TimelineWidget::TimebaseChangedEvent(const rational &timebase)
|
||||
|
||||
timecode_label_->setVisible(!timebase.isNull());
|
||||
|
||||
QMap<Block*, TimelineViewBlockItem*>::const_iterator iterator;
|
||||
|
||||
for (iterator=block_items_.begin();iterator!=block_items_.end();iterator++) {
|
||||
if (iterator.value()) {
|
||||
iterator.value()->SetTimebase(timebase);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (TimelineAndTrackView* view, views_) {
|
||||
view->view()->SetTimebase(timebase);
|
||||
}
|
||||
@@ -179,12 +187,10 @@ void TimelineWidget::ScaleChangedEvent(const double &scale)
|
||||
{
|
||||
TimeBasedWidget::ScaleChangedEvent(scale);
|
||||
|
||||
QMapIterator<Block*, TimelineViewBlockItem*> iterator(block_items_);
|
||||
QMap<Block*, TimelineViewBlockItem*>::const_iterator iterator;
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
iterator.next();
|
||||
|
||||
if (iterator.value() != nullptr) {
|
||||
for (iterator=block_items_.begin();iterator!=block_items_.end();iterator++) {
|
||||
if (iterator.value()) {
|
||||
iterator.value()->SetScale(scale);
|
||||
}
|
||||
}
|
||||
@@ -496,6 +502,61 @@ void TimelineWidget::ToggleLinksOnSelected()
|
||||
}
|
||||
}
|
||||
|
||||
void TimelineWidget::CopySelected(bool cut)
|
||||
{
|
||||
if (!GetConnectedNode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QList<TimelineViewBlockItem*> selected = GetSelectedBlocks();
|
||||
|
||||
if (selected.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QList<Node*> selected_nodes;
|
||||
|
||||
foreach (TimelineViewBlockItem* item, selected) {
|
||||
Node* block = item->block();
|
||||
|
||||
selected_nodes.append(block);
|
||||
|
||||
QList<Node*> deps = block->GetDependencies();
|
||||
|
||||
foreach (Node* d, deps) {
|
||||
if (!selected_nodes.contains(d)) {
|
||||
selected_nodes.append(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Core::instance()->CopyNodesToClipboard(selected_nodes);
|
||||
|
||||
if (cut) {
|
||||
DeleteSelected();
|
||||
}
|
||||
}
|
||||
|
||||
void TimelineWidget::Paste(bool insert)
|
||||
{
|
||||
if (!GetConnectedNode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QList<Node*> pasted = Core::instance()->PasteNodesFromClipboard(static_cast<Sequence*>(GetConnectedNode()->parent()));
|
||||
|
||||
if (insert) {
|
||||
// FIXME: Implement this
|
||||
}
|
||||
|
||||
foreach (Node* n, pasted) {
|
||||
// See if this block is a node and is a top level node
|
||||
if (n->IsBlock() && !n->output()->IsConnected()) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QList<TimelineViewBlockItem *> TimelineWidget::GetSelectedBlocks()
|
||||
{
|
||||
QList<TimelineViewBlockItem *> list;
|
||||
@@ -703,6 +764,7 @@ void TimelineWidget::AddBlock(Block *block, TrackReference track)
|
||||
item->SetYCoords(GetTrackY(track), GetTrackHeight(track));
|
||||
item->SetScale(GetScale());
|
||||
item->SetTrack(track);
|
||||
item->SetTimebase(timebase());
|
||||
|
||||
// Add to list of clip items that can be iterated through
|
||||
block_items_.insert(block, item);
|
||||
|
||||
@@ -59,6 +59,10 @@ public:
|
||||
|
||||
void ToggleLinksOnSelected();
|
||||
|
||||
void CopySelected(bool cut);
|
||||
|
||||
void Paste(bool insert);
|
||||
|
||||
QList<TimelineViewBlockItem*> GetSelectedBlocks();
|
||||
|
||||
signals:
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
|
||||
#include "common/qtutils.h"
|
||||
#include "config/config.h"
|
||||
#include "core.h"
|
||||
#include "node/block/transition/transition.h"
|
||||
#include "widget/viewer/audiowaveformview.h"
|
||||
|
||||
@@ -63,13 +64,13 @@ void TimelineViewBlockItem::UpdateRect()
|
||||
setPos(item_left, 0.0);
|
||||
|
||||
setToolTip(QCoreApplication::translate("TimelineViewBlockItem",
|
||||
"%1\n\nIn: %2\nOut: %3\nMedia In: %4").arg(block_->Name(),
|
||||
QString::number(block_->in().toDouble()),
|
||||
QString::number(block_->out().toDouble()),
|
||||
QString::number(block_->media_in().toDouble())));
|
||||
"%1\n\nIn: %2\nOut: %3\nLength: %4").arg(block_->Name(),
|
||||
Timecode::time_to_timecode(block_->in(), timebase(), Core::instance()->GetTimecodeDisplay()),
|
||||
Timecode::time_to_timecode(block_->out(), timebase(), Core::instance()->GetTimecodeDisplay()),
|
||||
Timecode::time_to_timecode(block_->out() - block_->in(), timebase(), Core::instance()->GetTimecodeDisplay())));
|
||||
}
|
||||
|
||||
void TimelineViewBlockItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
void TimelineViewBlockItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget */*widget*/)
|
||||
{
|
||||
switch (block_->type()) {
|
||||
case Block::kClip:
|
||||
|
||||
@@ -52,3 +52,10 @@ void TimelineViewRect::ScaleChangedEvent(const double &scale)
|
||||
|
||||
UpdateRect();
|
||||
}
|
||||
|
||||
void TimelineViewRect::TimebaseChangedEvent(const rational &tb)
|
||||
{
|
||||
TimelineScaledObject::TimebaseChangedEvent(tb);
|
||||
|
||||
UpdateRect();
|
||||
}
|
||||
|
||||
@@ -44,6 +44,8 @@ public:
|
||||
protected:
|
||||
virtual void ScaleChangedEvent(const double &) override;
|
||||
|
||||
virtual void TimebaseChangedEvent(const rational&) override;
|
||||
|
||||
int y_;
|
||||
|
||||
int height_;
|
||||
|
||||
Reference in New Issue
Block a user