Add push button support for OFX plugins

This commit adds support for push buttons in OFX plugins by:

- Adding `kPushButton` to `NodeValue` enum
- Implementing `pushButtonClicked` slot in `PluginNode`
- Creating `NodeParamButton` widget for UI representation
- Updating `paraminstance.h` to handle push button instances
- Modifying `nodeparamviewwidgetbridge.cpp` to connect push button signals
This commit is contained in:
2025-11-10 13:57:04 +08:00
parent 8a7b6cf869
commit 5aaa49c515
10 changed files with 188 additions and 66 deletions
+2
View File
@@ -57,6 +57,8 @@ set(OLIVE_RESOURCES
${CMAKE_CURRENT_BINARY_DIR}/ts/translations.qrc ${CMAKE_CURRENT_BINARY_DIR}/ts/translations.qrc
render/job/pluginjob.cpp render/job/pluginjob.cpp
render/job/pluginjob.h render/job/pluginjob.h
widget/nodeparamview/nodeparambutton.cpp
widget/nodeparamview/nodeparambutton.h
) )
# Add version object # Add version object
+11 -11
View File
@@ -53,20 +53,20 @@ olive::plugin::PluginNode::PluginNode(
} else if (ofxType == kOfxParamTypeStrChoice){ } else if (ofxType == kOfxParamTypeStrChoice){
type = NodeValue::kStrCombo; type = NodeValue::kStrCombo;
}else if (ofxType == kOfxParamTypeBytes }else if (ofxType == kOfxParamTypeBytes
|| ofxType == kOfxParamTypeCustom) { || ofxType == kOfxParamTypeCustom) {
type = NodeValue::kBinary; type = NodeValue::kBinary;
} else { } else if (ofxType == kOfxParamTypePushButton) {
type = NodeValue::kNone; type = NodeValue::kPushButton;
}
if (ofxType == kOfxParamTypePushButton) {
// TODO
} else if (ofxType == kOfxParamTypeGroup) { } else if (ofxType == kOfxParamTypeGroup) {
// TODO // TODO
} else if (ofxType == kOfxParamTypePage) { } else if (ofxType == kOfxParamTypePage) {
// TODO // TODO
}else {
type = NodeValue::kNone;
} }
AddInput(param.second->getName().data(), type); AddInput(param.second->getName().data(), type);
} }
@@ -91,12 +91,12 @@ void olive::plugin::PluginNode::Value(const NodeValueRow &value,
{ {
TexturePtr tex = value[kTextureInput].toTexture(); TexturePtr tex = value[kTextureInput].toTexture();
if (tex) { if (tex) {
PluginJob job(,value); PluginJob job(plugin, value);
table->Push(NodeValue::kTexture, tex->toJob(job), this); table->Push(NodeValue::kTexture, tex->toJob(job), this);
} }
}
void olive::plugin::PluginNode::pushButtonClicked(QString name)
{
} }
QString olive::plugin::PluginNode::id() const QString olive::plugin::PluginNode::id() const
+4
View File
@@ -40,6 +40,7 @@ public:
void AddPushButton(); void AddPushButton();
void AddPage(); void AddPage();
Node *copy() const override; Node *copy() const override;
/** /**
* @brief The main processing function * @brief The main processing function
@@ -73,6 +74,9 @@ public:
*/ */
virtual void GenerateFrame(FramePtr frame, const GenerateJob &job) const; virtual void GenerateFrame(FramePtr frame, const GenerateJob &job) const;
public slots:
void pushButtonClicked(QString name);
}; };
} }
+4
View File
@@ -197,6 +197,10 @@ public:
kBinary, kBinary,
/** /**
*Push Button
*/
kPushButton,
/**
* End of list * End of list
*/ */
kDataTypeCount kDataTypeCount
+61 -27
View File
@@ -21,20 +21,21 @@
#ifndef PARAM_INSTANCE_H #ifndef PARAM_INSTANCE_H
#define PARAM_INSTANCE_H #define PARAM_INSTANCE_H
#include "OlivePluginInstance.h"
#include "ofxhParam.h" #include "ofxhParam.h"
#include "node/plugins/Plugin.h"
namespace olive namespace olive
{ {
namespace plugin namespace plugin
{ {
class PushbuttonInstance : public OFX::Host::Param::PushbuttonInstance { class PushbuttonInstance : public OFX::Host::Param::PushbuttonInstance {
protected: protected:
OlivePluginInstance* _effect; PluginNode* node;
OFX::Host::Param::Descriptor *_descriptor; OFX::Host::Param::Descriptor *_descriptor;
public: public:
PushbuttonInstance(OlivePluginInstance *effect, const std::string &name, PushbuttonInstance(PluginNode *effect, const std::string &name,
OFX::Host::Param::Descriptor &descriptor) OFX::Host::Param::Descriptor &descriptor)
: OFX::Host::Param::PushbuttonInstance( descriptor) : OFX::Host::Param::PushbuttonInstance(descriptor)
, node(effect)
{ {
_descriptor = &descriptor; _descriptor = &descriptor;
}; };
@@ -42,22 +43,58 @@ public:
class IntegerInstance : public OFX::Host::Param::IntegerInstance { class IntegerInstance : public OFX::Host::Param::IntegerInstance {
protected: protected:
OlivePluginInstance* _effect; PluginNode* _node;
OFX::Host::Param::Descriptor& _descriptor; OFX::Host::Param::Descriptor& _descriptor;
QString id;
public: public:
IntegerInstance(OlivePluginInstance* effect, const std::string& name, OFX::Host::Param::Descriptor& descriptor); IntegerInstance(PluginNode *node, OFX::Host::Param::Descriptor &descriptor)
OfxStatus get(int&); : _node(node), _descriptor(descriptor),
OfxStatus get(OfxTime time, int&); OFX::Host::Param::IntegerInstance(_descriptor){}
OfxStatus set(int); OfxStatus get(int &a)
OfxStatus set(OfxTime time, int); {
if (id.isEmpty()) {
return kOfxStatErrBadHandle;
}
QVariant variant=_node->GetStandardValue(id);
if (variant.typeId()==QVariant::Int) {
a=variant.toInt();
return kOfxStatOK;
}
a=0;
return kOfxStatErrValue;
}
OfxStatus get(OfxTime time, int &data)
{
if (id.isEmpty()) {
return kOfxStatErrBadHandle;
}
QVariant variant=_node->GetValueAtTime(id, rational::fromDouble(time));
if (variant.typeId()==QVariant::Int) {
data=variant.toInt();
return kOfxStatOK;
}
data=0;
return kOfxStatErrValue;
}
OfxStatus set(int data)
{
_node->SetStandardValue(_descriptor.getName().c_str(), data);
id=_descriptor.getName().c_str();
return kOfxStatOK;
}
OfxStatus set(OfxTime time, int)
{
_node->SetValueAtTime()
}
}; };
class DoubleInstance : public OFX::Host::Param::DoubleInstance { class DoubleInstance : public OFX::Host::Param::DoubleInstance {
protected: protected:
OlivePluginInstance* _effect; PluginNode* node;
OFX::Host::Param::Descriptor& _descriptor; OFX::Host::Param::Descriptor& _descriptor;
public: public:
DoubleInstance(OlivePluginInstance* effect, const std::string& name, OFX::Host::Param::Descriptor& descriptor); DoubleInstance(PluginNode* effect, const std::string& name, OFX::Host::Param::Descriptor& descriptor);
OfxStatus get(double&); OfxStatus get(double&);
OfxStatus get(OfxTime time, double&); OfxStatus get(OfxTime time, double&);
OfxStatus set(double); OfxStatus set(double);
@@ -68,10 +105,10 @@ public:
class BooleanInstance : public OFX::Host::Param::BooleanInstance { class BooleanInstance : public OFX::Host::Param::BooleanInstance {
protected: protected:
OlivePluginInstance* _effect; PluginNode* node;
OFX::Host::Param::Descriptor& _descriptor; OFX::Host::Param::Descriptor& _descriptor;
public: public:
BooleanInstance(OlivePluginInstance* effect, const std::string& name, OFX::Host::Param::Descriptor& descriptor); BooleanInstance(PluginNode* effect, const std::string& name, OFX::Host::Param::Descriptor& descriptor);
OfxStatus get(bool&); OfxStatus get(bool&);
OfxStatus get(OfxTime time, bool&); OfxStatus get(OfxTime time, bool&);
OfxStatus set(bool); OfxStatus set(bool);
@@ -80,10 +117,10 @@ public:
class ChoiceInstance : public OFX::Host::Param::ChoiceInstance { class ChoiceInstance : public OFX::Host::Param::ChoiceInstance {
protected: protected:
OlivePluginInstance* _effect; PluginNode* node;
OFX::Host::Param::Descriptor& _descriptor; OFX::Host::Param::Descriptor& _descriptor;
public: public:
ChoiceInstance(OlivePluginInstance* effect, const std::string& name, OFX::Host::Param::Descriptor& descriptor); ChoiceInstance(PluginNode* effect, const std::string& name, OFX::Host::Param::Descriptor& descriptor);
OfxStatus get(int&); OfxStatus get(int&);
OfxStatus get(OfxTime time, int&); OfxStatus get(OfxTime time, int&);
OfxStatus set(int); OfxStatus set(int);
@@ -92,10 +129,10 @@ public:
class RGBAInstance : public OFX::Host::Param::RGBAInstance { class RGBAInstance : public OFX::Host::Param::RGBAInstance {
protected: protected:
OlivePluginInstance* _effect; PluginNode* node;
OFX::Host::Param::Descriptor& _descriptor; OFX::Host::Param::Descriptor& _descriptor;
public: public:
RGBAInstance(OlivePluginInstance* effect, const std::string& name, OFX::Host::Param::Descriptor& descriptor); RGBAInstance(PluginNode* effect, const std::string& name, OFX::Host::Param::Descriptor& descriptor);
OfxStatus get(double&,double&,double&,double&); OfxStatus get(double&,double&,double&,double&);
OfxStatus get(OfxTime time, double&,double&,double&,double&); OfxStatus get(OfxTime time, double&,double&,double&,double&);
OfxStatus set(double,double,double,double); OfxStatus set(double,double,double,double);
@@ -105,10 +142,10 @@ public:
class RGBInstance : public OFX::Host::Param::RGBInstance { class RGBInstance : public OFX::Host::Param::RGBInstance {
protected: protected:
OlivePluginInstance* _effect; PluginNode* node;
OFX::Host::Param::Descriptor& _descriptor; OFX::Host::Param::Descriptor& _descriptor;
public: public:
RGBInstance(OlivePluginInstance* effect, const std::string& name, OFX::Host::Param::Descriptor& descriptor); RGBInstance(PluginNode* effect, const std::string& name, OFX::Host::Param::Descriptor& descriptor);
OfxStatus get(double&,double&,double&); OfxStatus get(double&,double&,double&);
OfxStatus get(OfxTime time, double&,double&,double&); OfxStatus get(OfxTime time, double&,double&,double&);
OfxStatus set(double,double,double); OfxStatus set(double,double,double);
@@ -117,10 +154,10 @@ public:
class Double2DInstance : public OFX::Host::Param::Double2DInstance { class Double2DInstance : public OFX::Host::Param::Double2DInstance {
protected: protected:
OlivePluginInstance* _effect; PluginNode* node;
OFX::Host::Param::Descriptor& _descriptor; OFX::Host::Param::Descriptor& _descriptor;
public: public:
Double2DInstance(OlivePluginInstance* effect, const std::string& name, OFX::Host::Param::Descriptor& descriptor); Double2DInstance(PluginNode* effect, const std::string& name, OFX::Host::Param::Descriptor& descriptor);
OfxStatus get(double&,double&); OfxStatus get(double&,double&);
OfxStatus get(OfxTime time,double&,double&); OfxStatus get(OfxTime time,double&,double&);
OfxStatus set(double,double); OfxStatus set(double,double);
@@ -129,10 +166,10 @@ public:
class Integer2DInstance : public OFX::Host::Param::Integer2DInstance { class Integer2DInstance : public OFX::Host::Param::Integer2DInstance {
protected: protected:
OlivePluginInstance* _effect; PluginNode* node;
OFX::Host::Param::Descriptor& _descriptor; OFX::Host::Param::Descriptor& _descriptor;
public: public:
Integer2DInstance(OlivePluginInstance* effect, const std::string& name, OFX::Host::Param::Descriptor& descriptor); Integer2DInstance(PluginNode* effect, const std::string& name, OFX::Host::Param::Descriptor& descriptor);
OfxStatus get(int&,int&); OfxStatus get(int&,int&);
OfxStatus get(OfxTime time,int&,int&); OfxStatus get(OfxTime time,int&,int&);
OfxStatus set(int,int); OfxStatus set(int,int);
@@ -144,6 +181,3 @@ public:
#endif // HOST_DEMO_PARAM_INSTANCE_H #endif // HOST_DEMO_PARAM_INSTANCE_H
#endif //PARAMINSTANCE_H
+3 -4
View File
@@ -23,21 +23,20 @@
#include "pluginSupport/OlivePluginInstance.h" #include "pluginSupport/OlivePluginInstance.h"
#include <any> #include <any>
#include <OpenImageIO/detail/fmt/chrono.h>
namespace olive { namespace olive {
namespace plugin { namespace plugin {
class PluginJob :public AcceleratedJob{ class PluginJob :public AcceleratedJob{
public: public:
explicit PluginJob(std::shared_ptr<OlivePluginInstance> pluginInstance, NodeValueRow row): AcceleratedJob() explicit PluginJob(OFX::Host::ImageEffect::ImageEffectPlugin* pluginInstance, NodeValueRow row): AcceleratedJob()
{ {
this->pluginInstance = pluginInstance; this->pluginInstance = pluginInstance;
} }
private: private:
std::shared_ptr<OlivePluginInstance> pluginInstance; OFX::Host::ImageEffect::ImageEffectPlugin *pluginInstance=nullptr;
QHash<OfxTime, QHash<QString, std::any>> paramsOnTime; QHash<OfxTime, QHash<QString, std::any>> paramsOnTime;
+26 -24
View File
@@ -15,28 +15,30 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
set(OLIVE_SOURCES set(OLIVE_SOURCES
${OLIVE_SOURCES} ${OLIVE_SOURCES}
widget/nodeparamview/nodeparamview.cpp widget/nodeparamview/nodeparamview.cpp
widget/nodeparamview/nodeparamview.h widget/nodeparamview/nodeparamview.h
widget/nodeparamview/nodeparamviewarraywidget.cpp widget/nodeparamview/nodeparamviewarraywidget.cpp
widget/nodeparamview/nodeparamviewarraywidget.h widget/nodeparamview/nodeparamviewarraywidget.h
widget/nodeparamview/nodeparamviewconnectedlabel.cpp widget/nodeparamview/nodeparamviewconnectedlabel.cpp
widget/nodeparamview/nodeparamviewconnectedlabel.h widget/nodeparamview/nodeparamviewconnectedlabel.h
widget/nodeparamview/nodeparamviewcontext.cpp widget/nodeparamview/nodeparamviewcontext.cpp
widget/nodeparamview/nodeparamviewcontext.h widget/nodeparamview/nodeparamviewcontext.h
widget/nodeparamview/nodeparamviewdockarea.cpp widget/nodeparamview/nodeparamviewdockarea.cpp
widget/nodeparamview/nodeparamviewdockarea.h widget/nodeparamview/nodeparamviewdockarea.h
widget/nodeparamview/nodeparamviewitem.cpp widget/nodeparamview/nodeparamviewitem.cpp
widget/nodeparamview/nodeparamviewitem.h widget/nodeparamview/nodeparamviewitem.h
widget/nodeparamview/nodeparamviewitembase.cpp widget/nodeparamview/nodeparamviewitembase.cpp
widget/nodeparamview/nodeparamviewitembase.h widget/nodeparamview/nodeparamviewitembase.h
widget/nodeparamview/nodeparamviewitemtitlebar.cpp widget/nodeparamview/nodeparamviewitemtitlebar.cpp
widget/nodeparamview/nodeparamviewitemtitlebar.h widget/nodeparamview/nodeparamviewitemtitlebar.h
widget/nodeparamview/nodeparamviewkeyframecontrol.cpp widget/nodeparamview/nodeparamviewkeyframecontrol.cpp
widget/nodeparamview/nodeparamviewkeyframecontrol.h widget/nodeparamview/nodeparamviewkeyframecontrol.h
widget/nodeparamview/nodeparamviewtextedit.cpp widget/nodeparamview/nodeparamviewtextedit.cpp
widget/nodeparamview/nodeparamviewtextedit.h widget/nodeparamview/nodeparamviewtextedit.h
widget/nodeparamview/nodeparamviewwidgetbridge.cpp widget/nodeparamview/nodeparamviewwidgetbridge.cpp
widget/nodeparamview/nodeparamviewwidgetbridge.h widget/nodeparamview/nodeparamviewwidgetbridge.h
PARENT_SCOPE widget/nodeparamview/nodeparambutton.h
widget/nodeparamview/nodeparambutton.cpp
PARENT_SCOPE
) )
@@ -0,0 +1,20 @@
/*
* Olive Community Edition - Non-Linear Video Editor
* Copyright (C) 2025 Olive CE 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/>.
*
*/
#include "nodeparambutton.h"
@@ -0,0 +1,47 @@
/*
* Olive Community Edition - Non-Linear Video Editor
* Copyright (C) 2025 Olive CE 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/>.
*
*/
#ifndef NODEPARAMBUTTON_H
#define NODEPARAMBUTTON_H
#include "node/plugins/Plugin.h"
#include <QPushButton>
class NodeParamButton : public QPushButton{
Q_OBJECT
public:
NodeParamButton(QString name, QWidget *parent = nullptr):QPushButton(parent)
{
this->name_=name;
connect(this, &QPushButton::clicked, this, &NodeParamButton::pressed);
}
signals:
void onPressed(QString name);
private slots:
void pressed(){
emit onPressed(name_);
}
private:
QString name_;
};
#endif //NODEPARAMBUTTON_H
@@ -26,6 +26,7 @@
#include "common/qtutils.h" #include "common/qtutils.h"
#include "core.h" #include "core.h"
#include "nodeparambutton.h"
#include "node/group/group.h" #include "node/group/group.h"
#include "node/node.h" #include "node/node.h"
#include "node/nodeundo.h" #include "node/nodeundo.h"
@@ -40,6 +41,8 @@
#include "widget/slider/integerslider.h" #include "widget/slider/integerslider.h"
#include "widget/slider/rationalslider.h" #include "widget/slider/rationalslider.h"
#include <OpenImageIO/detail/fmt/base.h>
namespace olive namespace olive
{ {
@@ -179,6 +182,13 @@ void NodeParamViewWidgetBridge::CreateWidgets()
&NodeParamViewWidgetBridge::WidgetCallback); &NodeParamViewWidgetBridge::WidgetCallback);
break; break;
} }
case NodeValue::kPushButton: {
NodeInput input=GetInnerInput();
NodeParamButton *button=new NodeParamButton(input.name(),parent);
widgets_.append(button);
plugin::PluginNode* plugin_node=dynamic_cast<plugin::PluginNode*>(input.node());
connect(button, &NodeParamButton::onPressed, plugin_node, &plugin::PluginNode::pushButtonClicked);
}
} }
// Check all properties // Check all properties