add nf7::Node::Meta and improve nf7::Node interface
This commit is contained in:
parent
173edff4a3
commit
df56eb3462
@ -28,6 +28,24 @@ class Node : public File::Interface {
|
|||||||
};
|
};
|
||||||
using Flags = uint8_t;
|
using Flags = uint8_t;
|
||||||
|
|
||||||
|
struct Meta final {
|
||||||
|
public:
|
||||||
|
Meta() = default;
|
||||||
|
Meta(std::vector<std::string>&& i, std::vector<std::string>&& o) noexcept :
|
||||||
|
inputs(std::move(i)), outputs(std::move(o)) {
|
||||||
|
}
|
||||||
|
Meta(const std::vector<std::string>& i, const std::vector<std::string>& o) noexcept :
|
||||||
|
inputs(i), outputs(o) {
|
||||||
|
}
|
||||||
|
|
||||||
|
Meta(const Meta&) = default;
|
||||||
|
Meta(Meta&&) = default;
|
||||||
|
Meta& operator=(const Meta&) = default;
|
||||||
|
Meta& operator=(Meta&&) = default;
|
||||||
|
|
||||||
|
std::vector<std::string> inputs, outputs;
|
||||||
|
};
|
||||||
|
|
||||||
static void ValidateSockets(std::span<const std::string> v) {
|
static void ValidateSockets(std::span<const std::string> v) {
|
||||||
for (auto itr = v.begin(); itr < v.end(); ++itr) {
|
for (auto itr = v.begin(); itr < v.end(); ++itr) {
|
||||||
if (v.end() != std::find(itr+1, v.end(), *itr)) {
|
if (v.end() != std::find(itr+1, v.end(), *itr)) {
|
||||||
@ -50,13 +68,12 @@ class Node : public File::Interface {
|
|||||||
virtual void UpdateNode(Editor&) noexcept { }
|
virtual void UpdateNode(Editor&) noexcept { }
|
||||||
virtual void UpdateMenu(Editor&) noexcept { }
|
virtual void UpdateMenu(Editor&) noexcept { }
|
||||||
|
|
||||||
// The returned span is alive until next operation to the file.
|
// don't call too often because causes heap allocation
|
||||||
virtual std::span<const std::string> GetInputs() const noexcept = 0;
|
virtual Meta GetMeta() const noexcept = 0;
|
||||||
virtual std::span<const std::string> GetOutputs() const noexcept = 0;
|
|
||||||
|
|
||||||
Flags flags() const noexcept { return flags_; }
|
Flags flags() const noexcept { return flags_; }
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
Flags flags_;
|
Flags flags_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -122,13 +122,12 @@ class Device final : public nf7::FileBase,
|
|||||||
|
|
||||||
std::shared_ptr<nf7::Node::Lambda> CreateLambda(
|
std::shared_ptr<nf7::Node::Lambda> CreateLambda(
|
||||||
const std::shared_ptr<nf7::Node::Lambda>&) noexcept override;
|
const std::shared_ptr<nf7::Node::Lambda>&) noexcept override;
|
||||||
std::span<const std::string> GetInputs() const noexcept override {
|
nf7::Node::Meta GetMeta() const noexcept override {
|
||||||
static const std::vector<std::string> kInputs = {"info", "mix", "peek"};
|
static const std::vector<std::string> kInputs = {};
|
||||||
return kInputs;
|
return {
|
||||||
}
|
{"info", "mix", "peek"},
|
||||||
std::span<const std::string> GetOutputs() const noexcept override {
|
{"result"}
|
||||||
static const std::vector<std::string> kOutputs = {"result"};
|
};
|
||||||
return kOutputs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nf7::Future<std::shared_ptr<Instance>> Build() noexcept;
|
nf7::Future<std::shared_ptr<Instance>> Build() noexcept;
|
||||||
|
@ -106,16 +106,13 @@ class FontFace final : public nf7::FileBase,
|
|||||||
return {std::current_exception()};
|
return {std::current_exception()};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::span<const std::string> GetInputs() const noexcept override {
|
|
||||||
static const std::vector<std::string> kInputs = {"command"};
|
|
||||||
return kInputs;
|
|
||||||
}
|
|
||||||
std::span<const std::string> GetOutputs() const noexcept override {
|
|
||||||
static const std::vector<std::string> kOutputs = {"result"};
|
|
||||||
return kOutputs;
|
|
||||||
}
|
|
||||||
std::shared_ptr<nf7::Node::Lambda> CreateLambda(
|
std::shared_ptr<nf7::Node::Lambda> CreateLambda(
|
||||||
const std::shared_ptr<nf7::Node::Lambda>&) noexcept override;
|
const std::shared_ptr<nf7::Node::Lambda>&) noexcept override;
|
||||||
|
nf7::Node::Meta GetMeta() const noexcept override {
|
||||||
|
return {
|
||||||
|
{"command"}, {"result"},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
void UpdateMenu() noexcept override;
|
void UpdateMenu() noexcept override;
|
||||||
void UpdateTooltip() noexcept override;
|
void UpdateTooltip() noexcept override;
|
||||||
|
@ -140,11 +140,8 @@ class ObjBase : public nf7::FileBase,
|
|||||||
const std::shared_ptr<nf7::Node::Lambda>& parent) noexcept override {
|
const std::shared_ptr<nf7::Node::Lambda>& parent) noexcept override {
|
||||||
return std::make_shared<Lambda>(*this, parent);
|
return std::make_shared<Lambda>(*this, parent);
|
||||||
}
|
}
|
||||||
std::span<const std::string> GetInputs() const noexcept override {
|
nf7::Node::Meta GetMeta() const noexcept override {
|
||||||
return T::kInputs;
|
return {T::kInputs, T::kOutputs};
|
||||||
}
|
|
||||||
std::span<const std::string> GetOutputs() const noexcept override {
|
|
||||||
return T::kOutputs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceFuture Create() noexcept final {
|
ResourceFuture Create() noexcept final {
|
||||||
|
@ -90,11 +90,8 @@ class Node final : public nf7::FileBase,
|
|||||||
std::shared_ptr<nf7::Node::Lambda> CreateLambda(
|
std::shared_ptr<nf7::Node::Lambda> CreateLambda(
|
||||||
const std::shared_ptr<nf7::Node::Lambda>&) noexcept override;
|
const std::shared_ptr<nf7::Node::Lambda>&) noexcept override;
|
||||||
|
|
||||||
std::span<const std::string> GetInputs() const noexcept override {
|
nf7::Node::Meta GetMeta() const noexcept override {
|
||||||
return mem_->inputs;
|
return nf7::Node::Meta {mem_->inputs, mem_->outputs};
|
||||||
}
|
|
||||||
std::span<const std::string> GetOutputs() const noexcept override {
|
|
||||||
return mem_->outputs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nf7::Future<std::shared_ptr<nf7::luajit::Ref>> Build() noexcept;
|
nf7::Future<std::shared_ptr<nf7::luajit::Ref>> Build() noexcept;
|
||||||
|
@ -65,13 +65,8 @@ class Imm final : public nf7::FileBase,
|
|||||||
|
|
||||||
std::shared_ptr<nf7::Node::Lambda> CreateLambda(
|
std::shared_ptr<nf7::Node::Lambda> CreateLambda(
|
||||||
const std::shared_ptr<nf7::Node::Lambda>&) noexcept override;
|
const std::shared_ptr<nf7::Node::Lambda>&) noexcept override;
|
||||||
std::span<const std::string> GetInputs() const noexcept override {
|
nf7::Node::Meta GetMeta() const noexcept override {
|
||||||
static const std::vector<std::string> kInputs = {"in"};
|
return {{"in"}, {"out"}};
|
||||||
return kInputs;
|
|
||||||
}
|
|
||||||
std::span<const std::string> GetOutputs() const noexcept override {
|
|
||||||
static const std::vector<std::string> kOutputs = {"out"};
|
|
||||||
return kOutputs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateNode(nf7::Node::Editor&) noexcept override;
|
void UpdateNode(nf7::Node::Editor&) noexcept override;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <cstdlib>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <span>
|
#include <span>
|
||||||
@ -163,12 +164,8 @@ class Network final : public nf7::FileBase,
|
|||||||
|
|
||||||
std::shared_ptr<nf7::Node::Lambda> CreateLambda(
|
std::shared_ptr<nf7::Node::Lambda> CreateLambda(
|
||||||
const std::shared_ptr<nf7::Node::Lambda>&) noexcept override;
|
const std::shared_ptr<nf7::Node::Lambda>&) noexcept override;
|
||||||
|
nf7::Node::Meta GetMeta() const noexcept override {
|
||||||
std::span<const std::string> GetInputs() const noexcept override {
|
return {mem_->inputs, mem_->outputs};
|
||||||
return mem_->inputs;
|
|
||||||
}
|
|
||||||
std::span<const std::string> GetOutputs() const noexcept override {
|
|
||||||
return mem_->outputs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
File::Interface* interface(const std::type_info& t) noexcept override {
|
File::Interface* interface(const std::type_info& t) noexcept override {
|
||||||
@ -327,6 +324,7 @@ class Network::Item final {
|
|||||||
nf7::Env& env() const noexcept { return file_->env(); }
|
nf7::Env& env() const noexcept { return file_->env(); }
|
||||||
nf7::File& file() const noexcept { return *file_; }
|
nf7::File& file() const noexcept { return *file_; }
|
||||||
nf7::Node& node() const noexcept { return *node_; }
|
nf7::Node& node() const noexcept { return *node_; }
|
||||||
|
const nf7::Node::Meta& meta() const noexcept { return meta_; }
|
||||||
|
|
||||||
InternalNode* inode() const noexcept { return inode_; }
|
InternalNode* inode() const noexcept { return inode_; }
|
||||||
InternalNode::Flags iflags() const noexcept { return inode_? inode_->flags(): 0; }
|
InternalNode::Flags iflags() const noexcept { return inode_? inode_->flags(): 0; }
|
||||||
@ -335,8 +333,9 @@ class Network::Item final {
|
|||||||
ItemId id_;
|
ItemId id_;
|
||||||
|
|
||||||
std::unique_ptr<nf7::File> file_;
|
std::unique_ptr<nf7::File> file_;
|
||||||
nf7::Node* node_;
|
nf7::Node* node_;
|
||||||
InternalNode* inode_;
|
InternalNode* inode_;
|
||||||
|
nf7::Node::Meta meta_;
|
||||||
|
|
||||||
std::optional<nf7::MementoRecorder> mem_;
|
std::optional<nf7::MementoRecorder> mem_;
|
||||||
|
|
||||||
@ -365,7 +364,9 @@ class Network::Item final {
|
|||||||
node_ = &file_->interfaceOrThrow<nf7::Node>();
|
node_ = &file_->interfaceOrThrow<nf7::Node>();
|
||||||
mem_.emplace(file_->interface<nf7::Memento>());
|
mem_.emplace(file_->interface<nf7::Memento>());
|
||||||
|
|
||||||
inode_ = file_->interface<Network::InternalNode>();
|
inode_ = file_->interface<Network::InternalNode>();
|
||||||
|
meta_ = node_->GetMeta();
|
||||||
|
|
||||||
prev_pos_ = pos_;
|
prev_pos_ = pos_;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -717,12 +718,8 @@ class Network::Initiator final : public nf7::File,
|
|||||||
};
|
};
|
||||||
return std::make_shared<Emitter>(*this, parent);
|
return std::make_shared<Emitter>(*this, parent);
|
||||||
}
|
}
|
||||||
std::span<const std::string> GetInputs() const noexcept {
|
nf7::Node::Meta GetMeta() const noexcept {
|
||||||
return {};
|
return {{}, {"out"}};
|
||||||
}
|
|
||||||
std::span<const std::string> GetOutputs() const noexcept {
|
|
||||||
static const std::vector<std::string> kOutputs = {"out"};
|
|
||||||
return kOutputs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateNode(nf7::Node::Editor& ed) noexcept override;
|
void UpdateNode(nf7::Node::Editor& ed) noexcept override;
|
||||||
@ -769,20 +766,14 @@ class Network::Terminal : public nf7::FileBase,
|
|||||||
const std::shared_ptr<nf7::Node::Lambda>& parent) noexcept override {
|
const std::shared_ptr<nf7::Node::Lambda>& parent) noexcept override {
|
||||||
return std::make_shared<Emitter>(*this, parent);
|
return std::make_shared<Emitter>(*this, parent);
|
||||||
}
|
}
|
||||||
|
nf7::Node::Meta GetMeta() const noexcept override {
|
||||||
std::span<const std::string> GetInputs() const noexcept override {
|
switch (data().type) {
|
||||||
if (data().type == kOutput) {
|
case kInput:
|
||||||
static const std::vector<std::string> kInputs = {"in"};
|
return {{}, {"out"}};
|
||||||
return kInputs;
|
case kOutput:
|
||||||
|
return {{"in"}, {}};
|
||||||
}
|
}
|
||||||
return {};
|
std::abort();
|
||||||
}
|
|
||||||
std::span<const std::string> GetOutputs() const noexcept override {
|
|
||||||
if (data().type == kInput) {
|
|
||||||
static const std::vector<std::string> kInputs = {"out"};
|
|
||||||
return kInputs;
|
|
||||||
}
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateNode(nf7::Node::Editor&) noexcept override;
|
void UpdateNode(nf7::Node::Editor&) noexcept override;
|
||||||
@ -867,7 +858,7 @@ void Network::Sanitize() {
|
|||||||
// remove expired links
|
// remove expired links
|
||||||
for (const auto& item : items_) {
|
for (const auto& item : items_) {
|
||||||
auto cmd = links_.CreateCommandToRemoveExpired(
|
auto cmd = links_.CreateCommandToRemoveExpired(
|
||||||
item->id(), item->node().GetInputs(), item->node().GetOutputs());
|
item->id(), item->meta().inputs, item->meta().outputs);
|
||||||
if (cmd) {
|
if (cmd) {
|
||||||
cmd->Apply();
|
cmd->Apply();
|
||||||
}
|
}
|
||||||
@ -937,7 +928,6 @@ void Network::Item::Detach() noexcept {
|
|||||||
}
|
}
|
||||||
void Network::Item::Watcher::Handle(const File::Event& ev) noexcept {
|
void Network::Item::Watcher::Handle(const File::Event& ev) noexcept {
|
||||||
auto& item = *owner_;
|
auto& item = *owner_;
|
||||||
auto& node = item.node();
|
|
||||||
|
|
||||||
switch (ev.type) {
|
switch (ev.type) {
|
||||||
case File::Event::kUpdate:
|
case File::Event::kUpdate:
|
||||||
@ -945,8 +935,10 @@ void Network::Item::Watcher::Handle(const File::Event& ev) noexcept {
|
|||||||
auto& net = *item.owner_;
|
auto& net = *item.owner_;
|
||||||
net.Touch();
|
net.Touch();
|
||||||
|
|
||||||
const auto inputs = node.GetInputs();
|
// update metadata
|
||||||
const auto outputs = node.GetOutputs();
|
item.meta_ = item.node().GetMeta();
|
||||||
|
const auto& inputs = item.meta().inputs;
|
||||||
|
const auto& outputs = item.meta().outputs;
|
||||||
|
|
||||||
// check expired sockets
|
// check expired sockets
|
||||||
if (auto cmd = net.links_.CreateCommandToRemoveExpired(item.id(), inputs, outputs)) {
|
if (auto cmd = net.links_.CreateCommandToRemoveExpired(item.id(), inputs, outputs)) {
|
||||||
@ -1195,9 +1187,9 @@ void Network::Item::UpdateNode(Node::Editor& ed) noexcept {
|
|||||||
node_->UpdateNode(ed);
|
node_->UpdateNode(ed);
|
||||||
} else {
|
} else {
|
||||||
ImGui::TextUnformatted(file_->type().name().c_str());
|
ImGui::TextUnformatted(file_->type().name().c_str());
|
||||||
nf7::gui::NodeInputSockets(node_->GetInputs());
|
nf7::gui::NodeInputSockets(meta_.inputs);
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
nf7::gui::NodeOutputSockets(node_->GetOutputs());
|
nf7::gui::NodeOutputSockets(meta_.outputs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImNodes::EndNode();
|
ImNodes::EndNode();
|
||||||
|
@ -77,11 +77,8 @@ class Ref final : public nf7::FileBase, public nf7::Node {
|
|||||||
|
|
||||||
std::shared_ptr<nf7::Node::Lambda> CreateLambda(
|
std::shared_ptr<nf7::Node::Lambda> CreateLambda(
|
||||||
const std::shared_ptr<nf7::Node::Lambda>&) noexcept override;
|
const std::shared_ptr<nf7::Node::Lambda>&) noexcept override;
|
||||||
std::span<const std::string> GetInputs() const noexcept override {
|
nf7::Node::Meta GetMeta() const noexcept override {
|
||||||
return mem_->inputs;
|
return {mem_->inputs, mem_->outputs};
|
||||||
}
|
|
||||||
std::span<const std::string> GetOutputs() const noexcept override {
|
|
||||||
return mem_->outputs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateNode(nf7::Node::Editor&) noexcept override;
|
void UpdateNode(nf7::Node::Editor&) noexcept override;
|
||||||
@ -116,12 +113,13 @@ class Ref final : public nf7::FileBase, public nf7::Node {
|
|||||||
bool mod = false;
|
bool mod = false;
|
||||||
try {
|
try {
|
||||||
auto& n = target().interfaceOrThrow<nf7::Node>();
|
auto& n = target().interfaceOrThrow<nf7::Node>();
|
||||||
|
const auto meta = n.GetMeta();
|
||||||
|
|
||||||
const auto srci = n.GetInputs();
|
const auto& srci = meta.inputs;
|
||||||
mod |= std::equal(dsti.begin(), dsti.end(), srci.begin(), srci.end());
|
mod |= std::equal(dsti.begin(), dsti.end(), srci.begin(), srci.end());
|
||||||
dsti = std::vector<std::string>{srci.begin(), srci.end()};
|
dsti = std::vector<std::string>{srci.begin(), srci.end()};
|
||||||
|
|
||||||
const auto srco = n.GetOutputs();
|
const auto& srco = meta.outputs;
|
||||||
mod |= std::equal(dsto.begin(), dsto.end(), srco.begin(), srco.end());
|
mod |= std::equal(dsto.begin(), dsto.end(), srco.begin(), srco.end());
|
||||||
dsto = std::vector<std::string>{srco.begin(), srco.end()};
|
dsto = std::vector<std::string>{srco.begin(), srco.end()};
|
||||||
} catch (nf7::Exception& e) {
|
} catch (nf7::Exception& e) {
|
||||||
|
@ -180,7 +180,8 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ssla_->Listen(*file_, ss);
|
ssla_->Listen(*file_, ss);
|
||||||
for (const auto& name : node.GetInputs()) {
|
const auto inputs = node.GetMeta().inputs;
|
||||||
|
for (const auto& name : inputs) {
|
||||||
if (auto v = ss->Receive(name)) {
|
if (auto v = ss->Receive(name)) {
|
||||||
la_->Handle(name, *v, ssla_);
|
la_->Handle(name, *v, ssla_);
|
||||||
}
|
}
|
||||||
|
@ -90,13 +90,8 @@ class TL final : public nf7::FileBase, public nf7::DirItem, public nf7::Node {
|
|||||||
|
|
||||||
std::shared_ptr<nf7::Node::Lambda> CreateLambda(
|
std::shared_ptr<nf7::Node::Lambda> CreateLambda(
|
||||||
const std::shared_ptr<nf7::Node::Lambda>&) noexcept override;
|
const std::shared_ptr<nf7::Node::Lambda>&) noexcept override;
|
||||||
std::span<const std::string> GetInputs() const noexcept override {
|
nf7::Node::Meta GetMeta() const noexcept override {
|
||||||
static const std::vector<std::string> kInputs = {"exec"};
|
return {{"exec"}, {"result"}};
|
||||||
return kInputs;
|
|
||||||
}
|
|
||||||
std::span<const std::string> GetOutputs() const noexcept override {
|
|
||||||
static const std::vector<std::string> kOutputs = {"result"};
|
|
||||||
return kOutputs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostHandle(const nf7::File::Event& ev) noexcept;
|
void PostHandle(const nf7::File::Event& ev) noexcept;
|
||||||
|
@ -51,12 +51,8 @@ class Call final : public nf7::File, public nf7::Node {
|
|||||||
|
|
||||||
std::shared_ptr<nf7::Node::Lambda> CreateLambda(
|
std::shared_ptr<nf7::Node::Lambda> CreateLambda(
|
||||||
const std::shared_ptr<nf7::Node::Lambda>&) noexcept override;
|
const std::shared_ptr<nf7::Node::Lambda>&) noexcept override;
|
||||||
std::span<const std::string> GetInputs() const noexcept override {
|
nf7::Node::Meta GetMeta() const noexcept override {
|
||||||
static const std::vector<std::string> kInputs = {"save", "exit", "abort", "panic"};
|
return {{"save", "exit", "abort", "panic"}, {}};
|
||||||
return kInputs;
|
|
||||||
}
|
|
||||||
std::span<const std::string> GetOutputs() const noexcept override {
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateNode(nf7::Node::Editor&) noexcept override;
|
void UpdateNode(nf7::Node::Editor&) noexcept override;
|
||||||
|
@ -92,12 +92,8 @@ class Event final : public nf7::FileBase,
|
|||||||
|
|
||||||
std::shared_ptr<nf7::Node::Lambda> CreateLambda(
|
std::shared_ptr<nf7::Node::Lambda> CreateLambda(
|
||||||
const std::shared_ptr<nf7::Node::Lambda>&) noexcept override;
|
const std::shared_ptr<nf7::Node::Lambda>&) noexcept override;
|
||||||
std::span<const std::string> GetInputs() const noexcept override {
|
nf7::Node::Meta GetMeta() const noexcept override {
|
||||||
static const std::vector<std::string> kInputs = {"value"};
|
return {{"value"}, {}};
|
||||||
return kInputs;
|
|
||||||
}
|
|
||||||
std::span<const std::string> GetOutputs() const noexcept override {
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostUpdate() noexcept override;
|
void PostUpdate() noexcept override;
|
||||||
@ -121,12 +117,6 @@ class Event final : public nf7::FileBase,
|
|||||||
nf7::Node& GetHandler() const {
|
nf7::Node& GetHandler() const {
|
||||||
return ResolveOrThrow(mem_->handler).interfaceOrThrow<nf7::Node>();
|
return ResolveOrThrow(mem_->handler).interfaceOrThrow<nf7::Node>();
|
||||||
}
|
}
|
||||||
std::span<const std::string> GetHandlerInputs() const noexcept
|
|
||||||
try {
|
|
||||||
return GetHandler().GetInputs();
|
|
||||||
} catch (nf7::Exception&) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
std::shared_ptr<nf7::Node::Lambda> CreateLambdaIf() noexcept {
|
std::shared_ptr<nf7::Node::Lambda> CreateLambdaIf() noexcept {
|
||||||
try {
|
try {
|
||||||
if (!la_) {
|
if (!la_) {
|
||||||
@ -180,21 +170,18 @@ std::shared_ptr<nf7::Node::Lambda> Event::CreateLambda(
|
|||||||
|
|
||||||
void Event::PostUpdate() noexcept {
|
void Event::PostUpdate() noexcept {
|
||||||
const auto& io = ImGui::GetIO();
|
const auto& io = ImGui::GetIO();
|
||||||
const auto in = GetHandlerInputs();
|
|
||||||
|
|
||||||
if (in.end() != std::find(in.begin(), in.end(), "key")) {
|
for (size_t i = 0; i < ImGuiKey_KeysData_SIZE; ++i) {
|
||||||
for (size_t i = 0; i < ImGuiKey_KeysData_SIZE; ++i) {
|
const auto& key = io.KeysData[i];
|
||||||
const auto& key = io.KeysData[i];
|
const char* event = nullptr;
|
||||||
const char* event = nullptr;
|
if (key.DownDuration == 0) {
|
||||||
if (key.DownDuration == 0) {
|
event = "down";
|
||||||
event = "down";
|
} else if (key.DownDurationPrev >= 0 && !key.Down) {
|
||||||
} else if (key.DownDurationPrev >= 0 && !key.Down) {
|
event = "up";
|
||||||
event = "up";
|
}
|
||||||
}
|
if (event) {
|
||||||
if (event) {
|
const auto k = static_cast<ImGuiKey>(i);
|
||||||
const auto k = static_cast<ImGuiKey>(i);
|
TriggerKeyEvent(ImGui::GetKeyName(k), event);
|
||||||
TriggerKeyEvent(ImGui::GetKeyName(k), event);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,14 +143,8 @@ class NFile final : public nf7::FileBase,
|
|||||||
|
|
||||||
std::shared_ptr<nf7::Node::Lambda> CreateLambda(
|
std::shared_ptr<nf7::Node::Lambda> CreateLambda(
|
||||||
const std::shared_ptr<nf7::Node::Lambda>&) noexcept override;
|
const std::shared_ptr<nf7::Node::Lambda>&) noexcept override;
|
||||||
|
nf7::Node::Meta GetMeta() const noexcept override {
|
||||||
std::span<const std::string> GetInputs() const noexcept override {
|
return {{"command"}, {"result"}};
|
||||||
static const std::vector<std::string> kInputs = {"command"};
|
|
||||||
return kInputs;
|
|
||||||
}
|
|
||||||
std::span<const std::string> GetOutputs() const noexcept override {
|
|
||||||
static const std::vector<std::string> kOutputs = {"result"};
|
|
||||||
return kOutputs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateTooltip() noexcept override;
|
void UpdateTooltip() noexcept override;
|
||||||
|
@ -97,13 +97,8 @@ class Curve final : public nf7::FileBase,
|
|||||||
std::shared_ptr<nf7::Sequencer::Lambda> CreateLambda(
|
std::shared_ptr<nf7::Sequencer::Lambda> CreateLambda(
|
||||||
const std::shared_ptr<nf7::Context>&) noexcept override;
|
const std::shared_ptr<nf7::Context>&) noexcept override;
|
||||||
|
|
||||||
std::span<const std::string> GetInputs() const noexcept override {
|
nf7::Node::Meta GetMeta() const noexcept override {
|
||||||
static const std::vector<std::string> kInputs = {"x"};
|
return {{"x"}, {"y"}};
|
||||||
return kInputs;
|
|
||||||
}
|
|
||||||
std::span<const std::string> GetOutputs() const noexcept override {
|
|
||||||
static const std::vector<std::string> kOutputs = {"y"};
|
|
||||||
return kOutputs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateItem(nf7::Sequencer::Editor&) noexcept override;
|
void UpdateItem(nf7::Sequencer::Editor&) noexcept override;
|
||||||
|
@ -134,12 +134,8 @@ class Plot final : public nf7::FileBase,
|
|||||||
|
|
||||||
std::shared_ptr<nf7::Node::Lambda> CreateLambda(
|
std::shared_ptr<nf7::Node::Lambda> CreateLambda(
|
||||||
const std::shared_ptr<nf7::Node::Lambda>&) noexcept override;
|
const std::shared_ptr<nf7::Node::Lambda>&) noexcept override;
|
||||||
|
nf7::Node::Meta GetMeta() const noexcept override {
|
||||||
std::span<const std::string> GetInputs() const noexcept override {
|
return {inputs_, {}};
|
||||||
return inputs_;
|
|
||||||
}
|
|
||||||
std::span<const std::string> GetOutputs() const noexcept override {
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateMenu() noexcept override;
|
void UpdateMenu() noexcept override;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user