PivotGUI visuals + .lua update
All checks were successful
Linux arm64 / Build (push) Successful in 41m17s

This commit is contained in:
2024-04-11 00:20:51 +02:00
parent f595582948
commit 99c0e2010b
2 changed files with 69 additions and 58 deletions

View File

@@ -5,73 +5,84 @@
void PivotGui::Init() {} void PivotGui::Init() {}
void PivotGui::Render() { void PivotGui::Render() {
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
// Our state // divisions des fenetres
static bool show_demo_window = true; ImVec2 topLeftWindowSize(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.8f);
static bool show_another_window = false; ImVec2 topRightWindowSize(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.8f);
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about ImVec2 bottomWindowSize(io.DisplaySize.x, io.DisplaySize.y * 0.2f);
// Dear ImGui!).
if (show_demo_window)
ImGui::ShowDemoWindow(&show_demo_window);
// 2. Show a simple window that we create ourselves. We use a Begin/End pair to create a named window // Begin fenetre top left
static float f = 0.0f; ImGui::SetNextWindowSize(topLeftWindowSize);
static int counter = 0; 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);
ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. // Get window position
ImVec2 windowPos = ImGui::GetWindowPos();
ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) ImGui::Text("Matrice initiale:");
ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
ImGui::End();
// 3. Interface of Pivot // taille matrice
ImVec4 bg_color = {0.18, 0.8, 1, 0.8}; static int matrixSizeX = 4;
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar; static int matrixSizeY = 4;
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::Text("Matrice :"); ImGui::InputInt("##RowsMatriceInitiale", &matrixSizeY);
ImGui::SameLine();
ImGui::Text("Lignes");
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... // Draw matrix
const float time = (float)ImGui::GetTime(); ImGui::BeginChild("MatriceInitiale", ImVec2(topLeftWindowSize.x, io.DisplaySize.y * 0.7f), false);
for (int y = 0; y < 4; y++) for (int y = 0; y < matrixSizeY; y++) {
for (int x = 0; x < 4; x++) { for (int x = 0; x < matrixSizeX; x++) {
if (x > 0) if (x > 0)
ImGui::SameLine(); ImGui::SameLine();
ImGui::PushID(y * 4 + x); ImGui::PushID(y * matrixSizeX + x);
if (ImGui::Selectable("?", selected[y][x] != 0, 0, ImVec2(50, 50))) { ImGui::Selectable("?", false, 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::PopID();
} }
ImGui::PopStyleColor(); }
ImGui::End();
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() {}

View File

@@ -1,6 +1,6 @@
add_rules("mode.debug", "mode.release") 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}}) add_requires("imgui", {configs = {sdl2_no_renderer = true, opengl3 = true}})
set_languages("c++17") set_languages("c++17")