Skip to content

Commit

Permalink
Don't display key distance column
Browse files Browse the repository at this point in the history
  • Loading branch information
samsta committed Jun 13, 2022
1 parent d461cb1 commit 49ab2d2
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions src/LiveMusicBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,37 @@ void drawPlayingTracks(const json11::Json& data)
ImGui::Text("Now Playing:");
ImGuiTableFlags flags = ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingFixedFit;

if (not data["playing"].is_null() and ImGui::BeginTable("playing", data["cols"].array_items().size() + 1, flags))
if (not data["playing"].is_null() and ImGui::BeginTable("playing", data["cols"].array_items().size(), flags))
{
ImGui::TableSetupColumn("Deck");
int key_distance_col_ix = -1;
int col_ix = 1;
for (const auto& col_name: data["cols"].array_items())
{
if (col_name.string_value() == "KeyDistance")
{
key_distance_col_ix = col_ix++;
continue;
}
ImGui::TableSetupColumn(col_name.string_value().c_str());
col_ix++;
}
ImGui::TableHeadersRow();

int display_column_offset = 0;
for (const auto& track: data["playing"].object_items())
{
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
ImGui::TextUnformatted(track.first.c_str());
for (int column = 1; column <= track.second.array_items().size(); column++)
{
ImGui::TableSetColumnIndex(column);
if (column == key_distance_col_ix) {
// skip the column with the key distance
display_column_offset++;
continue;
}
ImGui::TableSetColumnIndex(column - display_column_offset);
if (track.second[column-1].is_number()) {
ImGui::Text("%3.5g", track.second[column-1].number_value());
} else {
Expand All @@ -72,17 +86,18 @@ void drawBrowserList(const json11::Json& data)
ImGui::Text("Browse Files:");
ImGuiTableFlags flags = ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingFixedFit;

int key_distance_col_ix = -1;
if (not data["rows"].is_null() and ImGui::BeginTable("tracks", data["cols"].array_items().size(), flags))
if (not data["rows"].is_null() and ImGui::BeginTable("tracks", data["cols"].array_items().size() - 1, flags))
{
int key_distance_col_ix = -1;
int col_ix = 0;
for (const auto& col_name: data["cols"].array_items())
{
ImGui::TableSetupColumn(col_name.string_value().c_str());
if (col_name.string_value() == "KeyDistance")
{
key_distance_col_ix = col_ix;
key_distance_col_ix = col_ix++;
continue;
}
ImGui::TableSetupColumn(col_name.string_value().c_str());
col_ix++;
}
ImGui::TableHeadersRow();
Expand Down Expand Up @@ -115,10 +130,15 @@ void drawBrowserList(const json11::Json& data)
}
}


int display_column_offset = 0;
for (int column = 0; column < row.array_items().size(); column++)
{
ImGui::TableSetColumnIndex(column);
if (column == key_distance_col_ix) {
// skip the column with the key distance
display_column_offset++;
continue;
}
ImGui::TableSetColumnIndex(column - display_column_offset);
if (column == 0)
{
ImGui::Selectable(row[column].string_value().c_str(), row_ix == data["sel_ix"].int_value(), ImGuiSelectableFlags_SpanAllColumns);
Expand Down

0 comments on commit 49ab2d2

Please sign in to comment.