43 int nExtraColumns =
static_cast<int>(extraColumns.size());
44 if (ImGui::BeginTable(fmt::format(
"Pin Settings##{}",
id).c_str(),
46 ImGuiTableFlags_Borders | ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_NoHostExtendX, ImVec2(0.0F, 0.0F)))
48 ImGui::TableSetupColumn(
"Pin");
49 for (
const auto& column : extraColumns)
51 ImGui::TableSetupColumn(column.header.c_str());
55 ImGui::TableSetupColumn(
"");
57 ImGui::TableHeadersRow();
60 bool dragAndDropPinStillInProgress =
false;
62 auto showDragDropTargetPin = [&](
size_t pinIdxTarget) {
63 ImGui::Dummy(ImVec2(-1.F, 2.F));
65 bool selectableDummy =
true;
66 ImGui::PushStyleVar(ImGuiStyleVar_SelectableTextAlign, ImVec2(0.5F, 0.5F));
67 ImGui::PushStyleColor(ImGuiCol_Header, IM_COL32(16, 173, 44, 79));
68 ImGui::Selectable(fmt::format(
"[drop here]").c_str(), &selectableDummy, ImGuiSelectableFlags_None,
69 ImVec2(std::max(ImGui::GetColumnWidth(0), ImGui::CalcTextSize(
"[drop here]").x), 20.F));
70 ImGui::PopStyleColor();
73 if (ImGui::BeginDragDropTarget())
75 if (
const ImGuiPayload* payloadData = ImGui::AcceptDragDropPayload(fmt::format(
"DND Pin {}",
id).c_str()))
77 auto pinIdxSource = *
static_cast<size_t*
>(payloadData->Data);
79 if (pinIdxSource < pinIdxTarget)
84 move(inputPins, pinIdxSource, pinIdxTarget);
87 ImGui::EndDragDropTarget();
89 ImGui::Dummy(ImVec2(-1.F, 2.F));
92 std::optional<size_t> deletePinIdx;
93 for (
size_t pinIndex = 0; pinIndex < inputPins.size(); pinIndex++)
95 ImGui::TableNextRow();
96 ImGui::TableNextColumn();
103 bool selectablePinDummy =
false;
104 ImGui::Selectable(fmt::format(
"{}##{}", inputPins.at(pinIndex).name,
id).c_str(), &selectablePinDummy);
105 if (pinIndex >=
_firstDynamicPinIdx && ImGui::BeginDragDropSource(ImGuiDragDropFlags_None))
107 dragAndDropPinStillInProgress =
true;
110 ImGui::SetDragDropPayload(fmt::format(
"DND Pin {}",
id).c_str(), &pinIndex,
sizeof(pinIndex));
111 ImGui::TextUnformatted(inputPins.at(pinIndex).name.c_str());
112 ImGui::EndDragDropSource();
118 showDragDropTargetPin(pinIndex + 1);
122 ImGui::SetTooltip(
"This item can be dragged to reorder the pins");
125 for (
const auto& column : extraColumns)
127 ImGui::TableNextColumn();
128 changed |= column.content(pinIndex);
133 ImGui::TableNextColumn();
134 if (ImGui::Button(fmt::format(
"x##{} - {}",
id, pinIndex).c_str()))
136 deletePinIdx = pinIndex;
138 if (ImGui::IsItemHovered())
140 ImGui::SetTooltip(
"Delete the pin");
146 LOG_TRACE(
"{}: Deleting pin with index {}",
id, *deletePinIdx);
152 if (!dragAndDropPinStillInProgress)
157 ImGui::TableNextRow();
158 ImGui::TableNextColumn();
159 if (ImGui::Button(fmt::format(
"Add Pin##{}",
id).c_str()))