This commit is contained in:
@@ -121,25 +121,7 @@ using StudioConfig = StudioConfigV2;
|
||||
StudioUI::StudioUI(turbine::Context &tctx, ox::StringParam projectDataDir) noexcept:
|
||||
m_sctx{*this, tctx},
|
||||
m_projectDataDir{std::move(projectDataDir)} {
|
||||
{
|
||||
auto const scale = turbine::isWayland() || ox::defines::OS == ox::OS::Darwin ?
|
||||
1.f : turbine::scale(m_tctx);
|
||||
ImFontConfig fontCfg;
|
||||
fontCfg.FontDataOwnedByAtlas = false;
|
||||
auto const &io = ImGui::GetIO();
|
||||
auto const font = files::RobotoMedium_ttf();
|
||||
// const_cast is needed because this data is definitely const,
|
||||
// but AddFontFromMemoryTTF requires a mutable buffer.
|
||||
// However, setting fontCfg.FontDataOwnedByAtlas ensures
|
||||
// that it will still be treated as const.
|
||||
// ImGui documentation recognizes that this is a bad design,
|
||||
// and hopefully it will change at some point.
|
||||
io.Fonts->AddFontFromMemoryTTF(
|
||||
const_cast<uint8_t*>(font.data()),
|
||||
static_cast<int>(font.size()),
|
||||
13 * scale,
|
||||
&fontCfg);
|
||||
}
|
||||
loadFont();
|
||||
auto &kctx = keelCtx(m_tctx);
|
||||
kctx.converters.emplace_back(keel::Converter::make<convertStudioConfigV1ToStudioConfigV2>());
|
||||
oxLogError(headerizeConfigFile<StudioConfigV1>(kctx));
|
||||
@@ -206,6 +188,7 @@ 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();
|
||||
@@ -240,6 +223,29 @@ void StudioUI::draw() noexcept {
|
||||
procFileMoves();
|
||||
}
|
||||
|
||||
void StudioUI::loadFont() noexcept {
|
||||
auto const scale = turbine::isWayland() || ox::defines::OS == ox::OS::Darwin ?
|
||||
1.f : turbine::scale(m_tctx);
|
||||
if (m_fontScale != scale) {
|
||||
m_fontScale = scale;
|
||||
ImFontConfig fontCfg;
|
||||
fontCfg.FontDataOwnedByAtlas = false;
|
||||
auto const &io = ImGui::GetIO();
|
||||
auto const font = files::RobotoMedium_ttf();
|
||||
// const_cast is needed because this data is definitely const,
|
||||
// but AddFontFromMemoryTTF requires a mutable buffer.
|
||||
// However, setting fontCfg.FontDataOwnedByAtlas ensures
|
||||
// that it will still be treated as const.
|
||||
// ImGui documentation recognizes that this is a bad design,
|
||||
// and hopefully it will change at some point.
|
||||
io.Fonts->AddFontFromMemoryTTF(
|
||||
const_cast<uint8_t*>(font.data()),
|
||||
static_cast<int>(font.size()),
|
||||
13 * scale,
|
||||
&fontCfg);
|
||||
}
|
||||
}
|
||||
|
||||
bool StudioUI::handleShutdown() noexcept {
|
||||
auto const out = ox::all_of(m_editors.begin(), m_editors.end(), [](ox::UPtr<BaseEditor> const &e) {
|
||||
return !e->unsavedChanges();
|
||||
|
||||
@@ -84,6 +84,7 @@ class StudioUI final: public ox::SignalHandler {
|
||||
ox::String args;
|
||||
};
|
||||
ox::Optional<NavAction> m_navAction;
|
||||
float m_fontScale{};
|
||||
|
||||
public:
|
||||
explicit StudioUI(turbine::Context &tctx, ox::StringParam projectDataDir) noexcept;
|
||||
@@ -105,6 +106,8 @@ class StudioUI final: public ox::SignalHandler {
|
||||
void draw() noexcept;
|
||||
|
||||
private:
|
||||
void loadFont() noexcept;
|
||||
|
||||
void drawMenu() noexcept;
|
||||
|
||||
void drawTabBar() noexcept;
|
||||
|
||||
Reference in New Issue
Block a user