mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-12 02:39:06 +08:00
Code cleaning
This commit is contained in:
parent
896d898124
commit
9e4bea8cce
@ -40,7 +40,7 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle)
|
|||||||
m_preset_bundle = preset_bundle;
|
m_preset_bundle = preset_bundle;
|
||||||
|
|
||||||
// Vertical sizer to hold the choice menu and the rest of the page.
|
// Vertical sizer to hold the choice menu and the rest of the page.
|
||||||
//#ifdef __WXOSX__
|
#ifdef __WXOSX__
|
||||||
auto *main_sizer = new wxBoxSizer(wxVERTICAL);
|
auto *main_sizer = new wxBoxSizer(wxVERTICAL);
|
||||||
main_sizer->SetSizeHints(this);
|
main_sizer->SetSizeHints(this);
|
||||||
this->SetSizer(main_sizer);
|
this->SetSizer(main_sizer);
|
||||||
@ -54,51 +54,16 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle)
|
|||||||
m_tmp_panel->Layout();
|
m_tmp_panel->Layout();
|
||||||
|
|
||||||
main_sizer->Add(m_tmp_panel, 1, wxEXPAND | wxALL, 0);
|
main_sizer->Add(m_tmp_panel, 1, wxEXPAND | wxALL, 0);
|
||||||
// #else
|
#else
|
||||||
// Tab *panel = this;
|
Tab *panel = this;
|
||||||
// auto *sizer = new wxBoxSizer(wxVERTICAL);
|
auto *sizer = new wxBoxSizer(wxVERTICAL);
|
||||||
// sizer->SetSizeHints(panel);
|
sizer->SetSizeHints(panel);
|
||||||
// panel->SetSizer(sizer);
|
panel->SetSizer(sizer);
|
||||||
// #endif //__WXOSX__
|
#endif //__WXOSX__
|
||||||
|
|
||||||
// preset chooser
|
// preset chooser
|
||||||
m_presets_choice = new wxBitmapComboBox(panel, wxID_ANY, "", wxDefaultPosition, wxSize(270, -1), 0, 0,wxCB_READONLY);
|
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);
|
auto color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
|
||||||
|
|
||||||
//buttons
|
//buttons
|
||||||
@ -189,37 +154,6 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle)
|
|||||||
m_hsizer = new wxBoxSizer(wxHORIZONTAL);
|
m_hsizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
sizer->Add(m_hsizer, 1, wxEXPAND, 0);
|
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
|
//left vertical sizer
|
||||||
m_left_sizer = new wxBoxSizer(wxVERTICAL);
|
m_left_sizer = new wxBoxSizer(wxVERTICAL);
|
||||||
m_hsizer->Add(m_left_sizer, 0, wxEXPAND | wxLEFT | wxTOP | wxBOTTOM, 3);
|
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.
|
// Initialize the page.
|
||||||
//#ifdef __WXOSX__
|
#ifdef __WXOSX__
|
||||||
auto panel = m_tmp_panel;
|
auto panel = m_tmp_panel;
|
||||||
// #else
|
#else
|
||||||
// auto panel = this;
|
auto panel = this;
|
||||||
// #endif
|
#endif
|
||||||
PageShp page(new Page(panel, title, icon_idx));
|
PageShp page(new Page(panel, title, icon_idx));
|
||||||
page->SetScrollbars(1, 1, 1, 1);
|
page->SetScrollbars(1, 1, 1, 1);
|
||||||
page->Hide();
|
page->Hide();
|
||||||
@ -313,27 +247,14 @@ PageShp Tab::add_options_page(const wxString& title, const std::string& icon, bo
|
|||||||
|
|
||||||
void Tab::OnActivate()
|
void Tab::OnActivate()
|
||||||
{
|
{
|
||||||
// #ifdef __WXOSX__
|
#ifdef __WXOSX__
|
||||||
wxWindowUpdateLocker noUpdates(this);
|
wxWindowUpdateLocker noUpdates(this);
|
||||||
|
|
||||||
auto size = GetSizer()->GetSize();
|
auto size = GetSizer()->GetSize();
|
||||||
m_tmp_panel->GetSizer()->SetMinSize(size.x + m_size_move, size.y);
|
m_tmp_panel->GetSizer()->SetMinSize(size.x + m_size_move, size.y);
|
||||||
Fit();
|
Fit();
|
||||||
m_size_move *= -1;
|
m_size_move *= -1;
|
||||||
|
#endif // __WXOSX__
|
||||||
// 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__
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tab::update_labels_colour()
|
void Tab::update_labels_colour()
|
||||||
@ -2134,7 +2055,6 @@ void Tab::OnTreeSelChange(wxTreeEvent& event)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
page->Show();
|
page->Show();
|
||||||
page->Fit();
|
|
||||||
m_hsizer->Layout();
|
m_hsizer->Layout();
|
||||||
Refresh();
|
Refresh();
|
||||||
|
|
||||||
|
@ -102,10 +102,10 @@ using PageShp = std::shared_ptr<Page>;
|
|||||||
class Tab: public wxPanel
|
class Tab: public wxPanel
|
||||||
{
|
{
|
||||||
wxNotebook* m_parent;
|
wxNotebook* m_parent;
|
||||||
//#ifdef __WXOSX__
|
#ifdef __WXOSX__
|
||||||
wxPanel* m_tmp_panel;
|
wxPanel* m_tmp_panel;
|
||||||
int m_size_move = -1;
|
int m_size_move = -1;
|
||||||
//#endif // __WXOSX__
|
#endif // __WXOSX__
|
||||||
protected:
|
protected:
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
const wxString m_title;
|
const wxString m_title;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user