| 26 | } |
| 27 | |
| 28 | void Program::render() { |
| 29 | bool p_open = true; |
| 30 | auto &io = ImGui::GetIO(); |
| 31 | ImGuiStyle &style = ImGui::GetStyle(); |
| 32 | |
| 33 | ImGui::SetNextWindowPos(ImVec2(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.5f), 0, ImVec2(0.5f, 0.5f)); |
| 34 | if (ImGui::BeginPopupModal("Program Preferences", &p_open, ImGuiWindowFlags_AlwaysAutoResize)) { |
| 35 | shown = false; |
| 36 | wasOpen = true; |
| 37 | |
| 38 | int t; |
| 39 | |
| 40 | t = config.windowX; |
| 41 | RightAlignedText("Window width", DPI(250)); |
| 42 | ImGui::SameLine(); |
| 43 | if (ImGui::InputInt("##windowX", &t)) { |
| 44 | if (t > 400) config.windowX = t; |
| 45 | } |
| 46 | |
| 47 | t = config.windowY; |
| 48 | RightAlignedText("Window height", DPI(250)); |
| 49 | ImGui::SameLine(); |
| 50 | if (ImGui::InputInt("##windowY", &t)) { |
| 51 | if (t > 320) config.windowY = t; |
| 52 | } |
| 53 | |
| 54 | std::vector<char> newFont(config.fontName.c_str(), config.fontName.c_str() + config.fontName.size() + 1); // Copy string data + '\0' char |
| 55 | if (newFont.size() < 256) // reserve space for new font name |
| 56 | newFont.resize(256, '\0'); // Max font name length is 255 characters |
| 57 | RightAlignedText("Font name", DPI(250)); |
| 58 | ImGui::SameLine(); |
| 59 | if (ImGui::InputText("##fontName", newFont.data(), newFont.size())) { |
| 60 | config.fontName = newFont.data(); |
| 61 | boardView.reloadFonts = true; |
| 62 | } |
| 63 | |
| 64 | t = config.fontSize; |
| 65 | RightAlignedText("Font size", DPI(250)); |
| 66 | ImGui::SameLine(); |
| 67 | if (ImGui::InputInt("##fontSize", &t)) { |
| 68 | if (t < 8) { |
| 69 | t = 8; |
| 70 | } else if (t > Fonts::MAX_FONT_SIZE) { // 50 is a value that hopefully should not break with too many fonts and 1024x1024 texture limits |
| 71 | t = Fonts::MAX_FONT_SIZE; |
| 72 | } |
| 73 | config.fontSize = t; |
| 74 | } |
| 75 | |
| 76 | t = config.dpi; |
| 77 | RightAlignedText("Screen DPI", DPI(250)); |
| 78 | ImGui::SameLine(); |
| 79 | if (ImGui::InputInt("##dpi", &t)) { |
| 80 | if ((t > 25) && (t < 600)) { |
| 81 | config.dpi = t; |
| 82 | setDPI(t); |
| 83 | } |
| 84 | } |
| 85 |
nothing calls this directly
no test coverage detected