[studio,turbine] Add pre-draw font loading
Build / build (push) Successful in 1m18s

This commit is contained in:
2026-05-27 20:39:05 -05:00
parent eb3364ce8e
commit afb1bd23a3
5 changed files with 18 additions and 4 deletions
+4
View File
@@ -74,6 +74,10 @@ class StudioUIDrawer: public turbine::gl::Drawer {
explicit StudioUIDrawer(StudioUI &ui) noexcept: m_ui(ui) {
}
void preDraw(turbine::Context &) noexcept final {
m_ui.preDraw();
}
void draw(turbine::Context&) noexcept final {
m_ui.draw();
}
+4 -2
View File
@@ -121,7 +121,6 @@ using StudioConfig = StudioConfigV2;
StudioUI::StudioUI(turbine::Context &tctx, ox::StringParam projectDataDir) noexcept:
m_sctx{*this, tctx},
m_projectDataDir{std::move(projectDataDir)} {
loadFont();
auto &kctx = keelCtx(m_tctx);
kctx.converters.emplace_back(keel::Converter::make<convertStudioConfigV1ToStudioConfigV2>());
oxLogError(headerizeConfigFile<StudioConfigV1>(kctx));
@@ -184,11 +183,14 @@ void StudioUI::handleNavigationChange(ox::StringParam path, ox::StringParam navA
m_navAction.emplace(std::move(path), std::move(navArgs));
}
void StudioUI::preDraw() noexcept {
loadFont();
}
void StudioUI::draw() noexcept {
if (turbine::isWayland() || ox::defines::OS == ox::OS::Darwin) {
ig::setDpiScale(1.f);
} else {
loadFont();
ig::setDpiScale(ImGui::GetWindowDpiScale());
}
glutils::clearScreen();
@@ -103,6 +103,8 @@ class StudioUI final: public ox::SignalHandler {
bool handleShutdown() noexcept;
protected:
void preDraw() noexcept;
void draw() noexcept;
private:
@@ -18,6 +18,7 @@ namespace gl {
class Drawer {
public:
virtual ~Drawer() = default;
virtual void preDraw(Context&) noexcept {}
virtual void draw(Context&) noexcept = 0;
};
void addDrawer(Context &ctx, Drawer *cd) noexcept;
+7 -2
View File
@@ -235,12 +235,15 @@ void requireRefreshFor(Context &ctx, int ms) noexcept {
static void draw(Context &ctx) noexcept {
// draw start
for (auto const d : ctx.drawers) {
d->preDraw(ctx);
}
#if TURBINE_USE_IMGUI
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
#endif
for (auto d : ctx.drawers) {
for (auto const d : ctx.drawers) {
d->draw(ctx);
}
#if TURBINE_USE_IMGUI
@@ -489,7 +492,9 @@ KeyEventHandler keyEventHandler(Context const &ctx) noexcept {
}
float scale(Context const &ctx) noexcept {
return ctx.scale;
float x{}, y{};
glfwGetWindowContentScale(ctx.window, &x, &y);
return y;
}
bool isWayland() noexcept {