diff --git a/app/node/CMakeLists.txt b/app/node/CMakeLists.txt index a0588dcbe..7df7de22d 100644 --- a/app/node/CMakeLists.txt +++ b/app/node/CMakeLists.txt @@ -24,6 +24,7 @@ add_subdirectory(input) add_subdirectory(math) add_subdirectory(output) add_subdirectory(project) +add_subdirectory(time) set(OLIVE_SOURCES ${OLIVE_SOURCES} diff --git a/app/node/time/CMakeLists.txt b/app/node/time/CMakeLists.txt new file mode 100644 index 000000000..30a364e7a --- /dev/null +++ b/app/node/time/CMakeLists.txt @@ -0,0 +1,22 @@ +# Olive - Non-Linear Video Editor +# Copyright (C) 2020 Olive Team +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +add_subdirectory(timeremap) + +set(OLIVE_SOURCES + ${OLIVE_SOURCES} + PARENT_SCOPE +) diff --git a/app/node/time/timeremap/CMakeLists.txt b/app/node/time/timeremap/CMakeLists.txt new file mode 100644 index 000000000..d9eb934d7 --- /dev/null +++ b/app/node/time/timeremap/CMakeLists.txt @@ -0,0 +1,22 @@ +# Olive - Non-Linear Video Editor +# Copyright (C) 2020 Olive Team +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +set(OLIVE_SOURCES + ${OLIVE_SOURCES} + node/time/timeremap/timeremap.cpp + node/time/timeremap/timeremap.h + PARENT_SCOPE +) diff --git a/app/node/time/timeremap/timeremap.cpp b/app/node/time/timeremap/timeremap.cpp new file mode 100644 index 000000000..b17251938 --- /dev/null +++ b/app/node/time/timeremap/timeremap.cpp @@ -0,0 +1,104 @@ +/*** + + Olive - Non-Linear Video Editor + Copyright (C) 2020 Olive Team + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +***/ + +#include "timeremap.h" + +#include "widget/slider/rationalslider.h" + +namespace olive { + +const QString TimeRemapNode::kTimeInput = QStringLiteral("time_in"); +const QString TimeRemapNode::kInputInput = QStringLiteral("input_in"); + +#define super Node + +TimeRemapNode::TimeRemapNode() +{ + AddInput(kTimeInput, NodeValue::kRational, QVariant::fromValue(rational(0)), InputFlags(kInputFlagNotConnectable)); + SetInputProperty(kTimeInput, QStringLiteral("view"), RationalSlider::kTime); + SetInputProperty(kTimeInput, QStringLiteral("viewlock"), true); + + // Ignore the hashing from time since we just pass through to the input + IgnoreHashingFrom(kTimeInput); + + AddInput(kInputInput, NodeValue::kNone, InputFlags(kInputFlagNotKeyframable)); +} + +Node *TimeRemapNode::copy() const +{ + return new TimeRemapNode(); +} + +QString TimeRemapNode::Name() const +{ + return tr("Time Remap"); +} + +QString TimeRemapNode::id() const +{ + return QStringLiteral("org.olivevideoeditor.Olive.timeremap"); +} + +QVector TimeRemapNode::Category() const +{ + return {kCategoryGeneral}; +} + +QString TimeRemapNode::Description() const +{ + return tr("Arbitrarily remap time through the nodes."); +} + +TimeRange TimeRemapNode::InputTimeAdjustment(const QString &input, int element, const TimeRange &input_time) const +{ + if (input == kInputInput) { + rational target_time = GetValueAtTime(kTimeInput, input_time.in()).value(); + + return TimeRange(target_time, target_time + input_time.length()); + } else { + return super::InputTimeAdjustment(input, element, input_time); + } +} + +TimeRange TimeRemapNode::OutputTimeAdjustment(const QString &input, int element, const TimeRange &input_time) const +{ + /*if (input == kInputInput) { + rational target_time = GetValueAtTime(kTimeInput, input_time.in()).value(); + + return TimeRange(target_time, target_time + input_time.length()); + } else { + return super::OutputTimeAdjustment(input, element, input_time); + }*/ + return super::OutputTimeAdjustment(input, element, input_time); +} + +void TimeRemapNode::Retranslate() +{ + SetInputName(kTimeInput, QStringLiteral("Time")); + SetInputName(kInputInput, QStringLiteral("Input")); +} + +QVector TimeRemapNode::inputs_for_output(const QString &output) const +{ + Q_UNUSED(output) + return {kInputInput}; +} + +} diff --git a/app/node/time/timeremap/timeremap.h b/app/node/time/timeremap/timeremap.h new file mode 100644 index 000000000..13e3bbcc8 --- /dev/null +++ b/app/node/time/timeremap/timeremap.h @@ -0,0 +1,57 @@ +/*** + + Olive - Non-Linear Video Editor + Copyright (C) 2020 Olive Team + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +***/ + +#ifndef TIMEREMAPNODE_H +#define TIMEREMAPNODE_H + +#include "node/node.h" + +namespace olive { + +class TimeRemapNode : public Node +{ + Q_OBJECT +public: + TimeRemapNode(); + + NODE_DEFAULT_DESTRUCTOR(TimeRemapNode) + + virtual Node* copy() const override; + + virtual QString Name() const override; + virtual QString id() const override; + virtual QVector Category() const override; + virtual QString Description() const override; + + virtual TimeRange InputTimeAdjustment(const QString& input, int element, const TimeRange& input_time) const override; + virtual TimeRange OutputTimeAdjustment(const QString& input, int element, const TimeRange& input_time) const override; + + virtual void Retranslate() override; + + virtual QVector inputs_for_output(const QString &output) const override; + + static const QString kTimeInput; + static const QString kInputInput; + +}; + +} + +#endif // TIMEREMAPNODE_H