0

How To Create a Table in ImGui of for example 2*2 matrix .and apply rotation to entire Table From Center to certain rotation angle.

is there any method to perform these operations?

ImGui::BeginTable(tableId.c_str(), globalColumnCount, tableFlags,ImVec2(tableWidth, 0));

// Set column widths before starting the table
for (int col = 0; col < globalColumnCount; col++)
 {
     ImGui::TableSetupColumn(headers[col].c_str(), ImGuiTableColumnFlags_WidthStretch, 0.0f, col / static_cast<float>(globalColumnCount));
 }

//row height setup
for (int row = 0; row < globalRowCount; row++)
 {
    ImGui::TableNextRow();
    float cellRowHeight = row_heights[row] * dpi;
    ImGui::SetCursorPosY(ImGui::GetCursorPosY() + cellRowHeight);
    

    // Check if the row is in the header section
    if (row < globalheadercount) {
        for (int col = 0; col < globalColumnCount; col++) {
            ImGui::TableNextColumn();
            // Set background color to transparent for header cells
              ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, ImGui::GetColorU32(ImVec4(0.0f, 0.0f, 0.0f, 0.0f))); 
            // Do not display any content for header cells
            // ImGui::Text("%s",headers[col].c_str());
           ImGui::Text("");
        }
    }


    // Check if the row is in the footer section 
    else if (row >= globalheadercount + globalBodyCount) {
        for (int col = 0; col < globalColumnCount; col++) {
            ImGui::TableNextColumn();
            // Set background color to black for footer cells
              ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, ImGui::GetColorU32(ImVec4(0.0f, 0.0f, 0.0f, 0.0f)));
            // Do not display any content for footer cells
            ImGui::Text("");
            
        }
    } else {
// Set background color to transparent for other cells
ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0, 0, 0, 0));
// Set text color to black
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0, 0, 0, 1));    

for (int col = 0; col < globalColumnCount; col++) {
    ImGui::TableNextColumn();

    std::string inputID = "###Input_" + elem_id + "_" + std::to_string(row) + "_" + std::to_string(col);
    // Store the original text color
    ImVec4 originalTextColor = ImGui::GetStyleColorVec4(ImGuiCol_Text);

    // Set text color to black
    ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0, 0, 0, 1));

    // Use cellTexts to store and retrieve the content of the input fields
    ImGui::InputText(inputID.c_str(), &cellTexts[tableIndex][row * globalColumnCount + col]);

    // Restore the original text color
    ImGui::PopStyleColor();
}

ImGui::PopStyleColor(2); // Restore the default background and text color

} }

// End the ImGui table 

ImGui::EndTable();

i tried to create table but rotation is not applying to entire table.

  • Hello there! Is there any chance you could share the code you have created so we can understand more of what you have tried? – Finlay Aug 14 '23 at 12:38
  • Please provide enough code so others can better understand or reproduce the problem. – Community Aug 14 '23 at 14:44

0 Answers0