aboutsummaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-12-07 17:27:06 +0000
committerDavid Robillard <d@drobilla.net>2007-12-07 17:27:06 +0000
commitaa11564fef8ed9330d42081288e8f310072c67d6 (patch)
tree3d092d0117fd8a309d4ec16e158893744a777362 /src/gui
parent885af895243b43220b1e99f1d3b2bebcc2ec6398 (diff)
downloadmachina-aa11564fef8ed9330d42081288e8f310072c67d6.tar.gz
machina-aa11564fef8ed9330d42081288e8f310072c67d6.tar.bz2
machina-aa11564fef8ed9330d42081288e8f310072c67d6.zip
Fix loading selector nodes.
Choosing evolution target MIDI from GUI. git-svn-id: http://svn.drobilla.net/lad/machina@963 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/MachinaGUI.cpp40
-rw-r--r--src/gui/MachinaGUI.hpp3
-rw-r--r--src/gui/machina.glade48
3 files changed, 76 insertions, 15 deletions
diff --git a/src/gui/MachinaGUI.cpp b/src/gui/MachinaGUI.cpp
index 0e872fd..4fdc6fa 100644
--- a/src/gui/MachinaGUI.cpp
+++ b/src/gui/MachinaGUI.cpp
@@ -78,6 +78,7 @@ MachinaGUI::MachinaGUI(SharedPtr<Machina::Engine> engine)
xml->get_widget("zoom_normal_but", _zoom_normal_button);
xml->get_widget("zoom_full_but", _zoom_full_button);
xml->get_widget("arrange_but", _arrange_button);
+ xml->get_widget("load_target_but", _load_target_button);
xml->get_widget("evolve_but", _evolve_button);
xml->get_widget("mutate_but", _mutate_button);
xml->get_widget("compress_but", _compress_button);
@@ -174,6 +175,7 @@ MachinaGUI::MachinaGUI(SharedPtr<Machina::Engine> engine)
Glib::signal_timeout().connect(sigc::mem_fun(this, &MachinaGUI::idle_callback), 100);
#ifdef HAVE_EUGENE
+ _load_target_button->signal_clicked().connect(sigc::mem_fun(this, &MachinaGUI::load_target_clicked));
_evolve_button->signal_clicked().connect(sigc::mem_fun(this, &MachinaGUI::evolve_toggled));
Glib::signal_timeout().connect(sigc::mem_fun(this, &MachinaGUI::evolve_callback), 1000);
#else
@@ -252,10 +254,31 @@ MachinaGUI::arrange()
void
+MachinaGUI::load_target_clicked()
+{
+ Gtk::FileChooserDialog dialog(*_main_window,
+ "Load MIDI file for evolution", Gtk::FILE_CHOOSER_ACTION_OPEN);
+ dialog.set_local_only(false);
+ dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
+ dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
+
+ Gtk::FileFilter filt;
+ filt.add_pattern("*.mid");
+ filt.set_name("MIDI Files");
+ dialog.set_filter(filt);
+
+ const int result = dialog.run();
+
+ if (result == Gtk::RESPONSE_OK)
+ _target_filename = dialog.get_filename();
+}
+
+
+void
MachinaGUI::evolve_toggled()
{
if (_evolve_button->get_active()) {
- _evolver = SharedPtr<Evolver>(new Evolver("target.mid", _engine->machine()));
+ _evolver = SharedPtr<Evolver>(new Evolver(_target_filename, _engine->machine()));
_evolve = true;
stop_clicked();
_engine->driver()->set_machine(SharedPtr<Machine>());
@@ -384,6 +407,11 @@ MachinaGUI::menu_file_open()
dialog.set_local_only(false);
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
+
+ Gtk::FileFilter filt;
+ filt.add_pattern("*.machina.ttl");
+ filt.set_name("Machina Machines (Turtle/RDF)");
+ dialog.set_filter(filt);
const int result = dialog.run();
@@ -477,6 +505,11 @@ MachinaGUI::menu_import_midi()
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
+ Gtk::FileFilter filt;
+ filt.add_pattern("*.mid");
+ filt.set_name("MIDI Files");
+ dialog.set_filter(filt);
+
Gtk::HBox* extra_widget = Gtk::manage(new Gtk::HBox());
Gtk::SpinButton* length_sb = Gtk::manage(new Gtk::SpinButton());
length_sb->set_increments(1, 10);
@@ -520,6 +553,11 @@ MachinaGUI::menu_export_midi()
Gtk::FILE_CHOOSER_ACTION_SAVE);
dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);
+
+ Gtk::FileFilter filt;
+ filt.add_pattern("*.mid");
+ filt.set_name("MIDI Files");
+ dialog.set_filter(filt);
const int result = dialog.run();
diff --git a/src/gui/MachinaGUI.hpp b/src/gui/MachinaGUI.hpp
index 3b6c340..26cfad4 100644
--- a/src/gui/MachinaGUI.hpp
+++ b/src/gui/MachinaGUI.hpp
@@ -63,6 +63,7 @@ protected:
void menu_help_about();
void menu_help_help();
void arrange();
+ void load_target_clicked();
void evolve_toggled();
void random_mutation(SharedPtr<Machina::Machine> machine);
void mutate(SharedPtr<Machina::Machine> machine, unsigned mutation);
@@ -83,6 +84,7 @@ protected:
bool _evolve;
string _save_uri;
+ string _target_filename;
boost::shared_ptr<MachinaCanvas> _canvas;
boost::shared_ptr<Machina::Engine> _engine;
@@ -121,6 +123,7 @@ protected:
Gtk::ToolButton* _zoom_normal_button;
Gtk::ToolButton* _zoom_full_button;
Gtk::ToolButton* _arrange_button;
+ Gtk::ToolButton* _load_target_button;
Gtk::ToggleToolButton* _evolve_button;
Gtk::ToolButton* _mutate_button;
Gtk::ToolButton* _compress_button;
diff --git a/src/gui/machina.glade b/src/gui/machina.glade
index e91553d..f991a08 100644
--- a/src/gui/machina.glade
+++ b/src/gui/machina.glade
@@ -404,6 +404,26 @@
<property name="icon_size">GTK_ICON_SIZE_SMALL_TOOLBAR</property>
<property name="icon_size_set">True</property>
<child>
+ <widget class="GtkSeparatorToolItem" id="toolbutton7">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkToolButton" id="load_target_but">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="tooltip" translatable="yes">Load MIDI file as evolutionary goal</property>
+ <property name="stock_id">gtk-open</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ </packing>
+ </child>
+ <child>
<widget class="GtkSeparatorToolItem" id="toolbutton5">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
@@ -704,58 +724,58 @@ Selector nodes are shown in green.
<property name="column_spacing">4</property>
<property name="row_spacing">8</property>
<child>
- <widget class="GtkSpinButton" id="node_properties_note_spinbutton">
+ <widget class="GtkSpinButton" id="node_properties_duration_spinbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="adjustment">60 0 127 1 10 10</property>
+ <property name="has_focus">True</property>
+ <property name="adjustment">1 0 999999 1 10 10</property>
<property name="climb_rate">1</property>
+ <property name="digits">2</property>
<property name="numeric">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="label6">
+ <widget class="GtkLabel" id="label7">
<property name="visible">True</property>
<property name="xalign">0</property>
- <property name="label" translatable="yes">Note: </property>
+ <property name="label" translatable="yes">Duration: </property>
</widget>
<packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkLabel" id="label7">
+ <widget class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="xalign">0</property>
- <property name="label" translatable="yes">Duration: </property>
+ <property name="label" translatable="yes">Note: </property>
</widget>
<packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
- <widget class="GtkSpinButton" id="node_properties_duration_spinbutton">
+ <widget class="GtkSpinButton" id="node_properties_note_spinbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="has_focus">True</property>
- <property name="adjustment">1 0 999999 1 10 10</property>
+ <property name="adjustment">60 0 127 1 10 10</property>
<property name="climb_rate">1</property>
- <property name="digits">2</property>
<property name="numeric">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>