allow track muting
This commit is contained in:
@@ -38,6 +38,10 @@ TrackOutput::TrackOutput() :
|
|||||||
connect(block_input_, SIGNAL(EdgeRemoved(NodeEdgePtr)), this, SLOT(BlockDisconnected(NodeEdgePtr)));
|
connect(block_input_, SIGNAL(EdgeRemoved(NodeEdgePtr)), this, SLOT(BlockDisconnected(NodeEdgePtr)));
|
||||||
connect(block_input_, SIGNAL(SizeChanged(int)), this, SLOT(BlockListSizeChanged(int)));
|
connect(block_input_, SIGNAL(SizeChanged(int)), this, SLOT(BlockListSizeChanged(int)));
|
||||||
|
|
||||||
|
muted_input_ = new NodeInput("muted_in");
|
||||||
|
muted_input_->set_data_type(NodeParam::kBoolean);
|
||||||
|
AddInput(muted_input_);
|
||||||
|
|
||||||
// Set default height
|
// Set default height
|
||||||
track_height_ = GetDefaultTrackHeight();
|
track_height_ = GetDefaultTrackHeight();
|
||||||
}
|
}
|
||||||
@@ -157,6 +161,10 @@ Block *TrackOutput::NearestBlockAfter(const rational &time) const
|
|||||||
|
|
||||||
Block *TrackOutput::BlockAtTime(const rational &time) const
|
Block *TrackOutput::BlockAtTime(const rational &time) const
|
||||||
{
|
{
|
||||||
|
if (IsMuted()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (Block* block, block_cache_) {
|
foreach (Block* block, block_cache_) {
|
||||||
if (block
|
if (block
|
||||||
&& block->in() <= time
|
&& block->in() <= time
|
||||||
@@ -172,6 +180,10 @@ QList<Block *> TrackOutput::BlocksAtTimeRange(const TimeRange &range) const
|
|||||||
{
|
{
|
||||||
QList<Block*> list;
|
QList<Block*> list;
|
||||||
|
|
||||||
|
if (IsMuted()) {
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (Block* block, block_cache_) {
|
foreach (Block* block, block_cache_) {
|
||||||
if (block
|
if (block
|
||||||
&& block->out() > range.in()
|
&& block->out() > range.in()
|
||||||
@@ -190,12 +202,7 @@ const QVector<Block *> &TrackOutput::Blocks() const
|
|||||||
|
|
||||||
void TrackOutput::InvalidateCache(const rational &start_range, const rational &end_range, NodeInput *from)
|
void TrackOutput::InvalidateCache(const rational &start_range, const rational &end_range, NodeInput *from)
|
||||||
{
|
{
|
||||||
/*// We intercept IC signals from Blocks since we may be performing several options and they may over-signal
|
Node::InvalidateCache(qMax(start_range, rational(0)), qMin(end_range, track_length()), from);
|
||||||
if (from == previous_input() && block_invalidate_cache_stack_ == 0) {
|
|
||||||
Node::InvalidateCache(qMax(start_range, rational(0)), qMin(end_range, in()), from);
|
|
||||||
} else {
|
|
||||||
}*/
|
|
||||||
Node::InvalidateCache(start_range, end_range, from);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackOutput::InsertBlockBefore(Block* block, Block* after)
|
void TrackOutput::InsertBlockBefore(Block* block, Block* after)
|
||||||
@@ -357,11 +364,22 @@ QString TrackOutput::GetDefaultTrackName(TrackType type, int index)
|
|||||||
return tr("Track %1").arg(user_friendly_index);
|
return tr("Track %1").arg(user_friendly_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TrackOutput::IsMuted() const
|
||||||
|
{
|
||||||
|
return muted_input_->get_value_at_time(0).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
void TrackOutput::SetTrackName(const QString &name)
|
void TrackOutput::SetTrackName(const QString &name)
|
||||||
{
|
{
|
||||||
track_name_ = name;
|
track_name_ = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TrackOutput::SetMuted(bool e)
|
||||||
|
{
|
||||||
|
muted_input_->set_value_at_time(0, e);
|
||||||
|
InvalidateCache(0, track_length());
|
||||||
|
}
|
||||||
|
|
||||||
void TrackOutput::UpdateInOutFrom(int index)
|
void TrackOutput::UpdateInOutFrom(int index)
|
||||||
{
|
{
|
||||||
Q_ASSERT(index >= 0);
|
Q_ASSERT(index >= 0);
|
||||||
|
|||||||
@@ -136,9 +136,13 @@ public:
|
|||||||
|
|
||||||
static QString GetDefaultTrackName(TrackType type, int index);
|
static QString GetDefaultTrackName(TrackType type, int index);
|
||||||
|
|
||||||
|
bool IsMuted() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void SetTrackName(const QString& name);
|
void SetTrackName(const QString& name);
|
||||||
|
|
||||||
|
void SetMuted(bool e);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
* @brief Signal emitted when a Block is added to this Track
|
* @brief Signal emitted when a Block is added to this Track
|
||||||
@@ -171,6 +175,8 @@ private:
|
|||||||
|
|
||||||
NodeInputArray* block_input_;
|
NodeInputArray* block_input_;
|
||||||
|
|
||||||
|
NodeInput* muted_input_;
|
||||||
|
|
||||||
TrackType track_type_;
|
TrackType track_type_;
|
||||||
|
|
||||||
rational track_length_;
|
rational track_length_;
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ void TrackView::ConnectTrackList(TrackList *list)
|
|||||||
|
|
||||||
if (list_ != nullptr) {
|
if (list_ != nullptr) {
|
||||||
foreach (TrackOutput* track, list_->Tracks()) {
|
foreach (TrackOutput* track, list_->Tracks()) {
|
||||||
splitter_->Insert(track->Index(), track->GetTrackHeight(), new TrackViewItem(track->GetTrackName()));
|
splitter_->Insert(track->Index(), track->GetTrackHeight(), new TrackViewItem(track));
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(list_, SIGNAL(TrackHeightChanged(int, int)), splitter_, SLOT(SetTrackHeight(int, int)));
|
connect(list_, SIGNAL(TrackHeightChanged(int, int)), splitter_, SLOT(SetTrackHeight(int, int)));
|
||||||
@@ -86,7 +86,7 @@ void TrackView::TrackHeightChanged(int index, int height)
|
|||||||
|
|
||||||
void TrackView::InsertTrack(TrackOutput *track)
|
void TrackView::InsertTrack(TrackOutput *track)
|
||||||
{
|
{
|
||||||
splitter_->Insert(track->Index(), track->GetTrackHeight(), new TrackViewItem(track->GetTrackName()));
|
splitter_->Insert(track->Index(), track->GetTrackHeight(), new TrackViewItem(track));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackView::RemoveTrack(TrackOutput *track)
|
void TrackView::RemoveTrack(TrackOutput *track)
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QtMath>
|
#include <QtMath>
|
||||||
|
|
||||||
TrackViewItem::TrackViewItem(const QString& name, Qt::Alignment alignment, QWidget *parent) :
|
TrackViewItem::TrackViewItem(TrackOutput* track, QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
alignment_(alignment)
|
track_(track)
|
||||||
{
|
{
|
||||||
QHBoxLayout* layout = new QHBoxLayout(this);
|
QHBoxLayout* layout = new QHBoxLayout(this);
|
||||||
layout->setSpacing(0);
|
layout->setSpacing(0);
|
||||||
@@ -17,7 +17,7 @@ TrackViewItem::TrackViewItem(const QString& name, Qt::Alignment alignment, QWidg
|
|||||||
stack_ = new QStackedWidget();
|
stack_ = new QStackedWidget();
|
||||||
layout->addWidget(stack_);
|
layout->addWidget(stack_);
|
||||||
|
|
||||||
label_ = new ClickableLabel(name);
|
label_ = new ClickableLabel(track_->GetTrackName());
|
||||||
connect(label_, SIGNAL(MouseDoubleClicked()), this, SLOT(LabelClicked()));
|
connect(label_, SIGNAL(MouseDoubleClicked()), this, SLOT(LabelClicked()));
|
||||||
stack_->addWidget(label_);
|
stack_->addWidget(label_);
|
||||||
|
|
||||||
@@ -27,6 +27,7 @@ TrackViewItem::TrackViewItem(const QString& name, Qt::Alignment alignment, QWidg
|
|||||||
stack_->addWidget(line_edit_);
|
stack_->addWidget(line_edit_);
|
||||||
|
|
||||||
mute_button_ = CreateMSLButton(tr("M"), Qt::red);
|
mute_button_ = CreateMSLButton(tr("M"), Qt::red);
|
||||||
|
connect(mute_button_, SIGNAL(toggled(bool)), track_, SLOT(SetMuted(bool)));
|
||||||
layout->addWidget(mute_button_);
|
layout->addWidget(mute_button_);
|
||||||
|
|
||||||
solo_button_ = CreateMSLButton(tr("S"), Qt::yellow);
|
solo_button_ = CreateMSLButton(tr("S"), Qt::yellow);
|
||||||
@@ -66,7 +67,7 @@ void TrackViewItem::LineEditConfirmed()
|
|||||||
QString line_edit_str = line_edit_->text();
|
QString line_edit_str = line_edit_->text();
|
||||||
if (!line_edit_str.isEmpty()) {
|
if (!line_edit_str.isEmpty()) {
|
||||||
label_->setText(line_edit_str);
|
label_->setText(line_edit_str);
|
||||||
emit NameChanged(line_edit_str);
|
track_->SetTrackName(line_edit_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
stack_->setCurrentWidget(label_);
|
stack_->setCurrentWidget(label_);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <QStackedWidget>
|
#include <QStackedWidget>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include "node/output/track/track.h"
|
||||||
#include "widget/clickablelabel/clickablelabel.h"
|
#include "widget/clickablelabel/clickablelabel.h"
|
||||||
#include "widget/focusablelineedit/focusablelineedit.h"
|
#include "widget/focusablelineedit/focusablelineedit.h"
|
||||||
|
|
||||||
@@ -12,18 +13,12 @@ class TrackViewItem : public QWidget
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
TrackViewItem(const QString& name,
|
TrackViewItem(TrackOutput* track,
|
||||||
Qt::Alignment alignment = Qt::AlignTop,
|
|
||||||
QWidget* parent = nullptr);
|
QWidget* parent = nullptr);
|
||||||
|
|
||||||
signals:
|
|
||||||
void NameChanged(const QString& name);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPushButton* CreateMSLButton(const QString &text, const QColor &checked_color) const;
|
QPushButton* CreateMSLButton(const QString &text, const QColor &checked_color) const;
|
||||||
|
|
||||||
Qt::Alignment alignment_;
|
|
||||||
|
|
||||||
QStackedWidget* stack_;
|
QStackedWidget* stack_;
|
||||||
|
|
||||||
ClickableLabel* label_;
|
ClickableLabel* label_;
|
||||||
@@ -33,6 +28,8 @@ private:
|
|||||||
QPushButton* solo_button_;
|
QPushButton* solo_button_;
|
||||||
QPushButton* lock_button_;
|
QPushButton* lock_button_;
|
||||||
|
|
||||||
|
TrackOutput* track_;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void LabelClicked();
|
void LabelClicked();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user