//UI Methods void NetworkChat(bool* opened) { ImGui::SetNextWindowSize(ImVec2(550, 275)); ImGui::SetNextWindowContentSize(ImVec2(550, 250)); if (!strcmp(input, "")) sceneManager->EnableInput(); else sceneManager->DisableInput(); if (!ImGui::Begin("Chat Log", opened)) { ImGui::End(); return; } ImGui::BeginChild("Log"); ImGui::TextUnformatted(logger.begin(), logger.end()); ImGui::SetScrollY(ImGui::GetScrollMaxY()); ImGui::EndChild(); ImGui::InputText("", input, 256); ImGui::SameLine(); if (ImGui::Button("Send")) { if (input[0] == '@') { char buffer[256]; if (sscanf(input, "@clear -%s\0", buffer)) { if (strcmp(buffer, "all")) logger.clear(); } if (sscanf(input, "@name -%s\0", buffer)) { ZeroMemory(name, 256); strcat(name, "["); strcat(name, buffer); strcat(name, "]"); logger.append("name Changed to : ");logger.append(name);logger.append("\n"); } } else { char buffer[256]; ZeroMemory(buffer, 256); strcat(buffer, name); strcat(buffer, input); strcat(buffer, "\n"); logger.append(buffer); SendNetworkMessage(buffer); } ZeroMemory(input, 256); } ImGui::End(); }
// Application code int main(int argc, char** argv) { InitGL(); Parameters parameters = { .exposure = 1.0, .zoom = 1.0, .pos = {0.0, 0.0}, .aspect = 1.0, .shadows = 0.0, .highlights = 0.0, .contrast = 0.0}; int w, h; glfwGetWindowSize(window, &w, &h); const Rect screen(w, h); Config config(".quickrelease.cfg", screen); config.load(); //InputImage tesla("stone.jpg"); //Geometry g(tesla, screen); InitImGui(); bool save_now = false; DirTree *dirTree =new DirTree("./"); DirTreeNode *addedDir = 0; bool show_dir_browser = false; const ImGuiWindowFlags layout_flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove ; SourceImage *currentImage = 0; while (!glfwWindowShouldClose(window)) { ImGuiIO& io = ImGui::GetIO(); io.MouseWheel = 0; glfwPollEvents(); UpdateImGui(); static bool show_test_window = false; static bool show_debug_window = true; static bool show_controls = true; static float f; if (show_dir_browser) { ImGui::Begin("Add a directory with images..", &show_dir_browser, ImVec2(200,500), 1.0, layout_flags); dirTree->imgui(&addedDir); if (addedDir) { if ((long)(addedDir) == -1) { std::cout << ".." << std::endl; dirTree = new DirTree("../" + dirTree->rootName()); } else { config.addDirectory(addedDir->fullPath()); } addedDir = 0; show_dir_browser = false; } ImGui::End(); } if (show_debug_window) { // Create a simple window // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug" ImGui::Text("Hello, world!"); ImGui::SliderFloat("float", &f, 0.0f, 1.0f); show_test_window ^= ImGui::Button("Test Window"); show_controls ^= ImGui::Button("Another Window"); // Calculate and show framerate static float ms_per_frame[120] = { 0 }; static int ms_per_frame_idx = 0; static float ms_per_frame_accum = 0.0f; ms_per_frame_accum -= ms_per_frame[ms_per_frame_idx]; ms_per_frame[ms_per_frame_idx] = ImGui::GetIO().DeltaTime * 1000.0f; ms_per_frame_accum += ms_per_frame[ms_per_frame_idx]; ms_per_frame_idx = (ms_per_frame_idx + 1) % 120; const float ms_per_frame_avg = ms_per_frame_accum / 120; { ImGui::BeginChild("Log"); ImGui::TextUnformatted(dlog.begin(), dlog.end()); ImGui::EndChild(); } ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", ms_per_frame_avg, 1000.0f / ms_per_frame_avg); } // Show the ImGui test window // Most of user example code is in ImGui::ShowTestWindow() if (show_test_window) { ImGui::SetNewWindowDefaultPos(ImVec2(650, 20)); // Normally user code doesn't need/want to call it because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly! ImGui::ShowTestWindow(&show_test_window); } // Show another simple window if (show_controls) { ImGui::SetNewWindowDefaultPos(ImVec2(400,0)); ImGui::Begin("Imports", &show_controls, ImVec2(200,500), 1.0, layout_flags); for (auto &dir : config.sourceDirs) { if (ImGui::Button(dir.path.c_str())) { debug(dir.path.c_str()); config.activate(dir); currentImage = dir.currentImage(); parameters.aspect = screen.ratio() / currentImage->imageData->ratio(); //(1.0 / image.ratio()) *0.5; } } ImGui::End(); ImGui::SetNewWindowDefaultPos(ImVec2(0,0)); ImGui::Begin("Adjustments", &show_controls, ImVec2(200,500), 1.0, layout_flags); show_debug_window ^= ImGui::Button("Debug"); show_dir_browser ^= ImGui::Button("Add Directory"); ImGui::Text("Exposure"); ImGui::SliderFloat("f0", ¶meters.exposure, 0.0f,2.0f); ImGui::Text("Shadows"); ImGui::SliderFloat("f1", ¶meters.shadows, 0.0f,1.0f); ImGui::Text("Highlights"); ImGui::SliderFloat("f2", ¶meters.highlights, 0.0f,1.0f); ImGui::Text("Contrast"); ImGui::SliderFloat("f3", ¶meters.contrast, 0.0f,1.0f); ImGui::Text("Zoom"); ImGui::SliderFloat("43", ¶meters.zoom, 0.1f,2.0f); if (config.current) { config.current->imgui(layout_flags, ¤tImage); } ImGui::End(); } // Rendering glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y); glClearColor(0.2f, 0.2f, 0.2f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); if (currentImage) { currentImage->geometry()->draw(¶meters); } ImGui::Render(); glfwSwapBuffers(window); } ImGui::Shutdown(); glfwTerminate(); config.save(); return 0; }