Page class is used as a container of option groups
and doesn't inherited from wxScrolledWindow now
This commit is contained in:
parent
8fb3a44a4e
commit
d5bd76776f
7 changed files with 80 additions and 38 deletions
|
@ -34,6 +34,7 @@ ObjectLayers::ObjectLayers(wxWindow* parent) :
|
|||
m_grid_sizer->Add(temp);
|
||||
}
|
||||
|
||||
m_og->activate();
|
||||
m_og->sizer->Clear(true);
|
||||
m_og->sizer->Add(m_grid_sizer, 0, wxEXPAND | wxALL, wxOSX ? 0 : 5);
|
||||
|
||||
|
|
|
@ -431,6 +431,7 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
|
|||
|
||||
m_main_grid_sizer->Add(m_check_inch, 1, wxEXPAND);
|
||||
|
||||
m_og->activate();
|
||||
m_og->sizer->Clear(true);
|
||||
m_og->sizer->Add(m_main_grid_sizer, 1, wxEXPAND | wxALL, border);
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@ wxSizer* OG_Settings::get_sizer()
|
|||
ObjectSettings::ObjectSettings(wxWindow* parent) :
|
||||
OG_Settings(parent, true)
|
||||
{
|
||||
m_og->activate();
|
||||
m_og->set_name(_(L("Additional Settings")));
|
||||
|
||||
m_settings_list_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
|
|
@ -110,13 +110,13 @@ OptionsGroup::OptionsGroup( wxWindow* _parent, const wxString& title,
|
|||
m_show_modified_btns(is_tab_opt),
|
||||
staticbox(title!=""), extra_column(extra_clmn)
|
||||
{
|
||||
if (staticbox) {
|
||||
/*if (staticbox) {
|
||||
stb = new wxStaticBox(_parent, wxID_ANY, _(title));
|
||||
if (!wxOSX) stb->SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||
stb->SetFont(wxOSX ? wxGetApp().normal_font() : wxGetApp().bold_font());
|
||||
} else
|
||||
stb = nullptr;
|
||||
sizer = (staticbox ? new wxStaticBoxSizer(stb, wxVERTICAL) : new wxBoxSizer(wxVERTICAL));
|
||||
sizer = (staticbox ? new wxStaticBoxSizer(stb, wxVERTICAL) : new wxBoxSizer(wxVERTICAL));*/
|
||||
}
|
||||
|
||||
void OptionsGroup::add_undo_buttons_to_sizer(wxSizer* sizer, const t_field& field)
|
||||
|
@ -362,10 +362,19 @@ void OptionsGroup::activate_line(Line& line)
|
|||
}
|
||||
|
||||
// create all controls for the option group from the m_lines
|
||||
void OptionsGroup::activate()
|
||||
bool OptionsGroup::activate()
|
||||
{
|
||||
if (!sizer->IsEmpty())
|
||||
return;
|
||||
if (sizer)//(!sizer->IsEmpty())
|
||||
return false;
|
||||
|
||||
if (staticbox) {
|
||||
stb = new wxStaticBox(m_parent, wxID_ANY, _(title));
|
||||
if (!wxOSX) stb->SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||
stb->SetFont(wxOSX ? wxGetApp().normal_font() : wxGetApp().bold_font());
|
||||
}
|
||||
else
|
||||
stb = nullptr;
|
||||
sizer = (staticbox ? new wxStaticBoxSizer(stb, wxVERTICAL) : new wxBoxSizer(wxVERTICAL));
|
||||
|
||||
auto num_columns = 1U;
|
||||
size_t grow_col = 1;
|
||||
|
@ -389,24 +398,30 @@ void OptionsGroup::activate()
|
|||
// activate lines
|
||||
for (Line& line: m_lines)
|
||||
activate_line(line);
|
||||
|
||||
return true;
|
||||
}
|
||||
// delete all controls from the option group
|
||||
void OptionsGroup::clear()
|
||||
{
|
||||
if (sizer->IsEmpty())
|
||||
if (!sizer)//(sizer->IsEmpty())
|
||||
return;
|
||||
|
||||
m_grid_sizer->Clear(true);
|
||||
sizer->Clear(true);
|
||||
// m_grid_sizer->Clear(true);
|
||||
m_grid_sizer = nullptr;
|
||||
|
||||
// sizer->Clear(true);
|
||||
//if (stb) {
|
||||
// stb->SetContainingSizer(NULL);
|
||||
// stb->Destroy();
|
||||
//}
|
||||
sizer = nullptr;
|
||||
|
||||
for (Line& line : m_lines)
|
||||
if(line.full_Label)
|
||||
*line.full_Label = nullptr;
|
||||
|
||||
//for (auto extra_col_win : m_extra_column_item_ptrs)
|
||||
// destroy(extra_col_win);
|
||||
m_extra_column_item_ptrs.clear();
|
||||
|
||||
m_near_label_widget_ptrs.clear();
|
||||
m_fields.clear();
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ public:
|
|||
void activate_line(Line& line);
|
||||
|
||||
// create all controls for the option group from the m_lines
|
||||
void activate();
|
||||
bool activate();
|
||||
// delete all controls from the option group
|
||||
void clear();
|
||||
|
||||
|
|
|
@ -296,6 +296,19 @@ void Tab::create_preset_tab()
|
|||
m_treectrl->Bind(wxEVT_TREE_SEL_CHANGED, &Tab::OnTreeSelChange, this);
|
||||
m_treectrl->Bind(wxEVT_KEY_DOWN, &Tab::OnKeyDown, this);
|
||||
|
||||
// Initialize the page.
|
||||
#ifdef __WXOSX__
|
||||
auto page_parent = m_tmp_panel;
|
||||
#else
|
||||
auto page_parent = this;
|
||||
#endif
|
||||
|
||||
m_page_view = new wxScrolledWindow(page_parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
|
||||
m_page_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
m_page_view->SetSizer(m_page_sizer);
|
||||
m_page_view->SetScrollbars(1, 20, 1, 2);
|
||||
m_hsizer->Add(m_page_view, 1, wxEXPAND | wxLEFT, 5);
|
||||
|
||||
m_btn_save_preset->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e) { save_preset(); }));
|
||||
m_btn_delete_preset->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e) { delete_preset(); }));
|
||||
m_btn_hide_incompatible_presets->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e) {
|
||||
|
@ -368,15 +381,16 @@ Slic3r::GUI::PageShp Tab::add_options_page(const wxString& title, const std::str
|
|||
#else
|
||||
auto panel = this;
|
||||
#endif
|
||||
PageShp page(new Page(panel, title, icon_idx, m_mode_bitmap_cache));
|
||||
PageShp page(new Page(/*panel*/m_page_view, title, icon_idx, m_mode_bitmap_cache));
|
||||
// page->SetBackgroundStyle(wxBG_STYLE_SYSTEM);
|
||||
#ifdef __WINDOWS__
|
||||
// page->SetDoubleBuffered(true);
|
||||
#endif //__WINDOWS__
|
||||
|
||||
page->SetScrollbars(1, 20, 1, 2);
|
||||
page->Hide();
|
||||
m_hsizer->Add(page.get(), 1, wxEXPAND | wxLEFT, 5);
|
||||
//page->SetScrollbars(1, 20, 1, 2);
|
||||
//page->Hide();
|
||||
//m_hsizer->Add(page.get(), 1, wxEXPAND | wxLEFT, 5);
|
||||
// m_hsizer->Add(page->vsizer(), 1, wxEXPAND | wxLEFT, 5);
|
||||
|
||||
if (!is_extruder_pages)
|
||||
m_pages.push_back(page);
|
||||
|
@ -398,7 +412,7 @@ void Tab::OnActivate()
|
|||
|
||||
// create controls on active page
|
||||
active_selected_page();
|
||||
m_active_page->Show();
|
||||
// m_active_page->Show();
|
||||
m_hsizer->Layout();
|
||||
Refresh();
|
||||
}
|
||||
|
@ -2562,12 +2576,12 @@ void TabPrinter::build_unregular_pages()
|
|||
/* Workaround for correct layout of controls inside the created page:
|
||||
* In some _strange_ way we should we should imitate page resizing.
|
||||
*/
|
||||
auto layout_page = [this](PageShp page)
|
||||
/* auto layout_page = [this](PageShp page)
|
||||
{
|
||||
const wxSize& sz = page->GetSize();
|
||||
page->SetSize(sz.x + 1, sz.y + 1);
|
||||
page->SetSize(sz);
|
||||
};
|
||||
};*/
|
||||
#endif //__WXMSW__
|
||||
|
||||
// Add/delete Kinematics page according to is_marlin_flavor
|
||||
|
@ -2584,7 +2598,7 @@ void TabPrinter::build_unregular_pages()
|
|||
if (existed_page < n_before_extruders && is_marlin_flavor) {
|
||||
auto page = build_kinematics_page();
|
||||
#ifdef __WXMSW__
|
||||
layout_page(page);
|
||||
// layout_page(page);
|
||||
#endif
|
||||
m_pages.insert(m_pages.begin() + n_before_extruders, page);
|
||||
}
|
||||
|
@ -2722,7 +2736,7 @@ void TabPrinter::build_unregular_pages()
|
|||
optgroup->append_line(line);
|
||||
|
||||
#ifdef __WXMSW__
|
||||
layout_page(page);
|
||||
// layout_page(page);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -2762,8 +2776,8 @@ void TabPrinter::update_pages()
|
|||
return;
|
||||
|
||||
// hide all old pages
|
||||
for (auto& el : m_pages)
|
||||
el.get()->Hide();
|
||||
//for (auto& el : m_pages)
|
||||
// el.get()->Hide();
|
||||
|
||||
// set m_pages to m_pages_(technology before changing)
|
||||
m_printer_technology == ptFFF ? m_pages.swap(m_pages_fff) : m_pages.swap(m_pages_sla);
|
||||
|
@ -3320,9 +3334,11 @@ void Tab::clear_pages()
|
|||
{
|
||||
// invalidated highlighter, if any exists
|
||||
m_highlighter.invalidate();
|
||||
m_page_sizer->Clear(true);
|
||||
// clear pages from the controlls
|
||||
for (auto p : m_pages)
|
||||
p->clear();
|
||||
p->clear();
|
||||
int i = m_page_sizer->GetItemCount();
|
||||
|
||||
// nulling pointers
|
||||
m_parent_preset_description_line = nullptr;
|
||||
|
@ -3369,7 +3385,7 @@ void Tab::OnTreeSelChange(wxTreeEvent& event)
|
|||
* so on Window is no needed to call a Freeze/Thaw functions.
|
||||
* But under OSX (builds compiled with MacOSX10.14.sdk) wxStaticBitmap rendering is broken without Freeze/Thaw call.
|
||||
*/
|
||||
//#ifdef __WXOSX__ // Use Freeze/Thaw to avoid flickering during cleare/activate new page
|
||||
//#ifdef __WXOSX__ // Use Freeze/Thaw to avoid flickering during clear/activate new page
|
||||
wxWindowUpdateLocker noUpdates(this);
|
||||
//#endif
|
||||
#endif
|
||||
|
@ -3394,12 +3410,12 @@ void Tab::OnTreeSelChange(wxTreeEvent& event)
|
|||
m_active_page = page;
|
||||
clear_pages();
|
||||
|
||||
for (auto& el : m_pages)
|
||||
el.get()->Hide();
|
||||
//for (auto& el : m_pages)
|
||||
// el.get()->Hide();
|
||||
|
||||
if (wxGetApp().mainframe->is_active_and_shown_tab(this)) {
|
||||
active_selected_page();
|
||||
m_active_page->Show();
|
||||
// m_active_page->Show();
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
|
@ -3843,10 +3859,11 @@ Page::Page(wxWindow* parent, const wxString& title, const int iconID, const std:
|
|||
m_iconID(iconID),
|
||||
m_mode_bitmap_cache(mode_bmp_cache)
|
||||
{
|
||||
Create(m_parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
|
||||
m_vsizer = new wxBoxSizer(wxVERTICAL);
|
||||
// Create(m_parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
|
||||
// m_vsizer = new wxBoxSizer(wxVERTICAL);
|
||||
m_vsizer = (wxBoxSizer*)parent->GetSizer();
|
||||
m_item_color = &wxGetApp().get_label_clr_default();
|
||||
SetSizer(m_vsizer);
|
||||
// SetSizer(m_vsizer);
|
||||
}
|
||||
|
||||
void Page::reload_config()
|
||||
|
@ -3870,8 +3887,12 @@ void Page::update_visibility(ConfigOptionMode mode, bool update_contolls_visibil
|
|||
|
||||
void Page::activate(ConfigOptionMode mode)
|
||||
{
|
||||
//if (m_parent)
|
||||
//m_parent->SetSizer(m_vsizer);
|
||||
for (auto group : m_optgroups) {
|
||||
group->activate();
|
||||
if (!group->activate())
|
||||
continue;
|
||||
m_vsizer->Add(group->sizer, 0, wxEXPAND | wxALL, 10);
|
||||
group->update_visibility(mode);
|
||||
group->reload_config();
|
||||
}
|
||||
|
@ -3910,7 +3931,7 @@ bool Page::set_value(const t_config_option_key& opt_key, const boost::any& value
|
|||
bool changed = false;
|
||||
for(auto optgroup: m_optgroups) {
|
||||
if (optgroup->set_value(opt_key, value))
|
||||
changed = 1 ;
|
||||
changed = true ;
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
@ -3933,15 +3954,15 @@ ConfigOptionsGroupShp Page::new_optgroup(const wxString& title, int noncommon_la
|
|||
};
|
||||
|
||||
//! config_ have to be "right"
|
||||
ConfigOptionsGroupShp optgroup = std::make_shared<ConfigOptionsGroup>(this, title, m_config, true, extra_column);
|
||||
ConfigOptionsGroupShp optgroup = std::make_shared<ConfigOptionsGroup>(/*this*/m_parent, title, m_config, true, extra_column);
|
||||
optgroup->config_category = m_title.ToStdString();
|
||||
if (noncommon_label_width >= 0)
|
||||
optgroup->label_width = noncommon_label_width;
|
||||
|
||||
#ifdef __WXOSX__
|
||||
auto tab = GetParent()->GetParent();
|
||||
auto tab = parent()->GetParent()->GetParent();// GetParent()->GetParent();
|
||||
#else
|
||||
auto tab = GetParent();
|
||||
auto tab = parent()->GetParent();// GetParent();
|
||||
#endif
|
||||
optgroup->m_on_change = [this, tab](t_config_option_key opt_key, boost::any value) {
|
||||
//! This function will be called from OptionGroup.
|
||||
|
@ -3975,7 +3996,7 @@ ConfigOptionsGroupShp Page::new_optgroup(const wxString& title, int noncommon_la
|
|||
ctrl->SetBitmap(reinterpret_cast<ScalableBitmap*>(ctrl->GetClientData())->bmp());
|
||||
};
|
||||
|
||||
vsizer()->Add(optgroup->sizer, 0, wxEXPAND | wxALL, 10);
|
||||
// vsizer()->Add(optgroup->sizer, 0, wxEXPAND | wxALL, 10);
|
||||
m_optgroups.push_back(optgroup);
|
||||
|
||||
return optgroup;
|
||||
|
|
|
@ -44,7 +44,7 @@ class TabPresetComboBox;
|
|||
// Single Tab page containing a{ vsizer } of{ optgroups }
|
||||
// package Slic3r::GUI::Tab::Page;
|
||||
using ConfigOptionsGroupShp = std::shared_ptr<ConfigOptionsGroup>;
|
||||
class Page : public wxScrolledWindow
|
||||
class Page// : public wxScrolledWindow
|
||||
{
|
||||
wxWindow* m_parent;
|
||||
wxString m_title;
|
||||
|
@ -127,6 +127,9 @@ protected:
|
|||
wxTreeCtrl* m_treectrl;
|
||||
wxImageList* m_icons;
|
||||
|
||||
wxScrolledWindow* m_page_view {nullptr};
|
||||
wxBoxSizer* m_page_sizer {nullptr};
|
||||
|
||||
ModeSizer* m_mode_sizer;
|
||||
|
||||
struct PresetDependencies {
|
||||
|
|
Loading…
Reference in a new issue