added window for Pivot interface with a grid
All checks were successful
Linux arm64 / Build (push) Successful in 45m6s

This commit is contained in:
Morph01
2024-03-06 18:35:07 +01:00
parent b9a3fb4ca4
commit f595582948

View File

@@ -16,37 +16,62 @@ void PivotGui::Render() {
if (show_demo_window) if (show_demo_window)
ImGui::ShowDemoWindow(&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. // 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 float f = 0.0f; static int counter = 0;
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::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("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
ImGui::Checkbox("Another Window", &show_another_window); 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) ImGui::SetNextWindowPos(window_pos);
counter++; ImGui::SetNextWindowSize(window_size);
ImGui::SameLine(); ImGui::PushStyleColor(ImGuiCol_WindowBg, bg_color);
ImGui::Text("counter = %d", counter); ImGui::Begin("Pivot", nullptr, window_flags);
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate); ImGui::Text("Matrice :");
ImGui::End();
} ImGui::Dummy(vertical_spacing);
// 3. Show another simple window. static char selected[4][4] = {{1, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}};
if (show_another_window) {
ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing // Add in a bit of silly fun...
// button that will clear the bool when clicked) const float time = (float)ImGui::GetTime();
ImGui::Text("Hello from another window!");
if (ImGui::Button("Close Me")) for (int y = 0; y < 4; y++)
show_another_window = false; for (int x = 0; x < 4; x++) {
ImGui::End(); 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() {} void PivotGui::Destroy() {}