CollapsiblePanes are putted to ScrolledWindow

This commit is contained in:
YuSanka 2018-05-09 14:36:20 +02:00
parent db549e8609
commit c07f347ff6
3 changed files with 65 additions and 101 deletions

View File

@ -809,17 +809,25 @@ wxString from_u8(const std::string &str)
void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFlexGridSizer* preset_sizer) void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFlexGridSizer* preset_sizer)
{ {
sizer->SetMinSize(-1, 300);
auto main_sizer = new wxBoxSizer(wxVERTICAL);
auto main_page = new wxScrolledWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
main_page->SetSizer(main_sizer);
main_page->SetScrollbars(1, 1, 1, 1);
sizer->Add(main_page, 1, wxEXPAND | wxALL, 1);
// Experiments with new UI // Experiments with new UI
wxCollapsiblePane *collpane = new wxCollapsiblePane(parent, wxID_ANY, "Print settings:"); wxCollapsiblePane *collpane = new wxCollapsiblePane(main_page, wxID_ANY, "Frequently Changing Parameters:");
collpane->Bind(wxEVT_COLLAPSIBLEPANE_CHANGED, ([parent, collpane](wxCommandEvent e){ collpane->Bind(wxEVT_COLLAPSIBLEPANE_CHANGED, ([parent, main_page, collpane](wxCommandEvent e){
wxWindowUpdateLocker noUpdates_cp(collpane); wxWindowUpdateLocker noUpdates_cp(collpane);
wxWindowUpdateLocker noUpdates(parent); wxWindowUpdateLocker noUpdates(main_page);
parent->Layout(); parent->Layout();
main_page->Layout();
collpane->Refresh(); collpane->Refresh();
})); }));
// add the pane with a zero proportion value to the sizer which contains it // add the pane with a zero proportion value to the sizer which contains it
sizer->Add(collpane, 0, wxGROW | wxALL, 0); main_sizer->Add(collpane, 0, wxGROW | wxALL, 0);
wxWindow *win = collpane->GetPane(); wxWindow *win = collpane->GetPane();
#ifdef __WXMSW__ #ifdef __WXMSW__
@ -943,8 +951,36 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl
}; };
m_optgroup->append_line(line); m_optgroup->append_line(line);
auto common_sizer = new wxBoxSizer(wxVERTICAL); wxSizer *paneSz = new wxBoxSizer(wxVERTICAL);
common_sizer->Add(m_optgroup->sizer); paneSz->Add(m_optgroup->sizer, 1, wxGROW | wxEXPAND | /*wxBOTTOM*/wxALL, /*2*/5);
win->SetSizer(paneSz);
paneSz->SetSizeHints(win);
wxCollapsiblePane *collpane_objects = new wxCollapsiblePane(main_page, wxID_ANY, "Objects List:");
collpane_objects->Bind(wxEVT_COLLAPSIBLEPANE_CHANGED, ([parent, main_page, collpane_objects](wxCommandEvent e){
wxWindowUpdateLocker noUpdates_cp(collpane_objects);
wxWindowUpdateLocker noUpdates(main_page);
parent->Layout();
main_page->Layout();
collpane_objects->Refresh();
}));
// add the pane with a zero proportion value to the sizer which contains it
main_sizer->Add(collpane_objects, 0, wxGROW | wxALL, 0);
wxWindow *win_objects = collpane_objects->GetPane();
#ifdef __WXMSW__
collpane_objects->GetControlWidget()->SetWindowStyleFlag(wxNO_BORDER);
collpane_objects->GetControlWidget()->SetBackgroundColour(clr);
collpane_objects->SetBackgroundColour(clr);
win_objects->SetBackgroundColour(clr);
#endif //__WXMSW__
// auto common_sizer = new wxBoxSizer(wxVERTICAL);
// common_sizer->Add(m_optgroup->sizer);
// auto listctrl = new wxDataViewListCtrl(win, wxID_ANY, wxDefaultPosition, wxSize(-1, 100)); // auto listctrl = new wxDataViewListCtrl(win, wxID_ANY, wxDefaultPosition, wxSize(-1, 100));
// listctrl->AppendToggleColumn("Toggle"); // listctrl->AppendToggleColumn("Toggle");
@ -964,9 +1000,10 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl
// common_sizer->Add(listctrl, 0, wxEXPAND | wxALL, 1); // common_sizer->Add(listctrl, 0, wxEXPAND | wxALL, 1);
// ********************************************************************************************** // **********************************************************************************************
auto objects_ctrl = new wxDataViewCtrl(win, wxID_ANY, wxDefaultPosition, wxDefaultSize); auto objects_ctrl = new wxDataViewCtrl(win_objects, wxID_ANY, wxDefaultPosition, wxDefaultSize);
wxSizer *objects_sz = new wxBoxSizer(wxVERTICAL); wxSizer *objects_sz = new wxBoxSizer(wxVERTICAL);
objects_ctrl->SetMinSize(wxSize(-1, 200)); objects_ctrl->SetBestFittingSize(wxSize(-1, 200));
// objects_ctrl->SetMinSize(wxSize(-1, 200));
objects_sz->Add(objects_ctrl, 1, wxGROW | wxALL, 5); objects_sz->Add(objects_ctrl, 1, wxGROW | wxALL, 5);
auto objects_model = new MyObjectTreeModel; auto objects_model = new MyObjectTreeModel;
@ -979,108 +1016,31 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl
// column 0 of the view control: // column 0 of the view control:
wxDataViewTextRenderer *tr = new wxDataViewTextRenderer("string", wxDATAVIEW_CELL_INERT); wxDataViewTextRenderer *tr = new wxDataViewTextRenderer("string", wxDATAVIEW_CELL_INERT);
wxDataViewColumn *column00 = new wxDataViewColumn("Name", tr, 0, 150, wxALIGN_LEFT, wxDataViewColumn *column00 = new wxDataViewColumn("Name", tr, 0, 140, wxALIGN_LEFT,
wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_RESIZABLE); wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_RESIZABLE);
objects_ctrl->AppendColumn(column00); objects_ctrl->AppendColumn(column00);
// column 1 of the view control: // column 1 of the view control:
tr = new wxDataViewTextRenderer("string", wxDATAVIEW_CELL_INERT); tr = new wxDataViewTextRenderer("string", wxDATAVIEW_CELL_INERT);
wxDataViewColumn *column01 = new wxDataViewColumn("Copy", tr, 1, 95, wxALIGN_CENTER_HORIZONTAL, wxDataViewColumn *column01 = new wxDataViewColumn("Copy", tr, 1, 75, wxALIGN_CENTER_HORIZONTAL,
wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_RESIZABLE); wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_RESIZABLE);
objects_ctrl->AppendColumn(column01); objects_ctrl->AppendColumn(column01);
// column 2 of the view control: // column 2 of the view control:
tr = new wxDataViewTextRenderer("string", wxDATAVIEW_CELL_INERT); tr = new wxDataViewTextRenderer("string", wxDATAVIEW_CELL_INERT);
wxDataViewColumn *column02 = new wxDataViewColumn("Scale", tr, 2, 95, wxALIGN_CENTER_HORIZONTAL, wxDataViewColumn *column02 = new wxDataViewColumn("Scale", tr, 2, 80, wxALIGN_CENTER_HORIZONTAL,
wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_RESIZABLE); wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_RESIZABLE);
objects_ctrl->AppendColumn(column02); objects_ctrl->AppendColumn(column02);
common_sizer->Add(objects_sz, 0, wxEXPAND | wxALL, 1); // common_sizer->Add(objects_sz, 0, wxEXPAND | wxALL, 1);
// ********************************************************************************************** wxSizer *paneSz_objects = new wxBoxSizer(wxVERTICAL);
/* auto view_ctrl = new wxDataViewCtrl(win, wxID_ANY, wxDefaultPosition, wxDefaultSize); paneSz_objects->Add(objects_sz, 1, wxGROW | wxEXPAND | wxBOTTOM, 2);
wxSizer *PanelSz = new wxBoxSizer(wxVERTICAL); win_objects->SetSizer(paneSz_objects);
view_ctrl->SetMinSize(wxSize(-1, 200)); paneSz_objects->SetSizeHints(win_objects);
PanelSz->Add(view_ctrl, 1, wxGROW | wxALL, 5);
PanelSz->Add( new wxStaticText(win, wxID_ANY, "Most of the cells above are editable!"), 0, wxGROW | wxALL, 5);
auto m_music_model = new MyMusicTreeModel;
view_ctrl->AssociateModel(m_music_model);
#if wxUSE_DRAG_AND_DROP && wxUSE_UNICODE
view_ctrl->EnableDragSource(wxDF_UNICODETEXT);
view_ctrl->EnableDropTarget(wxDF_UNICODETEXT);
#endif // wxUSE_DRAG_AND_DROP && wxUSE_UNICODE
// column 0 of the view control:
tr = new wxDataViewTextRenderer("string", wxDATAVIEW_CELL_INERT);
wxDataViewColumn *column0 =
new wxDataViewColumn("title", tr, 0, 150, wxALIGN_LEFT,
wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_RESIZABLE);
view_ctrl->AppendColumn(column0);
#if 0
// Call this and sorting is enabled
// immediately upon start up.
column0->SetAsSortKey();
#endif
// column 1 of the view control:
tr = new wxDataViewTextRenderer("string", wxDATAVIEW_CELL_EDITABLE);
wxDataViewColumn *column1 =
new wxDataViewColumn("artist", tr, 1, 150, wxALIGN_LEFT,
wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_REORDERABLE |
wxDATAVIEW_COL_RESIZABLE);
column1->SetMinWidth(100); // this column can't be resized to be smaller
view_ctrl->AppendColumn(column1);
// column 2 of the view control:
wxDataViewSpinRenderer *sr =
new wxDataViewSpinRenderer(0, 2010, wxDATAVIEW_CELL_EDITABLE,
wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
wxDataViewColumn *column2 =
new wxDataViewColumn("year", sr, 2, 60, wxALIGN_LEFT,
wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_REORDERABLE);
view_ctrl->AppendColumn(column2);
// column 3 of the view control:
wxArrayString choices;
choices.Add("good");
choices.Add("bad");
choices.Add("lousy");
wxDataViewChoiceRenderer *c =
new wxDataViewChoiceRenderer(choices, wxDATAVIEW_CELL_EDITABLE,
wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
wxDataViewColumn *column3 =
new wxDataViewColumn("rating", c, 3, 100, wxALIGN_LEFT,
wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_RESIZABLE);
view_ctrl->AppendColumn(column3);
// column 4 of the view control:
view_ctrl->AppendProgressColumn("popularity", 4, wxDATAVIEW_CELL_INERT, 80);
// column 5 of the view control:
MyCustomRenderer *cr = new MyCustomRenderer(wxDATAVIEW_CELL_ACTIVATABLE);
wxDataViewColumn *column5 =
new wxDataViewColumn("custom", cr, 5, -1, wxALIGN_LEFT,
wxDATAVIEW_COL_RESIZABLE);
view_ctrl->AppendColumn(column5);
// **********************************************************************************************
common_sizer->Add(PanelSz, 0, wxEXPAND | wxALL, 1);
*/
wxSizer *paneSz = new wxBoxSizer(wxVERTICAL);
paneSz->Add(common_sizer/*m_optgroup->sizer*/, 1, wxGROW | wxEXPAND | wxBOTTOM, 2);
win->SetSizer(paneSz);
paneSz->SetSizeHints(win);
} }
ConfigOptionsGroup* get_optgroup() ConfigOptionsGroup* get_optgroup()

