aboutsummaryrefslogtreecommitdiffstats
path: root/src/gui/MachinaCanvas.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2013-01-11 21:07:26 +0000
committerDavid Robillard <d@drobilla.net>2013-01-11 21:07:26 +0000
commitbef1c2ea010da638ffbb437c37a6d32ddc99b568 (patch)
tree3c40f06df385e40edd512247eda23b1f650623df /src/gui/MachinaCanvas.cpp
parentd88a8a0a01baff2c4038c315672c6c670361b82c (diff)
downloadmachina-bef1c2ea010da638ffbb437c37a6d32ddc99b568.tar.gz
machina-bef1c2ea010da638ffbb437c37a6d32ddc99b568.tar.bz2
machina-bef1c2ea010da638ffbb437c37a6d32ddc99b568.zip
Bring Machina back into the fold (fix #844).
git-svn-id: http://svn.drobilla.net/lad/trunk/machina@4921 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/gui/MachinaCanvas.cpp')
-rw-r--r--src/gui/MachinaCanvas.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/gui/MachinaCanvas.cpp b/src/gui/MachinaCanvas.cpp
index da03cd9..57cffc9 100644
--- a/src/gui/MachinaCanvas.cpp
+++ b/src/gui/MachinaCanvas.cpp
@@ -17,7 +17,6 @@
#include <map>
-#include "raul/log.hpp"
#include "raul/SharedPtr.hpp"
#include "raul/TimeStamp.hpp"
@@ -40,6 +39,9 @@ MachinaCanvas::MachinaCanvas(MachinaGUI* app, int width, int height)
, _app(app)
{
widget().grab_focus();
+
+ signal_event.connect(
+ sigc::mem_fun(this, &MachinaCanvas::on_event));
}
bool
@@ -56,7 +58,7 @@ MachinaCanvas::node_clicked(WeakPtr<NodeView> item, GdkEventButton* event)
_app->controller()->learn(_app->maid(), node->node()->id());
return false;
- } else if (event->button == 3) { // Right click: connect/disconnect
+ } else if (event->button == 1) { // Left click: connect/disconnect
SharedPtr<NodeView> last = _last_clicked.lock();
if (last) {
@@ -72,7 +74,6 @@ MachinaCanvas::node_clicked(WeakPtr<NodeView> item, GdkEventButton* event)
} else {
_last_clicked = node;
- node->set_fill_color(0xFF0000FF);
}
return true;
@@ -99,7 +100,7 @@ MachinaCanvas::on_new_object(SharedPtr<Client::ClientObject> object)
{
const Machina::URIs& uris = URIs::instance();
const Raul::Atom& type = object->get(uris.rdf_type);
- if (type == "machina:Node") {
+ if (type.get<URIInt>() == uris.machina_Node) {
SharedPtr<NodeView> view(
new NodeView(_app->window(), *this, object,
object->get(uris.machina_canvas_x).get_float(),
@@ -108,13 +109,13 @@ MachinaCanvas::on_new_object(SharedPtr<Client::ClientObject> object)
//if ( ! node->enter_action() && ! node->exit_action() )
// view->set_base_color(0x101010FF);
- view->signal_click().connect(
+ view->signal_clicked().connect(
sigc::bind<0>(sigc::mem_fun(this, &MachinaCanvas::node_clicked),
WeakPtr<NodeView>(view)));
object->set_view(view);
- } else if (type == "machina:Edge") {
+ } else if (type.get<URIInt>() == uris.machina_Edge) {
SharedPtr<Machina::Client::ClientObject> tail = _app->client_model()->find(
object->get(uris.machina_tail_id).get_int32());
SharedPtr<Machina::Client::ClientObject> head = _app->client_model()->find(
@@ -129,7 +130,7 @@ MachinaCanvas::on_new_object(SharedPtr<Client::ClientObject> object)
object->set_view(view);
} else {
- Raul::error << "Unknown object type " << type << std::endl;
+ std::cerr << "Unknown object type" << std::endl;
}
}
@@ -137,12 +138,12 @@ void
MachinaCanvas::on_erase_object(SharedPtr<Client::ClientObject> object)
{
const Raul::Atom& type = object->get(URIs::instance().rdf_type);
- if (type == "machina:Node") {
+ if (type.get<URIInt>() == URIs::instance().machina_Node) {
// Destruction of the view will remove from the canvas
- } else if (type == "machina:Edge") {
+ } else if (type.get<URIInt>() == URIs::instance().machina_Edge) {
object->set_view(SharedPtr<Client::ClientObject::View>());
} else {
- Raul::error << "Unknown object type " << type << std::endl;
+ std::cerr << "Unknown object type" << std::endl;
}
}
@@ -150,10 +151,11 @@ void
MachinaCanvas::action_create_node(double x, double y)
{
Machina::Client::ClientObject obj(0);
- obj.set(URIs::instance().rdf_type, "machina:Node");
- obj.set(URIs::instance().machina_canvas_x, Raul::Atom((float)x));
- obj.set(URIs::instance().machina_canvas_y, Raul::Atom((float)y));
- obj.set(URIs::instance().machina_duration, Raul::Atom((float)1.0));
+ obj.set(URIs::instance().rdf_type,
+ _app->forge().make_urid(URIs::instance().machina_Node));
+ obj.set(URIs::instance().machina_canvas_x, _app->forge().make((float)x));
+ obj.set(URIs::instance().machina_canvas_y, _app->forge().make((float)y));
+ obj.set(URIs::instance().machina_duration, _app->forge().make(1.0f));
_app->controller()->create(obj);
}