| 1116 | |
| 1117 | template<typename T, int R, int C> |
| 1118 | bool GuiImpl::addMatrixVar(const char label[], math::matrix<T, R, C>& var, float minVal, float maxVal, bool sameLine) |
| 1119 | { |
| 1120 | using MatrixType = math::matrix<T, R, C>; |
| 1121 | std::string labelString(label); |
| 1122 | std::string hiddenLabelString("##"); |
| 1123 | hiddenLabelString += labelString + "[0]"; |
| 1124 | |
| 1125 | ImVec2 topLeft = ImGui::GetCursorScreenPos(); |
| 1126 | ImVec2 bottomRight; |
| 1127 | |
| 1128 | bool b = false; |
| 1129 | |
| 1130 | for (uint32_t i = 0; i < static_cast<uint32_t>(var.getColCount()); ++i) |
| 1131 | { |
| 1132 | std::string& stringToDisplay = hiddenLabelString; |
| 1133 | hiddenLabelString[hiddenLabelString.size() - 2] = '0' + static_cast<int32_t>(i); |
| 1134 | if (i == var.getColCount() - 1) |
| 1135 | { |
| 1136 | stringToDisplay = labelString; |
| 1137 | } |
| 1138 | |
| 1139 | // Just to keep the parity with GLM |
| 1140 | auto col = var.getCol(i); |
| 1141 | b |= addVecVar<typename MatrixType::ColType>(stringToDisplay.c_str(), col, minVal, maxVal, 0.001f, sameLine); |
| 1142 | var.setCol(i, col); |
| 1143 | |
| 1144 | if (i == 0) |
| 1145 | { |
| 1146 | ImGui::SameLine(); |
| 1147 | bottomRight = ImGui::GetCursorScreenPos(); |
| 1148 | float oldSpacing = ImGui::GetStyle().ItemSpacing.y; |
| 1149 | ImGui::GetStyle().ItemSpacing.y = 0.0f; |
| 1150 | ImGui::Dummy({}); |
| 1151 | ImGui::Dummy({}); |
| 1152 | ImGui::GetStyle().ItemSpacing.y = oldSpacing; |
| 1153 | ImVec2 correctedCursorPos = ImGui::GetCursorScreenPos(); |
| 1154 | correctedCursorPos.y += oldSpacing; |
| 1155 | ImGui::SetCursorScreenPos(correctedCursorPos); |
| 1156 | bottomRight.y = ImGui::GetCursorScreenPos().y; |
| 1157 | } |
| 1158 | else if (i == 1) |
| 1159 | { |
| 1160 | bottomRight.y = topLeft.y + (bottomRight.y - topLeft.y) * (var.getColCount()); |
| 1161 | bottomRight.x -= ImGui::GetStyle().ItemInnerSpacing.x * 3 - 1; |
| 1162 | bottomRight.y -= ImGui::GetStyle().ItemInnerSpacing.y - 1; |
| 1163 | topLeft.x -= 1; |
| 1164 | topLeft.y -= 1; |
| 1165 | auto colorVec4 = ImGui::GetStyleColorVec4(ImGuiCol_ScrollbarGrab); |
| 1166 | colorVec4.w *= 0.25f; |
| 1167 | ImU32 color = ImGui::ColorConvertFloat4ToU32(colorVec4); |
| 1168 | ImGui::GetWindowDrawList()->AddRect(topLeft, bottomRight, color); |
| 1169 | } |
| 1170 | } |
| 1171 | return b; |
| 1172 | } |
| 1173 | |
| 1174 | void GuiImpl::addGraph( |
| 1175 | const char label[], |
no test coverage detected