diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/EdgeView.hpp | 2 | ||||
-rw-r--r-- | src/gui/MachinaCanvas.cpp | 16 | ||||
-rw-r--r-- | src/gui/MachinaCanvas.hpp | 1 | ||||
-rw-r--r-- | src/gui/MachinaGUI.cpp | 35 | ||||
-rw-r--r-- | src/gui/MachinaGUI.hpp | 10 | ||||
-rw-r--r-- | src/gui/machina.glade | 407 |
6 files changed, 289 insertions, 182 deletions
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<Machina::Edge> edge() { return _edge; } void show_label(bool show); + void update(); virtual double length_hint() const; private: - void update(); bool on_event(GdkEvent* ev); SharedPtr<Machina::Edge> _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<NodeView> src, boost::shared_ptr<NodeView> 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<Machina::Machine> 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<NodeView> head_view = views[(*e)->head()]; if (!head_view) { @@ -201,3 +201,13 @@ MachinaCanvas::build(SharedPtr<Machina::Machine> machine) } +void +MachinaCanvas::update_edges() +{ + for (ConnectionList::iterator i = _connections.begin(); i != _connections.end(); ++i) { + SharedPtr<EdgeView> edge = PtrCast<EdgeView>(*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<NodeView> port2); void build(SharedPtr<Machina::Machine> 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 <libglademm/xml.h> #include <redlandmm/Model.hpp> #include <machina/Machine.hpp> +#include <machina/MachineMutation.hpp> #include <machina/SMFDriver.hpp> #include "GladeXml.hpp" #include "MachinaGUI.hpp" @@ -31,6 +32,8 @@ #include "NodeView.hpp" #include "EdgeView.hpp" +using namespace Machina; + MachinaGUI::MachinaGUI(SharedPtr<Machina::Engine> engine) : _refresh(false), @@ -69,6 +72,9 @@ 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("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<Machina::Engine> 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 @@ </packing> </child> <child> - <widget class="GtkToolbar" id="toolbar"> + <widget class="GtkHBox" id="hbox2"> <property name="visible">True</property> - <property name="toolbar_style">GTK_TOOLBAR_BOTH_HORIZ</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <child> - <widget class="GtkToggleToolButton" id="record_but"> - <property name="visible">True</property> - <property name="tooltip" translatable="yes">Record</property> - <property name="stock_id">gtk-media-record</property> - </widget> - <packing> - <property name="expand">False</property> - </packing> - </child> - <child> - <widget class="GtkToolButton" id="stop_but"> - <property name="visible">True</property> - <property name="tooltip" translatable="yes">Stop playback or recording</property> - <property name="stock_id">gtk-media-stop</property> - </widget> - <packing> - <property name="expand">False</property> - </packing> - </child> - <child> - <widget class="GtkToggleToolButton" id="play_but"> - <property name="visible">True</property> - <property name="tooltip" translatable="yes">Play</property> - <property name="stock_id">gtk-media-play</property> - <property name="active">True</property> - </widget> - <packing> - <property name="expand">False</property> - </packing> - </child> - <child> - <widget class="GtkSeparatorToolItem" id="separatortoolitem4"> - <property name="visible">True</property> - </widget> - <packing> - <property name="expand">False</property> - <property name="homogeneous">False</property> - </packing> - </child> - <child> - <widget class="GtkToolItem" id="toolitem1"> + <widget class="GtkToolbar" id="toolbar"> <property name="visible">True</property> + <property name="toolbar_style">GTK_TOOLBAR_BOTH_HORIZ</property> + <property name="show_arrow">False</property> <child> - <widget class="GtkHBox" id="hbox1"> + <widget class="GtkToggleToolButton" id="record_but"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Record</property> + <property name="stock_id">gtk-media-record</property> + </widget> + <packing> + <property name="expand">False</property> + </packing> + </child> + <child> + <widget class="GtkToolButton" id="stop_but"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Stop playback or recording</property> + <property name="stock_id">gtk-media-stop</property> + </widget> + <packing> + <property name="expand">False</property> + </packing> + </child> + <child> + <widget class="GtkToggleToolButton" id="play_but"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Play</property> + <property name="stock_id">gtk-media-play</property> + <property name="active">True</property> + </widget> + <packing> + <property name="expand">False</property> + </packing> + </child> + <child> + <widget class="GtkSeparatorToolItem" id="separatortoolitem4"> + <property name="visible">True</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="homogeneous">False</property> + </packing> + </child> + <child> + <widget class="GtkToolItem" id="toolitem1"> <property name="visible">True</property> - <property name="border_width">4</property> - <property name="spacing">6</property> - <child> - <widget class="GtkRadioButton" id="slave_radiobutton"> - <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="response_id">0</property> - <property name="draw_indicator">True</property> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> <child> - <widget class="GtkHBox" id="hbox3"> + <widget class="GtkHBox" id="hbox1"> <property name="visible">True</property> + <property name="border_width">4</property> + <property name="spacing">6</property> <child> - <widget class="GtkRadioButton" id="bpm_radiobutton"> + <widget class="GtkRadioButton" id="slave_radiobutton"> <property name="visible">True</property> + <property name="sensitive">False</property> <property name="can_focus">True</property> - <property name="tooltip" translatable="yes">Use internal tempo</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="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> @@ -294,135 +280,204 @@ </packing> </child> <child> - <widget class="GtkSpinButton" id="bpm_spinbutton"> + <widget class="GtkHBox" id="hbox3"> <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> + <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> </widget> <packing> <property name="position">1</property> </packing> </child> + </widget> + </child> + </widget> + <packing> + <property name="expand">False</property> + <property name="homogeneous">False</property> + </packing> + </child> + <child> + <widget class="GtkSeparatorToolItem" id="separatortoolitem2"> + <property name="visible">True</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="homogeneous">False</property> + </packing> + </child> + <child> + <widget class="GtkToolItem" id="toolitem3"> + <property name="visible">True</property> + <child> + <widget class="GtkHBox" id="hbox4"> + <property name="visible">True</property> + <property name="border_width">4</property> <child> - <widget class="GtkLabel" id="label8"> + <widget class="GtkCheckButton" id="quantize_checkbutton"> <property name="visible">True</property> - <property name="label" translatable="yes"> BPM</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="use_underline">True</property> + <property name="response_id">0</property> + <property name="draw_indicator">True</property> </widget> <packing> <property name="expand">False</property> <property name="fill">False</property> - <property name="position">2</property> + </packing> + </child> + <child> + <widget class="GtkSpinButton" id="quantize_spinbutton"> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_focus">True</property> + <property name="adjustment">1 1 99 1 4 4</property> + <property name="climb_rate">1</property> + </widget> + <packing> + <property name="position">1</property> </packing> </child> </widget> - <packing> - <property name="position">1</property> - </packing> </child> </widget> + <packing> + <property name="expand">False</property> + <property name="homogeneous">False</property> + </packing> </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="homogeneous">False</property> - </packing> - </child> - <child> - <widget class="GtkSeparatorToolItem" id="separatortoolitem2"> - <property name="visible">True</property> - </widget> - <packing> - <property name="expand">False</property> - <property name="homogeneous">False</property> - </packing> - </child> - <child> - <widget class="GtkToolItem" id="toolitem3"> - <property name="visible">True</property> <child> - <widget class="GtkHBox" id="hbox4"> + <widget class="GtkSeparatorToolItem" id="separatortoolitem3"> <property name="visible">True</property> - <property name="border_width">4</property> - <child> - <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="use_underline">True</property> - <property name="response_id">0</property> - <property name="draw_indicator">True</property> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - <child> - <widget class="GtkSpinButton" id="quantize_spinbutton"> - <property name="visible">True</property> - <property name="sensitive">False</property> - <property name="can_focus">True</property> - <property name="adjustment">1 1 99 1 4 4</property> - <property name="climb_rate">1</property> - </widget> - <packing> - <property name="position">1</property> - </packing> - </child> </widget> + <packing> + <property name="expand">False</property> + <property name="homogeneous">False</property> + </packing> + </child> + <child> + <widget class="GtkToolButton" id="zoom_normal_but"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Zoom to normal size</property> + <property name="stock_id">gtk-zoom-100</property> + </widget> + <packing> + <property name="expand">False</property> + </packing> + </child> + <child> + <widget class="GtkToolButton" id="zoom_full_but"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Zoom to fit entire machine</property> + <property name="stock_id">gtk-zoom-fit</property> + </widget> + <packing> + <property name="expand">False</property> + </packing> + </child> + <child> + <widget class="GtkToolButton" id="arrange_but"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Automatically arrange nodes</property> + <property name="stock_id">gtk-refresh</property> + </widget> + <packing> + <property name="expand">False</property> + </packing> </child> </widget> - <packing> - <property name="expand">False</property> - <property name="homogeneous">False</property> - </packing> - </child> - <child> - <widget class="GtkSeparatorToolItem" id="separatortoolitem3"> - <property name="visible">True</property> - </widget> - <packing> - <property name="expand">False</property> - <property name="homogeneous">False</property> - </packing> - </child> - <child> - <widget class="GtkToolButton" id="zoom_normal_but"> - <property name="visible">True</property> - <property name="tooltip" translatable="yes">Zoom to normal size</property> - <property name="stock_id">gtk-zoom-100</property> - </widget> - <packing> - <property name="expand">False</property> - </packing> - </child> - <child> - <widget class="GtkToolButton" id="zoom_full_but"> - <property name="visible">True</property> - <property name="tooltip" translatable="yes">Zoom to fit entire machine</property> - <property name="stock_id">gtk-zoom-fit</property> - </widget> - <packing> - <property name="expand">False</property> - </packing> </child> <child> - <widget class="GtkToolButton" id="arrange_but"> + <widget class="GtkToolbar" id="toolbar1"> <property name="visible">True</property> - <property name="tooltip" translatable="yes">Automatically arrange nodes</property> - <property name="stock_id">gtk-refresh</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</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="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="label" translatable="yes">Add Edge</property> + <property name="stock_id">gtk-add</property> + </widget> + <packing> + <property name="expand">False</property> + </packing> + </child> + <child> + <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="label" translatable="yes">Remove Edge</property> + <property name="stock_id">gtk-remove</property> + </widget> + <packing> + <property name="expand">False</property> + </packing> + </child> + <child> + <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> + </widget> + <packing> + <property name="expand">False</property> + </packing> + </child> </widget> <packing> <property name="expand">False</property> + <property name="position">1</property> </packing> </child> </widget> <packing> <property name="expand">False</property> - <property name="fill">False</property> <property name="position">1</property> </packing> </child> @@ -559,58 +614,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> |