Merge branch 'master' of https://github.com/prusa3d/Slic3r into et_canvas_gui_refactoring
This commit is contained in:
commit
1ce3bb690c
@ -81,7 +81,7 @@ IMPLEMENT_APP(GUI_App)
|
||||
GUI_App::GUI_App()
|
||||
: wxApp()
|
||||
, m_em_unit(10)
|
||||
, m_imgui(new ImGuiWrapper())
|
||||
, m_imgui(nullptr)
|
||||
{}
|
||||
|
||||
bool GUI_App::OnInit()
|
||||
@ -90,7 +90,6 @@ bool GUI_App::OnInit()
|
||||
const wxString resources_dir = from_u8(Slic3r::resources_dir());
|
||||
wxCHECK_MSG(wxDirExists(resources_dir), false,
|
||||
wxString::Format("Resources path does not exist or is not a directory: %s", resources_dir));
|
||||
wxCHECK_MSG(m_imgui->init(), false, "Failed to initialize ImGui");
|
||||
|
||||
SetAppName("Slic3rPE-beta");
|
||||
SetAppDisplayName("Slic3r Prusa Edition");
|
||||
@ -136,6 +135,11 @@ bool GUI_App::OnInit()
|
||||
app_config->save();
|
||||
});
|
||||
|
||||
// initialize label colors and fonts
|
||||
init_label_colours();
|
||||
init_fonts();
|
||||
m_imgui.reset(new ImGuiWrapper(m_normal_font.GetPixelSize().y));
|
||||
|
||||
load_language();
|
||||
|
||||
// Suppress the '- default -' presets.
|
||||
@ -148,9 +152,6 @@ bool GUI_App::OnInit()
|
||||
|
||||
// Let the libslic3r know the callback, which will translate messages on demand.
|
||||
Slic3r::I18N::set_translate_callback(libslic3r_translate_callback);
|
||||
// initialize label colors and fonts
|
||||
init_label_colours();
|
||||
init_fonts();
|
||||
|
||||
// application frame
|
||||
if (wxImage::FindHandler(wxBITMAP_TYPE_PNG) == nullptr)
|
||||
|
@ -45,8 +45,11 @@ bool GLGizmoSlaSupports::on_init()
|
||||
|
||||
void GLGizmoSlaSupports::set_sla_support_data(ModelObject* model_object, const Selection& selection)
|
||||
{
|
||||
if (selection.is_empty())
|
||||
if (selection.is_empty()) {
|
||||
m_model_object = nullptr;
|
||||
m_old_model_object = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
m_old_model_object = m_model_object;
|
||||
m_model_object = model_object;
|
||||
|
@ -26,14 +26,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()
|
||||
@ -42,19 +50,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) {
|
||||
@ -88,7 +83,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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,8 +98,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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -329,15 +324,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) {
|
||||
|
@ -22,6 +22,7 @@ class ImGuiWrapper
|
||||
|
||||
FontsMap m_fonts;
|
||||
const ImWchar *m_glyph_ranges;
|
||||
float m_font_size;
|
||||
unsigned m_font_texture;
|
||||
float m_style_scaling;
|
||||
unsigned m_mouse_buttons;
|
||||
@ -30,10 +31,9 @@ class ImGuiWrapper
|
||||
std::string m_clipboard_text;
|
||||
|
||||
public:
|
||||
ImGuiWrapper();
|
||||
ImGuiWrapper(float font_size);
|
||||
~ImGuiWrapper();
|
||||
|
||||
bool init();
|
||||
void read_glsl_version();
|
||||
|
||||
void set_language(const std::string &language);
|
||||
@ -73,7 +73,7 @@ public:
|
||||
bool want_any_input() const;
|
||||
|
||||
private:
|
||||
void init_default_font(float scaling);
|
||||
void init_default_font();
|
||||
void create_device_objects();
|
||||
void create_fonts_texture();
|
||||
void init_input();
|
||||
|
Loading…
Reference in New Issue
Block a user