--- gigedit/trunk/src/gigedit/mainwindow.cpp 2014/06/11 20:26:26 2624
+++ gigedit/trunk/src/gigedit/mainwindow.cpp 2014/07/05 19:43:14 2664
@@ -53,6 +53,7 @@
MainWindow::MainWindow() :
+ m_DimRegionChooser(*this),
dimreg_label(_("Changes apply to:")),
dimreg_all_regions(_("all regions")),
dimreg_all_dimregs(_("all dimension splits")),
@@ -146,8 +147,19 @@
actionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT),
sigc::mem_fun(
*this, &MainWindow::on_action_quit));
- actionGroup->add(Gtk::Action::create("MenuInstrument", _("_Instrument")));
-
+ actionGroup->add(
+ Gtk::Action::create("MenuSample", _("_Sample")),
+ sigc::mem_fun(*this, &MainWindow::show_samples_tab)
+ );
+ actionGroup->add(
+ Gtk::Action::create("MenuInstrument", _("_Instrument")),
+ sigc::mem_fun(*this, &MainWindow::show_intruments_tab)
+ );
+ actionGroup->add(
+ Gtk::Action::create("MenuScript", _("S_cript")),
+ sigc::mem_fun(*this, &MainWindow::show_scripts_tab)
+ );
+ actionGroup->add(Gtk::Action::create("AllInstruments", _("_Select")));
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit")));
@@ -287,7 +299,33 @@
" "
" "
" "
+ "
"
" "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
" "
" "
" "
@@ -370,7 +408,7 @@
instrument_menu = static_cast(
- uiManager->get_widget("/MenuBar/MenuInstrument"))->get_submenu();
+ uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments"))->get_submenu();
Gtk::Widget* menuBar = uiManager->get_widget("/MenuBar");
m_VBox.pack_start(*menuBar, Gtk::PACK_SHRINK);
@@ -415,7 +453,7 @@
{
Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(0);
Gtk::CellRendererText* cellrenderer =
- dynamic_cast(column->get_first_cell_renderer());
+ dynamic_cast(column->get_first_cell());
column->add_attribute(
cellrenderer->property_foreground(), m_SamplesModel.m_color
);
@@ -423,7 +461,7 @@
{
Gtk::TreeViewColumn* column = m_TreeViewSamples.get_column(1);
Gtk::CellRendererText* cellrenderer =
- dynamic_cast(column->get_first_cell_renderer());
+ dynamic_cast(column->get_first_cell());
column->add_attribute(
cellrenderer->property_foreground(), m_SamplesModel.m_color
);
@@ -440,6 +478,8 @@
m_refScriptsTreeModel = ScriptsTreeStore::create(m_ScriptsModel);
m_TreeViewScripts.set_model(m_refScriptsTreeModel);
m_TreeViewScripts.set_tooltip_text(_(
+ "Use CTRL + double click for editing a script."
+ "\n\n"
"Note: instrument scripts are a LinuxSampler extension of the gig "
"format. This feature will not work with the GigaStudio software!"
));
@@ -449,6 +489,10 @@
m_TreeViewScripts.signal_button_press_event().connect_notify(
sigc::mem_fun(*this, &MainWindow::on_script_treeview_button_release)
);
+ //FIXME: why the heck does this double click signal_row_activated() only fired while CTRL key is pressed ?
+ m_TreeViewScripts.signal_row_activated().connect(
+ sigc::mem_fun(*this, &MainWindow::script_double_clicked)
+ );
m_refScriptsTreeModel->signal_row_changed().connect(
sigc::mem_fun(*this, &MainWindow::script_name_changed)
);
@@ -628,7 +672,7 @@
void MainWindow::dimreg_changed()
{
update_dimregs();
- dimreg_edit.set_dim_region(m_DimRegionChooser.get_dimregion());
+ dimreg_edit.set_dim_region(m_DimRegionChooser.get_main_dimregion());
}
void MainWindow::on_sel_change()
@@ -858,7 +902,28 @@
// load the instrument
gig::File* pFile = (gig::File*) instr->GetParent();
load_gig(pFile, 0 /*file name*/, true /*shared instrument*/);
- //TODO: automatically select the given instrument
+ // automatically select the given instrument
+ int i = 0;
+ for (gig::Instrument* instrument = pFile->GetFirstInstrument(); instrument;
+ instrument = pFile->GetNextInstrument(), ++i)
+ {
+ if (instrument == instr) {
+ // select item in "instruments" tree view
+ m_TreeView.get_selection()->select(Gtk::TreePath(ToString(i)));
+ // make sure the selected item in the "instruments" tree view is
+ // visible (scroll to it)
+ m_TreeView.scroll_to_row(Gtk::TreePath(ToString(i)));
+ // select item in instrument menu
+ {
+ const std::vector children =
+ instrument_menu->get_children();
+ static_cast(children[i])->set_active();
+ }
+ // update region chooser and dimension region chooser
+ m_RegionChooser.set_instrument(instr);
+ break;
+ }
+ }
}
void MainWindow::on_loader_progress()
@@ -1139,8 +1204,8 @@
_(
"Gigedit is released under the GNU General Public License.\n"
"\n"
- "Please notice that this is still a very young instrument editor. "
- "So better backup your Gigasampler files before editing them with "
+ "This program is distributed WITHOUT ANY WARRANTY; So better "
+ "backup your Gigasampler/GigaStudio files before editing them with "
"this application.\n"
"\n"
"Please report bugs to: http://bugs.linuxsampler.org"
@@ -1436,7 +1501,7 @@
add_instrument_to_menu(name);
}
instrument_name_connection.unblock();
- uiManager->get_widget("/MenuBar/MenuInstrument")->show();
+ uiManager->get_widget("/MenuBar/MenuInstrument/AllInstruments")->show();
updateSampleRefCountMap(gig);
@@ -1458,7 +1523,7 @@
rowSample[m_SamplesModel.m_col_group] = NULL;
int refcount = sample_ref_count.count(sample) ? sample_ref_count[sample] : 0;
rowSample[m_SamplesModel.m_col_refcount] = ToString(refcount) + " " + _("Refs.");
- rowSample[m_SamplesModel.m_color] = refcount ? "black" : "gray";
+ rowSample[m_SamplesModel.m_color] = refcount ? "black" : "red";
}
}
}
@@ -1616,9 +1681,15 @@
show_instr_props();
} else if (button->type == GDK_BUTTON_PRESS && button->button == 3) {
// gig v2 files have no midi rules
+ const bool bEnabled = !(file->pVersion && file->pVersion->major == 2);
+ static_cast(
+ uiManager->get_widget("/MenuBar/MenuInstrument/MidiRules"))->set_sensitive(
+ bEnabled
+ );
static_cast(
uiManager->get_widget("/PopupMenu/MidiRules"))->set_sensitive(
- !(file->pVersion && file->pVersion->major == 2));
+ bEnabled
+ );
popup_menu->popup(button->button, button->time);
}
}
@@ -1652,6 +1723,8 @@
group_selected = row[m_SamplesModel.m_col_group];
sample_selected = row[m_SamplesModel.m_col_sample];
}
+
+
dynamic_cast(uiManager->get_widget("/SamplePopupMenu/SampleProperties"))->
set_sensitive(group_selected || sample_selected);
dynamic_cast(uiManager->get_widget("/SamplePopupMenu/AddSample"))->
@@ -1664,6 +1737,17 @@
set_sensitive(group_selected || sample_selected);
// show sample popup
sample_popup->popup(button->button, button->time);
+
+ dynamic_cast(uiManager->get_widget("/MenuBar/MenuSample/SampleProperties"))->
+ set_sensitive(group_selected || sample_selected);
+ dynamic_cast(uiManager->get_widget("/MenuBar/MenuSample/AddSample"))->
+ set_sensitive(group_selected || sample_selected);
+ dynamic_cast(uiManager->get_widget("/MenuBar/MenuSample/AddGroup"))->
+ set_sensitive(file);
+ dynamic_cast(uiManager->get_widget("/MenuBar/MenuSample/ShowSampleRefs"))->
+ set_sensitive(sample_selected);
+ dynamic_cast(uiManager->get_widget("/MenuBar/MenuSample/RemoveSample"))->
+ set_sensitive(group_selected || sample_selected);
}
}
@@ -1691,6 +1775,15 @@
set_sensitive(group_selected || script_selected);
// show sample popup
script_popup->popup(button->button, button->time);
+
+ dynamic_cast(uiManager->get_widget("/MenuBar/MenuScript/AddScript"))->
+ set_sensitive(group_selected || script_selected);
+ dynamic_cast(uiManager->get_widget("/MenuBar/MenuScript/AddScriptGroup"))->
+ set_sensitive(file);
+ dynamic_cast(uiManager->get_widget("/MenuBar/MenuScript/EditScript"))->
+ set_sensitive(script_selected);
+ dynamic_cast(uiManager->get_widget("/MenuBar/MenuScript/RemoveScript"))->
+ set_sensitive(group_selected || script_selected);
}
}
@@ -2498,6 +2591,21 @@
}
}
+void MainWindow::script_double_clicked(const Gtk::TreeModel::Path& path,
+ Gtk::TreeViewColumn* column)
+{
+ Gtk::TreeModel::iterator iter = m_refScriptsTreeModel->get_iter(path);
+ if (!iter) return;
+ Gtk::TreeModel::Row row = *iter;
+ gig::Script* script = row[m_ScriptsModel.m_col_script];
+ if (!script) return;
+
+ ScriptEditor* editor = new ScriptEditor;
+ editor->setScript(script);
+ //editor->reparent(*this);
+ editor->show();
+}
+
void MainWindow::instrument_name_changed(const Gtk::TreeModel::Path& path,
const Gtk::TreeModel::iterator& iter) {
if (!iter) return;
@@ -2732,7 +2840,7 @@
Gtk::TreeModel::Row rowSample = rowGroup.children()[s];
if (rowSample[m_SamplesModel.m_col_sample] != sample) continue;
rowSample[m_SamplesModel.m_col_refcount] = ToString(refcount) + " " + _("Refs.");
- rowSample[m_SamplesModel.m_color] = refcount ? "black" : "gray";
+ rowSample[m_SamplesModel.m_color] = refcount ? "black" : "red";
}
}
}
@@ -2752,6 +2860,18 @@
}
}
+void MainWindow::show_samples_tab() {
+ m_TreeViewNotebook.set_current_page(0);
+}
+
+void MainWindow::show_intruments_tab() {
+ m_TreeViewNotebook.set_current_page(1);
+}
+
+void MainWindow::show_scripts_tab() {
+ m_TreeViewNotebook.set_current_page(2);
+}
+
sigc::signal& MainWindow::signal_file_structure_to_be_changed() {
return file_structure_to_be_changed_signal;
}