aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/engine/Loader.cpp2
-rw-r--r--src/engine/MachineBuilder.cpp4
-rw-r--r--src/engine/Node.cpp22
-rw-r--r--src/engine/machina/Node.hpp16
-rw-r--r--src/gui/MachinaGUI.cpp6
-rw-r--r--src/gui/NodePropertiesWindow.cpp16
-rw-r--r--src/gui/NodeView.cpp22
-rw-r--r--src/gui/NodeView.hpp2
8 files changed, 57 insertions, 33 deletions
diff --git a/src/engine/Loader.cpp b/src/engine/Loader.cpp
index aa4d403..4449ae2 100644
--- a/src/engine/Loader.cpp
+++ b/src/engine/Loader.cpp
@@ -130,7 +130,7 @@ Loader::load(const Glib::ustring& uri)
results = query.run(_rdf_world, model);
for (Query::Results::iterator i = results.begin(); i != results.end(); ++i) {
- Created::iterator node_i = created.find((const char*)(*i)["initialNode"]);
+ Created::iterator node_i = created.find((const char*)(*i)["node"]);
if (node_i != created.end()) {
SharedPtr<Node> node = node_i->second;
const int note_num = (*i)["note"];
diff --git a/src/engine/MachineBuilder.cpp b/src/engine/MachineBuilder.cpp
index af486df..1830ee6 100644
--- a/src/engine/MachineBuilder.cpp
+++ b/src/engine/MachineBuilder.cpp
@@ -214,8 +214,8 @@ MachineBuilder::event(Raul::BeatTime time_offset,
assert(_connect_node->outgoing_edges().empty());
_connect_node->set_enter_action(resolved->enter_action());
_connect_node->set_exit_action(resolved->exit_action());
- resolved->remove_enter_action();
- resolved->remove_exit_action();
+ resolved->set_enter_action(SharedPtr<Action>());
+ resolved->set_exit_action(SharedPtr<Action>());
set_node_duration(_connect_node, resolved->duration());
resolved = _connect_node;
if (_machine->nodes().find(_connect_node) == _machine->nodes().end())
diff --git a/src/engine/Node.cpp b/src/engine/Node.cpp
index cb1a8eb..77c6d00 100644
--- a/src/engine/Node.cpp
+++ b/src/engine/Node.cpp
@@ -47,6 +47,7 @@ Node::set_selector(bool yn)
for (Edges::iterator i = _outgoing_edges.begin(); i != _outgoing_edges.end(); ++i)
(*i)->set_probability((*i)->probability() / prob_sum);
}
+ _changed = true;
}
@@ -54,28 +55,15 @@ void
Node::set_enter_action(SharedPtr<Action> action)
{
_enter_action = action;
+ _changed = true;
}
void
-Node::remove_enter_action()
-{
- _enter_action.reset();
-}
-
-
-
-void
Node::set_exit_action(SharedPtr<Action> action)
{
_exit_action = action;
-}
-
-
-void
-Node::remove_exit_action()
-{
- _exit_action.reset();
+ _changed = true;
}
@@ -84,8 +72,10 @@ Node::enter(SharedPtr<Raul::MIDISink> sink, BeatTime time)
{
assert(!_is_active);
+ _changed = true;
_is_active = true;
_enter_time = time;
+
if (sink && _enter_action)
_enter_action->execute(sink, time);
}
@@ -98,6 +88,8 @@ Node::exit(SharedPtr<Raul::MIDISink> sink, BeatTime time)
if (sink && _exit_action)
_exit_action->execute(sink, time);
+
+ _changed = true;
_is_active = false;
_enter_time = 0;
}
diff --git a/src/engine/machina/Node.hpp b/src/engine/machina/Node.hpp
index 2e26f0a..041f443 100644
--- a/src/engine/machina/Node.hpp
+++ b/src/engine/machina/Node.hpp
@@ -47,10 +47,7 @@ public:
Node(BeatCount duration=0, bool initial=false);
void set_enter_action(SharedPtr<Action> action);
- void remove_enter_action();
-
void set_exit_action(SharedPtr<Action> action);
- void remove_exit_action();
SharedPtr<Action> enter_action() { return _enter_action; }
SharedPtr<Action> exit_action() { return _exit_action; }
@@ -73,11 +70,24 @@ public:
void set_duration(BeatCount d) { _duration = d; }
bool is_selector() const { return _is_selector; }
void set_selector(bool i);
+
+ /// Schroedinger's flag
+ inline bool changed() {
+ if (_changed) {
+ _changed = false;
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ void set_changed() { _changed = true; }
typedef Raul::List<SharedPtr<Edge> > Edges;
Edges& outgoing_edges() { return _outgoing_edges; }
private:
+ bool _changed;
bool _is_initial;
bool _is_selector;
bool _is_active;
diff --git a/src/gui/MachinaGUI.cpp b/src/gui/MachinaGUI.cpp
index 6f8881e..0071743 100644
--- a/src/gui/MachinaGUI.cpp
+++ b/src/gui/MachinaGUI.cpp
@@ -151,10 +151,12 @@ MachinaGUI::~MachinaGUI()
bool
MachinaGUI::idle_callback()
{
+ const bool show_labels = _menu_view_labels->get_active();
+
for (ItemList::iterator i = _canvas->items().begin(); i != _canvas->items().end(); ++i) {
const SharedPtr<NodeView> nv = PtrCast<NodeView>(*i);
- if (nv)
- nv->update_state();
+ if (nv && nv->node()->changed())
+ nv->update_state(show_labels);
}
return true;
diff --git a/src/gui/NodePropertiesWindow.cpp b/src/gui/NodePropertiesWindow.cpp
index 6ba3e47..9f2e77a 100644
--- a/src/gui/NodePropertiesWindow.cpp
+++ b/src/gui/NodePropertiesWindow.cpp
@@ -17,6 +17,7 @@
#include <string>
#include "machina/MidiAction.hpp"
+#include "machina/ActionFactory.hpp"
#include "NodePropertiesWindow.hpp"
#include "GladeXml.hpp"
@@ -52,8 +53,20 @@ NodePropertiesWindow::~NodePropertiesWindow()
void
NodePropertiesWindow::apply_clicked()
{
+ const uint8_t note = _note_spinbutton->get_value();
+ if (!_node->enter_action()) {
+ _node->set_enter_action(ActionFactory::note_on(note));
+ _node->set_exit_action(ActionFactory::note_off(note));
+ } else {
+ SharedPtr<MidiAction> action = PtrCast<MidiAction>(_node->enter_action());
+ action->event()[1] = note;
+ action = PtrCast<MidiAction>(_node->exit_action());
+ action->event()[1] = note;
+ }
+
double duration = _duration_spinbutton->get_value();
_node->set_duration(duration);
+ _node->set_changed();
}
@@ -83,6 +96,9 @@ NodePropertiesWindow::set_node(SharedPtr<Machina::Node> node)
&& (enter_action->event()[0] & 0xF0) == 0x90) {
_note_spinbutton->set_value(enter_action->event()[1]);
_note_spinbutton->show();
+ } else if (!enter_action) {
+ _note_spinbutton->set_value(60);
+ _note_spinbutton->show();
} else {
_note_spinbutton->hide();
}
diff --git a/src/gui/NodeView.cpp b/src/gui/NodeView.cpp
index 18db225..c0378a7 100644
--- a/src/gui/NodeView.cpp
+++ b/src/gui/NodeView.cpp
@@ -15,10 +15,13 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include <iostream>
#include <machina/MidiAction.hpp>
#include "NodeView.hpp"
#include "NodePropertiesWindow.hpp"
+using namespace std;
+
NodeView::NodeView(Gtk::Window* window,
SharedPtr<FlowCanvas::Canvas> canvas,
@@ -31,7 +34,7 @@ NodeView::NodeView(Gtk::Window* window,
, _node(node)
{
signal_clicked.connect(sigc::mem_fun(this, &NodeView::handle_click));
- update_state();
+ update_state(false);
}
@@ -49,11 +52,11 @@ NodeView::handle_click(GdkEventButton* event)
if (event->button == 1) {
bool is_initial = _node->is_initial();
_node->set_initial( ! is_initial );
- update_state();
+ update_state(_label != NULL);
} else if (event->button == 3) {
bool is_selector = _node->is_selector();
_node->set_selector( ! is_selector );
- update_state();
+ update_state(_label != NULL);
}
}
}
@@ -68,12 +71,10 @@ NodeView::show_label(bool show)
= PtrCast<Machina::MidiAction>(_node->enter_action());
if (show) {
- if (action && action->event_size() >= 2
+ if (action && action->event_size() > 1
&& (action->event()[0] & 0xF0) == 0x90) {
-
- unsigned char note = action->event()[1];
- snprintf(str, 4, "%d", (int)note);
-
+ uint8_t note = action->event()[1];
+ snprintf(str, 4, "%d", note);
set_name(str);
}
} else {
@@ -83,7 +84,7 @@ NodeView::show_label(bool show)
void
-NodeView::update_state()
+NodeView::update_state(bool show_labels)
{
static const uint32_t active_color = 0xA0A0AAFF;
@@ -103,5 +104,8 @@ NodeView::update_state()
set_base_color(0x00A000FF);
set_border_width(_node->is_initial() ? 4.0 : 1.0);
+
+ if (show_labels)
+ show_label(true);
}
diff --git a/src/gui/NodeView.hpp b/src/gui/NodeView.hpp
index 82c1bdb..a0dd5b8 100644
--- a/src/gui/NodeView.hpp
+++ b/src/gui/NodeView.hpp
@@ -35,7 +35,7 @@ public:
void show_label(bool show);
- void update_state();
+ void update_state(bool show_labels);
private:
void handle_click(GdkEventButton* ev);