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

Method processLocationTable

source/Gui/SimulationParametersMainWindow.cpp:293–360  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

291}
292
293void SimulationParametersMainWindow::processLocationTable()
294{
295 static ImGuiTableFlags flags = ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_RowBg
296 | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_ScrollY | ImGuiTableFlags_ScrollX;
297
298 if (ImGui::BeginTable("Locations", 4, flags, ImVec2(-1, -1), 0)) {
299
300 ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_NoSort | ImGuiTableColumnFlags_WidthFixed, scale(140.0f));
301 ImGui::TableSetupColumn("Type", ImGuiTableColumnFlags_NoSort | ImGuiTableColumnFlags_WidthFixed, scale(140.0f));
302 ImGui::TableSetupColumn("Position", ImGuiTableColumnFlags_DefaultSort | ImGuiTableColumnFlags_WidthFixed, scale(115.0f));
303 ImGui::TableSetupColumn("Strength", ImGuiTableColumnFlags_DefaultSort | ImGuiTableColumnFlags_WidthFixed, scale(100.0f));
304 ImGui::TableSetupScrollFreeze(0, 1);
305 ImGui::TableHeadersRow();
306 ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg0, Const::TableHeaderColor);
307
308 ImGuiListClipper clipper;
309 clipper.Begin(_locations.size());
310 while (clipper.Step()) {
311 for (int row = clipper.DisplayStart; row < clipper.DisplayEnd; row++) {
312 auto const& entry = _locations.at(row);
313
314 ImGui::PushID(row);
315 ImGui::TableNextRow(0, scale(MasterRowHeight));
316
317 // name
318 ImGui::TableNextColumn();
319 auto selected = _selectedLocationIndex == row;
320 if (ImGui::Selectable(
321 "",
322 &selected,
323 ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowItemOverlap,
324 ImVec2(0, scale(MasterRowHeight) - ImGui::GetStyle().FramePadding.y))) {
325 _selectedLocationIndex = row;
326 }
327 ImGui::SameLine();
328 AlienImGui::Text(entry.name);
329
330
331 // type
332 ImGui::TableNextColumn();
333 if (entry.type == LocationType::Base) {
334 AlienImGui::Text("Base parameters");
335 } else if (entry.type == LocationType::ParameterZone) {
336 AlienImGui::Text("Zone");
337 } else if (entry.type == LocationType::RadiationSource) {
338 AlienImGui::Text("Radiation");
339 }
340
341 // position
342 ImGui::TableNextColumn();
343 if (row > 0) {
344 if (AlienImGui::ActionButton(AlienImGui::ActionButtonParameters().buttonText(ICON_FA_SEARCH))) {
345 onCenterLocation(row);
346 }
347 ImGui::SameLine();
348 }
349 AlienImGui::Text(entry.position);
350

Callers

nothing calls this directly

Calls 3

ImVec2Class · 0.85
scaleFunction · 0.85
sizeMethod · 0.80

Tested by

no test coverage detected