style: unify identifier naming per updated conventions
Automated with clang-tidy readability-identifier-naming (config added to .clang-tidy) plus scripted passes, per the updated rules now documented in CONTRIBUTING.md: - types (class/struct/enum/alias/template params): PascalCase - functions, variables, members: snake_case (incl. rational -> Rational) - private/protected members: trailing underscore; static member variables likewise (instance_, available_themes_) - constants and enum values: snake_case (kLinear -> k_linear, F32P -> f32p); ALL_CAPS reserved for macros - macros: OAK_ prefix (OLIVE_ADD_TEST/OLIVE_ASSERT/OLIVE_CONFIG -> OAK_ADD_TEST/OAK_ASSERT/OAK_CONFIG, GL_PREAMBLE -> OAK_GL_PREAMBLE, include guards -> OAK_*) - file names: all lowercase (Current/Plugin/OliveHost/OliveClip/ OlivePluginInstance -> current/plugin/olivehost/oliveclip/ oliveplugininstance) - getters share the member name sans underscore, setters set_foo() - Qt and third-party (OpenFX) virtual overrides and framework callbacks keep their original names (exempt in .clang-tidy) Manual follow-ups required where automation could not reach: - string-based QMetaObject/SIGNAL/SLOT references updated to renamed methods (AddTask, CreatedFile, DeleteSpecificFile, moveSelectionUp, ...) - macro bodies referencing renamed methods (OLIVE_CONFIG, NODE_DEFAULT_DESTRUCTOR, MANAGEDDISPLAYWIDGET_*) - self-shadowing locals renamed where signals/methods became same-named (size_changed, worker_count, selected_items, import param, filters) - third_party OFX member/namespace usages restored (OFX::Host::*, _created, _clipPrefsDirty, createInstance, clearPersistentMessage) - STL protocol aliases restored (const_iterator) with .clang-tidy ignore rules; qHash overloads restored Full build and test suite pass: ctest 4/4, ~1960 gtest cases green.
This commit is contained in:
@@ -33,31 +33,31 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const int kDecibelStep = 6;
|
||||
const int kDecibelMinimum =
|
||||
const int k_decibel_step = 6;
|
||||
const int k_decibel_minimum =
|
||||
-198; // Must be divisible by kDecibelStep for infinity to appear
|
||||
const int kMaximumSmoothness = 8;
|
||||
const int k_maximum_smoothness = 8;
|
||||
|
||||
QVector<AudioMonitor *> AudioMonitor::instances_;
|
||||
QVector<AudioMonitor *> AudioMonitor::instances;
|
||||
|
||||
AudioMonitor::AudioMonitor(QWidget *parent)
|
||||
: QOpenGLWidget(parent)
|
||||
, waveform_(nullptr)
|
||||
, cached_channels_(0)
|
||||
{
|
||||
instances_.append(this);
|
||||
instances.append(this);
|
||||
|
||||
values_.resize(kMaximumSmoothness);
|
||||
values_.resize(k_maximum_smoothness);
|
||||
|
||||
this->setMinimumWidth(this->fontMetrics().height());
|
||||
}
|
||||
|
||||
AudioMonitor::~AudioMonitor()
|
||||
{
|
||||
instances_.removeOne(this);
|
||||
instances.removeOne(this);
|
||||
}
|
||||
|
||||
void AudioMonitor::SetParams(const AudioParams ¶ms)
|
||||
void AudioMonitor::set_params(const AudioParams ¶ms)
|
||||
{
|
||||
if (params_ != params) {
|
||||
params_ = params;
|
||||
@@ -74,7 +74,7 @@ void AudioMonitor::SetParams(const AudioParams ¶ms)
|
||||
}
|
||||
}
|
||||
|
||||
void AudioMonitor::Stop()
|
||||
void AudioMonitor::stop()
|
||||
{
|
||||
waveform_ = nullptr;
|
||||
|
||||
@@ -82,7 +82,7 @@ void AudioMonitor::Stop()
|
||||
// loop will stop itself since file_ and waveform_ are null.
|
||||
}
|
||||
|
||||
void AudioMonitor::PushSampleBuffer(const SampleBuffer &d)
|
||||
void AudioMonitor::push_sample_buffer(const SampleBuffer &d)
|
||||
{
|
||||
if (!params_.channel_count()) {
|
||||
return;
|
||||
@@ -91,7 +91,7 @@ void AudioMonitor::PushSampleBuffer(const SampleBuffer &d)
|
||||
QVector<double> v(params_.channel_count(), 0);
|
||||
|
||||
const AudioLevelMeter::Stats stats =
|
||||
AudioLevelMeter::AnalyzeSampleBuffer(d);
|
||||
AudioLevelMeter::analyze_sample_buffer(d);
|
||||
for (int i = 0; i < v.size() && i < stats.channels.size(); i++) {
|
||||
v[i] = stats.channels.at(i).peak_linear;
|
||||
}
|
||||
@@ -99,13 +99,13 @@ void AudioMonitor::PushSampleBuffer(const SampleBuffer &d)
|
||||
// Fill values because they get averaged out for smoothing
|
||||
values_.fill(v);
|
||||
|
||||
SetUpdateLoop(true);
|
||||
set_update_loop(true);
|
||||
}
|
||||
|
||||
void AudioMonitor::StartWaveform(const AudioWaveformCache *waveform,
|
||||
const rational &start, int playback_speed)
|
||||
void AudioMonitor::start_waveform(const AudioWaveformCache *waveform,
|
||||
const Rational &start, int playback_speed)
|
||||
{
|
||||
Stop();
|
||||
stop();
|
||||
|
||||
waveform_length_ = waveform->length();
|
||||
if (start >= waveform_length_) {
|
||||
@@ -119,10 +119,10 @@ void AudioMonitor::StartWaveform(const AudioWaveformCache *waveform,
|
||||
|
||||
last_time_ = QDateTime::currentMSecsSinceEpoch();
|
||||
|
||||
SetUpdateLoop(true);
|
||||
set_update_loop(true);
|
||||
}
|
||||
|
||||
void AudioMonitor::SetUpdateLoop(bool e)
|
||||
void AudioMonitor::set_update_loop(bool e)
|
||||
{
|
||||
if (e) {
|
||||
connect(this, &AudioMonitor::frameSwapped, this,
|
||||
@@ -171,7 +171,7 @@ void AudioMonitor::paintGL()
|
||||
int peaks_pos;
|
||||
int channel_size;
|
||||
int db_line_length = fm.horizontalAdvance(QStringLiteral("-"));
|
||||
int db_width = QtUtils::QFontMetricsWidth(p.fontMetrics(), "-00 ");
|
||||
int db_width = QtUtils::q_font_metrics_width(p.fontMetrics(), "-00 ");
|
||||
if (horizontal) {
|
||||
// Insert peaks area
|
||||
full_meter_rect.adjust(0, 0, -font_height, 0);
|
||||
@@ -236,16 +236,16 @@ void AudioMonitor::paintGL()
|
||||
|
||||
cached_painter.setPen(palette.text().color());
|
||||
|
||||
for (int i = 0; i >= kDecibelMinimum; i -= kDecibelStep) {
|
||||
for (int i = 0; i >= k_decibel_minimum; i -= k_decibel_step) {
|
||||
QString db_label;
|
||||
qreal log_val;
|
||||
|
||||
if (i == kDecibelMinimum) {
|
||||
if (i == k_decibel_minimum) {
|
||||
db_label = QStringLiteral("-∞ ");
|
||||
log_val = 0;
|
||||
} else {
|
||||
db_label = QStringLiteral("%1 ").arg(i);
|
||||
log_val = Decibel::toLogarithmic(i);
|
||||
log_val = Decibel::to_logarithmic(i);
|
||||
}
|
||||
|
||||
QLine db_line;
|
||||
@@ -278,7 +278,7 @@ void AudioMonitor::paintGL()
|
||||
db_labels_rect.bottom() - font_height;
|
||||
}
|
||||
|
||||
if (overlaps_infinity && i == kDecibelMinimum) {
|
||||
if (overlaps_infinity && i == k_decibel_minimum) {
|
||||
overlaps_infinity = false;
|
||||
}
|
||||
|
||||
@@ -351,7 +351,7 @@ void AudioMonitor::paintGL()
|
||||
|
||||
QVector<double> v(params_.channel_count(), 0);
|
||||
|
||||
if (IsPlaying()) {
|
||||
if (is_playing()) {
|
||||
// Determines how many milliseconds have passed since last update
|
||||
qint64 current_time = QDateTime::currentMSecsSinceEpoch();
|
||||
qint64 delta_time = current_time - last_time_;
|
||||
@@ -363,19 +363,19 @@ void AudioMonitor::paintGL()
|
||||
}
|
||||
|
||||
if (waveform_) {
|
||||
UpdateValuesFromWaveform(v, delta_time);
|
||||
update_values_from_waveform(v, delta_time);
|
||||
|
||||
if (waveform_time_ >= waveform_length_) {
|
||||
Stop();
|
||||
stop();
|
||||
}
|
||||
}
|
||||
|
||||
last_time_ = current_time;
|
||||
}
|
||||
|
||||
PushValue(v);
|
||||
push_value(v);
|
||||
|
||||
QVector<double> vals = GetAverages();
|
||||
QVector<double> vals = get_averages();
|
||||
|
||||
p.setBrush(QColor(0, 0, 0, 128));
|
||||
p.setPen(Qt::NoPen);
|
||||
@@ -394,7 +394,7 @@ void AudioMonitor::paintGL()
|
||||
}
|
||||
|
||||
// Convert val to logarithmic scale
|
||||
vol = Decibel::LinearToLogarithmic(vol);
|
||||
vol = Decibel::linear_to_logarithmic(vol);
|
||||
|
||||
QRect peaks_rect, meter_rect;
|
||||
|
||||
@@ -424,9 +424,9 @@ void AudioMonitor::paintGL()
|
||||
}
|
||||
}
|
||||
|
||||
if (all_zeroes && !IsPlaying()) {
|
||||
if (all_zeroes && !is_playing()) {
|
||||
// Optimize by disabling the update loop
|
||||
SetUpdateLoop(false);
|
||||
set_update_loop(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -436,21 +436,21 @@ void AudioMonitor::mousePressEvent(QMouseEvent *)
|
||||
update();
|
||||
}
|
||||
|
||||
void AudioMonitor::UpdateValuesFromWaveform(QVector<double> &v,
|
||||
void AudioMonitor::update_values_from_waveform(QVector<double> &v,
|
||||
qint64 delta_time)
|
||||
{
|
||||
// Delta time is provided in milliseconds, so we convert to seconds in rational
|
||||
rational length(delta_time, 1000);
|
||||
// Delta time is provided in milliseconds, so we convert to seconds in Rational
|
||||
Rational length(delta_time, 1000);
|
||||
|
||||
AudioVisualWaveform::Sample sum =
|
||||
waveform_->GetSummaryFromTime(waveform_time_, length);
|
||||
waveform_->get_summary_from_time(waveform_time_, length);
|
||||
|
||||
AudioVisualWaveformSampleToInternalValues(sum, v);
|
||||
audio_visual_waveform_sample_to_internal_values(sum, v);
|
||||
|
||||
waveform_time_ += length;
|
||||
}
|
||||
|
||||
void AudioMonitor::AudioVisualWaveformSampleToInternalValues(
|
||||
void AudioMonitor::audio_visual_waveform_sample_to_internal_values(
|
||||
const AudioVisualWaveform::Sample &in, QVector<double> &out)
|
||||
{
|
||||
for (size_t i = 0; i < in.size(); i++) {
|
||||
@@ -463,7 +463,7 @@ void AudioMonitor::AudioVisualWaveformSampleToInternalValues(
|
||||
}
|
||||
}
|
||||
|
||||
void AudioMonitor::PushValue(const QVector<double> &v)
|
||||
void AudioMonitor::push_value(const QVector<double> &v)
|
||||
{
|
||||
int lim = values_.size() - 1;
|
||||
for (int i = 0; i < lim; i++) {
|
||||
@@ -472,7 +472,7 @@ void AudioMonitor::PushValue(const QVector<double> &v)
|
||||
values_[lim] = v;
|
||||
}
|
||||
|
||||
void AudioMonitor::BytesToSampleSummary(const QByteArray &b, QVector<double> &v)
|
||||
void AudioMonitor::bytes_to_sample_summary(const QByteArray &b, QVector<double> &v)
|
||||
{
|
||||
const float *samples = reinterpret_cast<const float *>(b.constData());
|
||||
int nb_samples = b.size() / sizeof(float);
|
||||
@@ -488,7 +488,7 @@ void AudioMonitor::BytesToSampleSummary(const QByteArray &b, QVector<double> &v)
|
||||
}
|
||||
}
|
||||
|
||||
QVector<double> AudioMonitor::GetAverages() const
|
||||
QVector<double> AudioMonitor::get_averages() const
|
||||
{
|
||||
QVector<double> v(params_.channel_count(), 0);
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef AUDIOMONITORWIDGET_H
|
||||
#define AUDIOMONITORWIDGET_H
|
||||
#ifndef OAK_AUDIOMONITORWIDGET_H
|
||||
#define OAK_AUDIOMONITORWIDGET_H
|
||||
|
||||
#include <QFile>
|
||||
#include <QOpenGLWidget>
|
||||
@@ -40,42 +40,42 @@ public:
|
||||
|
||||
virtual ~AudioMonitor() override;
|
||||
|
||||
bool IsPlaying() const
|
||||
bool is_playing() const
|
||||
{
|
||||
return waveform_;
|
||||
}
|
||||
|
||||
static void StartWaveformOnAll(const AudioWaveformCache *waveform,
|
||||
const rational &start, int playback_speed)
|
||||
static void start_waveform_on_all(const AudioWaveformCache *waveform,
|
||||
const Rational &start, int playback_speed)
|
||||
{
|
||||
foreach (AudioMonitor *m, instances_) {
|
||||
m->StartWaveform(waveform, start, playback_speed);
|
||||
foreach (AudioMonitor *m, instances) {
|
||||
m->start_waveform(waveform, start, playback_speed);
|
||||
}
|
||||
}
|
||||
|
||||
static void StopOnAll()
|
||||
static void stop_on_all()
|
||||
{
|
||||
foreach (AudioMonitor *m, instances_) {
|
||||
m->Stop();
|
||||
foreach (AudioMonitor *m, instances) {
|
||||
m->stop();
|
||||
}
|
||||
}
|
||||
|
||||
static void PushSampleBufferOnAll(const SampleBuffer &d)
|
||||
static void push_sample_buffer_on_all(const SampleBuffer &d)
|
||||
{
|
||||
foreach (AudioMonitor *m, instances_) {
|
||||
m->PushSampleBuffer(d);
|
||||
foreach (AudioMonitor *m, instances) {
|
||||
m->push_sample_buffer(d);
|
||||
}
|
||||
}
|
||||
|
||||
public slots:
|
||||
void SetParams(const AudioParams ¶ms);
|
||||
void set_params(const AudioParams ¶ms);
|
||||
|
||||
void Stop();
|
||||
void stop();
|
||||
|
||||
void PushSampleBuffer(const SampleBuffer &samples);
|
||||
void push_sample_buffer(const SampleBuffer &samples);
|
||||
|
||||
void StartWaveform(const AudioWaveformCache *waveform,
|
||||
const rational &start, int playback_speed);
|
||||
void start_waveform(const AudioWaveformCache *waveform,
|
||||
const Rational &start, int playback_speed);
|
||||
|
||||
protected:
|
||||
virtual void paintGL() override;
|
||||
@@ -83,26 +83,26 @@ protected:
|
||||
virtual void mousePressEvent(QMouseEvent *event) override;
|
||||
|
||||
private:
|
||||
void SetUpdateLoop(bool e);
|
||||
void set_update_loop(bool e);
|
||||
|
||||
void UpdateValuesFromWaveform(QVector<double> &v, qint64 delta_time);
|
||||
void update_values_from_waveform(QVector<double> &v, qint64 delta_time);
|
||||
|
||||
void AudioVisualWaveformSampleToInternalValues(
|
||||
void audio_visual_waveform_sample_to_internal_values(
|
||||
const AudioVisualWaveform::Sample &in, QVector<double> &out);
|
||||
|
||||
void PushValue(const QVector<double> &v);
|
||||
void push_value(const QVector<double> &v);
|
||||
|
||||
void BytesToSampleSummary(const QByteArray &bytes, QVector<double> &v);
|
||||
void bytes_to_sample_summary(const QByteArray &bytes, QVector<double> &v);
|
||||
|
||||
QVector<double> GetAverages() const;
|
||||
QVector<double> get_averages() const;
|
||||
|
||||
AudioParams params_;
|
||||
|
||||
qint64 last_time_;
|
||||
|
||||
const AudioWaveformCache *waveform_;
|
||||
rational waveform_time_;
|
||||
rational waveform_length_;
|
||||
Rational waveform_time_;
|
||||
Rational waveform_length_;
|
||||
|
||||
int playback_speed_;
|
||||
|
||||
@@ -112,9 +112,9 @@ private:
|
||||
QPixmap cached_background_;
|
||||
int cached_channels_;
|
||||
|
||||
static QVector<AudioMonitor *> instances_;
|
||||
static QVector<AudioMonitor *> instances;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // AUDIOMONITORWIDGET_H
|
||||
#endif // OAK_AUDIOMONITORWIDGET_H
|
||||
|
||||
@@ -37,13 +37,13 @@ BezierWidget::BezierWidget(QWidget *parent)
|
||||
layout->addWidget(new QLabel(tr("Center:")), row, 0);
|
||||
|
||||
x_slider_ = new FloatSlider();
|
||||
connect(x_slider_, &FloatSlider::ValueChanged, this,
|
||||
&BezierWidget::ValueChanged);
|
||||
connect(x_slider_, &FloatSlider::value_changed, this,
|
||||
&BezierWidget::value_changed);
|
||||
layout->addWidget(x_slider_, row, 1);
|
||||
|
||||
y_slider_ = new FloatSlider();
|
||||
connect(y_slider_, &FloatSlider::ValueChanged, this,
|
||||
&BezierWidget::ValueChanged);
|
||||
connect(y_slider_, &FloatSlider::value_changed, this,
|
||||
&BezierWidget::value_changed);
|
||||
layout->addWidget(y_slider_, row, 2);
|
||||
|
||||
row++;
|
||||
@@ -58,13 +58,13 @@ BezierWidget::BezierWidget(QWidget *parent)
|
||||
bezier_layout->addWidget(new QLabel(tr("In:")), row, 0);
|
||||
|
||||
cp1_x_slider_ = new FloatSlider();
|
||||
connect(cp1_x_slider_, &FloatSlider::ValueChanged, this,
|
||||
&BezierWidget::ValueChanged);
|
||||
connect(cp1_x_slider_, &FloatSlider::value_changed, this,
|
||||
&BezierWidget::value_changed);
|
||||
bezier_layout->addWidget(cp1_x_slider_, row, 1);
|
||||
|
||||
cp1_y_slider_ = new FloatSlider();
|
||||
connect(cp1_y_slider_, &FloatSlider::ValueChanged, this,
|
||||
&BezierWidget::ValueChanged);
|
||||
connect(cp1_y_slider_, &FloatSlider::value_changed, this,
|
||||
&BezierWidget::value_changed);
|
||||
bezier_layout->addWidget(cp1_y_slider_, row, 2);
|
||||
|
||||
row++;
|
||||
@@ -72,38 +72,38 @@ BezierWidget::BezierWidget(QWidget *parent)
|
||||
bezier_layout->addWidget(new QLabel(tr("Out:")), row, 0);
|
||||
|
||||
cp2_x_slider_ = new FloatSlider();
|
||||
connect(cp2_x_slider_, &FloatSlider::ValueChanged, this,
|
||||
&BezierWidget::ValueChanged);
|
||||
connect(cp2_x_slider_, &FloatSlider::value_changed, this,
|
||||
&BezierWidget::value_changed);
|
||||
bezier_layout->addWidget(cp2_x_slider_, row, 1);
|
||||
|
||||
cp2_y_slider_ = new FloatSlider();
|
||||
connect(cp2_y_slider_, &FloatSlider::ValueChanged, this,
|
||||
&BezierWidget::ValueChanged);
|
||||
connect(cp2_y_slider_, &FloatSlider::value_changed, this,
|
||||
&BezierWidget::value_changed);
|
||||
bezier_layout->addWidget(cp2_y_slider_, row, 2);
|
||||
}
|
||||
|
||||
Bezier BezierWidget::GetValue() const
|
||||
Bezier BezierWidget::get_value() const
|
||||
{
|
||||
Bezier b;
|
||||
|
||||
b.set_x(x_slider_->GetValue());
|
||||
b.set_y(y_slider_->GetValue());
|
||||
b.set_cp1_x(cp1_x_slider_->GetValue());
|
||||
b.set_cp1_y(cp1_y_slider_->GetValue());
|
||||
b.set_cp2_x(cp2_x_slider_->GetValue());
|
||||
b.set_cp2_y(cp2_y_slider_->GetValue());
|
||||
b.set_x(x_slider_->get_value());
|
||||
b.set_y(y_slider_->get_value());
|
||||
b.set_cp1_x(cp1_x_slider_->get_value());
|
||||
b.set_cp1_y(cp1_y_slider_->get_value());
|
||||
b.set_cp2_x(cp2_x_slider_->get_value());
|
||||
b.set_cp2_y(cp2_y_slider_->get_value());
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
void BezierWidget::SetValue(const Bezier &b)
|
||||
void BezierWidget::set_value(const Bezier &b)
|
||||
{
|
||||
x_slider_->SetValue(b.x());
|
||||
y_slider_->SetValue(b.y());
|
||||
cp1_x_slider_->SetValue(b.cp1_x());
|
||||
cp1_y_slider_->SetValue(b.cp1_y());
|
||||
cp2_x_slider_->SetValue(b.cp2_x());
|
||||
cp2_y_slider_->SetValue(b.cp2_y());
|
||||
x_slider_->set_value(b.x());
|
||||
y_slider_->set_value(b.y());
|
||||
cp1_x_slider_->set_value(b.cp1_x());
|
||||
cp1_y_slider_->set_value(b.cp1_y());
|
||||
cp2_x_slider_->set_value(b.cp2_x());
|
||||
cp2_y_slider_->set_value(b.cp2_y());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef BEZIERWIDGET_H
|
||||
#define BEZIERWIDGET_H
|
||||
#ifndef OAK_BEZIERWIDGET_H
|
||||
#define OAK_BEZIERWIDGET_H
|
||||
|
||||
#include <olive/core/core.h>
|
||||
#include <QCheckBox>
|
||||
@@ -38,9 +38,9 @@ class BezierWidget : public QWidget {
|
||||
public:
|
||||
explicit BezierWidget(QWidget *parent = nullptr);
|
||||
|
||||
Bezier GetValue() const;
|
||||
Bezier get_value() const;
|
||||
|
||||
void SetValue(const Bezier &b);
|
||||
void set_value(const Bezier &b);
|
||||
|
||||
FloatSlider *x_slider() const
|
||||
{
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
}
|
||||
|
||||
signals:
|
||||
void ValueChanged();
|
||||
void value_changed();
|
||||
|
||||
private:
|
||||
FloatSlider *x_slider_;
|
||||
@@ -91,4 +91,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // BEZIERWIDGET_H
|
||||
#endif // OAK_BEZIERWIDGET_H
|
||||
|
||||
@@ -39,14 +39,14 @@ ClickableLabel::ClickableLabel(QWidget *parent)
|
||||
void ClickableLabel::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton && underMouse()) {
|
||||
emit MouseClicked();
|
||||
emit mouse_clicked();
|
||||
}
|
||||
}
|
||||
|
||||
void ClickableLabel::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
emit MouseDoubleClicked();
|
||||
emit mouse_double_clicked();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef CLICKABLELABEL_H
|
||||
#define CLICKABLELABEL_H
|
||||
#ifndef OAK_CLICKABLELABEL_H
|
||||
#define OAK_CLICKABLELABEL_H
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
@@ -40,10 +40,10 @@ protected:
|
||||
virtual void mouseDoubleClickEvent(QMouseEvent *event) override;
|
||||
|
||||
signals:
|
||||
void MouseClicked();
|
||||
void MouseDoubleClicked();
|
||||
void mouse_clicked();
|
||||
void mouse_double_clicked();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // CLICKABLELABEL_H
|
||||
#endif // OAK_CLICKABLELABEL_H
|
||||
|
||||
@@ -35,17 +35,17 @@ CollapseButton::CollapseButton(QWidget *parent)
|
||||
setChecked(true);
|
||||
setIconSize(QSize(fontMetrics().height() / 2, fontMetrics().height() / 2));
|
||||
|
||||
connect(this, &CollapseButton::toggled, this, &CollapseButton::UpdateIcon);
|
||||
connect(this, &CollapseButton::toggled, this, &CollapseButton::update_icon);
|
||||
|
||||
UpdateIcon(isChecked());
|
||||
update_icon(isChecked());
|
||||
}
|
||||
|
||||
void CollapseButton::UpdateIcon(bool e)
|
||||
void CollapseButton::update_icon(bool e)
|
||||
{
|
||||
if (e) {
|
||||
setIcon(icon::TriDown);
|
||||
setIcon(icon::tri_down);
|
||||
} else {
|
||||
setIcon(icon::TriRight);
|
||||
setIcon(icon::tri_right);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef COLLAPSEBUTTON_H
|
||||
#define COLLAPSEBUTTON_H
|
||||
#ifndef OAK_COLLAPSEBUTTON_H
|
||||
#define OAK_COLLAPSEBUTTON_H
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
@@ -35,9 +35,9 @@ public:
|
||||
CollapseButton(QWidget *parent = nullptr);
|
||||
|
||||
private slots:
|
||||
void UpdateIcon(bool e);
|
||||
void update_icon(bool e);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // COLLAPSEBUTTON_H
|
||||
#endif // OAK_COLLAPSEBUTTON_H
|
||||
|
||||
@@ -37,52 +37,52 @@ ColorButton::ColorButton(ColorManager *color_manager, bool show_dialog_on_click,
|
||||
|
||||
if (show_dialog_on_click) {
|
||||
connect(this, &ColorButton::clicked, this,
|
||||
&ColorButton::ShowColorDialog);
|
||||
&ColorButton::show_color_dialog);
|
||||
}
|
||||
|
||||
SetColor(Color(1.0f, 1.0f, 1.0f));
|
||||
set_color(Color(1.0f, 1.0f, 1.0f));
|
||||
}
|
||||
|
||||
const ManagedColor &ColorButton::GetColor() const
|
||||
const ManagedColor &ColorButton::get_color() const
|
||||
{
|
||||
return color_;
|
||||
}
|
||||
|
||||
void ColorButton::SetColor(const ManagedColor &c)
|
||||
void ColorButton::set_color(const ManagedColor &c)
|
||||
{
|
||||
color_ = c;
|
||||
|
||||
color_.set_color_input(
|
||||
color_manager_->GetCompliantColorSpace(color_.color_input()));
|
||||
color_manager_->get_compliant_color_space(color_.color_input()));
|
||||
color_.set_color_output(
|
||||
color_manager_->GetCompliantColorSpace(color_.color_output()));
|
||||
color_manager_->get_compliant_color_space(color_.color_output()));
|
||||
|
||||
UpdateColor();
|
||||
update_color();
|
||||
}
|
||||
|
||||
void ColorButton::ShowColorDialog()
|
||||
void ColorButton::show_color_dialog()
|
||||
{
|
||||
if (!dialog_open_) {
|
||||
dialog_open_ = true;
|
||||
ColorDialog *cd = new ColorDialog(color_manager_, color_, this);
|
||||
|
||||
connect(cd, &ColorDialog::finished, this,
|
||||
&ColorButton::ColorDialogFinished);
|
||||
&ColorButton::color_dialog_finished);
|
||||
|
||||
cd->show();
|
||||
}
|
||||
}
|
||||
|
||||
void ColorButton::ColorDialogFinished(int e)
|
||||
void ColorButton::color_dialog_finished(int e)
|
||||
{
|
||||
ColorDialog *cd = static_cast<ColorDialog *>(sender());
|
||||
|
||||
if (e == QDialog::Accepted) {
|
||||
color_ = cd->GetSelectedColor();
|
||||
color_ = cd->get_selected_color();
|
||||
|
||||
UpdateColor();
|
||||
update_color();
|
||||
|
||||
emit ColorChanged(color_);
|
||||
emit color_changed(color_);
|
||||
}
|
||||
|
||||
cd->deleteLater();
|
||||
@@ -90,12 +90,12 @@ void ColorButton::ColorDialogFinished(int e)
|
||||
dialog_open_ = false;
|
||||
}
|
||||
|
||||
void ColorButton::UpdateColor()
|
||||
void ColorButton::update_color()
|
||||
{
|
||||
color_processor_ = ColorProcessor::Create(
|
||||
color_processor_ = ColorProcessor::create(
|
||||
color_manager_, color_.color_input(), color_.color_output());
|
||||
|
||||
QColor managed = QtUtils::toQColor(color_processor_->ConvertColor(color_));
|
||||
QColor managed = QtUtils::to_q_color(color_processor_->convert_color(color_));
|
||||
|
||||
setStyleSheet(QStringLiteral("%1--ColorButton {background: %2;}")
|
||||
.arg(MACRO_VAL_AS_STR(olive), managed.name()));
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef COLORBUTTON_H
|
||||
#define COLORBUTTON_H
|
||||
#ifndef OAK_COLORBUTTON_H
|
||||
#define OAK_COLORBUTTON_H
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
@@ -40,21 +40,21 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
const ManagedColor &GetColor() const;
|
||||
const ManagedColor &get_color() const;
|
||||
|
||||
public slots:
|
||||
void SetColor(const ManagedColor &c);
|
||||
void set_color(const ManagedColor &c);
|
||||
|
||||
signals:
|
||||
void ColorChanged(const ManagedColor &c);
|
||||
void color_changed(const ManagedColor &c);
|
||||
|
||||
private slots:
|
||||
void ShowColorDialog();
|
||||
void show_color_dialog();
|
||||
|
||||
void ColorDialogFinished(int e);
|
||||
void color_dialog_finished(int e);
|
||||
|
||||
private:
|
||||
void UpdateColor();
|
||||
void update_color();
|
||||
|
||||
ColorManager *color_manager_;
|
||||
|
||||
@@ -67,4 +67,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // COLORBUTTON_H
|
||||
#endif // OAK_COLORBUTTON_H
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace olive
|
||||
ColorCodingComboBox::ColorCodingComboBox(QWidget *parent)
|
||||
: QComboBox(parent)
|
||||
{
|
||||
SetColor(0);
|
||||
set_color(0);
|
||||
}
|
||||
|
||||
void ColorCodingComboBox::showPopup()
|
||||
@@ -41,14 +41,14 @@ void ColorCodingComboBox::showPopup()
|
||||
QAction *a = menu.exec(parentWidget()->mapToGlobal(pos()));
|
||||
|
||||
if (a) {
|
||||
SetColor(a->data().toInt());
|
||||
set_color(a->data().toInt());
|
||||
}
|
||||
}
|
||||
|
||||
void ColorCodingComboBox::SetColor(int index)
|
||||
void ColorCodingComboBox::set_color(int index)
|
||||
{
|
||||
clear();
|
||||
addItem(ColorCoding::GetColorName(index));
|
||||
addItem(ColorCoding::get_color_name(index));
|
||||
index_ = index;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef COLORCODINGCOMBOBOX_H
|
||||
#define COLORCODINGCOMBOBOX_H
|
||||
#ifndef OAK_COLORCODINGCOMBOBOX_H
|
||||
#define OAK_COLORCODINGCOMBOBOX_H
|
||||
|
||||
#include <QComboBox>
|
||||
|
||||
@@ -36,9 +36,9 @@ public:
|
||||
|
||||
virtual void showPopup() override;
|
||||
|
||||
void SetColor(int index);
|
||||
void set_color(int index);
|
||||
|
||||
int GetSelectedColor() const
|
||||
int get_selected_color() const
|
||||
{
|
||||
return index_;
|
||||
}
|
||||
@@ -49,4 +49,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // COLORCODINGCOMBOBOX_H
|
||||
#endif // OAK_COLORCODINGCOMBOBOX_H
|
||||
|
||||
@@ -44,41 +44,41 @@ ColorLabelMenu::ColorLabelMenu(QWidget *parent)
|
||||
QPainter painter(&p);
|
||||
painter.setPen(Qt::black);
|
||||
painter.setBrush(
|
||||
QtUtils::toQColor(ColorCoding::standard_colors().at(i)));
|
||||
QtUtils::to_q_color(ColorCoding::standard_colors().at(i)));
|
||||
painter.drawRect(p.rect().adjusted(0, 0, -1, -1));
|
||||
|
||||
QAction *a = AddItem(QStringLiteral("colorlabel%1").arg(i), this,
|
||||
&ColorLabelMenu::ActionTriggered);
|
||||
QAction *a = add_item(QStringLiteral("colorlabel%1").arg(i), this,
|
||||
&ColorLabelMenu::action_triggered);
|
||||
a->setIcon(p);
|
||||
a->setData(i);
|
||||
color_items_.replace(i, a);
|
||||
}
|
||||
|
||||
Retranslate();
|
||||
retranslate();
|
||||
}
|
||||
|
||||
void ColorLabelMenu::changeEvent(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::LanguageChange) {
|
||||
Retranslate();
|
||||
retranslate();
|
||||
}
|
||||
|
||||
Menu::changeEvent(event);
|
||||
}
|
||||
|
||||
void ColorLabelMenu::Retranslate()
|
||||
void ColorLabelMenu::retranslate()
|
||||
{
|
||||
this->setTitle(tr("Color"));
|
||||
|
||||
for (int i = 0; i < color_items_.size(); i++) {
|
||||
color_items_.at(i)->setText(ColorCoding::GetColorName(i));
|
||||
color_items_.at(i)->setText(ColorCoding::get_color_name(i));
|
||||
}
|
||||
}
|
||||
|
||||
void ColorLabelMenu::ActionTriggered()
|
||||
void ColorLabelMenu::action_triggered()
|
||||
{
|
||||
QAction *a = static_cast<QAction *>(sender());
|
||||
emit ColorSelected(a->data().toInt());
|
||||
emit color_selected(a->data().toInt());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef COLORLABELMENU_H
|
||||
#define COLORLABELMENU_H
|
||||
#ifndef OAK_COLORLABELMENU_H
|
||||
#define OAK_COLORLABELMENU_H
|
||||
|
||||
#include "widget/menu/menu.h"
|
||||
|
||||
@@ -35,17 +35,17 @@ public:
|
||||
virtual void changeEvent(QEvent *event) override;
|
||||
|
||||
signals:
|
||||
void ColorSelected(int i);
|
||||
void color_selected(int i);
|
||||
|
||||
private:
|
||||
void Retranslate();
|
||||
void retranslate();
|
||||
|
||||
QVector<QAction *> color_items_;
|
||||
|
||||
private slots:
|
||||
void ActionTriggered();
|
||||
void action_triggered();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // COLORLABELMENU_H
|
||||
#endif // OAK_COLORLABELMENU_H
|
||||
|
||||
@@ -37,12 +37,12 @@ ColorGradientWidget::ColorGradientWidget(Qt::Orientation orientation,
|
||||
{
|
||||
}
|
||||
|
||||
Color ColorGradientWidget::GetColorFromScreenPos(const QPoint &p) const
|
||||
Color ColorGradientWidget::get_color_from_screen_pos(const QPoint &p) const
|
||||
{
|
||||
if (orientation_ == Qt::Horizontal) {
|
||||
return LerpColor(start_, end_, p.x(), width());
|
||||
return lerp_color(start_, end_, p.x(), width());
|
||||
} else {
|
||||
return LerpColor(start_, end_, p.y(), height());
|
||||
return lerp_color(start_, end_, p.y(), height());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,8 +64,8 @@ void ColorGradientWidget::paintEvent(QPaintEvent *e)
|
||||
}
|
||||
|
||||
for (int i = 0; i < max; i++) {
|
||||
p.setPen(QtUtils::toQColor(
|
||||
GetManagedColor(LerpColor(start_, end_, i, max))));
|
||||
p.setPen(QtUtils::to_q_color(
|
||||
get_managed_color(lerp_color(start_, end_, i, max))));
|
||||
|
||||
if (orientation_ == Qt::Horizontal) {
|
||||
p.drawLine(i, 0, i, height());
|
||||
@@ -76,7 +76,7 @@ void ColorGradientWidget::paintEvent(QPaintEvent *e)
|
||||
|
||||
// Draw selector
|
||||
int selector_radius = qMax(2, min / 8);
|
||||
p.setPen(QPen(GetUISelectorColor(), qMax(1, selector_radius / 2)));
|
||||
p.setPen(QPen(get_ui_selector_color(), qMax(1, selector_radius / 2)));
|
||||
p.setBrush(Qt::NoBrush);
|
||||
|
||||
float clamped_val = std::clamp(val_, 0.0f, 1.0f);
|
||||
@@ -95,15 +95,15 @@ void ColorGradientWidget::SelectedColorChangedEvent(const Color &c,
|
||||
{
|
||||
float hue, sat;
|
||||
|
||||
c.toHsv(&hue, &sat, &val_);
|
||||
c.to_hsv(&hue, &sat, &val_);
|
||||
|
||||
if (external) {
|
||||
start_ = Color::fromHsv(hue, sat, 1.0);
|
||||
end_ = Color::fromHsv(hue, sat, 0.0);
|
||||
start_ = Color::from_hsv(hue, sat, 1.0);
|
||||
end_ = Color::from_hsv(hue, sat, 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
Color ColorGradientWidget::LerpColor(const Color &a, const Color &b, int i,
|
||||
Color ColorGradientWidget::lerp_color(const Color &a, const Color &b, int i,
|
||||
int max)
|
||||
{
|
||||
float t =
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef COLORGRADIENTGLWIDGET_H
|
||||
#define COLORGRADIENTGLWIDGET_H
|
||||
#ifndef OAK_COLORGRADIENTGLWIDGET_H
|
||||
#define OAK_COLORGRADIENTGLWIDGET_H
|
||||
|
||||
#include "colorswatchwidget.h"
|
||||
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
ColorGradientWidget(Qt::Orientation orientation, QWidget *parent = nullptr);
|
||||
|
||||
protected:
|
||||
virtual Color GetColorFromScreenPos(const QPoint &p) const override;
|
||||
virtual Color get_color_from_screen_pos(const QPoint &p) const override;
|
||||
|
||||
virtual void paintEvent(QPaintEvent *e) override;
|
||||
|
||||
@@ -41,7 +41,7 @@ protected:
|
||||
bool external) override;
|
||||
|
||||
private:
|
||||
static Color LerpColor(const Color &a, const Color &b, int i, int max);
|
||||
static Color lerp_color(const Color &a, const Color &b, int i, int max);
|
||||
|
||||
QPixmap cached_gradient_;
|
||||
|
||||
@@ -56,4 +56,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // COLORGRADIENTGLWIDGET_H
|
||||
#endif // OAK_COLORGRADIENTGLWIDGET_H
|
||||
|
||||
@@ -35,7 +35,7 @@ ColorPreviewBox::ColorPreviewBox(QWidget *parent)
|
||||
{
|
||||
}
|
||||
|
||||
void ColorPreviewBox::SetColorProcessor(ColorProcessorPtr to_ref,
|
||||
void ColorPreviewBox::set_color_processor(ColorProcessorPtr to_ref,
|
||||
ColorProcessorPtr to_display)
|
||||
{
|
||||
to_ref_processor_ = to_ref;
|
||||
@@ -44,7 +44,7 @@ void ColorPreviewBox::SetColorProcessor(ColorProcessorPtr to_ref,
|
||||
update();
|
||||
}
|
||||
|
||||
void ColorPreviewBox::SetColor(const Color &c)
|
||||
void ColorPreviewBox::set_color(const Color &c)
|
||||
{
|
||||
color_ = c;
|
||||
update();
|
||||
@@ -58,10 +58,10 @@ void ColorPreviewBox::paintEvent(QPaintEvent *e)
|
||||
|
||||
// Color management
|
||||
if (to_ref_processor_ && to_display_processor_) {
|
||||
c = QtUtils::toQColor(to_display_processor_->ConvertColor(
|
||||
to_ref_processor_->ConvertColor(color_)));
|
||||
c = QtUtils::to_q_color(to_display_processor_->convert_color(
|
||||
to_ref_processor_->convert_color(color_)));
|
||||
} else {
|
||||
c = QtUtils::toQColor(color_);
|
||||
c = QtUtils::to_q_color(color_);
|
||||
}
|
||||
|
||||
QPainter p(this);
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef COLORPREVIEWBOX_H
|
||||
#define COLORPREVIEWBOX_H
|
||||
#ifndef OAK_COLORPREVIEWBOX_H
|
||||
#define OAK_COLORPREVIEWBOX_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
@@ -34,11 +34,11 @@ class ColorPreviewBox : public QWidget {
|
||||
public:
|
||||
ColorPreviewBox(QWidget *parent = nullptr);
|
||||
|
||||
void SetColorProcessor(ColorProcessorPtr to_ref,
|
||||
void set_color_processor(ColorProcessorPtr to_ref,
|
||||
ColorProcessorPtr to_display);
|
||||
|
||||
public slots:
|
||||
void SetColor(const Color &c);
|
||||
void set_color(const Color &c);
|
||||
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent *e) override;
|
||||
@@ -53,4 +53,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // COLORPREVIEWBOX_H
|
||||
#endif // OAK_COLORPREVIEWBOX_H
|
||||
|
||||
@@ -56,19 +56,19 @@ ColorSpaceChooser::ColorSpaceChooser(ColorManager *color_manager,
|
||||
input_combobox_ = new QComboBox();
|
||||
layout->addWidget(input_combobox_, row, 1);
|
||||
|
||||
QStringList input_spaces = color_manager->ListAvailableColorspaces();
|
||||
QStringList input_spaces = color_manager->list_available_colorspaces();
|
||||
|
||||
foreach (const QString &s, input_spaces) {
|
||||
input_combobox_->addItem(s);
|
||||
}
|
||||
|
||||
if (!color_manager_->GetDefaultInputColorSpace().isEmpty()) {
|
||||
if (!color_manager_->get_default_input_color_space().isEmpty()) {
|
||||
input_combobox_->setCurrentText(
|
||||
color_manager_->GetDefaultInputColorSpace());
|
||||
color_manager_->get_default_input_color_space());
|
||||
}
|
||||
|
||||
connect(input_combobox_, &QComboBox::currentTextChanged, this,
|
||||
&ColorSpaceChooser::ComboBoxChanged);
|
||||
&ColorSpaceChooser::combo_box_changed);
|
||||
|
||||
row++;
|
||||
} else {
|
||||
@@ -82,17 +82,17 @@ ColorSpaceChooser::ColorSpaceChooser(ColorManager *color_manager,
|
||||
display_combobox_ = new QComboBox();
|
||||
layout->addWidget(display_combobox_, row, 1);
|
||||
|
||||
QStringList display_spaces = color_manager->ListAvailableDisplays();
|
||||
QStringList display_spaces = color_manager->list_available_displays();
|
||||
|
||||
foreach (const QString &s, display_spaces) {
|
||||
display_combobox_->addItem(s);
|
||||
}
|
||||
|
||||
display_combobox_->setCurrentText(
|
||||
color_manager_->GetDefaultDisplay());
|
||||
color_manager_->get_default_display());
|
||||
|
||||
connect(display_combobox_, &QComboBox::currentTextChanged, this,
|
||||
&ColorSpaceChooser::ComboBoxChanged);
|
||||
&ColorSpaceChooser::combo_box_changed);
|
||||
}
|
||||
|
||||
row++;
|
||||
@@ -103,10 +103,10 @@ ColorSpaceChooser::ColorSpaceChooser(ColorManager *color_manager,
|
||||
view_combobox_ = new QComboBox();
|
||||
layout->addWidget(view_combobox_, row, 1);
|
||||
|
||||
UpdateViews(display_combobox_->currentText());
|
||||
update_views(display_combobox_->currentText());
|
||||
|
||||
connect(view_combobox_, &QComboBox::currentTextChanged, this,
|
||||
&ColorSpaceChooser::ComboBoxChanged);
|
||||
&ColorSpaceChooser::combo_box_changed);
|
||||
}
|
||||
|
||||
row++;
|
||||
@@ -117,7 +117,7 @@ ColorSpaceChooser::ColorSpaceChooser(ColorManager *color_manager,
|
||||
look_combobox_ = new QComboBox();
|
||||
layout->addWidget(look_combobox_, row, 1);
|
||||
|
||||
QStringList looks = color_manager->ListAvailableLooks();
|
||||
QStringList looks = color_manager->list_available_looks();
|
||||
|
||||
look_combobox_->addItem(tr("(None)"), QString());
|
||||
|
||||
@@ -126,7 +126,7 @@ ColorSpaceChooser::ColorSpaceChooser(ColorManager *color_manager,
|
||||
}
|
||||
|
||||
connect(look_combobox_, &QComboBox::currentTextChanged, this,
|
||||
&ColorSpaceChooser::ComboBoxChanged);
|
||||
&ColorSpaceChooser::combo_box_changed);
|
||||
}
|
||||
} else {
|
||||
display_combobox_ = nullptr;
|
||||
@@ -155,12 +155,12 @@ ColorTransform ColorSpaceChooser::output() const
|
||||
|
||||
void ColorSpaceChooser::set_input(const QString &s)
|
||||
{
|
||||
input_combobox_->setCurrentText(color_manager_->GetCompliantColorSpace(s));
|
||||
input_combobox_->setCurrentText(color_manager_->get_compliant_color_space(s));
|
||||
}
|
||||
|
||||
void ColorSpaceChooser::set_output(const ColorTransform &out)
|
||||
{
|
||||
ColorTransform compliant = color_manager_->GetCompliantColorSpace(out);
|
||||
ColorTransform compliant = color_manager_->get_compliant_color_space(out);
|
||||
|
||||
display_combobox_->setCurrentText(compliant.display());
|
||||
view_combobox_->setCurrentText(compliant.view());
|
||||
@@ -172,13 +172,13 @@ void ColorSpaceChooser::set_output(const ColorTransform &out)
|
||||
}
|
||||
}
|
||||
|
||||
void ColorSpaceChooser::UpdateViews(const QString &display)
|
||||
void ColorSpaceChooser::update_views(const QString &display)
|
||||
{
|
||||
QString v = view_combobox_->currentText();
|
||||
|
||||
view_combobox_->clear();
|
||||
|
||||
QStringList views = color_manager_->ListAvailableViews(display);
|
||||
QStringList views = color_manager_->list_available_views(display);
|
||||
|
||||
foreach (const QString &s, views) {
|
||||
view_combobox_->addItem(s);
|
||||
@@ -189,26 +189,26 @@ void ColorSpaceChooser::UpdateViews(const QString &display)
|
||||
view_combobox_->setCurrentText(v);
|
||||
} else {
|
||||
// Otherwise reset to default view for this display
|
||||
view_combobox_->setCurrentText(color_manager_->GetDefaultView(display));
|
||||
view_combobox_->setCurrentText(color_manager_->get_default_view(display));
|
||||
}
|
||||
}
|
||||
|
||||
void ColorSpaceChooser::ComboBoxChanged()
|
||||
void ColorSpaceChooser::combo_box_changed()
|
||||
{
|
||||
if (sender() == display_combobox_) {
|
||||
UpdateViews(display_combobox_->currentText());
|
||||
update_views(display_combobox_->currentText());
|
||||
}
|
||||
|
||||
if (input_combobox_) {
|
||||
emit InputColorSpaceChanged(input());
|
||||
emit input_color_space_changed(input());
|
||||
}
|
||||
|
||||
if (display_combobox_) {
|
||||
emit OutputColorSpaceChanged(output());
|
||||
emit output_color_space_changed(output());
|
||||
}
|
||||
|
||||
if (input_combobox_ && display_combobox_) {
|
||||
emit ColorSpaceChanged(input(), output());
|
||||
emit color_space_changed(input(), output());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef COLORSPACECHOOSER_H
|
||||
#define COLORSPACECHOOSER_H
|
||||
#ifndef OAK_COLORSPACECHOOSER_H
|
||||
#define OAK_COLORSPACECHOOSER_H
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QGroupBox>
|
||||
@@ -45,14 +45,14 @@ public:
|
||||
void set_output(const ColorTransform &out);
|
||||
|
||||
signals:
|
||||
void InputColorSpaceChanged(const QString &input);
|
||||
void input_color_space_changed(const QString &input);
|
||||
|
||||
void OutputColorSpaceChanged(const ColorTransform &out);
|
||||
void output_color_space_changed(const ColorTransform &out);
|
||||
|
||||
void ColorSpaceChanged(const QString &input, const ColorTransform &out);
|
||||
void color_space_changed(const QString &input, const ColorTransform &out);
|
||||
|
||||
private slots:
|
||||
void UpdateViews(const QString &display);
|
||||
void update_views(const QString &display);
|
||||
|
||||
private:
|
||||
ColorManager *color_manager_;
|
||||
@@ -66,9 +66,9 @@ private:
|
||||
QComboBox *look_combobox_;
|
||||
|
||||
private slots:
|
||||
void ComboBoxChanged();
|
||||
void combo_box_changed();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // COLORSPACECHOOSER_H
|
||||
#endif // OAK_COLORSPACECHOOSER_H
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const int kDefaultColorCount = 16;
|
||||
const Color kDefaultColors[kDefaultColorCount] = {
|
||||
const int k_default_color_count = 16;
|
||||
const Color k_default_colors[k_default_color_count] = {
|
||||
Color(1.0, 1.0, 1.0), Color(1.0, 1.0, 0.0), Color(1.0, 0.5, 0.0),
|
||||
Color(1.0, 0.0, 0.0), Color(1.0, 0.0, 1.0), Color(0.5, 0.0, 1.0),
|
||||
Color(0.0, 0.0, 1.0), Color(0.0, 0.5, 1.0), Color(0.0, 1.0, 0.0),
|
||||
@@ -44,8 +44,8 @@ ColorSwatchChooser::ColorSwatchChooser(ColorManager *manager, QWidget *parent)
|
||||
{
|
||||
auto layout = new QGridLayout(this);
|
||||
|
||||
for (int x = 0; x < kColCount; x++) {
|
||||
for (int y = 0; y < kRowCount; y++) {
|
||||
for (int x = 0; x < k_col_count; x++) {
|
||||
for (int y = 0; y < k_row_count; y++) {
|
||||
// Create button
|
||||
auto b = new ColorButton(manager, false);
|
||||
b->setFixedWidth(b->sizeHint().height() / 2 * 3);
|
||||
@@ -53,85 +53,85 @@ ColorSwatchChooser::ColorSwatchChooser(ColorManager *manager, QWidget *parent)
|
||||
layout->addWidget(b, y, x);
|
||||
|
||||
// Save button in buttons array
|
||||
int btn_index = x + kColCount * y;
|
||||
int btn_index = x + k_col_count * y;
|
||||
buttons_[btn_index] = b;
|
||||
|
||||
// Set default color
|
||||
SetDefaultColor(btn_index);
|
||||
set_default_color(btn_index);
|
||||
|
||||
// Connect clicks
|
||||
connect(b, &ColorButton::clicked, this,
|
||||
&ColorSwatchChooser::HandleButtonClick);
|
||||
&ColorSwatchChooser::handle_button_click);
|
||||
connect(b, &ColorButton::customContextMenuRequested, this,
|
||||
&ColorSwatchChooser::HandleContextMenu);
|
||||
&ColorSwatchChooser::handle_context_menu);
|
||||
}
|
||||
}
|
||||
|
||||
LoadSwatches();
|
||||
load_swatches();
|
||||
}
|
||||
|
||||
void ColorSwatchChooser::SetDefaultColor(int index)
|
||||
void ColorSwatchChooser::set_default_color(int index)
|
||||
{
|
||||
if (index < kDefaultColorCount) {
|
||||
buttons_[index]->SetColor(kDefaultColors[index]);
|
||||
if (index < k_default_color_count) {
|
||||
buttons_[index]->set_color(k_default_colors[index]);
|
||||
} else {
|
||||
buttons_[index]->SetColor(Color(1.0, 1.0, 1.0));
|
||||
buttons_[index]->set_color(Color(1.0, 1.0, 1.0));
|
||||
}
|
||||
}
|
||||
|
||||
void ColorSwatchChooser::HandleButtonClick()
|
||||
void ColorSwatchChooser::handle_button_click()
|
||||
{
|
||||
auto b = static_cast<ColorButton *>(sender());
|
||||
|
||||
emit ColorClicked(b->GetColor());
|
||||
SetCurrentColor(b->GetColor());
|
||||
emit color_clicked(b->get_color());
|
||||
set_current_color(b->get_color());
|
||||
}
|
||||
|
||||
void ColorSwatchChooser::HandleContextMenu()
|
||||
void ColorSwatchChooser::handle_context_menu()
|
||||
{
|
||||
Menu m(this);
|
||||
|
||||
auto save_action = m.addAction(tr("Save Color Here"));
|
||||
connect(save_action, &QAction::triggered, this,
|
||||
&ColorSwatchChooser::SaveCurrentColor);
|
||||
&ColorSwatchChooser::save_current_color);
|
||||
|
||||
m.addSeparator();
|
||||
|
||||
auto reset_action = m.addAction(tr("Reset To Default"));
|
||||
connect(reset_action, &QAction::triggered, this,
|
||||
&ColorSwatchChooser::ResetMenuButton);
|
||||
&ColorSwatchChooser::reset_menu_button);
|
||||
|
||||
menu_btn_ = static_cast<ColorButton *>(sender());
|
||||
|
||||
m.exec(QCursor::pos());
|
||||
}
|
||||
|
||||
void ColorSwatchChooser::SaveCurrentColor()
|
||||
void ColorSwatchChooser::save_current_color()
|
||||
{
|
||||
menu_btn_->SetColor(current_);
|
||||
menu_btn_->set_color(current_);
|
||||
|
||||
SaveSwatches();
|
||||
save_swatches();
|
||||
}
|
||||
|
||||
void ColorSwatchChooser::ResetMenuButton()
|
||||
void ColorSwatchChooser::reset_menu_button()
|
||||
{
|
||||
for (int i = 0; i < kBtnCount; i++) {
|
||||
for (int i = 0; i < k_btn_count; i++) {
|
||||
if (buttons_[i] == menu_btn_) {
|
||||
SetDefaultColor(i);
|
||||
set_default_color(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString ColorSwatchChooser::GetSwatchFilename()
|
||||
QString ColorSwatchChooser::get_swatch_filename()
|
||||
{
|
||||
return QDir(FileFunctions::GetConfigurationLocation())
|
||||
return QDir(FileFunctions::get_configuration_location())
|
||||
.filePath(QStringLiteral("swatch"));
|
||||
}
|
||||
|
||||
void ColorSwatchChooser::LoadSwatches()
|
||||
void ColorSwatchChooser::load_swatches()
|
||||
{
|
||||
QFile f(GetSwatchFilename());
|
||||
QFile f(get_swatch_filename());
|
||||
if (f.open(QFile::ReadOnly)) {
|
||||
QDataStream d(&f);
|
||||
|
||||
@@ -140,7 +140,7 @@ void ColorSwatchChooser::LoadSwatches()
|
||||
|
||||
if (version == 1) {
|
||||
int index = 0;
|
||||
while (index < kBtnCount && !d.atEnd()) {
|
||||
while (index < k_btn_count && !d.atEnd()) {
|
||||
Color::DataType r;
|
||||
QString s;
|
||||
ManagedColor c;
|
||||
@@ -173,7 +173,7 @@ void ColorSwatchChooser::LoadSwatches()
|
||||
c.set_color_output(ColorTransform(s));
|
||||
}
|
||||
|
||||
buttons_[index]->SetColor(c);
|
||||
buttons_[index]->set_color(c);
|
||||
|
||||
index++;
|
||||
}
|
||||
@@ -183,9 +183,9 @@ void ColorSwatchChooser::LoadSwatches()
|
||||
}
|
||||
}
|
||||
|
||||
void ColorSwatchChooser::SaveSwatches()
|
||||
void ColorSwatchChooser::save_swatches()
|
||||
{
|
||||
QString fn = GetSwatchFilename();
|
||||
QString fn = get_swatch_filename();
|
||||
QFile f(fn);
|
||||
|
||||
if (f.open(QFile::WriteOnly)) {
|
||||
@@ -194,8 +194,8 @@ void ColorSwatchChooser::SaveSwatches()
|
||||
const uint version = 1;
|
||||
d << version;
|
||||
|
||||
for (int i = 0; i < kBtnCount; i++) {
|
||||
const ManagedColor &c = buttons_[i]->GetColor();
|
||||
for (int i = 0; i < k_btn_count; i++) {
|
||||
const ManagedColor &c = buttons_[i]->get_color();
|
||||
d << c.red();
|
||||
d << c.green();
|
||||
d << c.blue();
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef COLORSWATCHCHOOSER_H
|
||||
#define COLORSWATCHCHOOSER_H
|
||||
#ifndef OAK_COLORSWATCHCHOOSER_H
|
||||
#define OAK_COLORSWATCHCHOOSER_H
|
||||
|
||||
#include "node/color/colormanager/colormanager.h"
|
||||
#include "widget/colorbutton/colorbutton.h"
|
||||
@@ -34,40 +34,40 @@ public:
|
||||
ColorSwatchChooser(ColorManager *manager, QWidget *parent = nullptr);
|
||||
|
||||
public slots:
|
||||
void SetCurrentColor(const ManagedColor &c)
|
||||
void set_current_color(const ManagedColor &c)
|
||||
{
|
||||
current_ = c;
|
||||
}
|
||||
|
||||
signals:
|
||||
void ColorClicked(const ManagedColor &c);
|
||||
void color_clicked(const ManagedColor &c);
|
||||
|
||||
private:
|
||||
void SetDefaultColor(int index);
|
||||
void set_default_color(int index);
|
||||
|
||||
static QString GetSwatchFilename();
|
||||
static QString get_swatch_filename();
|
||||
|
||||
void LoadSwatches();
|
||||
void SaveSwatches();
|
||||
void load_swatches();
|
||||
void save_swatches();
|
||||
|
||||
static const int kRowCount = 4;
|
||||
static const int kColCount = 8;
|
||||
static const int kBtnCount = kRowCount * kColCount;
|
||||
ColorButton *buttons_[kBtnCount];
|
||||
static const int k_row_count = 4;
|
||||
static const int k_col_count = 8;
|
||||
static const int k_btn_count = k_row_count * k_col_count;
|
||||
ColorButton *buttons_[k_btn_count];
|
||||
|
||||
ManagedColor current_;
|
||||
ColorButton *menu_btn_;
|
||||
|
||||
private slots:
|
||||
void HandleButtonClick();
|
||||
void handle_button_click();
|
||||
|
||||
void HandleContextMenu();
|
||||
void handle_context_menu();
|
||||
|
||||
void SaveCurrentColor();
|
||||
void save_current_color();
|
||||
|
||||
void ResetMenuButton();
|
||||
void reset_menu_button();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // COLORSWATCHCHOOSER_H
|
||||
#endif // OAK_COLORSWATCHCHOOSER_H
|
||||
|
||||
@@ -35,33 +35,33 @@ ColorSwatchWidget::ColorSwatchWidget(QWidget *parent)
|
||||
{
|
||||
}
|
||||
|
||||
const Color &ColorSwatchWidget::GetSelectedColor() const
|
||||
const Color &ColorSwatchWidget::get_selected_color() const
|
||||
{
|
||||
return selected_color_;
|
||||
}
|
||||
|
||||
void ColorSwatchWidget::SetColorProcessor(ColorProcessorPtr to_linear,
|
||||
void ColorSwatchWidget::set_color_processor(ColorProcessorPtr to_linear,
|
||||
ColorProcessorPtr to_display)
|
||||
{
|
||||
to_linear_processor_ = to_linear;
|
||||
to_display_processor_ = to_display;
|
||||
|
||||
// Force full update
|
||||
SelectedColorChangedEvent(GetSelectedColor(), true);
|
||||
SelectedColorChangedEvent(get_selected_color(), true);
|
||||
update();
|
||||
}
|
||||
|
||||
void ColorSwatchWidget::SetSelectedColor(const Color &c)
|
||||
void ColorSwatchWidget::set_selected_color(const Color &c)
|
||||
{
|
||||
SetSelectedColorInternal(c, true);
|
||||
set_selected_color_internal(c, true);
|
||||
}
|
||||
|
||||
void ColorSwatchWidget::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
QWidget::mousePressEvent(e);
|
||||
|
||||
SetSelectedColorInternal(GetColorFromScreenPos(e->pos()), false);
|
||||
emit SelectedColorChanged(GetSelectedColor());
|
||||
set_selected_color_internal(get_color_from_screen_pos(e->pos()), false);
|
||||
emit selected_color_changed(get_selected_color());
|
||||
}
|
||||
|
||||
void ColorSwatchWidget::mouseMoveEvent(QMouseEvent *e)
|
||||
@@ -69,8 +69,8 @@ void ColorSwatchWidget::mouseMoveEvent(QMouseEvent *e)
|
||||
QWidget::mouseMoveEvent(e);
|
||||
|
||||
if (e->buttons() & Qt::LeftButton) {
|
||||
SetSelectedColorInternal(GetColorFromScreenPos(e->pos()), false);
|
||||
emit SelectedColorChanged(GetSelectedColor());
|
||||
set_selected_color_internal(get_color_from_screen_pos(e->pos()), false);
|
||||
emit selected_color_changed(get_selected_color());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,22 +78,22 @@ void ColorSwatchWidget::SelectedColorChangedEvent(const Color &, bool)
|
||||
{
|
||||
}
|
||||
|
||||
Qt::GlobalColor ColorSwatchWidget::GetUISelectorColor() const
|
||||
Qt::GlobalColor ColorSwatchWidget::get_ui_selector_color() const
|
||||
{
|
||||
return ColorCoding::GetUISelectorColor(GetSelectedColor());
|
||||
return ColorCoding::get_ui_selector_color(get_selected_color());
|
||||
}
|
||||
|
||||
Color ColorSwatchWidget::GetManagedColor(const Color &input) const
|
||||
Color ColorSwatchWidget::get_managed_color(const Color &input) const
|
||||
{
|
||||
if (to_linear_processor_ && to_display_processor_) {
|
||||
return to_display_processor_->ConvertColor(
|
||||
to_linear_processor_->ConvertColor(input));
|
||||
return to_display_processor_->convert_color(
|
||||
to_linear_processor_->convert_color(input));
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
void ColorSwatchWidget::SetSelectedColorInternal(const Color &c, bool external)
|
||||
void ColorSwatchWidget::set_selected_color_internal(const Color &c, bool external)
|
||||
{
|
||||
selected_color_ = c;
|
||||
SelectedColorChangedEvent(c, external);
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef COLORSWATCHWIDGET_H
|
||||
#define COLORSWATCHWIDGET_H
|
||||
#ifndef OAK_COLORSWATCHWIDGET_H
|
||||
#define OAK_COLORSWATCHWIDGET_H
|
||||
|
||||
#include <QOpenGLWidget>
|
||||
|
||||
@@ -34,32 +34,32 @@ class ColorSwatchWidget : public QWidget {
|
||||
public:
|
||||
ColorSwatchWidget(QWidget *parent = nullptr);
|
||||
|
||||
const Color &GetSelectedColor() const;
|
||||
const Color &get_selected_color() const;
|
||||
|
||||
void SetColorProcessor(ColorProcessorPtr to_linear,
|
||||
void set_color_processor(ColorProcessorPtr to_linear,
|
||||
ColorProcessorPtr to_display);
|
||||
|
||||
public slots:
|
||||
void SetSelectedColor(const Color &c);
|
||||
void set_selected_color(const Color &c);
|
||||
|
||||
signals:
|
||||
void SelectedColorChanged(const Color &c);
|
||||
void selected_color_changed(const Color &c);
|
||||
|
||||
protected:
|
||||
virtual void mousePressEvent(QMouseEvent *e) override;
|
||||
|
||||
virtual void mouseMoveEvent(QMouseEvent *e) override;
|
||||
|
||||
virtual Color GetColorFromScreenPos(const QPoint &p) const = 0;
|
||||
virtual Color get_color_from_screen_pos(const QPoint &p) const = 0;
|
||||
|
||||
virtual void SelectedColorChangedEvent(const Color &c, bool external);
|
||||
|
||||
Qt::GlobalColor GetUISelectorColor() const;
|
||||
Qt::GlobalColor get_ui_selector_color() const;
|
||||
|
||||
Color GetManagedColor(const Color &input) const;
|
||||
Color get_managed_color(const Color &input) const;
|
||||
|
||||
private:
|
||||
void SetSelectedColorInternal(const Color &c, bool external);
|
||||
void set_selected_color_internal(const Color &c, bool external);
|
||||
|
||||
Color selected_color_;
|
||||
|
||||
@@ -70,4 +70,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // COLORSWATCHWIDGET_H
|
||||
#endif // OAK_COLORSWATCHWIDGET_H
|
||||
|
||||
@@ -55,14 +55,14 @@ ColorValuesWidget::ColorValuesWidget(ColorManager *manager, QWidget *parent)
|
||||
preview_layout->addWidget(preview_);
|
||||
|
||||
color_picker_btn_ = new QPushButton();
|
||||
color_picker_btn_->setIcon(icon::ColorPicker);
|
||||
color_picker_btn_->setIcon(icon::color_picker);
|
||||
color_picker_btn_->setFixedWidth(
|
||||
color_picker_btn_->sizeHint().height());
|
||||
color_picker_btn_->setCheckable(true);
|
||||
connect(color_picker_btn_, &QPushButton::toggled, this,
|
||||
&ColorValuesWidget::ColorPickedBtnToggled);
|
||||
connect(Core::instance(), &Core::ColorPickerColorEmitted, this,
|
||||
&ColorValuesWidget::SetReferenceColor);
|
||||
&ColorValuesWidget::color_picked_btn_toggled);
|
||||
connect(Core::instance(), &Core::color_picker_color_emitted, this,
|
||||
&ColorValuesWidget::set_reference_color);
|
||||
preview_layout->addWidget(color_picker_btn_);
|
||||
|
||||
layout->addLayout(preview_layout);
|
||||
@@ -74,33 +74,33 @@ ColorValuesWidget::ColorValuesWidget(ColorManager *manager, QWidget *parent)
|
||||
|
||||
input_tab_ = new ColorValuesTab(true);
|
||||
tabs->addTab(input_tab_, tr("Input"));
|
||||
connect(input_tab_, &ColorValuesTab::ColorChanged, this,
|
||||
&ColorValuesWidget::UpdateValuesFromInput);
|
||||
connect(input_tab_, &ColorValuesTab::ColorChanged, this,
|
||||
&ColorValuesWidget::ColorChanged);
|
||||
connect(input_tab_, &ColorValuesTab::ColorChanged, preview_,
|
||||
&ColorPreviewBox::SetColor);
|
||||
connect(input_tab_, &ColorValuesTab::color_changed, this,
|
||||
&ColorValuesWidget::update_values_from_input);
|
||||
connect(input_tab_, &ColorValuesTab::color_changed, this,
|
||||
&ColorValuesWidget::color_changed);
|
||||
connect(input_tab_, &ColorValuesTab::color_changed, preview_,
|
||||
&ColorPreviewBox::set_color);
|
||||
|
||||
reference_tab_ = new ColorValuesTab();
|
||||
tabs->addTab(reference_tab_, tr("Reference"));
|
||||
connect(reference_tab_, &ColorValuesTab::ColorChanged, this,
|
||||
&ColorValuesWidget::UpdateValuesFromRef);
|
||||
connect(reference_tab_, &ColorValuesTab::color_changed, this,
|
||||
&ColorValuesWidget::update_values_from_ref);
|
||||
|
||||
display_tab_ = new ColorValuesTab();
|
||||
tabs->addTab(display_tab_, tr("Display"));
|
||||
connect(display_tab_, &ColorValuesTab::ColorChanged, this,
|
||||
&ColorValuesWidget::UpdateValuesFromDisplay);
|
||||
connect(display_tab_, &ColorValuesTab::color_changed, this,
|
||||
&ColorValuesWidget::update_values_from_display);
|
||||
|
||||
layout->addWidget(tabs);
|
||||
}
|
||||
}
|
||||
|
||||
Color ColorValuesWidget::GetColor() const
|
||||
Color ColorValuesWidget::get_color() const
|
||||
{
|
||||
return reference_tab_->GetColor();
|
||||
return reference_tab_->get_color();
|
||||
}
|
||||
|
||||
void ColorValuesWidget::SetColorProcessor(ColorProcessorPtr input_to_ref,
|
||||
void ColorValuesWidget::set_color_processor(ColorProcessorPtr input_to_ref,
|
||||
ColorProcessorPtr ref_to_display,
|
||||
ColorProcessorPtr display_to_ref,
|
||||
ColorProcessorPtr ref_to_input)
|
||||
@@ -110,9 +110,9 @@ void ColorValuesWidget::SetColorProcessor(ColorProcessorPtr input_to_ref,
|
||||
display_to_ref_ = display_to_ref;
|
||||
ref_to_input_ = ref_to_input;
|
||||
|
||||
UpdateValuesFromInput();
|
||||
update_values_from_input();
|
||||
|
||||
preview_->SetColorProcessor(input_to_ref_, ref_to_display_);
|
||||
preview_->set_color_processor(input_to_ref_, ref_to_display_);
|
||||
}
|
||||
|
||||
bool ColorValuesWidget::eventFilter(QObject *watcher, QEvent *event)
|
||||
@@ -129,7 +129,7 @@ bool ColorValuesWidget::eventFilter(QObject *watcher, QEvent *event)
|
||||
}
|
||||
|
||||
if (use_this_color) {
|
||||
picker_end_color_ = GetColor();
|
||||
picker_end_color_ = get_color();
|
||||
}
|
||||
color_picker_btn_->setChecked(false);
|
||||
return true;
|
||||
@@ -145,101 +145,101 @@ bool ColorValuesWidget::eventFilter(QObject *watcher, QEvent *event)
|
||||
return QWidget::eventFilter(watcher, event);
|
||||
}
|
||||
|
||||
void ColorValuesWidget::SetColor(const Color &c)
|
||||
void ColorValuesWidget::set_color(const Color &c)
|
||||
{
|
||||
input_tab_->SetColor(c);
|
||||
preview_->SetColor(c);
|
||||
input_tab_->set_color(c);
|
||||
preview_->set_color(c);
|
||||
|
||||
UpdateValuesFromInput();
|
||||
update_values_from_input();
|
||||
}
|
||||
|
||||
void ColorValuesWidget::SetReferenceColor(const Color &c)
|
||||
void ColorValuesWidget::set_reference_color(const Color &c)
|
||||
{
|
||||
reference_tab_->SetColor(c);
|
||||
reference_tab_->set_color(c);
|
||||
|
||||
UpdateValuesFromRef();
|
||||
update_values_from_ref();
|
||||
}
|
||||
|
||||
void ColorValuesWidget::UpdateValuesFromInput()
|
||||
void ColorValuesWidget::update_values_from_input()
|
||||
{
|
||||
UpdateRefFromInput();
|
||||
UpdateDisplayFromRef();
|
||||
update_ref_from_input();
|
||||
update_display_from_ref();
|
||||
}
|
||||
|
||||
void ColorValuesWidget::UpdateValuesFromRef()
|
||||
void ColorValuesWidget::update_values_from_ref()
|
||||
{
|
||||
UpdateInputFromRef();
|
||||
UpdateDisplayFromRef();
|
||||
update_input_from_ref();
|
||||
update_display_from_ref();
|
||||
}
|
||||
|
||||
void ColorValuesWidget::UpdateValuesFromDisplay()
|
||||
void ColorValuesWidget::update_values_from_display()
|
||||
{
|
||||
UpdateRefFromDisplay();
|
||||
UpdateInputFromRef();
|
||||
update_ref_from_display();
|
||||
update_input_from_ref();
|
||||
}
|
||||
|
||||
void ColorValuesWidget::ColorPickedBtnToggled(bool e)
|
||||
void ColorValuesWidget::color_picked_btn_toggled(bool e)
|
||||
{
|
||||
Core::instance()->RequestPixelSamplingInViewers(e);
|
||||
Core::instance()->request_pixel_sampling_in_viewers(e);
|
||||
|
||||
if (e) {
|
||||
qApp->installEventFilter(this);
|
||||
|
||||
// Store current color in case it needs to be restored
|
||||
picker_end_color_ = GetColor();
|
||||
picker_end_color_ = get_color();
|
||||
} else {
|
||||
qApp->removeEventFilter(this);
|
||||
|
||||
// Restore original color (or use overridden color from eventFilter)
|
||||
SetReferenceColor(picker_end_color_);
|
||||
emit ColorChanged(input_tab_->GetColor());
|
||||
set_reference_color(picker_end_color_);
|
||||
emit color_changed(input_tab_->get_color());
|
||||
}
|
||||
}
|
||||
|
||||
void ColorValuesWidget::UpdateInputFromRef()
|
||||
void ColorValuesWidget::update_input_from_ref()
|
||||
{
|
||||
if (ref_to_input_) {
|
||||
input_tab_->SetColor(
|
||||
ref_to_input_->ConvertColor(reference_tab_->GetColor()));
|
||||
input_tab_->set_color(
|
||||
ref_to_input_->convert_color(reference_tab_->get_color()));
|
||||
} else {
|
||||
input_tab_->SetColor(reference_tab_->GetColor());
|
||||
input_tab_->set_color(reference_tab_->get_color());
|
||||
}
|
||||
|
||||
preview_->SetColor(input_tab_->GetColor());
|
||||
emit ColorChanged(input_tab_->GetColor());
|
||||
preview_->set_color(input_tab_->get_color());
|
||||
emit color_changed(input_tab_->get_color());
|
||||
}
|
||||
|
||||
void ColorValuesWidget::UpdateDisplayFromRef()
|
||||
void ColorValuesWidget::update_display_from_ref()
|
||||
{
|
||||
if (ref_to_display_) {
|
||||
display_tab_->SetColor(
|
||||
ref_to_display_->ConvertColor(reference_tab_->GetColor()));
|
||||
display_tab_->set_color(
|
||||
ref_to_display_->convert_color(reference_tab_->get_color()));
|
||||
} else {
|
||||
display_tab_->SetColor(reference_tab_->GetColor());
|
||||
display_tab_->set_color(reference_tab_->get_color());
|
||||
}
|
||||
}
|
||||
|
||||
void ColorValuesWidget::UpdateRefFromInput()
|
||||
void ColorValuesWidget::update_ref_from_input()
|
||||
{
|
||||
if (input_to_ref_) {
|
||||
reference_tab_->SetColor(
|
||||
input_to_ref_->ConvertColor(input_tab_->GetColor()));
|
||||
reference_tab_->set_color(
|
||||
input_to_ref_->convert_color(input_tab_->get_color()));
|
||||
} else {
|
||||
reference_tab_->SetColor(input_tab_->GetColor());
|
||||
reference_tab_->set_color(input_tab_->get_color());
|
||||
}
|
||||
}
|
||||
|
||||
void ColorValuesWidget::UpdateRefFromDisplay()
|
||||
void ColorValuesWidget::update_ref_from_display()
|
||||
{
|
||||
if (display_to_ref_) {
|
||||
reference_tab_->SetColor(
|
||||
display_to_ref_->ConvertColor(display_tab_->GetColor()));
|
||||
reference_tab_->set_color(
|
||||
display_to_ref_->convert_color(display_tab_->get_color()));
|
||||
} else {
|
||||
reference_tab_->SetColor(display_tab_->GetColor());
|
||||
reference_tab_->set_color(display_tab_->get_color());
|
||||
}
|
||||
}
|
||||
|
||||
const double ColorValuesTab::kLegacyMultiplier = 255.0;
|
||||
const double ColorValuesTab::k_legacy_multiplier = 255.0;
|
||||
|
||||
ColorValuesTab::ColorValuesTab(bool with_legacy_option, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
@@ -251,9 +251,9 @@ ColorValuesTab::ColorValuesTab(bool with_legacy_option, QWidget *parent)
|
||||
if (with_legacy_option) {
|
||||
legacy_box_ = new QCheckBox(tr("Use legacy (8-bit) values"));
|
||||
legacy_box_->setChecked(
|
||||
OLIVE_CONFIG("UseLegacyColorInInputTab").toBool());
|
||||
OAK_CONFIG("UseLegacyColorInInputTab").toBool());
|
||||
connect(legacy_box_, &QCheckBox::clicked, this,
|
||||
&ColorValuesTab::LegacyChanged);
|
||||
&ColorValuesTab::legacy_changed);
|
||||
layout->addWidget(legacy_box_, row, 0, 1, 2);
|
||||
row++;
|
||||
} else {
|
||||
@@ -264,7 +264,7 @@ ColorValuesTab::ColorValuesTab(bool with_legacy_option, QWidget *parent)
|
||||
|
||||
layout->addWidget(new QLabel(tr("Red")), row, 0);
|
||||
|
||||
red_slider_ = CreateColorSlider();
|
||||
red_slider_ = create_color_slider();
|
||||
sliders_[0] = red_slider_;
|
||||
layout->addWidget(red_slider_, row, 1);
|
||||
|
||||
@@ -272,7 +272,7 @@ ColorValuesTab::ColorValuesTab(bool with_legacy_option, QWidget *parent)
|
||||
|
||||
layout->addWidget(new QLabel(tr("Green")), row, 0);
|
||||
|
||||
green_slider_ = CreateColorSlider();
|
||||
green_slider_ = create_color_slider();
|
||||
sliders_[1] = green_slider_;
|
||||
layout->addWidget(green_slider_, row, 1);
|
||||
|
||||
@@ -280,7 +280,7 @@ ColorValuesTab::ColorValuesTab(bool with_legacy_option, QWidget *parent)
|
||||
|
||||
layout->addWidget(new QLabel(tr("Blue")), row, 0);
|
||||
|
||||
blue_slider_ = CreateColorSlider();
|
||||
blue_slider_ = create_color_slider();
|
||||
sliders_[2] = blue_slider_;
|
||||
layout->addWidget(blue_slider_, row, 1);
|
||||
|
||||
@@ -290,112 +290,112 @@ ColorValuesTab::ColorValuesTab(bool with_legacy_option, QWidget *parent)
|
||||
layout->addWidget(hex_lbl_, row, 0);
|
||||
|
||||
hex_slider_ = new StringSlider();
|
||||
connect(hex_slider_, &StringSlider::ValueChanged, this,
|
||||
&ColorValuesTab::HexChanged);
|
||||
connect(hex_slider_, &StringSlider::value_changed, this,
|
||||
&ColorValuesTab::hex_changed);
|
||||
layout->addWidget(hex_slider_, row, 1);
|
||||
|
||||
if (legacy_box_) {
|
||||
LegacyChanged(AreSlidersLegacyValues());
|
||||
legacy_changed(are_sliders_legacy_values());
|
||||
}
|
||||
}
|
||||
|
||||
Color ColorValuesTab::GetColor() const
|
||||
Color ColorValuesTab::get_color() const
|
||||
{
|
||||
return Color(GetRed(), GetGreen(), GetBlue());
|
||||
return Color(get_red(), get_green(), get_blue());
|
||||
}
|
||||
|
||||
void ColorValuesTab::SetColor(const Color &c)
|
||||
void ColorValuesTab::set_color(const Color &c)
|
||||
{
|
||||
SetRed(c.red());
|
||||
SetGreen(c.green());
|
||||
SetBlue(c.blue());
|
||||
set_red(c.red());
|
||||
set_green(c.green());
|
||||
set_blue(c.blue());
|
||||
}
|
||||
|
||||
double ColorValuesTab::GetRed() const
|
||||
double ColorValuesTab::get_red() const
|
||||
{
|
||||
return GetValueInternal(red_slider_);
|
||||
return get_value_internal(red_slider_);
|
||||
}
|
||||
|
||||
double ColorValuesTab::GetGreen() const
|
||||
double ColorValuesTab::get_green() const
|
||||
{
|
||||
return GetValueInternal(green_slider_);
|
||||
return get_value_internal(green_slider_);
|
||||
}
|
||||
|
||||
double ColorValuesTab::GetBlue() const
|
||||
double ColorValuesTab::get_blue() const
|
||||
{
|
||||
return GetValueInternal(blue_slider_);
|
||||
return get_value_internal(blue_slider_);
|
||||
}
|
||||
|
||||
void ColorValuesTab::SetRed(double r)
|
||||
void ColorValuesTab::set_red(double r)
|
||||
{
|
||||
SetValueInternal(red_slider_, r);
|
||||
set_value_internal(red_slider_, r);
|
||||
}
|
||||
|
||||
void ColorValuesTab::SetGreen(double g)
|
||||
void ColorValuesTab::set_green(double g)
|
||||
{
|
||||
SetValueInternal(green_slider_, g);
|
||||
set_value_internal(green_slider_, g);
|
||||
}
|
||||
|
||||
void ColorValuesTab::SetBlue(double b)
|
||||
void ColorValuesTab::set_blue(double b)
|
||||
{
|
||||
SetValueInternal(blue_slider_, b);
|
||||
set_value_internal(blue_slider_, b);
|
||||
}
|
||||
|
||||
double ColorValuesTab::GetValueInternal(FloatSlider *slider) const
|
||||
double ColorValuesTab::get_value_internal(FloatSlider *slider) const
|
||||
{
|
||||
double d = slider->GetValue();
|
||||
double d = slider->get_value();
|
||||
|
||||
if (AreSlidersLegacyValues()) {
|
||||
d /= kLegacyMultiplier;
|
||||
if (are_sliders_legacy_values()) {
|
||||
d /= k_legacy_multiplier;
|
||||
}
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
void ColorValuesTab::SetValueInternal(FloatSlider *slider, double v)
|
||||
void ColorValuesTab::set_value_internal(FloatSlider *slider, double v)
|
||||
{
|
||||
if (AreSlidersLegacyValues()) {
|
||||
v *= kLegacyMultiplier;
|
||||
if (are_sliders_legacy_values()) {
|
||||
v *= k_legacy_multiplier;
|
||||
}
|
||||
|
||||
slider->SetValue(v);
|
||||
UpdateHex();
|
||||
slider->set_value(v);
|
||||
update_hex();
|
||||
}
|
||||
|
||||
FloatSlider *ColorValuesTab::CreateColorSlider()
|
||||
FloatSlider *ColorValuesTab::create_color_slider()
|
||||
{
|
||||
FloatSlider *fs = new FloatSlider();
|
||||
fs->SetLadderElementCount(1);
|
||||
connect(fs, &FloatSlider::ValueChanged, this,
|
||||
&ColorValuesTab::SliderChanged);
|
||||
fs->set_ladder_element_count(1);
|
||||
connect(fs, &FloatSlider::value_changed, this,
|
||||
&ColorValuesTab::slider_changed);
|
||||
return fs;
|
||||
}
|
||||
|
||||
void ColorValuesTab::SliderChanged()
|
||||
void ColorValuesTab::slider_changed()
|
||||
{
|
||||
emit ColorChanged(GetColor());
|
||||
UpdateHex();
|
||||
emit color_changed(get_color());
|
||||
update_hex();
|
||||
}
|
||||
|
||||
void ColorValuesTab::LegacyChanged(bool legacy)
|
||||
void ColorValuesTab::legacy_changed(bool legacy)
|
||||
{
|
||||
OLIVE_CONFIG("UseLegacyColorInInputTab") = legacy;
|
||||
OAK_CONFIG("UseLegacyColorInInputTab") = legacy;
|
||||
|
||||
double legacy_multiplier = legacy ? kLegacyMultiplier :
|
||||
1.0 / kLegacyMultiplier;
|
||||
double legacy_multiplier = legacy ? k_legacy_multiplier :
|
||||
1.0 / k_legacy_multiplier;
|
||||
int decimal_places = legacy ? 0 : 5;
|
||||
double drag_multiplier = legacy ? 1.0 : 0.01;
|
||||
|
||||
foreach (FloatSlider *s, sliders_) {
|
||||
s->SetValue(s->GetValue() * legacy_multiplier);
|
||||
s->SetDecimalPlaces(decimal_places);
|
||||
s->SetDragMultiplier(drag_multiplier);
|
||||
s->set_value(s->get_value() * legacy_multiplier);
|
||||
s->set_decimal_places(decimal_places);
|
||||
s->set_drag_multiplier(drag_multiplier);
|
||||
}
|
||||
|
||||
UpdateHex();
|
||||
update_hex();
|
||||
}
|
||||
|
||||
QString RGBValToString(double d)
|
||||
QString rgb_val_to_string(double d)
|
||||
{
|
||||
QString s = QString::number(d);
|
||||
|
||||
@@ -406,33 +406,33 @@ QString RGBValToString(double d)
|
||||
return s;
|
||||
}
|
||||
|
||||
void ColorValuesTab::UpdateHex()
|
||||
void ColorValuesTab::update_hex()
|
||||
{
|
||||
if (AreSlidersLegacyValues()) {
|
||||
double r = red_slider_->GetValue();
|
||||
double g = green_slider_->GetValue();
|
||||
double b = blue_slider_->GetValue();
|
||||
if (are_sliders_legacy_values()) {
|
||||
double r = red_slider_->get_value();
|
||||
double g = green_slider_->get_value();
|
||||
double b = blue_slider_->get_value();
|
||||
|
||||
if (r > kLegacyMultiplier || g > kLegacyMultiplier ||
|
||||
b > kLegacyMultiplier) {
|
||||
hex_slider_->SetValue(tr("(Invalid)"));
|
||||
if (r > k_legacy_multiplier || g > k_legacy_multiplier ||
|
||||
b > k_legacy_multiplier) {
|
||||
hex_slider_->set_value(tr("(Invalid)"));
|
||||
} else {
|
||||
uint32_t rgb = (uint8_t(r) << 16) | (uint8_t(g) << 8) | uint8_t(b);
|
||||
|
||||
hex_slider_->SetValue(QStringLiteral("%1")
|
||||
hex_slider_->set_value(QStringLiteral("%1")
|
||||
.arg(rgb, 6, 16, QLatin1Char('0'))
|
||||
.toUpper());
|
||||
}
|
||||
} else {
|
||||
hex_slider_->SetValue(
|
||||
hex_slider_->set_value(
|
||||
QStringLiteral("rgb(%1, %2, %3)")
|
||||
.arg(RGBValToString(red_slider_->GetValue()),
|
||||
RGBValToString(green_slider_->GetValue()),
|
||||
RGBValToString(blue_slider_->GetValue())));
|
||||
.arg(rgb_val_to_string(red_slider_->get_value()),
|
||||
rgb_val_to_string(green_slider_->get_value()),
|
||||
rgb_val_to_string(blue_slider_->get_value())));
|
||||
}
|
||||
}
|
||||
|
||||
bool ParseRGBString(QString s, double *r, double *g, double *b)
|
||||
bool parse_rgb_string(QString s, double *r, double *g, double *b)
|
||||
{
|
||||
// Trim whitespace
|
||||
s = s.trimmed();
|
||||
@@ -463,7 +463,7 @@ bool ParseRGBString(QString s, double *r, double *g, double *b)
|
||||
return true;
|
||||
}
|
||||
|
||||
void ColorValuesTab::HexChanged(const QString &s)
|
||||
void ColorValuesTab::hex_changed(const QString &s)
|
||||
{
|
||||
bool ok;
|
||||
uint32_t hex = s.toULong(&ok, 16);
|
||||
@@ -477,40 +477,40 @@ void ColorValuesTab::HexChanged(const QString &s)
|
||||
uint32_t g = (hex & 0x00FF00) >> 8;
|
||||
uint32_t b = (hex & 0x0000FF);
|
||||
|
||||
if (AreSlidersLegacyValues()) {
|
||||
red_slider_->SetValue(r);
|
||||
green_slider_->SetValue(g);
|
||||
blue_slider_->SetValue(b);
|
||||
if (are_sliders_legacy_values()) {
|
||||
red_slider_->set_value(r);
|
||||
green_slider_->set_value(g);
|
||||
blue_slider_->set_value(b);
|
||||
} else {
|
||||
red_slider_->SetValue(double(r) / kLegacyMultiplier);
|
||||
green_slider_->SetValue(double(g) / kLegacyMultiplier);
|
||||
blue_slider_->SetValue(double(b) / kLegacyMultiplier);
|
||||
red_slider_->set_value(double(r) / k_legacy_multiplier);
|
||||
green_slider_->set_value(double(g) / k_legacy_multiplier);
|
||||
blue_slider_->set_value(double(b) / k_legacy_multiplier);
|
||||
}
|
||||
|
||||
emit ColorChanged(GetColor());
|
||||
emit color_changed(get_color());
|
||||
} else {
|
||||
// Attempt to parse rgb/rgba
|
||||
double r, g, b;
|
||||
if (ParseRGBString(s, &r, &g, &b)) {
|
||||
if (AreSlidersLegacyValues()) {
|
||||
red_slider_->SetValue(r * kLegacyMultiplier);
|
||||
green_slider_->SetValue(g * kLegacyMultiplier);
|
||||
blue_slider_->SetValue(b * kLegacyMultiplier);
|
||||
if (parse_rgb_string(s, &r, &g, &b)) {
|
||||
if (are_sliders_legacy_values()) {
|
||||
red_slider_->set_value(r * k_legacy_multiplier);
|
||||
green_slider_->set_value(g * k_legacy_multiplier);
|
||||
blue_slider_->set_value(b * k_legacy_multiplier);
|
||||
} else {
|
||||
red_slider_->SetValue(r);
|
||||
green_slider_->SetValue(g);
|
||||
blue_slider_->SetValue(b);
|
||||
red_slider_->set_value(r);
|
||||
green_slider_->set_value(g);
|
||||
blue_slider_->set_value(b);
|
||||
}
|
||||
|
||||
emit ColorChanged(GetColor());
|
||||
emit color_changed(get_color());
|
||||
}
|
||||
}
|
||||
|
||||
// Conform string to our formatting
|
||||
UpdateHex();
|
||||
update_hex();
|
||||
}
|
||||
|
||||
bool ColorValuesTab::AreSlidersLegacyValues() const
|
||||
bool ColorValuesTab::are_sliders_legacy_values() const
|
||||
{
|
||||
return legacy_box_ && legacy_box_->isChecked();
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef COLORVALUESWIDGET_H
|
||||
#define COLORVALUESWIDGET_H
|
||||
#ifndef OAK_COLORVALUESWIDGET_H
|
||||
#define OAK_COLORVALUESWIDGET_H
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QPushButton>
|
||||
@@ -39,29 +39,29 @@ class ColorValuesTab : public QWidget {
|
||||
public:
|
||||
ColorValuesTab(bool with_legacy_option = false, QWidget *parent = nullptr);
|
||||
|
||||
Color GetColor() const;
|
||||
Color get_color() const;
|
||||
|
||||
void SetColor(const Color &c);
|
||||
void set_color(const Color &c);
|
||||
|
||||
double GetRed() const;
|
||||
double GetGreen() const;
|
||||
double GetBlue() const;
|
||||
void SetRed(double r);
|
||||
void SetGreen(double g);
|
||||
void SetBlue(double b);
|
||||
double get_red() const;
|
||||
double get_green() const;
|
||||
double get_blue() const;
|
||||
void set_red(double r);
|
||||
void set_green(double g);
|
||||
void set_blue(double b);
|
||||
|
||||
signals:
|
||||
void ColorChanged(const Color &c);
|
||||
void color_changed(const Color &c);
|
||||
|
||||
private:
|
||||
static const double kLegacyMultiplier;
|
||||
static const double k_legacy_multiplier;
|
||||
|
||||
double GetValueInternal(FloatSlider *slider) const;
|
||||
void SetValueInternal(FloatSlider *slider, double v);
|
||||
double get_value_internal(FloatSlider *slider) const;
|
||||
void set_value_internal(FloatSlider *slider, double v);
|
||||
|
||||
bool AreSlidersLegacyValues() const;
|
||||
bool are_sliders_legacy_values() const;
|
||||
|
||||
FloatSlider *CreateColorSlider();
|
||||
FloatSlider *create_color_slider();
|
||||
|
||||
FloatSlider *red_slider_;
|
||||
FloatSlider *green_slider_;
|
||||
@@ -75,13 +75,13 @@ private:
|
||||
QCheckBox *legacy_box_;
|
||||
|
||||
private slots:
|
||||
void SliderChanged();
|
||||
void slider_changed();
|
||||
|
||||
void LegacyChanged(bool e);
|
||||
void legacy_changed(bool e);
|
||||
|
||||
void UpdateHex();
|
||||
void update_hex();
|
||||
|
||||
void HexChanged(const QString &s);
|
||||
void hex_changed(const QString &s);
|
||||
};
|
||||
|
||||
class ColorValuesWidget : public QWidget {
|
||||
@@ -89,36 +89,36 @@ class ColorValuesWidget : public QWidget {
|
||||
public:
|
||||
ColorValuesWidget(ColorManager *manager, QWidget *parent = nullptr);
|
||||
|
||||
Color GetColor() const;
|
||||
Color get_color() const;
|
||||
|
||||
void SetColorProcessor(ColorProcessorPtr input_to_ref,
|
||||
void set_color_processor(ColorProcessorPtr input_to_ref,
|
||||
ColorProcessorPtr ref_to_display,
|
||||
ColorProcessorPtr display_to_ref,
|
||||
ColorProcessorPtr ref_to_input);
|
||||
|
||||
virtual bool eventFilter(QObject *watcher, QEvent *event) override;
|
||||
|
||||
void IgnorePickFrom(QWidget *w)
|
||||
void ignore_pick_from(QWidget *w)
|
||||
{
|
||||
ignore_pick_from_.append(w);
|
||||
}
|
||||
|
||||
public slots:
|
||||
void SetColor(const Color &c);
|
||||
void set_color(const Color &c);
|
||||
|
||||
void SetReferenceColor(const Color &c);
|
||||
void set_reference_color(const Color &c);
|
||||
|
||||
signals:
|
||||
void ColorChanged(const Color &c);
|
||||
void color_changed(const Color &c);
|
||||
|
||||
private:
|
||||
void UpdateInputFromRef();
|
||||
void update_input_from_ref();
|
||||
|
||||
void UpdateDisplayFromRef();
|
||||
void update_display_from_ref();
|
||||
|
||||
void UpdateRefFromInput();
|
||||
void update_ref_from_input();
|
||||
|
||||
void UpdateRefFromDisplay();
|
||||
void update_ref_from_display();
|
||||
|
||||
ColorManager *manager_;
|
||||
|
||||
@@ -145,15 +145,15 @@ private:
|
||||
QVector<QWidget *> ignore_pick_from_;
|
||||
|
||||
private slots:
|
||||
void UpdateValuesFromInput();
|
||||
void update_values_from_input();
|
||||
|
||||
void UpdateValuesFromRef();
|
||||
void update_values_from_ref();
|
||||
|
||||
void UpdateValuesFromDisplay();
|
||||
void update_values_from_display();
|
||||
|
||||
void ColorPickedBtnToggled(bool e);
|
||||
void color_picked_btn_toggled(bool e);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // COLORVALUESWIDGET_H
|
||||
#endif // OAK_COLORVALUESWIDGET_H
|
||||
|
||||
@@ -39,23 +39,23 @@ ColorWheelWidget::ColorWheelWidget(QWidget *parent)
|
||||
{
|
||||
}
|
||||
|
||||
Color ColorWheelWidget::GetColorFromScreenPos(const QPoint &p) const
|
||||
Color ColorWheelWidget::get_color_from_screen_pos(const QPoint &p) const
|
||||
{
|
||||
return GetColorFromTriangle(GetTriangleFromCoords(rect().center(), p));
|
||||
return get_color_from_triangle(get_triangle_from_coords(rect().center(), p));
|
||||
}
|
||||
|
||||
void ColorWheelWidget::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
ColorSwatchWidget::resizeEvent(e);
|
||||
|
||||
emit DiameterChanged(GetDiameter());
|
||||
emit diameter_changed(get_diameter());
|
||||
}
|
||||
|
||||
void ColorWheelWidget::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
ColorSwatchWidget::paintEvent(e);
|
||||
|
||||
int diameter = GetDiameter();
|
||||
int diameter = get_diameter();
|
||||
|
||||
// Half diameter
|
||||
int radius = diameter / 2;
|
||||
@@ -70,11 +70,11 @@ void ColorWheelWidget::paintEvent(QPaintEvent *e)
|
||||
|
||||
for (int i = 0; i < diameter; i++) {
|
||||
for (int j = 0; j < diameter; j++) {
|
||||
Triangle tri = GetTriangleFromCoords(center, j, i);
|
||||
Triangle tri = get_triangle_from_coords(center, j, i);
|
||||
|
||||
if (tri.hypotenuse <= radius) {
|
||||
Color managed = GetManagedColor(GetColorFromTriangle(tri));
|
||||
QColor c = QtUtils::toQColor(managed);
|
||||
Color managed = get_managed_color(get_color_from_triangle(tri));
|
||||
QColor c = QtUtils::to_q_color(managed);
|
||||
|
||||
// Very basic antialiasing around the edges of the wheel
|
||||
qreal alpha = qMin(1.0, radius - tri.hypotenuse);
|
||||
@@ -110,10 +110,10 @@ void ColorWheelWidget::paintEvent(QPaintEvent *e)
|
||||
// Really rough algorithm for determining whether the selector UI should be white or black
|
||||
|
||||
int selector_radius = qMax(1, radius / 32);
|
||||
p.setPen(QPen(GetUISelectorColor(), qMax(1, selector_radius / 4)));
|
||||
p.setPen(QPen(get_ui_selector_color(), qMax(1, selector_radius / 4)));
|
||||
p.setBrush(Qt::NoBrush);
|
||||
|
||||
p.drawEllipse(GetCoordsFromColor(GetSelectedColor()), selector_radius,
|
||||
p.drawEllipse(get_coords_from_color(get_selected_color()), selector_radius,
|
||||
selector_radius);
|
||||
}
|
||||
|
||||
@@ -125,25 +125,25 @@ void ColorWheelWidget::SelectedColorChangedEvent(const Color &c, bool external)
|
||||
}
|
||||
}
|
||||
|
||||
int ColorWheelWidget::GetDiameter() const
|
||||
int ColorWheelWidget::get_diameter() const
|
||||
{
|
||||
return qMin(width(), height());
|
||||
}
|
||||
|
||||
qreal ColorWheelWidget::GetRadius() const
|
||||
qreal ColorWheelWidget::get_radius() const
|
||||
{
|
||||
return GetDiameter() * 0.5;
|
||||
return get_diameter() * 0.5;
|
||||
}
|
||||
|
||||
ColorWheelWidget::Triangle
|
||||
ColorWheelWidget::GetTriangleFromCoords(const QPoint ¢er,
|
||||
ColorWheelWidget::get_triangle_from_coords(const QPoint ¢er,
|
||||
const QPoint &p) const
|
||||
{
|
||||
return GetTriangleFromCoords(center, p.y(), p.x());
|
||||
return get_triangle_from_coords(center, p.y(), p.x());
|
||||
}
|
||||
|
||||
ColorWheelWidget::Triangle
|
||||
ColorWheelWidget::GetTriangleFromCoords(const QPoint ¢er, qreal y,
|
||||
ColorWheelWidget::get_triangle_from_coords(const QPoint ¢er, qreal y,
|
||||
qreal x) const
|
||||
{
|
||||
qreal opposite = y - center.y();
|
||||
@@ -153,21 +153,21 @@ ColorWheelWidget::GetTriangleFromCoords(const QPoint ¢er, qreal y,
|
||||
return { opposite, adjacent, hypotenuse };
|
||||
}
|
||||
|
||||
Color ColorWheelWidget::GetColorFromTriangle(
|
||||
Color ColorWheelWidget::get_color_from_triangle(
|
||||
const ColorWheelWidget::Triangle &tri) const
|
||||
{
|
||||
qreal hue = qAtan2(tri.opposite, tri.adjacent) * M_180_OVER_PI + 180.0;
|
||||
qreal sat = qMin(1.0, (tri.hypotenuse / GetRadius()));
|
||||
qreal sat = qMin(1.0, (tri.hypotenuse / get_radius()));
|
||||
|
||||
return Color::fromHsv(hue, sat, val_);
|
||||
return Color::from_hsv(hue, sat, val_);
|
||||
}
|
||||
|
||||
QPoint ColorWheelWidget::GetCoordsFromColor(const Color &c) const
|
||||
QPoint ColorWheelWidget::get_coords_from_color(const Color &c) const
|
||||
{
|
||||
float hue, sat, val;
|
||||
c.toHsv(&hue, &sat, &val);
|
||||
c.to_hsv(&hue, &sat, &val);
|
||||
|
||||
qreal hypotenuse = sat * GetRadius();
|
||||
qreal hypotenuse = sat * get_radius();
|
||||
|
||||
qreal radian_angle = (hue - 180.0) / M_180_OVER_PI;
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef COLORWHEELWIDGET_H
|
||||
#define COLORWHEELWIDGET_H
|
||||
#ifndef OAK_COLORWHEELWIDGET_H
|
||||
#define OAK_COLORWHEELWIDGET_H
|
||||
|
||||
#include <QOpenGLWidget>
|
||||
|
||||
@@ -35,10 +35,10 @@ public:
|
||||
ColorWheelWidget(QWidget *parent = nullptr);
|
||||
|
||||
signals:
|
||||
void DiameterChanged(int radius);
|
||||
void diameter_changed(int radius);
|
||||
|
||||
protected:
|
||||
virtual Color GetColorFromScreenPos(const QPoint &p) const override;
|
||||
virtual Color get_color_from_screen_pos(const QPoint &p) const override;
|
||||
|
||||
virtual void resizeEvent(QResizeEvent *e) override;
|
||||
|
||||
@@ -48,9 +48,9 @@ protected:
|
||||
bool external) override;
|
||||
|
||||
private:
|
||||
int GetDiameter() const;
|
||||
int get_diameter() const;
|
||||
|
||||
qreal GetRadius() const;
|
||||
qreal get_radius() const;
|
||||
|
||||
struct Triangle {
|
||||
qreal opposite;
|
||||
@@ -58,12 +58,12 @@ private:
|
||||
qreal hypotenuse;
|
||||
};
|
||||
|
||||
Triangle GetTriangleFromCoords(const QPoint ¢er, const QPoint &p) const;
|
||||
Triangle GetTriangleFromCoords(const QPoint ¢er, qreal y,
|
||||
Triangle get_triangle_from_coords(const QPoint ¢er, const QPoint &p) const;
|
||||
Triangle get_triangle_from_coords(const QPoint ¢er, qreal y,
|
||||
qreal x) const;
|
||||
|
||||
Color GetColorFromTriangle(const Triangle &tri) const;
|
||||
QPoint GetCoordsFromColor(const Color &c) const;
|
||||
Color get_color_from_triangle(const Triangle &tri) const;
|
||||
QPoint get_coords_from_color(const Color &c) const;
|
||||
|
||||
QPixmap cached_wheel_;
|
||||
|
||||
@@ -74,4 +74,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // COLORWHEELWIDGET_H
|
||||
#endif // OAK_COLORWHEELWIDGET_H
|
||||
|
||||
@@ -30,7 +30,7 @@ ColumnedGridLayout::ColumnedGridLayout(QWidget *parent, int maximum_columns)
|
||||
{
|
||||
}
|
||||
|
||||
void ColumnedGridLayout::Add(QWidget *widget)
|
||||
void ColumnedGridLayout::add(QWidget *widget)
|
||||
{
|
||||
if (maximum_columns_ > 0) {
|
||||
int row = count() / maximum_columns_;
|
||||
@@ -43,12 +43,12 @@ void ColumnedGridLayout::Add(QWidget *widget)
|
||||
}
|
||||
}
|
||||
|
||||
int ColumnedGridLayout::MaximumColumns() const
|
||||
int ColumnedGridLayout::maximum_columns() const
|
||||
{
|
||||
return maximum_columns_;
|
||||
}
|
||||
|
||||
void ColumnedGridLayout::SetMaximumColumns(int maximum_columns)
|
||||
void ColumnedGridLayout::set_maximum_columns(int maximum_columns)
|
||||
{
|
||||
maximum_columns_ = maximum_columns;
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef COLUMNEDGRIDLAYOUT_H
|
||||
#define COLUMNEDGRIDLAYOUT_H
|
||||
#ifndef OAK_COLUMNEDGRIDLAYOUT_H
|
||||
#define OAK_COLUMNEDGRIDLAYOUT_H
|
||||
|
||||
#include <QGridLayout>
|
||||
|
||||
@@ -40,9 +40,9 @@ class ColumnedGridLayout : public QGridLayout {
|
||||
public:
|
||||
ColumnedGridLayout(QWidget *parent = nullptr, int maximum_columns = 0);
|
||||
|
||||
void Add(QWidget *widget);
|
||||
int MaximumColumns() const;
|
||||
void SetMaximumColumns(int maximum_columns);
|
||||
void add(QWidget *widget);
|
||||
int maximum_columns() const;
|
||||
void set_maximum_columns(int maximum_columns);
|
||||
|
||||
private:
|
||||
int maximum_columns_;
|
||||
@@ -50,4 +50,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // COLUMNEDGRIDLAYOUT_H
|
||||
#endif // OAK_COLUMNEDGRIDLAYOUT_H
|
||||
|
||||
@@ -43,17 +43,17 @@ CurveView::CurveView(QWidget *parent)
|
||||
, dragging_bezier_pt_(nullptr)
|
||||
{
|
||||
setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
||||
SetYAxisEnabled(true);
|
||||
SetAutoSelectSiblings(false);
|
||||
set_y_axis_enabled(true);
|
||||
set_auto_select_siblings(false);
|
||||
|
||||
text_padding_ =
|
||||
QtUtils::QFontMetricsWidth(fontMetrics(), QStringLiteral("i"));
|
||||
QtUtils::q_font_metrics_width(fontMetrics(), QStringLiteral("i"));
|
||||
|
||||
minimum_grid_space_ =
|
||||
QtUtils::QFontMetricsWidth(fontMetrics(), QStringLiteral("00000"));
|
||||
QtUtils::q_font_metrics_width(fontMetrics(), QStringLiteral("00000"));
|
||||
}
|
||||
|
||||
void CurveView::ConnectInput(const NodeKeyframeTrackReference &ref)
|
||||
void CurveView::connect_input(const NodeKeyframeTrackReference &ref)
|
||||
{
|
||||
if (connected_inputs_.contains(ref)) {
|
||||
// Input wasn't connected, do nothing
|
||||
@@ -61,19 +61,19 @@ void CurveView::ConnectInput(const NodeKeyframeTrackReference &ref)
|
||||
}
|
||||
|
||||
// Add keyframes from track
|
||||
KeyframeViewInputConnection *track_con = AddKeyframesOfTrack(ref);
|
||||
track_con->SetBrush(keyframe_colors_.value(ref));
|
||||
KeyframeViewInputConnection *track_con = add_keyframes_of_track(ref);
|
||||
track_con->set_brush(keyframe_colors_.value(ref));
|
||||
track_connections_.insert(ref, track_con);
|
||||
|
||||
// Signal to CurveWidget to update its bezier/linear/hold buttons if a key type changes
|
||||
connect(track_con, &KeyframeViewInputConnection::TypeChanged, this,
|
||||
&CurveView::SelectionChanged);
|
||||
connect(track_con, &KeyframeViewInputConnection::type_changed, this,
|
||||
&CurveView::selection_changed);
|
||||
|
||||
// Append to the list
|
||||
connected_inputs_.append(ref);
|
||||
}
|
||||
|
||||
void CurveView::DisconnectInput(const NodeKeyframeTrackReference &ref)
|
||||
void CurveView::disconnect_input(const NodeKeyframeTrackReference &ref)
|
||||
{
|
||||
if (!connected_inputs_.contains(ref)) {
|
||||
// Input wasn't connected, do nothing
|
||||
@@ -81,24 +81,24 @@ void CurveView::DisconnectInput(const NodeKeyframeTrackReference &ref)
|
||||
}
|
||||
|
||||
// Remove keyframes belonging to this element and track
|
||||
RemoveKeyframesOfTrack(track_connections_.take(ref));
|
||||
remove_keyframes_of_track(track_connections_.take(ref));
|
||||
|
||||
// Remove from the list
|
||||
connected_inputs_.removeOne(ref);
|
||||
}
|
||||
|
||||
void CurveView::SelectKeyframesOfInput(const NodeKeyframeTrackReference &ref)
|
||||
void CurveView::select_keyframes_of_input(const NodeKeyframeTrackReference &ref)
|
||||
{
|
||||
DeselectAll();
|
||||
deselect_all();
|
||||
|
||||
if (KeyframeViewInputConnection *con = track_connections_.value(ref)) {
|
||||
foreach (NodeKeyframe *key, con->GetKeyframes()) {
|
||||
SelectKeyframe(key);
|
||||
foreach (NodeKeyframe *key, con->get_keyframes()) {
|
||||
select_keyframe(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CurveView::SetKeyframeTrackColor(const NodeKeyframeTrackReference &ref,
|
||||
void CurveView::set_keyframe_track_color(const NodeKeyframeTrackReference &ref,
|
||||
const QColor &color)
|
||||
{
|
||||
// Insert color into hashmap
|
||||
@@ -106,7 +106,7 @@ void CurveView::SetKeyframeTrackColor(const NodeKeyframeTrackReference &ref,
|
||||
|
||||
if (KeyframeViewInputConnection *con = track_connections_.value(ref)) {
|
||||
// Update all keyframes
|
||||
con->SetBrush(color);
|
||||
con->set_brush(color);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ void CurveView::drawBackground(QPainter *painter, const QRectF &rect)
|
||||
|
||||
QVector<QLine> lines;
|
||||
|
||||
double x_interval = timebase().flipped().toDouble();
|
||||
double x_interval = timebase().flipped().to_double();
|
||||
double y_interval = 100.0;
|
||||
|
||||
int x_grid_interval, y_grid_interval;
|
||||
@@ -128,12 +128,12 @@ void CurveView::drawBackground(QPainter *painter, const QRectF &rect)
|
||||
painter->setPen(QPen(palette().window().color(), 1));
|
||||
|
||||
do {
|
||||
x_grid_interval = qRound(x_interval * GetScale() * timebase_dbl());
|
||||
x_grid_interval = qRound(x_interval * get_scale() * timebase_dbl());
|
||||
x_interval *= 2.0;
|
||||
} while (x_grid_interval < minimum_grid_space_);
|
||||
|
||||
do {
|
||||
y_grid_interval = qRound(y_interval * GetYScale());
|
||||
y_grid_interval = qRound(y_interval * get_y_scale());
|
||||
y_interval *= 2.0;
|
||||
} while (y_grid_interval < minimum_grid_space_);
|
||||
|
||||
@@ -146,7 +146,7 @@ void CurveView::drawBackground(QPainter *painter, const QRectF &rect)
|
||||
// Add vertical lines
|
||||
for (int i = x_start; i < rect.right(); i += x_grid_interval) {
|
||||
int value =
|
||||
qRound(static_cast<double>(i) / GetScale() / timebase_dbl());
|
||||
qRound(static_cast<double>(i) / get_scale() / timebase_dbl());
|
||||
painter->drawText(i + text_padding_,
|
||||
qRound(scene_bottom_left.y()) - text_padding_,
|
||||
QString::number(value));
|
||||
@@ -155,7 +155,7 @@ void CurveView::drawBackground(QPainter *painter, const QRectF &rect)
|
||||
|
||||
// Add horizontal lines
|
||||
for (int i = y_start; i < rect.bottom(); i += y_grid_interval) {
|
||||
int value = qRound(static_cast<double>(i) / GetYScale());
|
||||
int value = qRound(static_cast<double>(i) / get_y_scale());
|
||||
painter->drawText(qRound(scene_bottom_left.x()) + text_padding_,
|
||||
i - text_padding_, QString::number(-value));
|
||||
lines.append(QLine(qRound(rect.left()), i, qRound(rect.right()), i));
|
||||
@@ -169,9 +169,9 @@ void CurveView::drawBackground(QPainter *painter, const QRectF &rect)
|
||||
Node *node = ref.input().node();
|
||||
const QString &input = ref.input().input();
|
||||
|
||||
if (node->IsInputKeyframing(input, ref.input().element())) {
|
||||
if (node->is_input_keyframing(input, ref.input().element())) {
|
||||
const QVector<NodeKeyframeTrack> &tracks =
|
||||
node->GetKeyframeTracks(ref.input());
|
||||
node->get_keyframe_tracks(ref.input());
|
||||
|
||||
const NodeKeyframeTrack &track = tracks.at(ref.track());
|
||||
|
||||
@@ -183,7 +183,7 @@ void CurveView::drawBackground(QPainter *painter, const QRectF &rect)
|
||||
QPainterPath path;
|
||||
|
||||
// Draw straight line leading to first keyframe
|
||||
QPointF first_key_pos = GetKeyframePosition(track.first());
|
||||
QPointF first_key_pos = get_keyframe_position(track.first());
|
||||
path.moveTo(QPointF(scene_bottom_left.x(), first_key_pos.y()));
|
||||
path.lineTo(first_key_pos);
|
||||
|
||||
@@ -192,16 +192,16 @@ void CurveView::drawBackground(QPainter *painter, const QRectF &rect)
|
||||
NodeKeyframe *before = track.at(i - 1);
|
||||
NodeKeyframe *after = track.at(i);
|
||||
|
||||
QPointF before_pos = GetKeyframePosition(before);
|
||||
QPointF after_pos = GetKeyframePosition(after);
|
||||
QPointF before_pos = get_keyframe_position(before);
|
||||
QPointF after_pos = get_keyframe_position(after);
|
||||
|
||||
if (before->type() == NodeKeyframe::kHold) {
|
||||
if (before->type() == NodeKeyframe::k_hold) {
|
||||
// Draw a hold keyframe (basically a right angle)
|
||||
path.lineTo(after_pos.x(), before_pos.y());
|
||||
path.lineTo(after_pos.x(), after_pos.y());
|
||||
|
||||
} else if (before->type() == NodeKeyframe::kBezier &&
|
||||
after->type() == NodeKeyframe::kBezier) {
|
||||
} else if (before->type() == NodeKeyframe::k_bezier &&
|
||||
after->type() == NodeKeyframe::k_bezier) {
|
||||
// Draw a cubic bezier
|
||||
|
||||
// Cubic beziers have two control points, so we can just use both
|
||||
@@ -215,15 +215,15 @@ void CurveView::drawBackground(QPainter *painter, const QRectF &rect)
|
||||
path.cubicTo(before_control_point, after_control_point,
|
||||
after_pos);
|
||||
|
||||
} else if (before->type() == NodeKeyframe::kBezier ||
|
||||
after->type() == NodeKeyframe::kBezier) {
|
||||
} else if (before->type() == NodeKeyframe::k_bezier ||
|
||||
after->type() == NodeKeyframe::k_bezier) {
|
||||
// Draw a quadratic bezier
|
||||
|
||||
// Quadratic beziers have a single control point, we just have to determine which it is
|
||||
QPointF key_anchor;
|
||||
QPointF control_point;
|
||||
|
||||
if (before->type() == NodeKeyframe::kBezier) {
|
||||
if (before->type() == NodeKeyframe::k_bezier) {
|
||||
key_anchor = before_pos;
|
||||
control_point = before->valid_bezier_control_out();
|
||||
} else {
|
||||
@@ -244,7 +244,7 @@ void CurveView::drawBackground(QPainter *painter, const QRectF &rect)
|
||||
}
|
||||
|
||||
// Draw straight line leading from end keyframe
|
||||
QPointF last_key_pos = GetKeyframePosition(track.last());
|
||||
QPointF last_key_pos = get_keyframe_position(track.last());
|
||||
path.lineTo(QPointF(scene_top_right.x(), last_key_pos.y()));
|
||||
|
||||
painter->drawPath(path);
|
||||
@@ -264,15 +264,15 @@ void CurveView::ContextMenuEvent(Menu &m)
|
||||
{
|
||||
// View settings
|
||||
QAction *zoom_fit_action = m.addAction(tr("Zoom to Fit"));
|
||||
connect(zoom_fit_action, &QAction::triggered, this, &CurveView::ZoomToFit);
|
||||
connect(zoom_fit_action, &QAction::triggered, this, &CurveView::zoom_to_fit);
|
||||
|
||||
QAction *zoom_fit_selected_action = m.addAction(tr("Zoom to Fit Selected"));
|
||||
connect(zoom_fit_selected_action, &QAction::triggered, this,
|
||||
&CurveView::ZoomToFitSelected);
|
||||
&CurveView::zoom_to_fit_selected);
|
||||
|
||||
QAction *reset_zoom_action = m.addAction(tr("Reset Zoom"));
|
||||
connect(reset_zoom_action, &QAction::triggered, this,
|
||||
&CurveView::ResetZoom);
|
||||
&CurveView::reset_zoom);
|
||||
}
|
||||
|
||||
void CurveView::SceneRectUpdateEvent(QRectF &r)
|
||||
@@ -281,8 +281,8 @@ void CurveView::SceneRectUpdateEvent(QRectF &r)
|
||||
bool got_val = false;
|
||||
|
||||
foreach (KeyframeViewInputConnection *con, track_connections_) {
|
||||
foreach (NodeKeyframe *key, con->GetKeyframes()) {
|
||||
qreal key_y = GetItemYFromKeyframeValue(key);
|
||||
foreach (NodeKeyframe *key, con->get_keyframes()) {
|
||||
qreal key_y = get_item_y_from_keyframe_value(key);
|
||||
|
||||
if (got_val) {
|
||||
min_val = qMin(key_y, min_val);
|
||||
@@ -301,19 +301,19 @@ void CurveView::SceneRectUpdateEvent(QRectF &r)
|
||||
}
|
||||
}
|
||||
|
||||
qreal CurveView::GetKeyframeSceneY(KeyframeViewInputConnection *track,
|
||||
qreal CurveView::get_keyframe_scene_y(KeyframeViewInputConnection *track,
|
||||
NodeKeyframe *key)
|
||||
{
|
||||
return GetItemYFromKeyframeValue(key);
|
||||
return get_item_y_from_keyframe_value(key);
|
||||
}
|
||||
|
||||
void CurveView::DrawKeyframe(QPainter *painter, NodeKeyframe *key,
|
||||
void CurveView::draw_keyframe(QPainter *painter, NodeKeyframe *key,
|
||||
KeyframeViewInputConnection *track,
|
||||
const QRectF &key_rect)
|
||||
{
|
||||
if (IsKeyframeSelected(key) && key->type() == NodeKeyframe::kBezier) {
|
||||
if (is_keyframe_selected(key) && key->type() == NodeKeyframe::k_bezier) {
|
||||
// Draw bezier control points if keyframe is selected
|
||||
int control_point_size = QtUtils::QFontMetricsWidth(fontMetrics(), "o");
|
||||
int control_point_size = QtUtils::q_font_metrics_width(fontMetrics(), "o");
|
||||
int half_sz = control_point_size / 2;
|
||||
QRectF control_point_rect(-half_sz, -half_sz, control_point_size,
|
||||
control_point_size);
|
||||
@@ -332,14 +332,14 @@ void CurveView::DrawKeyframe(QPainter *painter, NodeKeyframe *key,
|
||||
painter->drawEllipse(cp_in);
|
||||
painter->drawEllipse(cp_out);
|
||||
|
||||
bezier_pts_.append({ cp_in, key, NodeKeyframe::kInHandle });
|
||||
bezier_pts_.append({ cp_out, key, NodeKeyframe::kOutHandle });
|
||||
bezier_pts_.append({ cp_in, key, NodeKeyframe::k_in_handle });
|
||||
bezier_pts_.append({ cp_out, key, NodeKeyframe::k_out_handle });
|
||||
}
|
||||
|
||||
super::DrawKeyframe(painter, key, track, key_rect);
|
||||
super::draw_keyframe(painter, key, track, key_rect);
|
||||
}
|
||||
|
||||
bool CurveView::FirstChanceMousePress(QMouseEvent *event)
|
||||
bool CurveView::first_chance_mouse_press(QMouseEvent *event)
|
||||
{
|
||||
dragging_bezier_pt_ = nullptr;
|
||||
QPointF scene_pt = mapToScene(event->pos());
|
||||
@@ -353,11 +353,11 @@ bool CurveView::FirstChanceMousePress(QMouseEvent *event)
|
||||
if (dragging_bezier_pt_) {
|
||||
NodeKeyframe *key = dragging_bezier_pt_->keyframe;
|
||||
dragging_bezier_point_start_ =
|
||||
(dragging_bezier_pt_->type == NodeKeyframe::kInHandle) ?
|
||||
(dragging_bezier_pt_->type == NodeKeyframe::k_in_handle) ?
|
||||
key->bezier_control_in() :
|
||||
key->bezier_control_out();
|
||||
dragging_bezier_point_opposing_start_ =
|
||||
(dragging_bezier_pt_->type == NodeKeyframe::kInHandle) ?
|
||||
(dragging_bezier_pt_->type == NodeKeyframe::k_in_handle) ?
|
||||
key->bezier_control_out() :
|
||||
key->bezier_control_in();
|
||||
|
||||
@@ -368,11 +368,11 @@ bool CurveView::FirstChanceMousePress(QMouseEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
void CurveView::FirstChanceMouseMove(QMouseEvent *event)
|
||||
void CurveView::first_chance_mouse_move(QMouseEvent *event)
|
||||
{
|
||||
// Calculate cursor difference and scale it
|
||||
QPointF scene_pos = mapToScene(event->pos());
|
||||
QPointF mouse_diff_scaled = GetScaledCursorPos(scene_pos - drag_start_);
|
||||
QPointF mouse_diff_scaled = get_scaled_cursor_pos(scene_pos - drag_start_);
|
||||
|
||||
if (event->modifiers() & Qt::ShiftModifier) {
|
||||
// If holding shift, only move one axis
|
||||
@@ -382,7 +382,7 @@ void CurveView::FirstChanceMouseMove(QMouseEvent *event)
|
||||
// Flip the mouse Y because bezier control points are drawn bottom to top, not top to bottom
|
||||
mouse_diff_scaled.setY(-mouse_diff_scaled.y());
|
||||
|
||||
QPointF new_bezier_pos = GenerateBezierControlPosition(
|
||||
QPointF new_bezier_pos = generate_bezier_control_position(
|
||||
dragging_bezier_pt_->type, dragging_bezier_point_start_,
|
||||
mouse_diff_scaled);
|
||||
|
||||
@@ -392,7 +392,7 @@ void CurveView::FirstChanceMouseMove(QMouseEvent *event)
|
||||
NodeKeyframe::get_opposing_bezier_type(dragging_bezier_pt_->type);
|
||||
|
||||
if (!(event->modifiers() & Qt::ControlModifier)) {
|
||||
new_opposing_pos = GenerateBezierControlPosition(
|
||||
new_opposing_pos = generate_bezier_control_position(
|
||||
opposing_type, dragging_bezier_point_opposing_start_,
|
||||
-mouse_diff_scaled);
|
||||
} else {
|
||||
@@ -405,10 +405,10 @@ void CurveView::FirstChanceMouseMove(QMouseEvent *event)
|
||||
dragging_bezier_pt_->keyframe->set_bezier_control(opposing_type,
|
||||
new_opposing_pos);
|
||||
|
||||
Redraw();
|
||||
redraw();
|
||||
}
|
||||
|
||||
void CurveView::FirstChanceMouseRelease(QMouseEvent *event)
|
||||
void CurveView::first_chance_mouse_release(QMouseEvent *event)
|
||||
{
|
||||
MultiUndoCommand *command = new MultiUndoCommand();
|
||||
|
||||
@@ -434,23 +434,23 @@ void CurveView::FirstChanceMouseRelease(QMouseEvent *event)
|
||||
command, tr("Moved Keyframe Bezier Control Point"));
|
||||
}
|
||||
|
||||
void CurveView::KeyframeDragStart(QMouseEvent *event)
|
||||
void CurveView::keyframe_drag_start(QMouseEvent *event)
|
||||
{
|
||||
drag_keyframe_values_.resize(GetSelectedKeyframes().size());
|
||||
for (size_t i = 0; i < GetSelectedKeyframes().size(); i++) {
|
||||
NodeKeyframe *key = GetSelectedKeyframes().at(i);
|
||||
drag_keyframe_values_.resize(get_selected_keyframes().size());
|
||||
for (size_t i = 0; i < get_selected_keyframes().size(); i++) {
|
||||
NodeKeyframe *key = get_selected_keyframes().at(i);
|
||||
drag_keyframe_values_[i] = key->value();
|
||||
}
|
||||
|
||||
drag_start_ = mapToScene(event->pos());
|
||||
}
|
||||
|
||||
void CurveView::KeyframeDragMove(QMouseEvent *event, QString &tip)
|
||||
void CurveView::keyframe_drag_move(QMouseEvent *event, QString &tip)
|
||||
{
|
||||
if (event->modifiers() & Qt::ShiftModifier) {
|
||||
// Lock to X axis only and set original values on all keys
|
||||
for (size_t i = 0; i < GetSelectedKeyframes().size(); i++) {
|
||||
NodeKeyframe *key = GetSelectedKeyframes().at(i);
|
||||
for (size_t i = 0; i < get_selected_keyframes().size(); i++) {
|
||||
NodeKeyframe *key = get_selected_keyframes().at(i);
|
||||
key->set_value(drag_keyframe_values_.at(i));
|
||||
}
|
||||
return;
|
||||
@@ -458,31 +458,31 @@ void CurveView::KeyframeDragMove(QMouseEvent *event, QString &tip)
|
||||
|
||||
// Calculate cursor difference
|
||||
double scaled_diff =
|
||||
(mapToScene(event->pos()).y() - drag_start_.y()) / GetYScale();
|
||||
(mapToScene(event->pos()).y() - drag_start_.y()) / get_y_scale();
|
||||
|
||||
// Validate movement - ensure no keyframe goes above its max point or below its min point
|
||||
for (size_t i = 0; i < GetSelectedKeyframes().size(); i++) {
|
||||
NodeKeyframe *key = GetSelectedKeyframes().at(i);
|
||||
for (size_t i = 0; i < get_selected_keyframes().size(); i++) {
|
||||
NodeKeyframe *key = get_selected_keyframes().at(i);
|
||||
|
||||
FloatSlider::DisplayType display = GetFloatDisplayTypeFromKeyframe(key);
|
||||
FloatSlider::DisplayType display = get_float_display_type_from_keyframe(key);
|
||||
Node *node = key->parent();
|
||||
double original_val = FloatSlider::TransformValueToDisplay(
|
||||
double original_val = FloatSlider::transform_value_to_display(
|
||||
drag_keyframe_values_.at(i).toDouble(), display);
|
||||
const QString &input = key->input();
|
||||
double new_val = FloatSlider::TransformDisplayToValue(
|
||||
double new_val = FloatSlider::transform_display_to_value(
|
||||
original_val - scaled_diff, display);
|
||||
double limited = new_val;
|
||||
|
||||
if (node->HasInputProperty(input, QStringLiteral("min"))) {
|
||||
if (node->has_input_property(input, QStringLiteral("min"))) {
|
||||
limited = qMax(
|
||||
limited,
|
||||
node->GetInputProperty(input, QStringLiteral("min")).toDouble());
|
||||
node->get_input_property(input, QStringLiteral("min")).toDouble());
|
||||
}
|
||||
|
||||
if (node->HasInputProperty(input, QStringLiteral("max"))) {
|
||||
if (node->has_input_property(input, QStringLiteral("max"))) {
|
||||
limited = qMin(
|
||||
limited,
|
||||
node->GetInputProperty(input, QStringLiteral("max")).toDouble());
|
||||
node->get_input_property(input, QStringLiteral("max")).toDouble());
|
||||
}
|
||||
|
||||
if (limited != new_val) {
|
||||
@@ -491,34 +491,34 @@ void CurveView::KeyframeDragMove(QMouseEvent *event, QString &tip)
|
||||
}
|
||||
|
||||
// Set values
|
||||
for (size_t i = 0; i < GetSelectedKeyframes().size(); i++) {
|
||||
NodeKeyframe *key = GetSelectedKeyframes().at(i);
|
||||
FloatSlider::DisplayType display = GetFloatDisplayTypeFromKeyframe(key);
|
||||
key->set_value(FloatSlider::TransformDisplayToValue(
|
||||
FloatSlider::TransformValueToDisplay(
|
||||
for (size_t i = 0; i < get_selected_keyframes().size(); i++) {
|
||||
NodeKeyframe *key = get_selected_keyframes().at(i);
|
||||
FloatSlider::DisplayType display = get_float_display_type_from_keyframe(key);
|
||||
key->set_value(FloatSlider::transform_display_to_value(
|
||||
FloatSlider::transform_value_to_display(
|
||||
drag_keyframe_values_.at(i).toDouble(), display) -
|
||||
scaled_diff,
|
||||
display));
|
||||
}
|
||||
|
||||
NodeKeyframe *tip_item = GetSelectedKeyframes().front();
|
||||
NodeKeyframe *tip_item = get_selected_keyframes().front();
|
||||
|
||||
bool ok;
|
||||
double num_value = tip_item->value().toDouble(&ok);
|
||||
|
||||
if (ok) {
|
||||
tip = QStringLiteral("%1\n");
|
||||
tip.append(FloatSlider::ValueToString(
|
||||
num_value + GetOffsetFromKeyframe(tip_item),
|
||||
GetFloatDisplayTypeFromKeyframe(tip_item), 2, true));
|
||||
tip.append(FloatSlider::value_to_string(
|
||||
num_value + get_offset_from_keyframe(tip_item),
|
||||
get_float_display_type_from_keyframe(tip_item), 2, true));
|
||||
}
|
||||
}
|
||||
|
||||
void CurveView::KeyframeDragRelease(QMouseEvent *event,
|
||||
void CurveView::keyframe_drag_release(QMouseEvent *event,
|
||||
MultiUndoCommand *command)
|
||||
{
|
||||
for (size_t i = 0; i < GetSelectedKeyframes().size(); i++) {
|
||||
NodeKeyframe *k = GetSelectedKeyframes().at(i);
|
||||
for (size_t i = 0; i < get_selected_keyframes().size(); i++) {
|
||||
NodeKeyframe *k = get_selected_keyframes().at(i);
|
||||
if (!qFuzzyCompare(k->value().toDouble(),
|
||||
drag_keyframe_values_.at(i).toDouble())) {
|
||||
command->add_child(new NodeParamSetKeyframeValueCommand(
|
||||
@@ -528,7 +528,7 @@ void CurveView::KeyframeDragRelease(QMouseEvent *event,
|
||||
}
|
||||
|
||||
QPointF
|
||||
CurveView::GenerateBezierControlPosition(const NodeKeyframe::BezierType mode,
|
||||
CurveView::generate_bezier_control_position(const NodeKeyframe::BezierType mode,
|
||||
const QPointF &start_point,
|
||||
const QPointF &scaled_cursor_diff)
|
||||
{
|
||||
@@ -537,7 +537,7 @@ CurveView::GenerateBezierControlPosition(const NodeKeyframe::BezierType mode,
|
||||
new_bezier_pos += scaled_cursor_diff;
|
||||
|
||||
// LIMIT bezier handles from overlapping each other
|
||||
if (mode == NodeKeyframe::kInHandle) {
|
||||
if (mode == NodeKeyframe::k_in_handle) {
|
||||
if (new_bezier_pos.x() > 0) {
|
||||
new_bezier_pos.setX(0);
|
||||
}
|
||||
@@ -550,26 +550,26 @@ CurveView::GenerateBezierControlPosition(const NodeKeyframe::BezierType mode,
|
||||
return new_bezier_pos;
|
||||
}
|
||||
|
||||
QPointF CurveView::GetScaledCursorPos(const QPointF &cursor_pos)
|
||||
QPointF CurveView::get_scaled_cursor_pos(const QPointF &cursor_pos)
|
||||
{
|
||||
return QPointF(cursor_pos.x() / GetScale(), cursor_pos.y() / GetYScale());
|
||||
return QPointF(cursor_pos.x() / get_scale(), cursor_pos.y() / get_y_scale());
|
||||
}
|
||||
|
||||
void CurveView::ZoomToFitInternal(bool selected_only)
|
||||
void CurveView::zoom_to_fit_internal(bool selected_only)
|
||||
{
|
||||
bool got_val = false;
|
||||
|
||||
rational min_time, max_time;
|
||||
Rational min_time, max_time;
|
||||
double min_val, max_val;
|
||||
|
||||
foreach (KeyframeViewInputConnection *con, track_connections_) {
|
||||
foreach (NodeKeyframe *key, con->GetKeyframes()) {
|
||||
if (!selected_only || IsKeyframeSelected(key)) {
|
||||
rational transformed_time =
|
||||
GetAdjustedTime(key->parent(), GetTimeTarget(), key->time(),
|
||||
Node::kTransformTowardsOutput);
|
||||
foreach (NodeKeyframe *key, con->get_keyframes()) {
|
||||
if (!selected_only || is_keyframe_selected(key)) {
|
||||
Rational transformed_time =
|
||||
get_adjusted_time(key->parent(), get_time_target(), key->time(),
|
||||
Node::k_transform_towards_output);
|
||||
|
||||
qreal key_y = GetUnscaledItemYFromKeyframeValue(key);
|
||||
qreal key_y = get_unscaled_item_y_from_keyframe_value(key);
|
||||
|
||||
if (got_val) {
|
||||
min_time = qMin(transformed_time, min_time);
|
||||
@@ -592,8 +592,8 @@ void CurveView::ZoomToFitInternal(bool selected_only)
|
||||
|
||||
// Prevent scaling if no keyframes were found
|
||||
if (got_val) {
|
||||
QRectF desired(QPointF(min_time.toDouble(), min_val),
|
||||
QPointF(max_time.toDouble(), max_val));
|
||||
QRectF desired(QPointF(min_time.to_double(), min_val),
|
||||
QPointF(max_time.to_double(), max_val));
|
||||
|
||||
const double scale_divider = 0.5;
|
||||
double scale_half_divider = scale_divider * 0.5;
|
||||
@@ -612,10 +612,10 @@ void CurveView::ZoomToFitInternal(bool selected_only)
|
||||
viewport()->height() / desired.height() * scale_divider;
|
||||
}
|
||||
|
||||
emit ScaleChanged(new_x_scale);
|
||||
SetYScale(new_y_scale);
|
||||
emit scale_changed(new_x_scale);
|
||||
set_y_scale(new_y_scale);
|
||||
|
||||
UpdateSceneRect();
|
||||
update_scene_rect();
|
||||
|
||||
int sb_x = desired.left() * new_x_scale -
|
||||
viewport()->width() * scale_half_divider;
|
||||
@@ -629,19 +629,19 @@ void CurveView::ZoomToFitInternal(bool selected_only)
|
||||
}
|
||||
}
|
||||
|
||||
qreal CurveView::GetItemYFromKeyframeValue(NodeKeyframe *key)
|
||||
qreal CurveView::get_item_y_from_keyframe_value(NodeKeyframe *key)
|
||||
{
|
||||
return GetUnscaledItemYFromKeyframeValue(key) * GetYScale();
|
||||
return get_unscaled_item_y_from_keyframe_value(key) * get_y_scale();
|
||||
}
|
||||
|
||||
qreal CurveView::GetUnscaledItemYFromKeyframeValue(NodeKeyframe *key)
|
||||
qreal CurveView::get_unscaled_item_y_from_keyframe_value(NodeKeyframe *key)
|
||||
{
|
||||
double val = key->value().toDouble();
|
||||
|
||||
val = FloatSlider::TransformValueToDisplay(
|
||||
val, GetFloatDisplayTypeFromKeyframe(key));
|
||||
val = FloatSlider::transform_value_to_display(
|
||||
val, get_float_display_type_from_keyframe(key));
|
||||
|
||||
val += GetOffsetFromKeyframe(key);
|
||||
val += get_offset_from_keyframe(key);
|
||||
|
||||
return -val;
|
||||
}
|
||||
@@ -649,35 +649,35 @@ qreal CurveView::GetUnscaledItemYFromKeyframeValue(NodeKeyframe *key)
|
||||
QPointF CurveView::ScalePoint(const QPointF &point)
|
||||
{
|
||||
// Flips Y coordinate because curves are drawn bottom to top
|
||||
return QPointF(point.x() * GetScale(), -point.y() * GetYScale());
|
||||
return QPointF(point.x() * get_scale(), -point.y() * get_y_scale());
|
||||
}
|
||||
|
||||
FloatSlider::DisplayType
|
||||
CurveView::GetFloatDisplayTypeFromKeyframe(NodeKeyframe *key)
|
||||
CurveView::get_float_display_type_from_keyframe(NodeKeyframe *key)
|
||||
{
|
||||
Node *node = key->parent();
|
||||
const QString &input = key->input();
|
||||
if (node->HasInputProperty(input, QStringLiteral("view"))) {
|
||||
if (node->has_input_property(input, QStringLiteral("view"))) {
|
||||
// Try to get view from input (which will be normal if unset)
|
||||
return static_cast<FloatSlider::DisplayType>(
|
||||
node->GetInputProperty(input, QStringLiteral("view")).toInt());
|
||||
node->get_input_property(input, QStringLiteral("view")).toInt());
|
||||
}
|
||||
|
||||
// Fallback to normal
|
||||
return FloatSlider::kNormal;
|
||||
return FloatSlider::k_normal;
|
||||
}
|
||||
|
||||
double CurveView::GetOffsetFromKeyframe(NodeKeyframe *key)
|
||||
double CurveView::get_offset_from_keyframe(NodeKeyframe *key)
|
||||
{
|
||||
Node *node = key->parent();
|
||||
const QString &input = key->input();
|
||||
if (node->HasInputProperty(input, QStringLiteral("offset"))) {
|
||||
QVariant v = node->GetInputProperty(input, QStringLiteral("offset"));
|
||||
if (node->has_input_property(input, QStringLiteral("offset"))) {
|
||||
QVariant v = node->get_input_property(input, QStringLiteral("offset"));
|
||||
|
||||
// NOTE: Implement getting correct offset for the track based on the data type
|
||||
QVector<QVariant> track_vals =
|
||||
NodeValue::split_normal_value_into_track_values(
|
||||
node->GetInputDataType(input), v);
|
||||
node->get_input_data_type(input), v);
|
||||
|
||||
return track_vals.at(key->track()).toDouble();
|
||||
}
|
||||
@@ -685,25 +685,25 @@ double CurveView::GetOffsetFromKeyframe(NodeKeyframe *key)
|
||||
return 0;
|
||||
}
|
||||
|
||||
QPointF CurveView::GetKeyframePosition(NodeKeyframe *key)
|
||||
QPointF CurveView::get_keyframe_position(NodeKeyframe *key)
|
||||
{
|
||||
return QPointF(GetKeyframeSceneX(key), GetItemYFromKeyframeValue(key));
|
||||
return QPointF(get_keyframe_scene_x(key), get_item_y_from_keyframe_value(key));
|
||||
}
|
||||
|
||||
void CurveView::ZoomToFit()
|
||||
void CurveView::zoom_to_fit()
|
||||
{
|
||||
ZoomToFitInternal(false);
|
||||
zoom_to_fit_internal(false);
|
||||
}
|
||||
|
||||
void CurveView::ZoomToFitSelected()
|
||||
void CurveView::zoom_to_fit_selected()
|
||||
{
|
||||
ZoomToFitInternal(true);
|
||||
zoom_to_fit_internal(true);
|
||||
}
|
||||
|
||||
void CurveView::ResetZoom()
|
||||
void CurveView::reset_zoom()
|
||||
{
|
||||
emit ScaleChanged(1.0);
|
||||
SetYScale(1.0);
|
||||
emit scale_changed(1.0);
|
||||
set_y_scale(1.0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef CURVEVIEW_H
|
||||
#define CURVEVIEW_H
|
||||
#ifndef OAK_CURVEVIEW_H
|
||||
#define OAK_CURVEVIEW_H
|
||||
|
||||
#include "node/keyframe.h"
|
||||
#include "widget/keyframeview/keyframeview.h"
|
||||
@@ -34,27 +34,27 @@ class CurveView : public KeyframeView {
|
||||
public:
|
||||
CurveView(QWidget *parent = nullptr);
|
||||
|
||||
void ConnectInput(const NodeKeyframeTrackReference &ref);
|
||||
void connect_input(const NodeKeyframeTrackReference &ref);
|
||||
|
||||
void DisconnectInput(const NodeKeyframeTrackReference &ref);
|
||||
void disconnect_input(const NodeKeyframeTrackReference &ref);
|
||||
|
||||
void SelectKeyframesOfInput(const NodeKeyframeTrackReference &ref);
|
||||
void select_keyframes_of_input(const NodeKeyframeTrackReference &ref);
|
||||
|
||||
void SetKeyframeTrackColor(const NodeKeyframeTrackReference &ref,
|
||||
void set_keyframe_track_color(const NodeKeyframeTrackReference &ref,
|
||||
const QColor &color);
|
||||
|
||||
const QHash<NodeKeyframeTrackReference, KeyframeViewInputConnection *> &
|
||||
GetConnections() const
|
||||
get_connections() const
|
||||
{
|
||||
return track_connections_;
|
||||
}
|
||||
|
||||
public slots:
|
||||
void ZoomToFit();
|
||||
void zoom_to_fit();
|
||||
|
||||
void ZoomToFitSelected();
|
||||
void zoom_to_fit_selected();
|
||||
|
||||
void ResetZoom();
|
||||
void reset_zoom();
|
||||
|
||||
protected:
|
||||
virtual void drawBackground(QPainter *painter, const QRectF &rect) override;
|
||||
@@ -64,45 +64,45 @@ protected:
|
||||
|
||||
virtual void SceneRectUpdateEvent(QRectF &r) override;
|
||||
|
||||
virtual qreal GetKeyframeSceneY(KeyframeViewInputConnection *track,
|
||||
virtual qreal get_keyframe_scene_y(KeyframeViewInputConnection *track,
|
||||
NodeKeyframe *key) override;
|
||||
|
||||
virtual void DrawKeyframe(QPainter *painter, NodeKeyframe *key,
|
||||
virtual void draw_keyframe(QPainter *painter, NodeKeyframe *key,
|
||||
KeyframeViewInputConnection *track,
|
||||
const QRectF &key_rect) override;
|
||||
|
||||
virtual bool FirstChanceMousePress(QMouseEvent *event) override;
|
||||
virtual void FirstChanceMouseMove(QMouseEvent *event) override;
|
||||
virtual void FirstChanceMouseRelease(QMouseEvent *event) override;
|
||||
virtual bool first_chance_mouse_press(QMouseEvent *event) override;
|
||||
virtual void first_chance_mouse_move(QMouseEvent *event) override;
|
||||
virtual void first_chance_mouse_release(QMouseEvent *event) override;
|
||||
|
||||
virtual void KeyframeDragStart(QMouseEvent *event) override;
|
||||
virtual void KeyframeDragMove(QMouseEvent *event, QString &tip) override;
|
||||
virtual void KeyframeDragRelease(QMouseEvent *event,
|
||||
virtual void keyframe_drag_start(QMouseEvent *event) override;
|
||||
virtual void keyframe_drag_move(QMouseEvent *event, QString &tip) override;
|
||||
virtual void keyframe_drag_release(QMouseEvent *event,
|
||||
MultiUndoCommand *command) override;
|
||||
|
||||
private:
|
||||
void ZoomToFitInternal(bool selected_only);
|
||||
void zoom_to_fit_internal(bool selected_only);
|
||||
|
||||
qreal GetItemYFromKeyframeValue(NodeKeyframe *key);
|
||||
qreal GetUnscaledItemYFromKeyframeValue(NodeKeyframe *key);
|
||||
qreal get_item_y_from_keyframe_value(NodeKeyframe *key);
|
||||
qreal get_unscaled_item_y_from_keyframe_value(NodeKeyframe *key);
|
||||
|
||||
QPointF ScalePoint(const QPointF &point);
|
||||
|
||||
static FloatSlider::DisplayType
|
||||
GetFloatDisplayTypeFromKeyframe(NodeKeyframe *key);
|
||||
get_float_display_type_from_keyframe(NodeKeyframe *key);
|
||||
|
||||
static double GetOffsetFromKeyframe(NodeKeyframe *key);
|
||||
static double get_offset_from_keyframe(NodeKeyframe *key);
|
||||
|
||||
void AdjustLines();
|
||||
void adjust_lines();
|
||||
|
||||
QPointF GetKeyframePosition(NodeKeyframe *key);
|
||||
QPointF get_keyframe_position(NodeKeyframe *key);
|
||||
|
||||
static QPointF
|
||||
GenerateBezierControlPosition(const NodeKeyframe::BezierType mode,
|
||||
generate_bezier_control_position(const NodeKeyframe::BezierType mode,
|
||||
const QPointF &start_point,
|
||||
const QPointF &scaled_cursor_diff);
|
||||
|
||||
QPointF GetScaledCursorPos(const QPointF &cursor_pos);
|
||||
QPointF get_scaled_cursor_pos(const QPointF &cursor_pos);
|
||||
|
||||
QHash<NodeKeyframeTrackReference, QColor> keyframe_colors_;
|
||||
QHash<NodeKeyframeTrackReference, KeyframeViewInputConnection *>
|
||||
@@ -132,4 +132,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // CURVEVIEW_H
|
||||
#endif // OAK_CURVEVIEW_H
|
||||
|
||||
@@ -47,10 +47,10 @@ CurveWidget::CurveWidget(QWidget *parent)
|
||||
outer_layout->addWidget(splitter);
|
||||
|
||||
tree_view_ = new NodeTreeView();
|
||||
tree_view_->SetOnlyShowKeyframable(true);
|
||||
tree_view_->SetShowKeyframeTracksAsRows(true);
|
||||
connect(tree_view_, &NodeTreeView::InputSelectionChanged, this,
|
||||
&CurveWidget::InputSelectionChanged);
|
||||
tree_view_->set_only_show_keyframable(true);
|
||||
tree_view_->set_show_keyframe_tracks_as_rows(true);
|
||||
connect(tree_view_, &NodeTreeView::input_selection_changed, this,
|
||||
&CurveWidget::input_selection_changed);
|
||||
splitter->addWidget(tree_view_);
|
||||
|
||||
QWidget *workarea = new QWidget();
|
||||
@@ -70,21 +70,21 @@ CurveWidget::CurveWidget(QWidget *parent)
|
||||
linear_button_->setEnabled(false);
|
||||
top_controls->addWidget(linear_button_);
|
||||
connect(linear_button_, &QPushButton::clicked, this,
|
||||
&CurveWidget::KeyframeTypeButtonTriggered);
|
||||
&CurveWidget::keyframe_type_button_triggered);
|
||||
|
||||
bezier_button_ = new QPushButton(tr("Bezier"));
|
||||
bezier_button_->setCheckable(true);
|
||||
bezier_button_->setEnabled(false);
|
||||
top_controls->addWidget(bezier_button_);
|
||||
connect(bezier_button_, &QPushButton::clicked, this,
|
||||
&CurveWidget::KeyframeTypeButtonTriggered);
|
||||
&CurveWidget::keyframe_type_button_triggered);
|
||||
|
||||
hold_button_ = new QPushButton(tr("Hold"));
|
||||
hold_button_->setCheckable(true);
|
||||
hold_button_->setEnabled(false);
|
||||
top_controls->addWidget(hold_button_);
|
||||
connect(hold_button_, &QPushButton::clicked, this,
|
||||
&CurveWidget::KeyframeTypeButtonTriggered);
|
||||
&CurveWidget::keyframe_type_button_triggered);
|
||||
|
||||
layout->addLayout(top_controls);
|
||||
|
||||
@@ -96,19 +96,19 @@ CurveWidget::CurveWidget(QWidget *parent)
|
||||
ruler_view_layout->addWidget(ruler());
|
||||
|
||||
view_ = new CurveView();
|
||||
ConnectTimelineView(view_);
|
||||
view_->SetSnapService(this);
|
||||
connect_timeline_view(view_);
|
||||
view_->set_snap_service(this);
|
||||
ruler_view_layout->addWidget(view_);
|
||||
|
||||
layout->addLayout(ruler_view_layout);
|
||||
|
||||
// Connect ruler and view together
|
||||
connect(view_, &CurveView::SelectionChanged, this,
|
||||
&CurveWidget::SelectionChanged);
|
||||
connect(view_, &CurveView::Dragged, this,
|
||||
&CurveWidget::KeyframeViewDragged);
|
||||
connect(view_, &CurveView::Released, this,
|
||||
&CurveWidget::KeyframeViewReleased);
|
||||
connect(view_, &CurveView::selection_changed, this,
|
||||
&CurveWidget::selection_changed);
|
||||
connect(view_, &CurveView::dragged, this,
|
||||
&CurveWidget::keyframe_view_dragged);
|
||||
connect(view_, &CurveView::released, this,
|
||||
&CurveWidget::keyframe_view_released);
|
||||
|
||||
// TimeBasedWidget's scrollbar has extra functionality that we can take advantage of
|
||||
view_->setHorizontalScrollBar(scrollbar());
|
||||
@@ -119,25 +119,25 @@ CurveWidget::CurveWidget(QWidget *parent)
|
||||
SetScale(120.0);
|
||||
}
|
||||
|
||||
const double &CurveWidget::GetVerticalScale()
|
||||
const double &CurveWidget::get_vertical_scale()
|
||||
{
|
||||
return view_->GetYScale();
|
||||
return view_->get_y_scale();
|
||||
}
|
||||
|
||||
void CurveWidget::SetVerticalScale(const double &vscale)
|
||||
void CurveWidget::set_vertical_scale(const double &vscale)
|
||||
{
|
||||
view_->SetYScale(vscale);
|
||||
view_->set_y_scale(vscale);
|
||||
}
|
||||
|
||||
void CurveWidget::DeleteSelected()
|
||||
{
|
||||
view_->DeleteSelected();
|
||||
view_->delete_selected();
|
||||
}
|
||||
|
||||
Node *CurveWidget::GetSelectedNodeWithID(const QString &id)
|
||||
Node *CurveWidget::get_selected_node_with_id(const QString &id)
|
||||
{
|
||||
for (auto it = view_->GetConnections().cbegin();
|
||||
it != view_->GetConnections().cend(); it++) {
|
||||
for (auto it = view_->get_connections().cbegin();
|
||||
it != view_->get_connections().cend(); it++) {
|
||||
Node *n = it.key().input().node();
|
||||
if (n->id() == id) {
|
||||
return n;
|
||||
@@ -147,28 +147,28 @@ Node *CurveWidget::GetSelectedNodeWithID(const QString &id)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CurveWidget::CopySelected(bool cut)
|
||||
bool CurveWidget::copy_selected(bool cut)
|
||||
{
|
||||
if (super::CopySelected(cut)) {
|
||||
if (super::copy_selected(cut)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return view_->CopySelected(cut);
|
||||
return view_->copy_selected(cut);
|
||||
}
|
||||
|
||||
bool CurveWidget::Paste()
|
||||
bool CurveWidget::paste()
|
||||
{
|
||||
if (super::Paste()) {
|
||||
if (super::paste()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return view_->Paste(std::bind(&CurveWidget::GetSelectedNodeWithID, this,
|
||||
return view_->paste(std::bind(&CurveWidget::get_selected_node_with_id, this,
|
||||
std::placeholders::_1));
|
||||
}
|
||||
|
||||
void CurveWidget::SetNodes(const QVector<Node *> &nodes)
|
||||
void CurveWidget::set_nodes(const QVector<Node *> &nodes)
|
||||
{
|
||||
tree_view_->SetNodes(nodes);
|
||||
tree_view_->set_nodes(nodes);
|
||||
|
||||
// Save new node list
|
||||
nodes_ = nodes;
|
||||
@@ -176,13 +176,13 @@ void CurveWidget::SetNodes(const QVector<Node *> &nodes)
|
||||
// Generate colors
|
||||
foreach (Node *node, nodes_) {
|
||||
foreach (const QString &input, node->inputs()) {
|
||||
if (node->IsInputKeyframable(input) &&
|
||||
!node->IsInputHidden(input)) {
|
||||
int arr_sz = node->InputArraySize(input);
|
||||
if (node->is_input_keyframable(input) &&
|
||||
!node->is_input_hidden(input)) {
|
||||
int arr_sz = node->input_array_size(input);
|
||||
for (int i = -1; i < arr_sz; i++) {
|
||||
// Generate a random color for this input
|
||||
const QVector<NodeKeyframeTrack> &tracks =
|
||||
node->GetKeyframeTracks(input, i);
|
||||
node->get_keyframe_tracks(input, i);
|
||||
|
||||
for (int j = 0; j < tracks.size(); j++) {
|
||||
NodeKeyframeTrackReference ref(
|
||||
@@ -193,8 +193,8 @@ void CurveWidget::SetNodes(const QVector<Node *> &nodes)
|
||||
QColor::fromHsl(std::rand() % 360, 255, 160);
|
||||
|
||||
keyframe_colors_.insert(ref, c);
|
||||
tree_view_->SetKeyframeTrackColor(ref, c);
|
||||
view_->SetKeyframeTrackColor(ref, c);
|
||||
tree_view_->set_keyframe_track_color(ref, c);
|
||||
view_->set_keyframe_track_color(ref, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -203,92 +203,92 @@ void CurveWidget::SetNodes(const QVector<Node *> &nodes)
|
||||
}
|
||||
}
|
||||
|
||||
void CurveWidget::TimebaseChangedEvent(const rational &timebase)
|
||||
void CurveWidget::TimebaseChangedEvent(const Rational &timebase)
|
||||
{
|
||||
super::TimebaseChangedEvent(timebase);
|
||||
|
||||
view_->SetTimebase(timebase);
|
||||
view_->set_timebase(timebase);
|
||||
}
|
||||
|
||||
void CurveWidget::ScaleChangedEvent(const double &scale)
|
||||
{
|
||||
super::ScaleChangedEvent(scale);
|
||||
|
||||
view_->SetScale(scale);
|
||||
view_->set_scale(scale);
|
||||
}
|
||||
|
||||
void CurveWidget::TimeTargetChangedEvent(ViewerOutput *target)
|
||||
{
|
||||
TimeTargetObject::TimeTargetChangedEvent(target);
|
||||
|
||||
key_control_->SetTimeTarget(target);
|
||||
key_control_->set_time_target(target);
|
||||
|
||||
view_->SetTimeTarget(target);
|
||||
view_->set_time_target(target);
|
||||
}
|
||||
|
||||
void CurveWidget::ConnectedNodeChangeEvent(ViewerOutput *n)
|
||||
{
|
||||
super::ConnectedNodeChangeEvent(n);
|
||||
|
||||
key_control_->SetTimeTarget(n);
|
||||
key_control_->set_time_target(n);
|
||||
|
||||
SetTimeTarget(n);
|
||||
set_time_target(n);
|
||||
}
|
||||
|
||||
void CurveWidget::SetKeyframeButtonEnabled(bool enable)
|
||||
void CurveWidget::set_keyframe_button_enabled(bool enable)
|
||||
{
|
||||
linear_button_->setEnabled(enable);
|
||||
bezier_button_->setEnabled(enable);
|
||||
hold_button_->setEnabled(enable);
|
||||
}
|
||||
|
||||
void CurveWidget::SetKeyframeButtonChecked(bool checked)
|
||||
void CurveWidget::set_keyframe_button_checked(bool checked)
|
||||
{
|
||||
linear_button_->setChecked(checked);
|
||||
bezier_button_->setChecked(checked);
|
||||
hold_button_->setChecked(checked);
|
||||
}
|
||||
|
||||
void CurveWidget::SetKeyframeButtonCheckedFromType(NodeKeyframe::Type type)
|
||||
void CurveWidget::set_keyframe_button_checked_from_type(NodeKeyframe::Type type)
|
||||
{
|
||||
linear_button_->setChecked(type == NodeKeyframe::kLinear);
|
||||
bezier_button_->setChecked(type == NodeKeyframe::kBezier);
|
||||
hold_button_->setChecked(type == NodeKeyframe::kHold);
|
||||
linear_button_->setChecked(type == NodeKeyframe::k_linear);
|
||||
bezier_button_->setChecked(type == NodeKeyframe::k_bezier);
|
||||
hold_button_->setChecked(type == NodeKeyframe::k_hold);
|
||||
}
|
||||
|
||||
void CurveWidget::ConnectInput(Node *node, const QString &input, int element)
|
||||
void CurveWidget::connect_input(Node *node, const QString &input, int element)
|
||||
{
|
||||
if (element == -1 && node->InputIsArray(input)) {
|
||||
if (element == -1 && node->input_is_array(input)) {
|
||||
// This is the root element, connect all elements (if applicable)
|
||||
int arr_sz = node->InputArraySize(input);
|
||||
int arr_sz = node->input_array_size(input);
|
||||
for (int i = -1; i < arr_sz; i++) {
|
||||
ConnectInputInternal(node, input, i);
|
||||
connect_input_internal(node, input, i);
|
||||
}
|
||||
} else {
|
||||
// This is a single element, just connect it as-is
|
||||
ConnectInputInternal(node, input, element);
|
||||
connect_input_internal(node, input, element);
|
||||
}
|
||||
}
|
||||
|
||||
void CurveWidget::ConnectInputInternal(Node *node, const QString &input,
|
||||
void CurveWidget::connect_input_internal(Node *node, const QString &input,
|
||||
int element)
|
||||
{
|
||||
NodeInput input_ref(node, input, element);
|
||||
int track_count =
|
||||
NodeValue::get_number_of_keyframe_tracks(input_ref.GetDataType());
|
||||
NodeValue::get_number_of_keyframe_tracks(input_ref.get_data_type());
|
||||
for (int i = 0; i < track_count; i++) {
|
||||
NodeKeyframeTrackReference track_ref(input_ref, i);
|
||||
view_->ConnectInput(track_ref);
|
||||
view_->connect_input(track_ref);
|
||||
selected_tracks_.append(track_ref);
|
||||
}
|
||||
}
|
||||
|
||||
void CurveWidget::SelectionChanged()
|
||||
void CurveWidget::selection_changed()
|
||||
{
|
||||
const std::vector<NodeKeyframe *> &selected = view_->GetSelectedKeyframes();
|
||||
const std::vector<NodeKeyframe *> &selected = view_->get_selected_keyframes();
|
||||
|
||||
SetKeyframeButtonChecked(false);
|
||||
SetKeyframeButtonEnabled(!selected.empty());
|
||||
set_keyframe_button_checked(false);
|
||||
set_keyframe_button_enabled(!selected.empty());
|
||||
|
||||
if (!selected.empty()) {
|
||||
bool all_same_type = true;
|
||||
@@ -305,12 +305,12 @@ void CurveWidget::SelectionChanged()
|
||||
}
|
||||
|
||||
if (all_same_type) {
|
||||
SetKeyframeButtonCheckedFromType(type);
|
||||
set_keyframe_button_checked_from_type(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CurveWidget::KeyframeTypeButtonTriggered(bool checked)
|
||||
void CurveWidget::keyframe_type_button_triggered(bool checked)
|
||||
{
|
||||
QPushButton *key_btn = static_cast<QPushButton *>(sender());
|
||||
|
||||
@@ -321,7 +321,7 @@ void CurveWidget::KeyframeTypeButtonTriggered(bool checked)
|
||||
}
|
||||
|
||||
// Get selected items and do nothing if there are none
|
||||
const std::vector<NodeKeyframe *> &selected = view_->GetSelectedKeyframes();
|
||||
const std::vector<NodeKeyframe *> &selected = view_->get_selected_keyframes();
|
||||
if (selected.empty()) {
|
||||
return;
|
||||
}
|
||||
@@ -331,15 +331,15 @@ void CurveWidget::KeyframeTypeButtonTriggered(bool checked)
|
||||
|
||||
// Determine which type to set
|
||||
if (key_btn == bezier_button_) {
|
||||
new_type = NodeKeyframe::kBezier;
|
||||
new_type = NodeKeyframe::k_bezier;
|
||||
} else if (key_btn == hold_button_) {
|
||||
new_type = NodeKeyframe::kHold;
|
||||
new_type = NodeKeyframe::k_hold;
|
||||
} else {
|
||||
new_type = NodeKeyframe::kLinear;
|
||||
new_type = NodeKeyframe::k_linear;
|
||||
}
|
||||
|
||||
// Ensure only the appropriate button is checked
|
||||
SetKeyframeButtonCheckedFromType(new_type);
|
||||
set_keyframe_button_checked_from_type(new_type);
|
||||
|
||||
MultiUndoCommand *command = new MultiUndoCommand();
|
||||
|
||||
@@ -351,47 +351,47 @@ void CurveWidget::KeyframeTypeButtonTriggered(bool checked)
|
||||
command, tr("Changed Type of %1 Keyframe(s) to %2"));
|
||||
}
|
||||
|
||||
void CurveWidget::InputSelectionChanged(const NodeKeyframeTrackReference &ref)
|
||||
void CurveWidget::input_selection_changed(const NodeKeyframeTrackReference &ref)
|
||||
{
|
||||
key_control_->SetInput(ref.input());
|
||||
key_control_->set_input(ref.input());
|
||||
|
||||
foreach (const NodeKeyframeTrackReference &c, selected_tracks_) {
|
||||
view_->DisconnectInput(c);
|
||||
view_->disconnect_input(c);
|
||||
}
|
||||
|
||||
selected_tracks_.clear();
|
||||
|
||||
if (ref.IsValid() && !ref.input().IsArray()) {
|
||||
if (ref.is_valid() && !ref.input().is_array()) {
|
||||
// This reference is a track, connect it only
|
||||
view_->ConnectInput(ref);
|
||||
view_->connect_input(ref);
|
||||
selected_tracks_.append(ref);
|
||||
} else if (ref.input().IsValid()) {
|
||||
} else if (ref.input().is_valid()) {
|
||||
// This reference is a input, connect all tracks
|
||||
ConnectInput(ref.input().node(), ref.input().input(),
|
||||
connect_input(ref.input().node(), ref.input().input(),
|
||||
ref.input().element());
|
||||
} else if (Node *node = ref.input().node()) {
|
||||
// This is a node, add all inputs
|
||||
foreach (const QString &input, node->inputs()) {
|
||||
if (node->IsInputKeyframable(input) &&
|
||||
!node->IsInputHidden(input)) {
|
||||
ConnectInput(node, input, -1);
|
||||
if (node->is_input_keyframable(input) &&
|
||||
!node->is_input_hidden(input)) {
|
||||
connect_input(node, input, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
view_->ZoomToFit();
|
||||
view_->zoom_to_fit();
|
||||
}
|
||||
|
||||
void CurveWidget::KeyframeViewDragged(int x, int y)
|
||||
void CurveWidget::keyframe_view_dragged(int x, int y)
|
||||
{
|
||||
SetCatchUpScrollValue(x);
|
||||
SetCatchUpScrollValue(view_->verticalScrollBar(), y, view_->height());
|
||||
set_catch_up_scroll_value(x);
|
||||
set_catch_up_scroll_value(view_->verticalScrollBar(), y, view_->height());
|
||||
}
|
||||
|
||||
void CurveWidget::KeyframeViewReleased()
|
||||
void CurveWidget::keyframe_view_released()
|
||||
{
|
||||
StopCatchUpScrollTimer();
|
||||
StopCatchUpScrollTimer(view_->verticalScrollBar());
|
||||
stop_catch_up_scroll_timer();
|
||||
stop_catch_up_scroll_timer(view_->verticalScrollBar());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef CURVEWIDGET_H
|
||||
#define CURVEWIDGET_H
|
||||
#ifndef OAK_CURVEWIDGET_H
|
||||
#define OAK_CURVEWIDGET_H
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QHBoxLayout>
|
||||
@@ -41,32 +41,32 @@ class CurveWidget : public TimeBasedWidget, public TimeTargetObject {
|
||||
public:
|
||||
CurveWidget(QWidget *parent = nullptr);
|
||||
|
||||
const double &GetVerticalScale();
|
||||
void SetVerticalScale(const double &vscale);
|
||||
const double &get_vertical_scale();
|
||||
void set_vertical_scale(const double &vscale);
|
||||
|
||||
void DeleteSelected();
|
||||
|
||||
void SelectAll()
|
||||
void select_all()
|
||||
{
|
||||
view_->SelectAll();
|
||||
view_->select_all();
|
||||
}
|
||||
|
||||
void DeselectAll()
|
||||
void deselect_all()
|
||||
{
|
||||
view_->DeselectAll();
|
||||
view_->deselect_all();
|
||||
}
|
||||
|
||||
Node *GetSelectedNodeWithID(const QString &id);
|
||||
Node *get_selected_node_with_id(const QString &id);
|
||||
|
||||
virtual bool CopySelected(bool cut) override;
|
||||
virtual bool copy_selected(bool cut) override;
|
||||
|
||||
virtual bool Paste() override;
|
||||
virtual bool paste() override;
|
||||
|
||||
public slots:
|
||||
void SetNodes(const QVector<Node *> &nodes);
|
||||
void set_nodes(const QVector<Node *> &nodes);
|
||||
|
||||
protected:
|
||||
virtual void TimebaseChangedEvent(const rational &) override;
|
||||
virtual void TimebaseChangedEvent(const Rational &) override;
|
||||
virtual void ScaleChangedEvent(const double &) override;
|
||||
|
||||
virtual void TimeTargetChangedEvent(ViewerOutput *target) override;
|
||||
@@ -74,32 +74,32 @@ protected:
|
||||
virtual void ConnectedNodeChangeEvent(ViewerOutput *n) override;
|
||||
|
||||
virtual const QVector<KeyframeViewInputConnection *> *
|
||||
GetSnapKeyframes() const override
|
||||
get_snap_keyframes() const override
|
||||
{
|
||||
return &view_->GetKeyframeTracks();
|
||||
return &view_->get_keyframe_tracks();
|
||||
}
|
||||
|
||||
virtual const TimeTargetObject *GetKeyframeTimeTarget() const override
|
||||
virtual const TimeTargetObject *get_keyframe_time_target() const override
|
||||
{
|
||||
return view_;
|
||||
}
|
||||
|
||||
virtual const std::vector<NodeKeyframe *> *
|
||||
GetSnapIgnoreKeyframes() const override
|
||||
get_snap_ignore_keyframes() const override
|
||||
{
|
||||
return &view_->GetSelectedKeyframes();
|
||||
return &view_->get_selected_keyframes();
|
||||
}
|
||||
|
||||
private:
|
||||
void SetKeyframeButtonEnabled(bool enable);
|
||||
void set_keyframe_button_enabled(bool enable);
|
||||
|
||||
void SetKeyframeButtonChecked(bool checked);
|
||||
void set_keyframe_button_checked(bool checked);
|
||||
|
||||
void SetKeyframeButtonCheckedFromType(NodeKeyframe::Type type);
|
||||
void set_keyframe_button_checked_from_type(NodeKeyframe::Type type);
|
||||
|
||||
void ConnectInput(Node *node, const QString &input, int element);
|
||||
void connect_input(Node *node, const QString &input, int element);
|
||||
|
||||
void ConnectInputInternal(Node *node, const QString &input, int element);
|
||||
void connect_input_internal(Node *node, const QString &input, int element);
|
||||
|
||||
QHash<NodeKeyframeTrackReference, QColor> keyframe_colors_;
|
||||
|
||||
@@ -120,16 +120,16 @@ private:
|
||||
QVector<NodeKeyframeTrackReference> selected_tracks_;
|
||||
|
||||
private slots:
|
||||
void SelectionChanged();
|
||||
void selection_changed();
|
||||
|
||||
void KeyframeTypeButtonTriggered(bool checked);
|
||||
void keyframe_type_button_triggered(bool checked);
|
||||
|
||||
void InputSelectionChanged(const NodeKeyframeTrackReference &ref);
|
||||
void input_selection_changed(const NodeKeyframeTrackReference &ref);
|
||||
|
||||
void KeyframeViewDragged(int x, int y);
|
||||
void KeyframeViewReleased();
|
||||
void keyframe_view_dragged(int x, int y);
|
||||
void keyframe_view_released();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // CURVEWIDGET_H
|
||||
#endif // OAK_CURVEWIDGET_H
|
||||
|
||||
@@ -41,19 +41,19 @@ FileField::FileField(QWidget *parent)
|
||||
|
||||
line_edit_ = new QLineEdit();
|
||||
connect(line_edit_, &QLineEdit::textChanged, this,
|
||||
&FileField::LineEditChanged);
|
||||
&FileField::line_edit_changed);
|
||||
connect(line_edit_, &QLineEdit::textEdited, this,
|
||||
&FileField::FilenameChanged);
|
||||
&FileField::filename_changed);
|
||||
layout->addWidget(line_edit_);
|
||||
|
||||
browse_btn_ = new QPushButton();
|
||||
browse_btn_->setIcon(icon::Open);
|
||||
browse_btn_->setIcon(icon::open);
|
||||
connect(browse_btn_, &QPushButton::clicked, this,
|
||||
&FileField::BrowseBtnClicked);
|
||||
&FileField::browse_btn_clicked);
|
||||
layout->addWidget(browse_btn_);
|
||||
}
|
||||
|
||||
void FileField::BrowseBtnClicked()
|
||||
void FileField::browse_btn_clicked()
|
||||
{
|
||||
QString s;
|
||||
|
||||
@@ -85,11 +85,11 @@ void FileField::BrowseBtnClicked()
|
||||
|
||||
if (!s.isEmpty()) {
|
||||
line_edit_->setText(s);
|
||||
emit FilenameChanged(s);
|
||||
emit filename_changed(s);
|
||||
}
|
||||
}
|
||||
|
||||
void FileField::LineEditChanged(const QString &text)
|
||||
void FileField::line_edit_changed(const QString &text)
|
||||
{
|
||||
if (QFileInfo::exists(text) || text.isEmpty()) {
|
||||
line_edit_->setStyleSheet(QString());
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef FILEFIELD_H
|
||||
#define FILEFIELD_H
|
||||
#ifndef OAK_FILEFIELD_H
|
||||
#define OAK_FILEFIELD_H
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
@@ -33,27 +33,27 @@ class FileField : public QWidget {
|
||||
public:
|
||||
FileField(QWidget *parent = nullptr);
|
||||
|
||||
QString GetFilename() const
|
||||
QString get_filename() const
|
||||
{
|
||||
return line_edit_->text();
|
||||
}
|
||||
|
||||
virtual void SetFilename(const QString &s)
|
||||
virtual void set_filename(const QString &s)
|
||||
{
|
||||
line_edit_->setText(s);
|
||||
}
|
||||
|
||||
void SetPlaceholder(const QString &s)
|
||||
void set_placeholder(const QString &s)
|
||||
{
|
||||
line_edit_->setPlaceholderText(s);
|
||||
}
|
||||
|
||||
void SetDirectoryMode(bool e)
|
||||
void set_directory_mode(bool e)
|
||||
{
|
||||
directory_mode_ = e;
|
||||
}
|
||||
|
||||
void SetNameFilter(const QString &filter)
|
||||
void set_name_filter(const QString &filter)
|
||||
{
|
||||
name_filter_ = filter;
|
||||
}
|
||||
@@ -64,13 +64,13 @@ public:
|
||||
*
|
||||
* Note: setting sidebar URLs requires Qt's non-native file dialog.
|
||||
*/
|
||||
void SetSidebarUrls(const QList<QUrl> &urls)
|
||||
void set_sidebar_urls(const QList<QUrl> &urls)
|
||||
{
|
||||
sidebar_urls_ = urls;
|
||||
}
|
||||
|
||||
signals:
|
||||
void FilenameChanged(const QString &filename);
|
||||
void filename_changed(const QString &filename);
|
||||
|
||||
private:
|
||||
QLineEdit *line_edit_;
|
||||
@@ -84,11 +84,11 @@ private:
|
||||
QList<QUrl> sidebar_urls_;
|
||||
|
||||
private slots:
|
||||
void BrowseBtnClicked();
|
||||
void browse_btn_clicked();
|
||||
|
||||
void LineEditChanged(const QString &text);
|
||||
void line_edit_changed(const QString &text);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // FILEFIELD_H
|
||||
#endif // OAK_FILEFIELD_H
|
||||
|
||||
@@ -35,7 +35,7 @@ LutFileField::LutFileField(QWidget *parent) : FileField(parent)
|
||||
library_combo_->setMinimumContentsLength(12);
|
||||
static_cast<QHBoxLayout *>(layout())->insertWidget(0, library_combo_, 1);
|
||||
|
||||
RefreshLibraryEntries();
|
||||
refresh_library_entries();
|
||||
|
||||
connect(library_combo_,
|
||||
static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this,
|
||||
@@ -43,33 +43,33 @@ LutFileField::LutFileField(QWidget *parent) : FileField(parent)
|
||||
const QString path =
|
||||
library_combo_->itemData(index).toString();
|
||||
if (!path.isEmpty()) {
|
||||
SetFilename(path);
|
||||
emit FilenameChanged(path);
|
||||
set_filename(path);
|
||||
emit filename_changed(path);
|
||||
}
|
||||
});
|
||||
|
||||
// Keep the combo in sync when the path is edited directly
|
||||
connect(this, &FileField::FilenameChanged, this, [this](const QString &) {
|
||||
RefreshLibraryEntries();
|
||||
connect(this, &FileField::filename_changed, this, [this](const QString &) {
|
||||
refresh_library_entries();
|
||||
});
|
||||
}
|
||||
|
||||
void LutFileField::SetFilename(const QString &s)
|
||||
void LutFileField::set_filename(const QString &s)
|
||||
{
|
||||
FileField::SetFilename(s);
|
||||
RefreshLibraryEntries();
|
||||
FileField::set_filename(s);
|
||||
refresh_library_entries();
|
||||
}
|
||||
|
||||
void LutFileField::RefreshLibraryEntries()
|
||||
void LutFileField::refresh_library_entries()
|
||||
{
|
||||
const QString current = GetFilename();
|
||||
const QString current = get_filename();
|
||||
|
||||
const QSignalBlocker blocker(library_combo_);
|
||||
library_combo_->clear();
|
||||
library_combo_->addItem(tr("Other (Custom File)..."), QString());
|
||||
|
||||
const QStringList library_dirs = LUTLibrary::GetDirectories();
|
||||
const QStringList luts = LUTLibrary::GetLutFiles();
|
||||
const QStringList library_dirs = LUTLibrary::get_directories();
|
||||
const QStringList luts = LUTLibrary::get_lut_files();
|
||||
for (const QString &lut : luts) {
|
||||
// Show the path relative to the library directory that contains it
|
||||
QString display = lut;
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef LUTFILEFIELD_H
|
||||
#define LUTFILEFIELD_H
|
||||
#ifndef OAK_LUTFILEFIELD_H
|
||||
#define OAK_LUTFILEFIELD_H
|
||||
|
||||
#include <QComboBox>
|
||||
|
||||
@@ -43,7 +43,7 @@ class LutFileField : public FileField {
|
||||
public:
|
||||
LutFileField(QWidget *parent = nullptr);
|
||||
|
||||
virtual void SetFilename(const QString &s) override;
|
||||
virtual void set_filename(const QString &s) override;
|
||||
|
||||
/**
|
||||
* @brief The combo box listing the LUT library entries
|
||||
@@ -61,11 +61,11 @@ private:
|
||||
* @brief Repopulates the combo from the LUT library and syncs the
|
||||
* selection with the current filename
|
||||
*/
|
||||
void RefreshLibraryEntries();
|
||||
void refresh_library_entries();
|
||||
|
||||
QComboBox *library_combo_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // LUTFILEFIELD_H
|
||||
#endif // OAK_LUTFILEFIELD_H
|
||||
|
||||
@@ -52,17 +52,17 @@
|
||||
#include <QtWidgets>
|
||||
|
||||
#include "flowlayout.h"
|
||||
FlowLayout::FlowLayout(QWidget *parent, int margin, int hSpacing, int vSpacing)
|
||||
FlowLayout::FlowLayout(QWidget *parent, int margin, int h_spacing, int v_spacing)
|
||||
: QLayout(parent)
|
||||
, m_hSpace(hSpacing)
|
||||
, m_vSpace(vSpacing)
|
||||
, m_hSpace_(h_spacing)
|
||||
, m_vSpace_(v_spacing)
|
||||
{
|
||||
setContentsMargins(margin, margin, margin, margin);
|
||||
}
|
||||
|
||||
FlowLayout::FlowLayout(int margin, int hSpacing, int vSpacing)
|
||||
: m_hSpace(hSpacing)
|
||||
, m_vSpace(vSpacing)
|
||||
FlowLayout::FlowLayout(int margin, int h_spacing, int v_spacing)
|
||||
: m_hSpace_(h_spacing)
|
||||
, m_vSpace_(v_spacing)
|
||||
{
|
||||
setContentsMargins(margin, margin, margin, margin);
|
||||
}
|
||||
@@ -76,41 +76,41 @@ FlowLayout::~FlowLayout()
|
||||
|
||||
void FlowLayout::addItem(QLayoutItem *item)
|
||||
{
|
||||
itemList.append(item);
|
||||
itemList_.append(item);
|
||||
}
|
||||
|
||||
int FlowLayout::horizontalSpacing() const
|
||||
int FlowLayout::horizontal_spacing() const
|
||||
{
|
||||
if (m_hSpace >= 0) {
|
||||
return m_hSpace;
|
||||
if (m_hSpace_ >= 0) {
|
||||
return m_hSpace_;
|
||||
} else {
|
||||
return smartSpacing(QStyle::PM_LayoutHorizontalSpacing);
|
||||
return smart_spacing(QStyle::PM_LayoutHorizontalSpacing);
|
||||
}
|
||||
}
|
||||
|
||||
int FlowLayout::verticalSpacing() const
|
||||
int FlowLayout::vertical_spacing() const
|
||||
{
|
||||
if (m_vSpace >= 0) {
|
||||
return m_vSpace;
|
||||
if (m_vSpace_ >= 0) {
|
||||
return m_vSpace_;
|
||||
} else {
|
||||
return smartSpacing(QStyle::PM_LayoutVerticalSpacing);
|
||||
return smart_spacing(QStyle::PM_LayoutVerticalSpacing);
|
||||
}
|
||||
}
|
||||
|
||||
int FlowLayout::count() const
|
||||
{
|
||||
return itemList.size();
|
||||
return itemList_.size();
|
||||
}
|
||||
|
||||
QLayoutItem *FlowLayout::itemAt(int index) const
|
||||
{
|
||||
return itemList.value(index);
|
||||
return itemList_.value(index);
|
||||
}
|
||||
|
||||
QLayoutItem *FlowLayout::takeAt(int index)
|
||||
{
|
||||
if (index >= 0 && index < itemList.size())
|
||||
return itemList.takeAt(index);
|
||||
if (index >= 0 && index < itemList_.size())
|
||||
return itemList_.takeAt(index);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
@@ -127,14 +127,14 @@ bool FlowLayout::hasHeightForWidth() const
|
||||
|
||||
int FlowLayout::heightForWidth(int width) const
|
||||
{
|
||||
int height = doLayout(QRect(0, 0, width, 0), true);
|
||||
int height = do_layout(QRect(0, 0, width, 0), true);
|
||||
return height;
|
||||
}
|
||||
|
||||
void FlowLayout::setGeometry(const QRect &rect)
|
||||
{
|
||||
QLayout::setGeometry(rect);
|
||||
doLayout(rect, false);
|
||||
do_layout(rect, false);
|
||||
}
|
||||
|
||||
QSize FlowLayout::sizeHint() const
|
||||
@@ -146,51 +146,51 @@ QSize FlowLayout::minimumSize() const
|
||||
{
|
||||
QSize size;
|
||||
QLayoutItem *item;
|
||||
foreach (item, itemList)
|
||||
foreach (item, itemList_)
|
||||
size = size.expandedTo(item->minimumSize());
|
||||
|
||||
size += QSize(2 * contentsMargins().left(), 2 * contentsMargins().top());
|
||||
return size;
|
||||
}
|
||||
|
||||
int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
|
||||
int FlowLayout::do_layout(const QRect &rect, bool test_only) const
|
||||
{
|
||||
int left, top, right, bottom;
|
||||
getContentsMargins(&left, &top, &right, &bottom);
|
||||
QRect effectiveRect = rect.adjusted(+left, +top, -right, -bottom);
|
||||
int x = effectiveRect.x();
|
||||
int y = effectiveRect.y();
|
||||
int lineHeight = 0;
|
||||
QRect effective_rect = rect.adjusted(+left, +top, -right, -bottom);
|
||||
int x = effective_rect.x();
|
||||
int y = effective_rect.y();
|
||||
int line_height = 0;
|
||||
|
||||
QLayoutItem *item;
|
||||
foreach (item, itemList) {
|
||||
foreach (item, itemList_) {
|
||||
QWidget *wid = item->widget();
|
||||
int spaceX = horizontalSpacing();
|
||||
if (spaceX == -1)
|
||||
spaceX = wid->style()->layoutSpacing(QSizePolicy::PushButton,
|
||||
int space_x = horizontal_spacing();
|
||||
if (space_x == -1)
|
||||
space_x = wid->style()->layoutSpacing(QSizePolicy::PushButton,
|
||||
QSizePolicy::PushButton,
|
||||
Qt::Horizontal);
|
||||
int spaceY = verticalSpacing();
|
||||
if (spaceY == -1)
|
||||
spaceY = wid->style()->layoutSpacing(
|
||||
int space_y = vertical_spacing();
|
||||
if (space_y == -1)
|
||||
space_y = wid->style()->layoutSpacing(
|
||||
QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical);
|
||||
int nextX = x + item->sizeHint().width() + spaceX;
|
||||
if (nextX - spaceX > effectiveRect.right() && lineHeight > 0) {
|
||||
x = effectiveRect.x();
|
||||
y = y + lineHeight + spaceY;
|
||||
nextX = x + item->sizeHint().width() + spaceX;
|
||||
lineHeight = 0;
|
||||
int next_x = x + item->sizeHint().width() + space_x;
|
||||
if (next_x - space_x > effective_rect.right() && line_height > 0) {
|
||||
x = effective_rect.x();
|
||||
y = y + line_height + space_y;
|
||||
next_x = x + item->sizeHint().width() + space_x;
|
||||
line_height = 0;
|
||||
}
|
||||
|
||||
if (!testOnly)
|
||||
if (!test_only)
|
||||
item->setGeometry(QRect(QPoint(x, y), item->sizeHint()));
|
||||
|
||||
x = nextX;
|
||||
lineHeight = qMax(lineHeight, item->sizeHint().height());
|
||||
x = next_x;
|
||||
line_height = qMax(line_height, item->sizeHint().height());
|
||||
}
|
||||
return y + lineHeight - rect.y() + bottom;
|
||||
return y + line_height - rect.y() + bottom;
|
||||
}
|
||||
int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const
|
||||
int FlowLayout::smart_spacing(QStyle::PixelMetric pm) const
|
||||
{
|
||||
QObject *parent = this->parent();
|
||||
if (!parent) {
|
||||
|
||||
@@ -49,22 +49,22 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef FLOWLAYOUT_H
|
||||
#define FLOWLAYOUT_H
|
||||
#ifndef OAK_FLOWLAYOUT_H
|
||||
#define OAK_FLOWLAYOUT_H
|
||||
|
||||
#include <QLayout>
|
||||
#include <QRect>
|
||||
#include <QStyle>
|
||||
class FlowLayout : public QLayout {
|
||||
public:
|
||||
explicit FlowLayout(QWidget *parent, int margin = -1, int hSpacing = -1,
|
||||
int vSpacing = -1);
|
||||
explicit FlowLayout(int margin = -1, int hSpacing = -1, int vSpacing = -1);
|
||||
explicit FlowLayout(QWidget *parent, int margin = -1, int h_spacing = -1,
|
||||
int v_spacing = -1);
|
||||
explicit FlowLayout(int margin = -1, int h_spacing = -1, int v_spacing = -1);
|
||||
~FlowLayout();
|
||||
|
||||
void addItem(QLayoutItem *item) override;
|
||||
int horizontalSpacing() const;
|
||||
int verticalSpacing() const;
|
||||
int horizontal_spacing() const;
|
||||
int vertical_spacing() const;
|
||||
Qt::Orientations expandingDirections() const override;
|
||||
bool hasHeightForWidth() const override;
|
||||
int heightForWidth(int) const override;
|
||||
@@ -76,12 +76,12 @@ public:
|
||||
QLayoutItem *takeAt(int index) override;
|
||||
|
||||
private:
|
||||
int doLayout(const QRect &rect, bool testOnly) const;
|
||||
int smartSpacing(QStyle::PixelMetric pm) const;
|
||||
int do_layout(const QRect &rect, bool test_only) const;
|
||||
int smart_spacing(QStyle::PixelMetric pm) const;
|
||||
|
||||
QList<QLayoutItem *> itemList;
|
||||
int m_hSpace;
|
||||
int m_vSpace;
|
||||
QList<QLayoutItem *> itemList_;
|
||||
int m_hSpace_;
|
||||
int m_vSpace_;
|
||||
};
|
||||
|
||||
#endif // FLOWLAYOUT_H
|
||||
#endif // OAK_FLOWLAYOUT_H
|
||||
|
||||
@@ -36,10 +36,10 @@ void FocusableLineEdit::keyPressEvent(QKeyEvent *e)
|
||||
switch (e->key()) {
|
||||
case Qt::Key_Return:
|
||||
case Qt::Key_Enter:
|
||||
emit Confirmed();
|
||||
emit confirmed();
|
||||
break;
|
||||
case Qt::Key_Escape:
|
||||
emit Cancelled();
|
||||
emit cancelled();
|
||||
break;
|
||||
default:
|
||||
QLineEdit::keyPressEvent(e);
|
||||
@@ -50,7 +50,7 @@ void FocusableLineEdit::focusOutEvent(QFocusEvent *e)
|
||||
{
|
||||
QLineEdit::focusOutEvent(e);
|
||||
|
||||
emit Confirmed();
|
||||
emit confirmed();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef SLIDERLINEEDIT_H
|
||||
#define SLIDERLINEEDIT_H
|
||||
#ifndef OAK_SLIDERLINEEDIT_H
|
||||
#define OAK_SLIDERLINEEDIT_H
|
||||
|
||||
#include <QLineEdit>
|
||||
|
||||
@@ -35,9 +35,9 @@ public:
|
||||
FocusableLineEdit(QWidget *parent = nullptr);
|
||||
|
||||
signals:
|
||||
void Confirmed();
|
||||
void confirmed();
|
||||
|
||||
void Cancelled();
|
||||
void cancelled();
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent *) override;
|
||||
@@ -47,4 +47,4 @@ protected:
|
||||
|
||||
}
|
||||
|
||||
#endif // SLIDERLINEEDIT_H
|
||||
#endif // OAK_SLIDERLINEEDIT_H
|
||||
|
||||
@@ -37,13 +37,13 @@ HandMovableView::HandMovableView(QWidget *parent)
|
||||
, default_drag_mode_(NoDrag)
|
||||
, is_timeline_axes_(false)
|
||||
{
|
||||
connect(Core::instance(), &Core::ToolChanged, this,
|
||||
&HandMovableView::ApplicationToolChanged);
|
||||
connect(Core::instance(), &Core::tool_changed, this,
|
||||
&HandMovableView::application_tool_changed);
|
||||
}
|
||||
|
||||
void HandMovableView::ApplicationToolChanged(Tool::Item tool)
|
||||
void HandMovableView::application_tool_changed(Tool::Item tool)
|
||||
{
|
||||
if (tool == Tool::kHand) {
|
||||
if (tool == Tool::k_hand) {
|
||||
setDragMode(ScrollHandDrag);
|
||||
setInteractive(false);
|
||||
} else {
|
||||
@@ -54,7 +54,7 @@ void HandMovableView::ApplicationToolChanged(Tool::Item tool)
|
||||
ToolChangedEvent(tool);
|
||||
}
|
||||
|
||||
bool HandMovableView::HandPress(QMouseEvent *event)
|
||||
bool HandMovableView::hand_press(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::MiddleButton) {
|
||||
pre_hand_drag_mode_ = dragMode();
|
||||
@@ -77,7 +77,7 @@ bool HandMovableView::HandPress(QMouseEvent *event)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HandMovableView::HandMove(QMouseEvent *event)
|
||||
bool HandMovableView::hand_move(QMouseEvent *event)
|
||||
{
|
||||
if (dragging_hand_) {
|
||||
// Transform mouse event to act like the left button is pressed
|
||||
@@ -112,7 +112,7 @@ bool HandMovableView::HandMove(QMouseEvent *event)
|
||||
return dragging_hand_;
|
||||
}
|
||||
|
||||
bool HandMovableView::HandRelease(QMouseEvent *event)
|
||||
bool HandMovableView::hand_release(QMouseEvent *event)
|
||||
{
|
||||
if (dragging_hand_) {
|
||||
// Transform mouse event to act like the left button is pressed
|
||||
@@ -134,13 +134,13 @@ bool HandMovableView::HandRelease(QMouseEvent *event)
|
||||
return false;
|
||||
}
|
||||
|
||||
void HandMovableView::SetDefaultDragMode(HandMovableView::DragMode mode)
|
||||
void HandMovableView::set_default_drag_mode(HandMovableView::DragMode mode)
|
||||
{
|
||||
default_drag_mode_ = mode;
|
||||
setDragMode(default_drag_mode_);
|
||||
}
|
||||
|
||||
const HandMovableView::DragMode &HandMovableView::GetDefaultDragMode() const
|
||||
const HandMovableView::DragMode &HandMovableView::get_default_drag_mode() const
|
||||
{
|
||||
return default_drag_mode_;
|
||||
}
|
||||
@@ -148,10 +148,10 @@ const HandMovableView::DragMode &HandMovableView::GetDefaultDragMode() const
|
||||
bool HandMovableView::WheelEventIsAZoomEvent(QWheelEvent *event)
|
||||
{
|
||||
return (static_cast<bool>(event->modifiers() & Qt::ControlModifier) ==
|
||||
!OLIVE_CONFIG("ScrollZooms").toBool());
|
||||
!OAK_CONFIG("ScrollZooms").toBool());
|
||||
}
|
||||
|
||||
qreal HandMovableView::GetScrollZoomMultiplier(QWheelEvent *event)
|
||||
qreal HandMovableView::get_scroll_zoom_multiplier(QWheelEvent *event)
|
||||
{
|
||||
qreal v =
|
||||
(static_cast<qreal>(event->angleDelta().x() + event->angleDelta().y()) *
|
||||
@@ -166,7 +166,7 @@ void HandMovableView::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
if (WheelEventIsAZoomEvent(event)) {
|
||||
if (!event->angleDelta().isNull()) {
|
||||
qreal multiplier = GetScrollZoomMultiplier(event);
|
||||
qreal multiplier = get_scroll_zoom_multiplier(event);
|
||||
|
||||
QPointF cursor_pos;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
@@ -175,14 +175,14 @@ void HandMovableView::wheelEvent(QWheelEvent *event)
|
||||
cursor_pos = event->posF();
|
||||
#endif
|
||||
|
||||
ZoomIntoCursorPosition(event, multiplier, cursor_pos);
|
||||
zoom_into_cursor_position(event, multiplier, cursor_pos);
|
||||
}
|
||||
} else if (is_timeline_axes_) {
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
||||
|
||||
QPoint angle_delta = event->angleDelta();
|
||||
|
||||
if (OLIVE_CONFIG("InvertTimelineScrollAxes")
|
||||
if (OAK_CONFIG("InvertTimelineScrollAxes")
|
||||
.toBool() // Check if config is set to invert timeline axes
|
||||
&&
|
||||
event->source() !=
|
||||
@@ -204,7 +204,7 @@ void HandMovableView::wheelEvent(QWheelEvent *event)
|
||||
|
||||
Qt::Orientation orientation = event->orientation();
|
||||
|
||||
if (OLIVE_CONFIG("InvertTimelineScrollAxes").toBool()) {
|
||||
if (OAK_CONFIG("InvertTimelineScrollAxes").toBool()) {
|
||||
orientation = (orientation == Qt::Horizontal) ? Qt::Vertical :
|
||||
Qt::Horizontal;
|
||||
}
|
||||
@@ -220,7 +220,7 @@ void HandMovableView::wheelEvent(QWheelEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
void HandMovableView::ZoomIntoCursorPosition(QWheelEvent *event,
|
||||
void HandMovableView::zoom_into_cursor_position(QWheelEvent *event,
|
||||
double multiplier,
|
||||
const QPointF &cursor_pos)
|
||||
{
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef HANDMOVABLEVIEW_H
|
||||
#define HANDMOVABLEVIEW_H
|
||||
#ifndef OAK_HANDMOVABLEVIEW_H
|
||||
#define OAK_HANDMOVABLEVIEW_H
|
||||
|
||||
#include <QGraphicsView>
|
||||
#include <QMenu>
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
|
||||
static bool WheelEventIsAZoomEvent(QWheelEvent *event);
|
||||
|
||||
static qreal GetScrollZoomMultiplier(QWheelEvent *event);
|
||||
static qreal get_scroll_zoom_multiplier(QWheelEvent *event);
|
||||
|
||||
virtual void CatchUpScrollEvent()
|
||||
{
|
||||
@@ -49,19 +49,19 @@ protected:
|
||||
Q_UNUSED(tool)
|
||||
}
|
||||
|
||||
bool HandPress(QMouseEvent *event);
|
||||
bool HandMove(QMouseEvent *event);
|
||||
bool HandRelease(QMouseEvent *event);
|
||||
bool hand_press(QMouseEvent *event);
|
||||
bool hand_move(QMouseEvent *event);
|
||||
bool hand_release(QMouseEvent *event);
|
||||
|
||||
void SetDefaultDragMode(DragMode mode);
|
||||
const DragMode &GetDefaultDragMode() const;
|
||||
void set_default_drag_mode(DragMode mode);
|
||||
const DragMode &get_default_drag_mode() const;
|
||||
|
||||
virtual void wheelEvent(QWheelEvent *event) override;
|
||||
|
||||
virtual void ZoomIntoCursorPosition(QWheelEvent *event, double multiplier,
|
||||
virtual void zoom_into_cursor_position(QWheelEvent *event, double multiplier,
|
||||
const QPointF &cursor_pos);
|
||||
|
||||
void SetIsTimelineAxes(bool e)
|
||||
void set_is_timeline_axes(bool e)
|
||||
{
|
||||
is_timeline_axes_ = e;
|
||||
}
|
||||
@@ -77,9 +77,9 @@ private:
|
||||
bool is_timeline_axes_;
|
||||
|
||||
private slots:
|
||||
void ApplicationToolChanged(Tool::Item tool);
|
||||
void application_tool_changed(Tool::Item tool);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // HANDMOVABLEVIEW_H
|
||||
#endif // OAK_HANDMOVABLEVIEW_H
|
||||
|
||||
@@ -33,20 +33,20 @@ HistoryWidget::HistoryWidget(QWidget *parent)
|
||||
|
||||
this->setModel(stack_);
|
||||
this->setRootIsDecorated(false);
|
||||
connect(stack_, &UndoStack::indexChanged, this,
|
||||
&HistoryWidget::indexChanged);
|
||||
connect(stack_, &UndoStack::index_changed, this,
|
||||
&HistoryWidget::index_changed);
|
||||
connect(this->selectionModel(), &QItemSelectionModel::currentRowChanged,
|
||||
this, &HistoryWidget::currentRowChanged);
|
||||
this, &HistoryWidget::current_row_changed);
|
||||
}
|
||||
|
||||
void HistoryWidget::indexChanged(int i)
|
||||
void HistoryWidget::index_changed(int i)
|
||||
{
|
||||
this->selectionModel()->select(this->model()->index(i - 1, 0),
|
||||
QItemSelectionModel::ClearAndSelect |
|
||||
QItemSelectionModel::Rows);
|
||||
}
|
||||
|
||||
void HistoryWidget::currentRowChanged(const QModelIndex ¤t,
|
||||
void HistoryWidget::current_row_changed(const QModelIndex ¤t,
|
||||
const QModelIndex &previous)
|
||||
{
|
||||
size_t jump_to = (current.row() + 1);
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef HISTORYWIDGET_H
|
||||
#define HISTORYWIDGET_H
|
||||
#ifndef OAK_HISTORYWIDGET_H
|
||||
#define OAK_HISTORYWIDGET_H
|
||||
|
||||
#include <QTreeView>
|
||||
|
||||
@@ -40,12 +40,12 @@ private:
|
||||
size_t current_row_;
|
||||
|
||||
private slots:
|
||||
void indexChanged(int i);
|
||||
void index_changed(int i);
|
||||
|
||||
void currentRowChanged(const QModelIndex ¤t,
|
||||
void current_row_changed(const QModelIndex ¤t,
|
||||
const QModelIndex &previous);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // HISTORYWIDGET_H
|
||||
#endif // OAK_HISTORYWIDGET_H
|
||||
|
||||
@@ -48,53 +48,53 @@ KeyframeView::KeyframeView(QWidget *parent)
|
||||
, first_chance_mouse_event_(false)
|
||||
{
|
||||
setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
||||
SetDefaultDragMode(RubberBandDrag);
|
||||
set_default_drag_mode(RubberBandDrag);
|
||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
||||
connect(this, &KeyframeView::customContextMenuRequested, this,
|
||||
&KeyframeView::ShowContextMenu);
|
||||
&KeyframeView::show_context_menu);
|
||||
}
|
||||
|
||||
void KeyframeView::DeleteSelected()
|
||||
void KeyframeView::delete_selected()
|
||||
{
|
||||
if (!selection_manager_.IsDragging()) {
|
||||
if (!selection_manager_.is_dragging()) {
|
||||
MultiUndoCommand *command = new MultiUndoCommand();
|
||||
|
||||
foreach (NodeKeyframe *key, GetSelectedKeyframes()) {
|
||||
foreach (NodeKeyframe *key, get_selected_keyframes()) {
|
||||
command->add_child(new NodeParamRemoveKeyframeCommand(key));
|
||||
}
|
||||
|
||||
Core::instance()->undo_stack()->push(
|
||||
command,
|
||||
tr("Deleted %1 Keyframe(s)").arg(GetSelectedKeyframes().size()));
|
||||
tr("Deleted %1 Keyframe(s)").arg(get_selected_keyframes().size()));
|
||||
}
|
||||
}
|
||||
|
||||
KeyframeView::NodeConnections KeyframeView::AddKeyframesOfNode(Node *n)
|
||||
KeyframeView::NodeConnections KeyframeView::add_keyframes_of_node(Node *n)
|
||||
{
|
||||
NodeConnections map;
|
||||
|
||||
foreach (const QString &i, n->inputs()) {
|
||||
map.insert(i, AddKeyframesOfInput(n, i));
|
||||
map.insert(i, add_keyframes_of_input(n, i));
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
KeyframeView::InputConnections
|
||||
KeyframeView::AddKeyframesOfInput(Node *on, const QString &oinput)
|
||||
KeyframeView::add_keyframes_of_input(Node *on, const QString &oinput)
|
||||
{
|
||||
InputConnections vec;
|
||||
|
||||
NodeInput resolved = NodeGroup::ResolveInput(NodeInput(on, oinput));
|
||||
NodeInput resolved = NodeGroup::resolve_input(NodeInput(on, oinput));
|
||||
Node *n = resolved.node();
|
||||
const QString &input = resolved.input();
|
||||
|
||||
if (n->IsInputKeyframable(input)) {
|
||||
int arr_sz = n->InputArraySize(input);
|
||||
if (n->is_input_keyframable(input)) {
|
||||
int arr_sz = n->input_array_size(input);
|
||||
vec.resize(arr_sz + 1);
|
||||
for (int i = -1; i < arr_sz; i++) {
|
||||
vec[i + 1] = AddKeyframesOfElement(NodeInput(n, input, i));
|
||||
vec[i + 1] = add_keyframes_of_element(NodeInput(n, input, i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,114 +102,114 @@ KeyframeView::AddKeyframesOfInput(Node *on, const QString &oinput)
|
||||
}
|
||||
|
||||
KeyframeView::ElementConnections
|
||||
KeyframeView::AddKeyframesOfElement(const NodeInput &input)
|
||||
KeyframeView::add_keyframes_of_element(const NodeInput &input)
|
||||
{
|
||||
const QVector<NodeKeyframeTrack> &tracks =
|
||||
input.node()->GetKeyframeTracks(input);
|
||||
input.node()->get_keyframe_tracks(input);
|
||||
ElementConnections vec(tracks.size());
|
||||
|
||||
for (int i = 0; i < tracks.size(); i++) {
|
||||
vec[i] = AddKeyframesOfTrack(NodeKeyframeTrackReference(input, i));
|
||||
vec[i] = add_keyframes_of_track(NodeKeyframeTrackReference(input, i));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
KeyframeViewInputConnection *
|
||||
KeyframeView::AddKeyframesOfTrack(const NodeKeyframeTrackReference &ref)
|
||||
KeyframeView::add_keyframes_of_track(const NodeKeyframeTrackReference &ref)
|
||||
{
|
||||
KeyframeViewInputConnection *track =
|
||||
new KeyframeViewInputConnection(ref, this);
|
||||
connect(track, &KeyframeViewInputConnection::RequireUpdate, this,
|
||||
&KeyframeView::Redraw);
|
||||
connect(track, &KeyframeViewInputConnection::require_update, this,
|
||||
&KeyframeView::redraw);
|
||||
tracks_.append(track);
|
||||
Redraw();
|
||||
redraw();
|
||||
return track;
|
||||
}
|
||||
|
||||
void KeyframeView::RemoveKeyframesOfTrack(
|
||||
void KeyframeView::remove_keyframes_of_track(
|
||||
KeyframeViewInputConnection *connection)
|
||||
{
|
||||
if (tracks_.removeOne(connection)) {
|
||||
foreach (NodeKeyframe *key, connection->GetKeyframes()) {
|
||||
selection_manager_.Deselect(key);
|
||||
foreach (NodeKeyframe *key, connection->get_keyframes()) {
|
||||
selection_manager_.deselect(key);
|
||||
}
|
||||
delete connection;
|
||||
Redraw();
|
||||
emit SelectionChanged();
|
||||
redraw();
|
||||
emit selection_changed();
|
||||
}
|
||||
}
|
||||
|
||||
void KeyframeView::SelectAll()
|
||||
void KeyframeView::select_all()
|
||||
{
|
||||
foreach (KeyframeViewInputConnection *track, tracks_) {
|
||||
foreach (NodeKeyframe *key, track->GetKeyframes()) {
|
||||
SelectKeyframe(key);
|
||||
foreach (NodeKeyframe *key, track->get_keyframes()) {
|
||||
select_keyframe(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KeyframeView::DeselectAll()
|
||||
void KeyframeView::deselect_all()
|
||||
{
|
||||
selection_manager_.ClearSelection();
|
||||
selection_manager_.clear_selection();
|
||||
|
||||
Redraw();
|
||||
redraw();
|
||||
}
|
||||
|
||||
void KeyframeView::Clear()
|
||||
void KeyframeView::clear()
|
||||
{
|
||||
if (!tracks_.isEmpty()) {
|
||||
qDeleteAll(tracks_);
|
||||
tracks_.clear();
|
||||
Redraw();
|
||||
redraw();
|
||||
}
|
||||
|
||||
selection_manager_.ClearSelection();
|
||||
selection_manager_.clear_selection();
|
||||
}
|
||||
|
||||
void KeyframeView::SelectionManagerSelectEvent(void *obj)
|
||||
{
|
||||
if (autoselect_siblings_) {
|
||||
NodeKeyframe *key = static_cast<NodeKeyframe *>(obj);
|
||||
QVector<NodeKeyframe *> keys = key->parent()->GetKeyframesAtTime(
|
||||
QVector<NodeKeyframe *> keys = key->parent()->get_keyframes_at_time(
|
||||
key->input(), key->time(), key->element());
|
||||
foreach (NodeKeyframe *k, keys) {
|
||||
if (k != key) {
|
||||
SelectKeyframe(k);
|
||||
select_keyframe(k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
emit SelectionChanged();
|
||||
emit selection_changed();
|
||||
}
|
||||
|
||||
void KeyframeView::SelectionManagerDeselectEvent(void *obj)
|
||||
{
|
||||
if (autoselect_siblings_) {
|
||||
NodeKeyframe *key = static_cast<NodeKeyframe *>(obj);
|
||||
QVector<NodeKeyframe *> keys = key->parent()->GetKeyframesAtTime(
|
||||
QVector<NodeKeyframe *> keys = key->parent()->get_keyframes_at_time(
|
||||
key->input(), key->time(), key->element());
|
||||
foreach (NodeKeyframe *k, keys) {
|
||||
if (k != key) {
|
||||
DeselectKeyframe(k);
|
||||
deselect_keyframe(k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
emit SelectionChanged();
|
||||
emit selection_changed();
|
||||
}
|
||||
|
||||
bool KeyframeView::CopySelected(bool cut)
|
||||
bool KeyframeView::copy_selected(bool cut)
|
||||
{
|
||||
if (!selection_manager_.GetSelectedObjects().empty()) {
|
||||
ProjectSerializer::SaveData sdata(ProjectSerializer::kOnlyKeyframes);
|
||||
sdata.SetOnlySerializeKeyframes(
|
||||
selection_manager_.GetSelectedObjects());
|
||||
if (!selection_manager_.get_selected_objects().empty()) {
|
||||
ProjectSerializer::SaveData sdata(ProjectSerializer::k_only_keyframes);
|
||||
sdata.set_only_serialize_keyframes(
|
||||
selection_manager_.get_selected_objects());
|
||||
|
||||
ProjectSerializer::Copy(sdata);
|
||||
ProjectSerializer::copy(sdata);
|
||||
|
||||
if (cut) {
|
||||
DeleteSelected();
|
||||
delete_selected();
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -218,28 +218,28 @@ bool KeyframeView::CopySelected(bool cut)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KeyframeView::Paste(
|
||||
bool KeyframeView::paste(
|
||||
std::function<Node *(const QString &)> find_node_function)
|
||||
{
|
||||
if (!GetViewerNode()) {
|
||||
if (!get_viewer_node()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ProjectSerializer::Result res =
|
||||
ProjectSerializer::Paste(ProjectSerializer::kOnlyKeyframes);
|
||||
if (res == ProjectSerializer::kSuccess) {
|
||||
ProjectSerializer::paste(ProjectSerializer::k_only_keyframes);
|
||||
if (res == ProjectSerializer::k_success) {
|
||||
const ProjectSerializer::SerializedKeyframes &keys =
|
||||
res.GetLoadData().keyframes;
|
||||
res.get_load_data().keyframes;
|
||||
|
||||
MultiUndoCommand *command = new MultiUndoCommand();
|
||||
|
||||
rational min = RATIONAL_MAX;
|
||||
Rational min = RATIONAL_MAX;
|
||||
for (auto it = keys.cbegin(); it != keys.cend(); it++) {
|
||||
for (NodeKeyframe *key : it.value()) {
|
||||
min = std::min(min, key->time());
|
||||
}
|
||||
}
|
||||
min -= GetViewerNode()->GetPlayhead();
|
||||
min -= get_viewer_node()->get_playhead();
|
||||
|
||||
for (auto it = keys.cbegin(); it != keys.cend(); it++) {
|
||||
const QString &paste_id = it.key();
|
||||
@@ -250,13 +250,13 @@ bool KeyframeView::Paste(
|
||||
if (node_with_id) {
|
||||
for (NodeKeyframe *key : it.value()) {
|
||||
// Adjust sequence time to node's time
|
||||
rational t = key->time() - min;
|
||||
t = GetAdjustedTime(GetTimeTarget(), node_with_id, t,
|
||||
Node::kTransformTowardsInput);
|
||||
Rational t = key->time() - min;
|
||||
t = get_adjusted_time(get_time_target(), node_with_id, t,
|
||||
Node::k_transform_towards_input);
|
||||
key->set_time(t);
|
||||
|
||||
if (NodeKeyframe *existing =
|
||||
node_with_id->GetKeyframeAtTimeOnTrack(
|
||||
node_with_id->get_keyframe_at_time_on_track(
|
||||
key->input(), key->time(), key->track(),
|
||||
key->element())) {
|
||||
command->add_child(
|
||||
@@ -283,83 +283,83 @@ void KeyframeView::CatchUpScrollEvent()
|
||||
{
|
||||
super::CatchUpScrollEvent();
|
||||
|
||||
this->selection_manager_.ForceDragUpdate();
|
||||
this->selection_manager_.force_drag_update();
|
||||
}
|
||||
|
||||
void KeyframeView::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
NodeKeyframe *key_under_cursor =
|
||||
selection_manager_.GetObjectAtPoint(event->pos());
|
||||
selection_manager_.get_object_at_point(event->pos());
|
||||
|
||||
if (HandPress(event) || (!key_under_cursor && PlayheadPress(event))) {
|
||||
if (hand_press(event) || (!key_under_cursor && playhead_press(event))) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Do mouse press things
|
||||
if (FirstChanceMousePress(event)) {
|
||||
if (first_chance_mouse_press(event)) {
|
||||
first_chance_mouse_event_ = true;
|
||||
} else if (NodeKeyframe *initial_key =
|
||||
selection_manager_.MousePress(event)) {
|
||||
selection_manager_.DragStart(initial_key, event, this);
|
||||
KeyframeDragStart(event);
|
||||
selection_manager_.mouse_press(event)) {
|
||||
selection_manager_.drag_start(initial_key, event, this);
|
||||
keyframe_drag_start(event);
|
||||
} else {
|
||||
selection_manager_.RubberBandStart(event);
|
||||
selection_manager_.rubber_band_start(event);
|
||||
}
|
||||
|
||||
// Update view
|
||||
Redraw();
|
||||
redraw();
|
||||
}
|
||||
|
||||
void KeyframeView::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (HandMove(event) || PlayheadMove(event)) {
|
||||
if (hand_move(event) || playhead_move(event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (first_chance_mouse_event_) {
|
||||
FirstChanceMouseMove(event);
|
||||
} else if (selection_manager_.IsDragging()) {
|
||||
first_chance_mouse_move(event);
|
||||
} else if (selection_manager_.is_dragging()) {
|
||||
QString tip;
|
||||
KeyframeDragMove(event, tip);
|
||||
selection_manager_.DragMove(event->pos(), tip);
|
||||
} else if (selection_manager_.IsRubberBanding()) {
|
||||
selection_manager_.RubberBandMove(event->pos());
|
||||
Redraw();
|
||||
keyframe_drag_move(event, tip);
|
||||
selection_manager_.drag_move(event->pos(), tip);
|
||||
} else if (selection_manager_.is_rubber_banding()) {
|
||||
selection_manager_.rubber_band_move(event->pos());
|
||||
redraw();
|
||||
}
|
||||
|
||||
if (event->buttons()) {
|
||||
// Signal cursor pos in case we should scroll to catch up to it
|
||||
emit Dragged(event->pos().x(), event->pos().y());
|
||||
emit dragged(event->pos().x(), event->pos().y());
|
||||
}
|
||||
}
|
||||
|
||||
void KeyframeView::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (HandRelease(event) || PlayheadRelease(event)) {
|
||||
if (hand_release(event) || playhead_release(event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (first_chance_mouse_event_) {
|
||||
FirstChanceMouseRelease(event);
|
||||
first_chance_mouse_release(event);
|
||||
first_chance_mouse_event_ = false;
|
||||
} else if (selection_manager_.IsDragging()) {
|
||||
} else if (selection_manager_.is_dragging()) {
|
||||
MultiUndoCommand *command = new MultiUndoCommand();
|
||||
selection_manager_.DragStop(command);
|
||||
KeyframeDragRelease(event, command);
|
||||
selection_manager_.drag_stop(command);
|
||||
keyframe_drag_release(event, command);
|
||||
Core::instance()->undo_stack()->push(
|
||||
command, tr("Moved %1 Keyframe(s)")
|
||||
.arg(selection_manager_.GetSelectedObjects().size()));
|
||||
} else if (selection_manager_.IsRubberBanding()) {
|
||||
selection_manager_.RubberBandStop();
|
||||
Redraw();
|
||||
emit SelectionChanged();
|
||||
.arg(selection_manager_.get_selected_objects().size()));
|
||||
} else if (selection_manager_.is_rubber_banding()) {
|
||||
selection_manager_.rubber_band_stop();
|
||||
redraw();
|
||||
emit selection_changed();
|
||||
}
|
||||
|
||||
emit Released();
|
||||
emit released();
|
||||
}
|
||||
|
||||
int BinarySearchFirstKeyframeAfterOrAt(const QVector<NodeKeyframe *> &keys,
|
||||
const rational &time)
|
||||
int binary_search_first_keyframe_after_or_at(const QVector<NodeKeyframe *> &keys,
|
||||
const Rational &time)
|
||||
{
|
||||
int low = 0;
|
||||
int high = keys.size() - 1;
|
||||
@@ -384,35 +384,35 @@ int BinarySearchFirstKeyframeAfterOrAt(const QVector<NodeKeyframe *> &keys,
|
||||
|
||||
void KeyframeView::drawForeground(QPainter *painter, const QRectF &rect)
|
||||
{
|
||||
int key_sz = QtUtils::QFontMetricsWidth(fontMetrics(), "Oi");
|
||||
int key_sz = QtUtils::q_font_metrics_width(fontMetrics(), "Oi");
|
||||
int key_rad = key_sz / 2;
|
||||
|
||||
selection_manager_.ClearDrawnObjects();
|
||||
selection_manager_.clear_drawn_objects();
|
||||
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
foreach (KeyframeViewInputConnection *track, tracks_) {
|
||||
const QVector<NodeKeyframe *> &keys = track->GetKeyframes();
|
||||
const QVector<NodeKeyframe *> &keys = track->get_keyframes();
|
||||
|
||||
if (keys.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!IsYAxisEnabled()) {
|
||||
if (!is_y_axis_enabled()) {
|
||||
// Filter out if the keyframes are offscreen Y
|
||||
qreal y = GetKeyframeSceneY(track, keys.first());
|
||||
qreal y = get_keyframe_scene_y(track, keys.first());
|
||||
if (y + key_rad < rect.top() || y - key_rad >= rect.bottom()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Find first keyframe to show with binary search
|
||||
rational left_time = GetUnadjustedKeyframeTime(
|
||||
keys.first(), SceneToTime(rect.left() - key_sz));
|
||||
int using_index = BinarySearchFirstKeyframeAfterOrAt(keys, left_time);
|
||||
Rational left_time = get_unadjusted_keyframe_time(
|
||||
keys.first(), scene_to_time(rect.left() - key_sz));
|
||||
int using_index = binary_search_first_keyframe_after_or_at(keys, left_time);
|
||||
|
||||
rational next_key = RATIONAL_MIN;
|
||||
NodeKeyframe::Type last_type = NodeKeyframe::kInvalid;
|
||||
Rational next_key = RATIONAL_MIN;
|
||||
NodeKeyframe::Type last_type = NodeKeyframe::k_invalid;
|
||||
for (int i = using_index; i < keys.size(); i++) {
|
||||
NodeKeyframe *key = keys.at(i);
|
||||
|
||||
@@ -428,7 +428,7 @@ void KeyframeView::drawForeground(QPainter *painter, const QRectF &rect)
|
||||
|
||||
if (key->time() < next_key) {
|
||||
// Next key still won't be drawn, so we'll switch to a binary search
|
||||
i = BinarySearchFirstKeyframeAfterOrAt(keys, next_key);
|
||||
i = binary_search_first_keyframe_after_or_at(keys, next_key);
|
||||
|
||||
if (i == keys.size()) {
|
||||
break;
|
||||
@@ -439,17 +439,17 @@ void KeyframeView::drawForeground(QPainter *painter, const QRectF &rect)
|
||||
}
|
||||
|
||||
QRectF key_rect(-key_rad, -key_rad, key_sz, key_sz);
|
||||
qreal key_x = GetKeyframeSceneX(key);
|
||||
key_rect.translate(key_x, GetKeyframeSceneY(track, key));
|
||||
qreal key_x = get_keyframe_scene_x(key);
|
||||
key_rect.translate(key_x, get_keyframe_scene_y(track, key));
|
||||
|
||||
if (key_rect.left() >= rect.right()) {
|
||||
// Break after last keyframe
|
||||
break;
|
||||
}
|
||||
|
||||
DrawKeyframe(painter, key, track, key_rect);
|
||||
draw_keyframe(painter, key, track, key_rect);
|
||||
|
||||
next_key = GetUnadjustedKeyframeTime(key, SceneToTime(key_x + 1));
|
||||
next_key = get_unadjusted_keyframe_time(key, scene_to_time(key_x + 1));
|
||||
last_type = key->type();
|
||||
}
|
||||
}
|
||||
@@ -457,24 +457,24 @@ void KeyframeView::drawForeground(QPainter *painter, const QRectF &rect)
|
||||
super::drawForeground(painter, rect);
|
||||
}
|
||||
|
||||
void KeyframeView::DrawKeyframe(QPainter *painter, NodeKeyframe *key,
|
||||
void KeyframeView::draw_keyframe(QPainter *painter, NodeKeyframe *key,
|
||||
KeyframeViewInputConnection *track,
|
||||
const QRectF &key_rect)
|
||||
{
|
||||
painter->setPen(Qt::black);
|
||||
|
||||
if (IsKeyframeSelected(key)) {
|
||||
if (is_keyframe_selected(key)) {
|
||||
painter->setBrush(palette().highlight());
|
||||
} else {
|
||||
painter->setBrush(track->GetBrush());
|
||||
painter->setBrush(track->get_brush());
|
||||
}
|
||||
|
||||
selection_manager_.DeclareDrawnObject(key, key_rect);
|
||||
selection_manager_.declare_drawn_object(key, key_rect);
|
||||
|
||||
switch (key->type()) {
|
||||
case NodeKeyframe::kInvalid:
|
||||
case NodeKeyframe::k_invalid:
|
||||
break;
|
||||
case NodeKeyframe::kLinear: {
|
||||
case NodeKeyframe::k_linear: {
|
||||
QPointF points[] = { QPointF(key_rect.center().x(), key_rect.top()),
|
||||
QPointF(key_rect.right(), key_rect.center().y()),
|
||||
QPointF(key_rect.center().x(), key_rect.bottom()),
|
||||
@@ -483,10 +483,10 @@ void KeyframeView::DrawKeyframe(QPainter *painter, NodeKeyframe *key,
|
||||
painter->drawPolygon(points, 4);
|
||||
break;
|
||||
}
|
||||
case NodeKeyframe::kBezier:
|
||||
case NodeKeyframe::k_bezier:
|
||||
painter->drawEllipse(key_rect);
|
||||
break;
|
||||
case NodeKeyframe::kHold:
|
||||
case NodeKeyframe::k_hold:
|
||||
painter->drawRect(key_rect);
|
||||
break;
|
||||
}
|
||||
@@ -496,19 +496,19 @@ void KeyframeView::ScaleChangedEvent(const double &scale)
|
||||
{
|
||||
super::ScaleChangedEvent(scale);
|
||||
|
||||
Redraw();
|
||||
redraw();
|
||||
}
|
||||
|
||||
void KeyframeView::TimeTargetChangedEvent(ViewerOutput *v)
|
||||
{
|
||||
Redraw();
|
||||
redraw();
|
||||
}
|
||||
|
||||
void KeyframeView::TimebaseChangedEvent(const rational &timebase)
|
||||
void KeyframeView::TimebaseChangedEvent(const Rational &timebase)
|
||||
{
|
||||
super::TimebaseChangedEvent(timebase);
|
||||
|
||||
selection_manager_.SetTimebase(timebase);
|
||||
selection_manager_.set_timebase(timebase);
|
||||
}
|
||||
|
||||
void KeyframeView::ContextMenuEvent(Menu &m)
|
||||
@@ -516,46 +516,46 @@ void KeyframeView::ContextMenuEvent(Menu &m)
|
||||
Q_UNUSED(m)
|
||||
}
|
||||
|
||||
void KeyframeView::SelectKeyframe(NodeKeyframe *key)
|
||||
void KeyframeView::select_keyframe(NodeKeyframe *key)
|
||||
{
|
||||
if (selection_manager_.Select(key)) {
|
||||
Redraw();
|
||||
if (selection_manager_.select(key)) {
|
||||
redraw();
|
||||
|
||||
emit SelectionChanged();
|
||||
emit selection_changed();
|
||||
}
|
||||
}
|
||||
|
||||
void KeyframeView::DeselectKeyframe(NodeKeyframe *key)
|
||||
void KeyframeView::deselect_keyframe(NodeKeyframe *key)
|
||||
{
|
||||
if (selection_manager_.Deselect(key)) {
|
||||
Redraw();
|
||||
if (selection_manager_.deselect(key)) {
|
||||
redraw();
|
||||
|
||||
emit SelectionChanged();
|
||||
emit selection_changed();
|
||||
}
|
||||
}
|
||||
|
||||
rational KeyframeView::GetUnadjustedKeyframeTime(NodeKeyframe *key,
|
||||
const rational &time)
|
||||
Rational KeyframeView::get_unadjusted_keyframe_time(NodeKeyframe *key,
|
||||
const Rational &time)
|
||||
{
|
||||
return GetAdjustedTime(GetTimeTarget(), key->parent(), time,
|
||||
Node::kTransformTowardsInput);
|
||||
return get_adjusted_time(get_time_target(), key->parent(), time,
|
||||
Node::k_transform_towards_input);
|
||||
}
|
||||
|
||||
rational KeyframeView::GetAdjustedKeyframeTime(NodeKeyframe *key)
|
||||
Rational KeyframeView::get_adjusted_keyframe_time(NodeKeyframe *key)
|
||||
{
|
||||
return GetAdjustedTime(key->parent(), GetTimeTarget(), key->time(),
|
||||
Node::kTransformTowardsOutput);
|
||||
return get_adjusted_time(key->parent(), get_time_target(), key->time(),
|
||||
Node::k_transform_towards_output);
|
||||
}
|
||||
|
||||
double KeyframeView::GetKeyframeSceneX(NodeKeyframe *key)
|
||||
double KeyframeView::get_keyframe_scene_x(NodeKeyframe *key)
|
||||
{
|
||||
return TimeToScene(GetAdjustedKeyframeTime(key));
|
||||
return time_to_scene(get_adjusted_keyframe_time(key));
|
||||
}
|
||||
|
||||
qreal KeyframeView::GetKeyframeSceneY(KeyframeViewInputConnection *track,
|
||||
qreal KeyframeView::get_keyframe_scene_y(KeyframeViewInputConnection *track,
|
||||
NodeKeyframe *key)
|
||||
{
|
||||
return mapFromGlobal(QPoint(0, track->GetKeyframeY())).y();
|
||||
return mapFromGlobal(QPoint(0, track->get_keyframe_y())).y();
|
||||
}
|
||||
|
||||
void KeyframeView::SceneRectUpdateEvent(QRectF &rect)
|
||||
@@ -564,29 +564,29 @@ void KeyframeView::SceneRectUpdateEvent(QRectF &rect)
|
||||
rect.setHeight(max_scroll_);
|
||||
}
|
||||
|
||||
rational KeyframeView::CalculateNewTimeFromScreen(const rational &old_time,
|
||||
Rational KeyframeView::calculate_new_time_from_screen(const Rational &old_time,
|
||||
double cursor_diff)
|
||||
{
|
||||
return rational::fromDouble(old_time.toDouble() + cursor_diff);
|
||||
return Rational::from_double(old_time.to_double() + cursor_diff);
|
||||
}
|
||||
|
||||
void KeyframeView::ShowContextMenu()
|
||||
void KeyframeView::show_context_menu()
|
||||
{
|
||||
Menu m;
|
||||
|
||||
MenuShared::instance()->AddItemsForEditMenu(&m, false);
|
||||
MenuShared::instance()->add_items_for_edit_menu(&m, false);
|
||||
|
||||
QAction *linear_key_action = nullptr;
|
||||
QAction *bezier_key_action = nullptr;
|
||||
QAction *hold_key_action = nullptr;
|
||||
|
||||
if (!GetSelectedKeyframes().empty()) {
|
||||
if (!get_selected_keyframes().empty()) {
|
||||
bool all_keys_are_same_type = true;
|
||||
NodeKeyframe::Type type = GetSelectedKeyframes().front()->type();
|
||||
NodeKeyframe::Type type = get_selected_keyframes().front()->type();
|
||||
|
||||
for (size_t i = 1; i < GetSelectedKeyframes().size(); i++) {
|
||||
NodeKeyframe *key_item = GetSelectedKeyframes().at(i);
|
||||
NodeKeyframe *prev_item = GetSelectedKeyframes().at(i - 1);
|
||||
for (size_t i = 1; i < get_selected_keyframes().size(); i++) {
|
||||
NodeKeyframe *key_item = get_selected_keyframes().at(i);
|
||||
NodeKeyframe *prev_item = get_selected_keyframes().at(i - 1);
|
||||
|
||||
if (key_item->type() != prev_item->type()) {
|
||||
all_keys_are_same_type = false;
|
||||
@@ -602,15 +602,15 @@ void KeyframeView::ShowContextMenu()
|
||||
|
||||
if (all_keys_are_same_type) {
|
||||
switch (type) {
|
||||
case NodeKeyframe::kInvalid:
|
||||
case NodeKeyframe::k_invalid:
|
||||
break;
|
||||
case NodeKeyframe::kLinear:
|
||||
case NodeKeyframe::k_linear:
|
||||
linear_key_action->setChecked(true);
|
||||
break;
|
||||
case NodeKeyframe::kBezier:
|
||||
case NodeKeyframe::k_bezier:
|
||||
bezier_key_action->setChecked(true);
|
||||
break;
|
||||
case NodeKeyframe::kHold:
|
||||
case NodeKeyframe::k_hold:
|
||||
hold_key_action->setChecked(true);
|
||||
break;
|
||||
}
|
||||
@@ -621,12 +621,12 @@ void KeyframeView::ShowContextMenu()
|
||||
|
||||
ContextMenuEvent(m);
|
||||
|
||||
if (!GetSelectedKeyframes().empty()) {
|
||||
if (!get_selected_keyframes().empty()) {
|
||||
m.addSeparator();
|
||||
|
||||
QAction *properties_action = m.addAction(tr("P&roperties"));
|
||||
connect(properties_action, &QAction::triggered, this,
|
||||
&KeyframeView::ShowKeyframePropertiesDialog);
|
||||
&KeyframeView::show_keyframe_properties_dialog);
|
||||
}
|
||||
|
||||
QAction *selected = m.exec(QCursor::pos());
|
||||
@@ -638,38 +638,38 @@ void KeyframeView::ShowContextMenu()
|
||||
NodeKeyframe::Type new_type;
|
||||
|
||||
if (selected == hold_key_action) {
|
||||
new_type = NodeKeyframe::kHold;
|
||||
new_type = NodeKeyframe::k_hold;
|
||||
} else if (selected == bezier_key_action) {
|
||||
new_type = NodeKeyframe::kBezier;
|
||||
new_type = NodeKeyframe::k_bezier;
|
||||
} else {
|
||||
new_type = NodeKeyframe::kLinear;
|
||||
new_type = NodeKeyframe::k_linear;
|
||||
}
|
||||
|
||||
MultiUndoCommand *command = new MultiUndoCommand();
|
||||
foreach (NodeKeyframe *item, GetSelectedKeyframes()) {
|
||||
foreach (NodeKeyframe *item, get_selected_keyframes()) {
|
||||
command->add_child(new KeyframeSetTypeCommand(item, new_type));
|
||||
}
|
||||
Core::instance()->undo_stack()->push(
|
||||
command, tr("Set Type of %1 Keyframe(s)")
|
||||
.arg(GetSelectedKeyframes().size()));
|
||||
.arg(get_selected_keyframes().size()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KeyframeView::ShowKeyframePropertiesDialog()
|
||||
void KeyframeView::show_keyframe_properties_dialog()
|
||||
{
|
||||
if (!GetSelectedKeyframes().empty()) {
|
||||
KeyframePropertiesDialog kd(GetSelectedKeyframes(), timebase(), this);
|
||||
if (!get_selected_keyframes().empty()) {
|
||||
KeyframePropertiesDialog kd(get_selected_keyframes(), timebase(), this);
|
||||
kd.exec();
|
||||
}
|
||||
}
|
||||
|
||||
void KeyframeView::UpdateRubberBandForScroll()
|
||||
void KeyframeView::update_rubber_band_for_scroll()
|
||||
{
|
||||
this->selection_manager_.ForceDragUpdate();
|
||||
this->selection_manager_.force_drag_update();
|
||||
}
|
||||
|
||||
void KeyframeView::Redraw()
|
||||
void KeyframeView::redraw()
|
||||
{
|
||||
viewport()->update();
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef KEYFRAMEVIEWBASE_H
|
||||
#define KEYFRAMEVIEWBASE_H
|
||||
#ifndef OAK_KEYFRAMEVIEWBASE_H
|
||||
#define OAK_KEYFRAMEVIEWBASE_H
|
||||
|
||||
#include <functional>
|
||||
|
||||
@@ -39,35 +39,35 @@ class KeyframeView : public TimeBasedView, public TimeTargetObject {
|
||||
public:
|
||||
KeyframeView(QWidget *parent = nullptr);
|
||||
|
||||
void DeleteSelected();
|
||||
void delete_selected();
|
||||
|
||||
using ElementConnections = QVector<KeyframeViewInputConnection *>;
|
||||
using InputConnections = QVector<ElementConnections>;
|
||||
using NodeConnections = QMap<QString, InputConnections>;
|
||||
|
||||
NodeConnections AddKeyframesOfNode(Node *n);
|
||||
NodeConnections add_keyframes_of_node(Node *n);
|
||||
|
||||
InputConnections AddKeyframesOfInput(Node *n, const QString &input);
|
||||
InputConnections add_keyframes_of_input(Node *n, const QString &input);
|
||||
|
||||
ElementConnections AddKeyframesOfElement(const NodeInput &input);
|
||||
ElementConnections add_keyframes_of_element(const NodeInput &input);
|
||||
|
||||
KeyframeViewInputConnection *
|
||||
AddKeyframesOfTrack(const NodeKeyframeTrackReference &ref);
|
||||
add_keyframes_of_track(const NodeKeyframeTrackReference &ref);
|
||||
|
||||
void RemoveKeyframesOfTrack(KeyframeViewInputConnection *connection);
|
||||
void remove_keyframes_of_track(KeyframeViewInputConnection *connection);
|
||||
|
||||
void SelectAll();
|
||||
void select_all();
|
||||
|
||||
void DeselectAll();
|
||||
void deselect_all();
|
||||
|
||||
void Clear();
|
||||
void clear();
|
||||
|
||||
const std::vector<NodeKeyframe *> &GetSelectedKeyframes() const
|
||||
const std::vector<NodeKeyframe *> &get_selected_keyframes() const
|
||||
{
|
||||
return selection_manager_.GetSelectedObjects();
|
||||
return selection_manager_.get_selected_objects();
|
||||
}
|
||||
|
||||
const QVector<KeyframeViewInputConnection *> &GetKeyframeTracks() const
|
||||
const QVector<KeyframeViewInputConnection *> &get_keyframe_tracks() const
|
||||
{
|
||||
return tracks_;
|
||||
}
|
||||
@@ -75,24 +75,24 @@ public:
|
||||
virtual void SelectionManagerSelectEvent(void *obj) override;
|
||||
virtual void SelectionManagerDeselectEvent(void *obj) override;
|
||||
|
||||
void SetMaxScroll(int i)
|
||||
void set_max_scroll(int i)
|
||||
{
|
||||
max_scroll_ = i;
|
||||
UpdateSceneRect();
|
||||
update_scene_rect();
|
||||
}
|
||||
|
||||
bool CopySelected(bool cut);
|
||||
bool copy_selected(bool cut);
|
||||
|
||||
bool Paste(std::function<Node *(const QString &)> find_node_function);
|
||||
bool paste(std::function<Node *(const QString &)> find_node_function);
|
||||
|
||||
virtual void CatchUpScrollEvent() override;
|
||||
|
||||
signals:
|
||||
void Dragged(int current_x, int current_y);
|
||||
void dragged(int current_x, int current_y);
|
||||
|
||||
void SelectionChanged();
|
||||
void selection_changed();
|
||||
|
||||
void Released();
|
||||
void released();
|
||||
|
||||
protected:
|
||||
virtual void mousePressEvent(QMouseEvent *event) override;
|
||||
@@ -101,7 +101,7 @@ protected:
|
||||
|
||||
virtual void drawForeground(QPainter *painter, const QRectF &rect) override;
|
||||
|
||||
virtual void DrawKeyframe(QPainter *painter, NodeKeyframe *key,
|
||||
virtual void draw_keyframe(QPainter *painter, NodeKeyframe *key,
|
||||
KeyframeViewInputConnection *track,
|
||||
const QRectF &key_rect);
|
||||
|
||||
@@ -109,55 +109,55 @@ protected:
|
||||
|
||||
virtual void TimeTargetChangedEvent(ViewerOutput *v) override;
|
||||
|
||||
virtual void TimebaseChangedEvent(const rational &timebase) override;
|
||||
virtual void TimebaseChangedEvent(const Rational &timebase) override;
|
||||
|
||||
virtual void ContextMenuEvent(Menu &m);
|
||||
|
||||
virtual bool FirstChanceMousePress(QMouseEvent *event)
|
||||
virtual bool first_chance_mouse_press(QMouseEvent *event)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
virtual void FirstChanceMouseMove(QMouseEvent *event)
|
||||
virtual void first_chance_mouse_move(QMouseEvent *event)
|
||||
{
|
||||
}
|
||||
virtual void FirstChanceMouseRelease(QMouseEvent *event)
|
||||
virtual void first_chance_mouse_release(QMouseEvent *event)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void KeyframeDragStart(QMouseEvent *event)
|
||||
virtual void keyframe_drag_start(QMouseEvent *event)
|
||||
{
|
||||
}
|
||||
virtual void KeyframeDragMove(QMouseEvent *event, QString &tip)
|
||||
virtual void keyframe_drag_move(QMouseEvent *event, QString &tip)
|
||||
{
|
||||
}
|
||||
virtual void KeyframeDragRelease(QMouseEvent *event,
|
||||
virtual void keyframe_drag_release(QMouseEvent *event,
|
||||
MultiUndoCommand *command)
|
||||
{
|
||||
}
|
||||
|
||||
void SelectKeyframe(NodeKeyframe *key);
|
||||
void select_keyframe(NodeKeyframe *key);
|
||||
|
||||
void DeselectKeyframe(NodeKeyframe *key);
|
||||
void deselect_keyframe(NodeKeyframe *key);
|
||||
|
||||
bool IsKeyframeSelected(NodeKeyframe *key) const
|
||||
bool is_keyframe_selected(NodeKeyframe *key) const
|
||||
{
|
||||
return selection_manager_.IsSelected(key);
|
||||
return selection_manager_.is_selected(key);
|
||||
}
|
||||
|
||||
rational GetUnadjustedKeyframeTime(NodeKeyframe *key, const rational &time);
|
||||
rational GetUnadjustedKeyframeTime(NodeKeyframe *key)
|
||||
Rational get_unadjusted_keyframe_time(NodeKeyframe *key, const Rational &time);
|
||||
Rational get_unadjusted_keyframe_time(NodeKeyframe *key)
|
||||
{
|
||||
return GetUnadjustedKeyframeTime(key, key->time());
|
||||
return get_unadjusted_keyframe_time(key, key->time());
|
||||
}
|
||||
|
||||
rational GetAdjustedKeyframeTime(NodeKeyframe *key);
|
||||
Rational get_adjusted_keyframe_time(NodeKeyframe *key);
|
||||
|
||||
double GetKeyframeSceneX(NodeKeyframe *key);
|
||||
double get_keyframe_scene_x(NodeKeyframe *key);
|
||||
|
||||
virtual qreal GetKeyframeSceneY(KeyframeViewInputConnection *track,
|
||||
virtual qreal get_keyframe_scene_y(KeyframeViewInputConnection *track,
|
||||
NodeKeyframe *key);
|
||||
|
||||
void SetAutoSelectSiblings(bool e)
|
||||
void set_auto_select_siblings(bool e)
|
||||
{
|
||||
autoselect_siblings_ = e;
|
||||
}
|
||||
@@ -165,10 +165,10 @@ protected:
|
||||
virtual void SceneRectUpdateEvent(QRectF &rect) override;
|
||||
|
||||
protected slots:
|
||||
void Redraw();
|
||||
void redraw();
|
||||
|
||||
private:
|
||||
rational CalculateNewTimeFromScreen(const rational &old_time,
|
||||
Rational calculate_new_time_from_screen(const Rational &old_time,
|
||||
double cursor_diff);
|
||||
|
||||
QVector<KeyframeViewInputConnection *> tracks_;
|
||||
@@ -182,13 +182,13 @@ private:
|
||||
bool first_chance_mouse_event_;
|
||||
|
||||
private slots:
|
||||
void ShowContextMenu();
|
||||
void show_context_menu();
|
||||
|
||||
void ShowKeyframePropertiesDialog();
|
||||
void show_keyframe_properties_dialog();
|
||||
|
||||
void UpdateRubberBandForScroll();
|
||||
void update_rubber_band_for_scroll();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // KEYFRAMEVIEWBASE_H
|
||||
#endif // OAK_KEYFRAMEVIEWBASE_H
|
||||
|
||||
@@ -32,77 +32,77 @@ KeyframeViewInputConnection::KeyframeViewInputConnection(
|
||||
, keyframe_view_(parent)
|
||||
, input_(input)
|
||||
, y_(0)
|
||||
, y_behavior_(kSingleRow)
|
||||
, y_behavior_(k_single_row)
|
||||
, brush_(Qt::white)
|
||||
{
|
||||
Node *n = input.input().node();
|
||||
|
||||
connect(n, &Node::KeyframeAdded, this,
|
||||
&KeyframeViewInputConnection::AddKeyframe);
|
||||
connect(n, &Node::KeyframeRemoved, this,
|
||||
&KeyframeViewInputConnection::RemoveKeyframe);
|
||||
connect(n, &Node::KeyframeTimeChanged, this,
|
||||
&KeyframeViewInputConnection::KeyframeChanged);
|
||||
connect(n, &Node::KeyframeTypeChanged, this,
|
||||
&KeyframeViewInputConnection::KeyframeChanged);
|
||||
connect(n, &Node::KeyframeTypeChanged, this,
|
||||
&KeyframeViewInputConnection::KeyframeTypeChanged);
|
||||
connect(n, &Node::KeyframeValueChanged, this,
|
||||
&KeyframeViewInputConnection::KeyframeChanged);
|
||||
connect(n, &Node::keyframe_added, this,
|
||||
&KeyframeViewInputConnection::add_keyframe);
|
||||
connect(n, &Node::keyframe_removed, this,
|
||||
&KeyframeViewInputConnection::remove_keyframe);
|
||||
connect(n, &Node::keyframe_time_changed, this,
|
||||
&KeyframeViewInputConnection::keyframe_changed);
|
||||
connect(n, &Node::keyframe_type_changed, this,
|
||||
&KeyframeViewInputConnection::keyframe_changed);
|
||||
connect(n, &Node::keyframe_type_changed, this,
|
||||
&KeyframeViewInputConnection::keyframe_type_changed);
|
||||
connect(n, &Node::keyframe_value_changed, this,
|
||||
&KeyframeViewInputConnection::keyframe_changed);
|
||||
}
|
||||
|
||||
void KeyframeViewInputConnection::SetKeyframeY(int y)
|
||||
void KeyframeViewInputConnection::set_keyframe_y(int y)
|
||||
{
|
||||
if (y_ != y) {
|
||||
y_ = y;
|
||||
|
||||
emit RequireUpdate();
|
||||
emit require_update();
|
||||
}
|
||||
}
|
||||
|
||||
void KeyframeViewInputConnection::SetYBehavior(YBehavior e)
|
||||
void KeyframeViewInputConnection::set_y_behavior(YBehavior e)
|
||||
{
|
||||
if (y_behavior_ != e) {
|
||||
y_behavior_ = e;
|
||||
|
||||
emit RequireUpdate();
|
||||
emit require_update();
|
||||
}
|
||||
}
|
||||
|
||||
void KeyframeViewInputConnection::SetBrush(const QBrush &brush)
|
||||
void KeyframeViewInputConnection::set_brush(const QBrush &brush)
|
||||
{
|
||||
if (brush_ != brush) {
|
||||
brush_ = brush;
|
||||
|
||||
emit RequireUpdate();
|
||||
emit require_update();
|
||||
}
|
||||
}
|
||||
|
||||
void KeyframeViewInputConnection::AddKeyframe(NodeKeyframe *key)
|
||||
void KeyframeViewInputConnection::add_keyframe(NodeKeyframe *key)
|
||||
{
|
||||
if (key->key_track_ref() == input_) {
|
||||
emit RequireUpdate();
|
||||
emit require_update();
|
||||
}
|
||||
}
|
||||
|
||||
void KeyframeViewInputConnection::RemoveKeyframe(NodeKeyframe *key)
|
||||
void KeyframeViewInputConnection::remove_keyframe(NodeKeyframe *key)
|
||||
{
|
||||
if (key->key_track_ref() == input_) {
|
||||
emit RequireUpdate();
|
||||
emit require_update();
|
||||
}
|
||||
}
|
||||
|
||||
void KeyframeViewInputConnection::KeyframeChanged(NodeKeyframe *key)
|
||||
void KeyframeViewInputConnection::keyframe_changed(NodeKeyframe *key)
|
||||
{
|
||||
if (key->key_track_ref() == input_) {
|
||||
emit RequireUpdate();
|
||||
emit require_update();
|
||||
}
|
||||
}
|
||||
|
||||
void KeyframeViewInputConnection::KeyframeTypeChanged(NodeKeyframe *key)
|
||||
void KeyframeViewInputConnection::keyframe_type_changed(NodeKeyframe *key)
|
||||
{
|
||||
if (key->key_track_ref() == input_) {
|
||||
emit TypeChanged();
|
||||
emit type_changed();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef KEYFRAMEVIEWINPUTCONNECTION_H
|
||||
#define KEYFRAMEVIEWINPUTCONNECTION_H
|
||||
#ifndef OAK_KEYFRAMEVIEWINPUTCONNECTION_H
|
||||
#define OAK_KEYFRAMEVIEWINPUTCONNECTION_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
@@ -38,41 +38,41 @@ public:
|
||||
KeyframeViewInputConnection(const NodeKeyframeTrackReference &input,
|
||||
KeyframeView *parent);
|
||||
|
||||
const int &GetKeyframeY() const
|
||||
const int &get_keyframe_y() const
|
||||
{
|
||||
return y_;
|
||||
}
|
||||
|
||||
void SetKeyframeY(int y);
|
||||
void set_keyframe_y(int y);
|
||||
|
||||
enum YBehavior { kSingleRow, kValueIsHeight };
|
||||
enum YBehavior { k_single_row, k_value_is_height };
|
||||
|
||||
void SetYBehavior(YBehavior e);
|
||||
void set_y_behavior(YBehavior e);
|
||||
|
||||
const QVector<NodeKeyframe *> &GetKeyframes() const
|
||||
const QVector<NodeKeyframe *> &get_keyframes() const
|
||||
{
|
||||
return input_.input()
|
||||
.node()
|
||||
->GetKeyframeTracks(input_.input())
|
||||
->get_keyframe_tracks(input_.input())
|
||||
.at(input_.track());
|
||||
}
|
||||
|
||||
const QBrush &GetBrush() const
|
||||
const QBrush &get_brush() const
|
||||
{
|
||||
return brush_;
|
||||
}
|
||||
|
||||
const NodeKeyframeTrackReference &GetReference() const
|
||||
const NodeKeyframeTrackReference &get_reference() const
|
||||
{
|
||||
return input_;
|
||||
}
|
||||
|
||||
void SetBrush(const QBrush &brush);
|
||||
void set_brush(const QBrush &brush);
|
||||
|
||||
signals:
|
||||
void RequireUpdate();
|
||||
void require_update();
|
||||
|
||||
void TypeChanged();
|
||||
void type_changed();
|
||||
|
||||
private:
|
||||
KeyframeView *keyframe_view_;
|
||||
@@ -86,15 +86,15 @@ private:
|
||||
QBrush brush_;
|
||||
|
||||
private slots:
|
||||
void AddKeyframe(NodeKeyframe *key);
|
||||
void add_keyframe(NodeKeyframe *key);
|
||||
|
||||
void RemoveKeyframe(NodeKeyframe *key);
|
||||
void remove_keyframe(NodeKeyframe *key);
|
||||
|
||||
void KeyframeChanged(NodeKeyframe *key);
|
||||
void keyframe_changed(NodeKeyframe *key);
|
||||
|
||||
void KeyframeTypeChanged(NodeKeyframe *key);
|
||||
void keyframe_type_changed(NodeKeyframe *key);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // KEYFRAMEVIEWINPUTCONNECTION_H
|
||||
#endif // OAK_KEYFRAMEVIEWINPUTCONNECTION_H
|
||||
|
||||
@@ -35,7 +35,7 @@ KeyframeSetTypeCommand::KeyframeSetTypeCommand(NodeKeyframe *key,
|
||||
{
|
||||
}
|
||||
|
||||
Project *KeyframeSetTypeCommand::GetRelevantProject() const
|
||||
Project *KeyframeSetTypeCommand::get_relevant_project() const
|
||||
{
|
||||
return key_->parent()->project();
|
||||
}
|
||||
@@ -69,7 +69,7 @@ KeyframeSetBezierControlPoint::KeyframeSetBezierControlPoint(
|
||||
{
|
||||
}
|
||||
|
||||
Project *KeyframeSetBezierControlPoint::GetRelevantProject() const
|
||||
Project *KeyframeSetBezierControlPoint::get_relevant_project() const
|
||||
{
|
||||
return key_->parent()->project();
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef KEYFRAMEVIEWUNDO_H
|
||||
#define KEYFRAMEVIEWUNDO_H
|
||||
#ifndef OAK_KEYFRAMEVIEWUNDO_H
|
||||
#define OAK_KEYFRAMEVIEWUNDO_H
|
||||
|
||||
#include "node/keyframe.h"
|
||||
#include "undo/undocommand.h"
|
||||
@@ -32,7 +32,7 @@ class KeyframeSetTypeCommand : public UndoCommand {
|
||||
public:
|
||||
KeyframeSetTypeCommand(NodeKeyframe *key, NodeKeyframe::Type type);
|
||||
|
||||
virtual Project *GetRelevantProject() const override;
|
||||
virtual Project *get_relevant_project() const override;
|
||||
|
||||
protected:
|
||||
virtual void redo() override;
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
const QPointF &new_point,
|
||||
const QPointF &old_point);
|
||||
|
||||
virtual Project *GetRelevantProject() const override;
|
||||
virtual Project *get_relevant_project() const override;
|
||||
|
||||
protected:
|
||||
virtual void redo() override;
|
||||
@@ -74,4 +74,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // KEYFRAMEVIEWUNDO_H
|
||||
#endif // OAK_KEYFRAMEVIEWUNDO_H
|
||||
|
||||
@@ -50,10 +50,10 @@ ManagedDisplayWidget::ManagedDisplayWidget(QWidget *parent)
|
||||
#ifdef OAK_ENABLE_DYNAMIC_RENDER_BACKEND
|
||||
{
|
||||
auto *dynamic_renderer = new DynamicRenderer(
|
||||
RenderManager::BackendToString(
|
||||
RenderManager::backend_to_string(
|
||||
RenderManager::instance()->requested_backend()),
|
||||
this);
|
||||
if (!dynamic_renderer->Load()) {
|
||||
if (!dynamic_renderer->load()) {
|
||||
qWarning()
|
||||
<< "Failed to load dynamic render backend for viewer, falling back to OpenGL";
|
||||
delete dynamic_renderer;
|
||||
@@ -66,22 +66,22 @@ ManagedDisplayWidget::ManagedDisplayWidget(QWidget *parent)
|
||||
attached_renderer_ = new OpenGLRenderer(this);
|
||||
#endif
|
||||
|
||||
if (attached_renderer_->IsOpenGL()) {
|
||||
if (attached_renderer_->is_open_gl()) {
|
||||
// OpenGL path
|
||||
inner_widget_ = new ManagedDisplayWidgetOpenGL();
|
||||
inner_widget_->setAttribute(Qt::WA_TranslucentBackground, false);
|
||||
connect(static_cast<ManagedDisplayWidgetOpenGL *>(inner_widget_),
|
||||
&ManagedDisplayWidgetOpenGL::OnInit, this,
|
||||
&ManagedDisplayWidget::OnInit, Qt::DirectConnection);
|
||||
&ManagedDisplayWidgetOpenGL::on_init, this,
|
||||
&ManagedDisplayWidget::on_init, Qt::DirectConnection);
|
||||
connect(static_cast<ManagedDisplayWidgetOpenGL *>(inner_widget_),
|
||||
&ManagedDisplayWidgetOpenGL::OnDestroy, this,
|
||||
&ManagedDisplayWidget::OnDestroy, Qt::DirectConnection);
|
||||
&ManagedDisplayWidgetOpenGL::on_destroy, this,
|
||||
&ManagedDisplayWidget::on_destroy, Qt::DirectConnection);
|
||||
connect(static_cast<ManagedDisplayWidgetOpenGL *>(inner_widget_),
|
||||
&ManagedDisplayWidgetOpenGL::OnPaint, this,
|
||||
&ManagedDisplayWidget::OnPaint, Qt::DirectConnection);
|
||||
&ManagedDisplayWidgetOpenGL::on_paint, this,
|
||||
&ManagedDisplayWidget::on_paint, Qt::DirectConnection);
|
||||
connect(static_cast<ManagedDisplayWidgetOpenGL *>(inner_widget_),
|
||||
&ManagedDisplayWidgetOpenGL::frameSwapped, this,
|
||||
&ManagedDisplayWidget::frameSwapped, Qt::DirectConnection);
|
||||
&ManagedDisplayWidget::frame_swapped, Qt::DirectConnection);
|
||||
|
||||
inner_widget_->installEventFilter(this);
|
||||
|
||||
@@ -100,8 +100,8 @@ ManagedDisplayWidget::ManagedDisplayWidget(QWidget *parent)
|
||||
inner_widget_ = bn_widget;
|
||||
inner_widget_->setAttribute(Qt::WA_OpaquePaintEvent);
|
||||
inner_widget_->installEventFilter(this);
|
||||
connect(bn_widget, &ManagedDisplayWidgetBackendNeutral::OnPaint, this,
|
||||
&ManagedDisplayWidget::OnPaint, Qt::DirectConnection);
|
||||
connect(bn_widget, &ManagedDisplayWidgetBackendNeutral::on_paint, this,
|
||||
&ManagedDisplayWidget::on_paint, Qt::DirectConnection);
|
||||
wrapper_ = inner_widget_;
|
||||
layout->addWidget(wrapper_);
|
||||
}
|
||||
@@ -113,37 +113,37 @@ ManagedDisplayWidget::~ManagedDisplayWidget()
|
||||
MANAGEDDISPLAYWIDGET_DEFAULT_DESTRUCTOR_INNER;
|
||||
|
||||
disconnect(static_cast<ManagedDisplayWidgetOpenGL *>(inner_widget_),
|
||||
&ManagedDisplayWidgetOpenGL::OnDestroy, this,
|
||||
&ManagedDisplayWidget::OnDestroy);
|
||||
&ManagedDisplayWidgetOpenGL::on_destroy, this,
|
||||
&ManagedDisplayWidget::on_destroy);
|
||||
} else {
|
||||
OnDestroy();
|
||||
on_destroy();
|
||||
}
|
||||
}
|
||||
|
||||
void ManagedDisplayWidget::ConnectColorManager(ColorManager *color_manager)
|
||||
void ManagedDisplayWidget::connect_color_manager(ColorManager *color_manager)
|
||||
{
|
||||
if (color_manager_ == color_manager) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (color_manager_ != nullptr) {
|
||||
disconnect(color_manager_, &ColorManager::ConfigChanged, this,
|
||||
&ManagedDisplayWidget::ColorConfigChanged);
|
||||
disconnect(color_manager_, &ColorManager::ReferenceSpaceChanged, this,
|
||||
&ManagedDisplayWidget::ColorConfigChanged);
|
||||
disconnect(color_manager_, &ColorManager::config_changed, this,
|
||||
&ManagedDisplayWidget::color_config_changed);
|
||||
disconnect(color_manager_, &ColorManager::reference_space_changed, this,
|
||||
&ManagedDisplayWidget::color_config_changed);
|
||||
}
|
||||
|
||||
color_manager_ = color_manager;
|
||||
|
||||
if (color_manager_ != nullptr) {
|
||||
connect(color_manager_, &ColorManager::ConfigChanged, this,
|
||||
&ManagedDisplayWidget::ColorConfigChanged);
|
||||
connect(color_manager_, &ColorManager::ReferenceSpaceChanged, this,
|
||||
&ManagedDisplayWidget::ColorConfigChanged);
|
||||
connect(color_manager_, &ColorManager::config_changed, this,
|
||||
&ManagedDisplayWidget::color_config_changed);
|
||||
connect(color_manager_, &ColorManager::reference_space_changed, this,
|
||||
&ManagedDisplayWidget::color_config_changed);
|
||||
}
|
||||
|
||||
ColorConfigChanged();
|
||||
emit ColorManagerChanged(color_manager_);
|
||||
color_config_changed();
|
||||
emit color_manager_changed(color_manager_);
|
||||
}
|
||||
|
||||
ColorManager *ManagedDisplayWidget::color_manager() const
|
||||
@@ -151,25 +151,25 @@ ColorManager *ManagedDisplayWidget::color_manager() const
|
||||
return color_manager_;
|
||||
}
|
||||
|
||||
void ManagedDisplayWidget::DisconnectColorManager()
|
||||
void ManagedDisplayWidget::disconnect_color_manager()
|
||||
{
|
||||
ConnectColorManager(nullptr);
|
||||
connect_color_manager(nullptr);
|
||||
}
|
||||
|
||||
const ColorTransform &ManagedDisplayWidget::GetColorTransform() const
|
||||
const ColorTransform &ManagedDisplayWidget::get_color_transform() const
|
||||
{
|
||||
return color_transform_;
|
||||
}
|
||||
|
||||
Menu *ManagedDisplayWidget::GetColorSpaceMenu(QMenu *parent, bool auto_connect)
|
||||
Menu *ManagedDisplayWidget::get_color_space_menu(QMenu *parent, bool auto_connect)
|
||||
{
|
||||
QStringList colorspaces = color_manager()->ListAvailableColorspaces();
|
||||
QStringList colorspaces = color_manager()->list_available_colorspaces();
|
||||
|
||||
Menu *ocio_colorspace_menu = new Menu(tr("Color Space"), parent);
|
||||
|
||||
if (auto_connect) {
|
||||
connect(ocio_colorspace_menu, &Menu::triggered, this,
|
||||
&ManagedDisplayWidget::MenuColorspaceSelect);
|
||||
&ManagedDisplayWidget::menu_colorspace_select);
|
||||
}
|
||||
|
||||
foreach (const QString &c, colorspaces) {
|
||||
@@ -182,7 +182,7 @@ Menu *ManagedDisplayWidget::GetColorSpaceMenu(QMenu *parent, bool auto_connect)
|
||||
return ocio_colorspace_menu;
|
||||
}
|
||||
|
||||
void ManagedDisplayWidget::ColorConfigChanged()
|
||||
void ManagedDisplayWidget::color_config_changed()
|
||||
{
|
||||
if (!color_manager_) {
|
||||
color_service_ = nullptr;
|
||||
@@ -195,13 +195,13 @@ void ManagedDisplayWidget::ColorConfigChanged()
|
||||
// which is usually a scene-referred space (e.g. ACEScg / Linear) and makes
|
||||
// the picture look raw/wrong on a monitor.
|
||||
if (color_transform_.output().isEmpty()) {
|
||||
QString display = color_manager_->GetDefaultDisplay();
|
||||
QString view = color_manager_->GetDefaultView(display);
|
||||
SetColorTransform(color_manager_->GetCompliantColorSpace(
|
||||
QString display = color_manager_->get_default_display();
|
||||
QString view = color_manager_->get_default_view(display);
|
||||
set_color_transform(color_manager_->get_compliant_color_space(
|
||||
ColorTransform(display, view, QString()), true));
|
||||
} else {
|
||||
SetColorTransform(
|
||||
color_manager_->GetCompliantColorSpace(color_transform_, false));
|
||||
set_color_transform(
|
||||
color_manager_->get_compliant_color_space(color_transform_, false));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,16 +210,16 @@ ColorProcessorPtr ManagedDisplayWidget::color_service()
|
||||
return color_service_;
|
||||
}
|
||||
|
||||
void ManagedDisplayWidget::ShowDefaultContextMenu()
|
||||
void ManagedDisplayWidget::show_default_context_menu()
|
||||
{
|
||||
Menu m(this);
|
||||
|
||||
if (color_manager_) {
|
||||
m.addMenu(GetColorSpaceMenu(&m));
|
||||
m.addMenu(get_color_space_menu(&m));
|
||||
m.addSeparator();
|
||||
m.addMenu(GetDisplayMenu(&m));
|
||||
m.addMenu(GetViewMenu(&m));
|
||||
m.addMenu(GetLookMenu(&m));
|
||||
m.addMenu(get_display_menu(&m));
|
||||
m.addMenu(get_view_menu(&m));
|
||||
m.addMenu(get_look_menu(&m));
|
||||
} else {
|
||||
QAction *a = m.addAction(tr("No color manager connected"));
|
||||
a->setEnabled(false);
|
||||
@@ -228,61 +228,61 @@ void ManagedDisplayWidget::ShowDefaultContextMenu()
|
||||
m.exec(QCursor::pos());
|
||||
}
|
||||
|
||||
void ManagedDisplayWidget::MenuDisplaySelect(QAction *action)
|
||||
void ManagedDisplayWidget::menu_display_select(QAction *action)
|
||||
{
|
||||
const ColorTransform &old_transform = GetColorTransform();
|
||||
const ColorTransform &old_transform = get_color_transform();
|
||||
|
||||
ColorTransform new_transform = color_manager()->GetCompliantColorSpace(
|
||||
ColorTransform new_transform = color_manager()->get_compliant_color_space(
|
||||
ColorTransform(action->data().toString(), old_transform.view(),
|
||||
old_transform.look()));
|
||||
|
||||
SetColorTransform(new_transform);
|
||||
set_color_transform(new_transform);
|
||||
}
|
||||
|
||||
void ManagedDisplayWidget::MenuViewSelect(QAction *action)
|
||||
void ManagedDisplayWidget::menu_view_select(QAction *action)
|
||||
{
|
||||
const ColorTransform &old_transform = GetColorTransform();
|
||||
const ColorTransform &old_transform = get_color_transform();
|
||||
|
||||
ColorTransform new_transform = color_manager()->GetCompliantColorSpace(
|
||||
ColorTransform new_transform = color_manager()->get_compliant_color_space(
|
||||
ColorTransform(old_transform.display(), action->data().toString(),
|
||||
old_transform.look()));
|
||||
|
||||
SetColorTransform(new_transform);
|
||||
set_color_transform(new_transform);
|
||||
}
|
||||
|
||||
void ManagedDisplayWidget::MenuLookSelect(QAction *action)
|
||||
void ManagedDisplayWidget::menu_look_select(QAction *action)
|
||||
{
|
||||
const ColorTransform &old_transform = GetColorTransform();
|
||||
const ColorTransform &old_transform = get_color_transform();
|
||||
|
||||
ColorTransform new_transform = color_manager()->GetCompliantColorSpace(
|
||||
ColorTransform new_transform = color_manager()->get_compliant_color_space(
|
||||
ColorTransform(old_transform.display(), old_transform.view(),
|
||||
action->data().toString()));
|
||||
|
||||
SetColorTransform(new_transform);
|
||||
set_color_transform(new_transform);
|
||||
}
|
||||
|
||||
void ManagedDisplayWidget::MenuColorspaceSelect(QAction *action)
|
||||
void ManagedDisplayWidget::menu_colorspace_select(QAction *action)
|
||||
{
|
||||
SetColorTransform(color_manager()->GetCompliantColorSpace(
|
||||
set_color_transform(color_manager()->get_compliant_color_space(
|
||||
ColorTransform(action->data().toString())));
|
||||
}
|
||||
|
||||
void ManagedDisplayWidget::OnDestroy()
|
||||
void ManagedDisplayWidget::on_destroy()
|
||||
{
|
||||
attached_renderer_->Destroy();
|
||||
attached_renderer_->PostDestroy();
|
||||
attached_renderer_->destroy();
|
||||
attached_renderer_->post_destroy();
|
||||
}
|
||||
|
||||
void ManagedDisplayWidget::SetColorTransform(const ColorTransform &transform)
|
||||
void ManagedDisplayWidget::set_color_transform(const ColorTransform &transform)
|
||||
{
|
||||
color_transform_ = transform;
|
||||
|
||||
SetupColorProcessor();
|
||||
setup_color_processor();
|
||||
|
||||
ColorProcessorChangedEvent();
|
||||
}
|
||||
|
||||
void ManagedDisplayWidget::OnInit()
|
||||
void ManagedDisplayWidget::on_init()
|
||||
{
|
||||
if (!is_backend_neutral_) {
|
||||
QOpenGLContext *context =
|
||||
@@ -290,23 +290,23 @@ void ManagedDisplayWidget::OnInit()
|
||||
#ifdef OAK_ENABLE_DYNAMIC_RENDER_BACKEND
|
||||
if (auto *dynamic_renderer =
|
||||
dynamic_cast<DynamicRenderer *>(attached_renderer_)) {
|
||||
dynamic_renderer->InitWithOpenGLContext(context);
|
||||
dynamic_renderer->PostInit();
|
||||
dynamic_renderer->init_with_open_gl_context(context);
|
||||
dynamic_renderer->post_init();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
static_cast<OpenGLRenderer *>(attached_renderer_)->Init(context);
|
||||
static_cast<OpenGLRenderer *>(attached_renderer_)->PostInit();
|
||||
static_cast<OpenGLRenderer *>(attached_renderer_)->init(context);
|
||||
static_cast<OpenGLRenderer *>(attached_renderer_)->post_init();
|
||||
} else {
|
||||
attached_renderer_->Init();
|
||||
attached_renderer_->PostInit();
|
||||
attached_renderer_->init();
|
||||
attached_renderer_->post_init();
|
||||
}
|
||||
}
|
||||
|
||||
void ManagedDisplayWidget::EnableDefaultContextMenu()
|
||||
void ManagedDisplayWidget::enable_default_context_menu()
|
||||
{
|
||||
connect(this, &ManagedDisplayWidget::customContextMenuRequested, this,
|
||||
&ManagedDisplayWidget::ShowDefaultContextMenu);
|
||||
&ManagedDisplayWidget::show_default_context_menu);
|
||||
}
|
||||
|
||||
void ManagedDisplayWidget::ColorProcessorChangedEvent()
|
||||
@@ -314,14 +314,14 @@ void ManagedDisplayWidget::ColorProcessorChangedEvent()
|
||||
update();
|
||||
}
|
||||
|
||||
void ManagedDisplayWidget::makeCurrent()
|
||||
void ManagedDisplayWidget::make_current()
|
||||
{
|
||||
if (!is_backend_neutral_) {
|
||||
static_cast<ManagedDisplayWidgetOpenGL *>(inner_widget_)->makeCurrent();
|
||||
}
|
||||
}
|
||||
|
||||
void ManagedDisplayWidget::doneCurrent()
|
||||
void ManagedDisplayWidget::done_current()
|
||||
{
|
||||
if (!is_backend_neutral_) {
|
||||
static_cast<ManagedDisplayWidgetOpenGL *>(inner_widget_)->doneCurrent();
|
||||
@@ -333,21 +333,21 @@ QPaintDevice *ManagedDisplayWidget::paint_device() const
|
||||
return inner_widget_;
|
||||
}
|
||||
|
||||
void ManagedDisplayWidget::SetInnerMouseTracking(bool e)
|
||||
void ManagedDisplayWidget::set_inner_mouse_tracking(bool e)
|
||||
{
|
||||
if (wrapper_) {
|
||||
wrapper_->setMouseTracking(e);
|
||||
}
|
||||
}
|
||||
|
||||
VideoParams ManagedDisplayWidget::GetViewportParams() const
|
||||
VideoParams ManagedDisplayWidget::get_viewport_params() const
|
||||
{
|
||||
int device_width = width() * devicePixelRatioF();
|
||||
int device_height = height() * devicePixelRatioF();
|
||||
PixelFormat device_format = static_cast<PixelFormat::Format>(
|
||||
OLIVE_CONFIG("OfflinePixelFormat").toInt());
|
||||
OAK_CONFIG("OfflinePixelFormat").toInt());
|
||||
return VideoParams(device_width, device_height, device_format,
|
||||
VideoParams::kInternalChannelCount);
|
||||
VideoParams::k_internal_channel_count);
|
||||
}
|
||||
|
||||
void ManagedDisplayWidget::update()
|
||||
@@ -367,7 +367,7 @@ bool ManagedDisplayWidget::eventFilter(QObject *o, QEvent *e)
|
||||
case QEvent::FocusIn:
|
||||
// HACK: QWindow focus isn't accounted for in QApplication::focusChanged, so we handle it
|
||||
// manually here.
|
||||
PanelManager::instance()->FocusChanged(nullptr, this);
|
||||
PanelManager::instance()->focus_changed(nullptr, this);
|
||||
break;
|
||||
case QEvent::ContextMenu: {
|
||||
QContextMenuEvent *ctx = static_cast<QContextMenuEvent *>(e);
|
||||
@@ -391,15 +391,15 @@ bool ManagedDisplayWidget::eventFilter(QObject *o, QEvent *e)
|
||||
return super::eventFilter(o, e);
|
||||
}
|
||||
|
||||
Menu *ManagedDisplayWidget::GetDisplayMenu(QMenu *parent, bool auto_connect)
|
||||
Menu *ManagedDisplayWidget::get_display_menu(QMenu *parent, bool auto_connect)
|
||||
{
|
||||
QStringList displays = color_manager()->ListAvailableDisplays();
|
||||
QStringList displays = color_manager()->list_available_displays();
|
||||
|
||||
Menu *ocio_display_menu = new Menu(tr("Display"), parent);
|
||||
|
||||
if (auto_connect) {
|
||||
connect(ocio_display_menu, &Menu::triggered, this,
|
||||
&ManagedDisplayWidget::MenuDisplaySelect);
|
||||
&ManagedDisplayWidget::menu_display_select);
|
||||
}
|
||||
|
||||
foreach (const QString &d, displays) {
|
||||
@@ -412,16 +412,16 @@ Menu *ManagedDisplayWidget::GetDisplayMenu(QMenu *parent, bool auto_connect)
|
||||
return ocio_display_menu;
|
||||
}
|
||||
|
||||
Menu *ManagedDisplayWidget::GetViewMenu(QMenu *parent, bool auto_connect)
|
||||
Menu *ManagedDisplayWidget::get_view_menu(QMenu *parent, bool auto_connect)
|
||||
{
|
||||
QStringList views =
|
||||
color_manager()->ListAvailableViews(color_transform_.display());
|
||||
color_manager()->list_available_views(color_transform_.display());
|
||||
|
||||
Menu *ocio_view_menu = new Menu(tr("View"), parent);
|
||||
|
||||
if (auto_connect) {
|
||||
connect(ocio_view_menu, &Menu::triggered, this,
|
||||
&ManagedDisplayWidget::MenuViewSelect);
|
||||
&ManagedDisplayWidget::menu_view_select);
|
||||
}
|
||||
|
||||
foreach (const QString &v, views) {
|
||||
@@ -434,15 +434,15 @@ Menu *ManagedDisplayWidget::GetViewMenu(QMenu *parent, bool auto_connect)
|
||||
return ocio_view_menu;
|
||||
}
|
||||
|
||||
Menu *ManagedDisplayWidget::GetLookMenu(QMenu *parent, bool auto_connect)
|
||||
Menu *ManagedDisplayWidget::get_look_menu(QMenu *parent, bool auto_connect)
|
||||
{
|
||||
QStringList looks = color_manager()->ListAvailableLooks();
|
||||
QStringList looks = color_manager()->list_available_looks();
|
||||
|
||||
Menu *ocio_look_menu = new Menu(tr("Look"), parent);
|
||||
|
||||
if (auto_connect) {
|
||||
connect(ocio_look_menu, &Menu::triggered, this,
|
||||
&ManagedDisplayWidget::MenuLookSelect);
|
||||
&ManagedDisplayWidget::menu_look_select);
|
||||
}
|
||||
|
||||
// Setup "no look" action
|
||||
@@ -462,17 +462,17 @@ Menu *ManagedDisplayWidget::GetLookMenu(QMenu *parent, bool auto_connect)
|
||||
return ocio_look_menu;
|
||||
}
|
||||
|
||||
void ManagedDisplayWidget::SetupColorProcessor()
|
||||
void ManagedDisplayWidget::setup_color_processor()
|
||||
{
|
||||
color_service_ = nullptr;
|
||||
|
||||
if (color_manager_) {
|
||||
// (Re)create color processor
|
||||
try {
|
||||
color_service_ = ColorProcessor::Create(
|
||||
color_manager_, color_manager_->GetReferenceColorSpace(),
|
||||
color_service_ = ColorProcessor::create(
|
||||
color_manager_, color_manager_->get_reference_color_space(),
|
||||
color_transform_);
|
||||
} catch (OCIO::Exception &e) {
|
||||
} catch (ocio::Exception &e) {
|
||||
QMessageBox::critical(
|
||||
this, tr("OpenColorIO Error"),
|
||||
tr("Failed to set color configuration: %1").arg(e.what()),
|
||||
@@ -482,7 +482,7 @@ void ManagedDisplayWidget::SetupColorProcessor()
|
||||
color_service_ = nullptr;
|
||||
}
|
||||
|
||||
emit ColorProcessorChanged(color_service_);
|
||||
emit color_processor_changed(color_service_);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef MANAGEDDISPLAYOBJECT_H
|
||||
#define MANAGEDDISPLAYOBJECT_H
|
||||
#ifndef OAK_MANAGEDDISPLAYOBJECT_H
|
||||
#define OAK_MANAGEDDISPLAYOBJECT_H
|
||||
|
||||
//#define USE_QOPENGLWINDOW
|
||||
|
||||
@@ -53,48 +53,48 @@ public:
|
||||
virtual ~ManagedDisplayWidgetOpenGL() override
|
||||
{
|
||||
if (context()) {
|
||||
DestroyListener();
|
||||
destroy_listener();
|
||||
disconnect(context(), &QOpenGLContext::aboutToBeDestroyed, this,
|
||||
&ManagedDisplayWidgetOpenGL::DestroyListener);
|
||||
&ManagedDisplayWidgetOpenGL::destroy_listener);
|
||||
}
|
||||
}
|
||||
|
||||
signals:
|
||||
// Render signals
|
||||
void OnInit();
|
||||
void OnPaint();
|
||||
void OnDestroy();
|
||||
void on_init();
|
||||
void on_paint();
|
||||
void on_destroy();
|
||||
|
||||
protected:
|
||||
virtual void initializeGL() override
|
||||
{
|
||||
connect(context(), &QOpenGLContext::aboutToBeDestroyed, this,
|
||||
&ManagedDisplayWidgetOpenGL::DestroyListener,
|
||||
&ManagedDisplayWidgetOpenGL::destroy_listener,
|
||||
Qt::DirectConnection);
|
||||
|
||||
emit OnInit();
|
||||
emit on_init();
|
||||
}
|
||||
|
||||
virtual void paintGL() override
|
||||
{
|
||||
emit OnPaint();
|
||||
emit on_paint();
|
||||
}
|
||||
|
||||
private slots:
|
||||
void DestroyListener()
|
||||
void destroy_listener()
|
||||
{
|
||||
makeCurrent();
|
||||
|
||||
emit OnDestroy();
|
||||
emit on_destroy();
|
||||
|
||||
doneCurrent();
|
||||
}
|
||||
};
|
||||
|
||||
#define MANAGEDDISPLAYWIDGET_DEFAULT_DESTRUCTOR_INNER \
|
||||
makeCurrent(); \
|
||||
OnDestroy(); \
|
||||
doneCurrent()
|
||||
make_current(); \
|
||||
on_destroy(); \
|
||||
done_current()
|
||||
#define MANAGEDDISPLAYWIDGET_DEFAULT_DESTRUCTOR(x) \
|
||||
virtual ~x() override \
|
||||
{ \
|
||||
@@ -116,14 +116,14 @@ public:
|
||||
}
|
||||
|
||||
signals:
|
||||
void OnPaint();
|
||||
void on_paint();
|
||||
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent *event) override
|
||||
{
|
||||
QWidget::paintEvent(event);
|
||||
|
||||
emit OnPaint();
|
||||
emit on_paint();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -137,7 +137,7 @@ public:
|
||||
/**
|
||||
* @brief Disconnect a ColorManager (equivalent to ConnectColorManager(nullptr))
|
||||
*/
|
||||
void DisconnectColorManager();
|
||||
void disconnect_color_manager();
|
||||
|
||||
/**
|
||||
* @brief Access currently connected ColorManager (nullptr if none)
|
||||
@@ -147,27 +147,27 @@ public:
|
||||
/**
|
||||
* @brief Get current color transform
|
||||
*/
|
||||
const ColorTransform &GetColorTransform() const;
|
||||
const ColorTransform &get_color_transform() const;
|
||||
|
||||
/**
|
||||
* @brief Get menu that can be used to select the colorspace
|
||||
*/
|
||||
Menu *GetColorSpaceMenu(QMenu *parent, bool auto_connect = true);
|
||||
Menu *get_color_space_menu(QMenu *parent, bool auto_connect = true);
|
||||
|
||||
/**
|
||||
* @brief Get menu that can be used to select the display transform
|
||||
*/
|
||||
Menu *GetDisplayMenu(QMenu *parent, bool auto_connect = true);
|
||||
Menu *get_display_menu(QMenu *parent, bool auto_connect = true);
|
||||
|
||||
/**
|
||||
* @brief Get menu that can be used to select the view transform
|
||||
*/
|
||||
Menu *GetViewMenu(QMenu *parent, bool auto_connect = true);
|
||||
Menu *get_view_menu(QMenu *parent, bool auto_connect = true);
|
||||
|
||||
/**
|
||||
* @brief Get menu that can be used to select the look transform
|
||||
*/
|
||||
Menu *GetLookMenu(QMenu *parent, bool auto_connect = true);
|
||||
Menu *get_look_menu(QMenu *parent, bool auto_connect = true);
|
||||
|
||||
/**
|
||||
* @brief Passes update signal through to inner widget
|
||||
@@ -180,25 +180,25 @@ public slots:
|
||||
/**
|
||||
* @brief Replaces the color transform with a new one
|
||||
*/
|
||||
void SetColorTransform(const ColorTransform &transform);
|
||||
void set_color_transform(const ColorTransform &transform);
|
||||
|
||||
/**
|
||||
* @brief Connect a ColorManager (ColorManagers usually belong to the Project)
|
||||
*/
|
||||
void ConnectColorManager(ColorManager *color_manager);
|
||||
void connect_color_manager(ColorManager *color_manager);
|
||||
|
||||
signals:
|
||||
/**
|
||||
* @brief Emitted when the color processor changes
|
||||
*/
|
||||
void ColorProcessorChanged(ColorProcessorPtr processor);
|
||||
void color_processor_changed(ColorProcessorPtr processor);
|
||||
|
||||
/**
|
||||
* @brief Emitted when a new color manager is connected
|
||||
*/
|
||||
void ColorManagerChanged(ColorManager *color_manager);
|
||||
void color_manager_changed(ColorManager *color_manager);
|
||||
|
||||
void frameSwapped();
|
||||
void frame_swapped();
|
||||
|
||||
protected:
|
||||
/**
|
||||
@@ -209,7 +209,7 @@ protected:
|
||||
/**
|
||||
* @brief Enables a context menu that allows simple access to the DVL pipeline
|
||||
*/
|
||||
void EnableDefaultContextMenu();
|
||||
void enable_default_context_menu();
|
||||
|
||||
/**
|
||||
* @brief Function called whenever the processor changes
|
||||
@@ -223,9 +223,9 @@ protected:
|
||||
return attached_renderer_;
|
||||
}
|
||||
|
||||
void makeCurrent();
|
||||
void make_current();
|
||||
|
||||
void doneCurrent();
|
||||
void done_current();
|
||||
|
||||
#ifdef USE_QOPENGLWINDOW
|
||||
QWindow *
|
||||
@@ -245,46 +245,46 @@ protected:
|
||||
*/
|
||||
QPaintDevice *paint_device() const;
|
||||
|
||||
void SetInnerMouseTracking(bool e);
|
||||
void set_inner_mouse_tracking(bool e);
|
||||
|
||||
bool IsBackendNeutral() const
|
||||
bool is_backend_neutral() const
|
||||
{
|
||||
return is_backend_neutral_;
|
||||
}
|
||||
|
||||
QRect GetInnerRect() const
|
||||
QRect get_inner_rect() const
|
||||
{
|
||||
return wrapper_ ? wrapper_->rect() : QRect();
|
||||
}
|
||||
|
||||
VideoParams GetViewportParams() const;
|
||||
VideoParams get_viewport_params() const;
|
||||
|
||||
protected slots:
|
||||
/**
|
||||
* @brief Called whenever the internal rendering context has been created
|
||||
*/
|
||||
virtual void OnInit();
|
||||
virtual void on_init();
|
||||
|
||||
/**
|
||||
* @brief Called while the internal rendering context is being rendered
|
||||
*/
|
||||
virtual void OnPaint() = 0;
|
||||
virtual void on_paint() = 0;
|
||||
|
||||
/**
|
||||
* @brief Called just before the internal rendering context is destroyed
|
||||
*/
|
||||
virtual void OnDestroy();
|
||||
virtual void on_destroy();
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Call this if this user has selected a different display/view/look to recreate the processor
|
||||
*/
|
||||
void SetupColorProcessor();
|
||||
void setup_color_processor();
|
||||
|
||||
/**
|
||||
* @brief Cleanup function
|
||||
*/
|
||||
void ClearOCIOLutTexture();
|
||||
void clear_ocio_lut_texture();
|
||||
|
||||
/**
|
||||
* @brief Main drawing surface abstraction
|
||||
@@ -322,34 +322,34 @@ private slots:
|
||||
/**
|
||||
* @brief Sets all color settings to the defaults pertaining to this configuration
|
||||
*/
|
||||
void ColorConfigChanged();
|
||||
void color_config_changed();
|
||||
|
||||
/**
|
||||
* @brief The default context menu shown
|
||||
*/
|
||||
void ShowDefaultContextMenu();
|
||||
void show_default_context_menu();
|
||||
|
||||
/**
|
||||
* @brief If GetDisplayMenu() is called with `auto_connect` set to true, it will be connected to this
|
||||
*/
|
||||
void MenuDisplaySelect(QAction *action);
|
||||
void menu_display_select(QAction *action);
|
||||
|
||||
/**
|
||||
* @brief If GetViewMenu() is called with `auto_connect` set to true, it will be connected to this
|
||||
*/
|
||||
void MenuViewSelect(QAction *action);
|
||||
void menu_view_select(QAction *action);
|
||||
|
||||
/**
|
||||
* @brief If GetLookMenu() is called with `auto_connect` set to true, it will be connected to this
|
||||
*/
|
||||
void MenuLookSelect(QAction *action);
|
||||
void menu_look_select(QAction *action);
|
||||
|
||||
/**
|
||||
* @brief If GetColorSpaceMenu() is called with `auto_connect` set to true, it will be connected to this
|
||||
*/
|
||||
void MenuColorspaceSelect(QAction *action);
|
||||
void menu_colorspace_select(QAction *action);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // MANAGEDDISPLAYOBJECT_H
|
||||
#endif // OAK_MANAGEDDISPLAYOBJECT_H
|
||||
|
||||
+12
-12
@@ -30,29 +30,29 @@ Menu::Menu(QMenuBar *bar)
|
||||
{
|
||||
bar->addMenu(this);
|
||||
|
||||
Init();
|
||||
init();
|
||||
}
|
||||
|
||||
Menu::Menu(Menu *menu)
|
||||
{
|
||||
menu->addMenu(this);
|
||||
|
||||
Init();
|
||||
init();
|
||||
}
|
||||
|
||||
Menu::Menu(QWidget *parent)
|
||||
: QMenu(parent)
|
||||
{
|
||||
Init();
|
||||
init();
|
||||
}
|
||||
|
||||
Menu::Menu(const QString &s, QWidget *parent)
|
||||
: QMenu(s, parent)
|
||||
{
|
||||
Init();
|
||||
init();
|
||||
}
|
||||
|
||||
QAction *Menu::AddActionWithData(const QString &text, const QVariant &d,
|
||||
QAction *Menu::add_action_with_data(const QString &text, const QVariant &d,
|
||||
const QVariant &compare)
|
||||
{
|
||||
QAction *a = addAction(text);
|
||||
@@ -64,14 +64,14 @@ QAction *Menu::AddActionWithData(const QString &text, const QVariant &d,
|
||||
return a;
|
||||
}
|
||||
|
||||
QAction *Menu::InsertAlphabetically(const QString &s)
|
||||
QAction *Menu::insert_alphabetically(const QString &s)
|
||||
{
|
||||
QAction *action = new QAction(s, this);
|
||||
InsertAlphabetically(action);
|
||||
insert_alphabetically(action);
|
||||
return action;
|
||||
}
|
||||
|
||||
void Menu::InsertAlphabetically(QAction *entry)
|
||||
void Menu::insert_alphabetically(QAction *entry)
|
||||
{
|
||||
QList<QAction *> actions = this->actions();
|
||||
|
||||
@@ -85,12 +85,12 @@ void Menu::InsertAlphabetically(QAction *entry)
|
||||
addAction(entry);
|
||||
}
|
||||
|
||||
void Menu::InsertAlphabetically(Menu *menu)
|
||||
void Menu::insert_alphabetically(Menu *menu)
|
||||
{
|
||||
InsertAlphabetically(menu->menuAction());
|
||||
insert_alphabetically(menu->menuAction());
|
||||
}
|
||||
|
||||
void Menu::ConformItem(QAction *a, const QString &id, const QKeySequence &key)
|
||||
void Menu::conform_item(QAction *a, const QString &id, const QKeySequence &key)
|
||||
{
|
||||
a->setProperty("id", id);
|
||||
|
||||
@@ -103,7 +103,7 @@ void Menu::ConformItem(QAction *a, const QString &id, const QKeySequence &key)
|
||||
}
|
||||
}
|
||||
|
||||
void Menu::Init()
|
||||
void Menu::init()
|
||||
{
|
||||
// HACK: Disables embossing on disabled text for a slightly nicer UI
|
||||
QPalette p = palette();
|
||||
|
||||
+19
-19
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef WIDGETMENU_H
|
||||
#define WIDGETMENU_H
|
||||
#ifndef OAK_WIDGETMENU_H
|
||||
#define OAK_WIDGETMENU_H
|
||||
|
||||
#include <QMenuBar>
|
||||
#include <QMenu>
|
||||
@@ -63,8 +63,8 @@ public:
|
||||
{
|
||||
bar->addMenu(this);
|
||||
|
||||
Init();
|
||||
ConnectAboutToShow(receiver, member);
|
||||
init();
|
||||
connect_about_to_show(receiver, member);
|
||||
}
|
||||
|
||||
Menu(Menu *menu);
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
{
|
||||
menu->addMenu(this);
|
||||
|
||||
Init();
|
||||
init();
|
||||
ConnectAboutToShow(receiver, member);
|
||||
}
|
||||
|
||||
@@ -121,23 +121,23 @@ public:
|
||||
* The QAction that was created and added to this Menu
|
||||
*/
|
||||
QAction *
|
||||
AddItem(const QString &id,
|
||||
add_item(const QString &id,
|
||||
const typename QtPrivate::FunctionPointer<Func>::Object *receiver,
|
||||
Func member, const QKeySequence &key = QKeySequence())
|
||||
{
|
||||
QAction *a = CreateItem(this, id, receiver, member, key);
|
||||
QAction *a = create_item(this, id, receiver, member, key);
|
||||
|
||||
addAction(a);
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
QAction *AddActionWithData(const QString &text, const QVariant &d,
|
||||
QAction *add_action_with_data(const QString &text, const QVariant &d,
|
||||
const QVariant &compare);
|
||||
|
||||
QAction *InsertAlphabetically(const QString &s);
|
||||
void InsertAlphabetically(QAction *entry);
|
||||
void InsertAlphabetically(Menu *menu);
|
||||
QAction *insert_alphabetically(const QString &s);
|
||||
void insert_alphabetically(QAction *entry);
|
||||
void insert_alphabetically(Menu *menu);
|
||||
|
||||
template <typename Func>
|
||||
/**
|
||||
@@ -167,14 +167,14 @@ public:
|
||||
*
|
||||
* The QAction that was created and added to this Menu
|
||||
*/
|
||||
static QAction *CreateItem(
|
||||
static QAction *create_item(
|
||||
QObject *parent, const QString &id,
|
||||
const typename QtPrivate::FunctionPointer<Func>::Object *receiver,
|
||||
Func member, const QKeySequence &key = QKeySequence())
|
||||
{
|
||||
QAction *a = new QAction(parent);
|
||||
|
||||
ConformItem(a, id, receiver, member, key);
|
||||
conform_item(a, id, receiver, member, key);
|
||||
|
||||
return a;
|
||||
}
|
||||
@@ -206,24 +206,24 @@ public:
|
||||
*
|
||||
* Default keyboard sequence
|
||||
*/
|
||||
static void ConformItem(
|
||||
static void conform_item(
|
||||
QAction *a, const QString &id,
|
||||
const typename QtPrivate::FunctionPointer<Func>::Object *receiver,
|
||||
Func member, const QKeySequence &key = QKeySequence())
|
||||
{
|
||||
ConformItem(a, id, key);
|
||||
conform_item(a, id, key);
|
||||
|
||||
connect(a, &QAction::triggered, receiver, member);
|
||||
}
|
||||
|
||||
static void ConformItem(QAction *a, const QString &id,
|
||||
static void conform_item(QAction *a, const QString &id,
|
||||
const QKeySequence &key = QKeySequence());
|
||||
|
||||
private:
|
||||
void Init();
|
||||
void init();
|
||||
|
||||
template <typename Func>
|
||||
void ConnectAboutToShow(
|
||||
void connect_about_to_show(
|
||||
const typename QtPrivate::FunctionPointer<Func>::Object *receiver,
|
||||
Func member)
|
||||
{
|
||||
@@ -233,4 +233,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // WIDGETMENU_H
|
||||
#endif // OAK_WIDGETMENU_H
|
||||
|
||||
+129
-129
@@ -36,115 +36,115 @@ MenuShared *MenuShared::instance_ = nullptr;
|
||||
MenuShared::MenuShared()
|
||||
{
|
||||
// "New" menu shared items
|
||||
new_project_item_ = Menu::CreateItem(this, "newproj", Core::instance(),
|
||||
&Core::CreateNewProject, tr("Ctrl+N"));
|
||||
new_sequence_item_ = Menu::CreateItem(this, "newseq", Core::instance(),
|
||||
&Core::CreateNewSequence,
|
||||
new_project_item_ = Menu::create_item(this, "newproj", Core::instance(),
|
||||
&Core::create_new_project, tr("Ctrl+N"));
|
||||
new_sequence_item_ = Menu::create_item(this, "newseq", Core::instance(),
|
||||
&Core::create_new_sequence,
|
||||
tr("Ctrl+Shift+N"));
|
||||
new_folder_item_ = Menu::CreateItem(this, "newfolder", Core::instance(),
|
||||
&Core::CreateNewFolder);
|
||||
new_folder_item_ = Menu::create_item(this, "newfolder", Core::instance(),
|
||||
&Core::create_new_folder);
|
||||
|
||||
// "Edit" menu shared items
|
||||
edit_cut_item_ = Menu::CreateItem(this, "cut", this,
|
||||
&MenuShared::CutTriggered, tr("Ctrl+X"));
|
||||
edit_copy_item_ = Menu::CreateItem(
|
||||
this, "copy", this, &MenuShared::CopyTriggered, tr("Ctrl+C"));
|
||||
edit_paste_item_ = Menu::CreateItem(
|
||||
this, "paste", this, &MenuShared::PasteTriggered, tr("Ctrl+V"));
|
||||
edit_cut_item_ = Menu::create_item(this, "cut", this,
|
||||
&MenuShared::cut_triggered, tr("Ctrl+X"));
|
||||
edit_copy_item_ = Menu::create_item(
|
||||
this, "copy", this, &MenuShared::copy_triggered, tr("Ctrl+C"));
|
||||
edit_paste_item_ = Menu::create_item(
|
||||
this, "paste", this, &MenuShared::paste_triggered, tr("Ctrl+V"));
|
||||
edit_paste_insert_item_ =
|
||||
Menu::CreateItem(this, "pasteinsert", this,
|
||||
&MenuShared::PasteInsertTriggered, tr("Ctrl+Shift+V"));
|
||||
edit_duplicate_item_ = Menu::CreateItem(
|
||||
this, "duplicate", this, &MenuShared::DuplicateTriggered, tr("Ctrl+D"));
|
||||
edit_rename_item_ = Menu::CreateItem(
|
||||
this, "rename", this, &MenuShared::RenameSelectedTriggered, tr("F2"));
|
||||
edit_delete_item_ = Menu::CreateItem(
|
||||
this, "delete", this, &MenuShared::DeleteSelectedTriggered, tr("Del"));
|
||||
Menu::create_item(this, "pasteinsert", this,
|
||||
&MenuShared::paste_insert_triggered, tr("Ctrl+Shift+V"));
|
||||
edit_duplicate_item_ = Menu::create_item(
|
||||
this, "duplicate", this, &MenuShared::duplicate_triggered, tr("Ctrl+D"));
|
||||
edit_rename_item_ = Menu::create_item(
|
||||
this, "rename", this, &MenuShared::rename_selected_triggered, tr("F2"));
|
||||
edit_delete_item_ = Menu::create_item(
|
||||
this, "delete", this, &MenuShared::delete_selected_triggered, tr("Del"));
|
||||
edit_ripple_delete_item_ =
|
||||
Menu::CreateItem(this, "rippledelete", this,
|
||||
&MenuShared::RippleDeleteTriggered, tr("Shift+Del"));
|
||||
edit_split_item_ = Menu::CreateItem(this, "split", this,
|
||||
&MenuShared::SplitAtPlayheadTriggered,
|
||||
Menu::create_item(this, "rippledelete", this,
|
||||
&MenuShared::ripple_delete_triggered, tr("Shift+Del"));
|
||||
edit_split_item_ = Menu::create_item(this, "split", this,
|
||||
&MenuShared::split_at_playhead_triggered,
|
||||
tr("Ctrl+K"));
|
||||
edit_speedduration_item_ =
|
||||
Menu::CreateItem(this, "speeddur", this,
|
||||
&MenuShared::SpeedDurationTriggered, tr("Ctrl+R"));
|
||||
Menu::create_item(this, "speeddur", this,
|
||||
&MenuShared::speed_duration_triggered, tr("Ctrl+R"));
|
||||
|
||||
// List of addable items
|
||||
for (int i = 0; i < Tool::kAddableCount; i++) {
|
||||
for (int i = 0; i < Tool::k_addable_count; i++) {
|
||||
Tool::AddableObject t = static_cast<Tool::AddableObject>(i);
|
||||
QAction *a = Menu::CreateItem(
|
||||
this, QStringLiteral("add:%1").arg(Tool::GetAddableObjectID(t)),
|
||||
this, &MenuShared::AddableItemTriggered);
|
||||
QAction *a = Menu::create_item(
|
||||
this, QStringLiteral("add:%1").arg(Tool::get_addable_object_id(t)),
|
||||
this, &MenuShared::addable_item_triggered);
|
||||
a->setData(t);
|
||||
addable_items_.append(a);
|
||||
}
|
||||
|
||||
// "In/Out" menu shared items
|
||||
inout_set_in_item_ = Menu::CreateItem(this, "setinpoint", this,
|
||||
&MenuShared::SetInTriggered, tr("I"));
|
||||
inout_set_out_item_ = Menu::CreateItem(
|
||||
this, "setoutpoint", this, &MenuShared::SetOutTriggered, tr("O"));
|
||||
inout_set_in_item_ = Menu::create_item(this, "setinpoint", this,
|
||||
&MenuShared::set_in_triggered, tr("I"));
|
||||
inout_set_out_item_ = Menu::create_item(
|
||||
this, "setoutpoint", this, &MenuShared::set_out_triggered, tr("O"));
|
||||
inout_reset_in_item_ =
|
||||
Menu::CreateItem(this, "resetin", this, &MenuShared::ResetInTriggered);
|
||||
inout_reset_out_item_ = Menu::CreateItem(this, "resetout", this,
|
||||
&MenuShared::ResetOutTriggered);
|
||||
inout_clear_inout_item_ = Menu::CreateItem(
|
||||
this, "clearinout", this, &MenuShared::ClearInOutTriggered, tr("G"));
|
||||
Menu::create_item(this, "resetin", this, &MenuShared::reset_in_triggered);
|
||||
inout_reset_out_item_ = Menu::create_item(this, "resetout", this,
|
||||
&MenuShared::reset_out_triggered);
|
||||
inout_clear_inout_item_ = Menu::create_item(
|
||||
this, "clearinout", this, &MenuShared::clear_in_out_triggered, tr("G"));
|
||||
|
||||
// "Clip Edit" menu shared items
|
||||
clip_add_default_transition_item_ = Menu::CreateItem(
|
||||
this, "deftransition", this, &MenuShared::DefaultTransitionTriggered,
|
||||
clip_add_default_transition_item_ = Menu::create_item(
|
||||
this, "deftransition", this, &MenuShared::default_transition_triggered,
|
||||
tr("Ctrl+Shift+D"));
|
||||
clip_link_unlink_item_ = Menu::CreateItem(this, "linkunlink", this,
|
||||
&MenuShared::ToggleLinksTriggered,
|
||||
clip_link_unlink_item_ = Menu::create_item(this, "linkunlink", this,
|
||||
&MenuShared::toggle_links_triggered,
|
||||
tr("Ctrl+L"));
|
||||
clip_enable_disable_item_ =
|
||||
Menu::CreateItem(this, "enabledisable", this,
|
||||
&MenuShared::EnableDisableTriggered, tr("Shift+E"));
|
||||
Menu::create_item(this, "enabledisable", this,
|
||||
&MenuShared::enable_disable_triggered, tr("Shift+E"));
|
||||
clip_nest_item_ =
|
||||
Menu::CreateItem(this, "nest", this, &MenuShared::NestTriggered);
|
||||
Menu::create_item(this, "nest", this, &MenuShared::nest_triggered);
|
||||
|
||||
// TimeRuler menu shared items
|
||||
frame_view_mode_group_ = new QActionGroup(this);
|
||||
|
||||
view_timecode_view_dropframe_item_ = Menu::CreateItem(
|
||||
this, "modedropframe", this, &MenuShared::TimecodeDisplayTriggered);
|
||||
view_timecode_view_dropframe_item_->setData(Timecode::kTimecodeDropFrame);
|
||||
view_timecode_view_dropframe_item_ = Menu::create_item(
|
||||
this, "modedropframe", this, &MenuShared::timecode_display_triggered);
|
||||
view_timecode_view_dropframe_item_->setData(Timecode::k_timecode_drop_frame);
|
||||
view_timecode_view_dropframe_item_->setCheckable(true);
|
||||
frame_view_mode_group_->addAction(view_timecode_view_dropframe_item_);
|
||||
|
||||
view_timecode_view_nondropframe_item_ = Menu::CreateItem(
|
||||
this, "modenondropframe", this, &MenuShared::TimecodeDisplayTriggered);
|
||||
view_timecode_view_nondropframe_item_ = Menu::create_item(
|
||||
this, "modenondropframe", this, &MenuShared::timecode_display_triggered);
|
||||
view_timecode_view_nondropframe_item_->setData(
|
||||
Timecode::kTimecodeNonDropFrame);
|
||||
Timecode::k_timecode_non_drop_frame);
|
||||
view_timecode_view_nondropframe_item_->setCheckable(true);
|
||||
frame_view_mode_group_->addAction(view_timecode_view_nondropframe_item_);
|
||||
|
||||
view_timecode_view_seconds_item_ = Menu::CreateItem(
|
||||
this, "modeseconds", this, &MenuShared::TimecodeDisplayTriggered);
|
||||
view_timecode_view_seconds_item_->setData(Timecode::kTimecodeSeconds);
|
||||
view_timecode_view_seconds_item_ = Menu::create_item(
|
||||
this, "modeseconds", this, &MenuShared::timecode_display_triggered);
|
||||
view_timecode_view_seconds_item_->setData(Timecode::k_timecode_seconds);
|
||||
view_timecode_view_seconds_item_->setCheckable(true);
|
||||
frame_view_mode_group_->addAction(view_timecode_view_seconds_item_);
|
||||
|
||||
view_timecode_view_frames_item_ = Menu::CreateItem(
|
||||
this, "modeframes", this, &MenuShared::TimecodeDisplayTriggered);
|
||||
view_timecode_view_frames_item_->setData(Timecode::kFrames);
|
||||
view_timecode_view_frames_item_ = Menu::create_item(
|
||||
this, "modeframes", this, &MenuShared::timecode_display_triggered);
|
||||
view_timecode_view_frames_item_->setData(Timecode::k_frames);
|
||||
view_timecode_view_frames_item_->setCheckable(true);
|
||||
frame_view_mode_group_->addAction(view_timecode_view_frames_item_);
|
||||
|
||||
view_timecode_view_milliseconds_item_ = Menu::CreateItem(
|
||||
this, "milliseconds", this, &MenuShared::TimecodeDisplayTriggered);
|
||||
view_timecode_view_milliseconds_item_->setData(Timecode::kMilliseconds);
|
||||
view_timecode_view_milliseconds_item_ = Menu::create_item(
|
||||
this, "milliseconds", this, &MenuShared::timecode_display_triggered);
|
||||
view_timecode_view_milliseconds_item_->setData(Timecode::k_milliseconds);
|
||||
view_timecode_view_milliseconds_item_->setCheckable(true);
|
||||
frame_view_mode_group_->addAction(view_timecode_view_milliseconds_item_);
|
||||
|
||||
// Color coding menu items
|
||||
color_coding_menu_ = new ColorLabelMenu();
|
||||
connect(color_coding_menu_, &ColorLabelMenu::ColorSelected, this,
|
||||
&MenuShared::ColorLabelTriggered);
|
||||
connect(color_coding_menu_, &ColorLabelMenu::color_selected, this,
|
||||
&MenuShared::color_label_triggered);
|
||||
|
||||
Retranslate();
|
||||
retranslate();
|
||||
}
|
||||
|
||||
MenuShared::~MenuShared()
|
||||
@@ -152,17 +152,17 @@ MenuShared::~MenuShared()
|
||||
delete color_coding_menu_;
|
||||
}
|
||||
|
||||
void MenuShared::CreateInstance()
|
||||
void MenuShared::create_instance()
|
||||
{
|
||||
instance_ = new MenuShared();
|
||||
}
|
||||
|
||||
void MenuShared::DestroyInstance()
|
||||
void MenuShared::destroy_instance()
|
||||
{
|
||||
delete instance_;
|
||||
}
|
||||
|
||||
void MenuShared::AddItemsForNewMenu(Menu *m)
|
||||
void MenuShared::add_items_for_new_menu(Menu *m)
|
||||
{
|
||||
m->addAction(new_project_item_);
|
||||
m->addSeparator();
|
||||
@@ -170,7 +170,7 @@ void MenuShared::AddItemsForNewMenu(Menu *m)
|
||||
m->addAction(new_folder_item_);
|
||||
}
|
||||
|
||||
void MenuShared::AddItemsForEditMenu(Menu *m, bool for_clips)
|
||||
void MenuShared::add_items_for_edit_menu(Menu *m, bool for_clips)
|
||||
{
|
||||
m->addAction(Core::instance()->undo_stack()->GetUndoAction());
|
||||
m->addAction(Core::instance()->undo_stack()->GetRedoAction());
|
||||
@@ -199,16 +199,16 @@ void MenuShared::AddItemsForEditMenu(Menu *m, bool for_clips)
|
||||
}
|
||||
}
|
||||
|
||||
void MenuShared::AddItemsForAddableObjectsMenu(Menu *m)
|
||||
void MenuShared::add_items_for_addable_objects_menu(Menu *m)
|
||||
{
|
||||
for (QAction *a : qAsConst(addable_items_)) {
|
||||
a->setChecked((a->data().toInt() ==
|
||||
Core::instance()->GetSelectedAddableObject()));
|
||||
Core::instance()->get_selected_addable_object()));
|
||||
m->addAction(a);
|
||||
}
|
||||
}
|
||||
|
||||
void MenuShared::AddItemsForInOutMenu(Menu *m)
|
||||
void MenuShared::add_items_for_in_out_menu(Menu *m)
|
||||
{
|
||||
m->addAction(inout_set_in_item_);
|
||||
m->addAction(inout_set_out_item_);
|
||||
@@ -218,12 +218,12 @@ void MenuShared::AddItemsForInOutMenu(Menu *m)
|
||||
m->addAction(inout_clear_inout_item_);
|
||||
}
|
||||
|
||||
void MenuShared::AddColorCodingMenu(Menu *m)
|
||||
void MenuShared::add_color_coding_menu(Menu *m)
|
||||
{
|
||||
m->addMenu(color_coding_menu_);
|
||||
}
|
||||
|
||||
void MenuShared::AddItemsForClipEditMenu(Menu *m)
|
||||
void MenuShared::add_items_for_clip_edit_menu(Menu *m)
|
||||
{
|
||||
m->addAction(clip_add_default_transition_item_);
|
||||
m->addAction(clip_link_unlink_item_);
|
||||
@@ -231,7 +231,7 @@ void MenuShared::AddItemsForClipEditMenu(Menu *m)
|
||||
m->addAction(clip_nest_item_);
|
||||
}
|
||||
|
||||
void MenuShared::AddItemsForTimeRulerMenu(Menu *m)
|
||||
void MenuShared::add_items_for_time_ruler_menu(Menu *m)
|
||||
{
|
||||
m->addAction(view_timecode_view_dropframe_item_);
|
||||
m->addAction(view_timecode_view_nondropframe_item_);
|
||||
@@ -240,21 +240,21 @@ void MenuShared::AddItemsForTimeRulerMenu(Menu *m)
|
||||
m->addAction(view_timecode_view_milliseconds_item_);
|
||||
}
|
||||
|
||||
void MenuShared::AboutToShowTimeRulerActions(const rational &timebase)
|
||||
void MenuShared::about_to_show_time_ruler_actions(const Rational &timebase)
|
||||
{
|
||||
QList<QAction *> timecode_display_actions =
|
||||
frame_view_mode_group_->actions();
|
||||
Timecode::Display current_timecode_display =
|
||||
Core::instance()->GetTimecodeDisplay();
|
||||
Core::instance()->get_timecode_display();
|
||||
|
||||
// Only show the drop-frame option if the timebase is drop-frame
|
||||
view_timecode_view_dropframe_item_->setVisible(
|
||||
!timebase.isNull() && Timecode::timebase_is_drop_frame(timebase));
|
||||
|
||||
if (!view_timecode_view_dropframe_item_->isVisible() &&
|
||||
current_timecode_display == Timecode::kTimecodeDropFrame) {
|
||||
current_timecode_display == Timecode::k_timecode_drop_frame) {
|
||||
// If the current setting is drop-frame, correct to non-drop frame
|
||||
current_timecode_display = Timecode::kTimecodeNonDropFrame;
|
||||
current_timecode_display = Timecode::k_timecode_non_drop_frame;
|
||||
}
|
||||
|
||||
foreach (QAction *a, timecode_display_actions) {
|
||||
@@ -270,106 +270,106 @@ MenuShared *MenuShared::instance()
|
||||
return instance_;
|
||||
}
|
||||
|
||||
void MenuShared::SplitAtPlayheadTriggered()
|
||||
void MenuShared::split_at_playhead_triggered()
|
||||
{
|
||||
TimelinePanel *timeline =
|
||||
PanelManager::instance()->MostRecentlyFocused<TimelinePanel>();
|
||||
PanelManager::instance()->most_recently_focused<TimelinePanel>();
|
||||
|
||||
if (timeline != nullptr) {
|
||||
timeline->SplitAtPlayhead();
|
||||
timeline->split_at_playhead();
|
||||
}
|
||||
}
|
||||
|
||||
void MenuShared::DeleteSelectedTriggered()
|
||||
void MenuShared::delete_selected_triggered()
|
||||
{
|
||||
PanelManager::instance()->CurrentlyFocused()->DeleteSelected();
|
||||
PanelManager::instance()->currently_focused()->delete_selected();
|
||||
}
|
||||
|
||||
void MenuShared::RippleDeleteTriggered()
|
||||
void MenuShared::ripple_delete_triggered()
|
||||
{
|
||||
PanelManager::instance()->CurrentlyFocused()->RippleDelete();
|
||||
PanelManager::instance()->currently_focused()->ripple_delete();
|
||||
}
|
||||
|
||||
void MenuShared::SetInTriggered()
|
||||
void MenuShared::set_in_triggered()
|
||||
{
|
||||
PanelManager::instance()->CurrentlyFocused()->SetIn();
|
||||
PanelManager::instance()->currently_focused()->set_in();
|
||||
}
|
||||
|
||||
void MenuShared::SetOutTriggered()
|
||||
void MenuShared::set_out_triggered()
|
||||
{
|
||||
PanelManager::instance()->CurrentlyFocused()->SetOut();
|
||||
PanelManager::instance()->currently_focused()->set_out();
|
||||
}
|
||||
|
||||
void MenuShared::ResetInTriggered()
|
||||
void MenuShared::reset_in_triggered()
|
||||
{
|
||||
PanelManager::instance()->CurrentlyFocused()->ResetIn();
|
||||
PanelManager::instance()->currently_focused()->reset_in();
|
||||
}
|
||||
|
||||
void MenuShared::ResetOutTriggered()
|
||||
void MenuShared::reset_out_triggered()
|
||||
{
|
||||
PanelManager::instance()->CurrentlyFocused()->ResetOut();
|
||||
PanelManager::instance()->currently_focused()->reset_out();
|
||||
}
|
||||
|
||||
void MenuShared::ClearInOutTriggered()
|
||||
void MenuShared::clear_in_out_triggered()
|
||||
{
|
||||
PanelManager::instance()->CurrentlyFocused()->ClearInOut();
|
||||
PanelManager::instance()->currently_focused()->clear_in_out();
|
||||
}
|
||||
|
||||
void MenuShared::ToggleLinksTriggered()
|
||||
void MenuShared::toggle_links_triggered()
|
||||
{
|
||||
PanelManager::instance()->CurrentlyFocused()->ToggleLinks();
|
||||
PanelManager::instance()->currently_focused()->toggle_links();
|
||||
}
|
||||
|
||||
void MenuShared::CutTriggered()
|
||||
void MenuShared::cut_triggered()
|
||||
{
|
||||
PanelManager::instance()->CurrentlyFocused()->CutSelected();
|
||||
PanelManager::instance()->currently_focused()->cut_selected();
|
||||
}
|
||||
|
||||
void MenuShared::CopyTriggered()
|
||||
void MenuShared::copy_triggered()
|
||||
{
|
||||
PanelManager::instance()->CurrentlyFocused()->CopySelected();
|
||||
PanelManager::instance()->currently_focused()->copy_selected();
|
||||
}
|
||||
|
||||
void MenuShared::PasteTriggered()
|
||||
void MenuShared::paste_triggered()
|
||||
{
|
||||
PanelManager::instance()->CurrentlyFocused()->Paste();
|
||||
PanelManager::instance()->currently_focused()->paste();
|
||||
}
|
||||
|
||||
void MenuShared::PasteInsertTriggered()
|
||||
void MenuShared::paste_insert_triggered()
|
||||
{
|
||||
PanelManager::instance()->CurrentlyFocused()->PasteInsert();
|
||||
PanelManager::instance()->currently_focused()->paste_insert();
|
||||
}
|
||||
|
||||
void MenuShared::DuplicateTriggered()
|
||||
void MenuShared::duplicate_triggered()
|
||||
{
|
||||
PanelManager::instance()->CurrentlyFocused()->Duplicate();
|
||||
PanelManager::instance()->currently_focused()->duplicate();
|
||||
}
|
||||
|
||||
void MenuShared::RenameSelectedTriggered()
|
||||
void MenuShared::rename_selected_triggered()
|
||||
{
|
||||
PanelManager::instance()->CurrentlyFocused()->RenameSelected();
|
||||
PanelManager::instance()->currently_focused()->rename_selected();
|
||||
}
|
||||
|
||||
void MenuShared::EnableDisableTriggered()
|
||||
void MenuShared::enable_disable_triggered()
|
||||
{
|
||||
PanelManager::instance()->CurrentlyFocused()->ToggleSelectedEnabled();
|
||||
PanelManager::instance()->currently_focused()->toggle_selected_enabled();
|
||||
}
|
||||
|
||||
void MenuShared::NestTriggered()
|
||||
void MenuShared::nest_triggered()
|
||||
{
|
||||
PanelManager::instance()
|
||||
->MostRecentlyFocused<TimelinePanel>()
|
||||
->NestSelectedClips();
|
||||
->most_recently_focused<TimelinePanel>()
|
||||
->nest_selected_clips();
|
||||
}
|
||||
|
||||
void MenuShared::DefaultTransitionTriggered()
|
||||
void MenuShared::default_transition_triggered()
|
||||
{
|
||||
PanelManager::instance()
|
||||
->MostRecentlyFocused<TimelinePanel>()
|
||||
->AddDefaultTransitionsToSelected();
|
||||
->most_recently_focused<TimelinePanel>()
|
||||
->add_default_transitions_to_selected();
|
||||
}
|
||||
|
||||
void MenuShared::TimecodeDisplayTriggered()
|
||||
void MenuShared::timecode_display_triggered()
|
||||
{
|
||||
// Assume the sender is a QAction
|
||||
QAction *action = static_cast<QAction *>(sender());
|
||||
@@ -379,33 +379,33 @@ void MenuShared::TimecodeDisplayTriggered()
|
||||
static_cast<Timecode::Display>(action->data().toInt());
|
||||
|
||||
// Set the current display mode
|
||||
Core::instance()->SetTimecodeDisplay(display);
|
||||
Core::instance()->set_timecode_display(display);
|
||||
}
|
||||
|
||||
void MenuShared::ColorLabelTriggered(int color_index)
|
||||
void MenuShared::color_label_triggered(int color_index)
|
||||
{
|
||||
PanelManager::instance()->CurrentlyFocused()->SetColorLabel(color_index);
|
||||
PanelManager::instance()->currently_focused()->set_color_label(color_index);
|
||||
}
|
||||
|
||||
void MenuShared::SpeedDurationTriggered()
|
||||
void MenuShared::speed_duration_triggered()
|
||||
{
|
||||
TimelinePanel *timeline =
|
||||
PanelManager::instance()->MostRecentlyFocused<TimelinePanel>();
|
||||
PanelManager::instance()->most_recently_focused<TimelinePanel>();
|
||||
|
||||
if (timeline) {
|
||||
timeline->ShowSpeedDurationDialogForSelectedClips();
|
||||
timeline->show_speed_duration_dialog_for_selected_clips();
|
||||
}
|
||||
}
|
||||
|
||||
void MenuShared::AddableItemTriggered()
|
||||
void MenuShared::addable_item_triggered()
|
||||
{
|
||||
QAction *a = static_cast<QAction *>(sender());
|
||||
Tool::AddableObject i = static_cast<Tool::AddableObject>(a->data().toInt());
|
||||
Core::instance()->SetTool(Tool::kAdd);
|
||||
Core::instance()->SetSelectedAddableObject(i);
|
||||
Core::instance()->set_tool(Tool::k_add);
|
||||
Core::instance()->set_selected_addable_object(i);
|
||||
}
|
||||
|
||||
void MenuShared::Retranslate()
|
||||
void MenuShared::retranslate()
|
||||
{
|
||||
// "New" menu shared items
|
||||
new_project_item_->setText(tr("&Project"));
|
||||
@@ -425,7 +425,7 @@ void MenuShared::Retranslate()
|
||||
edit_speedduration_item_->setText(tr("Speed/Duration"));
|
||||
|
||||
for (QAction *a : qAsConst(addable_items_)) {
|
||||
a->setText(Tool::GetAddableObjectName(
|
||||
a->setText(Tool::get_addable_object_name(
|
||||
static_cast<Tool::AddableObject>(a->data().toInt())));
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef MENUSHARED_H
|
||||
#define MENUSHARED_H
|
||||
#ifndef OAK_MENUSHARED_H
|
||||
#define OAK_MENUSHARED_H
|
||||
|
||||
#include <olive/core/core.h>
|
||||
#include "widget/colorlabelmenu/colorlabelmenu.h"
|
||||
@@ -40,20 +40,20 @@ public:
|
||||
MenuShared();
|
||||
virtual ~MenuShared() override;
|
||||
|
||||
static void CreateInstance();
|
||||
static void DestroyInstance();
|
||||
static void create_instance();
|
||||
static void destroy_instance();
|
||||
|
||||
void Retranslate();
|
||||
void retranslate();
|
||||
|
||||
void AddItemsForNewMenu(Menu *m);
|
||||
void AddItemsForEditMenu(Menu *m, bool for_clips);
|
||||
void AddItemsForAddableObjectsMenu(Menu *m);
|
||||
void AddItemsForInOutMenu(Menu *m);
|
||||
void AddColorCodingMenu(Menu *m);
|
||||
void AddItemsForClipEditMenu(Menu *m);
|
||||
void AddItemsForTimeRulerMenu(Menu *m);
|
||||
void add_items_for_new_menu(Menu *m);
|
||||
void add_items_for_edit_menu(Menu *m, bool for_clips);
|
||||
void add_items_for_addable_objects_menu(Menu *m);
|
||||
void add_items_for_in_out_menu(Menu *m);
|
||||
void add_color_coding_menu(Menu *m);
|
||||
void add_items_for_clip_edit_menu(Menu *m);
|
||||
void add_items_for_time_ruler_menu(Menu *m);
|
||||
|
||||
void AboutToShowTimeRulerActions(const rational &timebase);
|
||||
void about_to_show_time_ruler_actions(const Rational &timebase);
|
||||
|
||||
static MenuShared *instance();
|
||||
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
}
|
||||
|
||||
public slots:
|
||||
void DeleteSelectedTriggered();
|
||||
void delete_selected_triggered();
|
||||
|
||||
private:
|
||||
// "New" menu shared items
|
||||
@@ -113,39 +113,39 @@ private:
|
||||
static MenuShared *instance_;
|
||||
|
||||
private slots:
|
||||
void SplitAtPlayheadTriggered();
|
||||
void split_at_playhead_triggered();
|
||||
|
||||
void RippleDeleteTriggered();
|
||||
void ripple_delete_triggered();
|
||||
|
||||
void SetInTriggered();
|
||||
void set_in_triggered();
|
||||
|
||||
void SetOutTriggered();
|
||||
void set_out_triggered();
|
||||
|
||||
void ResetInTriggered();
|
||||
void reset_in_triggered();
|
||||
|
||||
void ResetOutTriggered();
|
||||
void reset_out_triggered();
|
||||
|
||||
void ClearInOutTriggered();
|
||||
void clear_in_out_triggered();
|
||||
|
||||
void ToggleLinksTriggered();
|
||||
void toggle_links_triggered();
|
||||
|
||||
void CutTriggered();
|
||||
void cut_triggered();
|
||||
|
||||
void CopyTriggered();
|
||||
void copy_triggered();
|
||||
|
||||
void PasteTriggered();
|
||||
void paste_triggered();
|
||||
|
||||
void PasteInsertTriggered();
|
||||
void paste_insert_triggered();
|
||||
|
||||
void DuplicateTriggered();
|
||||
void duplicate_triggered();
|
||||
|
||||
void RenameSelectedTriggered();
|
||||
void rename_selected_triggered();
|
||||
|
||||
void EnableDisableTriggered();
|
||||
void enable_disable_triggered();
|
||||
|
||||
void NestTriggered();
|
||||
void nest_triggered();
|
||||
|
||||
void DefaultTransitionTriggered();
|
||||
void default_transition_triggered();
|
||||
|
||||
/**
|
||||
* @brief A slot for the timecode display menu items
|
||||
@@ -153,15 +153,15 @@ private slots:
|
||||
* Assumes a QAction* sender() and its data() is a member of enum Timecode::Display. Uses the data() to signal a
|
||||
* timecode change throughout the rest of the application.
|
||||
*/
|
||||
void TimecodeDisplayTriggered();
|
||||
void timecode_display_triggered();
|
||||
|
||||
void ColorLabelTriggered(int color_index);
|
||||
void color_label_triggered(int color_index);
|
||||
|
||||
void SpeedDurationTriggered();
|
||||
void speed_duration_triggered();
|
||||
|
||||
void AddableItemTriggered();
|
||||
void addable_item_triggered();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // MENUSHARED_H
|
||||
#endif // OAK_MENUSHARED_H
|
||||
|
||||
@@ -34,9 +34,9 @@ MulticamDisplay::MulticamDisplay(QWidget *parent)
|
||||
{
|
||||
}
|
||||
|
||||
void MulticamDisplay::OnPaint()
|
||||
void MulticamDisplay::on_paint()
|
||||
{
|
||||
super::OnPaint();
|
||||
super::on_paint();
|
||||
|
||||
if (node_) {
|
||||
QPainter p(paint_device());
|
||||
@@ -45,43 +45,43 @@ void MulticamDisplay::OnPaint()
|
||||
p.setBrush(Qt::NoBrush);
|
||||
|
||||
int rows, cols;
|
||||
node_->GetRowsAndColumns(&rows, &cols);
|
||||
node_->get_rows_and_columns(&rows, &cols);
|
||||
|
||||
int multi = std::max(rows, cols);
|
||||
int cell_width = width() / multi;
|
||||
int cell_height = height() / multi;
|
||||
|
||||
int col, row;
|
||||
node_->IndexToRowCols(node_->GetCurrentSource(), rows, cols, &row,
|
||||
node_->index_to_row_cols(node_->get_current_source(), rows, cols, &row,
|
||||
&col);
|
||||
|
||||
QRect r(cell_width * col, cell_height * row, cell_width, cell_height);
|
||||
p.drawRect(GenerateWorldTransform().mapRect(r));
|
||||
p.drawRect(generate_world_transform().mapRect(r));
|
||||
}
|
||||
}
|
||||
|
||||
void MulticamDisplay::OnDestroy()
|
||||
void MulticamDisplay::on_destroy()
|
||||
{
|
||||
shader_ = QVariant();
|
||||
}
|
||||
|
||||
TexturePtr MulticamDisplay::LoadCustomTextureFromFrame(const QVariant &v)
|
||||
TexturePtr MulticamDisplay::load_custom_texture_from_frame(const QVariant &v)
|
||||
{
|
||||
if (v.canConvert<QVector<TexturePtr>>()) {
|
||||
QVector<TexturePtr> tex = v.value<QVector<TexturePtr>>();
|
||||
|
||||
TexturePtr main = renderer()->CreateTexture(this->GetViewportParams());
|
||||
TexturePtr main = renderer()->create_texture(this->get_viewport_params());
|
||||
|
||||
int rows, cols;
|
||||
MultiCamNode::GetRowsAndColumns(tex.size(), &rows, &cols);
|
||||
MultiCamNode::get_rows_and_columns(tex.size(), &rows, &cols);
|
||||
|
||||
if (shader_.isNull() || rows_ != rows || cols_ != cols) {
|
||||
if (!shader_.isNull()) {
|
||||
renderer()->DestroyNativeShader(shader_);
|
||||
renderer()->destroy_native_shader(shader_);
|
||||
}
|
||||
|
||||
shader_ = renderer()->CreateNativeShader(
|
||||
ShaderCode(GenerateShaderCode(rows, cols)));
|
||||
shader_ = renderer()->create_native_shader(
|
||||
ShaderCode(generate_shader_code(rows, cols)));
|
||||
|
||||
rows_ = rows;
|
||||
cols_ = cols;
|
||||
@@ -91,26 +91,26 @@ TexturePtr MulticamDisplay::LoadCustomTextureFromFrame(const QVariant &v)
|
||||
|
||||
for (int i = 0; i < tex.size(); i++) {
|
||||
int c, r;
|
||||
MultiCamNode::IndexToRowCols(i, rows, cols, &r, &c);
|
||||
job.Insert(QStringLiteral("tex_%1_%2")
|
||||
MultiCamNode::index_to_row_cols(i, rows, cols, &r, &c);
|
||||
job.insert(QStringLiteral("tex_%1_%2")
|
||||
.arg(QString::number(r), QString::number(c)),
|
||||
NodeValue(NodeValue::kTexture, tex.at(i)));
|
||||
NodeValue(NodeValue::k_texture, tex.at(i)));
|
||||
}
|
||||
|
||||
renderer()->BlitToTexture(shader_, job, main.get());
|
||||
renderer()->blit_to_texture(shader_, job, main.get());
|
||||
|
||||
return main;
|
||||
} else {
|
||||
return super::LoadCustomTextureFromFrame(v);
|
||||
return super::load_custom_texture_from_frame(v);
|
||||
}
|
||||
}
|
||||
|
||||
QString dblToGlsl(double d)
|
||||
QString dbl_to_glsl(double d)
|
||||
{
|
||||
return QString::number(d, 'f');
|
||||
}
|
||||
|
||||
QString MulticamDisplay::GenerateShaderCode(int rows, int cols)
|
||||
QString MulticamDisplay::generate_shader_code(int rows, int cols)
|
||||
{
|
||||
int multiplier = std::max(cols, rows);
|
||||
|
||||
@@ -139,7 +139,7 @@ QString MulticamDisplay::GenerateShaderCode(int rows, int cols)
|
||||
} else {
|
||||
shader.append(
|
||||
QStringLiteral(" if (ove_texcoord.x < %1) {")
|
||||
.arg(dblToGlsl(double(x + 1) / double(multiplier))));
|
||||
.arg(dbl_to_glsl(double(x + 1) / double(multiplier))));
|
||||
}
|
||||
|
||||
for (int y = 0; y < rows; y++) {
|
||||
@@ -151,17 +151,17 @@ QString MulticamDisplay::GenerateShaderCode(int rows, int cols)
|
||||
} else {
|
||||
shader.append(
|
||||
QStringLiteral(" if (ove_texcoord.y < %1) {")
|
||||
.arg(dblToGlsl(double(y + 1) / double(multiplier))));
|
||||
.arg(dbl_to_glsl(double(y + 1) / double(multiplier))));
|
||||
}
|
||||
QString input = QStringLiteral("tex_%1_%2")
|
||||
.arg(QString::number(y), QString::number(x));
|
||||
shader.append(
|
||||
QStringLiteral(
|
||||
" vec2 coord = vec2((ove_texcoord.x+%1)*%2, (ove_texcoord.y+%3)*%4);")
|
||||
.arg(dblToGlsl(-double(x) / double(multiplier)),
|
||||
dblToGlsl(multiplier),
|
||||
dblToGlsl(-double(y) / double(multiplier)),
|
||||
dblToGlsl(multiplier)));
|
||||
.arg(dbl_to_glsl(-double(x) / double(multiplier)),
|
||||
dbl_to_glsl(multiplier),
|
||||
dbl_to_glsl(-double(y) / double(multiplier)),
|
||||
dbl_to_glsl(multiplier)));
|
||||
shader.append(
|
||||
QStringLiteral(
|
||||
" if (%1_enabled && coord.x >= 0.0 && coord.x < 1.0 && coord.y >= 0.0 && coord.y < 1.0) {")
|
||||
@@ -183,7 +183,7 @@ QString MulticamDisplay::GenerateShaderCode(int rows, int cols)
|
||||
return shader.join('\n');
|
||||
}
|
||||
|
||||
void MulticamDisplay::SetMulticamNode(MultiCamNode *n)
|
||||
void MulticamDisplay::set_multicam_node(MultiCamNode *n)
|
||||
{
|
||||
node_ = n;
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef MULTICAMDISPLAY_H
|
||||
#define MULTICAMDISPLAY_H
|
||||
#ifndef OAK_MULTICAMDISPLAY_H
|
||||
#define OAK_MULTICAMDISPLAY_H
|
||||
|
||||
#include "node/input/multicam/multicamnode.h"
|
||||
#include "widget/viewer/viewerdisplay.h"
|
||||
@@ -33,17 +33,17 @@ class MulticamDisplay : public ViewerDisplayWidget {
|
||||
public:
|
||||
explicit MulticamDisplay(QWidget *parent = nullptr);
|
||||
|
||||
void SetMulticamNode(MultiCamNode *n);
|
||||
void set_multicam_node(MultiCamNode *n);
|
||||
|
||||
protected:
|
||||
virtual void OnPaint() override;
|
||||
virtual void on_paint() override;
|
||||
|
||||
virtual void OnDestroy() override;
|
||||
virtual void on_destroy() override;
|
||||
|
||||
virtual TexturePtr LoadCustomTextureFromFrame(const QVariant &v) override;
|
||||
virtual TexturePtr load_custom_texture_from_frame(const QVariant &v) override;
|
||||
|
||||
private:
|
||||
static QString GenerateShaderCode(int rows, int cols);
|
||||
static QString generate_shader_code(int rows, int cols);
|
||||
|
||||
MultiCamNode *node_;
|
||||
|
||||
@@ -54,4 +54,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // MULTICAMDISPLAY_H
|
||||
#endif // OAK_MULTICAMDISPLAY_H
|
||||
|
||||
@@ -43,17 +43,17 @@ MulticamWidget::MulticamWidget(QWidget *parent)
|
||||
layout->addWidget(sizer_);
|
||||
|
||||
display_ = new MulticamDisplay(this);
|
||||
display_->SetShowWidgetBackground(true);
|
||||
connect(display_, &ViewerDisplayWidget::DragStarted, this,
|
||||
&MulticamWidget::DisplayClicked);
|
||||
display_->set_show_widget_background(true);
|
||||
connect(display_, &ViewerDisplayWidget::drag_started, this,
|
||||
&MulticamWidget::display_clicked);
|
||||
|
||||
connect(sizer_, &ViewerSizer::RequestScale, display_,
|
||||
&ViewerDisplayWidget::SetMatrixZoom);
|
||||
connect(sizer_, &ViewerSizer::RequestTranslate, display_,
|
||||
&ViewerDisplayWidget::SetMatrixTranslate);
|
||||
connect(display_, &ViewerDisplayWidget::HandDragMoved, sizer_,
|
||||
&ViewerSizer::HandDragMove);
|
||||
sizer_->SetWidget(display_);
|
||||
connect(sizer_, &ViewerSizer::request_scale, display_,
|
||||
&ViewerDisplayWidget::set_matrix_zoom);
|
||||
connect(sizer_, &ViewerSizer::request_translate, display_,
|
||||
&ViewerDisplayWidget::set_matrix_translate);
|
||||
connect(display_, &ViewerDisplayWidget::hand_drag_moved, sizer_,
|
||||
&ViewerSizer::hand_drag_move);
|
||||
sizer_->set_widget(display_);
|
||||
|
||||
layout->addWidget(this->ruler());
|
||||
layout->addWidget(this->scrollbar());
|
||||
@@ -66,16 +66,16 @@ MulticamWidget::MulticamWidget(QWidget *parent)
|
||||
}
|
||||
}
|
||||
|
||||
void MulticamWidget::SetMulticamNodeInternal(ViewerOutput *viewer,
|
||||
void MulticamWidget::set_multicam_node_internal(ViewerOutput *viewer,
|
||||
MultiCamNode *n, ClipBlock *clip)
|
||||
{
|
||||
if (GetConnectedNode() != viewer) {
|
||||
ConnectViewerNode(viewer);
|
||||
if (get_connected_node() != viewer) {
|
||||
connect_viewer_node(viewer);
|
||||
}
|
||||
|
||||
if (node_ != n) {
|
||||
node_ = n;
|
||||
display_->SetMulticamNode(n);
|
||||
display_->set_multicam_node(n);
|
||||
}
|
||||
|
||||
if (clip_ != clip) {
|
||||
@@ -83,12 +83,12 @@ void MulticamWidget::SetMulticamNodeInternal(ViewerOutput *viewer,
|
||||
}
|
||||
}
|
||||
|
||||
void MulticamWidget::SetMulticamNode(ViewerOutput *viewer, MultiCamNode *n,
|
||||
ClipBlock *clip, const rational &time)
|
||||
void MulticamWidget::set_multicam_node(ViewerOutput *viewer, MultiCamNode *n,
|
||||
ClipBlock *clip, const Rational &time)
|
||||
{
|
||||
if (time.isNaN() || !GetConnectedNode() ||
|
||||
time == GetConnectedNode()->GetPlayhead()) {
|
||||
SetMulticamNodeInternal(viewer, n, clip);
|
||||
if (time.isNaN() || !get_connected_node() ||
|
||||
time == get_connected_node()->get_playhead()) {
|
||||
set_multicam_node_internal(viewer, n, clip);
|
||||
play_queue_.clear();
|
||||
} else {
|
||||
MulticamNodeQueue m = { time, viewer, n, clip };
|
||||
@@ -98,31 +98,31 @@ void MulticamWidget::SetMulticamNode(ViewerOutput *viewer, MultiCamNode *n,
|
||||
|
||||
void MulticamWidget::ConnectNodeEvent(ViewerOutput *n)
|
||||
{
|
||||
connect(n, &ViewerOutput::SizeChanged, sizer_, &ViewerSizer::SetChildSize);
|
||||
connect(n, &ViewerOutput::PixelAspectChanged, sizer_,
|
||||
&ViewerSizer::SetPixelAspectRatio);
|
||||
connect(n, &ViewerOutput::size_changed, sizer_, &ViewerSizer::set_child_size);
|
||||
connect(n, &ViewerOutput::pixel_aspect_changed, sizer_,
|
||||
&ViewerSizer::set_pixel_aspect_ratio);
|
||||
|
||||
VideoParams vp = n->GetVideoParams();
|
||||
sizer_->SetChildSize(vp.width(), vp.height());
|
||||
sizer_->SetPixelAspectRatio(vp.pixel_aspect_ratio());
|
||||
VideoParams vp = n->get_video_params();
|
||||
sizer_->set_child_size(vp.width(), vp.height());
|
||||
sizer_->set_pixel_aspect_ratio(vp.pixel_aspect_ratio());
|
||||
}
|
||||
|
||||
void MulticamWidget::DisconnectNodeEvent(ViewerOutput *n)
|
||||
{
|
||||
disconnect(n, &ViewerOutput::SizeChanged, sizer_,
|
||||
&ViewerSizer::SetChildSize);
|
||||
disconnect(n, &ViewerOutput::PixelAspectChanged, sizer_,
|
||||
&ViewerSizer::SetPixelAspectRatio);
|
||||
disconnect(n, &ViewerOutput::size_changed, sizer_,
|
||||
&ViewerSizer::set_child_size);
|
||||
disconnect(n, &ViewerOutput::pixel_aspect_changed, sizer_,
|
||||
&ViewerSizer::set_pixel_aspect_ratio);
|
||||
}
|
||||
|
||||
void MulticamWidget::TimeChangedEvent(const rational &t)
|
||||
void MulticamWidget::TimeChangedEvent(const Rational &t)
|
||||
{
|
||||
super::TimeChangedEvent(t);
|
||||
|
||||
if (!play_queue_.empty()) {
|
||||
const MulticamNodeQueue &m = play_queue_.front();
|
||||
if (m.time >= t) {
|
||||
SetMulticamNodeInternal(m.viewer, m.node, m.clip);
|
||||
set_multicam_node_internal(m.viewer, m.node, m.clip);
|
||||
play_queue_.pop_front();
|
||||
}
|
||||
}
|
||||
@@ -142,33 +142,33 @@ void MulticamWidget::Switch(int source, bool split_clip)
|
||||
BlockSplitPreservingLinksCommand *split = nullptr;
|
||||
|
||||
if (clip_ && split_clip &&
|
||||
clip_->in() < GetConnectedNode()->GetPlayhead() &&
|
||||
clip_->out() > GetConnectedNode()->GetPlayhead()) {
|
||||
clip_->in() < get_connected_node()->get_playhead() &&
|
||||
clip_->out() > get_connected_node()->get_playhead()) {
|
||||
QVector<Block *> blocks;
|
||||
|
||||
blocks.append(clip_);
|
||||
blocks.append(clip_->block_links());
|
||||
|
||||
split = new BlockSplitPreservingLinksCommand(
|
||||
blocks, { GetConnectedNode()->GetPlayhead() });
|
||||
blocks, { get_connected_node()->get_playhead() });
|
||||
split->redo_now();
|
||||
command->add_child(split);
|
||||
|
||||
clip = static_cast<ClipBlock *>(split->GetSplit(clip_, 0));
|
||||
clip = static_cast<ClipBlock *>(split->get_split(clip_, 0));
|
||||
|
||||
cam = clip->FindMulticam();
|
||||
cam = clip->find_multicam();
|
||||
}
|
||||
|
||||
command->add_child(new NodeParamSetStandardValueCommand(
|
||||
NodeKeyframeTrackReference(NodeInput(cam, cam->kCurrentInput)),
|
||||
NodeKeyframeTrackReference(NodeInput(cam, cam->k_current_input)),
|
||||
source));
|
||||
|
||||
for (Block *link : clip->block_links()) {
|
||||
if (ClipBlock *clink = dynamic_cast<ClipBlock *>(link)) {
|
||||
if (MultiCamNode *mlink = clink->FindMulticam()) {
|
||||
if (MultiCamNode *mlink = clink->find_multicam()) {
|
||||
command->add_child(new NodeParamSetStandardValueCommand(
|
||||
NodeKeyframeTrackReference(
|
||||
NodeInput(mlink, mlink->kCurrentInput)),
|
||||
NodeInput(mlink, mlink->k_current_input)),
|
||||
source));
|
||||
}
|
||||
}
|
||||
@@ -179,18 +179,18 @@ void MulticamWidget::Switch(int source, bool split_clip)
|
||||
|
||||
display_->update();
|
||||
|
||||
emit Switched();
|
||||
emit switched();
|
||||
}
|
||||
|
||||
void MulticamWidget::DisplayClicked(const QPoint &p)
|
||||
void MulticamWidget::display_clicked(const QPoint &p)
|
||||
{
|
||||
if (!node_) {
|
||||
return;
|
||||
}
|
||||
|
||||
QPointF click = display_->ScreenToScenePoint(p);
|
||||
int width = display_->GetVideoParams().width();
|
||||
int height = display_->GetVideoParams().height();
|
||||
QPointF click = display_->screen_to_scene_point(p);
|
||||
int width = display_->get_video_params().width();
|
||||
int height = display_->get_video_params().height();
|
||||
|
||||
if (click.x() < 0 || click.y() < 0 || click.x() >= width ||
|
||||
click.y() >= height) {
|
||||
@@ -198,14 +198,14 @@ void MulticamWidget::DisplayClicked(const QPoint &p)
|
||||
}
|
||||
|
||||
int rows, cols;
|
||||
node_->GetRowsAndColumns(&rows, &cols);
|
||||
node_->get_rows_and_columns(&rows, &cols);
|
||||
|
||||
int multi = std::max(cols, rows);
|
||||
|
||||
int c = click.x() / (width / multi);
|
||||
int r = click.y() / (height / multi);
|
||||
|
||||
int source = node_->RowsColsToIndex(r, c, rows, cols);
|
||||
int source = node_->rows_cols_to_index(r, c, rows, cols);
|
||||
|
||||
Switch(source, true);
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef MULTICAMWIDGET_H
|
||||
#define MULTICAMWIDGET_H
|
||||
#ifndef OAK_MULTICAMWIDGET_H
|
||||
#define OAK_MULTICAMWIDGET_H
|
||||
|
||||
#include "multicamdisplay.h"
|
||||
#include "node/input/multicam/multicamnode.h"
|
||||
@@ -34,24 +34,24 @@ class MulticamWidget : public TimeBasedWidget {
|
||||
public:
|
||||
explicit MulticamWidget(QWidget *parent = nullptr);
|
||||
|
||||
MulticamDisplay *GetDisplayWidget() const
|
||||
MulticamDisplay *get_display_widget() const
|
||||
{
|
||||
return display_;
|
||||
}
|
||||
|
||||
void SetMulticamNode(ViewerOutput *viewer, MultiCamNode *n, ClipBlock *clip,
|
||||
const rational &time);
|
||||
void set_multicam_node(ViewerOutput *viewer, MultiCamNode *n, ClipBlock *clip,
|
||||
const Rational &time);
|
||||
|
||||
protected:
|
||||
virtual void ConnectNodeEvent(ViewerOutput *n) override;
|
||||
virtual void DisconnectNodeEvent(ViewerOutput *n) override;
|
||||
virtual void TimeChangedEvent(const rational &t) override;
|
||||
virtual void TimeChangedEvent(const Rational &t) override;
|
||||
|
||||
signals:
|
||||
void Switched();
|
||||
void switched();
|
||||
|
||||
private:
|
||||
void SetMulticamNodeInternal(ViewerOutput *viewer, MultiCamNode *n,
|
||||
void set_multicam_node_internal(ViewerOutput *viewer, MultiCamNode *n,
|
||||
ClipBlock *clip);
|
||||
|
||||
void Switch(int source, bool split_clip);
|
||||
@@ -65,7 +65,7 @@ private:
|
||||
ClipBlock *clip_;
|
||||
|
||||
struct MulticamNodeQueue {
|
||||
rational time;
|
||||
Rational time;
|
||||
ViewerOutput *viewer;
|
||||
MultiCamNode *node;
|
||||
ClipBlock *clip;
|
||||
@@ -74,9 +74,9 @@ private:
|
||||
std::list<MulticamNodeQueue> play_queue_;
|
||||
|
||||
private slots:
|
||||
void DisplayClicked(const QPoint &p);
|
||||
void display_clicked(const QPoint &p);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // MULTICAMWIDGET_H
|
||||
#endif // OAK_MULTICAMWIDGET_H
|
||||
|
||||
@@ -39,56 +39,56 @@ NodeComboBox::NodeComboBox(QWidget *parent)
|
||||
|
||||
void NodeComboBox::showPopup()
|
||||
{
|
||||
Menu *m = NodeFactory::CreateMenu(this, true);
|
||||
Menu *m = NodeFactory::create_menu(this, true);
|
||||
|
||||
QAction *selected = m->exec(parentWidget()->mapToGlobal(pos()));
|
||||
|
||||
if (selected) {
|
||||
QString new_id = NodeFactory::GetIDFromMenuAction(selected);
|
||||
|
||||
SetNodeInternal(new_id, true);
|
||||
set_node_internal(new_id, true);
|
||||
}
|
||||
|
||||
delete m;
|
||||
}
|
||||
|
||||
const QString &NodeComboBox::GetSelectedNode() const
|
||||
const QString &NodeComboBox::get_selected_node() const
|
||||
{
|
||||
return selected_id_;
|
||||
}
|
||||
|
||||
void NodeComboBox::SetNode(const QString &id)
|
||||
void NodeComboBox::set_node(const QString &id)
|
||||
{
|
||||
SetNodeInternal(id, false);
|
||||
set_node_internal(id, false);
|
||||
}
|
||||
|
||||
void NodeComboBox::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
UpdateText();
|
||||
update_text();
|
||||
}
|
||||
|
||||
QComboBox::changeEvent(e);
|
||||
}
|
||||
|
||||
void NodeComboBox::UpdateText()
|
||||
void NodeComboBox::update_text()
|
||||
{
|
||||
clear();
|
||||
|
||||
if (!selected_id_.isEmpty()) {
|
||||
addItem(NodeFactory::GetNameFromID(selected_id_));
|
||||
addItem(NodeFactory::get_name_from_id(selected_id_));
|
||||
}
|
||||
}
|
||||
|
||||
void NodeComboBox::SetNodeInternal(const QString &id, bool emit_signal)
|
||||
void NodeComboBox::set_node_internal(const QString &id, bool emit_signal)
|
||||
{
|
||||
if (selected_id_ != id) {
|
||||
selected_id_ = id;
|
||||
|
||||
UpdateText();
|
||||
update_text();
|
||||
|
||||
if (emit_signal) {
|
||||
emit NodeChanged(selected_id_);
|
||||
emit node_changed(selected_id_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NODECOMBOBOX_H
|
||||
#define NODECOMBOBOX_H
|
||||
#ifndef OAK_NODECOMBOBOX_H
|
||||
#define OAK_NODECOMBOBOX_H
|
||||
|
||||
#include <QComboBox>
|
||||
|
||||
@@ -36,21 +36,21 @@ public:
|
||||
|
||||
virtual void showPopup() override;
|
||||
|
||||
const QString &GetSelectedNode() const;
|
||||
const QString &get_selected_node() const;
|
||||
|
||||
public slots:
|
||||
void SetNode(const QString &id);
|
||||
void set_node(const QString &id);
|
||||
|
||||
protected:
|
||||
virtual void changeEvent(QEvent *e) override;
|
||||
|
||||
signals:
|
||||
void NodeChanged(const QString &id);
|
||||
void node_changed(const QString &id);
|
||||
|
||||
private:
|
||||
void UpdateText();
|
||||
void update_text();
|
||||
|
||||
void SetNodeInternal(const QString &id, bool emit_signal);
|
||||
void set_node_internal(const QString &id, bool emit_signal);
|
||||
|
||||
QString selected_id_;
|
||||
};
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NODEPARAMBUTTON_H
|
||||
#define NODEPARAMBUTTON_H
|
||||
#include "node/plugins/Plugin.h"
|
||||
#ifndef OAK_NODEPARAMBUTTON_H
|
||||
#define OAK_NODEPARAMBUTTON_H
|
||||
#include "node/plugins/plugin.h"
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
@@ -33,15 +33,15 @@ public:
|
||||
connect(this, &QPushButton::clicked, this, &NodeParamButton::pressed);
|
||||
}
|
||||
signals:
|
||||
void onPressed(QString name);
|
||||
void on_pressed(QString name);
|
||||
private slots:
|
||||
void pressed()
|
||||
{
|
||||
emit onPressed(name_);
|
||||
emit on_pressed(name_);
|
||||
}
|
||||
|
||||
private:
|
||||
QString name_;
|
||||
};
|
||||
|
||||
#endif //NODEPARAMBUTTON_H
|
||||
#endif //OAK_NODEPARAMBUTTON_H
|
||||
|
||||
@@ -75,28 +75,28 @@ NodeParamView::NodeParamView(bool create_keyframe_view, QWidget *parent)
|
||||
param_widget_container_layout->addStretch(INT_MAX);
|
||||
|
||||
// Create contexts for three different types
|
||||
context_items_.resize(Track::kCount + 1);
|
||||
context_items_.resize(Track::k_count + 1);
|
||||
for (int i = 0; i < context_items_.size(); i++) {
|
||||
NodeParamViewContext *c = new NodeParamViewContext(param_widget_area_);
|
||||
c->setVisible(false);
|
||||
connect(c, &NodeParamViewContext::AboutToDeleteItem, this,
|
||||
&NodeParamView::ItemAboutToBeRemoved, Qt::DirectConnection);
|
||||
connect(c, &NodeParamViewContext::about_to_delete_item, this,
|
||||
&NodeParamView::item_about_to_be_removed, Qt::DirectConnection);
|
||||
|
||||
NodeParamViewItemTitleBar *title_bar =
|
||||
static_cast<NodeParamViewItemTitleBar *>(c->titleBarWidget());
|
||||
|
||||
if (i == Track::kVideo || i == Track::kAudio) {
|
||||
c->SetEffectType(static_cast<Track::Type>(i));
|
||||
title_bar->SetAddEffectButtonVisible(true);
|
||||
title_bar->SetText(tr("%1 Nodes")
|
||||
.arg(Footage::GetStreamTypeName(
|
||||
if (i == Track::k_video || i == Track::k_audio) {
|
||||
c->set_effect_type(static_cast<Track::Type>(i));
|
||||
title_bar->set_add_effect_button_visible(true);
|
||||
title_bar->set_text(tr("%1 Nodes")
|
||||
.arg(Footage::get_stream_type_name(
|
||||
static_cast<Track::Type>(i))));
|
||||
} else {
|
||||
title_bar->SetText(tr("Other"));
|
||||
title_bar->set_text(tr("Other"));
|
||||
}
|
||||
|
||||
context_items_[i] = c;
|
||||
param_widget_area_->AddItem(c);
|
||||
param_widget_area_->add_item(c);
|
||||
}
|
||||
|
||||
// Disable collapsing param view (but collapsing keyframe view is permitted)
|
||||
@@ -113,7 +113,7 @@ NodeParamView::NodeParamView(bool create_keyframe_view, QWidget *parent)
|
||||
connect(param_scroll_area_->verticalScrollBar(), &QScrollBar::rangeChanged,
|
||||
vertical_scrollbar_, &QScrollBar::setRange);
|
||||
connect(param_scroll_area_->verticalScrollBar(), &QScrollBar::rangeChanged,
|
||||
this, &NodeParamView::UpdateGlobalScrollBar);
|
||||
this, &NodeParamView::update_global_scroll_bar);
|
||||
connect(vertical_scrollbar_, &QScrollBar::valueChanged,
|
||||
param_scroll_area_->verticalScrollBar(), &QScrollBar::setValue);
|
||||
|
||||
@@ -130,17 +130,17 @@ NodeParamView::NodeParamView(bool create_keyframe_view, QWidget *parent)
|
||||
// Create keyframe view
|
||||
keyframe_view_ = new KeyframeView();
|
||||
keyframe_view_->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
keyframe_view_->SetSnapService(this);
|
||||
ConnectTimelineView(keyframe_view_);
|
||||
keyframe_view_->set_snap_service(this);
|
||||
connect_timeline_view(keyframe_view_);
|
||||
keyframe_area_layout->addWidget(keyframe_view_);
|
||||
|
||||
// Connect ruler and keyframe view together
|
||||
connect(keyframe_view_, &KeyframeView::Dragged, this,
|
||||
connect(keyframe_view_, &KeyframeView::dragged, this,
|
||||
static_cast<void (NodeParamView::*)(int)>(
|
||||
&NodeParamView::SetCatchUpScrollValue));
|
||||
connect(keyframe_view_, &KeyframeView::Released, this,
|
||||
&NodeParamView::set_catch_up_scroll_value));
|
||||
connect(keyframe_view_, &KeyframeView::released, this,
|
||||
static_cast<void (NodeParamView::*)()>(
|
||||
&NodeParamView::StopCatchUpScrollTimer));
|
||||
&NodeParamView::stop_catch_up_scroll_timer));
|
||||
|
||||
splitter->addWidget(keyframe_area);
|
||||
|
||||
@@ -180,7 +180,7 @@ NodeParamView::~NodeParamView()
|
||||
qDeleteAll(context_items_);
|
||||
}
|
||||
|
||||
void NodeParamView::CloseContextsBelongingToProject(Project *p)
|
||||
void NodeParamView::close_contexts_belonging_to_project(Project *p)
|
||||
{
|
||||
QVector<Node *> new_contexts = contexts_;
|
||||
|
||||
@@ -191,7 +191,7 @@ void NodeParamView::CloseContextsBelongingToProject(Project *p)
|
||||
}
|
||||
}
|
||||
|
||||
SetContexts(new_contexts);
|
||||
set_contexts(new_contexts);
|
||||
}
|
||||
|
||||
/*void NodeParamView::SelectNodes(const QVector<Node *> &nodes)
|
||||
@@ -253,14 +253,14 @@ void NodeParamView::DeselectNodes(const QVector<Node *> &nodes)
|
||||
}
|
||||
}*/
|
||||
|
||||
void NodeParamView::UpdateContexts()
|
||||
void NodeParamView::update_contexts()
|
||||
{
|
||||
bool changes_made = false;
|
||||
|
||||
foreach (Node *ctx, current_contexts_) {
|
||||
if (!contexts_.contains(ctx)) {
|
||||
// Context is being removed
|
||||
RemoveContext(ctx);
|
||||
remove_context(ctx);
|
||||
changes_made = true;
|
||||
}
|
||||
}
|
||||
@@ -268,7 +268,7 @@ void NodeParamView::UpdateContexts()
|
||||
foreach (Node *ctx, contexts_) {
|
||||
if (!current_contexts_.contains(ctx)) {
|
||||
// Context is being added
|
||||
AddContext(ctx);
|
||||
add_context(ctx);
|
||||
changes_made = true;
|
||||
}
|
||||
}
|
||||
@@ -276,38 +276,38 @@ void NodeParamView::UpdateContexts()
|
||||
if (changes_made) {
|
||||
current_contexts_ = contexts_;
|
||||
|
||||
if (IsGroupMode()) {
|
||||
if (is_group_mode()) {
|
||||
// Check inputs that have been passed through
|
||||
NodeGroup *group = static_cast<NodeGroup *>(contexts_.first());
|
||||
for (auto it = group->GetInputPassthroughs().cbegin();
|
||||
it != group->GetInputPassthroughs().cend(); it++) {
|
||||
GroupInputPassthroughAdded(group, it->second);
|
||||
for (auto it = group->get_input_passthroughs().cbegin();
|
||||
it != group->get_input_passthroughs().cend(); it++) {
|
||||
group_input_passthrough_added(group, it->second);
|
||||
}
|
||||
|
||||
connect(group, &NodeGroup::InputPassthroughAdded, this,
|
||||
&NodeParamView::GroupInputPassthroughAdded);
|
||||
connect(group, &NodeGroup::InputPassthroughRemoved, this,
|
||||
&NodeParamView::GroupInputPassthroughRemoved);
|
||||
connect(group, &NodeGroup::input_passthrough_added, this,
|
||||
&NodeParamView::group_input_passthrough_added);
|
||||
connect(group, &NodeGroup::input_passthrough_removed, this,
|
||||
&NodeParamView::group_input_passthrough_removed);
|
||||
}
|
||||
|
||||
foreach (NodeParamViewContext *ctx, context_items_) {
|
||||
SortItemsInContext(ctx);
|
||||
sort_items_in_context(ctx);
|
||||
}
|
||||
|
||||
if (keyframe_view_) {
|
||||
QueueKeyframePositionUpdate();
|
||||
queue_keyframe_position_update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamView::ItemAboutToBeRemoved(NodeParamViewItem *item)
|
||||
void NodeParamView::item_about_to_be_removed(NodeParamViewItem *item)
|
||||
{
|
||||
if (keyframe_view_) {
|
||||
for (auto it = item->GetKeyframeConnections().begin();
|
||||
it != item->GetKeyframeConnections().end(); it++) {
|
||||
for (auto it = item->get_keyframe_connections().begin();
|
||||
it != item->get_keyframe_connections().end(); it++) {
|
||||
for (auto jt = it->begin(); jt != it->end(); jt++) {
|
||||
for (auto kt = jt->begin(); kt != jt->end(); kt++) {
|
||||
keyframe_view_->RemoveKeyframesOfTrack(*kt);
|
||||
keyframe_view_->remove_keyframes_of_track(*kt);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -315,36 +315,36 @@ void NodeParamView::ItemAboutToBeRemoved(NodeParamViewItem *item)
|
||||
|
||||
QVector<NodeParamViewItem *> copy = selected_nodes_;
|
||||
if (copy.removeOne(item)) {
|
||||
SetSelectedNodes(copy);
|
||||
set_selected_nodes(copy);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamView::ItemClicked()
|
||||
void NodeParamView::item_clicked()
|
||||
{
|
||||
ToggleSelect(static_cast<NodeParamViewItem *>(sender()));
|
||||
toggle_select(static_cast<NodeParamViewItem *>(sender()));
|
||||
}
|
||||
|
||||
void NodeParamView::SelectNodeFromConnectedLink(Node *node)
|
||||
void NodeParamView::select_node_from_connected_link(Node *node)
|
||||
{
|
||||
NodeParamViewItem *item = static_cast<NodeParamViewItem *>(sender());
|
||||
|
||||
Node::ContextPair p = { node, item->GetContext() };
|
||||
SetSelectedNodes({ p });
|
||||
Node::ContextPair p = { node, item->get_context() };
|
||||
set_selected_nodes({ p });
|
||||
}
|
||||
|
||||
void NodeParamView::RequestEditTextInViewer()
|
||||
void NodeParamView::request_edit_text_in_viewer()
|
||||
{
|
||||
NodeParamViewItem *item = static_cast<NodeParamViewItem *>(sender());
|
||||
|
||||
SetSelectedNodes({ item });
|
||||
emit RequestViewerToStartEditingText();
|
||||
set_selected_nodes({ item });
|
||||
emit request_viewer_to_start_editing_text();
|
||||
}
|
||||
|
||||
void NodeParamView::SetContexts(const QVector<Node *> &contexts)
|
||||
void NodeParamView::set_contexts(const QVector<Node *> &contexts)
|
||||
{
|
||||
// Setting contexts is expensive, so we queue it here to prevent multiple calls in a short timespan
|
||||
contexts_ = contexts;
|
||||
UpdateContexts();
|
||||
update_contexts();
|
||||
}
|
||||
|
||||
void NodeParamView::resizeEvent(QResizeEvent *event)
|
||||
@@ -359,20 +359,20 @@ void NodeParamView::ScaleChangedEvent(const double &scale)
|
||||
super::ScaleChangedEvent(scale);
|
||||
|
||||
if (keyframe_view_) {
|
||||
keyframe_view_->SetScale(scale);
|
||||
keyframe_view_->set_scale(scale);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamView::TimebaseChangedEvent(const rational &timebase)
|
||||
void NodeParamView::TimebaseChangedEvent(const Rational &timebase)
|
||||
{
|
||||
super::TimebaseChangedEvent(timebase);
|
||||
|
||||
if (keyframe_view_) {
|
||||
keyframe_view_->SetTimebase(timebase);
|
||||
keyframe_view_->set_timebase(timebase);
|
||||
}
|
||||
|
||||
foreach (NodeParamViewContext *ctx, context_items_) {
|
||||
ctx->SetTimebase(timebase);
|
||||
ctx->set_timebase(timebase);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -380,15 +380,15 @@ void NodeParamView::ConnectedNodeChangeEvent(ViewerOutput *n)
|
||||
{
|
||||
if (keyframe_view_) {
|
||||
// Set viewer as a time target
|
||||
keyframe_view_->SetTimeTarget(n);
|
||||
keyframe_view_->set_time_target(n);
|
||||
}
|
||||
|
||||
foreach (NodeParamViewContext *item, context_items_) {
|
||||
item->SetTimeTarget(n);
|
||||
item->set_time_target(n);
|
||||
}
|
||||
}
|
||||
|
||||
void ReconnectOutputsIfNotDeletingNode(MultiUndoCommand *c,
|
||||
void reconnect_outputs_if_not_deleting_node(MultiUndoCommand *c,
|
||||
NodeViewDeleteCommand *dc, Node *output,
|
||||
Node *deleting, Node *context)
|
||||
{
|
||||
@@ -396,9 +396,9 @@ void ReconnectOutputsIfNotDeletingNode(MultiUndoCommand *c,
|
||||
it != deleting->output_connections().cend(); it++) {
|
||||
const NodeInput &proposed_reconnect = it->second;
|
||||
|
||||
if (dc->ContainsNode(proposed_reconnect.node(), context)) {
|
||||
if (dc->contains_node(proposed_reconnect.node(), context)) {
|
||||
// Uh-oh we're deleting this node too, instead connect to its outputs
|
||||
ReconnectOutputsIfNotDeletingNode(
|
||||
reconnect_outputs_if_not_deleting_node(
|
||||
c, dc, output, proposed_reconnect.node(), context);
|
||||
} else {
|
||||
c->add_child(new NodeEdgeAddCommand(output, it->second));
|
||||
@@ -409,7 +409,7 @@ void ReconnectOutputsIfNotDeletingNode(MultiUndoCommand *c,
|
||||
void NodeParamView::DeleteSelected()
|
||||
{
|
||||
if (keyframe_view_ && keyframe_view_->hasFocus()) {
|
||||
keyframe_view_->DeleteSelected();
|
||||
keyframe_view_->delete_selected();
|
||||
} else if (!selected_nodes_.isEmpty()) {
|
||||
MultiUndoCommand *c = new MultiUndoCommand();
|
||||
|
||||
@@ -419,24 +419,24 @@ void NodeParamView::DeleteSelected()
|
||||
|
||||
// Add all nodes
|
||||
foreach (NodeParamViewItem *item, selected_nodes_) {
|
||||
Node *n = item->GetNode();
|
||||
dc->AddNode(n, item->GetContext());
|
||||
Node *n = item->get_node();
|
||||
dc->add_node(n, item->get_context());
|
||||
}
|
||||
|
||||
// Make reconnections where possible
|
||||
foreach (NodeParamViewItem *item, selected_nodes_) {
|
||||
Node *n = item->GetNode();
|
||||
Node *n = item->get_node();
|
||||
|
||||
Node *node_being_deleted = n;
|
||||
Node *connected_to_effect_input = nullptr;
|
||||
|
||||
while (true) {
|
||||
if (node_being_deleted->GetEffectInput().IsValid()) {
|
||||
if (node_being_deleted->get_effect_input().is_valid()) {
|
||||
if ((connected_to_effect_input =
|
||||
node_being_deleted->GetEffectInput()
|
||||
.GetConnectedOutput())) {
|
||||
if (dc->ContainsNode(connected_to_effect_input,
|
||||
item->GetContext())) {
|
||||
node_being_deleted->get_effect_input()
|
||||
.get_connected_output())) {
|
||||
if (dc->contains_node(connected_to_effect_input,
|
||||
item->get_context())) {
|
||||
// Node's getting deleted, recurse
|
||||
node_being_deleted = connected_to_effect_input;
|
||||
continue;
|
||||
@@ -448,8 +448,8 @@ void NodeParamView::DeleteSelected()
|
||||
}
|
||||
|
||||
if (connected_to_effect_input) {
|
||||
ReconnectOutputsIfNotDeletingNode(
|
||||
c, dc, connected_to_effect_input, n, item->GetContext());
|
||||
reconnect_outputs_if_not_deleting_node(
|
||||
c, dc, connected_to_effect_input, n, item->get_context());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -458,7 +458,7 @@ void NodeParamView::DeleteSelected()
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamView::SetSelectedNodes(const QVector<NodeParamViewItem *> &nodes,
|
||||
void NodeParamView::set_selected_nodes(const QVector<NodeParamViewItem *> &nodes,
|
||||
bool handle_focused_node, bool emit_signal)
|
||||
{
|
||||
if (handle_focused_node) {
|
||||
@@ -467,7 +467,7 @@ void NodeParamView::SetSelectedNodes(const QVector<NodeParamViewItem *> &nodes,
|
||||
}
|
||||
|
||||
foreach (NodeParamViewItem *n, selected_nodes_) {
|
||||
n->SetHighlighted(false);
|
||||
n->set_highlighted(false);
|
||||
}
|
||||
|
||||
selected_nodes_ = nodes;
|
||||
@@ -479,10 +479,10 @@ void NodeParamView::SetSelectedNodes(const QVector<NodeParamViewItem *> &nodes,
|
||||
|
||||
for (int i = 0; i < selected_nodes_.size(); i++) {
|
||||
NodeParamViewItem *n = selected_nodes_.at(i);
|
||||
n->SetHighlighted(true);
|
||||
n->set_highlighted(true);
|
||||
|
||||
if (emit_signal) {
|
||||
p[i] = { n->GetNode(), n->GetContext() };
|
||||
p[i] = { n->get_node(), n->get_context() };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -490,22 +490,22 @@ void NodeParamView::SetSelectedNodes(const QVector<NodeParamViewItem *> &nodes,
|
||||
focused_node_ = nullptr;
|
||||
|
||||
foreach (NodeParamViewItem *n, selected_nodes_) {
|
||||
if (n->GetNode()->HasGizmos()) {
|
||||
if (n->get_node()->has_gizmos()) {
|
||||
focused_node_ = n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Node *n = focused_node_ ? focused_node_->GetNode() : nullptr;
|
||||
emit FocusedNodeChanged(n);
|
||||
Node *n = focused_node_ ? focused_node_->get_node() : nullptr;
|
||||
emit focused_node_changed(n);
|
||||
}
|
||||
|
||||
if (emit_signal) {
|
||||
emit SelectedNodesChanged(p);
|
||||
emit selected_nodes_changed(p);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamView::SetSelectedNodes(const QVector<Node::ContextPair> &nodes,
|
||||
void NodeParamView::set_selected_nodes(const QVector<Node::ContextPair> &nodes,
|
||||
bool emit_signal)
|
||||
{
|
||||
QVector<NodeParamViewItem *> items;
|
||||
@@ -516,7 +516,7 @@ void NodeParamView::SetSelectedNodes(const QVector<Node::ContextPair> &nodes,
|
||||
it++) {
|
||||
NodeParamViewContext *ctx = *it;
|
||||
|
||||
NodeParamViewItem *item = ctx->GetItem(n.node, n.context);
|
||||
NodeParamViewItem *item = ctx->get_item(n.node, n.context);
|
||||
|
||||
if (item) {
|
||||
items.append(item);
|
||||
@@ -527,7 +527,7 @@ void NodeParamView::SetSelectedNodes(const QVector<Node::ContextPair> &nodes,
|
||||
}
|
||||
}
|
||||
|
||||
SetSelectedNodes(items, true, emit_signal);
|
||||
set_selected_nodes(items, true, emit_signal);
|
||||
|
||||
if (!selected_nodes_.empty()) {
|
||||
NodeParamViewItem *scrolled_to = selected_nodes_.front();
|
||||
@@ -540,31 +540,31 @@ void NodeParamView::SetSelectedNodes(const QVector<Node::ContextPair> &nodes,
|
||||
|
||||
// Make sure the dock/tab containing this node is visible
|
||||
if (scrolled_ctx) {
|
||||
scrolled_ctx->SetExpanded(true);
|
||||
scrolled_ctx->set_expanded(true);
|
||||
scrolled_ctx->raise();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Node *NodeParamView::GetNodeWithID(const QString &id)
|
||||
Node *NodeParamView::get_node_with_id(const QString &id)
|
||||
{
|
||||
return GetNodeWithIDAndIgnoreList(id, QVector<Node *>());
|
||||
return get_node_with_id_and_ignore_list(id, QVector<Node *>());
|
||||
}
|
||||
|
||||
Node *NodeParamView::GetNodeWithIDAndIgnoreList(const QString &id,
|
||||
Node *NodeParamView::get_node_with_id_and_ignore_list(const QString &id,
|
||||
const QVector<Node *> &ignore)
|
||||
{
|
||||
for (NodeParamViewItem *item : selected_nodes_) {
|
||||
if (item->GetNode()->id() == id && !ignore.contains(item->GetNode())) {
|
||||
return item->GetNode();
|
||||
if (item->get_node()->id() == id && !ignore.contains(item->get_node())) {
|
||||
return item->get_node();
|
||||
}
|
||||
}
|
||||
|
||||
for (NodeParamViewContext *ctx : context_items_) {
|
||||
for (NodeParamViewItem *item : ctx->GetItems()) {
|
||||
if (item->GetNode()->id() == id &&
|
||||
!ignore.contains(item->GetNode())) {
|
||||
return item->GetNode();
|
||||
for (NodeParamViewItem *item : ctx->get_items()) {
|
||||
if (item->get_node()->id() == id &&
|
||||
!ignore.contains(item->get_node())) {
|
||||
return item->get_node();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -572,14 +572,14 @@ Node *NodeParamView::GetNodeWithIDAndIgnoreList(const QString &id,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool NodeParamView::CopySelected(bool cut)
|
||||
bool NodeParamView::copy_selected(bool cut)
|
||||
{
|
||||
if (super::CopySelected(cut)) {
|
||||
if (super::copy_selected(cut)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (keyframe_view_ && keyframe_view_->hasFocus()) {
|
||||
if (keyframe_view_->CopySelected(cut)) {
|
||||
if (keyframe_view_->copy_selected(cut)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -588,18 +588,18 @@ bool NodeParamView::CopySelected(bool cut)
|
||||
return false;
|
||||
}
|
||||
|
||||
ProjectSerializer::SaveData sdata(ProjectSerializer::kOnlyNodes);
|
||||
ProjectSerializer::SaveData sdata(ProjectSerializer::k_only_nodes);
|
||||
ProjectSerializer::SerializedProperties properties;
|
||||
QVector<Node *> nodes;
|
||||
|
||||
for (NodeParamViewItem *item : selected_nodes_) {
|
||||
Node *n = item->GetNode();
|
||||
Node *n = item->get_node();
|
||||
|
||||
if (!nodes.contains(n)) {
|
||||
nodes.append(n);
|
||||
|
||||
Node::Position pos =
|
||||
item->GetContext()->GetNodePositionDataInContext(n);
|
||||
item->get_context()->get_node_position_data_in_context(n);
|
||||
|
||||
properties[n][QStringLiteral("x")] =
|
||||
QString::number(pos.position.x());
|
||||
@@ -610,10 +610,10 @@ bool NodeParamView::CopySelected(bool cut)
|
||||
}
|
||||
}
|
||||
|
||||
sdata.SetOnlySerializeNodesAndResolveGroups(nodes);
|
||||
sdata.SetProperties(properties);
|
||||
sdata.set_only_serialize_nodes_and_resolve_groups(nodes);
|
||||
sdata.set_properties(properties);
|
||||
|
||||
ProjectSerializer::Copy(sdata);
|
||||
ProjectSerializer::copy(sdata);
|
||||
|
||||
if (cut) {
|
||||
DeleteSelected();
|
||||
@@ -622,34 +622,34 @@ bool NodeParamView::CopySelected(bool cut)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NodeParamView::Paste()
|
||||
bool NodeParamView::paste()
|
||||
{
|
||||
if (keyframe_view_) {
|
||||
if (keyframe_view_->Paste(std::bind(&NodeParamView::GetNodeWithID, this,
|
||||
if (keyframe_view_->paste(std::bind(&NodeParamView::get_node_with_id, this,
|
||||
std::placeholders::_1))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return Paste(this, std::bind(&NodeParamView::GenerateExistingPasteMap, this,
|
||||
return paste(this, std::bind(&NodeParamView::generate_existing_paste_map, this,
|
||||
std::placeholders::_1));
|
||||
}
|
||||
|
||||
bool NodeParamView::Paste(
|
||||
bool NodeParamView::paste(
|
||||
QWidget *parent,
|
||||
std::function<QHash<Node *, Node *>(const ProjectSerializer::Result &)>
|
||||
get_existing_map_function)
|
||||
{
|
||||
ProjectSerializer::Result res =
|
||||
ProjectSerializer::Paste(ProjectSerializer::kOnlyNodes);
|
||||
if (res.GetLoadData().nodes.isEmpty()) {
|
||||
ProjectSerializer::paste(ProjectSerializer::k_only_nodes);
|
||||
if (res.get_load_data().nodes.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Determine if any nodes of this type are already in the editor
|
||||
QHash<Node *, Node *> existing_nodes = get_existing_map_function(res);
|
||||
|
||||
QVector<Node *> nodes_to_paste_as_new = res.GetLoadData().nodes;
|
||||
QVector<Node *> nodes_to_paste_as_new = res.get_load_data().nodes;
|
||||
MultiUndoCommand *command = new MultiUndoCommand();
|
||||
|
||||
if (!existing_nodes.empty()) {
|
||||
@@ -659,7 +659,7 @@ bool NodeParamView::Paste(
|
||||
QStringList node_names;
|
||||
for (auto it = existing_nodes.cbegin(); it != existing_nodes.cend();
|
||||
it++) {
|
||||
node_names.append(it.key()->GetLabelAndName());
|
||||
node_names.append(it.key()->get_label_and_name());
|
||||
}
|
||||
|
||||
b.setText(
|
||||
@@ -685,7 +685,7 @@ bool NodeParamView::Paste(
|
||||
// Filter out existing nodes
|
||||
for (auto it = existing_nodes.cbegin(); it != existing_nodes.cend();
|
||||
it++) {
|
||||
Node::CopyInputs(it.value(), it.key(), false, command);
|
||||
Node::copy_inputs(it.value(), it.key(), false, command);
|
||||
nodes_to_paste_as_new.removeOne(it.value());
|
||||
}
|
||||
}
|
||||
@@ -694,8 +694,8 @@ bool NodeParamView::Paste(
|
||||
if (!nodes_to_paste_as_new.isEmpty()) {
|
||||
Node::PositionMap map;
|
||||
|
||||
for (auto it = res.GetLoadData().properties.cbegin();
|
||||
it != res.GetLoadData().properties.cend(); it++) {
|
||||
for (auto it = res.get_load_data().properties.cbegin();
|
||||
it != res.get_load_data().properties.cend(); it++) {
|
||||
if (nodes_to_paste_as_new.contains(it.key())) {
|
||||
Node::Position pos;
|
||||
|
||||
@@ -718,106 +718,106 @@ bool NodeParamView::Paste(
|
||||
return true;
|
||||
}
|
||||
|
||||
void NodeParamView::QueueKeyframePositionUpdate()
|
||||
void NodeParamView::queue_keyframe_position_update()
|
||||
{
|
||||
QMetaObject::invokeMethod(this, &NodeParamView::UpdateElementY,
|
||||
QMetaObject::invokeMethod(this, &NodeParamView::update_element_y,
|
||||
Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
void NodeParamView::AddContext(Node *ctx)
|
||||
void NodeParamView::add_context(Node *ctx)
|
||||
{
|
||||
NodeParamViewContext *item = GetContextItemFromContext(ctx);
|
||||
NodeParamViewContext *item = get_context_item_from_context(ctx);
|
||||
|
||||
// TEMP: Creating many NPV items is EXTREMELY slow so limit to one item per context for now.
|
||||
// I have a better solution in the works to use one UI for several nodes, but I haven't
|
||||
// done it yet, and this can severely affect productivity.
|
||||
if (item->GetContexts().size() == 1) {
|
||||
if (item->get_contexts().size() == 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Queued so that if any further work is done in connecting this node to the context, it'll be
|
||||
// done before our sorting function is called
|
||||
connect(ctx, &Node::NodeAddedToContext, this,
|
||||
&NodeParamView::NodeAddedToContext, Qt::QueuedConnection);
|
||||
connect(ctx, &Node::NodeRemovedFromContext, this,
|
||||
&NodeParamView::NodeRemovedFromContext, Qt::QueuedConnection);
|
||||
connect(ctx, &Node::node_added_to_context, this,
|
||||
&NodeParamView::node_added_to_context, Qt::QueuedConnection);
|
||||
connect(ctx, &Node::node_removed_from_context, this,
|
||||
&NodeParamView::node_removed_from_context, Qt::QueuedConnection);
|
||||
|
||||
item->AddContext(ctx);
|
||||
item->add_context(ctx);
|
||||
item->setVisible(true);
|
||||
|
||||
for (auto it = ctx->GetContextPositions().cbegin();
|
||||
it != ctx->GetContextPositions().cend(); it++) {
|
||||
AddNode(it.key(), ctx, item);
|
||||
for (auto it = ctx->get_context_positions().cbegin();
|
||||
it != ctx->get_context_positions().cend(); it++) {
|
||||
add_node(it.key(), ctx, item);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamView::RemoveContext(Node *ctx)
|
||||
void NodeParamView::remove_context(Node *ctx)
|
||||
{
|
||||
disconnect(ctx, &Node::NodeAddedToContext, this,
|
||||
&NodeParamView::NodeAddedToContext);
|
||||
disconnect(ctx, &Node::NodeRemovedFromContext, this,
|
||||
&NodeParamView::NodeRemovedFromContext);
|
||||
disconnect(ctx, &Node::node_added_to_context, this,
|
||||
&NodeParamView::node_added_to_context);
|
||||
disconnect(ctx, &Node::node_removed_from_context, this,
|
||||
&NodeParamView::node_removed_from_context);
|
||||
|
||||
foreach (NodeParamViewContext *item, context_items_) {
|
||||
item->RemoveContext(ctx);
|
||||
item->RemoveNodesWithContext(ctx);
|
||||
item->remove_context(ctx);
|
||||
item->remove_nodes_with_context(ctx);
|
||||
|
||||
if (item->GetContexts().isEmpty()) {
|
||||
if (item->get_contexts().isEmpty()) {
|
||||
item->setVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamView::AddNode(Node *n, Node *ctx, NodeParamViewContext *context)
|
||||
void NodeParamView::add_node(Node *n, Node *ctx, NodeParamViewContext *context)
|
||||
{
|
||||
if ((n->GetFlags() & Node::kDontShowInParamView) && !IsGroupMode() &&
|
||||
if ((n->get_flags() & Node::k_dont_show_in_param_view) && !is_group_mode() &&
|
||||
!show_all_nodes_) {
|
||||
return;
|
||||
}
|
||||
|
||||
NodeParamViewItem *item = new NodeParamViewItem(
|
||||
n, IsGroupMode() ? kCheckBoxesOnNonConnected : kNoCheckBoxes,
|
||||
context->GetDockArea());
|
||||
n, is_group_mode() ? k_check_boxes_on_non_connected : k_no_check_boxes,
|
||||
context->get_dock_area());
|
||||
|
||||
connect(item, &NodeParamViewItem::RequestSelectNode, this,
|
||||
&NodeParamView::SelectNodeFromConnectedLink);
|
||||
connect(item, &NodeParamViewItem::PinToggled, this,
|
||||
&NodeParamView::PinNode);
|
||||
connect(item, &NodeParamViewItem::InputCheckedChanged, this,
|
||||
&NodeParamView::InputCheckBoxChanged);
|
||||
connect(item, &NodeParamViewItem::Clicked, this,
|
||||
&NodeParamView::ItemClicked);
|
||||
connect(item, &NodeParamViewItem::RequestEditTextInViewer, this,
|
||||
&NodeParamView::RequestEditTextInViewer);
|
||||
connect(item, &NodeParamViewItem::request_select_node, this,
|
||||
&NodeParamView::select_node_from_connected_link);
|
||||
connect(item, &NodeParamViewItem::pin_toggled, this,
|
||||
&NodeParamView::pin_node);
|
||||
connect(item, &NodeParamViewItem::input_checked_changed, this,
|
||||
&NodeParamView::input_check_box_changed);
|
||||
connect(item, &NodeParamViewItem::clicked, this,
|
||||
&NodeParamView::item_clicked);
|
||||
connect(item, &NodeParamViewItem::request_edit_text_in_viewer, this,
|
||||
&NodeParamView::request_edit_text_in_viewer);
|
||||
|
||||
item->SetContext(ctx);
|
||||
item->SetTimeTarget(GetConnectedNode());
|
||||
item->SetTimebase(timebase());
|
||||
item->set_context(ctx);
|
||||
item->set_time_target(get_connected_node());
|
||||
item->set_timebase(timebase());
|
||||
|
||||
context->AddNode(item);
|
||||
context->add_node(item);
|
||||
|
||||
if (!focused_node_ && n->HasGizmos()) {
|
||||
if (!focused_node_ && n->has_gizmos()) {
|
||||
// We'll focus this node now
|
||||
SetSelectedNodes({ item });
|
||||
set_selected_nodes({ item });
|
||||
}
|
||||
|
||||
if (keyframe_view_) {
|
||||
connect(item, &NodeParamViewItem::dockLocationChanged, this,
|
||||
&NodeParamView::QueueKeyframePositionUpdate);
|
||||
connect(item, &NodeParamViewItem::ArrayExpandedChanged, this,
|
||||
&NodeParamView::QueueKeyframePositionUpdate);
|
||||
connect(item, &NodeParamViewItem::ExpandedChanged, this,
|
||||
&NodeParamView::QueueKeyframePositionUpdate);
|
||||
connect(item, &NodeParamViewItem::Moved, this,
|
||||
&NodeParamView::QueueKeyframePositionUpdate);
|
||||
connect(item, &NodeParamViewItem::InputArraySizeChanged, this,
|
||||
&NodeParamView::InputArraySizeChanged);
|
||||
&NodeParamView::queue_keyframe_position_update);
|
||||
connect(item, &NodeParamViewItem::array_expanded_changed, this,
|
||||
&NodeParamView::queue_keyframe_position_update);
|
||||
connect(item, &NodeParamViewItem::expanded_changed, this,
|
||||
&NodeParamView::queue_keyframe_position_update);
|
||||
connect(item, &NodeParamViewItem::moved, this,
|
||||
&NodeParamView::queue_keyframe_position_update);
|
||||
connect(item, &NodeParamViewItem::input_array_size_changed, this,
|
||||
&NodeParamView::input_array_size_changed);
|
||||
|
||||
item->SetKeyframeConnections(keyframe_view_->AddKeyframesOfNode(n));
|
||||
item->set_keyframe_connections(keyframe_view_->add_keyframes_of_node(n));
|
||||
}
|
||||
}
|
||||
|
||||
int GetDistanceBetweenNodes(Node *start, Node *end)
|
||||
int get_distance_between_nodes(Node *start, Node *end)
|
||||
{
|
||||
if (start == end) {
|
||||
return 0;
|
||||
@@ -825,7 +825,7 @@ int GetDistanceBetweenNodes(Node *start, Node *end)
|
||||
|
||||
for (auto it = start->input_connections().cbegin();
|
||||
it != start->input_connections().cend(); it++) {
|
||||
int this_node_dist = GetDistanceBetweenNodes(it->second, end);
|
||||
int this_node_dist = get_distance_between_nodes(it->second, end);
|
||||
if (this_node_dist != -1) {
|
||||
return 1 + this_node_dist;
|
||||
}
|
||||
@@ -834,18 +834,18 @@ int GetDistanceBetweenNodes(Node *start, Node *end)
|
||||
return -1;
|
||||
}
|
||||
|
||||
void NodeParamView::SortItemsInContext(NodeParamViewContext *context_item)
|
||||
void NodeParamView::sort_items_in_context(NodeParamViewContext *context_item)
|
||||
{
|
||||
QVector<QPair<NodeParamViewItem *, int>> distances;
|
||||
|
||||
for (auto it = context_item->GetItems().cbegin();
|
||||
it != context_item->GetItems().cend(); it++) {
|
||||
for (auto it = context_item->get_items().cbegin();
|
||||
it != context_item->get_items().cend(); it++) {
|
||||
NodeParamViewItem *item = *it;
|
||||
|
||||
int distance = -1;
|
||||
foreach (Node *ctx, context_item->GetContexts()) {
|
||||
foreach (Node *ctx, context_item->get_contexts()) {
|
||||
distance =
|
||||
qMax(distance, GetDistanceBetweenNodes(ctx, item->GetNode()));
|
||||
qMax(distance, get_distance_between_nodes(ctx, item->get_node()));
|
||||
}
|
||||
|
||||
if (distance == -1) {
|
||||
@@ -869,22 +869,22 @@ void NodeParamView::SortItemsInContext(NodeParamViewContext *context_item)
|
||||
}
|
||||
|
||||
foreach (auto info, distances) {
|
||||
context_item->GetDockArea()->AddItem(info.first);
|
||||
context_item->get_dock_area()->add_item(info.first);
|
||||
}
|
||||
}
|
||||
|
||||
NodeParamViewContext *NodeParamView::GetContextItemFromContext(Node *ctx)
|
||||
NodeParamViewContext *NodeParamView::get_context_item_from_context(Node *ctx)
|
||||
{
|
||||
Track::Type ctx_type = Track::kCount;
|
||||
Track::Type ctx_type = Track::k_count;
|
||||
|
||||
if (ClipBlock *clip = dynamic_cast<ClipBlock *>(ctx)) {
|
||||
if (clip->track()) {
|
||||
if (clip->track()->type() != Track::kNone) {
|
||||
if (clip->track()->type() != Track::k_none) {
|
||||
ctx_type = clip->track()->type();
|
||||
}
|
||||
}
|
||||
} else if (Track *track = dynamic_cast<Track *>(ctx)) {
|
||||
if (track->type() != Track::kNone) {
|
||||
if (track->type() != Track::k_none) {
|
||||
ctx_type = track->type();
|
||||
}
|
||||
}
|
||||
@@ -892,7 +892,7 @@ NodeParamViewContext *NodeParamView::GetContextItemFromContext(Node *ctx)
|
||||
return context_items_.at(ctx_type);
|
||||
}
|
||||
|
||||
void NodeParamView::ToggleSelect(NodeParamViewItem *item)
|
||||
void NodeParamView::toggle_select(NodeParamViewItem *item)
|
||||
{
|
||||
QVector<NodeParamViewItem *> new_sel;
|
||||
|
||||
@@ -904,31 +904,31 @@ void NodeParamView::ToggleSelect(NodeParamViewItem *item)
|
||||
// De-select this node
|
||||
if (qApp->keyboardModifiers() & Qt::ShiftModifier) {
|
||||
new_sel.removeOne(item);
|
||||
SetSelectedNodes(new_sel, true);
|
||||
set_selected_nodes(new_sel, true);
|
||||
}
|
||||
} else {
|
||||
new_sel.append(item);
|
||||
SetSelectedNodes(new_sel, false);
|
||||
set_selected_nodes(new_sel, false);
|
||||
|
||||
if (!new_sel.contains(focused_node_)) {
|
||||
// This node gets sent to both the curve editor and viewer, so we focus it even if it has
|
||||
// no gizmos
|
||||
focused_node_ = item;
|
||||
|
||||
emit FocusedNodeChanged(focused_node_ ? focused_node_->GetNode() :
|
||||
emit focused_node_changed(focused_node_ ? focused_node_->get_node() :
|
||||
nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QHash<Node *, Node *>
|
||||
NodeParamView::GenerateExistingPasteMap(const ProjectSerializer::Result &r)
|
||||
NodeParamView::generate_existing_paste_map(const ProjectSerializer::Result &r)
|
||||
{
|
||||
QVector<Node *> ignore_nodes;
|
||||
QHash<Node *, Node *> existing_nodes;
|
||||
for (Node *n : r.GetLoadData().nodes) {
|
||||
for (Node *n : r.get_load_data().nodes) {
|
||||
if (Node *existing =
|
||||
GetNodeWithIDAndIgnoreList(n->id(), ignore_nodes)) {
|
||||
get_node_with_id_and_ignore_list(n->id(), ignore_nodes)) {
|
||||
existing_nodes.insert(existing, n);
|
||||
ignore_nodes.append(existing);
|
||||
}
|
||||
@@ -936,18 +936,18 @@ NodeParamView::GenerateExistingPasteMap(const ProjectSerializer::Result &r)
|
||||
return existing_nodes;
|
||||
}
|
||||
|
||||
void NodeParamView::UpdateGlobalScrollBar()
|
||||
void NodeParamView::update_global_scroll_bar()
|
||||
{
|
||||
if (keyframe_view_) {
|
||||
keyframe_view_->SetMaxScroll(param_widget_container_->height() -
|
||||
keyframe_view_->set_max_scroll(param_widget_container_->height() -
|
||||
ruler()->height());
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamView::PinNode(bool pin)
|
||||
void NodeParamView::pin_node(bool pin)
|
||||
{
|
||||
NodeParamViewItem *item = static_cast<NodeParamViewItem *>(sender());
|
||||
Node *node = item->GetNode();
|
||||
Node *node = item->get_node();
|
||||
|
||||
if (pin) {
|
||||
pinned_nodes_.append(node);
|
||||
@@ -991,27 +991,27 @@ void NodeParamView::PinNode(bool pin)
|
||||
}
|
||||
}*/
|
||||
|
||||
void NodeParamView::UpdateElementY()
|
||||
void NodeParamView::update_element_y()
|
||||
{
|
||||
for (NodeParamViewContext *ctx : context_items_) {
|
||||
for (auto it = ctx->GetItems().cbegin(); it != ctx->GetItems().cend();
|
||||
for (auto it = ctx->get_items().cbegin(); it != ctx->get_items().cend();
|
||||
it++) {
|
||||
NodeParamViewItem *item = *it;
|
||||
Node *node = item->GetNode();
|
||||
Node *node = item->get_node();
|
||||
const KeyframeView::NodeConnections &connections =
|
||||
item->GetKeyframeConnections();
|
||||
item->get_keyframe_connections();
|
||||
|
||||
if (!connections.isEmpty()) {
|
||||
for (const QString &input : node->inputs()) {
|
||||
if (!(node->GetInputFlags(input) & kInputFlagHidden)) {
|
||||
if (!(node->get_input_flags(input) & k_input_flag_hidden)) {
|
||||
int arr_sz =
|
||||
NodeGroup::ResolveInput(NodeInput(node, input))
|
||||
.GetArraySize();
|
||||
NodeGroup::resolve_input(NodeInput(node, input))
|
||||
.get_array_size();
|
||||
|
||||
for (int i = -1; i < arr_sz; i++) {
|
||||
NodeInput ic = { node, input, i };
|
||||
|
||||
int y = item->GetElementY(ic);
|
||||
int y = item->get_element_y(ic);
|
||||
|
||||
// For some reason Qt's mapToGlobal doesn't seem to handle this, so we offset here
|
||||
y += vertical_scrollbar_->value();
|
||||
@@ -1024,7 +1024,7 @@ void NodeParamView::UpdateElementY()
|
||||
input_con.at(ic.element() + 1);
|
||||
for (KeyframeViewInputConnection *track :
|
||||
ele_con) {
|
||||
track->SetKeyframeY(y);
|
||||
track->set_keyframe_y(y);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1035,68 +1035,68 @@ void NodeParamView::UpdateElementY()
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamView::NodeAddedToContext(Node *n)
|
||||
void NodeParamView::node_added_to_context(Node *n)
|
||||
{
|
||||
Node *ctx = static_cast<Node *>(sender());
|
||||
NodeParamViewContext *item = GetContextItemFromContext(ctx);
|
||||
NodeParamViewContext *item = get_context_item_from_context(ctx);
|
||||
|
||||
AddNode(n, ctx, item);
|
||||
add_node(n, ctx, item);
|
||||
|
||||
SortItemsInContext(item);
|
||||
sort_items_in_context(item);
|
||||
|
||||
if (keyframe_view_) {
|
||||
QueueKeyframePositionUpdate();
|
||||
queue_keyframe_position_update();
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamView::NodeRemovedFromContext(Node *n)
|
||||
void NodeParamView::node_removed_from_context(Node *n)
|
||||
{
|
||||
Node *ctx = static_cast<Node *>(sender());
|
||||
|
||||
foreach (NodeParamViewContext *ctx_item, context_items_) {
|
||||
ctx_item->RemoveNode(n, ctx);
|
||||
ctx_item->remove_node(n, ctx);
|
||||
}
|
||||
|
||||
if (keyframe_view_) {
|
||||
QueueKeyframePositionUpdate();
|
||||
queue_keyframe_position_update();
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamView::InputCheckBoxChanged(const NodeInput &input, bool e)
|
||||
void NodeParamView::input_check_box_changed(const NodeInput &input, bool e)
|
||||
{
|
||||
NodeGroup *group = static_cast<NodeGroup *>(contexts_.first());
|
||||
|
||||
if (e) {
|
||||
group->AddInputPassthrough(input);
|
||||
group->add_input_passthrough(input);
|
||||
} else {
|
||||
group->RemoveInputPassthrough(input);
|
||||
group->remove_input_passthrough(input);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamView::GroupInputPassthroughAdded(NodeGroup *group,
|
||||
void NodeParamView::group_input_passthrough_added(NodeGroup *group,
|
||||
const NodeInput &input)
|
||||
{
|
||||
foreach (NodeParamViewContext *pvctx, context_items_) {
|
||||
pvctx->SetInputChecked(input, true);
|
||||
pvctx->set_input_checked(input, true);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamView::GroupInputPassthroughRemoved(NodeGroup *group,
|
||||
void NodeParamView::group_input_passthrough_removed(NodeGroup *group,
|
||||
const NodeInput &input)
|
||||
{
|
||||
foreach (NodeParamViewContext *pvctx, context_items_) {
|
||||
pvctx->SetInputChecked(input, false);
|
||||
pvctx->set_input_checked(input, false);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamView::InputArraySizeChanged(const QString &input, int,
|
||||
void NodeParamView::input_array_size_changed(const QString &input, int,
|
||||
int new_size)
|
||||
{
|
||||
NodeParamViewItem *sender =
|
||||
static_cast<NodeParamViewItem *>(this->sender());
|
||||
|
||||
KeyframeView::NodeConnections &connections =
|
||||
sender->GetKeyframeConnections();
|
||||
sender->get_keyframe_connections();
|
||||
KeyframeView::InputConnections &inputs = connections[input];
|
||||
|
||||
int adj_new_size = new_size + 1;
|
||||
@@ -1107,7 +1107,7 @@ void NodeParamView::InputArraySizeChanged(const QString &input, int,
|
||||
for (int i = adj_new_size; i < inputs.size(); i++) {
|
||||
const KeyframeView::ElementConnections &ec = inputs.at(i);
|
||||
for (auto kc : ec) {
|
||||
keyframe_view_->RemoveKeyframesOfTrack(kc);
|
||||
keyframe_view_->remove_keyframes_of_track(kc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1122,13 +1122,13 @@ void NodeParamView::InputArraySizeChanged(const QString &input, int,
|
||||
|
||||
// Fill in extra elements
|
||||
for (int i = old_size; i < inputs.size(); i++) {
|
||||
inputs[i] = keyframe_view_->AddKeyframesOfElement(
|
||||
NodeInput(sender->GetNode(), input, i - 1));
|
||||
inputs[i] = keyframe_view_->add_keyframes_of_element(
|
||||
NodeInput(sender->get_node(), input, i - 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QueueKeyframePositionUpdate();
|
||||
queue_keyframe_position_update();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NODEPARAMVIEW_H
|
||||
#define NODEPARAMVIEW_H
|
||||
#ifndef OAK_NODEPARAMVIEW_H
|
||||
#define OAK_NODEPARAMVIEW_H
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidget>
|
||||
@@ -48,104 +48,104 @@ public:
|
||||
|
||||
virtual ~NodeParamView() override;
|
||||
|
||||
void CloseContextsBelongingToProject(Project *p);
|
||||
void close_contexts_belonging_to_project(Project *p);
|
||||
|
||||
void DeleteSelected();
|
||||
|
||||
void SelectAll()
|
||||
void select_all()
|
||||
{
|
||||
keyframe_view_->SelectAll();
|
||||
keyframe_view_->select_all();
|
||||
}
|
||||
|
||||
void DeselectAll()
|
||||
void deselect_all()
|
||||
{
|
||||
keyframe_view_->DeselectAll();
|
||||
keyframe_view_->deselect_all();
|
||||
}
|
||||
|
||||
void SetSelectedNodes(const QVector<NodeParamViewItem *> &nodes,
|
||||
void set_selected_nodes(const QVector<NodeParamViewItem *> &nodes,
|
||||
bool handle_focused_node = true,
|
||||
bool emit_signal = true);
|
||||
void SetSelectedNodes(const QVector<Node::ContextPair> &nodes,
|
||||
void set_selected_nodes(const QVector<Node::ContextPair> &nodes,
|
||||
bool emit_signal = true);
|
||||
|
||||
Node *GetNodeWithID(const QString &id);
|
||||
Node *GetNodeWithIDAndIgnoreList(const QString &id,
|
||||
Node *get_node_with_id(const QString &id);
|
||||
Node *get_node_with_id_and_ignore_list(const QString &id,
|
||||
const QVector<Node *> &ignore);
|
||||
|
||||
const QVector<Node *> &GetContexts() const
|
||||
const QVector<Node *> &get_contexts() const
|
||||
{
|
||||
return contexts_;
|
||||
}
|
||||
|
||||
virtual bool CopySelected(bool cut) override;
|
||||
virtual bool copy_selected(bool cut) override;
|
||||
|
||||
virtual bool Paste() override;
|
||||
static bool Paste(
|
||||
virtual bool paste() override;
|
||||
static bool paste(
|
||||
QWidget *parent,
|
||||
std::function<QHash<Node *, Node *>(const ProjectSerializer::Result &)>
|
||||
get_existing_map_function);
|
||||
|
||||
public slots:
|
||||
void SetContexts(const QVector<Node *> &contexts);
|
||||
void set_contexts(const QVector<Node *> &contexts);
|
||||
|
||||
void UpdateElementY();
|
||||
void update_element_y();
|
||||
|
||||
signals:
|
||||
void FocusedNodeChanged(Node *n);
|
||||
void focused_node_changed(Node *n);
|
||||
|
||||
void SelectedNodesChanged(const QVector<Node::ContextPair> &nodes);
|
||||
void selected_nodes_changed(const QVector<Node::ContextPair> &nodes);
|
||||
|
||||
void RequestViewerToStartEditingText();
|
||||
void request_viewer_to_start_editing_text();
|
||||
|
||||
protected:
|
||||
virtual void resizeEvent(QResizeEvent *event) override;
|
||||
|
||||
virtual void ScaleChangedEvent(const double &) override;
|
||||
virtual void TimebaseChangedEvent(const rational &) override;
|
||||
virtual void TimebaseChangedEvent(const Rational &) override;
|
||||
|
||||
virtual void ConnectedNodeChangeEvent(ViewerOutput *n) override;
|
||||
|
||||
virtual const QVector<KeyframeViewInputConnection *> *
|
||||
GetSnapKeyframes() const override
|
||||
get_snap_keyframes() const override
|
||||
{
|
||||
return keyframe_view_ ? &keyframe_view_->GetKeyframeTracks() : nullptr;
|
||||
return keyframe_view_ ? &keyframe_view_->get_keyframe_tracks() : nullptr;
|
||||
}
|
||||
|
||||
virtual const std::vector<NodeKeyframe *> *
|
||||
GetSnapIgnoreKeyframes() const override
|
||||
get_snap_ignore_keyframes() const override
|
||||
{
|
||||
return keyframe_view_ ? &keyframe_view_->GetSelectedKeyframes() :
|
||||
return keyframe_view_ ? &keyframe_view_->get_selected_keyframes() :
|
||||
nullptr;
|
||||
}
|
||||
|
||||
virtual const TimeTargetObject *GetKeyframeTimeTarget() const override
|
||||
virtual const TimeTargetObject *get_keyframe_time_target() const override
|
||||
{
|
||||
return keyframe_view_;
|
||||
}
|
||||
|
||||
private:
|
||||
void QueueKeyframePositionUpdate();
|
||||
void queue_keyframe_position_update();
|
||||
|
||||
void AddContext(Node *context);
|
||||
void add_context(Node *context);
|
||||
|
||||
void RemoveContext(Node *context);
|
||||
void remove_context(Node *context);
|
||||
|
||||
void AddNode(Node *n, Node *ctx, NodeParamViewContext *context);
|
||||
void add_node(Node *n, Node *ctx, NodeParamViewContext *context);
|
||||
|
||||
void SortItemsInContext(NodeParamViewContext *context);
|
||||
void sort_items_in_context(NodeParamViewContext *context);
|
||||
|
||||
NodeParamViewContext *GetContextItemFromContext(Node *context);
|
||||
NodeParamViewContext *get_context_item_from_context(Node *context);
|
||||
|
||||
bool IsGroupMode() const
|
||||
bool is_group_mode() const
|
||||
{
|
||||
return contexts_.size() == 1 &&
|
||||
dynamic_cast<NodeGroup *>(contexts_.first());
|
||||
}
|
||||
|
||||
void ToggleSelect(NodeParamViewItem *item);
|
||||
void toggle_select(NodeParamViewItem *item);
|
||||
|
||||
QHash<Node *, Node *>
|
||||
GenerateExistingPasteMap(const ProjectSerializer::Result &r);
|
||||
generate_existing_paste_map(const ProjectSerializer::Result &r);
|
||||
|
||||
KeyframeView *keyframe_view_;
|
||||
|
||||
@@ -174,38 +174,38 @@ private:
|
||||
bool show_all_nodes_;
|
||||
|
||||
private slots:
|
||||
void UpdateGlobalScrollBar();
|
||||
void update_global_scroll_bar();
|
||||
|
||||
void PinNode(bool pin);
|
||||
void pin_node(bool pin);
|
||||
|
||||
//void FocusChanged(QWidget *old, QWidget *now);
|
||||
|
||||
void NodeAddedToContext(Node *n);
|
||||
void node_added_to_context(Node *n);
|
||||
|
||||
void NodeRemovedFromContext(Node *n);
|
||||
void node_removed_from_context(Node *n);
|
||||
|
||||
void InputCheckBoxChanged(const NodeInput &input, bool e);
|
||||
void input_check_box_changed(const NodeInput &input, bool e);
|
||||
|
||||
void GroupInputPassthroughAdded(olive::NodeGroup *group,
|
||||
void group_input_passthrough_added(olive::NodeGroup *group,
|
||||
const olive::NodeInput &input);
|
||||
|
||||
void GroupInputPassthroughRemoved(olive::NodeGroup *group,
|
||||
void group_input_passthrough_removed(olive::NodeGroup *group,
|
||||
const olive::NodeInput &input);
|
||||
|
||||
void UpdateContexts();
|
||||
void update_contexts();
|
||||
|
||||
void ItemAboutToBeRemoved(NodeParamViewItem *item);
|
||||
void item_about_to_be_removed(NodeParamViewItem *item);
|
||||
|
||||
void ItemClicked();
|
||||
void item_clicked();
|
||||
|
||||
void SelectNodeFromConnectedLink(Node *node);
|
||||
void select_node_from_connected_link(Node *node);
|
||||
|
||||
void RequestEditTextInViewer();
|
||||
void request_edit_text_in_viewer();
|
||||
|
||||
void InputArraySizeChanged(const QString &input, int old_size,
|
||||
void input_array_size_changed(const QString &input, int old_size,
|
||||
int new_size);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEPARAMVIEW_H
|
||||
#endif // OAK_NODEPARAMVIEW_H
|
||||
|
||||
@@ -41,20 +41,20 @@ NodeParamViewArrayWidget::NodeParamViewArrayWidget(Node *node,
|
||||
count_lbl_ = new QLabel();
|
||||
layout->addWidget(count_lbl_);
|
||||
|
||||
connect(node_, &Node::InputArraySizeChanged, this,
|
||||
&NodeParamViewArrayWidget::UpdateCounter);
|
||||
connect(node_, &Node::input_array_size_changed, this,
|
||||
&NodeParamViewArrayWidget::update_counter);
|
||||
|
||||
UpdateCounter(input_, 0, node_->InputArraySize(input_));
|
||||
update_counter(input_, 0, node_->input_array_size(input_));
|
||||
}
|
||||
|
||||
void NodeParamViewArrayWidget::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
{
|
||||
QWidget::mouseDoubleClickEvent(event);
|
||||
|
||||
emit DoubleClicked();
|
||||
emit double_clicked();
|
||||
}
|
||||
|
||||
void NodeParamViewArrayWidget::UpdateCounter(const QString &input, int old_size,
|
||||
void NodeParamViewArrayWidget::update_counter(const QString &input, int old_size,
|
||||
int new_size)
|
||||
{
|
||||
Q_UNUSED(old_size)
|
||||
@@ -68,7 +68,7 @@ NodeParamViewArrayButton::NodeParamViewArrayButton(
|
||||
: QPushButton(parent)
|
||||
, type_(type)
|
||||
{
|
||||
Retranslate();
|
||||
retranslate();
|
||||
|
||||
int sz = sizeHint().height() / 3 * 2;
|
||||
setFixedSize(sz, sz);
|
||||
@@ -77,15 +77,15 @@ NodeParamViewArrayButton::NodeParamViewArrayButton(
|
||||
void NodeParamViewArrayButton::changeEvent(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::LanguageChange) {
|
||||
Retranslate();
|
||||
retranslate();
|
||||
}
|
||||
|
||||
QPushButton::changeEvent(event);
|
||||
}
|
||||
|
||||
void NodeParamViewArrayButton::Retranslate()
|
||||
void NodeParamViewArrayButton::retranslate()
|
||||
{
|
||||
if (type_ == kAdd) {
|
||||
if (type_ == k_add) {
|
||||
setText(tr("+"));
|
||||
} else {
|
||||
setText(tr("-"));
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NODEPARAMVIEWARRAYWIDGET_H
|
||||
#define NODEPARAMVIEWARRAYWIDGET_H
|
||||
#ifndef OAK_NODEPARAMVIEWARRAYWIDGET_H
|
||||
#define OAK_NODEPARAMVIEWARRAYWIDGET_H
|
||||
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
@@ -34,7 +34,7 @@ namespace olive
|
||||
class NodeParamViewArrayButton : public QPushButton {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Type { kAdd, kRemove };
|
||||
enum Type { k_add, k_remove };
|
||||
|
||||
NodeParamViewArrayButton(Type type, QWidget *parent = nullptr);
|
||||
|
||||
@@ -42,7 +42,7 @@ protected:
|
||||
virtual void changeEvent(QEvent *event) override;
|
||||
|
||||
private:
|
||||
void Retranslate();
|
||||
void retranslate();
|
||||
|
||||
Type type_;
|
||||
};
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
QWidget *parent = nullptr);
|
||||
|
||||
signals:
|
||||
void DoubleClicked();
|
||||
void double_clicked();
|
||||
|
||||
protected:
|
||||
virtual void mouseDoubleClickEvent(QMouseEvent *event) override;
|
||||
@@ -67,9 +67,9 @@ private:
|
||||
QLabel *count_lbl_;
|
||||
|
||||
private slots:
|
||||
void UpdateCounter(const QString &input, int old_size, int new_size);
|
||||
void update_counter(const QString &input, int old_size, int new_size);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEPARAMVIEWARRAYWIDGET_H
|
||||
#endif // OAK_NODEPARAMVIEWARRAYWIDGET_H
|
||||
|
||||
@@ -51,7 +51,7 @@ NodeParamViewConnectedLabel::NodeParamViewConnectedLabel(const NodeInput &input,
|
||||
// Set up label area
|
||||
QHBoxLayout *label_layout = new QHBoxLayout();
|
||||
label_layout->setSpacing(
|
||||
QtUtils::QFontMetricsWidth(fontMetrics(), QStringLiteral(" ")));
|
||||
QtUtils::q_font_metrics_width(fontMetrics(), QStringLiteral(" ")));
|
||||
label_layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->addLayout(label_layout);
|
||||
|
||||
@@ -64,10 +64,10 @@ NodeParamViewConnectedLabel::NodeParamViewConnectedLabel(const NodeInput &input,
|
||||
connected_to_lbl_ = new ClickableLabel(this);
|
||||
connected_to_lbl_->setCursor(Qt::PointingHandCursor);
|
||||
connected_to_lbl_->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(connected_to_lbl_, &ClickableLabel::MouseClicked, this,
|
||||
&NodeParamViewConnectedLabel::ConnectionClicked);
|
||||
connect(connected_to_lbl_, &ClickableLabel::mouse_clicked, this,
|
||||
&NodeParamViewConnectedLabel::connection_clicked);
|
||||
connect(connected_to_lbl_, &ClickableLabel::customContextMenuRequested,
|
||||
this, &NodeParamViewConnectedLabel::ShowLabelContextMenu);
|
||||
this, &NodeParamViewConnectedLabel::show_label_context_menu);
|
||||
label_layout->addWidget(connected_to_lbl_);
|
||||
|
||||
label_layout->addStretch();
|
||||
@@ -78,47 +78,47 @@ NodeParamViewConnectedLabel::NodeParamViewConnectedLabel(const NodeInput &input,
|
||||
connected_to_lbl_->setForegroundRole(QPalette::Link);
|
||||
connected_to_lbl_->setFont(link_font);
|
||||
|
||||
if (input_.IsConnected()) {
|
||||
InputConnected(input_.GetConnectedOutput(), input_);
|
||||
if (input_.is_connected()) {
|
||||
input_connected(input_.get_connected_output(), input_);
|
||||
} else {
|
||||
InputDisconnected(nullptr, input_);
|
||||
input_disconnected(nullptr, input_);
|
||||
}
|
||||
|
||||
connect(input_.node(), &Node::InputConnected, this,
|
||||
&NodeParamViewConnectedLabel::InputConnected);
|
||||
connect(input_.node(), &Node::InputDisconnected, this,
|
||||
&NodeParamViewConnectedLabel::InputDisconnected);
|
||||
connect(input_.node(), &Node::input_connected, this,
|
||||
&NodeParamViewConnectedLabel::input_connected);
|
||||
connect(input_.node(), &Node::input_disconnected, this,
|
||||
&NodeParamViewConnectedLabel::input_disconnected);
|
||||
|
||||
// Creating the tree is expensive, hold off until the user specifically requests it
|
||||
value_tree_ = nullptr;
|
||||
connect(collapse_btn, &CollapseButton::toggled, this,
|
||||
&NodeParamViewConnectedLabel::SetValueTreeVisible);
|
||||
&NodeParamViewConnectedLabel::set_value_tree_visible);
|
||||
}
|
||||
|
||||
void NodeParamViewConnectedLabel::SetViewerNode(ViewerOutput *viewer)
|
||||
void NodeParamViewConnectedLabel::set_viewer_node(ViewerOutput *viewer)
|
||||
{
|
||||
if (viewer_) {
|
||||
disconnect(viewer_, &ViewerOutput::PlayheadChanged, this,
|
||||
&NodeParamViewConnectedLabel::UpdateValueTree);
|
||||
disconnect(viewer_, &ViewerOutput::playhead_changed, this,
|
||||
&NodeParamViewConnectedLabel::update_value_tree);
|
||||
}
|
||||
|
||||
viewer_ = viewer;
|
||||
|
||||
if (viewer_) {
|
||||
connect(viewer_, &ViewerOutput::PlayheadChanged, this,
|
||||
&NodeParamViewConnectedLabel::UpdateValueTree);
|
||||
UpdateValueTree();
|
||||
connect(viewer_, &ViewerOutput::playhead_changed, this,
|
||||
&NodeParamViewConnectedLabel::update_value_tree);
|
||||
update_value_tree();
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewConnectedLabel::CreateTree()
|
||||
void NodeParamViewConnectedLabel::create_tree()
|
||||
{
|
||||
// Set up table area
|
||||
value_tree_ = new NodeValueTree(this);
|
||||
layout()->addWidget(value_tree_);
|
||||
}
|
||||
|
||||
void NodeParamViewConnectedLabel::InputConnected(Node *output,
|
||||
void NodeParamViewConnectedLabel::input_connected(Node *output,
|
||||
const NodeInput &input)
|
||||
{
|
||||
if (input_ != input) {
|
||||
@@ -127,10 +127,10 @@ void NodeParamViewConnectedLabel::InputConnected(Node *output,
|
||||
|
||||
connected_node_ = output;
|
||||
|
||||
UpdateLabel();
|
||||
update_label();
|
||||
}
|
||||
|
||||
void NodeParamViewConnectedLabel::InputDisconnected(Node *output,
|
||||
void NodeParamViewConnectedLabel::input_disconnected(Node *output,
|
||||
const NodeInput &input)
|
||||
{
|
||||
if (input_ != input) {
|
||||
@@ -141,10 +141,10 @@ void NodeParamViewConnectedLabel::InputDisconnected(Node *output,
|
||||
|
||||
connected_node_ = nullptr;
|
||||
|
||||
UpdateLabel();
|
||||
update_label();
|
||||
}
|
||||
|
||||
void NodeParamViewConnectedLabel::ShowLabelContextMenu()
|
||||
void NodeParamViewConnectedLabel::show_label_context_menu()
|
||||
{
|
||||
Menu m(this);
|
||||
|
||||
@@ -152,25 +152,25 @@ void NodeParamViewConnectedLabel::ShowLabelContextMenu()
|
||||
connect(disconnect_action, &QAction::triggered, this, [this]() {
|
||||
Core::instance()->undo_stack()->push(
|
||||
new NodeEdgeRemoveCommand(connected_node_, input_),
|
||||
Node::GetDisconnectCommandString(connected_node_, input_));
|
||||
Node::get_disconnect_command_string(connected_node_, input_));
|
||||
});
|
||||
|
||||
m.exec(QCursor::pos());
|
||||
}
|
||||
|
||||
void NodeParamViewConnectedLabel::ConnectionClicked()
|
||||
void NodeParamViewConnectedLabel::connection_clicked()
|
||||
{
|
||||
if (connected_node_) {
|
||||
emit RequestSelectNode(connected_node_);
|
||||
emit request_select_node(connected_node_);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewConnectedLabel::UpdateLabel()
|
||||
void NodeParamViewConnectedLabel::update_label()
|
||||
{
|
||||
QString s;
|
||||
|
||||
if (connected_node_) {
|
||||
s = connected_node_->Name();
|
||||
s = connected_node_->name();
|
||||
} else {
|
||||
s = tr("Nothing");
|
||||
}
|
||||
@@ -178,14 +178,14 @@ void NodeParamViewConnectedLabel::UpdateLabel()
|
||||
connected_to_lbl_->setText(s);
|
||||
}
|
||||
|
||||
void NodeParamViewConnectedLabel::UpdateValueTree()
|
||||
void NodeParamViewConnectedLabel::update_value_tree()
|
||||
{
|
||||
if (value_tree_ && viewer_ && value_tree_->isVisible()) {
|
||||
value_tree_->SetNode(input_, viewer_->GetPlayhead());
|
||||
value_tree_->set_node(input_, viewer_->get_playhead());
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewConnectedLabel::SetValueTreeVisible(bool e)
|
||||
void NodeParamViewConnectedLabel::set_value_tree_visible(bool e)
|
||||
{
|
||||
if (value_tree_) {
|
||||
value_tree_->setVisible(e);
|
||||
@@ -193,11 +193,11 @@ void NodeParamViewConnectedLabel::SetValueTreeVisible(bool e)
|
||||
|
||||
if (e) {
|
||||
if (!value_tree_) {
|
||||
CreateTree();
|
||||
create_tree();
|
||||
value_tree_->setVisible(true);
|
||||
}
|
||||
|
||||
UpdateValueTree();
|
||||
update_value_tree();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NODEPARAMVIEWCONNECTEDLABEL_H
|
||||
#define NODEPARAMVIEWCONNECTEDLABEL_H
|
||||
#ifndef OAK_NODEPARAMVIEWCONNECTEDLABEL_H
|
||||
#define OAK_NODEPARAMVIEWCONNECTEDLABEL_H
|
||||
|
||||
#include "node/param.h"
|
||||
#include "widget/clickablelabel/clickablelabel.h"
|
||||
@@ -35,26 +35,26 @@ public:
|
||||
NodeParamViewConnectedLabel(const NodeInput &input,
|
||||
QWidget *parent = nullptr);
|
||||
|
||||
void SetViewerNode(ViewerOutput *viewer);
|
||||
void set_viewer_node(ViewerOutput *viewer);
|
||||
|
||||
signals:
|
||||
void RequestSelectNode(Node *n);
|
||||
void request_select_node(Node *n);
|
||||
|
||||
private slots:
|
||||
void InputConnected(Node *output, const NodeInput &input);
|
||||
void input_connected(Node *output, const NodeInput &input);
|
||||
|
||||
void InputDisconnected(Node *output, const NodeInput &input);
|
||||
void input_disconnected(Node *output, const NodeInput &input);
|
||||
|
||||
void ShowLabelContextMenu();
|
||||
void show_label_context_menu();
|
||||
|
||||
void ConnectionClicked();
|
||||
void connection_clicked();
|
||||
|
||||
private:
|
||||
void UpdateLabel();
|
||||
void update_label();
|
||||
|
||||
void UpdateValueTree();
|
||||
void update_value_tree();
|
||||
|
||||
void CreateTree();
|
||||
void create_tree();
|
||||
|
||||
ClickableLabel *connected_to_lbl_;
|
||||
|
||||
@@ -67,9 +67,9 @@ private:
|
||||
ViewerOutput *viewer_;
|
||||
|
||||
private slots:
|
||||
void SetValueTreeVisible(bool e);
|
||||
void set_value_tree_visible(bool e);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEPARAMVIEWCONNECTEDLABEL_H
|
||||
#endif // OAK_NODEPARAMVIEWCONNECTEDLABEL_H
|
||||
|
||||
@@ -34,29 +34,29 @@ namespace olive
|
||||
|
||||
NodeParamViewContext::NodeParamViewContext(QWidget *parent)
|
||||
: super(parent)
|
||||
, type_(Track::kNone)
|
||||
, type_(Track::k_none)
|
||||
{
|
||||
QWidget *body = new QWidget();
|
||||
QHBoxLayout *body_layout = new QHBoxLayout(body);
|
||||
SetBody(body);
|
||||
set_body(body);
|
||||
|
||||
dock_area_ = new NodeParamViewDockArea();
|
||||
body_layout->addWidget(dock_area_);
|
||||
|
||||
setBackgroundRole(QPalette::Base);
|
||||
|
||||
Retranslate();
|
||||
retranslate();
|
||||
|
||||
connect(title_bar(), &NodeParamViewItemTitleBar::AddEffectButtonClicked,
|
||||
this, &NodeParamViewContext::AddEffectButtonClicked);
|
||||
connect(title_bar(), &NodeParamViewItemTitleBar::add_effect_button_clicked,
|
||||
this, &NodeParamViewContext::add_effect_button_clicked);
|
||||
}
|
||||
|
||||
NodeParamViewItem *NodeParamViewContext::GetItem(Node *node, Node *ctx)
|
||||
NodeParamViewItem *NodeParamViewContext::get_item(Node *node, Node *ctx)
|
||||
{
|
||||
for (auto it = items_.begin(); it != items_.end(); it++) {
|
||||
NodeParamViewItem *item = *it;
|
||||
|
||||
if (item->GetNode() == node && item->GetContext() == ctx) {
|
||||
if (item->get_node() == node && item->get_context() == ctx) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
@@ -64,20 +64,20 @@ NodeParamViewItem *NodeParamViewContext::GetItem(Node *node, Node *ctx)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void NodeParamViewContext::AddNode(NodeParamViewItem *item)
|
||||
void NodeParamViewContext::add_node(NodeParamViewItem *item)
|
||||
{
|
||||
items_.append(item);
|
||||
dock_area_->AddItem(item);
|
||||
dock_area_->add_item(item);
|
||||
}
|
||||
|
||||
void NodeParamViewContext::RemoveNode(Node *node, Node *ctx)
|
||||
void NodeParamViewContext::remove_node(Node *node, Node *ctx)
|
||||
{
|
||||
for (auto it = items_.begin(); it != items_.end();) {
|
||||
NodeParamViewItem *item = *it;
|
||||
|
||||
if (item->GetNode() == node && item->GetContext() == ctx) {
|
||||
emit AboutToDeleteItem(item);
|
||||
dock_area_->RemoveItem(item);
|
||||
if (item->get_node() == node && item->get_context() == ctx) {
|
||||
emit about_to_delete_item(item);
|
||||
dock_area_->remove_item(item);
|
||||
it = items_.erase(it);
|
||||
} else {
|
||||
it++;
|
||||
@@ -85,14 +85,14 @@ void NodeParamViewContext::RemoveNode(Node *node, Node *ctx)
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewContext::RemoveNodesWithContext(Node *ctx)
|
||||
void NodeParamViewContext::remove_nodes_with_context(Node *ctx)
|
||||
{
|
||||
for (auto it = items_.begin(); it != items_.end();) {
|
||||
NodeParamViewItem *item = *it;
|
||||
|
||||
if (item->GetContext() == ctx) {
|
||||
emit AboutToDeleteItem(item);
|
||||
dock_area_->RemoveItem(item);
|
||||
if (item->get_context() == ctx) {
|
||||
emit about_to_delete_item(item);
|
||||
dock_area_->remove_item(item);
|
||||
it = items_.erase(it);
|
||||
} else {
|
||||
it++;
|
||||
@@ -100,72 +100,72 @@ void NodeParamViewContext::RemoveNodesWithContext(Node *ctx)
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewContext::SetInputChecked(const NodeInput &input, bool e)
|
||||
void NodeParamViewContext::set_input_checked(const NodeInput &input, bool e)
|
||||
{
|
||||
foreach (NodeParamViewItem *item, items_) {
|
||||
if (item->GetNode() == input.node()) {
|
||||
item->SetInputChecked(input, e);
|
||||
if (item->get_node() == input.node()) {
|
||||
item->set_input_checked(input, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewContext::SetTimebase(const rational &timebase)
|
||||
void NodeParamViewContext::set_timebase(const Rational &timebase)
|
||||
{
|
||||
foreach (NodeParamViewItem *item, items_) {
|
||||
item->SetTimebase(timebase);
|
||||
item->set_timebase(timebase);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewContext::SetTimeTarget(ViewerOutput *n)
|
||||
void NodeParamViewContext::set_time_target(ViewerOutput *n)
|
||||
{
|
||||
foreach (NodeParamViewItem *item, items_) {
|
||||
item->SetTimeTarget(n);
|
||||
item->set_time_target(n);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewContext::SetEffectType(Track::Type type)
|
||||
void NodeParamViewContext::set_effect_type(Track::Type type)
|
||||
{
|
||||
type_ = type;
|
||||
}
|
||||
|
||||
void NodeParamViewContext::Retranslate()
|
||||
void NodeParamViewContext::retranslate()
|
||||
{
|
||||
}
|
||||
|
||||
void NodeParamViewContext::AddEffectButtonClicked()
|
||||
void NodeParamViewContext::add_effect_button_clicked()
|
||||
{
|
||||
Node::Flag flag = Node::kNone;
|
||||
Node::Flag flag = Node::k_none;
|
||||
|
||||
if (type_ == Track::kVideo) {
|
||||
flag = Node::kVideoEffect;
|
||||
if (type_ == Track::k_video) {
|
||||
flag = Node::k_video_effect;
|
||||
} else {
|
||||
flag = Node::kAudioEffect;
|
||||
flag = Node::k_audio_effect;
|
||||
}
|
||||
|
||||
if (flag == Node::kNone) {
|
||||
if (flag == Node::k_none) {
|
||||
return;
|
||||
}
|
||||
|
||||
Menu *m =
|
||||
NodeFactory::CreateMenu(this, false, Node::kCategoryUnknown, flag);
|
||||
NodeFactory::create_menu(this, false, Node::k_category_unknown, flag);
|
||||
connect(m, &Menu::triggered, this,
|
||||
&NodeParamViewContext::AddEffectMenuItemTriggered);
|
||||
&NodeParamViewContext::add_effect_menu_item_triggered);
|
||||
m->exec(QCursor::pos());
|
||||
delete m;
|
||||
}
|
||||
|
||||
void NodeParamViewContext::AddEffectMenuItemTriggered(QAction *a)
|
||||
void NodeParamViewContext::add_effect_menu_item_triggered(QAction *a)
|
||||
{
|
||||
Node *n = NodeFactory::CreateFromMenuAction(a);
|
||||
|
||||
if (n) {
|
||||
NodeInput new_node_input = n->GetEffectInput();
|
||||
NodeInput new_node_input = n->get_effect_input();
|
||||
MultiUndoCommand *command = new MultiUndoCommand();
|
||||
|
||||
QVector<Project *> graphs_added_to;
|
||||
|
||||
foreach (Node *ctx, contexts_) {
|
||||
NodeInput ctx_input = ctx->GetEffectInput();
|
||||
NodeInput ctx_input = ctx->get_effect_input();
|
||||
|
||||
if (!graphs_added_to.contains(ctx->parent())) {
|
||||
command->add_child(new NodeAddCommand(ctx->parent(), n));
|
||||
@@ -173,12 +173,12 @@ void NodeParamViewContext::AddEffectMenuItemTriggered(QAction *a)
|
||||
}
|
||||
|
||||
command->add_child(new NodeSetPositionCommand(
|
||||
n, ctx, ctx->GetNodePositionInContext(ctx)));
|
||||
n, ctx, ctx->get_node_position_in_context(ctx)));
|
||||
command->add_child(new NodeSetPositionCommand(
|
||||
ctx, ctx, ctx->GetNodePositionInContext(ctx) + QPointF(1, 0)));
|
||||
ctx, ctx, ctx->get_node_position_in_context(ctx) + QPointF(1, 0)));
|
||||
|
||||
if (ctx_input.IsConnected()) {
|
||||
Node *prev_output = ctx_input.GetConnectedOutput();
|
||||
if (ctx_input.is_connected()) {
|
||||
Node *prev_output = ctx_input.get_connected_output();
|
||||
|
||||
command->add_child(
|
||||
new NodeEdgeRemoveCommand(prev_output, ctx_input));
|
||||
@@ -190,7 +190,7 @@ void NodeParamViewContext::AddEffectMenuItemTriggered(QAction *a)
|
||||
}
|
||||
|
||||
Core::instance()->undo_stack()->push(
|
||||
command, tr("Added %1 to Node Chain").arg(n->Name()));
|
||||
command, tr("Added %1 to Node Chain").arg(n->name()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NODEPARAMVIEWCONTEXT_H
|
||||
#define NODEPARAMVIEWCONTEXT_H
|
||||
#ifndef OAK_NODEPARAMVIEWCONTEXT_H
|
||||
#define OAK_NODEPARAMVIEWCONTEXT_H
|
||||
|
||||
#include "nodeparamviewdockarea.h"
|
||||
#include "nodeparamviewitembase.h"
|
||||
@@ -34,53 +34,53 @@ class NodeParamViewContext : public NodeParamViewItemBase {
|
||||
public:
|
||||
NodeParamViewContext(QWidget *parent = nullptr);
|
||||
|
||||
NodeParamViewDockArea *GetDockArea() const
|
||||
NodeParamViewDockArea *get_dock_area() const
|
||||
{
|
||||
return dock_area_;
|
||||
}
|
||||
|
||||
const QVector<Node *> &GetContexts() const
|
||||
const QVector<Node *> &get_contexts() const
|
||||
{
|
||||
return contexts_;
|
||||
}
|
||||
|
||||
const QVector<NodeParamViewItem *> &GetItems() const
|
||||
const QVector<NodeParamViewItem *> &get_items() const
|
||||
{
|
||||
return items_;
|
||||
}
|
||||
|
||||
NodeParamViewItem *GetItem(Node *node, Node *ctx);
|
||||
NodeParamViewItem *get_item(Node *node, Node *ctx);
|
||||
|
||||
void AddNode(NodeParamViewItem *item);
|
||||
void add_node(NodeParamViewItem *item);
|
||||
|
||||
void RemoveNode(Node *node, Node *ctx);
|
||||
void remove_node(Node *node, Node *ctx);
|
||||
|
||||
void RemoveNodesWithContext(Node *ctx);
|
||||
void remove_nodes_with_context(Node *ctx);
|
||||
|
||||
void SetInputChecked(const NodeInput &input, bool e);
|
||||
void set_input_checked(const NodeInput &input, bool e);
|
||||
|
||||
void SetTimebase(const rational &timebase);
|
||||
void set_timebase(const Rational &timebase);
|
||||
|
||||
void SetTimeTarget(ViewerOutput *n);
|
||||
void set_time_target(ViewerOutput *n);
|
||||
|
||||
void SetEffectType(Track::Type type);
|
||||
void set_effect_type(Track::Type type);
|
||||
|
||||
signals:
|
||||
void AboutToDeleteItem(NodeParamViewItem *item);
|
||||
void about_to_delete_item(NodeParamViewItem *item);
|
||||
|
||||
public slots:
|
||||
void AddContext(Node *node)
|
||||
void add_context(Node *node)
|
||||
{
|
||||
contexts_.append(node);
|
||||
}
|
||||
|
||||
void RemoveContext(Node *node)
|
||||
void remove_context(Node *node)
|
||||
{
|
||||
contexts_.removeOne(node);
|
||||
}
|
||||
|
||||
protected slots:
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
private:
|
||||
NodeParamViewDockArea *dock_area_;
|
||||
@@ -92,11 +92,11 @@ private:
|
||||
Track::Type type_;
|
||||
|
||||
private slots:
|
||||
void AddEffectButtonClicked();
|
||||
void add_effect_button_clicked();
|
||||
|
||||
void AddEffectMenuItemTriggered(QAction *a);
|
||||
void add_effect_menu_item_triggered(QAction *a);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEPARAMVIEWCONTEXT_H
|
||||
#endif // OAK_NODEPARAMVIEWCONTEXT_H
|
||||
|
||||
@@ -42,7 +42,7 @@ QMenu *NodeParamViewDockArea::createPopupMenu()
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void NodeParamViewDockArea::AddItem(QDockWidget *item)
|
||||
void NodeParamViewDockArea::add_item(QDockWidget *item)
|
||||
{
|
||||
item->setAllowedAreas(Qt::LeftDockWidgetArea);
|
||||
item->setFeatures(QDockWidget::DockWidgetClosable |
|
||||
@@ -50,7 +50,7 @@ void NodeParamViewDockArea::AddItem(QDockWidget *item)
|
||||
addDockWidget(Qt::LeftDockWidgetArea, item);
|
||||
}
|
||||
|
||||
void NodeParamViewDockArea::RemoveItem(QDockWidget *item)
|
||||
void NodeParamViewDockArea::remove_item(QDockWidget *item)
|
||||
{
|
||||
if (!item) {
|
||||
return;
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NODEPARAMVIEWDOCKAREA_H
|
||||
#define NODEPARAMVIEWDOCKAREA_H
|
||||
#ifndef OAK_NODEPARAMVIEWDOCKAREA_H
|
||||
#define OAK_NODEPARAMVIEWDOCKAREA_H
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
@@ -36,10 +36,10 @@ public:
|
||||
|
||||
virtual QMenu *createPopupMenu() override;
|
||||
|
||||
void AddItem(QDockWidget *item);
|
||||
void RemoveItem(QDockWidget *item);
|
||||
void add_item(QDockWidget *item);
|
||||
void remove_item(QDockWidget *item);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEPARAMVIEWDOCKAREA_H
|
||||
#endif // OAK_NODEPARAMVIEWDOCKAREA_H
|
||||
|
||||
@@ -30,21 +30,21 @@
|
||||
#include "node/group/group.h"
|
||||
#include "node/nodeundo.h"
|
||||
#include "node/project/sequence/sequence.h"
|
||||
#include "pluginSupport/OlivePluginInstance.h"
|
||||
#include "pluginSupport/oliveplugininstance.h"
|
||||
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const int NodeParamViewItemBody::kKeyControlColumn = 10;
|
||||
const int NodeParamViewItemBody::kArrayInsertColumn = kKeyControlColumn - 1;
|
||||
const int NodeParamViewItemBody::kArrayRemoveColumn = kArrayInsertColumn - 1;
|
||||
const int NodeParamViewItemBody::kExtraButtonColumn = kKeyControlColumn - 1;
|
||||
const int NodeParamViewItemBody::k_key_control_column = 10;
|
||||
const int NodeParamViewItemBody::k_array_insert_column = k_key_control_column - 1;
|
||||
const int NodeParamViewItemBody::k_array_remove_column = k_array_insert_column - 1;
|
||||
const int NodeParamViewItemBody::k_extra_button_column = k_key_control_column - 1;
|
||||
|
||||
const int NodeParamViewItemBody::kOptionalCheckBox = 0;
|
||||
const int NodeParamViewItemBody::kArrayCollapseBtnColumn = 1;
|
||||
const int NodeParamViewItemBody::kLabelColumn = 2;
|
||||
const int NodeParamViewItemBody::kWidgetStartColumn = 3;
|
||||
const int NodeParamViewItemBody::kMaxWidgetColumn = kArrayRemoveColumn;
|
||||
const int NodeParamViewItemBody::k_optional_check_box = 0;
|
||||
const int NodeParamViewItemBody::k_array_collapse_btn_column = 1;
|
||||
const int NodeParamViewItemBody::k_label_column = 2;
|
||||
const int NodeParamViewItemBody::k_widget_start_column = 3;
|
||||
const int NodeParamViewItemBody::k_max_widget_column = k_array_remove_column;
|
||||
|
||||
#define super NodeParamViewItemBase
|
||||
|
||||
@@ -61,21 +61,21 @@ NodeParamViewItem::NodeParamViewItem(
|
||||
, ctx_(nullptr)
|
||||
, time_target_(nullptr)
|
||||
{
|
||||
node_->Retranslate();
|
||||
node_->retranslate();
|
||||
|
||||
// Create and add contents widget
|
||||
RecreateBody();
|
||||
recreate_body();
|
||||
|
||||
connect(node_, &Node::LabelChanged, this, &NodeParamViewItem::Retranslate);
|
||||
connect(node_, &Node::InputArraySizeChanged, this,
|
||||
&NodeParamViewItem::InputArraySizeChanged);
|
||||
connect(node_, &Node::MessageCountChanged, this,
|
||||
&NodeParamViewItem::UpdateMessagePanel);
|
||||
connect(node_, &Node::label_changed, this, &NodeParamViewItem::retranslate);
|
||||
connect(node_, &Node::input_array_size_changed, this,
|
||||
&NodeParamViewItem::input_array_size_changed);
|
||||
connect(node_, &Node::message_count_changed, this,
|
||||
&NodeParamViewItem::update_message_panel);
|
||||
|
||||
// FIXME: Implemented to pick up when an input is set to hidden or not - DEFINITELY not a fast
|
||||
// way of doing this, but "fine" for now.
|
||||
connect(node_, &Node::InputFlagsChanged, this,
|
||||
&NodeParamViewItem::RecreateBody);
|
||||
connect(node_, &Node::input_flags_changed, this,
|
||||
&NodeParamViewItem::recreate_body);
|
||||
|
||||
setBackgroundRole(QPalette::Window);
|
||||
|
||||
@@ -84,19 +84,19 @@ NodeParamViewItem::NodeParamViewItem(
|
||||
//title_bar()->SetEnabledCheckBoxChecked(node_->IsEnabled());
|
||||
//connect(title_bar(), &NodeParamViewItemTitleBar::EnabledCheckBoxClicked, node_, &Node::SetEnabled);
|
||||
|
||||
Retranslate();
|
||||
retranslate();
|
||||
}
|
||||
|
||||
void NodeParamViewItem::Retranslate()
|
||||
void NodeParamViewItem::retranslate()
|
||||
{
|
||||
node_->Retranslate();
|
||||
node_->retranslate();
|
||||
|
||||
title_bar()->SetText(GetTitleBarTextFromNode(node_));
|
||||
title_bar()->set_text(get_title_bar_text_from_node(node_));
|
||||
|
||||
body_->Retranslate();
|
||||
body_->retranslate();
|
||||
}
|
||||
|
||||
void NodeParamViewItem::RecreateBody()
|
||||
void NodeParamViewItem::recreate_body()
|
||||
{
|
||||
if (body_) {
|
||||
body_->setParent(nullptr);
|
||||
@@ -111,17 +111,17 @@ void NodeParamViewItem::RecreateBody()
|
||||
}
|
||||
|
||||
body_ = new NodeParamViewItemBody(node_, create_checkboxes_, this);
|
||||
connect(body_, &NodeParamViewItemBody::RequestSelectNode, this,
|
||||
&NodeParamViewItem::RequestSelectNode);
|
||||
connect(body_, &NodeParamViewItemBody::ArrayExpandedChanged, this,
|
||||
&NodeParamViewItem::ArrayExpandedChanged);
|
||||
connect(body_, &NodeParamViewItemBody::InputCheckedChanged, this,
|
||||
&NodeParamViewItem::InputCheckedChanged);
|
||||
connect(body_, &NodeParamViewItemBody::RequestEditTextInViewer, this,
|
||||
&NodeParamViewItem::RequestEditTextInViewer);
|
||||
body_->Retranslate();
|
||||
body_->SetTimebase(timebase_);
|
||||
body_->SetTimeTarget(time_target_);
|
||||
connect(body_, &NodeParamViewItemBody::request_select_node, this,
|
||||
&NodeParamViewItem::request_select_node);
|
||||
connect(body_, &NodeParamViewItemBody::array_expanded_changed, this,
|
||||
&NodeParamViewItem::array_expanded_changed);
|
||||
connect(body_, &NodeParamViewItemBody::input_checked_changed, this,
|
||||
&NodeParamViewItem::input_checked_changed);
|
||||
connect(body_, &NodeParamViewItemBody::request_edit_text_in_viewer, this,
|
||||
&NodeParamViewItem::request_edit_text_in_viewer);
|
||||
body_->retranslate();
|
||||
body_->set_timebase(timebase_);
|
||||
body_->set_time_target(time_target_);
|
||||
|
||||
message_container_ = new QWidget(this);
|
||||
QVBoxLayout *message_layout = new QVBoxLayout(message_container_);
|
||||
@@ -134,7 +134,7 @@ void NodeParamViewItem::RecreateBody()
|
||||
message_clear_button_ = new QPushButton(tr("Clear"), message_container_);
|
||||
message_clear_button_->setVisible(false);
|
||||
connect(message_clear_button_, &QPushButton::clicked, this,
|
||||
&NodeParamViewItem::ClearMessages);
|
||||
&NodeParamViewItem::clear_messages);
|
||||
message_header->addWidget(message_clear_button_);
|
||||
message_layout->addLayout(message_header);
|
||||
|
||||
@@ -146,11 +146,11 @@ void NodeParamViewItem::RecreateBody()
|
||||
message_layout->addWidget(message_label_);
|
||||
message_layout->addWidget(body_);
|
||||
|
||||
SetBody(message_container_);
|
||||
UpdateMessagePanel();
|
||||
set_body(message_container_);
|
||||
update_message_panel();
|
||||
}
|
||||
|
||||
void NodeParamViewItem::UpdateMessagePanel()
|
||||
void NodeParamViewItem::update_message_panel()
|
||||
{
|
||||
if (!message_label_) {
|
||||
return;
|
||||
@@ -159,7 +159,7 @@ void NodeParamViewItem::UpdateMessagePanel()
|
||||
auto *instance = node_->getPluginInstance();
|
||||
auto *olive_instance =
|
||||
dynamic_cast<plugin::OlivePluginInstance *>(instance);
|
||||
if (!olive_instance || olive_instance->persistentMessageCount() == 0) {
|
||||
if (!olive_instance || olive_instance->persistent_message_count() == 0) {
|
||||
message_label_->setVisible(false);
|
||||
if (message_clear_button_) {
|
||||
message_clear_button_->setVisible(false);
|
||||
@@ -168,16 +168,16 @@ void NodeParamViewItem::UpdateMessagePanel()
|
||||
}
|
||||
|
||||
QStringList lines;
|
||||
for (const auto &msg : olive_instance->persistentMessages()) {
|
||||
for (const auto &msg : olive_instance->persistent_messages()) {
|
||||
QString prefix;
|
||||
switch (msg.type) {
|
||||
case plugin::ErrorType::Error:
|
||||
case plugin::ErrorType::error:
|
||||
prefix = QStringLiteral("Error");
|
||||
break;
|
||||
case plugin::ErrorType::Warning:
|
||||
case plugin::ErrorType::warning:
|
||||
prefix = QStringLiteral("Warning");
|
||||
break;
|
||||
case plugin::ErrorType::Message:
|
||||
case plugin::ErrorType::message:
|
||||
prefix = QStringLiteral("Message");
|
||||
break;
|
||||
}
|
||||
@@ -191,22 +191,22 @@ void NodeParamViewItem::UpdateMessagePanel()
|
||||
}
|
||||
}
|
||||
|
||||
int NodeParamViewItem::GetElementY(const NodeInput &c) const
|
||||
int NodeParamViewItem::get_element_y(const NodeInput &c) const
|
||||
{
|
||||
if (IsExpanded()) {
|
||||
return body_->GetElementY(c);
|
||||
if (is_expanded()) {
|
||||
return body_->get_element_y(c);
|
||||
} else {
|
||||
// Not expanded, put keyframes at the titlebar Y
|
||||
return mapToGlobal(title_bar()->rect().center()).y();
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewItem::SetInputChecked(const NodeInput &input, bool e)
|
||||
void NodeParamViewItem::set_input_checked(const NodeInput &input, bool e)
|
||||
{
|
||||
body_->SetInputChecked(input, e);
|
||||
body_->set_input_checked(input, e);
|
||||
}
|
||||
|
||||
void NodeParamViewItem::ClearMessages()
|
||||
void NodeParamViewItem::clear_messages()
|
||||
{
|
||||
auto *instance = node_->getPluginInstance();
|
||||
auto *olive_instance =
|
||||
@@ -238,14 +238,14 @@ NodeParamViewItemBody::NodeParamViewItemBody(
|
||||
foreach (QString input, node->inputs()) {
|
||||
Node *n = node;
|
||||
|
||||
NodeInput resolved = NodeGroup::ResolveInput(NodeInput(n, input));
|
||||
NodeInput resolved = NodeGroup::resolve_input(NodeInput(n, input));
|
||||
if (!connected_signals.contains(resolved.node())) {
|
||||
connect(resolved.node(), &Node::InputArraySizeChanged, this,
|
||||
&NodeParamViewItemBody::InputArraySizeChanged);
|
||||
connect(resolved.node(), &Node::InputConnected, this,
|
||||
&NodeParamViewItemBody::EdgeChanged);
|
||||
connect(resolved.node(), &Node::InputDisconnected, this,
|
||||
&NodeParamViewItemBody::EdgeChanged);
|
||||
connect(resolved.node(), &Node::input_array_size_changed, this,
|
||||
&NodeParamViewItemBody::input_array_size_changed);
|
||||
connect(resolved.node(), &Node::input_connected, this,
|
||||
&NodeParamViewItemBody::edge_changed);
|
||||
connect(resolved.node(), &Node::input_disconnected, this,
|
||||
&NodeParamViewItemBody::edge_changed);
|
||||
|
||||
connected_signals.append(resolved.node());
|
||||
}
|
||||
@@ -253,11 +253,11 @@ NodeParamViewItemBody::NodeParamViewItemBody(
|
||||
input_group_lookup_.insert({ resolved.node(), resolved.input() },
|
||||
{ n, input });
|
||||
|
||||
if (!(n->GetInputFlags(input) & kInputFlagHidden)) {
|
||||
if (!(n->get_input_flags(input) & k_input_flag_hidden)) {
|
||||
QString page_label =
|
||||
n->GetInputProperty(input, QStringLiteral("ui_page")).toString();
|
||||
n->get_input_property(input, QStringLiteral("ui_page")).toString();
|
||||
QString group_label =
|
||||
n->GetInputProperty(input, QStringLiteral("ui_group"))
|
||||
n->get_input_property(input, QStringLiteral("ui_group"))
|
||||
.toString();
|
||||
if (!page_label.isEmpty() && page_label != current_page) {
|
||||
QLabel *page_title = new QLabel(page_label, this);
|
||||
@@ -278,17 +278,17 @@ NodeParamViewItemBody::NodeParamViewItemBody(
|
||||
insert_row++;
|
||||
current_group = group_label;
|
||||
}
|
||||
CreateWidgets(root_layout, n, input, -1, insert_row);
|
||||
create_widgets(root_layout, n, input, -1, insert_row);
|
||||
|
||||
insert_row++;
|
||||
|
||||
if (n->InputIsArray(input)) {
|
||||
if (n->input_is_array(input)) {
|
||||
// Insert here
|
||||
QWidget *array_widget = new QWidget(this);
|
||||
|
||||
QGridLayout *array_layout = new QGridLayout(array_widget);
|
||||
array_layout->setContentsMargins(
|
||||
QtUtils::QFontMetricsWidth(fontMetrics(),
|
||||
QtUtils::q_font_metrics_width(fontMetrics(),
|
||||
QStringLiteral(" ")),
|
||||
0, 0, 0);
|
||||
|
||||
@@ -300,11 +300,11 @@ NodeParamViewItemBody::NodeParamViewItemBody(
|
||||
|
||||
// Add one last add button for appending to the array
|
||||
NodeParamViewArrayButton *append_btn =
|
||||
new NodeParamViewArrayButton(NodeParamViewArrayButton::kAdd,
|
||||
new NodeParamViewArrayButton(NodeParamViewArrayButton::k_add,
|
||||
this);
|
||||
connect(append_btn, &NodeParamViewArrayButton::clicked, this,
|
||||
&NodeParamViewItemBody::ArrayAppendClicked);
|
||||
array_layout->addWidget(append_btn, arr_sz, kArrayInsertColumn);
|
||||
&NodeParamViewItemBody::array_append_clicked);
|
||||
array_layout->addWidget(append_btn, arr_sz, k_array_insert_column);
|
||||
|
||||
array_widget->setVisible(false);
|
||||
|
||||
@@ -317,7 +317,7 @@ NodeParamViewItemBody::NodeParamViewItemBody(
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewItemBody::CreateWidgets(QGridLayout *layout, Node *node,
|
||||
void NodeParamViewItemBody::create_widgets(QGridLayout *layout, Node *node,
|
||||
const QString &input, int element,
|
||||
int row)
|
||||
{
|
||||
@@ -333,11 +333,11 @@ void NodeParamViewItemBody::CreateWidgets(QGridLayout *layout, Node *node,
|
||||
if (create_checkboxes_) {
|
||||
ui_objects.optional_checkbox = new QCheckBox(this);
|
||||
connect(ui_objects.optional_checkbox, &QCheckBox::clicked, this,
|
||||
&NodeParamViewItemBody::OptionalCheckBoxClicked);
|
||||
layout->addWidget(ui_objects.optional_checkbox, row, kOptionalCheckBox);
|
||||
&NodeParamViewItemBody::optional_check_box_clicked);
|
||||
layout->addWidget(ui_objects.optional_checkbox, row, k_optional_check_box);
|
||||
|
||||
if (create_checkboxes_ == kCheckBoxesOnNonConnected &&
|
||||
input_ref.IsConnected()) {
|
||||
if (create_checkboxes_ == k_check_boxes_on_non_connected &&
|
||||
input_ref.is_connected()) {
|
||||
ui_objects.optional_checkbox->setVisible(false);
|
||||
}
|
||||
}
|
||||
@@ -346,9 +346,9 @@ void NodeParamViewItemBody::CreateWidgets(QGridLayout *layout, Node *node,
|
||||
ui_objects.main_label = new QLabel(this);
|
||||
|
||||
// Create input label
|
||||
layout->addWidget(ui_objects.main_label, row, kLabelColumn);
|
||||
layout->addWidget(ui_objects.main_label, row, k_label_column);
|
||||
|
||||
if (node->InputIsArray(input)) {
|
||||
if (node->input_is_array(input)) {
|
||||
if (element == -1) {
|
||||
// Create a collapse toggle for expanding/collapsing the array
|
||||
CollapseButton *array_collapse_btn = new CollapseButton(this);
|
||||
@@ -357,32 +357,32 @@ void NodeParamViewItemBody::CreateWidgets(QGridLayout *layout, Node *node,
|
||||
array_collapse_btn->setChecked(false);
|
||||
|
||||
// Add collapse button to layout
|
||||
layout->addWidget(array_collapse_btn, row, kArrayCollapseBtnColumn);
|
||||
layout->addWidget(array_collapse_btn, row, k_array_collapse_btn_column);
|
||||
|
||||
// Connect signal to show/hide array params when toggled
|
||||
connect(array_collapse_btn, &CollapseButton::toggled, this,
|
||||
&NodeParamViewItemBody::ArrayCollapseBtnPressed);
|
||||
&NodeParamViewItemBody::array_collapse_btn_pressed);
|
||||
|
||||
array_collapse_buttons_.insert({ node, input }, array_collapse_btn);
|
||||
|
||||
} else {
|
||||
NodeParamViewArrayButton *insert_element_btn =
|
||||
new NodeParamViewArrayButton(NodeParamViewArrayButton::kAdd,
|
||||
new NodeParamViewArrayButton(NodeParamViewArrayButton::k_add,
|
||||
this);
|
||||
NodeParamViewArrayButton *remove_element_btn =
|
||||
new NodeParamViewArrayButton(NodeParamViewArrayButton::kRemove,
|
||||
new NodeParamViewArrayButton(NodeParamViewArrayButton::k_remove,
|
||||
this);
|
||||
|
||||
layout->addWidget(insert_element_btn, row, kArrayInsertColumn);
|
||||
layout->addWidget(remove_element_btn, row, kArrayRemoveColumn);
|
||||
layout->addWidget(insert_element_btn, row, k_array_insert_column);
|
||||
layout->addWidget(remove_element_btn, row, k_array_remove_column);
|
||||
|
||||
ui_objects.array_insert_btn = insert_element_btn;
|
||||
ui_objects.array_remove_btn = remove_element_btn;
|
||||
|
||||
connect(insert_element_btn, &NodeParamViewArrayButton::clicked,
|
||||
this, &NodeParamViewItemBody::ArrayInsertClicked);
|
||||
this, &NodeParamViewItemBody::array_insert_clicked);
|
||||
connect(remove_element_btn, &NodeParamViewArrayButton::clicked,
|
||||
this, &NodeParamViewItemBody::ArrayRemoveClicked);
|
||||
this, &NodeParamViewItemBody::array_remove_clicked);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,80 +390,80 @@ void NodeParamViewItemBody::CreateWidgets(QGridLayout *layout, Node *node,
|
||||
ui_objects.widget_bridge =
|
||||
new NodeParamViewWidgetBridge(NodeInput(node, input, element), this);
|
||||
connect(ui_objects.widget_bridge,
|
||||
&NodeParamViewWidgetBridge::WidgetsRecreated, this,
|
||||
&NodeParamViewItemBody::ReplaceWidgets);
|
||||
&NodeParamViewWidgetBridge::widgets_recreated, this,
|
||||
&NodeParamViewItemBody::replace_widgets);
|
||||
connect(ui_objects.widget_bridge,
|
||||
&NodeParamViewWidgetBridge::ArrayWidgetDoubleClicked, this,
|
||||
&NodeParamViewItemBody::ToggleArrayExpanded);
|
||||
&NodeParamViewWidgetBridge::array_widget_double_clicked, this,
|
||||
&NodeParamViewItemBody::toggle_array_expanded);
|
||||
connect(ui_objects.widget_bridge,
|
||||
&NodeParamViewWidgetBridge::RequestEditTextInViewer, this,
|
||||
&NodeParamViewItemBody::RequestEditTextInViewer);
|
||||
&NodeParamViewWidgetBridge::request_edit_text_in_viewer, this,
|
||||
&NodeParamViewItemBody::request_edit_text_in_viewer);
|
||||
|
||||
// Place widgets into layout
|
||||
PlaceWidgetsFromBridge(layout, ui_objects.widget_bridge, row);
|
||||
place_widgets_from_bridge(layout, ui_objects.widget_bridge, row);
|
||||
|
||||
// In case this input is a group, resolve that actual input to use for connected labels
|
||||
NodeInput resolved = NodeGroup::ResolveInput(input_ref);
|
||||
NodeInput resolved = NodeGroup::resolve_input(input_ref);
|
||||
|
||||
if (node->IsInputConnectable(input)) {
|
||||
if (node->is_input_connectable(input)) {
|
||||
// Create clickable label used when an input is connected
|
||||
ui_objects.connected_label =
|
||||
new NodeParamViewConnectedLabel(resolved, this);
|
||||
connect(ui_objects.connected_label,
|
||||
&NodeParamViewConnectedLabel::RequestSelectNode, this,
|
||||
&NodeParamViewItemBody::RequestSelectNode);
|
||||
layout->addWidget(ui_objects.connected_label, row, kWidgetStartColumn,
|
||||
1, kKeyControlColumn - kWidgetStartColumn);
|
||||
&NodeParamViewConnectedLabel::request_select_node, this,
|
||||
&NodeParamViewItemBody::request_select_node);
|
||||
layout->addWidget(ui_objects.connected_label, row, k_widget_start_column,
|
||||
1, k_key_control_column - k_widget_start_column);
|
||||
}
|
||||
|
||||
// Add keyframe control to this layout if parameter is keyframable
|
||||
if (node->IsInputKeyframable(input)) {
|
||||
if (node->is_input_keyframable(input)) {
|
||||
ui_objects.key_control = new NodeParamViewKeyframeControl(this);
|
||||
ui_objects.key_control->SetInput(resolved);
|
||||
layout->addWidget(ui_objects.key_control, row, kKeyControlColumn);
|
||||
ui_objects.key_control->set_input(resolved);
|
||||
layout->addWidget(ui_objects.key_control, row, k_key_control_column);
|
||||
}
|
||||
|
||||
input_ui_map_.insert(input_ref, ui_objects);
|
||||
|
||||
if (node->IsInputConnectable(input)) {
|
||||
UpdateUIForEdgeConnection(input_ref);
|
||||
if (node->is_input_connectable(input)) {
|
||||
update_ui_for_edge_connection(input_ref);
|
||||
}
|
||||
|
||||
SetTimeTargetOnInputUI(ui_objects);
|
||||
SetTimebaseOnInputUI(ui_objects);
|
||||
set_time_target_on_input_ui(ui_objects);
|
||||
set_timebase_on_input_ui(ui_objects);
|
||||
}
|
||||
|
||||
void NodeParamViewItemBody::SetTimeTarget(ViewerOutput *target)
|
||||
void NodeParamViewItemBody::set_time_target(ViewerOutput *target)
|
||||
{
|
||||
time_target_ = target;
|
||||
|
||||
foreach (const InputUI &ui_obj, input_ui_map_) {
|
||||
SetTimeTargetOnInputUI(ui_obj);
|
||||
set_time_target_on_input_ui(ui_obj);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewItemBody::SetTimeTargetOnInputUI(const InputUI &ui_obj)
|
||||
void NodeParamViewItemBody::set_time_target_on_input_ui(const InputUI &ui_obj)
|
||||
{
|
||||
// Only keyframable inputs have a key control widget
|
||||
if (ui_obj.key_control) {
|
||||
ui_obj.key_control->SetTimeTarget(time_target_);
|
||||
ui_obj.key_control->set_time_target(time_target_);
|
||||
}
|
||||
if (ui_obj.connected_label) {
|
||||
ui_obj.connected_label->SetViewerNode(time_target_);
|
||||
ui_obj.connected_label->set_viewer_node(time_target_);
|
||||
}
|
||||
ui_obj.widget_bridge->SetTimeTarget(time_target_);
|
||||
ui_obj.widget_bridge->set_time_target(time_target_);
|
||||
}
|
||||
|
||||
void NodeParamViewItemBody::Retranslate()
|
||||
void NodeParamViewItemBody::retranslate()
|
||||
{
|
||||
for (auto i = input_ui_map_.begin(); i != input_ui_map_.end(); i++) {
|
||||
const NodeInput &ic = i.key();
|
||||
|
||||
if (ic.IsArray() && ic.element() >= 0) {
|
||||
if (ic.is_array() && ic.element() >= 0) {
|
||||
// Make the label the array index
|
||||
i.value().main_label->setText(tr("%1:").arg(
|
||||
ic.element() +
|
||||
ic.GetProperty(QStringLiteral("arraystart")).toInt()));
|
||||
ic.get_property(QStringLiteral("arraystart")).toInt()));
|
||||
} else {
|
||||
// Set to the input's name
|
||||
i.value().main_label->setText(tr("%1:").arg(ic.name()));
|
||||
@@ -471,9 +471,9 @@ void NodeParamViewItemBody::Retranslate()
|
||||
}
|
||||
}
|
||||
|
||||
int NodeParamViewItemBody::GetElementY(NodeInput c) const
|
||||
int NodeParamViewItemBody::get_element_y(NodeInput c) const
|
||||
{
|
||||
if (c.IsArray() && !array_ui_.value(c.input_pair()).widget->isVisible()) {
|
||||
if (c.is_array() && !array_ui_.value(c.input_pair()).widget->isVisible()) {
|
||||
// Array is collapsed, so we'll return the Y of its root
|
||||
c.set_element(-1);
|
||||
}
|
||||
@@ -493,7 +493,7 @@ int NodeParamViewItemBody::GetElementY(NodeInput c) const
|
||||
return lbl_center.y();
|
||||
}
|
||||
|
||||
void NodeParamViewItemBody::EdgeChanged(Node *output, const NodeInput &input)
|
||||
void NodeParamViewItemBody::edge_changed(Node *output, const NodeInput &input)
|
||||
{
|
||||
Q_UNUSED(output)
|
||||
|
||||
@@ -501,16 +501,16 @@ void NodeParamViewItemBody::EdgeChanged(Node *output, const NodeInput &input)
|
||||
input_group_lookup_.value({ input.node(), input.input() });
|
||||
NodeInput resolved(pair.node, pair.input, input.element());
|
||||
|
||||
UpdateUIForEdgeConnection(resolved);
|
||||
update_ui_for_edge_connection(resolved);
|
||||
}
|
||||
|
||||
void NodeParamViewItemBody::UpdateUIForEdgeConnection(const NodeInput &input)
|
||||
void NodeParamViewItemBody::update_ui_for_edge_connection(const NodeInput &input)
|
||||
{
|
||||
// Show/hide bridge widgets
|
||||
if (input_ui_map_.contains(input)) {
|
||||
const InputUI &ui_objects = input_ui_map_[input];
|
||||
|
||||
bool is_connected = NodeGroup::ResolveInput(input).IsConnected();
|
||||
bool is_connected = NodeGroup::resolve_input(input).is_connected();
|
||||
|
||||
foreach (QWidget *w, ui_objects.widget_bridge->widgets()) {
|
||||
w->setVisible(!is_connected);
|
||||
@@ -524,25 +524,25 @@ void NodeParamViewItemBody::UpdateUIForEdgeConnection(const NodeInput &input)
|
||||
}
|
||||
|
||||
// Show/hide optional checkbox if requested
|
||||
if (create_checkboxes_ == kCheckBoxesOnNonConnected) {
|
||||
if (create_checkboxes_ == k_check_boxes_on_non_connected) {
|
||||
ui_objects.optional_checkbox->setVisible(!is_connected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewItemBody::PlaceWidgetsFromBridge(
|
||||
void NodeParamViewItemBody::place_widgets_from_bridge(
|
||||
QGridLayout *layout, NodeParamViewWidgetBridge *bridge, int row)
|
||||
{
|
||||
// Add widgets for this parameter to the layout
|
||||
for (int i = 0; i < bridge->widgets().size(); i++) {
|
||||
QWidget *w = bridge->widgets().at(i);
|
||||
|
||||
int col = i + kWidgetStartColumn;
|
||||
int col = i + k_widget_start_column;
|
||||
|
||||
int colspan;
|
||||
if (i == bridge->widgets().size() - 1) {
|
||||
// Span this widget among remaining columns
|
||||
colspan = kMaxWidgetColumn - col;
|
||||
colspan = k_max_widget_column - col;
|
||||
} else {
|
||||
colspan = 1;
|
||||
}
|
||||
@@ -551,7 +551,7 @@ void NodeParamViewItemBody::PlaceWidgetsFromBridge(
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewItemBody::InputArraySizeChangedInternal(Node *node,
|
||||
void NodeParamViewItemBody::input_array_size_changed_internal(Node *node,
|
||||
const QString &input,
|
||||
int size)
|
||||
{
|
||||
@@ -569,10 +569,10 @@ void NodeParamViewItemBody::InputArraySizeChangedInternal(Node *node,
|
||||
|
||||
if (array_ui.count < size) {
|
||||
// Our UI count is smaller than the size, create more
|
||||
grid->addWidget(array_ui.append_btn, size, kArrayInsertColumn);
|
||||
grid->addWidget(array_ui.append_btn, size, k_array_insert_column);
|
||||
|
||||
for (int i = array_ui.count; i < size; i++) {
|
||||
CreateWidgets(grid, node, input, i, i);
|
||||
create_widgets(grid, node, input, i, i);
|
||||
}
|
||||
} else {
|
||||
for (int i = array_ui.count - 1; i >= size; i--) {
|
||||
@@ -587,16 +587,16 @@ void NodeParamViewItemBody::InputArraySizeChangedInternal(Node *node,
|
||||
delete input_ui.array_remove_btn;
|
||||
}
|
||||
|
||||
grid->addWidget(array_ui.append_btn, size, kArrayInsertColumn);
|
||||
grid->addWidget(array_ui.append_btn, size, k_array_insert_column);
|
||||
}
|
||||
|
||||
array_ui.count = size;
|
||||
|
||||
Retranslate();
|
||||
retranslate();
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewItemBody::ArrayCollapseBtnPressed(bool checked)
|
||||
void NodeParamViewItemBody::array_collapse_btn_pressed(bool checked)
|
||||
{
|
||||
const NodeInputPair &input =
|
||||
array_collapse_buttons_.key(static_cast<CollapseButton *>(sender()));
|
||||
@@ -605,15 +605,15 @@ void NodeParamViewItemBody::ArrayCollapseBtnPressed(bool checked)
|
||||
if (checked) {
|
||||
// Ensure widgets are created (the signal will be ignored if they are)
|
||||
NodeInput resolved =
|
||||
NodeGroup::ResolveInput(NodeInput(input.node, input.input));
|
||||
InputArraySizeChangedInternal(input.node, input.input,
|
||||
resolved.GetArraySize());
|
||||
NodeGroup::resolve_input(NodeInput(input.node, input.input));
|
||||
input_array_size_changed_internal(input.node, input.input,
|
||||
resolved.get_array_size());
|
||||
}
|
||||
|
||||
emit ArrayExpandedChanged(checked);
|
||||
emit array_expanded_changed(checked);
|
||||
}
|
||||
|
||||
void NodeParamViewItemBody::InputArraySizeChanged(const QString &input,
|
||||
void NodeParamViewItemBody::input_array_size_changed(const QString &input,
|
||||
int old_sz, int size)
|
||||
{
|
||||
Q_UNUSED(old_sz)
|
||||
@@ -621,58 +621,58 @@ void NodeParamViewItemBody::InputArraySizeChanged(const QString &input,
|
||||
NodeInputPair nip =
|
||||
input_group_lookup_.value({ static_cast<Node *>(sender()), input });
|
||||
|
||||
InputArraySizeChangedInternal(nip.node, nip.input, size);
|
||||
input_array_size_changed_internal(nip.node, nip.input, size);
|
||||
}
|
||||
|
||||
void NodeParamViewItemBody::ArrayAppendClicked()
|
||||
void NodeParamViewItemBody::array_append_clicked()
|
||||
{
|
||||
for (auto it = array_ui_.cbegin(); it != array_ui_.cend(); it++) {
|
||||
if (it.value().append_btn == sender()) {
|
||||
NodeInput real_input = NodeGroup::ResolveInput(
|
||||
NodeInput real_input = NodeGroup::resolve_input(
|
||||
NodeInput(it.key().node, it.key().input));
|
||||
Core::instance()->undo_stack()->push(
|
||||
new NodeArrayInsertCommand(real_input.node(),
|
||||
real_input.input(),
|
||||
real_input.GetArraySize()),
|
||||
real_input.get_array_size()),
|
||||
tr("Appended Array Element In %1 - %2")
|
||||
.arg(real_input.node()->GetLabelAndName(),
|
||||
real_input.GetInputName()));
|
||||
.arg(real_input.node()->get_label_and_name(),
|
||||
real_input.get_input_name()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewItemBody::ArrayInsertClicked()
|
||||
void NodeParamViewItemBody::array_insert_clicked()
|
||||
{
|
||||
for (auto it = input_ui_map_.cbegin(); it != input_ui_map_.cend(); it++) {
|
||||
if (it.value().array_insert_btn == sender()) {
|
||||
// Found our input and element
|
||||
NodeInput ic = NodeGroup::ResolveInput(it.key());
|
||||
NodeInput ic = NodeGroup::resolve_input(it.key());
|
||||
Core::instance()->undo_stack()->push(
|
||||
new NodeArrayInsertCommand(ic.node(), ic.input(), ic.element()),
|
||||
tr("Inserted Array Element In %1 - %2")
|
||||
.arg(ic.node()->GetLabelAndName(), ic.GetInputName()));
|
||||
.arg(ic.node()->get_label_and_name(), ic.get_input_name()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewItemBody::ArrayRemoveClicked()
|
||||
void NodeParamViewItemBody::array_remove_clicked()
|
||||
{
|
||||
for (auto it = input_ui_map_.cbegin(); it != input_ui_map_.cend(); it++) {
|
||||
if (it.value().array_remove_btn == sender()) {
|
||||
// Found our input and element
|
||||
NodeInput ic = NodeGroup::ResolveInput(it.key());
|
||||
NodeInput ic = NodeGroup::resolve_input(it.key());
|
||||
Core::instance()->undo_stack()->push(
|
||||
new NodeArrayRemoveCommand(ic.node(), ic.input(), ic.element()),
|
||||
tr("Removed Array Element In %1 - %2")
|
||||
.arg(ic.node()->GetLabelAndName(), ic.GetInputName()));
|
||||
.arg(ic.node()->get_label_and_name(), ic.get_input_name()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewItemBody::ToggleArrayExpanded()
|
||||
void NodeParamViewItemBody::toggle_array_expanded()
|
||||
{
|
||||
NodeParamViewWidgetBridge *bridge =
|
||||
static_cast<NodeParamViewWidgetBridge *>(sender());
|
||||
@@ -687,21 +687,21 @@ void NodeParamViewItemBody::ToggleArrayExpanded()
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewItemBody::SetTimebase(const rational &timebase)
|
||||
void NodeParamViewItemBody::set_timebase(const Rational &timebase)
|
||||
{
|
||||
timebase_ = timebase;
|
||||
|
||||
foreach (const InputUI &ui_obj, input_ui_map_) {
|
||||
SetTimebaseOnInputUI(ui_obj);
|
||||
set_timebase_on_input_ui(ui_obj);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewItemBody::SetTimebaseOnInputUI(const InputUI &ui_obj)
|
||||
void NodeParamViewItemBody::set_timebase_on_input_ui(const InputUI &ui_obj)
|
||||
{
|
||||
ui_obj.widget_bridge->SetTimebase(timebase_);
|
||||
ui_obj.widget_bridge->set_timebase(timebase_);
|
||||
}
|
||||
|
||||
void NodeParamViewItemBody::SetInputChecked(const NodeInput &input, bool e)
|
||||
void NodeParamViewItemBody::set_input_checked(const NodeInput &input, bool e)
|
||||
{
|
||||
if (input_ui_map_.contains(input)) {
|
||||
QCheckBox *cb = input_ui_map_.value(input).optional_checkbox;
|
||||
@@ -711,13 +711,13 @@ void NodeParamViewItemBody::SetInputChecked(const NodeInput &input, bool e)
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewItemBody::ReplaceWidgets(const NodeInput &input)
|
||||
void NodeParamViewItemBody::replace_widgets(const NodeInput &input)
|
||||
{
|
||||
InputUI ui = input_ui_map_.value(input);
|
||||
PlaceWidgetsFromBridge(ui.layout, ui.widget_bridge, ui.row);
|
||||
place_widgets_from_bridge(ui.layout, ui.widget_bridge, ui.row);
|
||||
}
|
||||
|
||||
void NodeParamViewItemBody::ShowSpeedDurationDialogForNode()
|
||||
void NodeParamViewItemBody::show_speed_duration_dialog_for_node()
|
||||
{
|
||||
// We should only get there if the node is a clip, determined by the dynamic_cast in CreateWidgets
|
||||
SpeedDurationDialog sdd({ static_cast<ClipBlock *>(node_) }, timebase_,
|
||||
@@ -725,13 +725,13 @@ void NodeParamViewItemBody::ShowSpeedDurationDialogForNode()
|
||||
sdd.exec();
|
||||
}
|
||||
|
||||
void NodeParamViewItemBody::OptionalCheckBoxClicked(bool e)
|
||||
void NodeParamViewItemBody::optional_check_box_clicked(bool e)
|
||||
{
|
||||
QCheckBox *cb = static_cast<QCheckBox *>(sender());
|
||||
|
||||
for (auto it = input_ui_map_.cbegin(); it != input_ui_map_.cend(); it++) {
|
||||
if (it.value().optional_checkbox == cb) {
|
||||
emit InputCheckedChanged(it.key(), e);
|
||||
emit input_checked_changed(it.key(), e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NODEPARAMVIEWITEM_H
|
||||
#define NODEPARAMVIEWITEM_H
|
||||
#ifndef OAK_NODEPARAMVIEWITEM_H
|
||||
#define OAK_NODEPARAMVIEWITEM_H
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QGridLayout>
|
||||
@@ -43,9 +43,9 @@ namespace olive
|
||||
{
|
||||
|
||||
enum NodeParamViewCheckBoxBehavior {
|
||||
kNoCheckBoxes,
|
||||
kCheckBoxesOn,
|
||||
kCheckBoxesOnNonConnected
|
||||
k_no_check_boxes,
|
||||
k_check_boxes_on,
|
||||
k_check_boxes_on_non_connected
|
||||
};
|
||||
|
||||
class NodeParamViewItemBody : public QWidget {
|
||||
@@ -55,36 +55,36 @@ public:
|
||||
NodeParamViewCheckBoxBehavior create_checkboxes,
|
||||
QWidget *parent = nullptr);
|
||||
|
||||
void SetTimeTarget(ViewerOutput *target);
|
||||
void set_time_target(ViewerOutput *target);
|
||||
|
||||
void Retranslate();
|
||||
void retranslate();
|
||||
|
||||
int GetElementY(NodeInput c) const;
|
||||
int get_element_y(NodeInput c) const;
|
||||
|
||||
// Set the timebase of any timebased widgets contained here
|
||||
void SetTimebase(const rational &timebase);
|
||||
void set_timebase(const Rational &timebase);
|
||||
|
||||
void SetInputChecked(const NodeInput &input, bool e);
|
||||
void set_input_checked(const NodeInput &input, bool e);
|
||||
|
||||
signals:
|
||||
void RequestSelectNode(Node *node);
|
||||
void request_select_node(Node *node);
|
||||
|
||||
void ArrayExpandedChanged(bool e);
|
||||
void array_expanded_changed(bool e);
|
||||
|
||||
void InputCheckedChanged(const NodeInput &input, bool e);
|
||||
void input_checked_changed(const NodeInput &input, bool e);
|
||||
|
||||
void RequestEditTextInViewer();
|
||||
void request_edit_text_in_viewer();
|
||||
|
||||
private:
|
||||
void CreateWidgets(QGridLayout *layout, Node *node, const QString &input,
|
||||
void create_widgets(QGridLayout *layout, Node *node, const QString &input,
|
||||
int element, int row_index);
|
||||
|
||||
void UpdateUIForEdgeConnection(const NodeInput &input);
|
||||
void update_ui_for_edge_connection(const NodeInput &input);
|
||||
|
||||
void PlaceWidgetsFromBridge(QGridLayout *layout,
|
||||
void place_widgets_from_bridge(QGridLayout *layout,
|
||||
NodeParamViewWidgetBridge *bridge, int row);
|
||||
|
||||
void InputArraySizeChangedInternal(Node *node, const QString &input,
|
||||
void input_array_size_changed_internal(Node *node, const QString &input,
|
||||
int size);
|
||||
|
||||
struct InputUI {
|
||||
@@ -111,8 +111,8 @@ private:
|
||||
NodeParamViewArrayButton *append_btn;
|
||||
};
|
||||
|
||||
void SetTimeTargetOnInputUI(const InputUI &ui);
|
||||
void SetTimebaseOnInputUI(const InputUI &ui);
|
||||
void set_time_target_on_input_ui(const InputUI &ui);
|
||||
void set_timebase_on_input_ui(const InputUI &ui);
|
||||
|
||||
Node *node_;
|
||||
|
||||
@@ -120,7 +120,7 @@ private:
|
||||
|
||||
QHash<NodeInputPair, CollapseButton *> array_collapse_buttons_;
|
||||
|
||||
rational timebase_;
|
||||
Rational timebase_;
|
||||
|
||||
ViewerOutput *time_target_;
|
||||
|
||||
@@ -134,38 +134,38 @@ private:
|
||||
* Serves as an effective "maximum column" index because the keyframe button is always aligned
|
||||
* to the right edge.
|
||||
*/
|
||||
static const int kKeyControlColumn;
|
||||
static const int k_key_control_column;
|
||||
|
||||
static const int kArrayInsertColumn;
|
||||
static const int kArrayRemoveColumn;
|
||||
static const int kExtraButtonColumn;
|
||||
static const int k_array_insert_column;
|
||||
static const int k_array_remove_column;
|
||||
static const int k_extra_button_column;
|
||||
|
||||
static const int kOptionalCheckBox;
|
||||
static const int kArrayCollapseBtnColumn;
|
||||
static const int kLabelColumn;
|
||||
static const int kWidgetStartColumn;
|
||||
static const int kMaxWidgetColumn;
|
||||
static const int k_optional_check_box;
|
||||
static const int k_array_collapse_btn_column;
|
||||
static const int k_label_column;
|
||||
static const int k_widget_start_column;
|
||||
static const int k_max_widget_column;
|
||||
|
||||
private slots:
|
||||
void EdgeChanged(Node *output, const NodeInput &input);
|
||||
void edge_changed(Node *output, const NodeInput &input);
|
||||
|
||||
void ArrayCollapseBtnPressed(bool checked);
|
||||
void array_collapse_btn_pressed(bool checked);
|
||||
|
||||
void InputArraySizeChanged(const QString &input, int old_sz, int size);
|
||||
void input_array_size_changed(const QString &input, int old_sz, int size);
|
||||
|
||||
void ArrayAppendClicked();
|
||||
void array_append_clicked();
|
||||
|
||||
void ArrayInsertClicked();
|
||||
void array_insert_clicked();
|
||||
|
||||
void ArrayRemoveClicked();
|
||||
void array_remove_clicked();
|
||||
|
||||
void ToggleArrayExpanded();
|
||||
void toggle_array_expanded();
|
||||
|
||||
void ReplaceWidgets(const NodeInput &input);
|
||||
void replace_widgets(const NodeInput &input);
|
||||
|
||||
void ShowSpeedDurationDialogForNode();
|
||||
void show_speed_duration_dialog_for_node();
|
||||
|
||||
void OptionalCheckBoxClicked(bool e);
|
||||
void optional_check_box_clicked(bool e);
|
||||
};
|
||||
|
||||
class NodeParamViewItem : public NodeParamViewItemBase {
|
||||
@@ -175,63 +175,63 @@ public:
|
||||
NodeParamViewCheckBoxBehavior create_checkboxes,
|
||||
QWidget *parent = nullptr);
|
||||
|
||||
void SetTimeTarget(ViewerOutput *target)
|
||||
void set_time_target(ViewerOutput *target)
|
||||
{
|
||||
time_target_ = target;
|
||||
|
||||
body_->SetTimeTarget(target);
|
||||
body_->set_time_target(target);
|
||||
}
|
||||
|
||||
void SetTimebase(const rational &timebase)
|
||||
void set_timebase(const Rational &timebase)
|
||||
{
|
||||
timebase_ = timebase;
|
||||
|
||||
body_->SetTimebase(timebase);
|
||||
body_->set_timebase(timebase);
|
||||
}
|
||||
|
||||
Node *GetContext() const
|
||||
Node *get_context() const
|
||||
{
|
||||
return ctx_;
|
||||
}
|
||||
|
||||
void SetContext(Node *ctx)
|
||||
void set_context(Node *ctx)
|
||||
{
|
||||
ctx_ = ctx;
|
||||
}
|
||||
|
||||
Node *GetNode() const
|
||||
Node *get_node() const
|
||||
{
|
||||
return node_;
|
||||
}
|
||||
|
||||
int GetElementY(const NodeInput &c) const;
|
||||
int get_element_y(const NodeInput &c) const;
|
||||
|
||||
void SetInputChecked(const NodeInput &input, bool e);
|
||||
void set_input_checked(const NodeInput &input, bool e);
|
||||
|
||||
KeyframeView::NodeConnections &GetKeyframeConnections()
|
||||
KeyframeView::NodeConnections &get_keyframe_connections()
|
||||
{
|
||||
return keyframe_connections_;
|
||||
}
|
||||
|
||||
void SetKeyframeConnections(const KeyframeView::NodeConnections &c)
|
||||
void set_keyframe_connections(const KeyframeView::NodeConnections &c)
|
||||
{
|
||||
keyframe_connections_ = c;
|
||||
}
|
||||
|
||||
signals:
|
||||
void RequestSelectNode(Node *node);
|
||||
void request_select_node(Node *node);
|
||||
|
||||
void ArrayExpandedChanged(bool e);
|
||||
void array_expanded_changed(bool e);
|
||||
|
||||
void InputCheckedChanged(const NodeInput &input, bool e);
|
||||
void input_checked_changed(const NodeInput &input, bool e);
|
||||
|
||||
void RequestEditTextInViewer();
|
||||
void request_edit_text_in_viewer();
|
||||
|
||||
void InputArraySizeChanged(const QString &input, int old_size,
|
||||
void input_array_size_changed(const QString &input, int old_size,
|
||||
int new_size);
|
||||
|
||||
protected slots:
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
private:
|
||||
NodeParamViewItemBody *body_;
|
||||
@@ -247,16 +247,16 @@ private:
|
||||
|
||||
ViewerOutput *time_target_;
|
||||
|
||||
rational timebase_;
|
||||
Rational timebase_;
|
||||
|
||||
KeyframeView::NodeConnections keyframe_connections_;
|
||||
|
||||
private slots:
|
||||
void RecreateBody();
|
||||
void UpdateMessagePanel();
|
||||
void ClearMessages();
|
||||
void recreate_body();
|
||||
void update_message_panel();
|
||||
void clear_messages();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEPARAMVIEWITEM_H
|
||||
#endif // OAK_NODEPARAMVIEWITEM_H
|
||||
|
||||
@@ -40,12 +40,12 @@ NodeParamViewItemBase::NodeParamViewItemBase(QWidget *parent)
|
||||
this->setTitleBarWidget(title_bar_);
|
||||
|
||||
// Connect title bar to this
|
||||
connect(title_bar_, &NodeParamViewItemTitleBar::ExpandedStateChanged, this,
|
||||
&NodeParamViewItemBase::SetExpanded);
|
||||
connect(title_bar_, &NodeParamViewItemTitleBar::PinToggled, this,
|
||||
&NodeParamViewItemBase::PinToggled);
|
||||
connect(title_bar_, &NodeParamViewItemTitleBar::Clicked, this,
|
||||
&NodeParamViewItemBase::Clicked);
|
||||
connect(title_bar_, &NodeParamViewItemTitleBar::expanded_state_changed, this,
|
||||
&NodeParamViewItemBase::set_expanded);
|
||||
connect(title_bar_, &NodeParamViewItemTitleBar::pin_toggled, this,
|
||||
&NodeParamViewItemBase::pin_toggled);
|
||||
connect(title_bar_, &NodeParamViewItemTitleBar::clicked, this,
|
||||
&NodeParamViewItemBase::clicked);
|
||||
|
||||
// Use dummy QWidget to retain width when not expanded (QDockWidget seems to ignore the titlebar
|
||||
// size hints and will shrink as small as possible if the body is hidden)
|
||||
@@ -60,26 +60,26 @@ NodeParamViewItemBase::NodeParamViewItemBase(QWidget *parent)
|
||||
setFocusPolicy(Qt::ClickFocus);
|
||||
}
|
||||
|
||||
bool NodeParamViewItemBase::IsExpanded() const
|
||||
bool NodeParamViewItemBase::is_expanded() const
|
||||
{
|
||||
return title_bar_->IsExpanded();
|
||||
return title_bar_->is_expanded();
|
||||
}
|
||||
|
||||
QString NodeParamViewItemBase::GetTitleBarTextFromNode(Node *n)
|
||||
QString NodeParamViewItemBase::get_title_bar_text_from_node(Node *n)
|
||||
{
|
||||
if (n->GetLabel().isEmpty()) {
|
||||
return n->Name();
|
||||
if (n->get_label().isEmpty()) {
|
||||
return n->name();
|
||||
} else {
|
||||
return tr("%1 (%2)").arg(n->GetLabel(), n->Name());
|
||||
return tr("%1 (%2)").arg(n->get_label(), n->name());
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewItemBase::SetBody(QWidget *body)
|
||||
void NodeParamViewItemBase::set_body(QWidget *body)
|
||||
{
|
||||
body_ = body;
|
||||
body_->setParent(this);
|
||||
|
||||
if (title_bar_->IsExpanded()) {
|
||||
if (title_bar_->is_expanded()) {
|
||||
setWidget(body_);
|
||||
}
|
||||
}
|
||||
@@ -97,18 +97,18 @@ void NodeParamViewItemBase::paintEvent(QPaintEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewItemBase::SetExpanded(bool e)
|
||||
void NodeParamViewItemBase::set_expanded(bool e)
|
||||
{
|
||||
setWidget(e ? body_ : hidden_body_);
|
||||
title_bar_->SetExpanded(e);
|
||||
title_bar_->set_expanded(e);
|
||||
|
||||
emit ExpandedChanged(e);
|
||||
emit expanded_changed(e);
|
||||
}
|
||||
|
||||
void NodeParamViewItemBase::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
Retranslate();
|
||||
retranslate();
|
||||
}
|
||||
|
||||
super::changeEvent(e);
|
||||
@@ -118,14 +118,14 @@ void NodeParamViewItemBase::moveEvent(QMoveEvent *event)
|
||||
{
|
||||
super::moveEvent(event);
|
||||
|
||||
emit Moved();
|
||||
emit moved();
|
||||
}
|
||||
|
||||
void NodeParamViewItemBase::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
super::mousePressEvent(e);
|
||||
|
||||
emit Clicked();
|
||||
emit clicked();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NODEPARAMVIEWITEMBASE_H
|
||||
#define NODEPARAMVIEWITEMBASE_H
|
||||
#ifndef OAK_NODEPARAMVIEWITEMBASE_H
|
||||
#define OAK_NODEPARAMVIEWITEMBASE_H
|
||||
|
||||
#include <QDockWidget>
|
||||
|
||||
@@ -35,41 +35,41 @@ class NodeParamViewItemBase : public QDockWidget {
|
||||
public:
|
||||
NodeParamViewItemBase(QWidget *parent = nullptr);
|
||||
|
||||
void SetHighlighted(bool e)
|
||||
void set_highlighted(bool e)
|
||||
{
|
||||
highlighted_ = e;
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
bool IsHighlighted() const
|
||||
bool is_highlighted() const
|
||||
{
|
||||
return highlighted_;
|
||||
}
|
||||
|
||||
bool IsExpanded() const;
|
||||
bool is_expanded() const;
|
||||
|
||||
static QString GetTitleBarTextFromNode(Node *n);
|
||||
static QString get_title_bar_text_from_node(Node *n);
|
||||
|
||||
public slots:
|
||||
void SetExpanded(bool e);
|
||||
void set_expanded(bool e);
|
||||
|
||||
void ToggleExpanded()
|
||||
void toggle_expanded()
|
||||
{
|
||||
SetExpanded(!IsExpanded());
|
||||
set_expanded(!is_expanded());
|
||||
}
|
||||
|
||||
signals:
|
||||
void PinToggled(bool e);
|
||||
void pin_toggled(bool e);
|
||||
|
||||
void ExpandedChanged(bool e);
|
||||
void expanded_changed(bool e);
|
||||
|
||||
void Moved();
|
||||
void moved();
|
||||
|
||||
void Clicked();
|
||||
void clicked();
|
||||
|
||||
protected:
|
||||
void SetBody(QWidget *body);
|
||||
void set_body(QWidget *body);
|
||||
|
||||
virtual void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
@@ -85,7 +85,7 @@ protected:
|
||||
virtual void mousePressEvent(QMouseEvent *e) override;
|
||||
|
||||
protected slots:
|
||||
virtual void Retranslate()
|
||||
virtual void retranslate()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -101,4 +101,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEPARAMVIEWITEMBASE_H
|
||||
#endif // OAK_NODEPARAMVIEWITEMBASE_H
|
||||
|
||||
@@ -37,7 +37,7 @@ NodeParamViewItemTitleBar::NodeParamViewItemTitleBar(QWidget *parent)
|
||||
|
||||
collapse_btn_ = new CollapseButton(this);
|
||||
connect(collapse_btn_, &QPushButton::clicked, this,
|
||||
&NodeParamViewItemTitleBar::ExpandedStateChanged);
|
||||
&NodeParamViewItemTitleBar::expanded_state_changed);
|
||||
layout->addWidget(collapse_btn_);
|
||||
|
||||
lbl_ = new QLabel(this);
|
||||
@@ -47,13 +47,13 @@ NodeParamViewItemTitleBar::NodeParamViewItemTitleBar(QWidget *parent)
|
||||
layout->addStretch();
|
||||
|
||||
add_fx_btn_ = new QPushButton(this);
|
||||
add_fx_btn_->setIcon(icon::AddEffect);
|
||||
add_fx_btn_->setIcon(icon::add_effect);
|
||||
add_fx_btn_->setFixedSize(add_fx_btn_->sizeHint().height(),
|
||||
add_fx_btn_->sizeHint().height());
|
||||
add_fx_btn_->setVisible(false);
|
||||
layout->addWidget(add_fx_btn_);
|
||||
connect(add_fx_btn_, &QPushButton::clicked, this,
|
||||
&NodeParamViewItemTitleBar::AddEffectButtonClicked);
|
||||
&NodeParamViewItemTitleBar::add_effect_button_clicked);
|
||||
|
||||
pin_btn_ = new QPushButton(QStringLiteral("P"), this);
|
||||
pin_btn_->setCheckable(true);
|
||||
@@ -62,16 +62,16 @@ NodeParamViewItemTitleBar::NodeParamViewItemTitleBar(QWidget *parent)
|
||||
pin_btn_->setVisible(false);
|
||||
layout->addWidget(pin_btn_);
|
||||
connect(pin_btn_, &QPushButton::clicked, this,
|
||||
&NodeParamViewItemTitleBar::PinToggled);
|
||||
&NodeParamViewItemTitleBar::pin_toggled);
|
||||
|
||||
enabled_checkbox_ = new QCheckBox(this);
|
||||
enabled_checkbox_->setVisible(false);
|
||||
layout->addWidget(enabled_checkbox_);
|
||||
connect(enabled_checkbox_, &QCheckBox::clicked, this,
|
||||
&NodeParamViewItemTitleBar::EnabledCheckBoxClicked);
|
||||
&NodeParamViewItemTitleBar::enabled_check_box_clicked);
|
||||
}
|
||||
|
||||
void NodeParamViewItemTitleBar::SetExpanded(bool e)
|
||||
void NodeParamViewItemTitleBar::set_expanded(bool e)
|
||||
{
|
||||
draw_border_ = e;
|
||||
collapse_btn_->setChecked(e);
|
||||
@@ -97,7 +97,7 @@ void NodeParamViewItemTitleBar::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
QWidget::mousePressEvent(event);
|
||||
|
||||
emit Clicked();
|
||||
emit clicked();
|
||||
}
|
||||
|
||||
void NodeParamViewItemTitleBar::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NODEPARAMVIEWITEMTITLEBAR_H
|
||||
#define NODEPARAMVIEWITEMTITLEBAR_H
|
||||
#ifndef OAK_NODEPARAMVIEWITEMTITLEBAR_H
|
||||
#define OAK_NODEPARAMVIEWITEMTITLEBAR_H
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QLabel>
|
||||
@@ -36,51 +36,51 @@ class NodeParamViewItemTitleBar : public QWidget {
|
||||
public:
|
||||
NodeParamViewItemTitleBar(QWidget *parent = nullptr);
|
||||
|
||||
bool IsExpanded() const
|
||||
bool is_expanded() const
|
||||
{
|
||||
return collapse_btn_->isChecked();
|
||||
}
|
||||
|
||||
public slots:
|
||||
void SetExpanded(bool e);
|
||||
void set_expanded(bool e);
|
||||
|
||||
void SetText(const QString &s)
|
||||
void set_text(const QString &s)
|
||||
{
|
||||
lbl_->setText(s);
|
||||
lbl_->setToolTip(s);
|
||||
lbl_->setMinimumWidth(1);
|
||||
}
|
||||
|
||||
void SetPinButtonVisible(bool e)
|
||||
void set_pin_button_visible(bool e)
|
||||
{
|
||||
pin_btn_->setVisible(e);
|
||||
}
|
||||
|
||||
void SetAddEffectButtonVisible(bool e)
|
||||
void set_add_effect_button_visible(bool e)
|
||||
{
|
||||
add_fx_btn_->setVisible(e);
|
||||
}
|
||||
|
||||
void SetEnabledCheckBoxVisible(bool e)
|
||||
void set_enabled_check_box_visible(bool e)
|
||||
{
|
||||
enabled_checkbox_->setVisible(e);
|
||||
}
|
||||
|
||||
void SetEnabledCheckBoxChecked(bool e)
|
||||
void set_enabled_check_box_checked(bool e)
|
||||
{
|
||||
enabled_checkbox_->setChecked(e);
|
||||
}
|
||||
|
||||
signals:
|
||||
void ExpandedStateChanged(bool e);
|
||||
void expanded_state_changed(bool e);
|
||||
|
||||
void PinToggled(bool e);
|
||||
void pin_toggled(bool e);
|
||||
|
||||
void AddEffectButtonClicked();
|
||||
void add_effect_button_clicked();
|
||||
|
||||
void EnabledCheckBoxClicked(bool e);
|
||||
void enabled_check_box_clicked(bool e);
|
||||
|
||||
void Clicked();
|
||||
void clicked();
|
||||
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent *event) override;
|
||||
@@ -104,4 +104,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEPARAMVIEWITEMTITLEBAR_H
|
||||
#endif // OAK_NODEPARAMVIEWITEMTITLEBAR_H
|
||||
|
||||
@@ -44,89 +44,89 @@ NodeParamViewKeyframeControl::NodeParamViewKeyframeControl(bool right_align,
|
||||
layout->addStretch();
|
||||
}
|
||||
|
||||
prev_key_btn_ = CreateNewToolButton(icon::TriLeft);
|
||||
prev_key_btn_ = create_new_tool_button(icon::tri_left);
|
||||
prev_key_btn_->setIconSize(prev_key_btn_->iconSize() / 2);
|
||||
layout->addWidget(prev_key_btn_);
|
||||
|
||||
toggle_key_btn_ = CreateNewToolButton(icon::Diamond);
|
||||
toggle_key_btn_ = create_new_tool_button(icon::diamond);
|
||||
toggle_key_btn_->setCheckable(true);
|
||||
toggle_key_btn_->setIconSize(toggle_key_btn_->iconSize() / 2);
|
||||
layout->addWidget(toggle_key_btn_);
|
||||
|
||||
next_key_btn_ = CreateNewToolButton(icon::TriRight);
|
||||
next_key_btn_ = create_new_tool_button(icon::tri_right);
|
||||
next_key_btn_->setIconSize(next_key_btn_->iconSize() / 2);
|
||||
layout->addWidget(next_key_btn_);
|
||||
|
||||
enable_key_btn_ = CreateNewToolButton(icon::Clock);
|
||||
enable_key_btn_ = create_new_tool_button(icon::clock);
|
||||
enable_key_btn_->setCheckable(true);
|
||||
enable_key_btn_->setIconSize(enable_key_btn_->iconSize() / 4 * 3);
|
||||
layout->addWidget(enable_key_btn_);
|
||||
|
||||
connect(prev_key_btn_, &QPushButton::clicked, this,
|
||||
&NodeParamViewKeyframeControl::GoToPreviousKey);
|
||||
&NodeParamViewKeyframeControl::go_to_previous_key);
|
||||
connect(next_key_btn_, &QPushButton::clicked, this,
|
||||
&NodeParamViewKeyframeControl::GoToNextKey);
|
||||
&NodeParamViewKeyframeControl::go_to_next_key);
|
||||
connect(toggle_key_btn_, &QPushButton::clicked, this,
|
||||
&NodeParamViewKeyframeControl::ToggleKeyframe);
|
||||
&NodeParamViewKeyframeControl::toggle_keyframe);
|
||||
connect(enable_key_btn_, &QPushButton::toggled, this,
|
||||
&NodeParamViewKeyframeControl::ShowButtonsFromKeyframeEnable);
|
||||
&NodeParamViewKeyframeControl::show_buttons_from_keyframe_enable);
|
||||
connect(enable_key_btn_, &QPushButton::clicked, this,
|
||||
&NodeParamViewKeyframeControl::KeyframeEnableBtnClicked);
|
||||
&NodeParamViewKeyframeControl::keyframe_enable_btn_clicked);
|
||||
|
||||
// Set defaults
|
||||
SetInput(NodeInput());
|
||||
ShowButtonsFromKeyframeEnable(false);
|
||||
set_input(NodeInput());
|
||||
show_buttons_from_keyframe_enable(false);
|
||||
}
|
||||
|
||||
void NodeParamViewKeyframeControl::SetInput(const NodeInput &input)
|
||||
void NodeParamViewKeyframeControl::set_input(const NodeInput &input)
|
||||
{
|
||||
if (input_.IsValid()) {
|
||||
disconnect(input_.node(), &Node::KeyframeEnableChanged, this,
|
||||
&NodeParamViewKeyframeControl::KeyframeEnableChanged);
|
||||
disconnect(input_.node(), &Node::KeyframeAdded, this,
|
||||
&NodeParamViewKeyframeControl::UpdateState);
|
||||
disconnect(input_.node(), &Node::KeyframeRemoved, this,
|
||||
&NodeParamViewKeyframeControl::UpdateState);
|
||||
disconnect(input_.node(), &Node::KeyframeTimeChanged, this,
|
||||
&NodeParamViewKeyframeControl::UpdateState);
|
||||
if (input_.is_valid()) {
|
||||
disconnect(input_.node(), &Node::keyframe_enable_changed, this,
|
||||
&NodeParamViewKeyframeControl::keyframe_enable_changed);
|
||||
disconnect(input_.node(), &Node::keyframe_added, this,
|
||||
&NodeParamViewKeyframeControl::update_state);
|
||||
disconnect(input_.node(), &Node::keyframe_removed, this,
|
||||
&NodeParamViewKeyframeControl::update_state);
|
||||
disconnect(input_.node(), &Node::keyframe_time_changed, this,
|
||||
&NodeParamViewKeyframeControl::update_state);
|
||||
}
|
||||
|
||||
input_ = input;
|
||||
SetButtonsEnabled(input_.IsValid());
|
||||
set_buttons_enabled(input_.is_valid());
|
||||
|
||||
// Pick up keyframing value
|
||||
enable_key_btn_->setChecked(input_.IsValid() && input_.IsKeyframing());
|
||||
enable_key_btn_->setChecked(input_.is_valid() && input_.is_keyframing());
|
||||
|
||||
// Update buttons
|
||||
UpdateState();
|
||||
update_state();
|
||||
|
||||
if (input_.IsValid()) {
|
||||
connect(input_.node(), &Node::KeyframeEnableChanged, this,
|
||||
&NodeParamViewKeyframeControl::KeyframeEnableChanged);
|
||||
connect(input_.node(), &Node::KeyframeAdded, this,
|
||||
&NodeParamViewKeyframeControl::UpdateState);
|
||||
connect(input_.node(), &Node::KeyframeRemoved, this,
|
||||
&NodeParamViewKeyframeControl::UpdateState);
|
||||
connect(input_.node(), &Node::KeyframeTimeChanged, this,
|
||||
&NodeParamViewKeyframeControl::UpdateState);
|
||||
if (input_.is_valid()) {
|
||||
connect(input_.node(), &Node::keyframe_enable_changed, this,
|
||||
&NodeParamViewKeyframeControl::keyframe_enable_changed);
|
||||
connect(input_.node(), &Node::keyframe_added, this,
|
||||
&NodeParamViewKeyframeControl::update_state);
|
||||
connect(input_.node(), &Node::keyframe_removed, this,
|
||||
&NodeParamViewKeyframeControl::update_state);
|
||||
connect(input_.node(), &Node::keyframe_time_changed, this,
|
||||
&NodeParamViewKeyframeControl::update_state);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewKeyframeControl::TimeTargetDisconnectEvent(ViewerOutput *v)
|
||||
{
|
||||
disconnect(v, &ViewerOutput::PlayheadChanged, this,
|
||||
&NodeParamViewKeyframeControl::UpdateState);
|
||||
disconnect(v, &ViewerOutput::playhead_changed, this,
|
||||
&NodeParamViewKeyframeControl::update_state);
|
||||
}
|
||||
|
||||
void NodeParamViewKeyframeControl::TimeTargetConnectEvent(ViewerOutput *v)
|
||||
{
|
||||
connect(v, &ViewerOutput::PlayheadChanged, this,
|
||||
&NodeParamViewKeyframeControl::UpdateState);
|
||||
UpdateState();
|
||||
connect(v, &ViewerOutput::playhead_changed, this,
|
||||
&NodeParamViewKeyframeControl::update_state);
|
||||
update_state();
|
||||
}
|
||||
|
||||
QPushButton *
|
||||
NodeParamViewKeyframeControl::CreateNewToolButton(const QIcon &icon) const
|
||||
NodeParamViewKeyframeControl::create_new_tool_button(const QIcon &icon) const
|
||||
{
|
||||
QPushButton *btn = new QPushButton();
|
||||
btn->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
|
||||
@@ -135,7 +135,7 @@ NodeParamViewKeyframeControl::CreateNewToolButton(const QIcon &icon) const
|
||||
return btn;
|
||||
}
|
||||
|
||||
void NodeParamViewKeyframeControl::SetButtonsEnabled(bool e)
|
||||
void NodeParamViewKeyframeControl::set_buttons_enabled(bool e)
|
||||
{
|
||||
prev_key_btn_->setEnabled(e);
|
||||
toggle_key_btn_->setEnabled(e);
|
||||
@@ -143,45 +143,45 @@ void NodeParamViewKeyframeControl::SetButtonsEnabled(bool e)
|
||||
enable_key_btn_->setEnabled(e);
|
||||
}
|
||||
|
||||
rational NodeParamViewKeyframeControl::GetCurrentTimeAsNodeTime() const
|
||||
Rational NodeParamViewKeyframeControl::get_current_time_as_node_time() const
|
||||
{
|
||||
return GetAdjustedTime(GetTimeTarget(), input_.node(),
|
||||
GetTimeTarget()->GetPlayhead(),
|
||||
Node::kTransformTowardsInput);
|
||||
return get_adjusted_time(get_time_target(), input_.node(),
|
||||
get_time_target()->get_playhead(),
|
||||
Node::k_transform_towards_input);
|
||||
}
|
||||
|
||||
rational
|
||||
NodeParamViewKeyframeControl::ConvertToViewerTime(const rational &r) const
|
||||
Rational
|
||||
NodeParamViewKeyframeControl::convert_to_viewer_time(const Rational &r) const
|
||||
{
|
||||
return GetAdjustedTime(input_.node(), GetTimeTarget(), r,
|
||||
Node::kTransformTowardsOutput);
|
||||
return get_adjusted_time(input_.node(), get_time_target(), r,
|
||||
Node::k_transform_towards_output);
|
||||
}
|
||||
|
||||
void NodeParamViewKeyframeControl::ShowButtonsFromKeyframeEnable(bool e)
|
||||
void NodeParamViewKeyframeControl::show_buttons_from_keyframe_enable(bool e)
|
||||
{
|
||||
prev_key_btn_->setVisible(e);
|
||||
toggle_key_btn_->setVisible(e);
|
||||
next_key_btn_->setVisible(e);
|
||||
}
|
||||
|
||||
void NodeParamViewKeyframeControl::ToggleKeyframe(bool e)
|
||||
void NodeParamViewKeyframeControl::toggle_keyframe(bool e)
|
||||
{
|
||||
rational node_time = GetCurrentTimeAsNodeTime();
|
||||
Rational node_time = get_current_time_as_node_time();
|
||||
|
||||
QVector<NodeKeyframe *> keys =
|
||||
input_.node()->GetKeyframesAtTime(input_, node_time);
|
||||
input_.node()->get_keyframes_at_time(input_, node_time);
|
||||
|
||||
MultiUndoCommand *command = new MultiUndoCommand();
|
||||
|
||||
int nb_tracks = input_.node()->GetNumberOfKeyframeTracks(input_);
|
||||
int nb_tracks = input_.node()->get_number_of_keyframe_tracks(input_);
|
||||
|
||||
if (e && keys.isEmpty()) {
|
||||
// Add a keyframe here (one for each track)
|
||||
for (int i = 0; i < nb_tracks; i++) {
|
||||
NodeKeyframe *key = new NodeKeyframe(
|
||||
node_time,
|
||||
input_.node()->GetSplitValueAtTimeOnTrack(input_, node_time, i),
|
||||
input_.node()->GetBestKeyframeTypeForTimeOnTrack(input_,
|
||||
input_.node()->get_split_value_at_time_on_track(input_, node_time, i),
|
||||
input_.node()->get_best_keyframe_type_for_time_on_track(input_,
|
||||
node_time, i),
|
||||
i, input_.element(), input_.input());
|
||||
|
||||
@@ -193,11 +193,11 @@ void NodeParamViewKeyframeControl::ToggleKeyframe(bool e)
|
||||
foreach (NodeKeyframe *key, keys) {
|
||||
command->add_child(new NodeParamRemoveKeyframeCommand(key));
|
||||
|
||||
if (input_.node()->GetKeyframeTracks(input_).size() == 1) {
|
||||
if (input_.node()->get_keyframe_tracks(input_).size() == 1) {
|
||||
// If this was the last keyframe on this track, set the standard value to the value at this time too
|
||||
command->add_child(new NodeParamSetStandardValueCommand(
|
||||
NodeKeyframeTrackReference(input_, key->track()),
|
||||
input_.node()->GetSplitValueAtTimeOnTrack(input_, node_time,
|
||||
input_.node()->get_split_value_at_time_on_track(input_, node_time,
|
||||
key->track())));
|
||||
}
|
||||
}
|
||||
@@ -206,52 +206,52 @@ void NodeParamViewKeyframeControl::ToggleKeyframe(bool e)
|
||||
Core::instance()->undo_stack()->push(command, tr("Toggled Keyframe"));
|
||||
}
|
||||
|
||||
void NodeParamViewKeyframeControl::UpdateState()
|
||||
void NodeParamViewKeyframeControl::update_state()
|
||||
{
|
||||
if (!input_.IsValid() || !input_.IsKeyframing() || !GetTimeTarget()) {
|
||||
if (!input_.is_valid() || !input_.is_keyframing() || !get_time_target()) {
|
||||
return;
|
||||
}
|
||||
|
||||
NodeKeyframe *earliest_key = input_.node()->GetEarliestKeyframe(input_);
|
||||
NodeKeyframe *latest_key = input_.node()->GetLatestKeyframe(input_);
|
||||
NodeKeyframe *earliest_key = input_.node()->get_earliest_keyframe(input_);
|
||||
NodeKeyframe *latest_key = input_.node()->get_latest_keyframe(input_);
|
||||
|
||||
rational node_time = GetCurrentTimeAsNodeTime();
|
||||
Rational node_time = get_current_time_as_node_time();
|
||||
|
||||
prev_key_btn_->setEnabled(earliest_key && node_time > earliest_key->time());
|
||||
next_key_btn_->setEnabled(latest_key && node_time < latest_key->time());
|
||||
toggle_key_btn_->setChecked(
|
||||
input_.node()->HasKeyframeAtTime(input_, node_time));
|
||||
input_.node()->has_keyframe_at_time(input_, node_time));
|
||||
}
|
||||
|
||||
void NodeParamViewKeyframeControl::GoToPreviousKey()
|
||||
void NodeParamViewKeyframeControl::go_to_previous_key()
|
||||
{
|
||||
rational node_time = GetCurrentTimeAsNodeTime();
|
||||
Rational node_time = get_current_time_as_node_time();
|
||||
|
||||
NodeKeyframe *previous_key =
|
||||
input_.node()->GetClosestKeyframeBeforeTime(input_, node_time);
|
||||
input_.node()->get_closest_keyframe_before_time(input_, node_time);
|
||||
|
||||
if (previous_key && GetTimeTarget()) {
|
||||
rational key_time = ConvertToViewerTime(previous_key->time());
|
||||
GetTimeTarget()->SetPlayhead(key_time);
|
||||
if (previous_key && get_time_target()) {
|
||||
Rational key_time = convert_to_viewer_time(previous_key->time());
|
||||
get_time_target()->set_playhead(key_time);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewKeyframeControl::GoToNextKey()
|
||||
void NodeParamViewKeyframeControl::go_to_next_key()
|
||||
{
|
||||
rational node_time = GetCurrentTimeAsNodeTime();
|
||||
Rational node_time = get_current_time_as_node_time();
|
||||
|
||||
NodeKeyframe *next_key =
|
||||
input_.node()->GetClosestKeyframeAfterTime(input_, node_time);
|
||||
input_.node()->get_closest_keyframe_after_time(input_, node_time);
|
||||
|
||||
if (next_key && GetTimeTarget()) {
|
||||
rational key_time = ConvertToViewerTime(next_key->time());
|
||||
GetTimeTarget()->SetPlayhead(key_time);
|
||||
if (next_key && get_time_target()) {
|
||||
Rational key_time = convert_to_viewer_time(next_key->time());
|
||||
get_time_target()->set_playhead(key_time);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewKeyframeControl::KeyframeEnableBtnClicked(bool e)
|
||||
void NodeParamViewKeyframeControl::keyframe_enable_btn_clicked(bool e)
|
||||
{
|
||||
if (e == input_.IsKeyframing()) {
|
||||
if (e == input_.is_keyframing()) {
|
||||
// No-op
|
||||
return;
|
||||
}
|
||||
@@ -266,12 +266,12 @@ void NodeParamViewKeyframeControl::KeyframeEnableBtnClicked(bool e)
|
||||
|
||||
// Create one keyframe across all tracks here
|
||||
const QVector<QVariant> &key_vals =
|
||||
input_.node()->GetSplitStandardValue(input_);
|
||||
input_.node()->get_split_standard_value(input_);
|
||||
|
||||
for (int i = 0; i < key_vals.size(); i++) {
|
||||
NodeKeyframe *key =
|
||||
new NodeKeyframe(GetCurrentTimeAsNodeTime(), key_vals.at(i),
|
||||
NodeKeyframe::kDefaultType, i,
|
||||
new NodeKeyframe(get_current_time_as_node_time(), key_vals.at(i),
|
||||
NodeKeyframe::k_default_type, i,
|
||||
input_.element(), input_.input());
|
||||
|
||||
command->add_child(
|
||||
@@ -280,7 +280,7 @@ void NodeParamViewKeyframeControl::KeyframeEnableBtnClicked(bool e)
|
||||
|
||||
command_name =
|
||||
tr("Enabled Keyframing On %1 - %2")
|
||||
.arg(input_.node()->GetLabelAndName(), input_.GetInputName());
|
||||
.arg(input_.node()->get_label_and_name(), input_.get_input_name());
|
||||
} else {
|
||||
// Confirm the user wants to clear all keyframes
|
||||
if (QMessageBox::warning(
|
||||
@@ -289,12 +289,12 @@ void NodeParamViewKeyframeControl::KeyframeEnableBtnClicked(bool e)
|
||||
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
|
||||
// Store value at this time, we'll set this as the persistent value later
|
||||
const QVector<QVariant> &stored_vals =
|
||||
input_.node()->GetSplitValueAtTime(input_,
|
||||
GetCurrentTimeAsNodeTime());
|
||||
input_.node()->get_split_value_at_time(input_,
|
||||
get_current_time_as_node_time());
|
||||
|
||||
// Delete all keyframes
|
||||
foreach (const NodeKeyframeTrack &track,
|
||||
input_.node()->GetKeyframeTracks(input_)) {
|
||||
input_.node()->get_keyframe_tracks(input_)) {
|
||||
for (int i = track.size() - 1; i >= 0; i--) {
|
||||
command->add_child(
|
||||
new NodeParamRemoveKeyframeCommand(track.at(i)));
|
||||
@@ -312,8 +312,8 @@ void NodeParamViewKeyframeControl::KeyframeEnableBtnClicked(bool e)
|
||||
new NodeParamSetKeyframingCommand(input_, false));
|
||||
|
||||
command_name = tr("Disabled Keyframing On %1 - %2")
|
||||
.arg(input_.node()->GetLabelAndName(),
|
||||
input_.GetInputName());
|
||||
.arg(input_.node()->get_label_and_name(),
|
||||
input_.get_input_name());
|
||||
} else {
|
||||
// Disable action has effectively been ignored
|
||||
enable_key_btn_->setChecked(true);
|
||||
@@ -323,7 +323,7 @@ void NodeParamViewKeyframeControl::KeyframeEnableBtnClicked(bool e)
|
||||
Core::instance()->undo_stack()->push(command, command_name);
|
||||
}
|
||||
|
||||
void NodeParamViewKeyframeControl::KeyframeEnableChanged(const NodeInput &input,
|
||||
void NodeParamViewKeyframeControl::keyframe_enable_changed(const NodeInput &input,
|
||||
bool e)
|
||||
{
|
||||
if (input_ == input) {
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NODEPARAMVIEWKEYFRAMECONTROL_H
|
||||
#define NODEPARAMVIEWKEYFRAMECONTROL_H
|
||||
#ifndef OAK_NODEPARAMVIEWKEYFRAMECONTROL_H
|
||||
#define OAK_NODEPARAMVIEWKEYFRAMECONTROL_H
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QWidget>
|
||||
@@ -40,25 +40,25 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
const NodeInput &GetConnectedInput() const
|
||||
const NodeInput &get_connected_input() const
|
||||
{
|
||||
return input_;
|
||||
}
|
||||
|
||||
void SetInput(const NodeInput &input);
|
||||
void set_input(const NodeInput &input);
|
||||
|
||||
protected:
|
||||
virtual void TimeTargetDisconnectEvent(ViewerOutput *v) override;
|
||||
virtual void TimeTargetConnectEvent(ViewerOutput *v) override;
|
||||
|
||||
private:
|
||||
QPushButton *CreateNewToolButton(const QIcon &icon) const;
|
||||
QPushButton *create_new_tool_button(const QIcon &icon) const;
|
||||
|
||||
void SetButtonsEnabled(bool e);
|
||||
void set_buttons_enabled(bool e);
|
||||
|
||||
rational GetCurrentTimeAsNodeTime() const;
|
||||
Rational get_current_time_as_node_time() const;
|
||||
|
||||
rational ConvertToViewerTime(const rational &r) const;
|
||||
Rational convert_to_viewer_time(const Rational &r) const;
|
||||
|
||||
QPushButton *prev_key_btn_;
|
||||
QPushButton *toggle_key_btn_;
|
||||
@@ -68,21 +68,21 @@ private:
|
||||
NodeInput input_;
|
||||
|
||||
private slots:
|
||||
void ShowButtonsFromKeyframeEnable(bool e);
|
||||
void show_buttons_from_keyframe_enable(bool e);
|
||||
|
||||
void ToggleKeyframe(bool e);
|
||||
void toggle_keyframe(bool e);
|
||||
|
||||
void UpdateState();
|
||||
void update_state();
|
||||
|
||||
void GoToPreviousKey();
|
||||
void go_to_previous_key();
|
||||
|
||||
void GoToNextKey();
|
||||
void go_to_next_key();
|
||||
|
||||
void KeyframeEnableBtnClicked(bool e);
|
||||
void keyframe_enable_btn_clicked(bool e);
|
||||
|
||||
void KeyframeEnableChanged(const NodeInput &input, bool e);
|
||||
void keyframe_enable_changed(const NodeInput &input, bool e);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEPARAMVIEWKEYFRAMECONTROL_H
|
||||
#endif // OAK_NODEPARAMVIEWKEYFRAMECONTROL_H
|
||||
|
||||
@@ -38,46 +38,46 @@ NodeParamViewTextEdit::NodeParamViewTextEdit(QWidget *parent)
|
||||
line_edit_ = new QPlainTextEdit();
|
||||
line_edit_->setUndoRedoEnabled(true);
|
||||
connect(line_edit_, &QPlainTextEdit::textChanged, this,
|
||||
&NodeParamViewTextEdit::InnerWidgetTextChanged);
|
||||
&NodeParamViewTextEdit::inner_widget_text_changed);
|
||||
layout->addWidget(line_edit_);
|
||||
|
||||
edit_btn_ = new QPushButton();
|
||||
edit_btn_->setIcon(icon::ToolEdit);
|
||||
edit_btn_->setIcon(icon::tool_edit);
|
||||
edit_btn_->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Expanding);
|
||||
layout->addWidget(edit_btn_);
|
||||
connect(edit_btn_, &QPushButton::clicked, this,
|
||||
&NodeParamViewTextEdit::ShowTextDialog);
|
||||
&NodeParamViewTextEdit::show_text_dialog);
|
||||
|
||||
edit_in_viewer_btn_ = new QPushButton(tr("Edit In Viewer"));
|
||||
edit_in_viewer_btn_->setIcon(icon::Pencil);
|
||||
edit_in_viewer_btn_->setIcon(icon::pencil);
|
||||
layout->addWidget(edit_in_viewer_btn_);
|
||||
connect(edit_in_viewer_btn_, &QPushButton::clicked, this,
|
||||
&NodeParamViewTextEdit::RequestEditInViewer);
|
||||
&NodeParamViewTextEdit::request_edit_in_viewer);
|
||||
|
||||
SetEditInViewerOnlyMode(false);
|
||||
set_edit_in_viewer_only_mode(false);
|
||||
}
|
||||
|
||||
void NodeParamViewTextEdit::SetEditInViewerOnlyMode(bool on)
|
||||
void NodeParamViewTextEdit::set_edit_in_viewer_only_mode(bool on)
|
||||
{
|
||||
line_edit_->setVisible(!on);
|
||||
edit_btn_->setVisible(!on);
|
||||
edit_in_viewer_btn_->setVisible(on);
|
||||
}
|
||||
|
||||
void NodeParamViewTextEdit::ShowTextDialog()
|
||||
void NodeParamViewTextEdit::show_text_dialog()
|
||||
{
|
||||
TextDialog d(this->text(), this);
|
||||
if (d.exec() == QDialog::Accepted) {
|
||||
QString s = d.text();
|
||||
|
||||
line_edit_->setPlainText(s);
|
||||
emit textEdited(s);
|
||||
emit text_edited(s);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamViewTextEdit::InnerWidgetTextChanged()
|
||||
void NodeParamViewTextEdit::inner_widget_text_changed()
|
||||
{
|
||||
emit textEdited(this->text());
|
||||
emit text_edited(this->text());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NODEPARAMVIEWTEXTEDIT_H
|
||||
#define NODEPARAMVIEWTEXTEDIT_H
|
||||
#ifndef OAK_NODEPARAMVIEWTEXTEDIT_H
|
||||
#define OAK_NODEPARAMVIEWTEXTEDIT_H
|
||||
|
||||
#include <QPlainTextEdit>
|
||||
#include <QPushButton>
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
return line_edit_->toPlainText();
|
||||
}
|
||||
|
||||
void SetEditInViewerOnlyMode(bool on);
|
||||
void set_edit_in_viewer_only_mode(bool on);
|
||||
|
||||
public slots:
|
||||
void setText(const QString &s)
|
||||
@@ -66,9 +66,9 @@ public slots:
|
||||
}
|
||||
|
||||
signals:
|
||||
void textEdited(const QString &);
|
||||
void text_edited(const QString &);
|
||||
|
||||
void RequestEditInViewer();
|
||||
void request_edit_in_viewer();
|
||||
|
||||
private:
|
||||
QPlainTextEdit *line_edit_;
|
||||
@@ -78,11 +78,11 @@ private:
|
||||
QPushButton *edit_in_viewer_btn_;
|
||||
|
||||
private slots:
|
||||
void ShowTextDialog();
|
||||
void show_text_dialog();
|
||||
|
||||
void InnerWidgetTextChanged();
|
||||
void inner_widget_text_changed();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEPARAMVIEWTEXTEDIT_H
|
||||
#endif // OAK_NODEPARAMVIEWTEXTEDIT_H
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NODEPARAMVIEWWIDGETBRIDGE_H
|
||||
#define NODEPARAMVIEWWIDGETBRIDGE_H
|
||||
#ifndef OAK_NODEPARAMVIEWWIDGETBRIDGE_H
|
||||
#define OAK_NODEPARAMVIEWWIDGETBRIDGE_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
@@ -48,61 +48,61 @@ public:
|
||||
}
|
||||
|
||||
// Set the timebase of certain Timebased widgets
|
||||
void SetTimebase(const rational &timebase);
|
||||
void set_timebase(const Rational &timebase);
|
||||
|
||||
signals:
|
||||
void ArrayWidgetDoubleClicked();
|
||||
void array_widget_double_clicked();
|
||||
|
||||
void WidgetsRecreated(const NodeInput &input);
|
||||
void widgets_recreated(const NodeInput &input);
|
||||
|
||||
void RequestEditTextInViewer();
|
||||
void request_edit_text_in_viewer();
|
||||
|
||||
protected:
|
||||
virtual void TimeTargetDisconnectEvent(ViewerOutput *v) override;
|
||||
virtual void TimeTargetConnectEvent(ViewerOutput *v) override;
|
||||
|
||||
private:
|
||||
void CreateWidgets();
|
||||
void create_widgets();
|
||||
|
||||
void SetInputValue(const QVariant &value, int track);
|
||||
void set_input_value(const QVariant &value, int track);
|
||||
|
||||
void SetInputValueInternal(const QVariant &value, int track,
|
||||
void set_input_value_internal(const QVariant &value, int track,
|
||||
MultiUndoCommand *command,
|
||||
bool insert_on_all_tracks_if_no_key);
|
||||
|
||||
void ProcessSlider(NumericSliderBase *slider, int slider_track,
|
||||
void process_slider(NumericSliderBase *slider, int slider_track,
|
||||
const QVariant &value);
|
||||
void ProcessSlider(NumericSliderBase *slider, const QVariant &value)
|
||||
void process_slider(NumericSliderBase *slider, const QVariant &value)
|
||||
{
|
||||
ProcessSlider(slider, widgets_.indexOf(slider), value);
|
||||
process_slider(slider, widgets_.indexOf(slider), value);
|
||||
}
|
||||
|
||||
void SetProperty(const QString &key, const QVariant &value);
|
||||
void set_property(const QString &key, const QVariant &value);
|
||||
|
||||
template <typename T> void CreateSliders(int count, QWidget *parent);
|
||||
template <typename T> void create_sliders(int count, QWidget *parent);
|
||||
|
||||
void UpdateWidgetValues();
|
||||
void update_widget_values();
|
||||
|
||||
rational GetCurrentTimeAsNodeTime() const;
|
||||
Rational get_current_time_as_node_time() const;
|
||||
|
||||
const NodeInput &GetOuterInput() const
|
||||
const NodeInput &get_outer_input() const
|
||||
{
|
||||
return input_hierarchy_.first();
|
||||
}
|
||||
|
||||
const NodeInput &GetInnerInput() const
|
||||
const NodeInput &get_inner_input() const
|
||||
{
|
||||
return input_hierarchy_.last();
|
||||
}
|
||||
|
||||
QString GetCommandName() const;
|
||||
QString get_command_name() const;
|
||||
|
||||
NodeValue::Type GetDataType() const
|
||||
NodeValue::Type get_data_type() const
|
||||
{
|
||||
return GetOuterInput().GetDataType();
|
||||
return get_outer_input().get_data_type();
|
||||
}
|
||||
|
||||
void UpdateProperties();
|
||||
void update_properties();
|
||||
|
||||
QVector<NodeInput> input_hierarchy_;
|
||||
|
||||
@@ -113,16 +113,16 @@ private:
|
||||
NodeParamViewScrollBlocker scroll_filter_;
|
||||
|
||||
private slots:
|
||||
void WidgetCallback();
|
||||
void widget_callback();
|
||||
|
||||
void InputValueChanged(const NodeInput &input, const TimeRange &range);
|
||||
void input_value_changed(const NodeInput &input, const TimeRange &range);
|
||||
|
||||
void InputDataTypeChanged(const QString &input, NodeValue::Type type);
|
||||
void input_data_type_changed(const QString &input, NodeValue::Type type);
|
||||
|
||||
void PropertyChanged(const QString &input, const QString &key,
|
||||
void property_changed(const QString &input, const QString &key,
|
||||
const QVariant &value);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEPARAMVIEWWIDGETBRIDGE_H
|
||||
#endif // OAK_NODEPARAMVIEWWIDGETBRIDGE_H
|
||||
|
||||
@@ -37,27 +37,27 @@ NodeTableView::NodeTableView(QWidget *parent)
|
||||
tr("A/W") });
|
||||
}
|
||||
|
||||
void NodeTableView::SelectNodes(const QVector<Node *> &nodes)
|
||||
void NodeTableView::select_nodes(const QVector<Node *> &nodes)
|
||||
{
|
||||
foreach (Node *n, nodes) {
|
||||
QTreeWidgetItem *top_item = new QTreeWidgetItem();
|
||||
top_item->setText(0, n->GetLabelAndName());
|
||||
top_item->setText(0, n->get_label_and_name());
|
||||
top_item->setFirstColumnSpanned(true);
|
||||
this->addTopLevelItem(top_item);
|
||||
top_level_item_map_.insert(n, top_item);
|
||||
}
|
||||
|
||||
SetTime(last_time_);
|
||||
set_time(last_time_);
|
||||
}
|
||||
|
||||
void NodeTableView::DeselectNodes(const QVector<Node *> &nodes)
|
||||
void NodeTableView::deselect_nodes(const QVector<Node *> &nodes)
|
||||
{
|
||||
foreach (Node *n, nodes) {
|
||||
delete top_level_item_map_.take(n);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeTableView::SetTime(const rational &time)
|
||||
void NodeTableView::set_time(const Rational &time)
|
||||
{
|
||||
last_time_ = time;
|
||||
|
||||
@@ -70,7 +70,7 @@ void NodeTableView::SetTime(const rational &time)
|
||||
|
||||
// Generate a value database for this node at this time
|
||||
NodeValueDatabase db =
|
||||
traverser.GenerateDatabase(node, TimeRange(time, time));
|
||||
traverser.generate_database(node, TimeRange(time, time));
|
||||
|
||||
// Delete any children of this item that aren't in this database
|
||||
for (int j = 0; j < item->childCount(); j++) {
|
||||
@@ -85,7 +85,7 @@ void NodeTableView::SetTime(const rational &time)
|
||||
for (auto l = db.begin(); l != db.end(); l++) {
|
||||
const NodeValueTable &table = l.value();
|
||||
|
||||
if (!node->HasInputWithID(l.key())) {
|
||||
if (!node->has_input_with_id(l.key())) {
|
||||
// Filters out table entries that aren't inputs (like "global")
|
||||
continue;
|
||||
}
|
||||
@@ -103,49 +103,49 @@ void NodeTableView::SetTime(const rational &time)
|
||||
|
||||
if (!input_item) {
|
||||
input_item = new QTreeWidgetItem();
|
||||
input_item->setText(0, node->GetInputName(l.key()));
|
||||
input_item->setText(0, node->get_input_name(l.key()));
|
||||
input_item->setData(0, Qt::UserRole, l.key());
|
||||
input_item->setFirstColumnSpanned(true);
|
||||
item->addChild(input_item);
|
||||
}
|
||||
|
||||
// Create children if necessary
|
||||
while (input_item->childCount() < table.Count()) {
|
||||
while (input_item->childCount() < table.count()) {
|
||||
input_item->addChild(new QTreeWidgetItem());
|
||||
}
|
||||
|
||||
// Remove children if necessary
|
||||
while (input_item->childCount() > table.Count()) {
|
||||
while (input_item->childCount() > table.count()) {
|
||||
delete input_item->takeChild(input_item->childCount() - 1);
|
||||
}
|
||||
|
||||
for (int j = 0; j < table.Count(); j++) {
|
||||
const NodeValue &value = table.at(table.Count() - 1 - j);
|
||||
for (int j = 0; j < table.count(); j++) {
|
||||
const NodeValue &value = table.at(table.count() - 1 - j);
|
||||
|
||||
// Create item
|
||||
QTreeWidgetItem *sub_item = input_item->child(j);
|
||||
|
||||
// Set data type name
|
||||
sub_item->setText(
|
||||
0, NodeValue::GetPrettyDataTypeName(value.type()));
|
||||
0, NodeValue::get_pretty_data_type_name(value.type()));
|
||||
|
||||
// Determine source
|
||||
QString source_name;
|
||||
if (value.source()) {
|
||||
source_name = value.source()->GetLabelAndName();
|
||||
source_name = value.source()->get_label_and_name();
|
||||
} else {
|
||||
source_name = tr("(unknown)");
|
||||
}
|
||||
sub_item->setText(1, source_name);
|
||||
|
||||
switch (value.type()) {
|
||||
case NodeValue::kVideoParams:
|
||||
case NodeValue::kAudioParams:
|
||||
case NodeValue::k_video_params:
|
||||
case NodeValue::k_audio_params:
|
||||
// These types have no string representation
|
||||
break;
|
||||
case NodeValue::kTexture: {
|
||||
case NodeValue::k_texture: {
|
||||
// NodeTraverser puts video params in here
|
||||
for (int k = 0; k < VideoParams::kRGBAChannelCount; k++) {
|
||||
for (int k = 0; k < VideoParams::k_rgba_channel_count; k++) {
|
||||
this->setItemWidget(sub_item, 2 + k, new QCheckBox());
|
||||
}
|
||||
break;
|
||||
@@ -153,7 +153,7 @@ void NodeTableView::SetTime(const rational &time)
|
||||
default: {
|
||||
QVector<QVariant> split_values = value.to_split_value();
|
||||
for (int k = 0; k < split_values.size(); k++) {
|
||||
sub_item->setText(2 + k, NodeValue::ValueToString(
|
||||
sub_item->setText(2 + k, NodeValue::value_to_string(
|
||||
value.type(),
|
||||
split_values.at(k), true));
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NODETABLEVIEW_H
|
||||
#define NODETABLEVIEW_H
|
||||
#ifndef OAK_NODETABLEVIEW_H
|
||||
#define OAK_NODETABLEVIEW_H
|
||||
|
||||
#include <QTreeWidget>
|
||||
|
||||
@@ -34,18 +34,18 @@ class NodeTableView : public QTreeWidget {
|
||||
public:
|
||||
NodeTableView(QWidget *parent = nullptr);
|
||||
|
||||
void SelectNodes(const QVector<Node *> &nodes);
|
||||
void select_nodes(const QVector<Node *> &nodes);
|
||||
|
||||
void DeselectNodes(const QVector<Node *> &nodes);
|
||||
void deselect_nodes(const QVector<Node *> &nodes);
|
||||
|
||||
void SetTime(const rational &time);
|
||||
void set_time(const Rational &time);
|
||||
|
||||
private:
|
||||
QMap<Node *, QTreeWidgetItem *> top_level_item_map_;
|
||||
|
||||
rational last_time_;
|
||||
Rational last_time_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NODETABLEVIEW_H
|
||||
#endif // OAK_NODETABLEVIEW_H
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NODETABLEWIDGET_H
|
||||
#define NODETABLEWIDGET_H
|
||||
#ifndef OAK_NODETABLEWIDGET_H
|
||||
#define OAK_NODETABLEWIDGET_H
|
||||
|
||||
#include "nodetableview.h"
|
||||
#include "widget/timebased/timebasedwidget.h"
|
||||
@@ -32,20 +32,20 @@ class NodeTableWidget : public TimeBasedWidget {
|
||||
public:
|
||||
NodeTableWidget(QWidget *parent = nullptr);
|
||||
|
||||
void SelectNodes(const QVector<Node *> &nodes)
|
||||
void select_nodes(const QVector<Node *> &nodes)
|
||||
{
|
||||
view_->SelectNodes(nodes);
|
||||
view_->select_nodes(nodes);
|
||||
}
|
||||
|
||||
void DeselectNodes(const QVector<Node *> &nodes)
|
||||
void deselect_nodes(const QVector<Node *> &nodes)
|
||||
{
|
||||
view_->DeselectNodes(nodes);
|
||||
view_->deselect_nodes(nodes);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void TimeChangedEvent(const rational &time) override
|
||||
virtual void TimeChangedEvent(const Rational &time) override
|
||||
{
|
||||
view_->SetTime(time);
|
||||
view_->set_time(time);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -54,4 +54,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // NODETABLEWIDGET_H
|
||||
#endif // OAK_NODETABLEWIDGET_H
|
||||
|
||||
@@ -33,24 +33,24 @@ NodeTreeView::NodeTreeView(QWidget *parent)
|
||||
, checkboxes_enabled_(false)
|
||||
{
|
||||
connect(this, &NodeTreeView::itemChanged, this,
|
||||
&NodeTreeView::ItemCheckStateChanged);
|
||||
&NodeTreeView::item_check_state_changed);
|
||||
connect(this, &NodeTreeView::itemSelectionChanged, this,
|
||||
&NodeTreeView::SelectionChanged);
|
||||
&NodeTreeView::selection_changed);
|
||||
|
||||
Retranslate();
|
||||
retranslate();
|
||||
}
|
||||
|
||||
bool NodeTreeView::IsNodeEnabled(Node *n) const
|
||||
bool NodeTreeView::is_node_enabled(Node *n) const
|
||||
{
|
||||
return !disabled_nodes_.contains(n);
|
||||
}
|
||||
|
||||
bool NodeTreeView::IsInputEnabled(const NodeKeyframeTrackReference &ref) const
|
||||
bool NodeTreeView::is_input_enabled(const NodeKeyframeTrackReference &ref) const
|
||||
{
|
||||
return !disabled_inputs_.contains(ref);
|
||||
}
|
||||
|
||||
void NodeTreeView::SetKeyframeTrackColor(const NodeKeyframeTrackReference &ref,
|
||||
void NodeTreeView::set_keyframe_track_color(const NodeKeyframeTrackReference &ref,
|
||||
const QColor &color)
|
||||
{
|
||||
// Insert into hashmap
|
||||
@@ -63,7 +63,7 @@ void NodeTreeView::SetKeyframeTrackColor(const NodeKeyframeTrackReference &ref,
|
||||
}
|
||||
}
|
||||
|
||||
void NodeTreeView::SetNodes(const QVector<Node *> &nodes)
|
||||
void NodeTreeView::set_nodes(const QVector<Node *> &nodes)
|
||||
{
|
||||
nodes_ = nodes;
|
||||
|
||||
@@ -72,33 +72,33 @@ void NodeTreeView::SetNodes(const QVector<Node *> &nodes)
|
||||
|
||||
foreach (Node *n, nodes_) {
|
||||
QTreeWidgetItem *node_item = new QTreeWidgetItem();
|
||||
node_item->setText(0, n->Name());
|
||||
node_item->setText(0, n->name());
|
||||
if (checkboxes_enabled_) {
|
||||
node_item->setCheckState(
|
||||
0, disabled_nodes_.contains(n) ? Qt::Unchecked : Qt::Checked);
|
||||
}
|
||||
node_item->setData(0, kItemType, kItemTypeNode);
|
||||
node_item->setData(0, kItemNodePointer, QtUtils::PtrToValue(n));
|
||||
node_item->setData(0, k_item_type, k_item_type_node);
|
||||
node_item->setData(0, k_item_node_pointer, QtUtils::ptr_to_value(n));
|
||||
|
||||
foreach (const QString &input, n->inputs()) {
|
||||
if (n->IsInputHidden(input) ||
|
||||
(only_show_keyframable_ && !n->IsInputKeyframable(input))) {
|
||||
if (n->is_input_hidden(input) ||
|
||||
(only_show_keyframable_ && !n->is_input_keyframable(input))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
QTreeWidgetItem *input_item = nullptr;
|
||||
|
||||
int arr_sz = n->InputArraySize(input);
|
||||
int arr_sz = n->input_array_size(input);
|
||||
for (int i = -1; i < arr_sz; i++) {
|
||||
NodeInput input_ref(n, input, i);
|
||||
const QVector<NodeKeyframeTrack> &key_tracks =
|
||||
n->GetKeyframeTracks(input_ref);
|
||||
n->get_keyframe_tracks(input_ref);
|
||||
|
||||
int this_element_track;
|
||||
|
||||
if (show_keyframe_tracks_as_rows_ &&
|
||||
(key_tracks.size() == 1 ||
|
||||
(i == -1 && n->InputIsArray(input)))) {
|
||||
(i == -1 && n->input_is_array(input)))) {
|
||||
this_element_track = 0;
|
||||
} else {
|
||||
this_element_track = -1;
|
||||
@@ -107,19 +107,19 @@ void NodeTreeView::SetNodes(const QVector<Node *> &nodes)
|
||||
QTreeWidgetItem *element_item;
|
||||
|
||||
if (input_item) {
|
||||
element_item = CreateItem(
|
||||
element_item = create_item(
|
||||
input_item, NodeKeyframeTrackReference(
|
||||
input_ref, this_element_track));
|
||||
} else {
|
||||
input_item = CreateItem(node_item,
|
||||
input_item = create_item(node_item,
|
||||
NodeKeyframeTrackReference(
|
||||
input_ref, this_element_track));
|
||||
element_item = input_item;
|
||||
}
|
||||
|
||||
if (show_keyframe_tracks_as_rows_ && key_tracks.size() > 1 &&
|
||||
(!n->InputIsArray(input) || i >= 0)) {
|
||||
CreateItemsForTracks(element_item, input_ref,
|
||||
(!n->input_is_array(input) || i >= 0)) {
|
||||
create_items_for_tracks(element_item, input_ref,
|
||||
key_tracks.size());
|
||||
}
|
||||
}
|
||||
@@ -141,7 +141,7 @@ void NodeTreeView::changeEvent(QEvent *e)
|
||||
QTreeWidget::changeEvent(e);
|
||||
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
Retranslate();
|
||||
retranslate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,19 +149,19 @@ void NodeTreeView::mouseDoubleClickEvent(QMouseEvent *e)
|
||||
{
|
||||
QTreeWidget::mouseDoubleClickEvent(e);
|
||||
|
||||
NodeKeyframeTrackReference ref = GetSelectedInput();
|
||||
NodeKeyframeTrackReference ref = get_selected_input();
|
||||
|
||||
if (ref.input().IsValid()) {
|
||||
emit InputDoubleClicked(ref);
|
||||
if (ref.input().is_valid()) {
|
||||
emit input_double_clicked(ref);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeTreeView::Retranslate()
|
||||
void NodeTreeView::retranslate()
|
||||
{
|
||||
setHeaderLabel(tr("Nodes"));
|
||||
}
|
||||
|
||||
NodeKeyframeTrackReference NodeTreeView::GetSelectedInput()
|
||||
NodeKeyframeTrackReference NodeTreeView::get_selected_input()
|
||||
{
|
||||
QList<QTreeWidgetItem *> sel = selectedItems();
|
||||
|
||||
@@ -170,12 +170,12 @@ NodeKeyframeTrackReference NodeTreeView::GetSelectedInput()
|
||||
if (!sel.isEmpty()) {
|
||||
QTreeWidgetItem *item = sel.first();
|
||||
|
||||
if (item->data(0, kItemType).toInt() == kItemTypeInput) {
|
||||
selected_ref = item->data(0, kItemInputReference)
|
||||
if (item->data(0, k_item_type).toInt() == k_item_type_input) {
|
||||
selected_ref = item->data(0, k_item_input_reference)
|
||||
.value<NodeKeyframeTrackReference>();
|
||||
} else {
|
||||
selected_ref = NodeKeyframeTrackReference(NodeInput(
|
||||
QtUtils::ValueToPtr<Node>(item->data(0, kItemNodePointer)),
|
||||
QtUtils::value_to_ptr<Node>(item->data(0, k_item_node_pointer)),
|
||||
QString()));
|
||||
}
|
||||
}
|
||||
@@ -183,16 +183,16 @@ NodeKeyframeTrackReference NodeTreeView::GetSelectedInput()
|
||||
return selected_ref;
|
||||
}
|
||||
|
||||
QTreeWidgetItem *NodeTreeView::CreateItem(QTreeWidgetItem *parent,
|
||||
QTreeWidgetItem *NodeTreeView::create_item(QTreeWidgetItem *parent,
|
||||
const NodeKeyframeTrackReference &ref)
|
||||
{
|
||||
QTreeWidgetItem *input_item = new QTreeWidgetItem(parent);
|
||||
|
||||
QString item_name;
|
||||
if (ref.track() == -1 ||
|
||||
NodeValue::get_number_of_keyframe_tracks(ref.input().GetDataType()) ==
|
||||
NodeValue::get_number_of_keyframe_tracks(ref.input().get_data_type()) ==
|
||||
1 ||
|
||||
(ref.input().IsArray() && ref.input().element() == -1)) {
|
||||
(ref.input().is_array() && ref.input().element() == -1)) {
|
||||
if (ref.input().element() == -1) {
|
||||
item_name = ref.input().name();
|
||||
} else {
|
||||
@@ -201,16 +201,16 @@ QTreeWidgetItem *NodeTreeView::CreateItem(QTreeWidgetItem *parent,
|
||||
} else {
|
||||
switch (ref.track()) {
|
||||
case 0:
|
||||
item_name = UseRGBAOverXYZW(ref) ? tr("R") : tr("X");
|
||||
item_name = use_rgba_over_xyzw(ref) ? tr("R") : tr("X");
|
||||
break;
|
||||
case 1:
|
||||
item_name = UseRGBAOverXYZW(ref) ? tr("G") : tr("Y");
|
||||
item_name = use_rgba_over_xyzw(ref) ? tr("G") : tr("Y");
|
||||
break;
|
||||
case 2:
|
||||
item_name = UseRGBAOverXYZW(ref) ? tr("B") : tr("Z");
|
||||
item_name = use_rgba_over_xyzw(ref) ? tr("B") : tr("Z");
|
||||
break;
|
||||
case 3:
|
||||
item_name = UseRGBAOverXYZW(ref) ? tr("A") : tr("W");
|
||||
item_name = use_rgba_over_xyzw(ref) ? tr("A") : tr("W");
|
||||
break;
|
||||
default:
|
||||
item_name = QString::number(ref.track());
|
||||
@@ -222,8 +222,8 @@ QTreeWidgetItem *NodeTreeView::CreateItem(QTreeWidgetItem *parent,
|
||||
input_item->setCheckState(
|
||||
0, disabled_inputs_.contains(ref) ? Qt::Unchecked : Qt::Checked);
|
||||
}
|
||||
input_item->setData(0, kItemType, kItemTypeInput);
|
||||
input_item->setData(0, kItemInputReference, QVariant::fromValue(ref));
|
||||
input_item->setData(0, k_item_type, k_item_type_input);
|
||||
input_item->setData(0, k_item_input_reference, QVariant::fromValue(ref));
|
||||
|
||||
if (keyframe_colors_.contains(ref)) {
|
||||
input_item->setForeground(0, keyframe_colors_.value(ref));
|
||||
@@ -234,59 +234,59 @@ QTreeWidgetItem *NodeTreeView::CreateItem(QTreeWidgetItem *parent,
|
||||
return input_item;
|
||||
}
|
||||
|
||||
void NodeTreeView::CreateItemsForTracks(QTreeWidgetItem *parent,
|
||||
void NodeTreeView::create_items_for_tracks(QTreeWidgetItem *parent,
|
||||
const NodeInput &input, int track_count)
|
||||
{
|
||||
for (int j = 0; j < track_count; j++) {
|
||||
CreateItem(parent, NodeKeyframeTrackReference(input, j));
|
||||
create_item(parent, NodeKeyframeTrackReference(input, j));
|
||||
}
|
||||
}
|
||||
|
||||
bool NodeTreeView::UseRGBAOverXYZW(const NodeKeyframeTrackReference &ref)
|
||||
bool NodeTreeView::use_rgba_over_xyzw(const NodeKeyframeTrackReference &ref)
|
||||
{
|
||||
return ref.input().GetDataType() == NodeValue::kColor;
|
||||
return ref.input().get_data_type() == NodeValue::k_color;
|
||||
}
|
||||
|
||||
void NodeTreeView::ItemCheckStateChanged(QTreeWidgetItem *item, int column)
|
||||
void NodeTreeView::item_check_state_changed(QTreeWidgetItem *item, int column)
|
||||
{
|
||||
Q_UNUSED(column)
|
||||
|
||||
switch (item->data(0, kItemType).toInt()) {
|
||||
case kItemTypeNode: {
|
||||
Node *n = QtUtils::ValueToPtr<Node>(item->data(0, kItemNodePointer));
|
||||
switch (item->data(0, k_item_type).toInt()) {
|
||||
case k_item_type_node: {
|
||||
Node *n = QtUtils::value_to_ptr<Node>(item->data(0, k_item_node_pointer));
|
||||
|
||||
if (item->checkState(0) == Qt::Checked) {
|
||||
if (disabled_nodes_.contains(n)) {
|
||||
disabled_nodes_.removeOne(n);
|
||||
emit NodeEnableChanged(n, true);
|
||||
emit node_enable_changed(n, true);
|
||||
}
|
||||
} else if (!disabled_nodes_.contains(n)) {
|
||||
disabled_nodes_.append(n);
|
||||
emit NodeEnableChanged(n, false);
|
||||
emit node_enable_changed(n, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case kItemTypeInput: {
|
||||
NodeKeyframeTrackReference i = item->data(0, kItemInputReference)
|
||||
case k_item_type_input: {
|
||||
NodeKeyframeTrackReference i = item->data(0, k_item_input_reference)
|
||||
.value<NodeKeyframeTrackReference>();
|
||||
|
||||
if (item->checkState(0) == Qt::Checked) {
|
||||
if (disabled_inputs_.contains(i)) {
|
||||
disabled_inputs_.removeOne(i);
|
||||
emit InputEnableChanged(i, true);
|
||||
emit input_enable_changed(i, true);
|
||||
}
|
||||
} else if (!disabled_inputs_.contains(i)) {
|
||||
disabled_inputs_.append(i);
|
||||
emit InputEnableChanged(i, false);
|
||||
emit input_enable_changed(i, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NodeTreeView::SelectionChanged()
|
||||
void NodeTreeView::selection_changed()
|
||||
{
|
||||
emit InputSelectionChanged(GetSelectedInput());
|
||||
emit input_selection_changed(get_selected_input());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NODETREEVIEW_H
|
||||
#define NODETREEVIEW_H
|
||||
#ifndef OAK_NODETREEVIEW_H
|
||||
#define OAK_NODETREEVIEW_H
|
||||
|
||||
#include <QTreeWidget>
|
||||
|
||||
@@ -34,39 +34,39 @@ class NodeTreeView : public QTreeWidget {
|
||||
public:
|
||||
NodeTreeView(QWidget *parent = nullptr);
|
||||
|
||||
bool IsNodeEnabled(Node *n) const;
|
||||
bool is_node_enabled(Node *n) const;
|
||||
|
||||
bool IsInputEnabled(const NodeKeyframeTrackReference &ref) const;
|
||||
bool is_input_enabled(const NodeKeyframeTrackReference &ref) const;
|
||||
|
||||
void SetCheckBoxesEnabled(bool e)
|
||||
void set_check_boxes_enabled(bool e)
|
||||
{
|
||||
checkboxes_enabled_ = e;
|
||||
}
|
||||
|
||||
void SetKeyframeTrackColor(const NodeKeyframeTrackReference &ref,
|
||||
void set_keyframe_track_color(const NodeKeyframeTrackReference &ref,
|
||||
const QColor &color);
|
||||
|
||||
void SetOnlyShowKeyframable(bool e)
|
||||
void set_only_show_keyframable(bool e)
|
||||
{
|
||||
only_show_keyframable_ = e;
|
||||
}
|
||||
|
||||
void SetShowKeyframeTracksAsRows(bool e)
|
||||
void set_show_keyframe_tracks_as_rows(bool e)
|
||||
{
|
||||
show_keyframe_tracks_as_rows_ = e;
|
||||
}
|
||||
|
||||
public slots:
|
||||
void SetNodes(const QVector<Node *> &nodes);
|
||||
void set_nodes(const QVector<Node *> &nodes);
|
||||
|
||||
signals:
|
||||
void NodeEnableChanged(Node *n, bool e);
|
||||
void node_enable_changed(Node *n, bool e);
|
||||
|
||||
void InputEnableChanged(const NodeKeyframeTrackReference &ref, bool e);
|
||||
void input_enable_changed(const NodeKeyframeTrackReference &ref, bool e);
|
||||
|
||||
void InputSelectionChanged(const NodeKeyframeTrackReference &ref);
|
||||
void input_selection_changed(const NodeKeyframeTrackReference &ref);
|
||||
|
||||
void InputDoubleClicked(const NodeKeyframeTrackReference &ref);
|
||||
void input_double_clicked(const NodeKeyframeTrackReference &ref);
|
||||
|
||||
protected:
|
||||
virtual void changeEvent(QEvent *e) override;
|
||||
@@ -74,23 +74,23 @@ protected:
|
||||
virtual void mouseDoubleClickEvent(QMouseEvent *e) override;
|
||||
|
||||
private:
|
||||
void Retranslate();
|
||||
void retranslate();
|
||||
|
||||
NodeKeyframeTrackReference GetSelectedInput();
|
||||
NodeKeyframeTrackReference get_selected_input();
|
||||
|
||||
QTreeWidgetItem *CreateItem(QTreeWidgetItem *parent,
|
||||
QTreeWidgetItem *create_item(QTreeWidgetItem *parent,
|
||||
const NodeKeyframeTrackReference &ref);
|
||||
|
||||
void CreateItemsForTracks(QTreeWidgetItem *parent, const NodeInput &input,
|
||||
void create_items_for_tracks(QTreeWidgetItem *parent, const NodeInput &input,
|
||||
int track_count);
|
||||
|
||||
static bool UseRGBAOverXYZW(const NodeKeyframeTrackReference &ref);
|
||||
static bool use_rgba_over_xyzw(const NodeKeyframeTrackReference &ref);
|
||||
|
||||
enum ItemType { kItemTypeNode, kItemTypeInput };
|
||||
enum ItemType { k_item_type_node, k_item_type_input };
|
||||
|
||||
static const int kItemType = Qt::UserRole;
|
||||
static const int kItemInputReference = Qt::UserRole + 1;
|
||||
static const int kItemNodePointer = Qt::UserRole + 1;
|
||||
static const int k_item_type = Qt::UserRole;
|
||||
static const int k_item_input_reference = Qt::UserRole + 1;
|
||||
static const int k_item_node_pointer = Qt::UserRole + 1;
|
||||
|
||||
QVector<Node *> nodes_;
|
||||
|
||||
@@ -109,11 +109,11 @@ private:
|
||||
bool checkboxes_enabled_;
|
||||
|
||||
private slots:
|
||||
void ItemCheckStateChanged(QTreeWidgetItem *item, int column);
|
||||
void item_check_state_changed(QTreeWidgetItem *item, int column);
|
||||
|
||||
void SelectionChanged();
|
||||
void selection_changed();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NODETREEVIEW_H
|
||||
#endif // OAK_NODETREEVIEW_H
|
||||
|
||||
@@ -37,31 +37,31 @@ NodeValueTree::NodeValueTree(QWidget *parent)
|
||||
p.setHorizontalStretch(1);
|
||||
setSizePolicy(p);
|
||||
|
||||
static const int kMinimumRows = 10;
|
||||
setMinimumHeight(fontMetrics().height() * kMinimumRows);
|
||||
static const int k_minimum_rows = 10;
|
||||
setMinimumHeight(fontMetrics().height() * k_minimum_rows);
|
||||
|
||||
Retranslate();
|
||||
retranslate();
|
||||
}
|
||||
|
||||
void NodeValueTree::SetNode(const NodeInput &input, const rational &time)
|
||||
void NodeValueTree::set_node(const NodeInput &input, const Rational &time)
|
||||
{
|
||||
clear();
|
||||
|
||||
NodeTraverser traverser;
|
||||
|
||||
Node *connected_node = input.GetConnectedOutput();
|
||||
Node *connected_node = input.get_connected_output();
|
||||
|
||||
NodeValueTable table =
|
||||
traverser.GenerateTable(connected_node, TimeRange(time, time));
|
||||
traverser.generate_table(connected_node, TimeRange(time, time));
|
||||
|
||||
int index = traverser.GenerateRowValueElementIndex(
|
||||
int index = traverser.generate_row_value_element_index(
|
||||
input.node(), input.input(), input.element(), &table);
|
||||
|
||||
for (int i = 0; i < table.Count(); i++) {
|
||||
for (int i = 0; i < table.count(); i++) {
|
||||
const NodeValue &value = table.at(i);
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem(this);
|
||||
|
||||
Node::ValueHint hint({ value.type() }, table.Count() - 1 - i,
|
||||
Node::ValueHint hint({ value.type() }, table.count() - 1 - i,
|
||||
value.tag());
|
||||
|
||||
QRadioButton *radio = new QRadioButton(this);
|
||||
@@ -71,37 +71,37 @@ void NodeValueTree::SetNode(const NodeInput &input, const rational &time)
|
||||
radio->setChecked(true);
|
||||
}
|
||||
connect(radio, &QRadioButton::clicked, this,
|
||||
&NodeValueTree::RadioButtonChecked);
|
||||
&NodeValueTree::radio_button_checked);
|
||||
|
||||
setItemWidget(item, 0, radio);
|
||||
item->setText(1, NodeValue::GetPrettyDataTypeName(value.type()));
|
||||
item->setText(2, NodeValue::ValueToString(value, false));
|
||||
item->setText(3, value.source()->GetLabelAndName());
|
||||
item->setText(1, NodeValue::get_pretty_data_type_name(value.type()));
|
||||
item->setText(2, NodeValue::value_to_string(value, false));
|
||||
item->setText(3, value.source()->get_label_and_name());
|
||||
}
|
||||
}
|
||||
|
||||
void NodeValueTree::changeEvent(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::LanguageChange) {
|
||||
Retranslate();
|
||||
retranslate();
|
||||
}
|
||||
|
||||
super::changeEvent(event);
|
||||
}
|
||||
|
||||
void NodeValueTree::Retranslate()
|
||||
void NodeValueTree::retranslate()
|
||||
{
|
||||
setHeaderLabels({ QString(), tr("Type"), tr("Value"), tr("Source") });
|
||||
}
|
||||
|
||||
void NodeValueTree::RadioButtonChecked(bool e)
|
||||
void NodeValueTree::radio_button_checked(bool e)
|
||||
{
|
||||
if (e) {
|
||||
QRadioButton *btn = static_cast<QRadioButton *>(sender());
|
||||
Node::ValueHint hint = btn->property("hint").value<Node::ValueHint>();
|
||||
NodeInput input = btn->property("input").value<NodeInput>();
|
||||
|
||||
input.node()->SetValueHintForInput(input.input(), hint,
|
||||
input.node()->set_value_hint_for_input(input.input(), hint,
|
||||
input.element());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NODEVALUETREE_H
|
||||
#define NODEVALUETREE_H
|
||||
#ifndef OAK_NODEVALUETREE_H
|
||||
#define OAK_NODEVALUETREE_H
|
||||
|
||||
#include <QRadioButton>
|
||||
#include <QTreeWidget>
|
||||
@@ -32,18 +32,18 @@ class NodeValueTree : public QTreeWidget {
|
||||
public:
|
||||
NodeValueTree(QWidget *parent = nullptr);
|
||||
|
||||
void SetNode(const NodeInput &input, const rational &time);
|
||||
void set_node(const NodeInput &input, const Rational &time);
|
||||
|
||||
protected:
|
||||
virtual void changeEvent(QEvent *event) override;
|
||||
|
||||
private:
|
||||
void Retranslate();
|
||||
void retranslate();
|
||||
|
||||
private slots:
|
||||
void RadioButtonChecked(bool e);
|
||||
void radio_button_checked(bool e);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEVALUETREE_H
|
||||
#endif // OAK_NODEVALUETREE_H
|
||||
|
||||
+360
-360
File diff suppressed because it is too large
Load Diff
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NODEVIEW_H
|
||||
#define NODEVIEW_H
|
||||
#ifndef OAK_NODEVIEW_H
|
||||
#define OAK_NODEVIEW_H
|
||||
|
||||
#include <QGraphicsView>
|
||||
#include <QTimer>
|
||||
@@ -50,85 +50,85 @@ public:
|
||||
|
||||
virtual ~NodeView() override;
|
||||
|
||||
void SetContexts(const QVector<Node *> &nodes);
|
||||
void set_contexts(const QVector<Node *> &nodes);
|
||||
|
||||
const QVector<Node *> &GetContexts() const
|
||||
const QVector<Node *> &get_contexts() const
|
||||
{
|
||||
if (overlay_view_) {
|
||||
return overlay_view_->GetContexts();
|
||||
return overlay_view_->get_contexts();
|
||||
} else {
|
||||
return contexts_;
|
||||
}
|
||||
}
|
||||
|
||||
bool IsGroupOverlay() const
|
||||
bool is_group_overlay() const
|
||||
{
|
||||
return overlay_view_;
|
||||
}
|
||||
|
||||
void CloseContextsBelongingToProject(Project *project);
|
||||
void close_contexts_belonging_to_project(Project *project);
|
||||
|
||||
void ClearGraph();
|
||||
void clear_graph();
|
||||
|
||||
/**
|
||||
* @brief Delete selected nodes from graph (user-friendly/undoable)
|
||||
*/
|
||||
void DeleteSelected();
|
||||
void delete_selected();
|
||||
|
||||
void SelectAll();
|
||||
void DeselectAll();
|
||||
void select_all();
|
||||
void deselect_all();
|
||||
|
||||
void Select(const QVector<Node::ContextPair> &nodes,
|
||||
void select(const QVector<Node::ContextPair> &nodes,
|
||||
bool center_view_on_item);
|
||||
|
||||
void CopySelected(bool cut);
|
||||
void Paste();
|
||||
void copy_selected(bool cut);
|
||||
void paste();
|
||||
|
||||
void Duplicate();
|
||||
void duplicate();
|
||||
|
||||
void SetColorLabel(int index);
|
||||
void set_color_label(int index);
|
||||
|
||||
void ZoomIn();
|
||||
void zoom_in();
|
||||
|
||||
void ZoomOut();
|
||||
void zoom_out();
|
||||
|
||||
const QVector<Node *> &GetCurrentContexts() const
|
||||
const QVector<Node *> &get_current_contexts() const
|
||||
{
|
||||
return contexts_;
|
||||
}
|
||||
|
||||
public slots:
|
||||
void SetMiniMapEnabled(bool e)
|
||||
void set_mini_map_enabled(bool e)
|
||||
{
|
||||
minimap_->setVisible(e);
|
||||
}
|
||||
|
||||
void ShowAddMenu()
|
||||
void show_add_menu()
|
||||
{
|
||||
Menu *m = CreateAddMenu(nullptr);
|
||||
Menu *m = create_add_menu(nullptr);
|
||||
m->exec(QCursor::pos());
|
||||
delete m;
|
||||
}
|
||||
|
||||
void CenterOnItemsBoundingRect();
|
||||
void center_on_items_bounding_rect();
|
||||
|
||||
void CenterOnNode(olive::Node *n);
|
||||
void center_on_node(olive::Node *n);
|
||||
|
||||
void LabelSelectedNodes();
|
||||
void label_selected_nodes();
|
||||
|
||||
signals:
|
||||
void NodesSelected(const QVector<Node *> &nodes);
|
||||
void nodes_selected(const QVector<Node *> &nodes);
|
||||
|
||||
void NodesDeselected(const QVector<Node *> &nodes);
|
||||
void nodes_deselected(const QVector<Node *> &nodes);
|
||||
|
||||
void NodeSelectionChanged(const QVector<Node *> &nodes);
|
||||
void node_selection_changed(const QVector<Node *> &nodes);
|
||||
void
|
||||
NodeSelectionChangedWithContexts(const QVector<Node::ContextPair> &nodes);
|
||||
node_selection_changed_with_contexts(const QVector<Node::ContextPair> &nodes);
|
||||
|
||||
void NodeGroupOpened(NodeGroup *group);
|
||||
void NodeGroupClosed();
|
||||
void node_group_opened(NodeGroup *group);
|
||||
void node_group_closed();
|
||||
|
||||
void EscPressed();
|
||||
void esc_pressed();
|
||||
|
||||
protected:
|
||||
virtual void keyPressEvent(QKeyEvent *event) override;
|
||||
@@ -145,7 +145,7 @@ protected:
|
||||
|
||||
virtual void resizeEvent(QResizeEvent *event) override;
|
||||
|
||||
virtual void ZoomIntoCursorPosition(QWheelEvent *event, double multiplier,
|
||||
virtual void zoom_into_cursor_position(QWheelEvent *event, double multiplier,
|
||||
const QPointF &cursor_pos) override;
|
||||
|
||||
virtual bool event(QEvent *event) override;
|
||||
@@ -155,54 +155,54 @@ protected:
|
||||
virtual void changeEvent(QEvent *e) override;
|
||||
|
||||
private:
|
||||
void DetachItemsFromCursor(bool delete_nodes_too = true);
|
||||
void detach_items_from_cursor(bool delete_nodes_too = true);
|
||||
|
||||
void SetFlowDirection(NodeViewCommon::FlowDirection dir);
|
||||
void set_flow_direction(NodeViewCommon::FlowDirection dir);
|
||||
|
||||
void MoveAttachedNodesToCursor(const QPoint &p);
|
||||
void ProcessMovingAttachedNodes(const QPoint &pos);
|
||||
QVector<Node *> ProcessDroppingAttachedNodes(MultiUndoCommand *command,
|
||||
void move_attached_nodes_to_cursor(const QPoint &p);
|
||||
void process_moving_attached_nodes(const QPoint &pos);
|
||||
QVector<Node *> process_dropping_attached_nodes(MultiUndoCommand *command,
|
||||
Node *select_context,
|
||||
const QPoint &pos);
|
||||
Node *GetContextAtMousePos(const QPoint &p);
|
||||
Node *get_context_at_mouse_pos(const QPoint &p);
|
||||
|
||||
void ConnectSelectionChangedSignal();
|
||||
void DisconnectSelectionChangedSignal();
|
||||
void connect_selection_changed_signal();
|
||||
void disconnect_selection_changed_signal();
|
||||
|
||||
void ZoomFromKeyboard(double multiplier);
|
||||
void zoom_from_keyboard(double multiplier);
|
||||
|
||||
void ClearCreateEdgeInputIfNecessary();
|
||||
void clear_create_edge_input_if_necessary();
|
||||
|
||||
QPointF GetEstimatedPositionForContext(NodeViewItem *item,
|
||||
QPointF get_estimated_position_for_context(NodeViewItem *item,
|
||||
Node *context) const;
|
||||
|
||||
NodeViewItem *GetAssumedItemForSelectedNode(Node *node);
|
||||
bool GetAssumedPositionForSelectedNode(Node *node, Node::Position *pos);
|
||||
NodeViewItem *get_assumed_item_for_selected_node(Node *node);
|
||||
bool get_assumed_position_for_selected_node(Node *node, Node::Position *pos);
|
||||
|
||||
Menu *CreateAddMenu(Menu *parent);
|
||||
Menu *create_add_menu(Menu *parent);
|
||||
|
||||
void PositionNewEdge(const QPoint &pos);
|
||||
void position_new_edge(const QPoint &pos);
|
||||
|
||||
void AddContext(Node *n);
|
||||
void add_context(Node *n);
|
||||
|
||||
void RemoveContext(Node *n);
|
||||
void remove_context(Node *n);
|
||||
|
||||
bool IsItemAttachedToCursor(NodeViewItem *item) const;
|
||||
bool is_item_attached_to_cursor(NodeViewItem *item) const;
|
||||
|
||||
void ExpandItem(NodeViewItem *item);
|
||||
void expand_item(NodeViewItem *item);
|
||||
|
||||
void CollapseItem(NodeViewItem *item);
|
||||
void collapse_item(NodeViewItem *item);
|
||||
|
||||
void EndEdgeDrag(bool cancel = false);
|
||||
void end_edge_drag(bool cancel = false);
|
||||
|
||||
void PostPaste(const QVector<Node *> &new_nodes,
|
||||
void post_paste(const QVector<Node *> &new_nodes,
|
||||
const Node::PositionMap &map);
|
||||
|
||||
void ResizeOverlay();
|
||||
void resize_overlay();
|
||||
|
||||
NodeViewMiniMap *minimap_;
|
||||
|
||||
NodeViewContext *GetContextItemFromNodeItem(NodeViewItem *item);
|
||||
NodeViewContext *get_context_item_from_node_item(NodeViewItem *item);
|
||||
|
||||
struct AttachedItem {
|
||||
NodeViewItem *item;
|
||||
@@ -210,7 +210,7 @@ private:
|
||||
QPointF original_pos;
|
||||
};
|
||||
|
||||
void SetAttachedItems(const QVector<AttachedItem> &items);
|
||||
void set_attached_items(const QVector<AttachedItem> &items);
|
||||
QVector<AttachedItem> attached_items_;
|
||||
|
||||
NodeViewEdge *drop_edge_;
|
||||
@@ -243,59 +243,59 @@ private:
|
||||
|
||||
QAction *show_in_param_editor_action_;
|
||||
|
||||
static const double kMinimumScale;
|
||||
static const double k_minimum_scale;
|
||||
|
||||
static const int kMaximumContexts;
|
||||
static const int k_maximum_contexts;
|
||||
|
||||
private slots:
|
||||
/**
|
||||
* @brief Receiver for when the scene's selected items change
|
||||
*/
|
||||
void UpdateSelectionCache();
|
||||
void update_selection_cache();
|
||||
|
||||
/**
|
||||
* @brief Receiver for when the user right clicks (or otherwise requests a context menu)
|
||||
*/
|
||||
void ShowContextMenu(const QPoint &pos);
|
||||
void show_context_menu(const QPoint &pos);
|
||||
|
||||
/**
|
||||
* @brief Receiver for when the user requests a new node from the add menu
|
||||
*/
|
||||
void CreateNodeSlot(QAction *action);
|
||||
void create_node_slot(QAction *action);
|
||||
|
||||
/**
|
||||
* @brief Receiver for setting the direction from the context menu
|
||||
*/
|
||||
void ContextMenuSetDirection(QAction *action);
|
||||
void context_menu_set_direction(QAction *action);
|
||||
|
||||
/**
|
||||
* @brief Opens the selected node in a Viewer
|
||||
*/
|
||||
void OpenSelectedNodeInViewer();
|
||||
void open_selected_node_in_viewer();
|
||||
|
||||
void UpdateSceneBoundingRect();
|
||||
void update_scene_bounding_rect();
|
||||
|
||||
void RepositionMiniMap();
|
||||
void reposition_mini_map();
|
||||
|
||||
void UpdateViewportOnMiniMap();
|
||||
void update_viewport_on_mini_map();
|
||||
|
||||
void MoveToScenePoint(const QPointF &pos);
|
||||
void move_to_scene_point(const QPointF &pos);
|
||||
|
||||
void NodeRemovedFromGraph();
|
||||
void node_removed_from_graph();
|
||||
|
||||
void GroupNodes();
|
||||
void group_nodes();
|
||||
|
||||
void UngroupNodes();
|
||||
void ungroup_nodes();
|
||||
|
||||
void ShowNodeProperties();
|
||||
void show_node_properties();
|
||||
|
||||
void ShowSelectedNodeInParamEditor();
|
||||
void show_selected_node_in_param_editor();
|
||||
|
||||
void ItemAboutToBeDeleted(NodeViewItem *item);
|
||||
void item_about_to_be_deleted(NodeViewItem *item);
|
||||
|
||||
void CloseOverlay();
|
||||
void close_overlay();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEVIEW_H
|
||||
#endif // OAK_NODEVIEW_H
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NODEVIEWCOMMON_H
|
||||
#define NODEVIEWCOMMON_H
|
||||
#ifndef OAK_NODEVIEWCOMMON_H
|
||||
#define OAK_NODEVIEWCOMMON_H
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
@@ -32,45 +32,45 @@ namespace olive
|
||||
class NodeViewCommon {
|
||||
public:
|
||||
enum FlowDirection {
|
||||
kInvalidDirection = -1,
|
||||
kTopToBottom,
|
||||
kBottomToTop,
|
||||
kLeftToRight,
|
||||
kRightToLeft
|
||||
k_invalid_direction = -1,
|
||||
k_top_to_bottom,
|
||||
k_bottom_to_top,
|
||||
k_left_to_right,
|
||||
k_right_to_left
|
||||
};
|
||||
|
||||
static Qt::Orientation GetFlowOrientation(FlowDirection dir)
|
||||
static Qt::Orientation get_flow_orientation(FlowDirection dir)
|
||||
{
|
||||
if (dir == kTopToBottom || dir == kBottomToTop) {
|
||||
if (dir == k_top_to_bottom || dir == k_bottom_to_top) {
|
||||
return Qt::Vertical;
|
||||
} else {
|
||||
return Qt::Horizontal;
|
||||
}
|
||||
}
|
||||
|
||||
static bool IsFlowVertical(FlowDirection dir)
|
||||
static bool is_flow_vertical(FlowDirection dir)
|
||||
{
|
||||
return dir == kTopToBottom || dir == kBottomToTop;
|
||||
return dir == k_top_to_bottom || dir == k_bottom_to_top;
|
||||
}
|
||||
|
||||
static bool IsFlowHorizontal(FlowDirection dir)
|
||||
static bool is_flow_horizontal(FlowDirection dir)
|
||||
{
|
||||
return dir == kLeftToRight || dir == kRightToLeft;
|
||||
return dir == k_left_to_right || dir == k_right_to_left;
|
||||
}
|
||||
|
||||
static bool DirectionsAreOpposing(FlowDirection a, FlowDirection b)
|
||||
static bool directions_are_opposing(FlowDirection a, FlowDirection b)
|
||||
{
|
||||
return ((a == NodeViewCommon::kLeftToRight &&
|
||||
b == NodeViewCommon::kRightToLeft) ||
|
||||
(a == NodeViewCommon::kRightToLeft &&
|
||||
b == NodeViewCommon::kLeftToRight) ||
|
||||
(a == NodeViewCommon::kTopToBottom &&
|
||||
b == NodeViewCommon::kBottomToTop) ||
|
||||
(a == NodeViewCommon::kBottomToTop &&
|
||||
b == NodeViewCommon::kTopToBottom));
|
||||
return ((a == NodeViewCommon::k_left_to_right &&
|
||||
b == NodeViewCommon::k_right_to_left) ||
|
||||
(a == NodeViewCommon::k_right_to_left &&
|
||||
b == NodeViewCommon::k_left_to_right) ||
|
||||
(a == NodeViewCommon::k_top_to_bottom &&
|
||||
b == NodeViewCommon::k_bottom_to_top) ||
|
||||
(a == NodeViewCommon::k_bottom_to_top &&
|
||||
b == NodeViewCommon::k_top_to_bottom));
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEVIEWCOMMON_H
|
||||
#endif // OAK_NODEVIEWCOMMON_H
|
||||
|
||||
@@ -45,36 +45,36 @@ NodeViewContext::NodeViewContext(Node *context, QGraphicsItem *item)
|
||||
{
|
||||
Block *block = dynamic_cast<Block *>(context_);
|
||||
if (block && block->track() && block->track()->sequence()) {
|
||||
rational timebase = block->track()
|
||||
Rational timebase = block->track()
|
||||
->sequence()
|
||||
->GetVideoParams()
|
||||
->get_video_params()
|
||||
.frame_rate_as_time_base();
|
||||
lbl_ =
|
||||
QCoreApplication::translate("NodeViewContext", "%1 [%2] :: %3 - %4")
|
||||
.arg(block->GetLabelAndName(),
|
||||
Track::Reference::TypeToTranslatedString(
|
||||
.arg(block->get_label_and_name(),
|
||||
Track::Reference::type_to_translated_string(
|
||||
block->track()->type()),
|
||||
QString::fromStdString(Timecode::time_to_timecode(
|
||||
block->in(), timebase,
|
||||
Core::instance()->GetTimecodeDisplay())),
|
||||
Core::instance()->get_timecode_display())),
|
||||
QString::fromStdString(Timecode::time_to_timecode(
|
||||
block->out(), timebase,
|
||||
Core::instance()->GetTimecodeDisplay())));
|
||||
Core::instance()->get_timecode_display())));
|
||||
} else {
|
||||
lbl_ = context_->GetLabelAndName();
|
||||
lbl_ = context_->get_label_and_name();
|
||||
}
|
||||
|
||||
const Node::PositionMap &map = context_->GetContextPositions();
|
||||
const Node::PositionMap &map = context_->get_context_positions();
|
||||
for (auto it = map.cbegin(); it != map.cend(); it++) {
|
||||
AddChild(it.key());
|
||||
add_child(it.key());
|
||||
}
|
||||
|
||||
connect(context_, &Node::NodeAddedToContext, this,
|
||||
&NodeViewContext::AddChild, Qt::DirectConnection);
|
||||
connect(context_, &Node::NodePositionInContextChanged, this,
|
||||
&NodeViewContext::SetChildPosition, Qt::DirectConnection);
|
||||
connect(context_, &Node::NodeRemovedFromContext, this,
|
||||
&NodeViewContext::RemoveChild, Qt::DirectConnection);
|
||||
connect(context_, &Node::node_added_to_context, this,
|
||||
&NodeViewContext::add_child, Qt::DirectConnection);
|
||||
connect(context_, &Node::node_position_in_context_changed, this,
|
||||
&NodeViewContext::set_child_position, Qt::DirectConnection);
|
||||
connect(context_, &Node::node_removed_from_context, this,
|
||||
&NodeViewContext::remove_child, Qt::DirectConnection);
|
||||
}
|
||||
|
||||
NodeViewContext::~NodeViewContext()
|
||||
@@ -84,50 +84,50 @@ NodeViewContext::~NodeViewContext()
|
||||
edges_.clear();
|
||||
}
|
||||
|
||||
void NodeViewContext::AddChild(Node *node)
|
||||
void NodeViewContext::add_child(Node *node)
|
||||
{
|
||||
if (!context_) {
|
||||
return;
|
||||
}
|
||||
|
||||
NodeViewItem *item = new NodeViewItem(node, context_, this);
|
||||
item->SetFlowDirection(flow_dir_);
|
||||
item->set_flow_direction(flow_dir_);
|
||||
|
||||
AddNodeInternal(node, item);
|
||||
add_node_internal(node, item);
|
||||
|
||||
if (NodeGroup *group = dynamic_cast<NodeGroup *>(node)) {
|
||||
for (auto it = group->GetContextPositions().cbegin();
|
||||
it != group->GetContextPositions().cend(); it++) {
|
||||
for (auto it = group->get_context_positions().cbegin();
|
||||
it != group->get_context_positions().cend(); it++) {
|
||||
// Use this item as the representative for all of these nodes too
|
||||
AddNodeInternal(it.key(), item);
|
||||
add_node_internal(it.key(), item);
|
||||
}
|
||||
|
||||
connect(group, &NodeGroup::NodeAddedToContext, this,
|
||||
&NodeViewContext::GroupAddedNode);
|
||||
connect(group, &NodeGroup::NodeRemovedFromContext, this,
|
||||
&NodeViewContext::GroupRemovedNode);
|
||||
connect(group, &NodeGroup::node_added_to_context, this,
|
||||
&NodeViewContext::group_added_node);
|
||||
connect(group, &NodeGroup::node_removed_from_context, this,
|
||||
&NodeViewContext::group_removed_node);
|
||||
}
|
||||
|
||||
UpdateRect();
|
||||
update_rect();
|
||||
}
|
||||
|
||||
void NodeViewContext::SetChildPosition(Node *node, const QPointF &pos)
|
||||
void NodeViewContext::set_child_position(Node *node, const QPointF &pos)
|
||||
{
|
||||
item_map_.value(node)->SetNodePosition(pos);
|
||||
item_map_.value(node)->set_node_position(pos);
|
||||
}
|
||||
|
||||
void NodeViewContext::RemoveChild(Node *node)
|
||||
void NodeViewContext::remove_child(Node *node)
|
||||
{
|
||||
disconnect(node, &Node::InputConnected, this,
|
||||
&NodeViewContext::ChildInputConnected);
|
||||
disconnect(node, &Node::InputDisconnected, this,
|
||||
&NodeViewContext::ChildInputDisconnected);
|
||||
disconnect(node, &Node::input_connected, this,
|
||||
&NodeViewContext::child_input_connected);
|
||||
disconnect(node, &Node::input_disconnected, this,
|
||||
&NodeViewContext::child_input_disconnected);
|
||||
|
||||
if (NodeGroup *group = dynamic_cast<NodeGroup *>(node)) {
|
||||
disconnect(group, &NodeGroup::NodeAddedToContext, this,
|
||||
&NodeViewContext::GroupAddedNode);
|
||||
disconnect(group, &NodeGroup::NodeRemovedFromContext, this,
|
||||
&NodeViewContext::GroupRemovedNode);
|
||||
disconnect(group, &NodeGroup::node_added_to_context, this,
|
||||
&NodeViewContext::group_added_node);
|
||||
disconnect(group, &NodeGroup::node_removed_from_context, this,
|
||||
&NodeViewContext::group_removed_node);
|
||||
}
|
||||
|
||||
NodeViewItem *item = item_map_.take(node);
|
||||
@@ -136,22 +136,22 @@ void NodeViewContext::RemoveChild(Node *node)
|
||||
// now can be handled before the item is destroyed
|
||||
scene()->removeItem(item);
|
||||
|
||||
emit ItemAboutToBeDeleted(item);
|
||||
emit item_about_to_be_deleted(item);
|
||||
|
||||
// Delete edges first because the edge destructor will try to reference item (maybe that should
|
||||
// be changed...)
|
||||
QVector<NodeViewEdge *> edges_to_remove = item->GetAllEdgesRecursively();
|
||||
QVector<NodeViewEdge *> edges_to_remove = item->get_all_edges_recursively();
|
||||
foreach (NodeViewEdge *edge, edges_to_remove) {
|
||||
if (node == item->GetNode() || edge->output() == node ||
|
||||
if (node == item->get_node() || edge->output() == node ||
|
||||
edge->input().node() == node) {
|
||||
ChildInputDisconnected(edge->output(), edge->input());
|
||||
child_input_disconnected(edge->output(), edge->input());
|
||||
}
|
||||
}
|
||||
|
||||
// Check if this item is specifically for this node and the node is a group. If so, remove it for
|
||||
// all other entries in the map.
|
||||
if (item->GetNode() == node) {
|
||||
if (dynamic_cast<NodeGroup *>(item->GetNode())) {
|
||||
if (item->get_node() == node) {
|
||||
if (dynamic_cast<NodeGroup *>(item->get_node())) {
|
||||
for (auto it = item_map_.begin(); it != item_map_.end();) {
|
||||
if (it.value() == item) {
|
||||
it = item_map_.erase(it);
|
||||
@@ -164,22 +164,22 @@ void NodeViewContext::RemoveChild(Node *node)
|
||||
delete item;
|
||||
}
|
||||
|
||||
UpdateRect();
|
||||
update_rect();
|
||||
}
|
||||
|
||||
void NodeViewContext::ChildInputConnected(Node *output, const NodeInput &input)
|
||||
void NodeViewContext::child_input_connected(Node *output, const NodeInput &input)
|
||||
{
|
||||
// Add edge
|
||||
if (!input.IsHidden()) {
|
||||
if (!input.is_hidden()) {
|
||||
if (NodeViewItem *output_item = item_map_.value(output)) {
|
||||
AddEdgeInternal(
|
||||
add_edge_internal(
|
||||
output, input, output_item,
|
||||
item_map_.value(input.node())->GetItemForInput(input));
|
||||
item_map_.value(input.node())->get_item_for_input(input));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool NodeViewContext::ChildInputDisconnected(Node *output,
|
||||
bool NodeViewContext::child_input_disconnected(Node *output,
|
||||
const NodeInput &input)
|
||||
{
|
||||
// Remove edge
|
||||
@@ -195,59 +195,59 @@ bool NodeViewContext::ChildInputDisconnected(Node *output,
|
||||
return false;
|
||||
}
|
||||
|
||||
qreal GetTextOffset(const QFontMetricsF &fm)
|
||||
qreal get_text_offset(const QFontMetricsF &fm)
|
||||
{
|
||||
return fm.height() / 2;
|
||||
}
|
||||
|
||||
void NodeViewContext::UpdateRect()
|
||||
void NodeViewContext::update_rect()
|
||||
{
|
||||
QFont f;
|
||||
QFontMetricsF fm(f);
|
||||
qreal lbl_offset = GetTextOffset(fm);
|
||||
qreal lbl_offset = get_text_offset(fm);
|
||||
|
||||
QRectF cbr = childrenBoundingRect();
|
||||
QRectF rect = cbr;
|
||||
int pad = NodeViewItem::DefaultItemHeight();
|
||||
int pad = NodeViewItem::default_item_height();
|
||||
rect.adjust(-pad, -lbl_offset * 2 - fm.height() - pad, pad, pad);
|
||||
setRect(rect);
|
||||
|
||||
last_titlebar_height_ = rect.y() + (cbr.y() - rect.y()) - pad;
|
||||
}
|
||||
|
||||
void NodeViewContext::SetFlowDirection(NodeViewCommon::FlowDirection dir)
|
||||
void NodeViewContext::set_flow_direction(NodeViewCommon::FlowDirection dir)
|
||||
{
|
||||
flow_dir_ = dir;
|
||||
|
||||
foreach (NodeViewItem *item, item_map_) {
|
||||
item->SetFlowDirection(dir);
|
||||
item->set_flow_direction(dir);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeViewContext::SetCurvedEdges(bool e)
|
||||
void NodeViewContext::set_curved_edges(bool e)
|
||||
{
|
||||
curved_edges_ = e;
|
||||
|
||||
foreach (NodeViewEdge *edge, edges_) {
|
||||
edge->SetCurved(e);
|
||||
edge->set_curved(e);
|
||||
}
|
||||
}
|
||||
|
||||
int NodeViewContext::DeleteSelected(NodeViewDeleteCommand *command)
|
||||
int NodeViewContext::delete_selected(NodeViewDeleteCommand *command)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
// Delete any selected edges
|
||||
foreach (NodeViewEdge *edge, edges_) {
|
||||
if (edge->isSelected()) {
|
||||
command->AddEdge(edge->output(), edge->input());
|
||||
command->add_edge(edge->output(), edge->input());
|
||||
}
|
||||
}
|
||||
|
||||
// Delete any selected nodes
|
||||
foreach (NodeViewItem *node, item_map_) {
|
||||
if (node->isSelected()) {
|
||||
command->AddNode(node->GetNode(), context_);
|
||||
command->add_node(node->get_node(), context_);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
@@ -255,7 +255,7 @@ int NodeViewContext::DeleteSelected(NodeViewDeleteCommand *command)
|
||||
return count;
|
||||
}
|
||||
|
||||
void NodeViewContext::Select(const QVector<Node *> &nodes)
|
||||
void NodeViewContext::select(const QVector<Node *> &nodes)
|
||||
{
|
||||
foreach (Node *n, nodes) {
|
||||
if (NodeViewItem *item = item_map_.value(n)) {
|
||||
@@ -264,7 +264,7 @@ void NodeViewContext::Select(const QVector<Node *> &nodes)
|
||||
}
|
||||
}
|
||||
|
||||
QVector<NodeViewItem *> NodeViewContext::GetSelectedItems() const
|
||||
QVector<NodeViewItem *> NodeViewContext::get_selected_items() const
|
||||
{
|
||||
QVector<NodeViewItem *> items;
|
||||
|
||||
@@ -279,12 +279,12 @@ QVector<NodeViewItem *> NodeViewContext::GetSelectedItems() const
|
||||
return items;
|
||||
}
|
||||
|
||||
QPointF NodeViewContext::MapScenePosToNodePosInContext(const QPointF &pos) const
|
||||
QPointF NodeViewContext::map_scene_pos_to_node_pos_in_context(const QPointF &pos) const
|
||||
{
|
||||
for (auto it = item_map_.cbegin(); it != item_map_.cend(); it++) {
|
||||
QPointF pos_inside_parent =
|
||||
it.value()->mapToParent(it.value()->mapFromScene(pos));
|
||||
return NodeViewItem::ScreenToNodePoint(pos_inside_parent, flow_dir_);
|
||||
return NodeViewItem::screen_to_node_point(pos_inside_parent, flow_dir_);
|
||||
}
|
||||
return QPointF(0, 0);
|
||||
}
|
||||
@@ -295,7 +295,7 @@ void NodeViewContext::paint(QPainter *painter,
|
||||
{
|
||||
// Set pen and brush
|
||||
Color color = context_->color();
|
||||
QColor c = QtUtils::toQColor(color);
|
||||
QColor c = QtUtils::to_q_color(color);
|
||||
QPen pen(c, 2);
|
||||
if (option->state & QStyle::State_Selected) {
|
||||
pen.setStyle(Qt::DotLine);
|
||||
@@ -319,9 +319,9 @@ void NodeViewContext::paint(QPainter *painter,
|
||||
painter->setClipping(false);
|
||||
|
||||
// Draw titlebar text
|
||||
painter->setPen(ColorCoding::GetUISelectorColor(color));
|
||||
painter->setPen(ColorCoding::get_ui_selector_color(color));
|
||||
|
||||
int offset = GetTextOffset(painter->fontMetrics());
|
||||
int offset = get_text_offset(painter->fontMetrics());
|
||||
|
||||
QRectF text_rect = rect();
|
||||
text_rect.adjust(offset, offset, -offset, -offset);
|
||||
@@ -344,41 +344,41 @@ void NodeViewContext::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
super::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void NodeViewContext::AddNodeInternal(Node *node, NodeViewItem *item)
|
||||
void NodeViewContext::add_node_internal(Node *node, NodeViewItem *item)
|
||||
{
|
||||
connect(node, &Node::InputConnected, this,
|
||||
&NodeViewContext::ChildInputConnected);
|
||||
connect(node, &Node::InputDisconnected, this,
|
||||
&NodeViewContext::ChildInputDisconnected);
|
||||
connect(node, &Node::input_connected, this,
|
||||
&NodeViewContext::child_input_connected);
|
||||
connect(node, &Node::input_disconnected, this,
|
||||
&NodeViewContext::child_input_disconnected);
|
||||
|
||||
item_map_.insert(node, item);
|
||||
|
||||
if (node == context_) {
|
||||
item->SetLabelAsOutput(true);
|
||||
item->set_label_as_output(true);
|
||||
}
|
||||
|
||||
for (auto it = node->output_connections().cbegin();
|
||||
it != node->output_connections().cend(); it++) {
|
||||
if (!it->second.IsHidden()) {
|
||||
if (!it->second.is_hidden()) {
|
||||
if (NodeViewItem *other_item = item_map_.value(it->second.node())) {
|
||||
AddEdgeInternal(node, it->second, item,
|
||||
other_item->GetItemForInput(it->second));
|
||||
add_edge_internal(node, it->second, item,
|
||||
other_item->get_item_for_input(it->second));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto it = node->input_connections().cbegin();
|
||||
it != node->input_connections().cend(); it++) {
|
||||
if (!it->first.IsHidden()) {
|
||||
if (!it->first.is_hidden()) {
|
||||
if (NodeViewItem *other_item = item_map_.value(it->second)) {
|
||||
AddEdgeInternal(it->second, it->first, other_item,
|
||||
item->GetItemForInput(it->first));
|
||||
add_edge_internal(it->second, it->first, other_item,
|
||||
item->get_item_for_input(it->first));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NodeViewContext::AddEdgeInternal(Node *output, const NodeInput &input,
|
||||
void NodeViewContext::add_edge_internal(Node *output, const NodeInput &input,
|
||||
NodeViewItem *from, NodeViewItem *to)
|
||||
{
|
||||
if (from == to) {
|
||||
@@ -387,20 +387,20 @@ void NodeViewContext::AddEdgeInternal(Node *output, const NodeInput &input,
|
||||
|
||||
NodeViewEdge *edge_ui = new NodeViewEdge(output, input, from, to, this);
|
||||
|
||||
edge_ui->Adjust();
|
||||
edge_ui->SetCurved(curved_edges_);
|
||||
edge_ui->adjust();
|
||||
edge_ui->set_curved(curved_edges_);
|
||||
|
||||
edges_.append(edge_ui);
|
||||
}
|
||||
|
||||
void NodeViewContext::GroupAddedNode(Node *node)
|
||||
void NodeViewContext::group_added_node(Node *node)
|
||||
{
|
||||
NodeGroup *group = static_cast<NodeGroup *>(sender());
|
||||
|
||||
AddNodeInternal(node, item_map_.value(group));
|
||||
add_node_internal(node, item_map_.value(group));
|
||||
}
|
||||
|
||||
void NodeViewContext::GroupRemovedNode(Node *node)
|
||||
void NodeViewContext::group_removed_node(Node *node)
|
||||
{
|
||||
NodeGroup *group = static_cast<NodeGroup *>(sender());
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NODEVIEWCONTEXT_H
|
||||
#define NODEVIEWCONTEXT_H
|
||||
#ifndef OAK_NODEVIEWCONTEXT_H
|
||||
#define OAK_NODEVIEWCONTEXT_H
|
||||
|
||||
#include <QGraphicsRectItem>
|
||||
#include <QGraphicsTextItem>
|
||||
@@ -37,26 +37,26 @@ public:
|
||||
|
||||
virtual ~NodeViewContext() override;
|
||||
|
||||
Node *GetContext() const
|
||||
Node *get_context() const
|
||||
{
|
||||
return context_;
|
||||
}
|
||||
|
||||
void UpdateRect();
|
||||
void update_rect();
|
||||
|
||||
void SetFlowDirection(NodeViewCommon::FlowDirection dir);
|
||||
void set_flow_direction(NodeViewCommon::FlowDirection dir);
|
||||
|
||||
void SetCurvedEdges(bool e);
|
||||
void set_curved_edges(bool e);
|
||||
|
||||
int DeleteSelected(NodeViewDeleteCommand *command);
|
||||
int delete_selected(NodeViewDeleteCommand *command);
|
||||
|
||||
void Select(const QVector<Node *> &nodes);
|
||||
void select(const QVector<Node *> &nodes);
|
||||
|
||||
QVector<NodeViewItem *> GetSelectedItems() const;
|
||||
QVector<NodeViewItem *> get_selected_items() const;
|
||||
|
||||
QPointF MapScenePosToNodePosInContext(const QPointF &pos) const;
|
||||
QPointF map_scene_pos_to_node_pos_in_context(const QPointF &pos) const;
|
||||
|
||||
NodeViewItem *GetItemFromMap(Node *node) const
|
||||
NodeViewItem *get_item_from_map(Node *node) const
|
||||
{
|
||||
return item_map_.value(node);
|
||||
}
|
||||
@@ -66,18 +66,18 @@ public:
|
||||
QWidget *widget = nullptr) override;
|
||||
|
||||
public slots:
|
||||
void AddChild(Node *node);
|
||||
void add_child(Node *node);
|
||||
|
||||
void SetChildPosition(Node *node, const QPointF &pos);
|
||||
void set_child_position(Node *node, const QPointF &pos);
|
||||
|
||||
void RemoveChild(Node *node);
|
||||
void remove_child(Node *node);
|
||||
|
||||
void ChildInputConnected(Node *output, const NodeInput &input);
|
||||
void child_input_connected(Node *output, const NodeInput &input);
|
||||
|
||||
bool ChildInputDisconnected(Node *output, const NodeInput &input);
|
||||
bool child_input_disconnected(Node *output, const NodeInput &input);
|
||||
|
||||
signals:
|
||||
void ItemAboutToBeDeleted(NodeViewItem *item);
|
||||
void item_about_to_be_deleted(NodeViewItem *item);
|
||||
|
||||
protected:
|
||||
virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange change,
|
||||
@@ -86,9 +86,9 @@ protected:
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
|
||||
private:
|
||||
void AddNodeInternal(Node *node, NodeViewItem *item);
|
||||
void add_node_internal(Node *node, NodeViewItem *item);
|
||||
|
||||
void AddEdgeInternal(Node *output, const NodeInput &input,
|
||||
void add_edge_internal(Node *output, const NodeInput &input,
|
||||
NodeViewItem *from, NodeViewItem *to);
|
||||
|
||||
Node *context_;
|
||||
@@ -106,11 +106,11 @@ private:
|
||||
QVector<NodeViewEdge *> edges_;
|
||||
|
||||
private slots:
|
||||
void GroupAddedNode(Node *node);
|
||||
void group_added_node(Node *node);
|
||||
|
||||
void GroupRemovedNode(Node *node);
|
||||
void group_removed_node(Node *node);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEVIEWCONTEXT_H
|
||||
#endif // OAK_NODEVIEWCONTEXT_H
|
||||
|
||||
@@ -45,11 +45,11 @@ NodeViewEdge::NodeViewEdge(Node *output, const NodeInput &input,
|
||||
, from_item_(from_item)
|
||||
, to_item_(to_item)
|
||||
{
|
||||
Init();
|
||||
SetConnected(true);
|
||||
init();
|
||||
set_connected(true);
|
||||
|
||||
from_item_->AddEdge(this);
|
||||
to_item_->AddEdge(this);
|
||||
from_item_->add_edge(this);
|
||||
to_item_->add_edge(this);
|
||||
}
|
||||
|
||||
NodeViewEdge::NodeViewEdge(QGraphicsItem *parent)
|
||||
@@ -57,83 +57,83 @@ NodeViewEdge::NodeViewEdge(QGraphicsItem *parent)
|
||||
, from_item_(nullptr)
|
||||
, to_item_(nullptr)
|
||||
{
|
||||
Init();
|
||||
init();
|
||||
}
|
||||
|
||||
NodeViewEdge::~NodeViewEdge()
|
||||
{
|
||||
if (from_item_) {
|
||||
from_item_->RemoveEdge(this);
|
||||
from_item_->remove_edge(this);
|
||||
}
|
||||
|
||||
if (to_item_) {
|
||||
to_item_->RemoveEdge(this);
|
||||
to_item_->remove_edge(this);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeViewEdge::set_from_item(NodeViewItem *i)
|
||||
{
|
||||
if (from_item_) {
|
||||
from_item_->RemoveEdge(this);
|
||||
from_item_->remove_edge(this);
|
||||
}
|
||||
|
||||
from_item_ = i;
|
||||
|
||||
if (from_item_) {
|
||||
from_item_->AddEdge(this);
|
||||
from_item_->add_edge(this);
|
||||
}
|
||||
|
||||
Adjust();
|
||||
adjust();
|
||||
}
|
||||
|
||||
void NodeViewEdge::set_to_item(NodeViewItem *i)
|
||||
{
|
||||
if (to_item_) {
|
||||
to_item_->RemoveEdge(this);
|
||||
to_item_->remove_edge(this);
|
||||
}
|
||||
|
||||
to_item_ = i;
|
||||
|
||||
if (to_item_) {
|
||||
to_item_->AddEdge(this);
|
||||
to_item_->add_edge(this);
|
||||
}
|
||||
|
||||
Adjust();
|
||||
adjust();
|
||||
}
|
||||
|
||||
void NodeViewEdge::Adjust()
|
||||
void NodeViewEdge::adjust()
|
||||
{
|
||||
// Draw a line between the two
|
||||
SetPoints(from_item()->GetOutputPoint(), to_item()->GetInputPoint());
|
||||
set_points(from_item()->get_output_point(), to_item()->get_input_point());
|
||||
}
|
||||
|
||||
void NodeViewEdge::SetConnected(bool c)
|
||||
void NodeViewEdge::set_connected(bool c)
|
||||
{
|
||||
connected_ = c;
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
void NodeViewEdge::SetHighlighted(bool e)
|
||||
void NodeViewEdge::set_highlighted(bool e)
|
||||
{
|
||||
highlighted_ = e;
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
void NodeViewEdge::SetPoints(const QPointF &start, const QPointF &end)
|
||||
void NodeViewEdge::set_points(const QPointF &start, const QPointF &end)
|
||||
{
|
||||
cached_start_ = start;
|
||||
cached_end_ = end;
|
||||
|
||||
UpdateCurve();
|
||||
update_curve();
|
||||
}
|
||||
|
||||
void NodeViewEdge::SetCurved(bool e)
|
||||
void NodeViewEdge::set_curved(bool e)
|
||||
{
|
||||
curved_ = e;
|
||||
|
||||
UpdateCurve();
|
||||
update_curve();
|
||||
}
|
||||
|
||||
void NodeViewEdge::paint(QPainter *painter,
|
||||
@@ -162,7 +162,7 @@ void NodeViewEdge::paint(QPainter *painter,
|
||||
painter->drawPath(path());
|
||||
}
|
||||
|
||||
void NodeViewEdge::Init()
|
||||
void NodeViewEdge::init()
|
||||
{
|
||||
connected_ = false;
|
||||
highlighted_ = false;
|
||||
@@ -177,7 +177,7 @@ void NodeViewEdge::Init()
|
||||
edge_width_ = QFontMetrics(QFont()).height() / 12;
|
||||
}
|
||||
|
||||
void NodeViewEdge::UpdateCurve()
|
||||
void NodeViewEdge::update_curve()
|
||||
{
|
||||
const QPointF &start = cached_start_;
|
||||
const QPointF &end = cached_end_;
|
||||
@@ -194,30 +194,30 @@ void NodeViewEdge::UpdateCurve()
|
||||
QPointF cp1, cp2;
|
||||
|
||||
NodeViewCommon::FlowDirection from_flow =
|
||||
from_item_ ? from_item_->GetFlowDirection() :
|
||||
NodeViewCommon::kInvalidDirection;
|
||||
from_item_ ? from_item_->get_flow_direction() :
|
||||
NodeViewCommon::k_invalid_direction;
|
||||
NodeViewCommon::FlowDirection to_flow =
|
||||
to_item_ ? to_item_->GetFlowDirection() :
|
||||
NodeViewCommon::kInvalidDirection;
|
||||
to_item_ ? to_item_->get_flow_direction() :
|
||||
NodeViewCommon::k_invalid_direction;
|
||||
|
||||
if (from_flow == NodeViewCommon::kInvalidDirection &&
|
||||
to_flow == NodeViewCommon::kInvalidDirection) {
|
||||
if (from_flow == NodeViewCommon::k_invalid_direction &&
|
||||
to_flow == NodeViewCommon::k_invalid_direction) {
|
||||
// This is a technically unsupported scenario, but to avoid issues, we'll use a fallback
|
||||
from_flow = NodeViewCommon::kLeftToRight;
|
||||
to_flow = NodeViewCommon::kLeftToRight;
|
||||
} else if (from_flow == NodeViewCommon::kInvalidDirection) {
|
||||
from_flow = NodeViewCommon::k_left_to_right;
|
||||
to_flow = NodeViewCommon::k_left_to_right;
|
||||
} else if (from_flow == NodeViewCommon::k_invalid_direction) {
|
||||
from_flow = to_flow;
|
||||
} else if (to_flow == NodeViewCommon::kInvalidDirection) {
|
||||
} else if (to_flow == NodeViewCommon::k_invalid_direction) {
|
||||
to_flow = from_flow;
|
||||
}
|
||||
|
||||
if (NodeViewCommon::GetFlowOrientation(from_flow) == Qt::Horizontal) {
|
||||
if (NodeViewCommon::get_flow_orientation(from_flow) == Qt::Horizontal) {
|
||||
cp1 = QPointF(half_x, start.y());
|
||||
} else {
|
||||
cp1 = QPointF(start.x(), half_y);
|
||||
}
|
||||
|
||||
if (NodeViewCommon::GetFlowOrientation(to_flow) == Qt::Horizontal) {
|
||||
if (NodeViewCommon::get_flow_orientation(to_flow) == Qt::Horizontal) {
|
||||
cp2 = QPointF(half_x, end.y());
|
||||
} else {
|
||||
cp2 = QPointF(end.x(), half_y);
|
||||
@@ -244,8 +244,8 @@ void NodeViewEdge::UpdateCurve()
|
||||
std::swap(y2, y3);
|
||||
}
|
||||
|
||||
double t = Bezier::CubicXtoT(continue_x, x1, x2, x3, x4);
|
||||
double y = Bezier::CubicTtoY(y1, y2, y3, y4, t);
|
||||
double t = Bezier::cubic_xto_t(continue_x, x1, x2, x3, x4);
|
||||
double y = Bezier::cubic_tto_y(y1, y2, y3, y4, t);
|
||||
|
||||
angle = std::atan2(end.y() - y, end.x() - continue_x);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user