1 |
/* |
/* |
2 |
Copyright (c) 2014 Christian Schoenebeck |
Copyright (c) 2014,2015 Christian Schoenebeck |
3 |
|
|
4 |
This file is part of "gigedit" and released under the terms of the |
This file is part of "gigedit" and released under the terms of the |
5 |
GNU General Public License version 2. |
GNU General Public License version 2. |
31 |
#endif |
#endif |
32 |
m_descriptionLabel.set_text(_( |
m_descriptionLabel.set_text(_( |
33 |
"Selected sample is referenced by the following instruments and their " |
"Selected sample is referenced by the following instruments and their " |
34 |
"respective regions:" |
"respective regions. Click on a reference below to jump directly to " |
35 |
|
"its specific dimension region." |
36 |
)); |
)); |
37 |
|
|
38 |
m_refTreeModel = RefsTreeStore::create(m_columns); |
m_refTreeModel = RefsTreeStore::create(m_columns); |
39 |
m_treeView.set_model(m_refTreeModel); |
m_treeView.set_model(m_refTreeModel); |
40 |
m_treeView.set_tooltip_text(_( |
m_treeView.set_tooltip_text(_( |
41 |
"Amount of times the selected sample in question is referenced." |
"Amount of times the selected sample in question is referenced. Click " |
42 |
|
"to jump to the specific reference." |
43 |
)); |
)); |
44 |
m_treeView.append_column(_("Name"), m_columns.m_col_name); |
m_treeView.append_column(_("Name"), m_columns.m_col_name); |
45 |
m_treeView.append_column(_("References"), m_columns.m_col_refcount); |
m_treeView.append_column(_("References"), m_columns.m_col_refcount); |
46 |
m_treeView.set_headers_visible(true); |
m_treeView.set_headers_visible(true); |
47 |
//m_treeView.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE); |
m_treeView.get_selection()->set_mode(Gtk::SELECTION_SINGLE); |
48 |
//m_treeView.get_selection()->signal_changed().connect( |
m_treeView.get_selection()->signal_changed().connect( |
49 |
// sigc::mem_fun(*this, &ReferencesView::onSelectionChanged) |
sigc::mem_fun(*this, &ReferencesView::onSelectionChanged) |
50 |
//); |
); |
51 |
|
|
52 |
m_buttonBox.set_layout(Gtk::BUTTONBOX_END); |
m_buttonBox.set_layout(Gtk::BUTTONBOX_END); |
53 |
m_buttonBox.set_border_width(5); |
m_buttonBox.set_border_width(5); |
129 |
// unfold all instruments by default |
// unfold all instruments by default |
130 |
m_treeView.expand_all(); |
m_treeView.expand_all(); |
131 |
} |
} |
132 |
|
|
133 |
|
void ReferencesView::onSelectionChanged() { |
134 |
|
if (!m_sample) return; |
135 |
|
|
136 |
|
Glib::RefPtr<Gtk::TreeSelection> sel = m_treeView.get_selection(); |
137 |
|
Gtk::TreeModel::iterator it = sel->get_selected(); |
138 |
|
Gtk::TreeModel::Row row = *it; |
139 |
|
if (!it) return; |
140 |
|
gig::Instrument* pInstrument = row[m_columns.m_col_instr]; |
141 |
|
gig::Region* pRegion = row[m_columns.m_col_region]; |
142 |
|
gig::DimensionRegion* pDimRgn = NULL; |
143 |
|
if (pRegion) { |
144 |
|
// pick the 1st dimension region of that region referencing the sample |
145 |
|
for (int dr = 0; dr < pRegion->DimensionRegions && pRegion->pDimensionRegions[dr]; ++dr) { |
146 |
|
if (pRegion->pDimensionRegions[dr]->pSample == m_sample) { |
147 |
|
pDimRgn = pRegion->pDimensionRegions[dr]; |
148 |
|
break; |
149 |
|
} |
150 |
|
} |
151 |
|
} else if (pInstrument) { |
152 |
|
// pick the 1st region and its 1st dimension region referencing the sample |
153 |
|
for (pRegion = pInstrument->GetFirstRegion(); pRegion; pRegion = pInstrument->GetNextRegion()) { |
154 |
|
for (int dr = 0; dr < pRegion->DimensionRegions && pRegion->pDimensionRegions[dr]; ++dr) { |
155 |
|
if (pRegion->pDimensionRegions[dr]->pSample == m_sample) { |
156 |
|
pDimRgn = pRegion->pDimensionRegions[dr]; |
157 |
|
break; |
158 |
|
} |
159 |
|
} |
160 |
|
} |
161 |
|
} else { |
162 |
|
return; // no dimension region resolved to be selected, so do nothing |
163 |
|
} |
164 |
|
|
165 |
|
if (pDimRgn) { |
166 |
|
bool selectionSuccess = dimension_region_selected.emit(pDimRgn); |
167 |
|
if (selectionSuccess) hide(); |
168 |
|
} |
169 |
|
} |