implement group-based opacity node

This commit is contained in:
itsmattkc
2022-01-21 10:08:48 -08:00
parent 8ab3331586
commit 3cf90116e2
9 changed files with 140 additions and 0 deletions
+1
View File
@@ -18,6 +18,7 @@ add_subdirectory(audio)
add_subdirectory(block)
add_subdirectory(color)
add_subdirectory(distort)
add_subdirectory(effect)
add_subdirectory(filter)
add_subdirectory(generator)
add_subdirectory(group)
+22
View File
@@ -0,0 +1,22 @@
# Olive - Non-Linear Video Editor
# Copyright (C) 2021 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 <http://www.gnu.org/licenses/>.
add_subdirectory(opacity)
set(OLIVE_SOURCES
${OLIVE_SOURCES}
PARENT_SCOPE
)
+22
View File
@@ -0,0 +1,22 @@
# Olive - Non-Linear Video Editor
# Copyright (C) 2021 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 <http://www.gnu.org/licenses/>.
set(OLIVE_SOURCES
${OLIVE_SOURCES}
node/effect/opacity/opacityeffect.cpp
node/effect/opacity/opacityeffect.h
PARENT_SCOPE
)
+38
View File
@@ -0,0 +1,38 @@
#include "opacityeffect.h"
#include "node/math/math/math.h"
#include "widget/slider/floatslider.h"
namespace olive {
#define super NodeGroup
OpacityEffect::OpacityEffect()
{
MathNode *math = new MathNode();
math->SetOperation(MathNode::kOpMultiply);
SetNodePositionInContext(math, QPointF(0, 0));
tex_in_pass_ = AddInputPassthrough(NodeInput(math, MathNode::kParamAIn));
SetInputDataType(tex_in_pass_, NodeValue::kTexture);
value_in_pass_ = AddInputPassthrough(NodeInput(math, MathNode::kParamBIn));
SetInputProperty(value_in_pass_, QStringLiteral("view"), FloatSlider::kPercentage);
SetInputProperty(value_in_pass_, QStringLiteral("min"), 0.0);
SetInputProperty(value_in_pass_, QStringLiteral("max"), 1.0);
math->SetStandardValue(MathNode::kParamBIn, 1.0);
SetOutputPassthrough(math);
}
void OpacityEffect::Retranslate()
{
super::Retranslate();
SetInputName(tex_in_pass_, tr("Texture"));
SetInputName(value_in_pass_, tr("Opacity"));
}
}
+47
View File
@@ -0,0 +1,47 @@
#ifndef OPACITYEFFECT_H
#define OPACITYEFFECT_H
#include "node/group/group.h"
namespace olive {
class OpacityEffect : public NodeGroup
{
public:
OpacityEffect();
NODE_DEFAULT_DESTRUCTOR(OpacityEffect)
NODE_COPY_FUNCTION(OpacityEffect)
virtual QString Name() const override
{
return tr("Opacity");
}
virtual QString id() const override
{
return QStringLiteral("org.olivevideoeditor.Olive.opacityeffect");
}
virtual QVector<CategoryID> Category() const override
{
return {kCategoryFilter, kCategoryVideoEffect};
}
virtual QString Description() const override
{
return tr("Alter a video's opacity.\n\nThis is equivalent to multiplying a video by a number between 0.0 and 1.0.");
}
virtual void Retranslate() override;
private:
QString tex_in_pass_;
QString value_in_pass_;
};
}
#endif // OPACITYEFFECT_H
+3
View File
@@ -31,6 +31,7 @@
#include "block/transition/diptocolor/diptocolortransition.h"
#include "distort/crop/cropdistortnode.h"
#include "distort/transform/transformdistortnode.h"
#include "effect/opacity/opacityeffect.h"
#include "generator/matrix/matrix.h"
#include "generator/polygon/polygon.h"
#include "generator/shape/shapenode.h"
@@ -252,6 +253,8 @@ Node *NodeFactory::CreateFromFactoryIndex(const NodeFactory::InternalID &id)
return new ShapeNode();
case kGroupNode:
return new NodeGroup();
case kOpacityEffect:
return new OpacityEffect();
case kInternalNodeCount:
break;
+1
View File
@@ -62,6 +62,7 @@ public:
kSubtitleBlock,
kShapeGenerator,
kGroupNode,
kOpacityEffect,
// Count value
kInternalNodeCount
+4
View File
@@ -1643,6 +1643,10 @@ QString Node::GetCategoryName(const CategoryID &c)
return tr("Transition");
case kCategoryProject:
return tr("Project");
case kCategoryVideoEffect:
return tr("Video Effect");
case kCategoryAudioEffect:
return tr("Audio Effect");
case kCategoryUnknown:
case kCategoryCount:
break;
+2
View File
@@ -90,6 +90,8 @@ public:
kCategoryTransition,
kCategoryDistort,
kCategoryProject,
kCategoryVideoEffect,
kCategoryAudioEffect,
kCategoryCount
};