Skip to content

Commit

Permalink
node: make convenient input flag setter
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmattkc committed Feb 21, 2023
1 parent 7348d28 commit f9cd28a
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 34 deletions.
3 changes: 2 additions & 1 deletion app/node/block/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ Block::Block() :
SetInputProperty(kLengthInput, QStringLiteral("view"), RationalSlider::kTime);
SetInputProperty(kLengthInput, QStringLiteral("viewlock"), true);

SetInputFlags(kEnabledInput, InputFlags(GetInputFlags(kEnabledInput) | kInputFlagNotConnectable | kInputFlagNotKeyframable));
SetInputFlag(kEnabledInput, kInputFlagNotConnectable);
SetInputFlag(kEnabledInput, kInputFlagNotKeyframable);

SetFlag(kDontShowInParamView);
}
Expand Down
12 changes: 6 additions & 6 deletions app/node/block/subtitle/subtitle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ SubtitleBlock::SubtitleBlock()
{
AddInput(kTextIn, NodeValue::kText, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));

SetInputFlags(kBufferIn, InputFlags(GetInputFlags(kBufferIn) | kInputFlagHidden));
SetInputFlags(kLengthInput, InputFlags(GetInputFlags(kLengthInput) | kInputFlagHidden));
SetInputFlags(kMediaInInput, InputFlags(GetInputFlags(kMediaInInput) | kInputFlagHidden));
SetInputFlags(kSpeedInput, InputFlags(GetInputFlags(kSpeedInput) | kInputFlagHidden));
SetInputFlags(kReverseInput, InputFlags(GetInputFlags(kReverseInput) | kInputFlagHidden));
SetInputFlags(kMaintainAudioPitchInput, InputFlags(GetInputFlags(kMaintainAudioPitchInput) | kInputFlagHidden));
SetInputFlag(kBufferIn, kInputFlagHidden);
SetInputFlag(kLengthInput, kInputFlagHidden);
SetInputFlag(kMediaInInput, kInputFlagHidden);
SetInputFlag(kSpeedInput, kInputFlagHidden);
SetInputFlag(kReverseInput, kInputFlagHidden);
SetInputFlag(kMaintainAudioPitchInput, kInputFlagHidden);

