Application Scaling for MSW:
+ Experiments with toolBars scaling + Rescaled warning and printing legends
This commit is contained in:
parent
ae2c61160f
commit
fc63a28481
@ -703,6 +703,7 @@ void GLCanvas3D::WarningTexture::activate(WarningTexture::Warning warning, bool
|
||||
m_warnings.erase(it);
|
||||
if (m_warnings.empty()) { // nothing remains to be shown
|
||||
reset();
|
||||
m_msg_text = "";// save information for rescaling
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -723,6 +724,10 @@ void GLCanvas3D::WarningTexture::activate(WarningTexture::Warning warning, bool
|
||||
}
|
||||
|
||||
_generate(text, canvas, red_colored); // GUI::GLTexture::reset() is called at the beginning of generate(...)
|
||||
|
||||
// save information for rescaling
|
||||
m_msg_text = text;
|
||||
m_is_colored_red = red_colored;
|
||||
}
|
||||
|
||||
|
||||
@ -791,7 +796,9 @@ bool GLCanvas3D::WarningTexture::_generate(const std::string& msg_utf8, const GL
|
||||
wxMemoryDC memDC;
|
||||
// select default font
|
||||
const float scale = canvas.get_canvas_size().get_scale_factor();
|
||||
wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Scale(scale);
|
||||
// wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Scale(scale);
|
||||
wxFont font = wxGetApp().normal_font();//! #ys_FIXME_experiment
|
||||
|
||||
font.MakeLarger();
|
||||
font.MakeBold();
|
||||
memDC.SetFont(font);
|
||||
@ -892,6 +899,14 @@ void GLCanvas3D::WarningTexture::render(const GLCanvas3D& canvas) const
|
||||
}
|
||||
}
|
||||
|
||||
void GLCanvas3D::WarningTexture::rescale(const GLCanvas3D& canvas)
|
||||
{
|
||||
if (m_msg_text.empty())
|
||||
return;
|
||||
|
||||
_generate(m_msg_text, canvas, m_is_colored_red);
|
||||
}
|
||||
|
||||
const unsigned char GLCanvas3D::LegendTexture::Squares_Border_Color[3] = { 64, 64, 64 };
|
||||
const unsigned char GLCanvas3D::LegendTexture::Default_Background_Color[3] = { (unsigned char)(DEFAULT_BG_LIGHT_COLOR[0] * 255.0f), (unsigned char)(DEFAULT_BG_LIGHT_COLOR[1] * 255.0f), (unsigned char)(DEFAULT_BG_LIGHT_COLOR[2] * 255.0f) };
|
||||
const unsigned char GLCanvas3D::LegendTexture::Error_Background_Color[3] = { (unsigned char)(ERROR_BG_LIGHT_COLOR[0] * 255.0f), (unsigned char)(ERROR_BG_LIGHT_COLOR[1] * 255.0f), (unsigned char)(ERROR_BG_LIGHT_COLOR[2] * 255.0f) };
|
||||
@ -962,7 +977,8 @@ bool GLCanvas3D::LegendTexture::generate(const GCodePreviewData& preview_data, c
|
||||
const int scaled_border = Px_Border * scale;
|
||||
|
||||
// select default font
|
||||
wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Scale(scale_gl);
|
||||
// wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Scale(scale_gl);
|
||||
wxFont font = wxGetApp().normal_font();//! #ys_FIXME_experiment
|
||||
#ifdef __WXMSW__
|
||||
// Disabling ClearType works, but the font returned is very different (much thicker) from the default.
|
||||
// msw_disable_cleartype(font);
|
||||
@ -3150,6 +3166,11 @@ double GLCanvas3D::get_size_proportional_to_max_bed_size(double factor) const
|
||||
return factor * m_bed.get_bounding_box().max_size();
|
||||
}
|
||||
|
||||
void GLCanvas3D::rescale()
|
||||
{
|
||||
m_warning_texture.rescale(*this);
|
||||
}
|
||||
|
||||
bool GLCanvas3D::_is_shown_on_screen() const
|
||||
{
|
||||
return (m_canvas != nullptr) ? m_canvas->IsShownOnScreen() : false;
|
||||
@ -3794,7 +3815,8 @@ void GLCanvas3D::_render_gizmos_overlay() const
|
||||
#if ENABLE_RETINA_GL
|
||||
m_gizmos.set_overlay_scale(m_retina_helper->get_scale_factor());
|
||||
#else
|
||||
m_gizmos.set_overlay_scale(m_canvas->GetContentScaleFactor());
|
||||
// m_gizmos.set_overlay_scale(m_canvas->GetContentScaleFactor());
|
||||
m_gizmos.set_overlay_scale(wxGetApp().em_unit()*0.1f);//! #ys_FIXME_experiment
|
||||
#endif /* __WXMSW__ */
|
||||
|
||||
m_gizmos.render_overlay(*this, m_selection);
|
||||
@ -3806,7 +3828,8 @@ void GLCanvas3D::_render_toolbar() const
|
||||
#if ENABLE_RETINA_GL
|
||||
m_toolbar.set_scale(m_retina_helper->get_scale_factor());
|
||||
#else
|
||||
m_toolbar.set_scale(m_canvas->GetContentScaleFactor());
|
||||
// m_toolbar.set_scale(m_canvas->GetContentScaleFactor());
|
||||
m_toolbar.set_scale(wxGetApp().em_unit()*0.1f);//! #ys_FIXME_experiment
|
||||
#endif // ENABLE_RETINA_GL
|
||||
|
||||
Size cnv_size = get_canvas_size();
|
||||
@ -3869,7 +3892,8 @@ void GLCanvas3D::_render_view_toolbar() const
|
||||
#if ENABLE_RETINA_GL
|
||||
m_view_toolbar.set_scale(m_retina_helper->get_scale_factor());
|
||||
#else
|
||||
m_view_toolbar.set_scale(m_canvas->GetContentScaleFactor());
|
||||
// m_view_toolbar.set_scale(m_canvas->GetContentScaleFactor());
|
||||
m_view_toolbar.set_scale(wxGetApp().em_unit()*0.1f); //! #ys_FIXME_experiment
|
||||
#endif // ENABLE_RETINA_GL
|
||||
|
||||
Size cnv_size = get_canvas_size();
|
||||
|
@ -353,6 +353,9 @@ private:
|
||||
void activate(WarningTexture::Warning warning, bool state, const GLCanvas3D& canvas);
|
||||
void render(const GLCanvas3D& canvas) const;
|
||||
|
||||
// function used to get an information for rescaling of the warning
|
||||
void rescale(const GLCanvas3D& canvas);
|
||||
|
||||
private:
|
||||
static const unsigned char Background_Color[3];
|
||||
static const unsigned char Opacity;
|
||||
@ -360,6 +363,10 @@ private:
|
||||
int m_original_width;
|
||||
int m_original_height;
|
||||
|
||||
// information for rescaling of the warning legend
|
||||
std::string m_msg_text = "";
|
||||
bool m_is_colored_red{false};
|
||||
|
||||
// Information about which warnings are currently active.
|
||||
std::vector<Warning> m_warnings;
|
||||
|
||||
@ -587,6 +594,8 @@ public:
|
||||
|
||||
double get_size_proportional_to_max_bed_size(double factor) const;
|
||||
|
||||
void rescale();
|
||||
|
||||
private:
|
||||
bool _is_shown_on_screen() const;
|
||||
|
||||
|
@ -396,9 +396,16 @@ void Preview::refresh_print()
|
||||
load_print(true);
|
||||
}
|
||||
|
||||
void Preview::rescale_slider()
|
||||
void Preview::rescale()
|
||||
{
|
||||
// rescale slider
|
||||
if (m_slider) m_slider->rescale();
|
||||
|
||||
// rescale warning legend on the canvas
|
||||
get_canvas3d()->rescale();
|
||||
|
||||
// rescale legend
|
||||
refresh_print();
|
||||
}
|
||||
|
||||
void Preview::bind_event_handlers()
|
||||
|
@ -120,7 +120,7 @@ public:
|
||||
void reload_print(bool keep_volumes = false);
|
||||
void refresh_print();
|
||||
|
||||
void rescale_slider();
|
||||
void rescale();
|
||||
|
||||
private:
|
||||
bool init(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, Model* model);
|
||||
|
@ -3806,7 +3806,9 @@ bool Plater::can_paste_from_clipboard() const
|
||||
|
||||
void Plater::rescale()
|
||||
{
|
||||
p->preview->rescale_slider();
|
||||
p->preview->rescale();
|
||||
|
||||
p->view3D->get_canvas3d()->rescale();
|
||||
|
||||
p->sidebar->rescale();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user