diff options
author | David Robillard <d@drobilla.net> | 2007-12-05 23:45:51 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-12-05 23:45:51 +0000 |
commit | a96b70b1c92b7f2622ebeff9d34c92ba089997f1 (patch) | |
tree | 732a8c2b225f619394ef5bb3d4a4a27d682409db /src/gui | |
parent | f673a148c7104b3aaee4b1332a3631ac15f5f769 (diff) | |
download | machina-a96b70b1c92b7f2622ebeff9d34c92ba089997f1.tar.gz machina-a96b70b1c92b7f2622ebeff9d34c92ba089997f1.tar.bz2 machina-a96b70b1c92b7f2622ebeff9d34c92ba089997f1.zip |
Working mutation operators.
git-svn-id: http://svn.drobilla.net/lad/machina@952 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/MachinaCanvas.cpp | 2 | ||||
-rw-r--r-- | src/gui/MachinaCanvas.hpp | 6 | ||||
-rw-r--r-- | src/gui/MachinaGUI.cpp | 77 | ||||
-rw-r--r-- | src/gui/MachinaGUI.hpp | 13 | ||||
-rw-r--r-- | src/gui/machina.glade | 218 |
5 files changed, 226 insertions, 90 deletions
diff --git a/src/gui/MachinaCanvas.cpp b/src/gui/MachinaCanvas.cpp index 8ed9e40..fb6ae94 100644 --- a/src/gui/MachinaCanvas.cpp +++ b/src/gui/MachinaCanvas.cpp @@ -117,7 +117,7 @@ MachinaCanvas::connect_node(boost::shared_ptr<NodeView> src, boost::shared_ptr<NodeView> head) { SharedPtr<Machina::Edge> edge(new Machina::Edge(src->node(), head->node())); - src->node()->add_outgoing_edge(edge); + src->node()->add_edge(edge); boost::shared_ptr<Connection> c(new EdgeView(shared_from_this(), src, head, edge)); diff --git a/src/gui/MachinaCanvas.hpp b/src/gui/MachinaCanvas.hpp index 631957e..211ebd7 100644 --- a/src/gui/MachinaCanvas.hpp +++ b/src/gui/MachinaCanvas.hpp @@ -15,8 +15,8 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#ifndef PATCHAGEPATCHBAYAREA_H -#define PATCHAGEPATCHBAYAREA_H +#ifndef MACHINA_CANVAS_HPP_H +#define MACHINA_CANVAS_HPP_H #include <string> #include <raul/SharedPtr.hpp> @@ -59,4 +59,4 @@ private: }; -#endif // PATCHAGEPATCHBAYAREA_H +#endif // MACHINA_CANVAS_HPP_H diff --git a/src/gui/MachinaGUI.cpp b/src/gui/MachinaGUI.cpp index 6c94211..3749d3a 100644 --- a/src/gui/MachinaGUI.cpp +++ b/src/gui/MachinaGUI.cpp @@ -61,8 +61,7 @@ MachinaGUI::MachinaGUI(SharedPtr<Machina::Engine> engine) xml->get_widget("help_about_menuitem", _menu_help_about); xml->get_widget("help_help_menuitem", _menu_help_help); xml->get_widget("canvas_scrolledwindow", _canvas_scrolledwindow); - xml->get_widget("slave_radiobutton", _slave_radiobutton); - xml->get_widget("bpm_radiobutton", _bpm_radiobutton); + xml->get_widget("clock_checkbutton", _clock_checkbutton); xml->get_widget("bpm_spinbutton", _bpm_spinbutton); xml->get_widget("quantize_checkbutton", _quantize_checkbutton); xml->get_widget("quantize_spinbutton", _quantize_spinbutton); @@ -72,6 +71,11 @@ 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("mutate_but", _mutate_button); + xml->get_widget("compress_but", _compress_button); + xml->get_widget("add_node_but", _add_node_button); + xml->get_widget("remove_node_but", _remove_node_button); + xml->get_widget("adjust_node_but", _adjust_node_button); xml->get_widget("add_edge_but", _add_edge_button); xml->get_widget("remove_edge_but", _remove_edge_button); xml->get_widget("adjust_edge_but", _adjust_edge_button); @@ -117,17 +121,23 @@ MachinaGUI::MachinaGUI(SharedPtr<Machina::Engine> engine) sigc::mem_fun(this, &MachinaGUI::menu_help_about)); _menu_help_help->signal_activate().connect( sigc::mem_fun(this, &MachinaGUI::menu_help_help)); - _slave_radiobutton->signal_toggled().connect( - sigc::mem_fun(this, &MachinaGUI::tempo_changed)); - _bpm_radiobutton->signal_toggled().connect( - sigc::mem_fun(this, &MachinaGUI::tempo_changed)); - _bpm_spinbutton->signal_changed().connect( + _clock_checkbutton->signal_toggled().connect( sigc::mem_fun(this, &MachinaGUI::tempo_changed)); _quantize_checkbutton->signal_toggled().connect( sigc::mem_fun(this, &MachinaGUI::quantize_changed)); _quantize_spinbutton->signal_changed().connect( sigc::mem_fun(this, &MachinaGUI::quantize_changed)); + _mutate_button->signal_clicked().connect( + sigc::mem_fun(this, &MachinaGUI::mutate)); + _compress_button->signal_clicked().connect( + sigc::mem_fun(this, &MachinaGUI::compress)); + _add_node_button->signal_clicked().connect( + sigc::mem_fun(this, &MachinaGUI::add_node)); + _remove_node_button->signal_clicked().connect( + sigc::mem_fun(this, &MachinaGUI::remove_node)); + _adjust_node_button->signal_clicked().connect( + sigc::mem_fun(this, &MachinaGUI::adjust_node)); _add_edge_button->signal_clicked().connect( sigc::mem_fun(this, &MachinaGUI::add_edge)); _remove_edge_button->signal_clicked().connect( @@ -141,7 +151,7 @@ MachinaGUI::MachinaGUI(SharedPtr<Machina::Engine> engine) _main_window->present(); - _bpm_radiobutton->set_active(true); + _clock_checkbutton->set_active(true); _quantize_checkbutton->set_active(false); update_toolbar(); @@ -211,11 +221,59 @@ MachinaGUI::arrange() _canvas->arrange(_menu_view_time_edges->get_active()); } + +void +MachinaGUI::mutate() +{ + switch (rand() % 7) { + case 0: compress(); break; + case 1: add_node(); break; + case 2: remove_node(); break; + case 3: adjust_node(); break; + case 4: add_edge(); break; + case 5: remove_edge(); break; + case 6: adjust_edge(); default: break; + } +} + + +void +MachinaGUI::compress() +{ + Mutation::Compress::mutate(*_engine->machine().get()); + _canvas->build(_engine->machine()); +} + + +void +MachinaGUI::add_node() +{ + Mutation::AddNode::mutate(*_engine->machine().get()); + _canvas->build(_engine->machine()); +} + + +void +MachinaGUI::remove_node() +{ + Mutation::RemoveNode::mutate(*_engine->machine().get()); + _canvas->build(_engine->machine()); +} + + +void +MachinaGUI::adjust_node() +{ + Mutation::AdjustNode::mutate(*_engine->machine().get()); + idle_callback(); // update nodes +} + void MachinaGUI::add_edge() { Mutation::AddEdge::mutate(*_engine->machine().get()); + _canvas->build(_engine->machine()); } @@ -223,6 +281,7 @@ void MachinaGUI::remove_edge() { Mutation::RemoveEdge::mutate(*_engine->machine().get()); + _canvas->build(_engine->machine()); } @@ -239,7 +298,7 @@ MachinaGUI::update_toolbar() { _record_button->set_active(_engine->driver()->recording()); _play_button->set_active(_engine->machine()->is_activated()); - _bpm_spinbutton->set_sensitive(_bpm_radiobutton->get_active()); + _bpm_spinbutton->set_sensitive(_clock_checkbutton->get_active()); _quantize_spinbutton->set_sensitive(_quantize_checkbutton->get_active()); } diff --git a/src/gui/MachinaGUI.hpp b/src/gui/MachinaGUI.hpp index cc1eee3..c82cd01 100644 --- a/src/gui/MachinaGUI.hpp +++ b/src/gui/MachinaGUI.hpp @@ -63,6 +63,11 @@ protected: void menu_help_about(); void menu_help_help(); void arrange(); + void mutate(); + void compress(); + void add_node(); + void remove_node(); + void adjust_node(); void add_edge(); void remove_edge(); void adjust_edge(); @@ -108,8 +113,7 @@ protected: Gtk::ScrolledWindow* _canvas_scrolledwindow; Gtk::TextView* _status_text; Gtk::Expander* _messages_expander; - Gtk::RadioButton* _slave_radiobutton; - Gtk::RadioButton* _bpm_radiobutton; + Gtk::CheckButton* _clock_checkbutton; Gtk::SpinButton* _bpm_spinbutton; Gtk::CheckButton* _quantize_checkbutton; Gtk::SpinButton* _quantize_spinbutton; @@ -119,6 +123,11 @@ protected: Gtk::ToolButton* _zoom_normal_button; Gtk::ToolButton* _zoom_full_button; Gtk::ToolButton* _arrange_button; + Gtk::ToolButton* _mutate_button; + Gtk::ToolButton* _compress_button; + Gtk::ToolButton* _add_node_button; + Gtk::ToolButton* _remove_node_button; + Gtk::ToolButton* _adjust_node_button; Gtk::ToolButton* _add_edge_button; Gtk::ToolButton* _remove_edge_button; Gtk::ToolButton* _adjust_edge_button; diff --git a/src/gui/machina.glade b/src/gui/machina.glade index 11f3e7c..2153908 100644 --- a/src/gui/machina.glade +++ b/src/gui/machina.glade @@ -213,7 +213,7 @@ <child> <widget class="GtkToolbar" id="toolbar"> <property name="visible">True</property> - <property name="toolbar_style">GTK_TOOLBAR_BOTH_HORIZ</property> + <property name="toolbar_style">GTK_TOOLBAR_ICONS</property> <property name="show_arrow">False</property> <child> <widget class="GtkToggleToolButton" id="record_but"> @@ -259,71 +259,40 @@ <widget class="GtkToolItem" id="toolitem1"> <property name="visible">True</property> <child> - <widget class="GtkHBox" id="hbox1"> + <widget class="GtkHBox" id="hbox3"> <property name="visible">True</property> - <property name="border_width">4</property> - <property name="spacing">6</property> <child> - <widget class="GtkRadioButton" id="slave_radiobutton"> + <widget class="GtkCheckButton" id="clock_checkbutton"> <property name="visible">True</property> - <property name="sensitive">False</property> <property name="can_focus">True</property> - <property name="tooltip" translatable="yes">Slave to JACK transport</property> - <property name="label" translatable="yes">Slave</property> - <property name="use_underline">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">Internal clock</property> <property name="response_id">0</property> + <property name="active">True</property> <property name="draw_indicator">True</property> </widget> + </child> + <child> + <widget class="GtkSpinButton" id="bpm_spinbutton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="tooltip" translatable="yes">Set internal tempo</property> + <property name="adjustment">120 1 640 1 10 10</property> + <property name="climb_rate">1</property> + </widget> <packing> - <property name="expand">False</property> - <property name="fill">False</property> + <property name="position">1</property> </packing> </child> <child> - <widget class="GtkHBox" id="hbox3"> + <widget class="GtkLabel" id="label8"> <property name="visible">True</property> - <child> - <widget class="GtkRadioButton" id="bpm_radiobutton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="tooltip" translatable="yes">Use internal tempo</property> - <property name="use_underline">True</property> - <property name="response_id">0</property> - <property name="active">True</property> - <property name="draw_indicator">True</property> - <property name="group">slave_radiobutton</property> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - <child> - <widget class="GtkSpinButton" id="bpm_spinbutton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="tooltip" translatable="yes">Set internal tempo</property> - <property name="adjustment">120 1 640 1 10 10</property> - <property name="climb_rate">1</property> - </widget> - <packing> - <property name="position">1</property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label8"> - <property name="visible">True</property> - <property name="label" translatable="yes"> BPM</property> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">2</property> - </packing> - </child> + <property name="label" translatable="yes"> BPM</property> </widget> <packing> - <property name="position">1</property> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">2</property> </packing> </child> </widget> @@ -354,8 +323,8 @@ <widget class="GtkCheckButton" id="quantize_checkbutton"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="tooltip" translatable="yes">Quantize recording</property> - <property name="label" translatable="yes">Quantize: 1/</property> + <property name="tooltip" translatable="yes">Quantize recording (beats)</property> + <property name="label" translatable="yes">1/</property> <property name="use_underline">True</property> <property name="response_id">0</property> <property name="draw_indicator">True</property> @@ -430,16 +399,115 @@ <widget class="GtkToolbar" id="toolbar1"> <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="toolbar_style">GTK_TOOLBAR_ICONS</property> <property name="show_arrow">False</property> <property name="icon_size">GTK_ICON_SIZE_SMALL_TOOLBAR</property> <property name="icon_size_set">True</property> <child> + <widget class="GtkSeparatorToolItem" id="toolbutton4"> + <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> + <property name="homogeneous">False</property> + </packing> + </child> + <child> + <widget class="GtkToolButton" id="mutate_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">Random mutation</property> + <property name="stock_id">gtk-dialog-warning</property> + <accelerator key="m" modifiers="GDK_CONTROL_MASK" signal="clicked"/> + </widget> + <packing> + <property name="expand">False</property> + </packing> + </child> + <child> + <widget class="GtkSeparatorToolItem" id="toolbutton3"> + <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="compress_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">Compress (merge identical nodes)</property> + <property name="stock_id">gtk-convert</property> + </widget> + <packing> + <property name="expand">False</property> + </packing> + </child> + <child> + <widget class="GtkSeparatorToolItem" id="toolbutton2"> + <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> + <property name="homogeneous">False</property> + </packing> + </child> + <child> + <widget class="GtkToolButton" id="add_node_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">Create node</property> + <property name="label" translatable="yes">Add Node</property> + <property name="stock_id">gtk-new</property> + </widget> + <packing> + <property name="expand">False</property> + </packing> + </child> + <child> + <widget class="GtkToolButton" id="remove_node_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">Delete node</property> + <property name="label" translatable="yes">Delete Node</property> + <property name="stock_id">gtk-delete</property> + </widget> + <packing> + <property name="expand">False</property> + </packing> + </child> + <child> + <widget class="GtkToolButton" id="adjust_node_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">Adjust node</property> + <property name="label" translatable="yes">Adjust Node</property> + <property name="stock_id">gtk-edit</property> + </widget> + <packing> + <property name="expand">False</property> + </packing> + </child> + <child> + <widget class="GtkSeparatorToolItem" id="toolbutton1"> + <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> + <property name="homogeneous">False</property> + </packing> + </child> + <child> <widget class="GtkToolButton" id="add_edge_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">Add random edge</property> + <property name="tooltip" translatable="yes">Add edge</property> <property name="label" translatable="yes">Add Edge</property> - <property name="stock_id">gtk-add</property> + <property name="stock_id">gtk-connect</property> </widget> <packing> <property name="expand">False</property> @@ -449,9 +517,9 @@ <widget class="GtkToolButton" id="remove_edge_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">Remove random edge</property> + <property name="tooltip" translatable="yes">Remove edge</property> <property name="label" translatable="yes">Remove Edge</property> - <property name="stock_id">gtk-remove</property> + <property name="stock_id">gtk-disconnect</property> </widget> <packing> <property name="expand">False</property> @@ -461,9 +529,9 @@ <widget class="GtkToolButton" id="adjust_edge_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">Adjust random edge probability</property> - <property name="label" translatable="yes">Mutate Edge Probabililty</property> - <property name="stock_id">gtk-edit</property> + <property name="tooltip" translatable="yes">Adjust edge</property> + <property name="label" translatable="yes">Adjust Edge</property> + <property name="stock_id">gtk-select-color</property> </widget> <packing> <property name="expand">False</property> @@ -614,58 +682,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_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> <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="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="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> |