From 0123cdeacc9acc7ca16fa8b0a9dee7a5d916b7df Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 5 Apr 2007 05:50:53 +0000 Subject: Selector states. Togglable edge and state labels. Builder fixes. GUI/input/etc fixes. git-svn-id: http://svn.drobilla.net/lad/machina@398 a436a847-0d15-0410-975c-d299462d15a1 --- src/gui/MachinaCanvas.cpp | 4 ++++ src/gui/MachinaGUI.cpp | 6 +++++ src/gui/NodeView.cpp | 45 ++++++++++++++++++++++++++++++++----- src/gui/NodeView.hpp | 4 +++- src/gui/machina.glade | 57 ++++++----------------------------------------- 5 files changed, 59 insertions(+), 57 deletions(-) (limited to 'src/gui') diff --git a/src/gui/MachinaCanvas.cpp b/src/gui/MachinaCanvas.cpp index 134b885..716a40d 100644 --- a/src/gui/MachinaCanvas.cpp +++ b/src/gui/MachinaCanvas.cpp @@ -52,6 +52,9 @@ MachinaCanvas::node_clicked(WeakPtr item, GdkEventButton* event) if (!node) return; + if (event->state & GDK_CONTROL_MASK) + return; + // Middle click, learn if (event->button == 2) { _app->machine()->learn(Machina::LearnRequest::create(_app->maid(), node->node())); @@ -192,6 +195,7 @@ void MachinaCanvas::build(SharedPtr machine) { destroy(); + _last_clicked.reset(); if (!machine) return; diff --git a/src/gui/MachinaGUI.cpp b/src/gui/MachinaGUI.cpp index 3cf38bd..e5e6d90 100644 --- a/src/gui/MachinaGUI.cpp +++ b/src/gui/MachinaGUI.cpp @@ -608,6 +608,12 @@ void MachinaGUI::show_labels_toggled() { const bool show = _menu_view_labels->get_active(); + + for (ItemList::iterator i = _canvas->items().begin(); i != _canvas->items().end(); ++i) { + const SharedPtr nv = PtrCast(*i); + if (nv) + nv->show_label(show); + } for (ConnectionList::iterator c = _canvas->connections().begin(); c != _canvas->connections().end(); ++c) { diff --git a/src/gui/NodeView.cpp b/src/gui/NodeView.cpp index 6ff21ee..d38e228 100644 --- a/src/gui/NodeView.cpp +++ b/src/gui/NodeView.cpp @@ -15,6 +15,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include #include "NodeView.hpp" #include "NodePropertiesWindow.hpp" @@ -29,7 +30,8 @@ NodeView::NodeView(Gtk::Window* window, , _window(window) , _node(node) { - //signal_double_clicked.connect(sigc::mem_fun(this, &NodeView::on_double_click)); + signal_clicked.connect(sigc::mem_fun(this, &NodeView::handle_click)); + update_state(); } @@ -41,27 +43,50 @@ NodeView::on_double_click(GdkEventButton*) void -NodeView::on_click(GdkEventButton* event) +NodeView::handle_click(GdkEventButton* event) { 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); + update_state(); } 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); + update_state(); } } } void -NodeView::update_state() +NodeView::show_label(bool show) { - static const uint32_t active_color = 0x80808AFF; + char str[4]; + + SharedPtr action + = PtrCast(_node->enter_action()); + + if (show) { + if (action && action->event_size() >= 2 + && (action->event()[0] & 0xF0) == 0x90) { + + unsigned char note = action->event()[1]; + snprintf(str, 4, "%d", (int)note); + + set_name(str); + } + } else { + set_name(""); + } +} + +void +NodeView::update_state() +{ + static const uint32_t active_color = 0xA0A0AAFF; + if (_node->is_active()) { if (_color != active_color) { _old_color = _color; @@ -70,5 +95,13 @@ NodeView::update_state() } else if (_color == active_color) { set_base_color(_old_color); } + + if (_node->is_selector()) + if (_node->is_active()) + set_base_color(0x00FF00FF); + else + set_base_color(0x00A000FF); + + set_border_width(_node->is_initial() ? 4.0 : 1.0); } diff --git a/src/gui/NodeView.hpp b/src/gui/NodeView.hpp index 4641787..41ff45f 100644 --- a/src/gui/NodeView.hpp +++ b/src/gui/NodeView.hpp @@ -32,11 +32,13 @@ public: double y); SharedPtr node() { return _node; } + + void show_label(bool show); void update_state(); private: - void on_click(GdkEventButton* ev); + void handle_click(GdkEventButton* ev); void on_double_click(GdkEventButton* ev); Gtk::Window* _window; diff --git a/src/gui/machina.glade b/src/gui/machina.glade index b5349be..61096f1 100644 --- a/src/gui/machina.glade +++ b/src/gui/machina.glade @@ -316,51 +316,6 @@ - - - True - Add selected states - gtk-add - True - True - False - - - False - True - - - - - - True - Multiply (merge) selected states - - True - gtk-convert - True - True - False - - - False - True - - - - - - True - True - True - True - - - False - False - - - True @@ -732,7 +687,8 @@ True Machina © 2007 Dave Robillard <http://drobilla.net> - It's a machine + A MIDI sequencer based on + probabilistic finite-state automata 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 @@ -808,14 +764,15 @@ along with Machina; if not, write to the Free Software Foundation, Inc., True - Interface is still a bit arbitrary: + Initial nodes are shown with a thick border. +Selector nodes are shown in green. - Middle click canvas to create a new node - Middle click nodes to learn a MIDI note for that node - Right click two nodes in succession to connect nodes -- Double click a node to make it an initial node - -Connect some nodes up and double click one. You'll get it. +- Double click a node to show its properties dialog +- Ctrl+Left click a node to make it an initial node +- Ctrl+Right click a node to make it a selector node False False GTK_JUSTIFY_LEFT -- cgit v1.2.1