aboutsummaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/EdgeView.cpp2
-rw-r--r--src/gui/GladeXml.hpp5
-rw-r--r--src/gui/MachinaCanvas.cpp10
-rw-r--r--src/gui/MachinaGUI.cpp10
-rw-r--r--src/gui/MachinaGUI.hpp4
-rw-r--r--src/gui/NodePropertiesWindow.cpp5
-rw-r--r--src/gui/main.cpp4
-rw-r--r--src/gui/wscript44
8 files changed, 70 insertions, 14 deletions
diff --git a/src/gui/EdgeView.cpp b/src/gui/EdgeView.cpp
index fb9fb07..46d3e77 100644
--- a/src/gui/EdgeView.cpp
+++ b/src/gui/EdgeView.cpp
@@ -75,7 +75,7 @@ EdgeView::EdgeView(SharedPtr<Canvas> canvas,
double
EdgeView::length_hint() const
{
- return _edge->tail().lock()->duration() * 10;
+ return _edge->tail().lock()->duration().ticks() * 10;
}
diff --git a/src/gui/GladeXml.hpp b/src/gui/GladeXml.hpp
index 66e2a99..09ba044 100644
--- a/src/gui/GladeXml.hpp
+++ b/src/gui/GladeXml.hpp
@@ -19,6 +19,7 @@
#include <string>
#include <gtkmm.h>
#include <libglademm/xml.h>
+#include "config.h"
class GladeXml
{
@@ -31,13 +32,13 @@ public:
std::ifstream fs(glade_filename.c_str());
if (fs.fail()) { // didn't find it, check PKGDATADIR
fs.clear();
- glade_filename = PKGDATADIR;
+ glade_filename = MACHINA_DATA_DIR;
glade_filename += "/machina.glade";
fs.open(glade_filename.c_str());
if (fs.fail()) {
std::cerr << "Unable to find machina.glade in current directory or "
- << PKGDATADIR << "." << std::endl;
+ << MACHINA_DATA_DIR << "." << std::endl;
exit(EXIT_FAILURE);
}
fs.close();
diff --git a/src/gui/MachinaCanvas.cpp b/src/gui/MachinaCanvas.cpp
index 717960e..222f1a8 100644
--- a/src/gui/MachinaCanvas.cpp
+++ b/src/gui/MachinaCanvas.cpp
@@ -17,6 +17,7 @@
#include <map>
#include "raul/SharedPtr.hpp"
+#include "raul/TimeStamp.hpp"
#include "machina/Node.hpp"
#include "machina/Machine.hpp"
#include "machina/Action.hpp"
@@ -27,6 +28,7 @@
#include "NodeView.hpp"
#include "EdgeView.hpp"
+using namespace Raul;
using namespace FlowCanvas;
@@ -57,11 +59,12 @@ MachinaCanvas::node_clicked(WeakPtr<NodeView> item, GdkEventButton* event)
SharedPtr<NodeView> last = _last_clicked.lock();
if (last) {
- if (node != last)
+ if (node != last) {
if (get_connection(last, node))
disconnect_node(last, node);
else
connect_node(last, node);
+ }
last->set_default_base_color();
_last_clicked.reset();
@@ -78,7 +81,7 @@ bool
MachinaCanvas::canvas_event(GdkEvent* event)
{
static int last = 0;
-
+
SharedPtr<Machina::Machine> machine = _app->machine();
if (!machine)
return false;
@@ -92,7 +95,8 @@ MachinaCanvas::canvas_event(GdkEvent* event)
string name = string("Note")+(char)(last++ +'0');
- SharedPtr<Machina::Node> node(new Machina::Node(1.0, false));
+ TimeDuration dur(TimeUnit(TimeUnit::BEATS, 0), 1.0);
+ SharedPtr<Machina::Node> node(new Machina::Node(dur, false));
SharedPtr<NodeView> view(new NodeView(_app->window(), shared_from_this(), node,
name, x, y));
diff --git a/src/gui/MachinaGUI.cpp b/src/gui/MachinaGUI.cpp
index d7927df..761fb8d 100644
--- a/src/gui/MachinaGUI.cpp
+++ b/src/gui/MachinaGUI.cpp
@@ -44,6 +44,7 @@ using namespace Machina;
MachinaGUI::MachinaGUI(SharedPtr<Machina::Engine> engine)
: _refresh(false)
, _evolve(false)
+ , _unit(TimeUnit::BEATS, 19200)
, _engine(engine)
, _maid(new Raul::Maid(32))
{
@@ -285,7 +286,7 @@ void
MachinaGUI::evolve_toggled()
{
if (_evolve_button->get_active()) {
- _evolver = SharedPtr<Evolver>(new Evolver(_target_filename, _engine->machine()));
+ _evolver = SharedPtr<Evolver>(new Evolver(_unit, _target_filename, _engine->machine()));
_evolve = true;
stop_clicked();
_engine->driver()->set_machine(SharedPtr<Machine>());
@@ -535,7 +536,8 @@ MachinaGUI::menu_import_midi()
if (result == Gtk::RESPONSE_OK) {
SharedPtr<Machina::SMFDriver> file_driver(new Machina::SMFDriver());
- double length = length_sb->get_value_as_int();
+ double length_dbl = length_sb->get_value_as_int();
+ Raul::TimeStamp length(_unit, length_dbl);
SharedPtr<Machina::Machine> machine = file_driver->learn(dialog.get_filename(), 0.0, length);
@@ -574,8 +576,8 @@ MachinaGUI::menu_export_midi()
_engine->driver()->deactivate();
const SharedPtr<Machina::Machine> m = _engine->machine();
m->set_sink(file_driver->writer());
- file_driver->writer()->start(dialog.get_filename());
- file_driver->run(m, 32); // TODO: solve halting problem
+ file_driver->writer()->start(dialog.get_filename(), TimeStamp(_unit, 0.0));
+ file_driver->run(m, TimeStamp(_unit, 32.0)); // TODO: solve halting problem
m->set_sink(_engine->driver());
m->reset(m->time());
file_driver->writer()->finish();
diff --git a/src/gui/MachinaGUI.hpp b/src/gui/MachinaGUI.hpp
index 342cedf..c539bd0 100644
--- a/src/gui/MachinaGUI.hpp
+++ b/src/gui/MachinaGUI.hpp
@@ -90,10 +90,12 @@ protected:
string _save_uri;
string _target_filename;
+
+ Raul::TimeUnit _unit;
boost::shared_ptr<MachinaCanvas> _canvas;
boost::shared_ptr<Machina::Engine> _engine;
-
+
SharedPtr<Raul::Maid> _maid;
SharedPtr<Machina::Evolver> _evolver;
diff --git a/src/gui/NodePropertiesWindow.cpp b/src/gui/NodePropertiesWindow.cpp
index 9f2e77a..d74d4b5 100644
--- a/src/gui/NodePropertiesWindow.cpp
+++ b/src/gui/NodePropertiesWindow.cpp
@@ -64,7 +64,8 @@ NodePropertiesWindow::apply_clicked()
action->event()[1] = note;
}
- double duration = _duration_spinbutton->get_value();
+ double duration_dbl = _duration_spinbutton->get_value();
+ TimeStamp duration(TimeUnit(TimeUnit::BEATS, 19200), duration_dbl);
_node->set_duration(duration);
_node->set_changed();
}
@@ -102,7 +103,7 @@ NodePropertiesWindow::set_node(SharedPtr<Machina::Node> node)
} else {
_note_spinbutton->hide();
}
- _duration_spinbutton->set_value(node->duration());
+ _duration_spinbutton->set_value(node->duration().to_double());
}
diff --git a/src/gui/main.cpp b/src/gui/main.cpp
index 3fc80aa..e819ac2 100644
--- a/src/gui/main.cpp
+++ b/src/gui/main.cpp
@@ -45,6 +45,7 @@ main(int argc, char** argv)
SharedPtr<Machina::Machine> machine;
// Load machine, if given
+#if 0
if (argc >= 2) {
const string filename = argv[1];
cout << "Building machine from MIDI file " << filename << endl;
@@ -64,9 +65,10 @@ main(int argc, char** argv)
machine = Loader(rdf_world).load(filename);
}
}
+#endif
if (!machine)
- machine = SharedPtr<Machine>(new Machine());
+ machine = SharedPtr<Machine>(new Machine(TimeUnit(TimeUnit::BEATS, 0)));
// Build engine
SharedPtr<Driver> driver;
diff --git a/src/gui/wscript b/src/gui/wscript
new file mode 100644
index 0000000..3e461bf
--- /dev/null
+++ b/src/gui/wscript
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+import Params
+import autowaf
+
+def build(bld):
+ obj = bld.create_obj('cpp', 'shlib')
+ obj.source = '''
+ EdgeView.cpp
+ MachinaCanvas.cpp
+ MachinaGUI.cpp
+ NodePropertiesWindow.cpp
+ NodeView.cpp
+ '''
+
+ obj.includes = ['.', '..', '../engine']
+ obj.name = 'libmachina_gui'
+ obj.target = 'machina_gui'
+ obj.uselib_local = 'libmachina_engine'
+ autowaf.use_lib(bld, obj, '''
+ FLOWCANVAS
+ GLADEMM
+ GLIBMM
+ GNOMECANVASMM
+ GTKMM
+ RAUL
+ REDLANDMM
+ SIGCPP
+ EUGENE
+ ''')
+
+ # GUI runtime files
+ install_files('DATADIR', 'machina', 'machina.glade')
+ install_files('DATADIR', 'machina', 'machina.svg')
+
+ # Executable
+ obj = bld.create_obj('cpp', 'program')
+ obj.target = 'machina_gui'
+ obj.source = 'main.cpp'
+ obj.includes = ['.', '../engine']
+ obj.defines = 'VERSION=\\\"' + bld.env()['MACHINA_VERSION'] + '\\\"'
+ obj.uselib_local = 'libmachina_engine libmachina_gui'
+ autowaf.use_lib(bld, obj, 'GTHREAD GLIBMM REDLANDMM RAUL MACHINA EUGENE')
+
+ autowaf.build_wrapper(bld, 'machina.in', obj)