Code cleaning
This commit is contained in:
parent
896d898124
commit
9e4bea8cce
2 changed files with 15 additions and 95 deletions
|
@ -40,7 +40,7 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle)
|
|||
m_preset_bundle = preset_bundle;
|
||||
|
||||
// Vertical sizer to hold the choice menu and the rest of the page.
|
||||
//#ifdef __WXOSX__
|
||||
#ifdef __WXOSX__
|
||||
auto *main_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
main_sizer->SetSizeHints(this);
|
||||
this->SetSizer(main_sizer);
|
||||
|
@ -54,51 +54,16 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle)
|
|||
m_tmp_panel->Layout();
|
||||
|
||||
main_sizer->Add(m_tmp_panel, 1, wxEXPAND | wxALL, 0);
|
||||
// #else
|
||||
// Tab *panel = this;
|
||||
// auto *sizer = new wxBoxSizer(wxVERTICAL);
|
||||
// sizer->SetSizeHints(panel);
|
||||
// panel->SetSizer(sizer);
|
||||
// #endif //__WXOSX__
|
||||
#else
|
||||
Tab *panel = this;
|
||||
auto *sizer = new wxBoxSizer(wxVERTICAL);
|
||||
sizer->SetSizeHints(panel);
|
||||
panel->SetSizer(sizer);
|
||||
#endif //__WXOSX__
|
||||
|
||||
// preset chooser
|
||||
m_presets_choice = new wxBitmapComboBox(panel, wxID_ANY, "", wxDefaultPosition, wxSize(270, -1), 0, 0,wxCB_READONLY);
|
||||
/*
|
||||
m_cc_presets_choice = new wxComboCtrl(panel, wxID_ANY, L(""), wxDefaultPosition, wxDefaultSize, wxCB_READONLY);
|
||||
wxDataViewTreeCtrlComboPopup* popup = new wxDataViewTreeCtrlComboPopup;
|
||||
if (popup != nullptr)
|
||||
{
|
||||
// FIXME If the following line is removed, the combo box popup list will not react to mouse clicks.
|
||||
// On the other side, with this line the combo box popup cannot be closed by clicking on the combo button on Windows 10.
|
||||
// m_cc_presets_choice->UseAltPopupWindow();
|
||||
|
||||
// m_cc_presets_choice->EnablePopupAnimation(false);
|
||||
m_cc_presets_choice->SetPopupControl(popup);
|
||||
popup->SetStringValue(from_u8("Text1"));
|
||||
|
||||
popup->Bind(wxEVT_DATAVIEW_SELECTION_CHANGED, [this, popup](wxCommandEvent& evt)
|
||||
{
|
||||
auto selected = popup->GetItemText(popup->GetSelection());
|
||||
if (selected != _(L("System presets")) && selected != _(L("Default presets")))
|
||||
{
|
||||
m_cc_presets_choice->SetText(selected);
|
||||
std::string selected_string = selected.ToUTF8().data();
|
||||
#ifdef __APPLE__
|
||||
#else
|
||||
select_preset(selected_string);
|
||||
#endif
|
||||
}
|
||||
});
|
||||
|
||||
// popup->Bind(wxEVT_KEY_DOWN, [popup](wxKeyEvent& evt) { popup->OnKeyEvent(evt); });
|
||||
// popup->Bind(wxEVT_KEY_UP, [popup](wxKeyEvent& evt) { popup->OnKeyEvent(evt); });
|
||||
|
||||
auto icons = new wxImageList(16, 16, true, 1);
|
||||
popup->SetImageList(icons);
|
||||
icons->Add(*new wxIcon(from_u8(Slic3r::var("flag-green-icon.png")), wxBITMAP_TYPE_PNG));
|
||||
icons->Add(*new wxIcon(from_u8(Slic3r::var("flag-red-icon.png")), wxBITMAP_TYPE_PNG));
|
||||
}
|
||||
*/
|
||||
auto color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
|
||||
|
||||
//buttons
|
||||
|
@ -189,37 +154,6 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle)
|
|||
m_hsizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer->Add(m_hsizer, 1, wxEXPAND, 0);
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
//temporary left vertical sizer
|
||||
m_left_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
m_hsizer->Add(m_left_sizer, 0, wxEXPAND | wxLEFT | wxTOP | wxBOTTOM, 3);
|
||||
|
||||
// tree
|
||||
m_presetctrl = new wxDataViewTreeCtrl(panel, wxID_ANY, wxDefaultPosition, wxSize(200, -1), wxDV_NO_HEADER);
|
||||
m_left_sizer->Add(m_presetctrl, 1, wxEXPAND);
|
||||
m_preset_icons = new wxImageList(16, 16, true, 1);
|
||||
m_presetctrl->SetImageList(m_preset_icons);
|
||||
m_preset_icons->Add(*new wxIcon(from_u8(Slic3r::var("flag-green-icon.png")), wxBITMAP_TYPE_PNG));
|
||||
m_preset_icons->Add(*new wxIcon(from_u8(Slic3r::var("flag-red-icon.png")), wxBITMAP_TYPE_PNG));
|
||||
|
||||
m_presetctrl->Bind(wxEVT_DATAVIEW_SELECTION_CHANGED, [this](wxCommandEvent& evt)
|
||||
{
|
||||
auto selected = m_presetctrl->GetItemText(m_presetctrl->GetSelection());
|
||||
if (selected != _(L("System presets")) && selected != _(L("Default presets")))
|
||||
{
|
||||
std::string selected_string = selected.ToUTF8().data();
|
||||
#ifdef __APPLE__
|
||||
#else
|
||||
select_preset(selected_string);
|
||||
#endif
|
||||
}
|
||||
});
|
||||
|
||||
*/
|
||||
|
||||
//left vertical sizer
|
||||
m_left_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
m_hsizer->Add(m_left_sizer, 0, wxEXPAND | wxLEFT | wxTOP | wxBOTTOM, 3);
|
||||
|
@ -295,11 +229,11 @@ PageShp Tab::add_options_page(const wxString& title, const std::string& icon, bo
|
|||
}
|
||||
}
|
||||
// Initialize the page.
|
||||
//#ifdef __WXOSX__
|
||||
#ifdef __WXOSX__
|
||||
auto panel = m_tmp_panel;
|
||||
// #else
|
||||
// auto panel = this;
|
||||
// #endif
|
||||
#else
|
||||
auto panel = this;
|
||||
#endif
|
||||
PageShp page(new Page(panel, title, icon_idx));
|
||||
page->SetScrollbars(1, 1, 1, 1);
|
||||
page->Hide();
|
||||
|
@ -313,27 +247,14 @@ PageShp Tab::add_options_page(const wxString& title, const std::string& icon, bo
|
|||
|
||||
void Tab::OnActivate()
|
||||
{
|
||||
// #ifdef __WXOSX__
|
||||
#ifdef __WXOSX__
|
||||
wxWindowUpdateLocker noUpdates(this);
|
||||
|
||||
auto size = GetSizer()->GetSize();
|
||||
m_tmp_panel->GetSizer()->SetMinSize(size.x + m_size_move, size.y);
|
||||
Fit();
|
||||
m_size_move *= -1;
|
||||
|
||||
// Page* page = nullptr;
|
||||
// auto selection = m_treectrl->GetItemText(m_treectrl->GetSelection());
|
||||
// for (auto p : m_pages)
|
||||
// if (p->title() == selection)
|
||||
// {
|
||||
// page = p.get();
|
||||
// break;
|
||||
// }
|
||||
// if (page == nullptr) return;
|
||||
// page->Fit();
|
||||
// m_hsizer->Layout();
|
||||
// Refresh();
|
||||
// #endif // __WXOSX__
|
||||
#endif // __WXOSX__
|
||||
}
|
||||
|
||||
void Tab::update_labels_colour()
|
||||
|
@ -2134,7 +2055,6 @@ void Tab::OnTreeSelChange(wxTreeEvent& event)
|
|||
#endif
|
||||
|
||||
page->Show();
|
||||
page->Fit();
|
||||
m_hsizer->Layout();
|
||||
Refresh();
|
||||
|
||||
|
|
|
@ -102,10 +102,10 @@ using PageShp = std::shared_ptr<Page>;
|
|||
class Tab: public wxPanel
|
||||
{
|
||||
wxNotebook* m_parent;
|
||||
//#ifdef __WXOSX__
|
||||
#ifdef __WXOSX__
|
||||
wxPanel* m_tmp_panel;
|
||||
int m_size_move = -1;
|
||||
//#endif // __WXOSX__
|
||||
#endif // __WXOSX__
|
||||
protected:
|
||||
std::string m_name;
|
||||
const wxString m_title;
|
||||
|
|
Loading…
Add table
Reference in a new issue