MCPcopy Create free account
hub / github.com/chrxh/alien / processEditor

Method processEditor

source/Gui/GenomeEditorWindow.cpp:236–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

234}
235
236void GenomeEditorWindow::processEditor()
237{
238 if (ImGui::BeginTabBar("##", ImGuiTabBarFlags_AutoSelectNewTabs | ImGuiTabBarFlags_FittingPolicyResizeDown)) {
239
240 if (ImGui::TabItemButton("+", ImGuiTabItemFlags_Trailing | ImGuiTabItemFlags_NoTooltip)) {
241 scheduleAddTab(GenomeDescription());
242 }
243 AlienImGui::Tooltip("New genome");
244
245 std::optional<int> tabIndexToSelect = _tabIndexToSelect;
246 std::optional<int> tabToDelete;
247 _tabIndexToSelect.reset();
248
249 //process tabs
250 for (auto const& [index, tabData] : _tabDatas | boost::adaptors::indexed(0)) {
251
252 ImGui::PushID(tabData.id);
253 bool open = true;
254 bool* openPtr = nullptr;
255 if (_tabDatas.size() > 1) {
256 openPtr = &open;
257 }
258 int flags = (tabIndexToSelect && *tabIndexToSelect == index) ? ImGuiTabItemFlags_SetSelected : ImGuiTabItemFlags_None;
259 if (ImGui::BeginTabItem(("Genome " + std::to_string(index + 1)).c_str(), openPtr, flags)) {
260 _selectedTabIndex = toInt(index);
261 processTab(tabData);
262 ImGui::EndTabItem();
263 }
264 if (openPtr && *openPtr == false) {
265 tabToDelete = toInt(index);
266 }
267 ImGui::PopID();
268 }
269
270 //delete tab
271 if (tabToDelete.has_value()) {
272 _tabDatas.erase(_tabDatas.begin() + *tabToDelete);
273 if (_selectedTabIndex == _tabDatas.size()) {
274 _selectedTabIndex = toInt(_tabDatas.size() - 1);
275 }
276 }
277
278 //add tab
279 if (_tabToAdd.has_value()) {
280 _tabDatas.emplace_back(*_tabToAdd);
281 _tabToAdd.reset();
282 }
283
284 ImGui::EndTabBar();
285 }
286}
287
288void GenomeEditorWindow::processTab(TabData& tab)
289{

Callers

nothing calls this directly

Calls 6

GenomeDescriptionClass · 0.85
to_stringFunction · 0.85
toIntFunction · 0.85
resetMethod · 0.80
sizeMethod · 0.80
beginMethod · 0.80

Tested by

no test coverage detected