Experiments with msw_rescale fixing
This commit is contained in:
parent
ce22251707
commit
415877d79e
@ -130,8 +130,8 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
|
|||||||
|
|
||||||
auto manifold_warning_icon = [this](wxWindow* parent) {
|
auto manifold_warning_icon = [this](wxWindow* parent) {
|
||||||
m_fix_throught_netfab_bitmap = new wxStaticBitmap(parent, wxID_ANY, wxNullBitmap);
|
m_fix_throught_netfab_bitmap = new wxStaticBitmap(parent, wxID_ANY, wxNullBitmap);
|
||||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
// auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
sizer->Add(m_fix_throught_netfab_bitmap);
|
// sizer->Add(m_fix_throught_netfab_bitmap);
|
||||||
|
|
||||||
if (is_windows10())
|
if (is_windows10())
|
||||||
m_fix_throught_netfab_bitmap->Bind(wxEVT_CONTEXT_MENU, [this](wxCommandEvent &e)
|
m_fix_throught_netfab_bitmap->Bind(wxEVT_CONTEXT_MENU, [this](wxCommandEvent &e)
|
||||||
@ -144,17 +144,19 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
|
|||||||
update_warning_icon_state(wxGetApp().obj_list()->get_mesh_errors_list());
|
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.label = "";
|
||||||
def.gui_type = "legend";
|
def.gui_type = "legend";
|
||||||
def.tooltip = L("Object name");
|
def.tooltip = L("Object name");
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
def.width = 19;
|
def.width = 20;
|
||||||
#else
|
#else
|
||||||
def.width = 21;
|
def.width = 22;
|
||||||
#endif
|
#endif
|
||||||
def.set_default_value(new ConfigOptionString{ " " });
|
def.set_default_value(new ConfigOptionString{ " " });
|
||||||
line.append_option(Option(def, "object_name"));
|
line.append_option(Option(def, "object_name"));
|
||||||
@ -233,10 +235,19 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
|
|||||||
|
|
||||||
// call back for a rescale of button "Set uniform scale"
|
// call back for a rescale of button "Set uniform scale"
|
||||||
m_og->rescale_near_label_widget = [this](wxWindow* win) {
|
m_og->rescale_near_label_widget = [this](wxWindow* win) {
|
||||||
|
// rescale lock icon
|
||||||
auto *ctrl = dynamic_cast<LockButton*>(win);
|
auto *ctrl = dynamic_cast<LockButton*>(win);
|
||||||
if (ctrl == nullptr)
|
if (ctrl != nullptr) {
|
||||||
return;
|
|
||||||
ctrl->msw_rescale();
|
ctrl->msw_rescale();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
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());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -431,6 +442,7 @@ void ObjectManipulation::emulate_kill_focus()
|
|||||||
void ObjectManipulation::update_warning_icon_state(const wxString& tooltip)
|
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->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);
|
m_fix_throught_netfab_bitmap->SetToolTip(tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -664,7 +676,10 @@ void ObjectManipulation::msw_rescale()
|
|||||||
{
|
{
|
||||||
msw_rescale_word_local_combo(m_word_local_combo);
|
msw_rescale_word_local_combo(m_word_local_combo);
|
||||||
m_manifold_warning_bmp.msw_rescale();
|
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());
|
||||||
|
|
||||||
get_og()->msw_rescale();
|
get_og()->msw_rescale();
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,8 @@ public:
|
|||||||
this->Bind(EVT_DPI_CHANGED, [this](const DpiChangedEvent &evt) {
|
this->Bind(EVT_DPI_CHANGED, [this](const DpiChangedEvent &evt) {
|
||||||
m_scale_factor = (float)evt.dpi / (float)DPI_DEFAULT;
|
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)
|
if (!m_can_rescale)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -124,6 +126,8 @@ private:
|
|||||||
float m_prev_scale_factor;
|
float m_prev_scale_factor;
|
||||||
bool m_can_rescale{ true };
|
bool m_can_rescale{ true };
|
||||||
|
|
||||||
|
int m_new_font_point_size;
|
||||||
|
|
||||||
// void recalc_font()
|
// void recalc_font()
|
||||||
// {
|
// {
|
||||||
// wxClientDC dc(this);
|
// wxClientDC dc(this);
|
||||||
@ -148,18 +152,42 @@ private:
|
|||||||
window->Layout();
|
window->Layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 int font_point_size)
|
||||||
|
{
|
||||||
|
auto children = window->GetChildren();
|
||||||
|
|
||||||
|
for (auto child : children) {
|
||||||
|
scale_controls_fonts(child, font_point_size);
|
||||||
|
scale_win_font(child, font_point_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
window->Layout();
|
||||||
|
}
|
||||||
|
|
||||||
void rescale(const wxRect &suggested_rect)
|
void rescale(const wxRect &suggested_rect)
|
||||||
{
|
{
|
||||||
this->Freeze();
|
this->Freeze();
|
||||||
const float relative_scale_factor = m_scale_factor / m_prev_scale_factor;
|
// const float relative_scale_factor = m_scale_factor / m_prev_scale_factor;
|
||||||
|
|
||||||
// rescale fonts of all controls
|
// rescale fonts of all controls
|
||||||
scale_controls_fonts(this, relative_scale_factor);
|
// scale_controls_fonts(this, relative_scale_factor);
|
||||||
this->SetFont(this->GetFont().Scaled(relative_scale_factor));
|
scale_controls_fonts(this, m_new_font_point_size);
|
||||||
|
|
||||||
|
// this->SetFont(this->GetFont().Scaled(relative_scale_factor));
|
||||||
|
scale_win_font(this, m_new_font_point_size);
|
||||||
|
|
||||||
|
|
||||||
// rescale normal_font value
|
// rescale normal_font value
|
||||||
m_normal_font = m_normal_font.Scaled(relative_scale_factor);
|
// m_normal_font = m_normal_font.Scaled(relative_scale_factor);
|
||||||
|
m_normal_font = this->GetFont();
|
||||||
|
|
||||||
// An analog of em_unit value from GUI_App.
|
// An analog of em_unit value from GUI_App.
|
||||||
m_em_unit = std::max<size_t>(10, 10 * m_scale_factor);
|
m_em_unit = std::max<size_t>(10, 10 * m_scale_factor);
|
||||||
|
@ -2478,6 +2478,8 @@ void LockButton::msw_rescale()
|
|||||||
m_bmp_lock_off .msw_rescale();
|
m_bmp_lock_off .msw_rescale();
|
||||||
m_bmp_unlock_on .msw_rescale();
|
m_bmp_unlock_on .msw_rescale();
|
||||||
m_bmp_unlock_off.msw_rescale();
|
m_bmp_unlock_off.msw_rescale();
|
||||||
|
|
||||||
|
enter_button(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LockButton::enter_button(const bool enter)
|
void LockButton::enter_button(const bool enter)
|
||||||
|
Loading…
Reference in New Issue
Block a user