aboutsummaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-03-30 22:32:07 +0000
committerDavid Robillard <d@drobilla.net>2007-03-30 22:32:07 +0000
commitdd6be02a7478225f19f02432919b64b96b733172 (patch)
tree35d3476f6728801ed1e6b8d124fc85d549e91bfd /src/gui
parent2124952b855e093d6253bfd763cd9ebfe69e9def (diff)
downloadmachina-dd6be02a7478225f19f02432919b64b96b733172.tar.gz
machina-dd6be02a7478225f19f02432919b64b96b733172.tar.bz2
machina-dd6be02a7478225f19f02432919b64b96b733172.zip
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
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/EdgeView.cpp7
-rw-r--r--src/gui/EdgeView.hpp2
-rw-r--r--src/gui/MachinaCanvas.cpp22
-rw-r--r--src/gui/MachinaGUI.cpp18
4 files changed, 37 insertions, 12 deletions
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<FlowCanvas> 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<Machina::Edge> 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<NodeView> src,
- boost::shared_ptr<NodeView> dst)
+ boost::shared_ptr<NodeView> head)
{
- SharedPtr<Machina::Edge> edge(new Machina::Edge(src->node(), dst->node()));
+ SharedPtr<Machina::Edge> edge(new Machina::Edge(src->node(), head->node()));
src->node()->add_outgoing_edge(edge);
boost::shared_ptr<Connection> 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<NodeView> src,
- boost::shared_ptr<NodeView> dst)
+ boost::shared_ptr<NodeView> 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<MachinaPort> input
@@ -213,16 +213,16 @@ MachinaCanvas::build(SharedPtr<Machina::Machine> machine)
for (Machina::Node::Edges::const_iterator e = view->node()->outgoing_edges().begin();
e != view->node()->outgoing_edges().end(); ++e) {
- SharedPtr<NodeView> dst_view = views[(*e)->dst()];
- if (!dst_view) {
+ SharedPtr<NodeView> head_view = views[(*e)->head()];
+ if (!head_view) {
cerr << "WARNING: Edge to node with no view" << endl;
continue;
}
boost::shared_ptr<Connection> 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 <cmath>
#include <sstream>
#include <fstream>
+#include <limits.h>
#include <pthread.h>
#include <libgnomecanvasmm.h>
#include <libglademm/xml.h>
@@ -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<Machina::SMFDriver> file_driver(new Machina::SMFDriver());
//SharedPtr<Machina::Machine> machine = file_driver->learn(dialog.get_uri(),
// track_sb->get_value_as_int());
- SharedPtr<Machina::Machine> machine = file_driver->learn(dialog.get_filename(), 0.0, 16.0);
+
+ double length = length_sb->get_value_as_int();
+
+ SharedPtr<Machina::Machine> machine = file_driver->learn(dialog.get_filename(), 0.0, length);
if (machine) {
dialog.hide();