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/Node.cpp12
-rw-r--r--src/engine/machina/Node.hpp3
-rw-r--r--src/gui/MachinaCanvas.cpp1
-rw-r--r--src/gui/MachinaGUI.cpp29
-rw-r--r--src/gui/MachinaGUI.hpp1
-rw-r--r--src/gui/NodeView.cpp14
-rw-r--r--src/gui/machina.glade1
8 files changed, 53 insertions, 10 deletions
diff --git a/src/engine/Loader.cpp b/src/engine/Loader.cpp
index 02aff51..539c86f 100644
--- a/src/engine/Loader.cpp
+++ b/src/engine/Loader.cpp
@@ -128,7 +128,7 @@ Loader::load(const Glib::ustring& uri)
cout << "Node: " << node_id << " - " << duration << endl;
if (created.find(node_id.collate_key()) == created.end()) {
- SharedPtr<Node> node(new Node(strtod(duration.c_str(), NULL), true));
+ SharedPtr<Node> node(new Node(strtod(duration.c_str(), NULL), false));
machine->add_node(node);
created.insert(std::make_pair(node_id.collate_key(), node));
} else {
diff --git a/src/engine/Node.cpp b/src/engine/Node.cpp
index d94e0bc..768422e 100644
--- a/src/engine/Node.cpp
+++ b/src/engine/Node.cpp
@@ -25,6 +25,7 @@ namespace Machina {
Node::Node(BeatCount duration, bool initial)
: _is_initial(initial)
+ , _is_selector(false)
, _is_active(false)
, _enter_time(0)
, _duration(duration)
@@ -127,9 +128,14 @@ Node::write_state(Raul::RDFWriter& writer)
if (!_id)
set_id(writer.blank_id());
- writer.write(_id,
- RdfId(RdfId::RESOURCE, "rdf:type"),
- RdfId(RdfId::RESOURCE, "machina:Node"));
+ if (_is_selector)
+ writer.write(_id,
+ RdfId(RdfId::RESOURCE, "rdf:type"),
+ RdfId(RdfId::RESOURCE, "machina:SelectorNode"));
+ else
+ writer.write(_id,
+ RdfId(RdfId::RESOURCE, "rdf:type"),
+ RdfId(RdfId::RESOURCE, "machina:Node"));
writer.write(_id,
RdfId(RdfId::RESOURCE, "machina:duration"),
diff --git a/src/engine/machina/Node.hpp b/src/engine/machina/Node.hpp
index 5181149..b4c72e2 100644
--- a/src/engine/machina/Node.hpp
+++ b/src/engine/machina/Node.hpp
@@ -66,6 +66,8 @@ public:
bool is_initial() const { return _is_initial; }
void set_initial(bool i) { _is_initial = i; }
+ bool is_selector() const { return _is_selector; }
+ void set_selector(bool i) { _is_selector = i; }
bool is_active() const { return _is_active; }
BeatTime enter_time() const { assert(_is_active); return _enter_time; }
BeatTime exit_time() const { assert(_is_active); return _enter_time + _duration; }
@@ -77,6 +79,7 @@ public:
private:
bool _is_initial;
+ bool _is_selector;
bool _is_active;
BeatTime _enter_time; ///< valid iff _is_active
BeatCount _duration;
diff --git a/src/gui/MachinaCanvas.cpp b/src/gui/MachinaCanvas.cpp
index e11532e..a6a565e 100644
--- a/src/gui/MachinaCanvas.cpp
+++ b/src/gui/MachinaCanvas.cpp
@@ -15,7 +15,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
-//#include "config.h"
#include <map>
#include <raul/SharedPtr.h>
#include "machina/Node.hpp"
diff --git a/src/gui/MachinaGUI.cpp b/src/gui/MachinaGUI.cpp
index 381d8f4..ffbfb5a 100644
--- a/src/gui/MachinaGUI.cpp
+++ b/src/gui/MachinaGUI.cpp
@@ -75,7 +75,8 @@ MachinaGUI::MachinaGUI(SharedPtr<Machina::Engine> engine)
xml->get_widget("arrange_but", _arrange_button);
_canvas_scrolledwindow->add(*_canvas);
- //m_canvas_scrolledwindow->signal_event().connect(sigc::mem_fun(_canvas, &FlowCanvas::scroll_event_handler));
+ _canvas_scrolledwindow->signal_event().connect(sigc::mem_fun(this,
+ &MachinaGUI::scrolled_window_event));
_canvas->scroll_to(static_cast<int>(_canvas->width()/2 - 320),
static_cast<int>(_canvas->height()/2 - 240)); // FIXME: hardcoded
@@ -195,6 +196,32 @@ MachinaGUI::idle_callback()
}
+bool
+MachinaGUI::scrolled_window_event(GdkEvent* event)
+{
+ if (event->type == GDK_KEY_PRESS) {
+ if (event->key.keyval == GDK_Delete) {
+
+ ItemList selection = _canvas->selected_items();
+ _canvas->clear_selection();
+
+ for (ItemList::iterator i = selection.begin();
+ i != selection.end(); ++i) {
+ SharedPtr<NodeView> view = PtrCast<NodeView>(*i);
+ if (view) {
+ machine()->remove_node(view->node());
+ _canvas->remove_item(view);
+ }
+ }
+
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
void
MachinaGUI::update_toolbar()
{
diff --git a/src/gui/MachinaGUI.hpp b/src/gui/MachinaGUI.hpp
index 3c16f86..5dd943f 100644
--- a/src/gui/MachinaGUI.hpp
+++ b/src/gui/MachinaGUI.hpp
@@ -71,6 +71,7 @@ protected:
void zoom_changed();
bool idle_callback();
void update_toolbar();
+ bool scrolled_window_event(GdkEvent* ev);
void on_pane_position_changed();
void on_messages_expander_changed();
diff --git a/src/gui/NodeView.cpp b/src/gui/NodeView.cpp
index be40047..6ff21ee 100644
--- a/src/gui/NodeView.cpp
+++ b/src/gui/NodeView.cpp
@@ -43,10 +43,16 @@ NodeView::on_double_click(GdkEventButton*)
void
NodeView::on_click(GdkEventButton* event)
{
- if (event->button == 3) {
- bool is_initial = _node->is_initial();
- _node->set_initial( ! is_initial );
- set_border_width(is_initial ? 1.0 : 2.0);
+ if (event->state & GDK_CONTROL_MASK) {
+ if (event->button == 1) {
+ bool is_initial = _node->is_initial();
+ _node->set_initial( ! is_initial );
+ set_border_width(is_initial ? 1.0 : 6.0);
+ } else if (event->button == 3) {
+ bool is_selector = _node->is_selector();
+ _node->set_selector( ! is_selector );
+ set_border_width(is_selector ? 1.0 : 3.0);
+ }
}
}
diff --git a/src/gui/machina.glade b/src/gui/machina.glade
index df73a85..5b12fa1 100644
--- a/src/gui/machina.glade
+++ b/src/gui/machina.glade
@@ -468,6 +468,7 @@
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="can_focus">True</property>
+ <property name="has_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property>
<property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
<property name="shadow_type">GTK_SHADOW_IN</property>