// Undo block flag that hides in param view
SetFlag(kDontShowInParamView, false);
Expand Down
2 changes: 1 addition & 1 deletion app/node/distort/mask/mask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const QString MaskDistortNode::kInvertInput = QStringLiteral("invert_in");
MaskDistortNode::MaskDistortNode()
{
// Mask should always be (1.0, 1.0, 1.0) for multiply to work correctly
SetInputFlags(kColorInput, InputFlags(GetInputFlags(kColorInput) | kInputFlagHidden));
SetInputFlag(kColorInput, kInputFlagHidden);

AddInput(kInvertInput, NodeValue::kBoolean, false);

Expand Down
8 changes: 4 additions & 4 deletions app/node/filter/blur/blur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,10 @@ void BlurFilterNode::InputValueChangedEvent(const QString &input, int element)

void BlurFilterNode::UpdateInputs(Method method)
{
SetInputFlags(kHorizInput, (method == kBox || method == kGaussian) ? InputFlags() : InputFlags(kInputFlagHidden));
SetInputFlags(kVertInput, (method == kBox || method == kGaussian) ? InputFlags() : InputFlags(kInputFlagHidden));
SetInputFlags(kDirectionalDegreesInput, (method == kDirectional) ? InputFlags() : InputFlags(kInputFlagHidden));
SetInputFlags(kRadialCenterInput, (method == kRadial) ? InputFlags() : InputFlags(kInputFlagHidden));
SetInputFlag(kHorizInput, kInputFlagHidden, !(method == kBox || method == kGaussian));
SetInputFlag(kVertInput, kInputFlagHidden, !(method == kBox || method == kGaussian));
SetInputFlag(kDirectionalDegreesInput, kInputFlagHidden, !(method == kDirectional));
SetInputFlag(kRadialCenterInput, kInputFlagHidden, !(method == kRadial));
}

}
8 changes: 1 addition & 7 deletions app/node/generator/shape/shapenode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,7 @@ void ShapeNode::Value(const NodeValueRow &value, const NodeGlobals &globals, Nod
void ShapeNode::InputValueChangedEvent(const QString &input, int element)
{
if (input == kTypeInput) {
InputFlags i = GetInputFlags(kRadiusInput);
if (GetStandardValue(kTypeInput).toInt() == kRoundedRectangle) {
i &= InputFlag(~kInputFlagHidden);
} else {
i |= kInputFlagHidden;
}
SetInputFlags(kRadiusInput, i);
SetInputFlag(kRadiusInput, kInputFlagHidden, (GetStandardValue(kTypeInput).toInt() != kRoundedRectangle));
}
super::InputValueChangedEvent(input, element);
}
Expand Down
4 changes: 2 additions & 2 deletions app/node/input/multicam/multicamnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void MultiCamNode::InputConnectedEvent(const QString &input, int element, Node *
{
if (input == kSequenceInput) {
if (Sequence *s = dynamic_cast<Sequence*>(output)) {
SetInputFlags(kSequenceTypeInput, GetInputFlags(kSequenceTypeInput) & InputFlag(~kInputFlagHidden));
SetInputFlag(kSequenceTypeInput, kInputFlagHidden, false);
sequence_ = s;
}
}
Expand All @@ -112,7 +112,7 @@ void MultiCamNode::InputConnectedEvent(const QString &input, int element, Node *
void MultiCamNode::InputDisconnectedEvent(const QString &input, int element, Node *output)
{
if (input == kSequenceInput) {
SetInputFlags(kSequenceTypeInput, GetInputFlags(kSequenceTypeInput) | kInputFlagHidden);
SetInputFlag(kSequenceTypeInput, kInputFlagHidden, true);
sequence_ = nullptr;
}
}
Expand Down
8 changes: 6 additions & 2 deletions app/node/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -903,12 +903,16 @@ InputFlags Node::GetInputFlags(const QString &input) const
}
}

void Node::SetInputFlags(const QString &input, const InputFlags &f)
void Node::SetInputFlag(const QString &input, InputFlag f, bool on)
{
Input* i = GetInternalInputData(input);

if (i) {
i->flags = f;
if (on) {
i->flags |= f;
} else {
i->flags &= ~f;
}
emit InputFlagsChanged(input, i->flags);
} else {
ReportInvalidInput("set flags of", input, -1);
Expand Down
2 changes: 1 addition & 1 deletion app/node/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ class Node : public QObject
}

InputFlags GetInputFlags(const QString& input) const;
void SetInputFlags(const QString &input, const InputFlags &f);
void SetInputFlag(const QString &input, InputFlag f, bool on = true);

virtual void LoadFinishedEvent(){}
virtual void ConnectedToPreviewEvent(){}
Expand Down
44 changes: 35 additions & 9 deletions app/node/param.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace olive {
class Node;
class NodeKeyframe;

enum InputFlag {
enum InputFlag : uint64_t {
/// By default, inputs are keyframable, connectable, and NOT arrays
kInputFlagNormal = 0x0,
kInputFlagArray = 0x1,
Expand Down Expand Up @@ -61,51 +61,77 @@ class InputFlags {
return i;
}

InputFlags &operator|=(const InputFlags &f)
InputFlags operator|(const InputFlag &f) const
{
f_ |= f.f_;
return *this;
InputFlags i = *this;
i |= f;
return i;
}

InputFlags operator|(const InputFlag &f) const
InputFlags operator|(const uint64_t &f) const
{
InputFlags i = *this;
i |= f;
return i;
}

InputFlags &operator|=(const InputFlags &f)
{
f_ |= f.f_;
return *this;
}

InputFlags &operator|=(const InputFlag &f)
{
f_ |= f;
return *this;
}

InputFlags &operator|=(const uint64_t &f)
{
f_ |= f;
return *this;
}

InputFlags operator&(const InputFlags &f) const
{
InputFlags i = *this;
i &= f;
return i;
}

InputFlags &operator&=(const InputFlags &f)
InputFlags operator&(const InputFlag &f) const
{
f_ &= f.f_;
return *this;
InputFlags i = *this;
i &= f;
return i;
}

InputFlags operator&(const InputFlag &f) const
InputFlags operator&(const uint64_t &f) const
{
InputFlags i = *this;
i &= f;
return i;
}

InputFlags &operator&=(const InputFlags &f)
{
f_ &= f.f_;
return *this;
}

InputFlags &operator&=(const InputFlag &f)
{
f_ &= f;
return *this;
}

InputFlags &operator&=(const uint64_t &f)
{
f_ &= f;
return *this;
}

InputFlags operator~() const
{
InputFlags i = *this;
Expand Down
2 changes: 1 addition & 1 deletion app/node/project/serializer/serializer220403.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ void ProjectSerializer220403::PostConnect(const XMLNodeData &xml_node_data) cons

l.group->AddInputPassthrough(resolved, l.passthrough_id);

l.group->SetInputFlags(l.passthrough_id, resolved.GetFlags() | l.custom_flags);
l.group->SetInputFlag(l.passthrough_id, InputFlag(l.custom_flags.value()));

if (!l.custom_name.isEmpty()) {
l.group->SetInputName(l.passthrough_id, l.custom_name);
Expand Down

0 comments on commit f9cd28a

Please sign in to comment.