aboutsummaryrefslogtreecommitdiffstats
path: root/src/gui/NodePropertiesWindow.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-03-25 03:01:32 +0000
committerDavid Robillard <d@drobilla.net>2007-03-25 03:01:32 +0000
commitf9c827a15fda4a0ce2ca3cfdc64ec1448385f149 (patch)
tree2a84884814207da7c5ec8f8d7b6902b8fc979910 /src/gui/NodePropertiesWindow.cpp
parent2bcf45ee765a733cd5b0a606ed44a7d311eb9783 (diff)
downloadmachina-f9c827a15fda4a0ce2ca3cfdc64ec1448385f149.tar.gz
machina-f9c827a15fda4a0ce2ca3cfdc64ec1448385f149.tar.bz2
machina-f9c827a15fda4a0ce2ca3cfdc64ec1448385f149.zip
Added node properties window.
Improved learning algorithm. git-svn-id: http://svn.drobilla.net/lad/machina@375 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/gui/NodePropertiesWindow.cpp')
-rw-r--r--src/gui/NodePropertiesWindow.cpp99
1 files changed, 99 insertions, 0 deletions
diff --git a/src/gui/NodePropertiesWindow.cpp b/src/gui/NodePropertiesWindow.cpp
new file mode 100644
index 0000000..151c602
--- /dev/null
+++ b/src/gui/NodePropertiesWindow.cpp
@@ -0,0 +1,99 @@
+/* This file is part of Machina.
+ * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
+ *
+ * Machina is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * Machina is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <string>
+#include "machina/MidiAction.hpp"
+#include "NodePropertiesWindow.hpp"
+#include "GladeXml.hpp"
+
+using namespace std;
+using namespace Machina;
+
+
+NodePropertiesWindow* NodePropertiesWindow::_instance = NULL;
+
+
+NodePropertiesWindow::NodePropertiesWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& xml)
+ : Gtk::Dialog(cobject)
+{
+ property_visible() = false;
+
+ xml->get_widget("node_properties_note_spinbutton", _note_spinbutton);
+ xml->get_widget("node_properties_duration_spinbutton", _duration_spinbutton);
+ xml->get_widget("node_properties_cancel_button", _cancel_button);
+ xml->get_widget("node_properties_ok_button", _ok_button);
+
+ _ok_button->signal_clicked().connect(sigc::mem_fun(this, &NodePropertiesWindow::ok_clicked));
+ _cancel_button->signal_clicked().connect(sigc::mem_fun(this, &NodePropertiesWindow::cancel_clicked));
+}
+
+
+NodePropertiesWindow::~NodePropertiesWindow()
+{
+}
+
+
+void
+NodePropertiesWindow::ok_clicked()
+{
+ assert(this == _instance);
+ delete _instance;
+ _instance = NULL;
+}
+
+
+void
+NodePropertiesWindow::cancel_clicked()
+{
+ assert(this == _instance);
+ delete _instance;
+ _instance = NULL;
+}
+
+
+void
+NodePropertiesWindow::set_node(SharedPtr<Machina::Node> node)
+{
+ _node = node;
+ SharedPtr<MidiAction> enter_action = PtrCast<MidiAction>(node->enter_action());
+ if (enter_action && enter_action->event_size() > 1
+ && (enter_action->event()[0] & 0xF0) == 0x90) {
+ _note_spinbutton->set_value(enter_action->event()[1]);
+ _note_spinbutton->show();
+ } else {
+ _note_spinbutton->hide();
+ }
+ _duration_spinbutton->set_value(node->duration());
+}
+
+
+void
+NodePropertiesWindow::present(Gtk::Window* parent, SharedPtr<Machina::Node> node)
+{
+ if (!_instance) {
+ Glib::RefPtr<Gnome::Glade::Xml> xml = GladeXml::create();
+
+ xml->get_widget_derived("node_properties_dialog", _instance);
+
+ if (parent)
+ _instance->set_transient_for(*parent);
+ }
+
+ _instance->set_node(node);
+ _instance->show();
+}
+