From c5d5b612f91a45fb0f462fe554e4132d1af1db01 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 9 Feb 2007 19:19:31 +0000 Subject: Removed data type stuff from SLV2. Reworked event system in FlowCanvas to use signals. Added straight connections and arrowheads to FlowCanvas, Ellipse fixes. git-svn-id: http://svn.drobilla.net/lad/machina@293 a436a847-0d15-0410-975c-d299462d15a1 --- src/gui/MachinaCanvas.cpp | 37 ++++++++++++++++++++++++------------- src/gui/MachinaCanvas.hpp | 1 + 2 files changed, 25 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/gui/MachinaCanvas.cpp b/src/gui/MachinaCanvas.cpp index 2309a5c..303774f 100644 --- a/src/gui/MachinaCanvas.cpp +++ b/src/gui/MachinaCanvas.cpp @@ -25,6 +25,7 @@ MachinaCanvas::MachinaCanvas(MachinaGUI* app, int width, int height) : FlowCanvas(width, height), _app(app) { + } @@ -99,11 +100,11 @@ MachinaCanvas::status_message(const string& msg) void MachinaCanvas::item_selected(SharedPtr i) { + cerr << "SELECTED: " << i->name() << endl; + SharedPtr item = PtrCast(i); if (!item) return; - - cerr << "SELECTED: " << i->name() << endl; SharedPtr last = _last_selected.lock(); @@ -121,6 +122,15 @@ MachinaCanvas::item_selected(SharedPtr i) } +void +MachinaCanvas::item_clicked(SharedPtr i, GdkEventButton* event) +{ + cerr << "CLICKED " << event->button << ": " << i->name() << endl; + + //return false; +} + + bool MachinaCanvas::canvas_event(GdkEvent* event) { @@ -133,25 +143,26 @@ MachinaCanvas::canvas_event(GdkEvent* event) const double x = event->button.x; const double y = event->button.y; + SharedPtr item; + if (event->button.button == 1) { - SharedPtr item(new Ellipse(shared_from_this(), + item = SharedPtr(new Ellipse(shared_from_this(), string("Note")+(char)(last++ +'0'), x, y, 30, 30, true)); + } else if (event->button.button == 2) { + item = SharedPtr(new Module(shared_from_this(), + string("Note")+(char)(last++ +'0'), x, y, true)); + } + + if (item) { item->signal_selected.connect(sigc::bind(sigc::mem_fun(this, &MachinaCanvas::item_selected), item)); + item->signal_clicked.connect(sigc::bind<0>(sigc::mem_fun(this, + &MachinaCanvas::item_clicked), item)); add_item(item); - item->raise_to_top(); - } else if (event->button.button == 2) { - SharedPtr item(new Module(shared_from_this(), - string("Note")+(char)(last++ +'0'), x, y, true)); item->resize(); - add_item(item); - } else if (event->button.button == 3) { - //_last_click_x = (int)event->button.x; - //_last_click_y = (int)event->button.y; - //show_menu(event); + item->raise_to_top(); } } return FlowCanvas::canvas_event(event); } - diff --git a/src/gui/MachinaCanvas.hpp b/src/gui/MachinaCanvas.hpp index 85ae550..b06a5d8 100644 --- a/src/gui/MachinaCanvas.hpp +++ b/src/gui/MachinaCanvas.hpp @@ -44,6 +44,7 @@ protected: bool canvas_event(GdkEvent* event); void item_selected(SharedPtr item); + void item_clicked(SharedPtr item, GdkEventButton* ev); private: MachinaGUI* _app; -- cgit v1.2.1