mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 08:47:52 -06:00
imgui: Get font size from wxWidgets, fix #2043
This commit is contained in:
parent
32ed064797
commit
3cfb234e86
3 changed files with 23 additions and 27 deletions
|
@ -25,14 +25,22 @@ namespace Slic3r {
|
|||
namespace GUI {
|
||||
|
||||
|
||||
ImGuiWrapper::ImGuiWrapper()
|
||||
ImGuiWrapper::ImGuiWrapper(float font_size)
|
||||
: m_glyph_ranges(nullptr)
|
||||
, m_font_size(font_size)
|
||||
, m_font_texture(0)
|
||||
, m_style_scaling(1.0)
|
||||
, m_mouse_buttons(0)
|
||||
, m_disabled(false)
|
||||
, m_new_frame_open(false)
|
||||
{
|
||||
ImGui::CreateContext();
|
||||
|
||||
init_default_font();
|
||||
init_input();
|
||||
init_style();
|
||||
|
||||
ImGui::GetIO().IniFilename = nullptr;
|
||||
}
|
||||
|
||||
ImGuiWrapper::~ImGuiWrapper()
|
||||
|
@ -41,19 +49,6 @@ ImGuiWrapper::~ImGuiWrapper()
|
|||
ImGui::DestroyContext();
|
||||
}
|
||||
|
||||
bool ImGuiWrapper::init()
|
||||
{
|
||||
ImGui::CreateContext();
|
||||
|
||||
init_default_font(m_style_scaling);
|
||||
init_input();
|
||||
init_style();
|
||||
|
||||
ImGui::GetIO().IniFilename = nullptr;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImGuiWrapper::set_language(const std::string &language)
|
||||
{
|
||||
if (m_new_frame_open) {
|
||||
|
@ -87,7 +82,7 @@ void ImGuiWrapper::set_language(const std::string &language)
|
|||
|
||||
if (ranges != m_glyph_ranges) {
|
||||
m_glyph_ranges = ranges;
|
||||
init_default_font(m_style_scaling);
|
||||
init_default_font();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,8 +97,8 @@ void ImGuiWrapper::set_style_scaling(float scaling)
|
|||
{
|
||||
if (!std::isnan(scaling) && !std::isinf(scaling) && scaling != m_style_scaling) {
|
||||
ImGui::GetStyle().ScaleAllSizes(scaling / m_style_scaling);
|
||||
init_default_font(scaling);
|
||||
m_style_scaling = scaling;
|
||||
init_default_font();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -328,15 +323,15 @@ bool ImGuiWrapper::want_any_input() const
|
|||
return io.WantCaptureMouse || io.WantCaptureKeyboard || io.WantTextInput;
|
||||
}
|
||||
|
||||
void ImGuiWrapper::init_default_font(float scaling)
|
||||
void ImGuiWrapper::init_default_font()
|
||||
{
|
||||
static const float font_size = 18.0f;
|
||||
const float font_size = m_font_size * m_style_scaling;
|
||||
|
||||
destroy_fonts_texture();
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.Fonts->Clear();
|
||||
ImFont* font = io.Fonts->AddFontFromFileTTF((Slic3r::resources_dir() + "/fonts/NotoSans-Regular.ttf").c_str(), font_size * scaling, nullptr, m_glyph_ranges);
|
||||
ImFont* font = io.Fonts->AddFontFromFileTTF((Slic3r::resources_dir() + "/fonts/NotoSans-Regular.ttf").c_str(), font_size, nullptr, m_glyph_ranges);
|
||||
if (font == nullptr) {
|
||||
font = io.Fonts->AddFontDefault();
|
||||
if (font == nullptr) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue