Fixed "actions" buttons size under OSX

This commit is contained in:
YuSanka 2019-12-13 17:56:04 +01:00
parent 81a2f8535a
commit 7d0d70534b
3 changed files with 16 additions and 4 deletions

View File

@ -853,18 +853,23 @@ Sidebar::Sidebar(Plater *parent)
auto init_scalable_btn = [this](ScalableButton** btn, const std::string& icon_name, wxString tooltip = wxEmptyString) auto init_scalable_btn = [this](ScalableButton** btn, const std::string& icon_name, wxString tooltip = wxEmptyString)
{ {
ScalableBitmap bmp = ScalableBitmap(this, icon_name, int(2.5 * wxGetApp().em_unit())); #ifdef __APPLE__
int bmp_px_cnt = 16;
#else
int bmp_px_cnt = 32;
#endif //__APPLE__
ScalableBitmap bmp = ScalableBitmap(this, icon_name, bmp_px_cnt);
*btn = new ScalableButton(this, wxID_ANY, bmp, "", wxBU_EXACTFIT); *btn = new ScalableButton(this, wxID_ANY, bmp, "", wxBU_EXACTFIT);
(*btn)->SetToolTip(tooltip); (*btn)->SetToolTip(tooltip);
(*btn)->Hide(); (*btn)->Hide();
}; };
init_scalable_btn(&p->btn_send_gcode , "export_gcode", _(L("Send to printer"))); init_scalable_btn(&p->btn_send_gcode , "export_gcode", _(L("Send to printer")));
init_scalable_btn(&p->btn_remove_device, "revert_all_" , _(L("Remove device"))); init_scalable_btn(&p->btn_remove_device, "cross" , _(L("Remove device")));
// regular buttons "Slice now" and "Export G-code" // regular buttons "Slice now" and "Export G-code"
const int scaled_height = p->btn_remove_device->GetBitmap().GetHeight() + 4; const int scaled_height = p->btn_remove_device->GetBitmapHeight() + 4;
auto init_btn = [this](wxButton **btn, wxString label, const int button_height) { auto init_btn = [this](wxButton **btn, wxString label, const int button_height) {
*btn = new wxButton(this, wxID_ANY, label, wxDefaultPosition, *btn = new wxButton(this, wxID_ANY, label, wxDefaultPosition,
wxSize(-1, button_height), wxBU_EXACTFIT); wxSize(-1, button_height), wxBU_EXACTFIT);
@ -880,7 +885,7 @@ Sidebar::Sidebar(Plater *parent)
auto* complect_btns_sizer = new wxBoxSizer(wxHORIZONTAL); auto* complect_btns_sizer = new wxBoxSizer(wxHORIZONTAL);
complect_btns_sizer->Add(p->btn_export_gcode, 1, wxEXPAND); complect_btns_sizer->Add(p->btn_export_gcode, 1, wxEXPAND);
complect_btns_sizer->Add(p->btn_send_gcode, 0, wxEXPAND); complect_btns_sizer->Add(p->btn_send_gcode);
complect_btns_sizer->Add(p->btn_remove_device); complect_btns_sizer->Add(p->btn_remove_device);
btns_sizer->Add(p->btn_reslice, 0, wxEXPAND | wxTOP, margin_5); btns_sizer->Add(p->btn_reslice, 0, wxEXPAND | wxTOP, margin_5);

View File

@ -3961,6 +3961,12 @@ void ScalableButton::SetBitmapDisabled_(const ScalableBitmap& bmp)
m_disabled_icon_name = bmp.name(); m_disabled_icon_name = bmp.name();
} }
int ScalableButton::GetBitmapHeight()
{
const float scale_factor = get_svg_scale_factor(m_parent);
return int((float)GetBitmap().GetHeight() / scale_factor);
}
void ScalableButton::msw_rescale() void ScalableButton::msw_rescale()
{ {
SetBitmap(create_scaled_bitmap(m_parent, m_current_icon_name, m_px_cnt, m_is_horizontal)); SetBitmap(create_scaled_bitmap(m_parent, m_current_icon_name, m_px_cnt, m_is_horizontal));

View File

@ -1110,6 +1110,7 @@ public:
void SetBitmap_(const ScalableBitmap& bmp); void SetBitmap_(const ScalableBitmap& bmp);
void SetBitmapDisabled_(const ScalableBitmap &bmp); void SetBitmapDisabled_(const ScalableBitmap &bmp);
int GetBitmapHeight();
void msw_rescale(); void msw_rescale();