This commit is contained in:
@@ -121,25 +121,7 @@ using StudioConfig = StudioConfigV2;
|
|||||||
StudioUI::StudioUI(turbine::Context &tctx, ox::StringParam projectDataDir) noexcept:
|
StudioUI::StudioUI(turbine::Context &tctx, ox::StringParam projectDataDir) noexcept:
|
||||||
m_sctx{*this, tctx},
|
m_sctx{*this, tctx},
|
||||||
m_projectDataDir{std::move(projectDataDir)} {
|
m_projectDataDir{std::move(projectDataDir)} {
|
||||||
{
|
loadFont();
|
||||||
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);
|
|
||||||
}
|
|
||||||
auto &kctx = keelCtx(m_tctx);
|
auto &kctx = keelCtx(m_tctx);
|
||||||
kctx.converters.emplace_back(keel::Converter::make<convertStudioConfigV1ToStudioConfigV2>());
|
kctx.converters.emplace_back(keel::Converter::make<convertStudioConfigV1ToStudioConfigV2>());
|
||||||
oxLogError(headerizeConfigFile<StudioConfigV1>(kctx));
|
oxLogError(headerizeConfigFile<StudioConfigV1>(kctx));
|
||||||
@@ -206,6 +188,7 @@ void StudioUI::draw() noexcept {
|
|||||||
if (turbine::isWayland() || ox::defines::OS == ox::OS::Darwin) {
|
if (turbine::isWayland() || ox::defines::OS == ox::OS::Darwin) {
|
||||||
ig::setDpiScale(1.f);
|
ig::setDpiScale(1.f);
|
||||||
} else {
|
} else {
|
||||||
|
loadFont();
|
||||||
ig::setDpiScale(ImGui::GetWindowDpiScale());
|
ig::setDpiScale(ImGui::GetWindowDpiScale());
|
||||||
}
|
}
|
||||||
glutils::clearScreen();
|
glutils::clearScreen();
|
||||||
@@ -240,6 +223,29 @@ void StudioUI::draw() noexcept {
|
|||||||
procFileMoves();
|
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 {
|
bool StudioUI::handleShutdown() noexcept {
|
||||||
auto const out = ox::all_of(m_editors.begin(), m_editors.end(), [](ox::UPtr<BaseEditor> const &e) {
|
auto const out = ox::all_of(m_editors.begin(), m_editors.end(), [](ox::UPtr<BaseEditor> const &e) {
|
||||||
return !e->unsavedChanges();
|
return !e->unsavedChanges();
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ class StudioUI final: public ox::SignalHandler {
|
|||||||
ox::String args;
|
ox::String args;
|
||||||
};
|
};
|
||||||
ox::Optional<NavAction> m_navAction;
|
ox::Optional<NavAction> m_navAction;
|
||||||
|
float m_fontScale{};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit StudioUI(turbine::Context &tctx, ox::StringParam projectDataDir) noexcept;
|
explicit StudioUI(turbine::Context &tctx, ox::StringParam projectDataDir) noexcept;
|
||||||
@@ -105,6 +106,8 @@ class StudioUI final: public ox::SignalHandler {
|
|||||||
void draw() noexcept;
|
void draw() noexcept;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void loadFont() noexcept;
|
||||||
|
|
||||||
void drawMenu() noexcept;
|
void drawMenu() noexcept;
|
||||||
|
|
||||||
void drawTabBar() noexcept;
|
void drawTabBar() noexcept;
|
||||||
|
|||||||
Reference in New Issue
Block a user