MCPcopy Create free account
hub / github.com/OpenBoardView/OpenBoardView / render

Method render

src/openboardview/GUI/Preferences/Program.cpp:28–265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26}
27
28void 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

Callers

nothing calls this directly

Calls 9

RightAlignedTextFunction · 0.85
DPIFunction · 0.85
setDPIFunction · 0.85
SetFZKeyMethod · 0.80
SetCAEKeyMethod · 0.80
SetXZZPCBKeyMethod · 0.80
show_file_pickerFunction · 0.50
writeToConfigMethod · 0.45
isPressedMethod · 0.45

Tested by

no test coverage detected