View File

@ -186,9 +186,9 @@ MyObjectTreeModel::MyObjectTreeModel()
m_objects.emplace(root3); m_objects.emplace(root3);
auto root4 = new MyObjectTreeModelNode("Object4"); auto root4 = new MyObjectTreeModelNode("Object4");
m_objects.emplace(root4); m_objects.emplace(root4);
root4->Append(new MyObjectTreeModelNode(root2, "SubObject1")); root4->Append(new MyObjectTreeModelNode(root4, "SubObject1"));
root4->Append(new MyObjectTreeModelNode(root2, "SubObject2")); root4->Append(new MyObjectTreeModelNode(root4, "SubObject2"));
root4->Append(new MyObjectTreeModelNode(root2, "SubObject3")); root4->Append(new MyObjectTreeModelNode(root4, "SubObject3"));
} }
wxString MyObjectTreeModel::GetName(const wxDataViewItem &item) const wxString MyObjectTreeModel::GetName(const wxDataViewItem &item) const
@ -200,7 +200,7 @@ wxString MyObjectTreeModel::GetName(const wxDataViewItem &item) const
return node->m_name; return node->m_name;
} }
wxString MyObjectTreeModel::GetCopyCnt(const wxDataViewItem &item) const wxString MyObjectTreeModel::GetCopy(const wxDataViewItem &item) const
{ {
MyObjectTreeModelNode *node = (MyObjectTreeModelNode*)item.GetID(); MyObjectTreeModelNode *node = (MyObjectTreeModelNode*)item.GetID();
if (!node) // happens if item.IsOk()==false if (!node) // happens if item.IsOk()==false
@ -302,8 +302,8 @@ unsigned int MyObjectTreeModel::GetChildren(const wxDataViewItem &parent, wxData
MyObjectTreeModelNode *node = (MyObjectTreeModelNode*)parent.GetID(); MyObjectTreeModelNode *node = (MyObjectTreeModelNode*)parent.GetID();
if (!node) if (!node)
{ {
for (auto object: m_objects) for (auto object : m_objects)
array.Add(wxDataViewItem((void*)object)); array.Add(wxDataViewItem((void*)object));
return m_objects.size(); return m_objects.size();
} }

View File

@ -148,7 +148,7 @@ public:
// helper method for wxLog // helper method for wxLog
wxString GetName(const wxDataViewItem &item) const; wxString GetName(const wxDataViewItem &item) const;
wxString GetCopyCnt(const wxDataViewItem &item) const; wxString GetCopy(const wxDataViewItem &item) const;
wxString GetScale(const wxDataViewItem &item) const; wxString GetScale(const wxDataViewItem &item) const;
// helper methods to change the model // helper methods to change the model
@ -172,6 +172,10 @@ public:
virtual bool IsContainer(const wxDataViewItem &item) const override; virtual bool IsContainer(const wxDataViewItem &item) const override;
virtual unsigned int GetChildren(const wxDataViewItem &parent, virtual unsigned int GetChildren(const wxDataViewItem &parent,
wxDataViewItemArray &array) const override; wxDataViewItemArray &array) const override;
// Is the container just a header or an item with all columns
// In our case it is an item with all columns
virtual bool HasContainerColumns(const wxDataViewItem& WXUNUSED(item)) const override { return true; }
}; };