diff --git a/src/gui/PivotGui.cpp b/src/gui/PivotGui.cpp index 252410a..2be47f7 100644 --- a/src/gui/PivotGui.cpp +++ b/src/gui/PivotGui.cpp @@ -16,37 +16,62 @@ void PivotGui::Render() { 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. - { - static float f = 0.0f; - static int counter = 0; + // 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; - ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. + ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. - 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::Checkbox("Another Window", &show_another_window); + 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(); - ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f + // 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}; - if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated) - counter++; - ImGui::SameLine(); - ImGui::Text("counter = %d", counter); + ImGui::SetNextWindowPos(window_pos); + ImGui::SetNextWindowSize(window_size); + ImGui::PushStyleColor(ImGuiCol_WindowBg, bg_color); + ImGui::Begin("Pivot", nullptr, window_flags); - ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate); - ImGui::End(); - } + ImGui::Text("Matrice :"); + + ImGui::Dummy(vertical_spacing); - // 3. Show another simple window. - if (show_another_window) { - ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing - // button that will clear the bool when clicked) - ImGui::Text("Hello from another window!"); - if (ImGui::Button("Close Me")) - show_another_window = false; - ImGui::End(); - } + static char selected[4][4] = {{1, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}; + + // Add in a bit of silly fun... + const float time = (float)ImGui::GetTime(); + + 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(); } void PivotGui::Destroy() {}