mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-11 00:01:47 +08:00
Merge remote-tracking branch 'remotes/origin/ys_bf_msw_scale'
This commit is contained in:
commit
c8a78f5d85
@ -153,8 +153,8 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
|
||||
|
||||
auto manifold_warning_icon = [this](wxWindow* parent) {
|
||||
m_fix_throught_netfab_bitmap = new wxStaticBitmap(parent, wxID_ANY, wxNullBitmap);
|
||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer->Add(m_fix_throught_netfab_bitmap);
|
||||
// auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
// sizer->Add(m_fix_throught_netfab_bitmap);
|
||||
|
||||
if (is_windows10())
|
||||
m_fix_throught_netfab_bitmap->Bind(wxEVT_CONTEXT_MENU, [this](wxCommandEvent &e)
|
||||
@ -167,17 +167,19 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
|
||||
update_warning_icon_state(wxGetApp().obj_list()->get_mesh_errors_list());
|
||||
});
|
||||
|
||||
return sizer;
|
||||
// return sizer;
|
||||
return m_fix_throught_netfab_bitmap;
|
||||
};
|
||||
|
||||
line.append_widget(manifold_warning_icon);
|
||||
// line.append_widget(manifold_warning_icon);
|
||||
line.near_label_widget = manifold_warning_icon;
|
||||
def.label = "";
|
||||
def.gui_type = "legend";
|
||||
def.tooltip = L("Object name");
|
||||
#ifdef __APPLE__
|
||||
def.width = 19;
|
||||
def.width = 20;
|
||||
#else
|
||||
def.width = 21;
|
||||
def.width = 22;
|
||||
#endif
|
||||
def.set_default_value(new ConfigOptionString{ " " });
|
||||
line.append_option(Option(def, "object_name"));
|
||||
@ -392,10 +394,19 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
|
||||
|
||||
// call back for a rescale of button "Set uniform scale"
|
||||
m_og->rescale_near_label_widget = [this](wxWindow* win) {
|
||||
// rescale lock icon
|
||||
auto *ctrl = dynamic_cast<LockButton*>(win);
|
||||
if (ctrl == nullptr)
|
||||
if (ctrl != nullptr) {
|
||||
ctrl->msw_rescale();
|
||||
return;
|
||||
ctrl->msw_rescale();
|
||||
}
|
||||
|
||||
if (win == m_fix_throught_netfab_bitmap)
|
||||
return;
|
||||
|
||||
// rescale "place" of the empty icon (to correct layout of the "Size" and "Scale")
|
||||
if (dynamic_cast<wxStaticBitmap*>(win) != nullptr)
|
||||
win->SetMinSize(create_scaled_bitmap(m_parent, "one_layer_lock_on.png").GetSize());
|
||||
};
|
||||
}
|
||||
|
||||
@ -685,6 +696,7 @@ void ObjectManipulation::emulate_kill_focus()
|
||||
void ObjectManipulation::update_warning_icon_state(const wxString& tooltip)
|
||||
{
|
||||
m_fix_throught_netfab_bitmap->SetBitmap(tooltip.IsEmpty() ? wxNullBitmap : m_manifold_warning_bmp.bmp());
|
||||
m_fix_throught_netfab_bitmap->SetMinSize(tooltip.IsEmpty() ? wxSize(0,0) : m_manifold_warning_bmp.bmp().GetSize());
|
||||
m_fix_throught_netfab_bitmap->SetToolTip(tooltip);
|
||||
}
|
||||
|
||||
@ -919,7 +931,10 @@ void ObjectManipulation::msw_rescale()
|
||||
{
|
||||
msw_rescale_word_local_combo(m_word_local_combo);
|
||||
m_manifold_warning_bmp.msw_rescale();
|
||||
m_fix_throught_netfab_bitmap->SetBitmap(m_manifold_warning_bmp.bmp());
|
||||
|
||||
const wxString& tooltip = m_fix_throught_netfab_bitmap->GetToolTipText();
|
||||
m_fix_throught_netfab_bitmap->SetBitmap(tooltip.IsEmpty() ? wxNullBitmap : m_manifold_warning_bmp.bmp());
|
||||
m_fix_throught_netfab_bitmap->SetMinSize(tooltip.IsEmpty() ? wxSize(0, 0) : m_manifold_warning_bmp.bmp().GetSize());
|
||||
|
||||
m_mirror_bitmap_on.msw_rescale();
|
||||
m_mirror_bitmap_off.msw_rescale();
|
||||
|
@ -64,6 +64,12 @@ public:
|
||||
m_prev_scale_factor = m_scale_factor;
|
||||
m_normal_font = get_default_font_for_dpi(dpi);
|
||||
|
||||
/* Because of default window font is a primary display font,
|
||||
* We should set correct font for window before getting em_unit value.
|
||||
*/
|
||||
#ifndef __WXOSX__ // Don't call SetFont under OSX to avoid name cutting in ObjectList
|
||||
this->SetFont(m_normal_font);
|
||||
#endif
|
||||
// initialize default width_unit according to the width of the one symbol ("m") of the currently active font of this window.
|
||||
m_em_unit = std::max<size_t>(10, this->GetTextExtent("m").x - 1);
|
||||
|
||||
@ -72,6 +78,8 @@ public:
|
||||
this->Bind(EVT_DPI_CHANGED, [this](const DpiChangedEvent &evt) {
|
||||
m_scale_factor = (float)evt.dpi / (float)DPI_DEFAULT;
|
||||
|
||||
m_new_font_point_size = get_default_font_for_dpi(evt.dpi).GetPointSize();
|
||||
|
||||
if (!m_can_rescale)
|
||||
return;
|
||||
|
||||
@ -124,6 +132,8 @@ private:
|
||||
float m_prev_scale_factor;
|
||||
bool m_can_rescale{ true };
|
||||
|
||||
int m_new_font_point_size;
|
||||
|
||||
// void recalc_font()
|
||||
// {
|
||||
// wxClientDC dc(this);
|
||||
@ -135,14 +145,22 @@ private:
|
||||
// check if new scale is differ from previous
|
||||
bool is_new_scale_factor() const { return fabs(m_scale_factor - m_prev_scale_factor) > 0.001; }
|
||||
|
||||
// function for a font scaling of the window
|
||||
void scale_win_font(wxWindow *window, const int font_point_size)
|
||||
{
|
||||
wxFont new_font(window->GetFont());
|
||||
new_font.SetPointSize(font_point_size);
|
||||
window->SetFont(new_font);
|
||||
}
|
||||
|
||||
// recursive function for scaling fonts for all controls in Window
|
||||
void scale_controls_fonts(wxWindow *window, const float scale_f)
|
||||
void scale_controls_fonts(wxWindow *window, const int font_point_size)
|
||||
{
|
||||
auto children = window->GetChildren();
|
||||
|
||||
for (auto child : children) {
|
||||
scale_controls_fonts(child, scale_f);
|
||||
child->SetFont(child->GetFont().Scaled(scale_f));
|
||||
scale_controls_fonts(child, font_point_size);
|
||||
scale_win_font(child, font_point_size);
|
||||
}
|
||||
|
||||
window->Layout();
|
||||
@ -151,18 +169,18 @@ private:
|
||||
void rescale(const wxRect &suggested_rect)
|
||||
{
|
||||
this->Freeze();
|
||||
const float relative_scale_factor = m_scale_factor / m_prev_scale_factor;
|
||||
|
||||
// rescale fonts of all controls
|
||||
scale_controls_fonts(this, relative_scale_factor);
|
||||
this->SetFont(this->GetFont().Scaled(relative_scale_factor));
|
||||
scale_controls_fonts(this, m_new_font_point_size);
|
||||
// rescale current window font
|
||||
scale_win_font(this, m_new_font_point_size);
|
||||
|
||||
|
||||
// rescale normal_font value
|
||||
m_normal_font = m_normal_font.Scaled(relative_scale_factor);
|
||||
// set normal application font as a current window font
|
||||
m_normal_font = this->GetFont();
|
||||
|
||||
// An analog of em_unit value from GUI_App.
|
||||
m_em_unit = std::max<size_t>(10, 10 * m_scale_factor);
|
||||
// update em_unit value for new window font
|
||||
m_em_unit = std::max<size_t>(10, this->GetTextExtent("m").x - 1);
|
||||
|
||||
// rescale missed controls sizes and images
|
||||
on_dpi_changed(suggested_rect);
|
||||
|
@ -39,10 +39,12 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
|
||||
{
|
||||
// Fonts were created by the DPIFrame constructor for the monitor, on which the window opened.
|
||||
wxGetApp().update_fonts(this);
|
||||
/*
|
||||
#ifndef __WXOSX__ // Don't call SetFont under OSX to avoid name cutting in ObjectList
|
||||
this->SetFont(this->normal_font());
|
||||
#endif
|
||||
|
||||
// Font is already set in DPIFrame constructor
|
||||
*/
|
||||
// Load the icon either from the exe, or from the ico file.
|
||||
#if _WIN32
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user