allow LuaJIT/InlineNode to have custom I/O
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
|
||||
namespace nf7::gui {
|
||||
|
||||
static inline void NodeSocket() noexcept {
|
||||
inline void NodeSocket() noexcept {
|
||||
auto win = ImGui::GetCurrentWindow();
|
||||
|
||||
const auto em = ImGui::GetFontSize();
|
||||
@@ -28,4 +28,39 @@ static inline void NodeSocket() noexcept {
|
||||
ImGui::Dummy(sz);
|
||||
}
|
||||
|
||||
inline void NodeInputSockets(std::span<const std::string> names) noexcept {
|
||||
ImGui::BeginGroup();
|
||||
for (auto& name : names) {
|
||||
if (ImNodes::BeginInputSlot(name.c_str(), 1)) {
|
||||
ImGui::AlignTextToFramePadding();
|
||||
nf7::gui::NodeSocket();
|
||||
ImGui::SameLine();
|
||||
ImGui::TextUnformatted(name.c_str());
|
||||
ImNodes::EndSlot();
|
||||
}
|
||||
}
|
||||
ImGui::EndGroup();
|
||||
}
|
||||
|
||||
inline void NodeOutputSockets(std::span<const std::string> names) noexcept {
|
||||
float maxw = 0;
|
||||
for (auto& name : names) {
|
||||
maxw = std::max(maxw, ImGui::CalcTextSize(name.c_str()).x);
|
||||
}
|
||||
|
||||
ImGui::BeginGroup();
|
||||
for (auto& name : names) {
|
||||
const auto w = ImGui::CalcTextSize(name.c_str()).x;
|
||||
ImGui::SetCursorPosX(ImGui::GetCursorPosX()+maxw-w);
|
||||
if (ImNodes::BeginOutputSlot(name.c_str(), 1)) {
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::TextUnformatted(name.c_str());
|
||||
ImGui::SameLine();
|
||||
nf7::gui::NodeSocket();
|
||||
ImNodes::EndSlot();
|
||||
}
|
||||
}
|
||||
ImGui::EndGroup();
|
||||
}
|
||||
|
||||
} // namespacce nf7::gui
|
||||
|
Reference in New Issue
Block a user