-
Notifications
You must be signed in to change notification settings - Fork 0
/
PhysicalView.cpp
52 lines (41 loc) · 1.6 KB
/
PhysicalView.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
///////////////////////////////////////////////////////////////////
#include "GuitarView.h"
///////////////////////////////////////////////////////////////////
void
PhysicalView::init(Glib::RefPtr<Gtk::Builder> & builder, Glib::RefPtr<Gtk::Application> & app)
{
m_phyTreeView = builder->get_widget<Gtk::TreeView>("phy_treeview");
m_phyApplyButton = builder->get_widget<Gtk::Button>("phy_apply");
m_phyApplyButton->signal_clicked().connect(sigc::mem_fun(*this, &PhysicalView::phyApplyButtonClicked));
Gtk::TreeModelColumn<Glib::ustring> strcol;
Gtk::TreeModelColumnRecord columns;
columns.add(strcol);
m_phyModel = Gtk::ListStore::create(columns);
m_phyTreeView->set_model(m_phyModel);
m_phyTreeView->set_headers_visible();
static Gtk::TreeViewColumn column1("Physical Name", strcol);
m_phyTreeView->append_column(column1);
Glib::RefPtr<Gtk::TreeSelection> ts = m_phyTreeView->get_selection();
std::vector<std::string> names;
m_parent.m_guitarModel.getPhysicalNames(names);
for (const auto & name : names) {
auto iter = m_phyModel->append();
iter->set_value(0, name);
ts->select(iter);
}
}
//////////////////////////////////////////////////////////////////
void
PhysicalView::phyApplyButtonClicked()
{
Glib::RefPtr<Gtk::TreeSelection> ts = m_phyTreeView->get_selection();
if (!ts) return;
if (ts->count_selected_rows()==0) return;
Gtk::TreeModel::iterator i = ts->get_selected();
if (!i) return;
std::string name;
i->get_value(0, name);
m_parent.m_guitarModel.applyPhysical(name);
m_parent.m_neckView.m_drawingArea->queue_draw();
}
///////////////////////////////////////////////////////////////////