timeline/block: reimplemented enabling/disabling blocks
This commit is contained in:
@@ -47,6 +47,12 @@ Block::Block() :
|
||||
media_in_input_->set_is_keyframable(false);
|
||||
AddInput(media_in_input_);
|
||||
|
||||
enabled_input_ = new NodeInput("enabled_in", NodeParam::kBoolean);
|
||||
enabled_input_->SetConnectable(false);
|
||||
enabled_input_->set_is_keyframable(false);
|
||||
enabled_input_->set_standard_value(true);
|
||||
AddInput(enabled_input_);
|
||||
|
||||
speed_input_ = new NodeInput("speed_in", NodeParam::kRational);
|
||||
speed_input_->set_standard_value(QVariant::fromValue(rational(1)));
|
||||
speed_input_->SetConnectable(false);
|
||||
@@ -168,6 +174,18 @@ bool Block::is_reversed() const
|
||||
return speed() < 0;
|
||||
}
|
||||
|
||||
bool Block::is_enabled() const
|
||||
{
|
||||
return enabled_input_->get_standard_value().toBool();
|
||||
}
|
||||
|
||||
void Block::set_enabled(bool e)
|
||||
{
|
||||
enabled_input_->set_standard_value(e);
|
||||
|
||||
emit EnabledChanged();
|
||||
}
|
||||
|
||||
QString Block::block_name() const
|
||||
{
|
||||
return name_input_->get_standard_value().toString();
|
||||
@@ -177,7 +195,7 @@ void Block::set_block_name(const QString &name)
|
||||
{
|
||||
name_input_->set_standard_value(name);
|
||||
|
||||
// FIXME: Signal the name has changed to update UI objects
|
||||
emit NameChanged();
|
||||
}
|
||||
|
||||
rational Block::SequenceToMediaTime(const rational &sequence_time) const
|
||||
|
||||
@@ -75,6 +75,9 @@ public:
|
||||
bool is_still() const;
|
||||
bool is_reversed() const;
|
||||
|
||||
bool is_enabled() const;
|
||||
void set_enabled(bool e);
|
||||
|
||||
QString block_name() const;
|
||||
void set_block_name(const QString& name);
|
||||
|
||||
@@ -110,6 +113,10 @@ signals:
|
||||
|
||||
void LinksChanged();
|
||||
|
||||
void NameChanged();
|
||||
|
||||
void EnabledChanged();
|
||||
|
||||
protected:
|
||||
rational SequenceToMediaTime(const rational& sequence_time) const;
|
||||
|
||||
@@ -127,6 +134,7 @@ private:
|
||||
NodeInput* length_input_;
|
||||
NodeInput* media_in_input_;
|
||||
NodeInput* speed_input_;
|
||||
NodeInput* enabled_input_;
|
||||
|
||||
rational in_point_;
|
||||
rational out_point_;
|
||||
|
||||
@@ -198,7 +198,11 @@ Block *TrackOutput::BlockAtTime(const rational &time) const
|
||||
if (block
|
||||
&& block->in() <= time
|
||||
&& block->out() > time) {
|
||||
return block;
|
||||
if (block->is_enabled()) {
|
||||
return block;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -153,6 +153,11 @@ void TimelinePanel::RippleDeleteInToOut()
|
||||
static_cast<TimelineWidget*>(GetTimeBasedWidget())->DeleteInToOut(true);
|
||||
}
|
||||
|
||||
void TimelinePanel::ToggleSelectedEnabled()
|
||||
{
|
||||
static_cast<TimelineWidget*>(GetTimeBasedWidget())->ToggleSelectedEnabled();
|
||||
}
|
||||
|
||||
void TimelinePanel::InsertFootageAtPlayhead(const QList<Footage *> &footage)
|
||||
{
|
||||
static_cast<TimelineWidget*>(GetTimeBasedWidget())->InsertFootageAtPlayhead(footage);
|
||||
|
||||
@@ -77,6 +77,8 @@ public:
|
||||
|
||||
virtual void RippleDeleteInToOut() override;
|
||||
|
||||
virtual void ToggleSelectedEnabled() override;
|
||||
|
||||
void InsertFootageAtPlayhead(const QList<Footage *> &footage);
|
||||
|
||||
void OverwriteFootageAtPlayhead(const QList<Footage *> &footage);
|
||||
|
||||
@@ -195,7 +195,7 @@ void MenuShared::DuplicateTriggered()
|
||||
|
||||
void MenuShared::EnableDisableTriggered()
|
||||
{
|
||||
qDebug() << "FIXME: Stub";
|
||||
PanelManager::instance()->CurrentlyFocused()->ToggleSelectedEnabled();
|
||||
}
|
||||
|
||||
void MenuShared::NestTriggered()
|
||||
|
||||
@@ -154,6 +154,8 @@ public:
|
||||
|
||||
virtual void RippleDeleteInToOut(){}
|
||||
|
||||
virtual void ToggleSelectedEnabled(){}
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief paintEvent
|
||||
|
||||
@@ -730,6 +730,25 @@ void TimelineWidget::DeleteInToOut(bool ripple)
|
||||
Core::instance()->undo_stack()->push(command);
|
||||
}
|
||||
|
||||
void TimelineWidget::ToggleSelectedEnabled()
|
||||
{
|
||||
QList<TimelineViewBlockItem*> items = GetSelectedBlocks();
|
||||
|
||||
if (items.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QUndoCommand* command = new QUndoCommand();
|
||||
|
||||
foreach (TimelineViewBlockItem* i, items) {
|
||||
new BlockEnableDisableCommand(i->block(),
|
||||
!i->block()->is_enabled(),
|
||||
command);
|
||||
}
|
||||
|
||||
Core::instance()->undo_stack()->pushIfHasChildren(command);
|
||||
}
|
||||
|
||||
QList<TimelineViewBlockItem *> TimelineWidget::GetSelectedBlocks()
|
||||
{
|
||||
QList<TimelineViewBlockItem *> list;
|
||||
@@ -988,6 +1007,8 @@ void TimelineWidget::AddBlock(Block *block, TrackReference track)
|
||||
|
||||
connect(block, &Block::Refreshed, this, &TimelineWidget::BlockChanged);
|
||||
connect(block, &Block::LinksChanged, this, &TimelineWidget::PreviewUpdated);
|
||||
connect(block, &Block::NameChanged, this, &TimelineWidget::PreviewUpdated);
|
||||
connect(block, &Block::EnabledChanged, this, &TimelineWidget::PreviewUpdated);
|
||||
|
||||
if (block->type() == Block::kClip) {
|
||||
connect(static_cast<ClipBlock*>(block), &ClipBlock::PreviewUpdated, this, &TimelineWidget::PreviewUpdated);
|
||||
|
||||
@@ -88,6 +88,8 @@ public:
|
||||
|
||||
void DeleteInToOut(bool ripple);
|
||||
|
||||
void ToggleSelectedEnabled();
|
||||
|
||||
QList<TimelineViewBlockItem*> GetSelectedBlocks();
|
||||
|
||||
signals:
|
||||
|
||||
@@ -799,4 +799,22 @@ BlockLinkManyCommand::BlockLinkManyCommand(const QList<Block *> blocks, bool lin
|
||||
}
|
||||
}
|
||||
|
||||
BlockEnableDisableCommand::BlockEnableDisableCommand(Block *block, bool enabled, QUndoCommand *parent) :
|
||||
UndoCommand(parent),
|
||||
block_(block),
|
||||
old_enabled_(block_->is_enabled()),
|
||||
new_enabled_(enabled)
|
||||
{
|
||||
}
|
||||
|
||||
void BlockEnableDisableCommand::redo_internal()
|
||||
{
|
||||
block_->set_enabled(new_enabled_);
|
||||
}
|
||||
|
||||
void BlockEnableDisableCommand::undo_internal()
|
||||
{
|
||||
block_->set_enabled(old_enabled_);
|
||||
}
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
@@ -375,6 +375,23 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class BlockEnableDisableCommand : public UndoCommand {
|
||||
public:
|
||||
BlockEnableDisableCommand(Block* block, bool enabled, QUndoCommand* parent = nullptr);
|
||||
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
Block* block_;
|
||||
|
||||
bool old_enabled_;
|
||||
|
||||
bool new_enabled_;
|
||||
|
||||
};
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
#endif // TIMELINEUNDOABLE_H
|
||||
|
||||
@@ -80,8 +80,15 @@ void TimelineViewBlockItem::paint(QPainter *painter, const QStyleOptionGraphicsI
|
||||
QLinearGradient grad;
|
||||
grad.setStart(0, rect().top());
|
||||
grad.setFinalStop(0, rect().bottom());
|
||||
grad.setColorAt(0.0, QColor(160, 160, 240));
|
||||
grad.setColorAt(1.0, QColor(128, 128, 192));
|
||||
|
||||
if (block_->is_enabled()) {
|
||||
grad.setColorAt(0.0, QColor(160, 160, 240));
|
||||
grad.setColorAt(1.0, QColor(128, 128, 192));
|
||||
} else {
|
||||
grad.setColorAt(0.0, QColor(160, 160, 160));
|
||||
grad.setColorAt(1.0, QColor(128, 128, 128));
|
||||
}
|
||||
|
||||
painter->fillRect(rect(), grad);
|
||||
|
||||
if (option->state & QStyle::State_Selected) {
|
||||
@@ -121,7 +128,12 @@ void TimelineViewBlockItem::paint(QPainter *painter, const QStyleOptionGraphicsI
|
||||
painter->drawLine(rect().topLeft(), QPointF(rect().right(), rect().top()));
|
||||
painter->drawLine(rect().topLeft(), QPointF(rect().left(), rect().bottom() - 1));
|
||||
|
||||
painter->setPen(Qt::white);
|
||||
// Draw text
|
||||
if (block_->is_enabled()) {
|
||||
painter->setPen(Qt::white);
|
||||
} else {
|
||||
painter->setPen(Qt::lightGray);
|
||||
}
|
||||
painter->drawText(rect(), static_cast<int>(Qt::AlignLeft | Qt::AlignTop), block_->block_name());
|
||||
|
||||
// Linked clips are underlined
|
||||
|
||||
Reference in New Issue
Block a user