From f673a148c7104b3aaee4b1332a3631ac15f5f769 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 5 Dec 2007 07:31:01 +0000 Subject: Add preliminary mutation to machina (only random edge probability mutation so far). git-svn-id: http://svn.drobilla.net/lad/machina@951 a436a847-0d15-0410-975c-d299462d15a1 --- src/gui/EdgeView.hpp | 2 +- src/gui/MachinaCanvas.cpp | 16 +- src/gui/MachinaCanvas.hpp | 1 + src/gui/MachinaGUI.cpp | 35 ++++ src/gui/MachinaGUI.hpp | 10 +- src/gui/machina.glade | 407 ++++++++++++++++++++++++++-------------------- 6 files changed, 289 insertions(+), 182 deletions(-) (limited to 'src/gui') diff --git a/src/gui/EdgeView.hpp b/src/gui/EdgeView.hpp index 2555e4a..2b04324 100644 --- a/src/gui/EdgeView.hpp +++ b/src/gui/EdgeView.hpp @@ -34,11 +34,11 @@ public: SharedPtr edge() { return _edge; } void show_label(bool show); + void update(); virtual double length_hint() const; private: - void update(); bool on_event(GdkEvent* ev); SharedPtr _edge; diff --git a/src/gui/MachinaCanvas.cpp b/src/gui/MachinaCanvas.cpp index e899a64..8ed9e40 100644 --- a/src/gui/MachinaCanvas.cpp +++ b/src/gui/MachinaCanvas.cpp @@ -131,7 +131,7 @@ void MachinaCanvas::disconnect_node(boost::shared_ptr src, boost::shared_ptr head) { - src->node()->remove_outgoing_edges_to(head->node()); + src->node()->remove_edges_to(head->node()); remove_connection(src, head); } @@ -177,8 +177,8 @@ MachinaCanvas::build(SharedPtr machine) if (!view) continue; - for (Machina::Node::Edges::const_iterator e = view->node()->outgoing_edges().begin(); - e != view->node()->outgoing_edges().end(); ++e) { + for (Machina::Node::Edges::const_iterator e = view->node()->edges().begin(); + e != view->node()->edges().end(); ++e) { SharedPtr head_view = views[(*e)->head()]; if (!head_view) { @@ -201,3 +201,13 @@ MachinaCanvas::build(SharedPtr machine) } +void +MachinaCanvas::update_edges() +{ + for (ConnectionList::iterator i = _connections.begin(); i != _connections.end(); ++i) { + SharedPtr edge = PtrCast(*i); + if (edge) + edge->update(); + } +} + diff --git a/src/gui/MachinaCanvas.hpp b/src/gui/MachinaCanvas.hpp index 63c88fd..631957e 100644 --- a/src/gui/MachinaCanvas.hpp +++ b/src/gui/MachinaCanvas.hpp @@ -41,6 +41,7 @@ public: SharedPtr port2); void build(SharedPtr machine); + void update_edges(); ArtVpathDash* selector_dash() { return _selector_dash; } diff --git a/src/gui/MachinaGUI.cpp b/src/gui/MachinaGUI.cpp index 2e383ec..6c94211 100644 --- a/src/gui/MachinaGUI.cpp +++ b/src/gui/MachinaGUI.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "GladeXml.hpp" #include "MachinaGUI.hpp" @@ -31,6 +32,8 @@ #include "NodeView.hpp" #include "EdgeView.hpp" +using namespace Machina; + MachinaGUI::MachinaGUI(SharedPtr engine) : _refresh(false), @@ -69,6 +72,9 @@ MachinaGUI::MachinaGUI(SharedPtr 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("add_edge_but", _add_edge_button); + xml->get_widget("remove_edge_but", _remove_edge_button); + xml->get_widget("adjust_edge_but", _adjust_edge_button); _canvas_scrolledwindow->add(*_canvas); _canvas_scrolledwindow->signal_event().connect(sigc::mem_fun(this, @@ -121,6 +127,13 @@ MachinaGUI::MachinaGUI(SharedPtr engine) sigc::mem_fun(this, &MachinaGUI::quantize_changed)); _quantize_spinbutton->signal_changed().connect( sigc::mem_fun(this, &MachinaGUI::quantize_changed)); + + _add_edge_button->signal_clicked().connect( + sigc::mem_fun(this, &MachinaGUI::add_edge)); + _remove_edge_button->signal_clicked().connect( + sigc::mem_fun(this, &MachinaGUI::remove_edge)); + _adjust_edge_button->signal_clicked().connect( + sigc::mem_fun(this, &MachinaGUI::adjust_edge)); connect_widgets(); @@ -198,6 +211,28 @@ MachinaGUI::arrange() _canvas->arrange(_menu_view_time_edges->get_active()); } + +void +MachinaGUI::add_edge() +{ + Mutation::AddEdge::mutate(*_engine->machine().get()); +} + + +void +MachinaGUI::remove_edge() +{ + Mutation::RemoveEdge::mutate(*_engine->machine().get()); +} + + +void +MachinaGUI::adjust_edge() +{ + Mutation::AdjustEdge::mutate(*_engine->machine().get()); + _canvas->update_edges(); +} + void MachinaGUI::update_toolbar() diff --git a/src/gui/MachinaGUI.hpp b/src/gui/MachinaGUI.hpp index 4b82ff3..cc1eee3 100644 --- a/src/gui/MachinaGUI.hpp +++ b/src/gui/MachinaGUI.hpp @@ -62,10 +62,13 @@ protected: void show_labels_toggled(); void menu_help_about(); void menu_help_help(); + void arrange(); + void add_edge(); + void remove_edge(); + void adjust_edge(); void zoom(double z); - bool idle_callback(); void update_toolbar(); - void arrange(); + bool idle_callback(); bool scrolled_window_event(GdkEvent* ev); void record_toggled(); @@ -116,6 +119,9 @@ protected: Gtk::ToolButton* _zoom_normal_button; Gtk::ToolButton* _zoom_full_button; Gtk::ToolButton* _arrange_button; + Gtk::ToolButton* _add_edge_button; + Gtk::ToolButton* _remove_edge_button; + Gtk::ToolButton* _adjust_edge_button; }; #endif // MACHINA_GUI_H diff --git a/src/gui/machina.glade b/src/gui/machina.glade index f892894..11f3e7c 100644 --- a/src/gui/machina.glade +++ b/src/gui/machina.glade @@ -207,86 +207,72 @@ - + True - GTK_TOOLBAR_BOTH_HORIZ + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - - True - Record - gtk-media-record - - - False - - - - - True - Stop playback or recording - gtk-media-stop - - - False - - - - - True - Play - gtk-media-play - True - - - False - - - - - True - - - False - False - - - - + True + GTK_TOOLBAR_BOTH_HORIZ + False - + + True + Record + gtk-media-record + + + False + + + + + True + Stop playback or recording + gtk-media-stop + + + False + + + + + True + Play + gtk-media-play + True + + + False + + + + + True + + + False + False + + + + True - 4 - 6 - - - True - False - True - Slave to JACK transport - Slave - True - 0 - True - - - False - False - - - + True + 4 + 6 - + True + False True - Use internal tempo + Slave to JACK transport + Slave True 0 - True True - slave_radiobutton False @@ -294,135 +280,204 @@ - + True - True - Set internal tempo - 120 1 640 1 10 10 - 1 + + + True + True + Use internal tempo + True + 0 + True + True + slave_radiobutton + + + False + False + + + + + True + True + Set internal tempo + 120 1 640 1 10 10 + 1 + + + 1 + + + + + True + BPM + + + False + False + 2 + + 1 + + + + + False + False + + + + + True + + + False + False + + + + + True + + + True + 4 - + True - BPM + True + Quantize recording + Quantize: 1/ + True + 0 + True False False - 2 + + + + + True + False + True + 1 1 99 1 4 4 + 1 + + + 1 - - 1 - + + False + False + - - - False - False - - - - - True - - - False - False - - - - - True - + True - 4 - - - True - True - Quantize recording - Quantize: 1/ - True - 0 - True - - - False - False - - - - - True - False - True - 1 1 99 1 4 4 - 1 - - - 1 - - + + False + False + + + + + True + Zoom to normal size + gtk-zoom-100 + + + False + + + + + True + Zoom to fit entire machine + gtk-zoom-fit + + + False + + + + + True + Automatically arrange nodes + gtk-refresh + + + False + - - False - False - - - - - True - - - False - False - - - - - True - Zoom to normal size - gtk-zoom-100 - - - False - - - - - True - Zoom to fit entire machine - gtk-zoom-fit - - - False - - + True - Automatically arrange nodes - gtk-refresh + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + False + GTK_ICON_SIZE_SMALL_TOOLBAR + True + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Add random edge + Add Edge + gtk-add + + + False + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Remove random edge + Remove Edge + gtk-remove + + + False + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Adjust random edge probability + Mutate Edge Probabililty + gtk-edit + + + False + + False + 1 False - False 1 @@ -559,58 +614,58 @@ Selector nodes are shown in green. 4 8 - + True True - 60 0 127 1 10 10 + True + 1 0 999999 1 10 10 1 + 2 True 1 2 + 1 + 2 - + True 0 - Note: + Duration: + 1 + 2 GTK_FILL - + True 0 - Duration: + Note: - 1 - 2 GTK_FILL - + True True - True - 1 0 999999 1 10 10 + 60 0 127 1 10 10 1 - 2 True 1 2 - 1 - 2 -- cgit v1.2.1