diff --git a/src/gui/PivotGui.cpp b/src/gui/PivotGui.cpp index 2be47f7..d106069 100644 --- a/src/gui/PivotGui.cpp +++ b/src/gui/PivotGui.cpp @@ -5,73 +5,84 @@ void PivotGui::Init() {} void PivotGui::Render() { + ImGuiIO& io = ImGui::GetIO(); - ImGuiIO& io = ImGui::GetIO(); + // divisions des fenetres + ImVec2 topLeftWindowSize(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.8f); + ImVec2 topRightWindowSize(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.8f); + ImVec2 bottomWindowSize(io.DisplaySize.x, io.DisplaySize.y * 0.2f); - // Our state - static bool show_demo_window = true; - static bool show_another_window = false; - // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about - // Dear ImGui!). - if (show_demo_window) - ImGui::ShowDemoWindow(&show_demo_window); + // Begin fenetre top left + ImGui::SetNextWindowSize(topLeftWindowSize); + ImGui::SetNextWindowPos(ImVec2(0, 0)); // Position at the top-left corner + ImGui::Begin("Left Top Window", nullptr, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar); - // 2. Show a simple window that we create ourselves. We use a Begin/End pair to create a named window - static float f = 0.0f; - static int counter = 0; + // Get window position + ImVec2 windowPos = ImGui::GetWindowPos(); - ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. + ImGui::Text("Matrice initiale:"); - ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) - ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state - ImGui::End(); + // taille matrice + static int matrixSizeX = 4; + static int matrixSizeY = 4; - // 3. Interface of Pivot - ImVec4 bg_color = {0.18, 0.8, 1, 0.8}; - ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar; - ImVec2 window_pos = {0, 0}; - ImVec2 window_size = ImGui::GetIO().DisplaySize; - ImVec2 vertical_spacing = {0, 40}; - ImGui::SetNextWindowPos(window_pos); - ImGui::SetNextWindowSize(window_size); - ImGui::PushStyleColor(ImGuiCol_WindowBg, bg_color); - ImGui::Begin("Pivot", nullptr, window_flags); + ImGui::InputInt("##RowsMatriceInitiale", &matrixSizeY); + ImGui::SameLine(); + ImGui::Text("Lignes"); - ImGui::Text("Matrice :"); - - ImGui::Dummy(vertical_spacing); - static char selected[4][4] = {{1, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}; + ImGui::InputInt("##ColumnsMatriceInitiale", &matrixSizeX); + ImGui::SameLine(); + ImGui::Text("Colonnes"); - // Add in a bit of silly fun... - const float time = (float)ImGui::GetTime(); + // Draw matrix + ImGui::BeginChild("MatriceInitiale", ImVec2(topLeftWindowSize.x, io.DisplaySize.y * 0.7f), false); - for (int y = 0; y < 4; y++) - for (int x = 0; x < 4; x++) { - if (x > 0) - ImGui::SameLine(); - ImGui::PushID(y * 4 + x); - if (ImGui::Selectable("?", selected[y][x] != 0, 0, ImVec2(50, 50))) { - // Toggle clicked cell + toggle neighbors - selected[y][x] ^= 1; - if (x > 0) { - selected[y][x - 1] ^= 1; - } - if (x < 3) { - selected[y][x + 1] ^= 1; - } - if (y > 0) { - selected[y - 1][x] ^= 1; - } - if (y < 3) { - selected[y + 1][x] ^= 1; - } - } - ImGui::PopID(); - } - ImGui::PopStyleColor(); - ImGui::End(); + for (int y = 0; y < matrixSizeY; y++) { + for (int x = 0; x < matrixSizeX; x++) { + if (x > 0) + ImGui::SameLine(); + ImGui::PushID(y * matrixSizeX + x); + ImGui::Selectable("?", false, 0, ImVec2(50, 50)); + ImGui::PopID(); + } + } + + ImGui::Text("Matrice finale:"); + + ImGui::EndChild(); // End Matrice initiale + + ImGui::End(); // End fenetre top left + + // Begin fenetre top right + ImGui::SetNextWindowSize(topRightWindowSize); + ImGui::SetNextWindowPos(ImVec2(windowPos.x + topLeftWindowSize.x, 0)); // Position at the top-right corner + ImGui::Begin("Right Top Window", nullptr, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar); + + // rajouter le code pour la partie top right + + ImGui::End(); // End fenetre top right + + // Begin fenetre bas + ImGui::SetNextWindowSize(bottomWindowSize); + ImGui::SetNextWindowPos(ImVec2(0, io.DisplaySize.y * 0.8f)); // Position at the bottom-left corner + ImGui::Begin("Bottom Part", nullptr, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar); + + // rajouter des boutons clickables + if (ImGui::Button("Calcul noyeau")) { + // Code de calcul + } + ImGui::SameLine(); // Align buttons horizontally + if (ImGui::Button("Calcul rang")) { + // Code de calcul + } + ImGui::SameLine(); // Align buttons horizontally + if (ImGui::Button("Calcul inverse")) { + // Code de calcul + } + + ImGui::End(); // End fenetre bas } -void PivotGui::Destroy() {} +void PivotGui::Destroy() {} \ No newline at end of file diff --git a/xmake.lua b/xmake.lua index 75f1954..3123ed7 100644 --- a/xmake.lua +++ b/xmake.lua @@ -1,6 +1,6 @@ add_rules("mode.debug", "mode.release") -add_requires("libsdl >= 2") +add_requires("libsdl 2.28.3", {configs = {sdlmain = false}}) add_requires("imgui", {configs = {sdl2_no_renderer = true, opengl3 = true}}) set_languages("c++17")