Upgrade for ModeButtons
This commit is contained in:
parent
1a3fc0994b
commit
77401ed79d
4 changed files with 10 additions and 14 deletions
src/slic3r/GUI
|
@ -718,7 +718,7 @@ Sidebar::Sidebar(Plater *parent)
|
||||||
p->scrolled->SetSizer(scrolled_sizer);
|
p->scrolled->SetSizer(scrolled_sizer);
|
||||||
|
|
||||||
// Sizer with buttons for mode changing
|
// Sizer with buttons for mode changing
|
||||||
p->mode_sizer = new ModeSizer(p->scrolled, 2 * wxGetApp().em_unit());
|
p->mode_sizer = new ModeSizer(p->scrolled);
|
||||||
|
|
||||||
// The preset chooser
|
// The preset chooser
|
||||||
p->sizer_presets = new wxFlexGridSizer(10, 1, 1, 2);
|
p->sizer_presets = new wxFlexGridSizer(10, 1, 1, 2);
|
||||||
|
|
|
@ -198,7 +198,7 @@ void Tab::create_preset_tab()
|
||||||
// There is used just additional sizer for m_mode_sizer with right alignment
|
// There is used just additional sizer for m_mode_sizer with right alignment
|
||||||
auto mode_sizer = new wxBoxSizer(wxVERTICAL);
|
auto mode_sizer = new wxBoxSizer(wxVERTICAL);
|
||||||
mode_sizer->Add(m_mode_sizer, 1, wxALIGN_RIGHT);
|
mode_sizer->Add(m_mode_sizer, 1, wxALIGN_RIGHT);
|
||||||
m_hsizer->Add(mode_sizer, 1, wxALIGN_CENTER_VERTICAL | wxRIGHT, wxOSX ? 15 : 5);
|
m_hsizer->Add(mode_sizer, 1, wxALIGN_CENTER_VERTICAL | wxRIGHT, wxOSX ? 15 : 10);
|
||||||
|
|
||||||
//Horizontal sizer to hold the tree and the selected page.
|
//Horizontal sizer to hold the tree and the selected page.
|
||||||
m_hsizer = new wxBoxSizer(wxHORIZONTAL);
|
m_hsizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
|
|
@ -2808,11 +2808,13 @@ ModeButton::ModeButton( wxWindow * parent,
|
||||||
const wxString& mode /* = wxEmptyString*/,
|
const wxString& mode /* = wxEmptyString*/,
|
||||||
const wxSize& size /* = wxDefaultSize*/,
|
const wxSize& size /* = wxDefaultSize*/,
|
||||||
const wxPoint& pos /* = wxDefaultPosition*/) :
|
const wxPoint& pos /* = wxDefaultPosition*/) :
|
||||||
ScalableButton(parent, id, icon_name, mode, size, pos)
|
ScalableButton(parent, id, icon_name, mode, size, pos, wxBU_EXACTFIT)
|
||||||
{
|
{
|
||||||
m_tt_focused = wxString::Format(_(L("Switch to the %s mode")), mode);
|
m_tt_focused = wxString::Format(_(L("Switch to the %s mode")), mode);
|
||||||
m_tt_selected = wxString::Format(_(L("Current mode is %s")), mode);
|
m_tt_selected = wxString::Format(_(L("Current mode is %s")), mode);
|
||||||
|
|
||||||
|
SetBitmapMargins(3, 0);
|
||||||
|
|
||||||
//button events
|
//button events
|
||||||
Bind(wxEVT_BUTTON, &ModeButton::OnButton, this);
|
Bind(wxEVT_BUTTON, &ModeButton::OnButton, this);
|
||||||
Bind(wxEVT_ENTER_WINDOW, &ModeButton::OnEnterBtn, this);
|
Bind(wxEVT_ENTER_WINDOW, &ModeButton::OnEnterBtn, this);
|
||||||
|
@ -2841,6 +2843,7 @@ void ModeButton::focus_button(const bool focus)
|
||||||
Slic3r::GUI::wxGetApp().normal_font();
|
Slic3r::GUI::wxGetApp().normal_font();
|
||||||
|
|
||||||
SetFont(new_font);
|
SetFont(new_font);
|
||||||
|
SetForegroundColour(wxSystemSettings::GetColour(focus ? wxSYS_COLOUR_BTNTEXT : wxSYS_COLOUR_BTNSHADOW));
|
||||||
|
|
||||||
Refresh();
|
Refresh();
|
||||||
Update();
|
Update();
|
||||||
|
@ -2851,7 +2854,7 @@ void ModeButton::focus_button(const bool focus)
|
||||||
// ModeSizer
|
// ModeSizer
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
ModeSizer::ModeSizer(wxWindow *parent, int hgap/* = 10*/) :
|
ModeSizer::ModeSizer(wxWindow *parent, int hgap/* = 0*/) :
|
||||||
wxFlexGridSizer(3, 0, hgap)
|
wxFlexGridSizer(3, 0, hgap)
|
||||||
{
|
{
|
||||||
SetFlexibleDirection(wxHORIZONTAL);
|
SetFlexibleDirection(wxHORIZONTAL);
|
||||||
|
@ -2869,15 +2872,8 @@ ModeSizer::ModeSizer(wxWindow *parent, int hgap/* = 10*/) :
|
||||||
|
|
||||||
m_mode_btns.reserve(3);
|
m_mode_btns.reserve(3);
|
||||||
for (const auto& button : buttons) {
|
for (const auto& button : buttons) {
|
||||||
#ifdef __WXOSX__
|
m_mode_btns.push_back(new ModeButton(parent, wxID_ANY, button.second, button.first));
|
||||||
wxSize sz = parent->GetTextExtent(button.first);
|
|
||||||
// set default width for ModeButtons to correct rendering on OnFocus under OSX
|
|
||||||
sz.x += 2 * em_unit(parent);
|
|
||||||
m_mode_btns.push_back(new ModeButton(parent, wxID_ANY, button.second, button.first, sz));
|
|
||||||
#else
|
|
||||||
m_mode_btns.push_back(new ModeButton(parent, wxID_ANY, button.second, button.first));;
|
|
||||||
#endif // __WXOSX__
|
|
||||||
|
|
||||||
m_mode_btns.back()->Bind(wxEVT_BUTTON, std::bind(modebtnfn, std::placeholders::_1, int(m_mode_btns.size() - 1)));
|
m_mode_btns.back()->Bind(wxEVT_BUTTON, std::bind(modebtnfn, std::placeholders::_1, int(m_mode_btns.size() - 1)));
|
||||||
Add(m_mode_btns.back());
|
Add(m_mode_btns.back());
|
||||||
}
|
}
|
||||||
|
|
|
@ -946,7 +946,7 @@ private:
|
||||||
class ModeSizer : public wxFlexGridSizer
|
class ModeSizer : public wxFlexGridSizer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ModeSizer( wxWindow *parent, int hgap = 10);
|
ModeSizer( wxWindow *parent, int hgap = 0);
|
||||||
~ModeSizer() {}
|
~ModeSizer() {}
|
||||||
|
|
||||||
void SetMode(const /*ConfigOptionMode*/int mode);
|
void SetMode(const /*ConfigOptionMode*/int mode);
|
||||||
|
|
Loading…
Reference in a new issue