MCPcopy Create free account
hub / github.com/DISTRHO/Cardinal / resetEverything

Function resetEverything

plugins/Cardinal/src/ImGuiWidget.cpp:76–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76struct ImGuiWidget::PrivateData {
77 ImGuiContext* context = nullptr;
78 bool created = false;
79 bool darkMode = true;
80 bool fontGenerated = false;
81 bool useMonospacedFont = false;
82 float originalScaleFactor = 0.0f;
83 float scaleFactor = 0.0f;
84 double lastFrameTime = 0.0;
85
86 PrivateData()
87 {
88 IMGUI_CHECKVERSION();
89 context = ImGui::CreateContext();
90 ImGui::SetCurrentContext(context);
91 setupIO();
92 }
93
94 ~PrivateData()
95 {
96 // this should not happen
97 if (created)
98 {
99 ImGui::SetCurrentContext(context);
100#if defined(DGL_USE_OPENGL3)
101 ImGui_ImplOpenGL3_Shutdown();
102#else
103 ImGui_ImplOpenGL2_Shutdown();
104#endif
105 }
106
107 ImGui::DestroyContext(context);
108 }
109
110 void generateFontIfNeeded()
111 {
112 if (fontGenerated)
113 return;
114
115 DISTRHO_SAFE_ASSERT_RETURN(scaleFactor != 0.0f,);
116
117 fontGenerated = true;
118
119 ImGuiIO& io(ImGui::GetIO());
120
121 if (useMonospacedFont)
122 {
123 const std::string fontPath = asset::system("res/fonts/ShareTechMono-Regular.ttf");
124 ImFontConfig fc;
125 fc.OversampleH = 1;
126 fc.OversampleV = 1;
127 fc.PixelSnapH = true;
128 io.Fonts->AddFontFromFileTTF(fontPath.c_str(), 13.0f * scaleFactor, &fc);
129 io.Fonts->Build();
130 }
131 else
132 {
133#ifndef DGL_NO_SHARED_RESOURCES

Callers

nothing calls this directly

Calls 5

setupIOFunction · 0.85
ImGui_ImplOpenGL3_InitFunction · 0.85
ImGui_ImplOpenGL2_InitFunction · 0.85

Tested by

no test coverage detected