From dd6be02a7478225f19f02432919b64b96b733172 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 30 Mar 2007 22:32:07 +0000 Subject: Canvas auto-layout uses durations like graphviz diagrams. Learning fixes. Added duration spinbutton to MIDI Import dialog. git-svn-id: http://svn.drobilla.net/lad/machina@381 a436a847-0d15-0410-975c-d299462d15a1 --- src/gui/EdgeView.cpp | 7 +++++++ src/gui/EdgeView.hpp | 2 ++ src/gui/MachinaCanvas.cpp | 22 +++++++++++----------- src/gui/MachinaGUI.cpp | 18 +++++++++++++++++- 4 files changed, 37 insertions(+), 12 deletions(-) (limited to 'src/gui') diff --git a/src/gui/EdgeView.cpp b/src/gui/EdgeView.cpp index 4817eca..fccf8d5 100644 --- a/src/gui/EdgeView.cpp +++ b/src/gui/EdgeView.cpp @@ -33,6 +33,13 @@ EdgeView::EdgeView(SharedPtr canvas, { } + +double +EdgeView::length_hint() const +{ + return _edge->tail().lock()->duration() * 10; +} + void EdgeView::update_label() diff --git a/src/gui/EdgeView.hpp b/src/gui/EdgeView.hpp index c61d0cf..c394d49 100644 --- a/src/gui/EdgeView.hpp +++ b/src/gui/EdgeView.hpp @@ -34,6 +34,8 @@ public: SharedPtr edge() { return _edge; } void update_label(); + + virtual double length_hint() const; private: bool on_event(GdkEvent* ev); diff --git a/src/gui/MachinaCanvas.cpp b/src/gui/MachinaCanvas.cpp index a6a565e..134b885 100644 --- a/src/gui/MachinaCanvas.cpp +++ b/src/gui/MachinaCanvas.cpp @@ -115,25 +115,25 @@ MachinaCanvas::canvas_event(GdkEvent* event) void MachinaCanvas::connect_node(boost::shared_ptr src, - boost::shared_ptr dst) + boost::shared_ptr head) { - SharedPtr edge(new Machina::Edge(src->node(), dst->node())); + SharedPtr edge(new Machina::Edge(src->node(), head->node())); src->node()->add_outgoing_edge(edge); boost::shared_ptr c(new EdgeView(shared_from_this(), - src, dst, edge)); + src, head, edge)); src->add_connection(c); - dst->add_connection(c); + head->add_connection(c); add_connection(c); } void MachinaCanvas::disconnect_node(boost::shared_ptr src, - boost::shared_ptr dst) + boost::shared_ptr head) { - src->node()->remove_outgoing_edges_to(dst->node()); - remove_connection(src, dst); + src->node()->remove_outgoing_edges_to(head->node()); + remove_connection(src, head); #if 0 boost::shared_ptr input @@ -213,16 +213,16 @@ MachinaCanvas::build(SharedPtr machine) for (Machina::Node::Edges::const_iterator e = view->node()->outgoing_edges().begin(); e != view->node()->outgoing_edges().end(); ++e) { - SharedPtr dst_view = views[(*e)->dst()]; - if (!dst_view) { + SharedPtr head_view = views[(*e)->head()]; + if (!head_view) { cerr << "WARNING: Edge to node with no view" << endl; continue; } boost::shared_ptr c(new EdgeView(shared_from_this(), - view, dst_view, (*e))); + view, head_view, (*e))); view->add_connection(c); - dst_view->add_connection(c); + head_view->add_connection(c); add_connection(c); } diff --git a/src/gui/MachinaGUI.cpp b/src/gui/MachinaGUI.cpp index ffbfb5a..de432aa 100644 --- a/src/gui/MachinaGUI.cpp +++ b/src/gui/MachinaGUI.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -426,6 +427,18 @@ MachinaGUI::menu_import_midi() Gtk::FILE_CHOOSER_ACTION_OPEN); dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); + + Gtk::HBox* extra_widget = Gtk::manage(new Gtk::HBox()); + Gtk::SpinButton* length_sb = Gtk::manage(new Gtk::SpinButton()); + length_sb->set_increments(1, 10); + length_sb->set_range(0, INT_MAX); + length_sb->set_value(0); + extra_widget->pack_start(*Gtk::manage(new Gtk::Label("")), true, true); + extra_widget->pack_start(*Gtk::manage(new Gtk::Label("Maximum Length (0 = unlimited): ")), false, false); + extra_widget->pack_start(*length_sb, false, false); + dialog.set_extra_widget(*extra_widget); + extra_widget->show_all(); + /*Gtk::HBox* extra_widget = Gtk::manage(new Gtk::HBox()); Gtk::SpinButton* track_sb = Gtk::manage(new Gtk::SpinButton()); @@ -444,7 +457,10 @@ MachinaGUI::menu_import_midi() SharedPtr file_driver(new Machina::SMFDriver()); //SharedPtr machine = file_driver->learn(dialog.get_uri(), // track_sb->get_value_as_int()); - SharedPtr machine = file_driver->learn(dialog.get_filename(), 0.0, 16.0); + + double length = length_sb->get_value_as_int(); + + SharedPtr machine = file_driver->learn(dialog.get_filename(), 0.0, length); if (machine) { dialog.hide(); -- cgit v1.2.1