aboutsummaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-12-02 04:43:48 +0000
committerDavid Robillard <d@drobilla.net>2007-12-02 04:43:48 +0000
commit0e03c5f94d91086ac1b9f3b42cee4459290e353e (patch)
tree4ae2e6f69c5b127bc2d0ba2920a7e9a2741c0339 /src/gui
parent377f82ab766acf2c52674c11d507aeaee4349f46 (diff)
downloadmachina-0e03c5f94d91086ac1b9f3b42cee4459290e353e.tar.gz
machina-0e03c5f94d91086ac1b9f3b42cee4459290e353e.tar.bz2
machina-0e03c5f94d91086ac1b9f3b42cee4459290e353e.zip
Ability to add notes to non-MIDI-note nodes (ie make noise with mouse only).
Fix note label display. Canvas prettiness ++. git-svn-id: http://svn.drobilla.net/lad/machina@937 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/MachinaGUI.cpp6
-rw-r--r--src/gui/NodePropertiesWindow.cpp16
-rw-r--r--src/gui/NodeView.cpp22
-rw-r--r--src/gui/NodeView.hpp2
4 files changed, 34 insertions, 12 deletions
diff --git a/src/gui/MachinaGUI.cpp b/src/gui/MachinaGUI.cpp
index 6f8881e..0071743 100644
--- a/src/gui/MachinaGUI.cpp
+++ b/src/gui/MachinaGUI.cpp
@@ -151,10 +151,12 @@ MachinaGUI::~MachinaGUI()
bool
MachinaGUI::idle_callback()
{
+ const bool show_labels = _menu_view_labels->get_active();
+
for (ItemList::iterator i = _canvas->items().begin(); i != _canvas->items().end(); ++i) {
const SharedPtr<NodeView> nv = PtrCast<NodeView>(*i);
- if (nv)
- nv->update_state();
+ if (nv && nv->node()->changed())
+ nv->update_state(show_labels);
}
return true;
diff --git a/src/gui/NodePropertiesWindow.cpp b/src/gui/NodePropertiesWindow.cpp
index 6ba3e47..9f2e77a 100644
--- a/src/gui/NodePropertiesWindow.cpp
+++ b/src/gui/NodePropertiesWindow.cpp
@@ -17,6 +17,7 @@
#include <string>
#include "machina/MidiAction.hpp"
+#include "machina/ActionFactory.hpp"
#include "NodePropertiesWindow.hpp"
#include "GladeXml.hpp"
@@ -52,8 +53,20 @@ NodePropertiesWindow::~NodePropertiesWindow()
void
NodePropertiesWindow::apply_clicked()
{
+ const uint8_t note = _note_spinbutton->get_value();
+ if (!_node->enter_action()) {
+ _node->set_enter_action(ActionFactory::note_on(note));
+ _node->set_exit_action(ActionFactory::note_off(note));
+ } else {
+ SharedPtr<MidiAction> action = PtrCast<MidiAction>(_node->enter_action());
+ action->event()[1] = note;
+ action = PtrCast<MidiAction>(_node->exit_action());
+ action->event()[1] = note;
+ }
+
double duration = _duration_spinbutton->get_value();
_node->set_duration(duration);
+ _node->set_changed();
}
@@ -83,6 +96,9 @@ NodePropertiesWindow::set_node(SharedPtr<Machina::Node> node)
&& (enter_action->event()[0] & 0xF0) == 0x90) {
_note_spinbutton->set_value(enter_action->event()[1]);
_note_spinbutton->show();
+ } else if (!enter_action) {
+ _note_spinbutton->set_value(60);
+ _note_spinbutton->show();
} else {
_note_spinbutton->hide();
}
diff --git a/src/gui/NodeView.cpp b/src/gui/NodeView.cpp
index 18db225..c0378a7 100644
--- a/src/gui/NodeView.cpp
+++ b/src/gui/NodeView.cpp
@@ -15,10 +15,13 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#include <iostream>
#include <machina/MidiAction.hpp>
#include "NodeView.hpp"
#include "NodePropertiesWindow.hpp"
+using namespace std;
+
NodeView::NodeView(Gtk::Window* window,
SharedPtr<FlowCanvas::Canvas> canvas,
@@ -31,7 +34,7 @@ NodeView::NodeView(Gtk::Window* window,
, _node(node)
{
signal_clicked.connect(sigc::mem_fun(this, &NodeView::handle_click));
- update_state();
+ update_state(false);
}
@@ -49,11 +52,11 @@ NodeView::handle_click(GdkEventButton* event)
if (event->button == 1) {
bool is_initial = _node->is_initial();
_node->set_initial( ! is_initial );
- update_state();
+ update_state(_label != NULL);
} else if (event->button == 3) {
bool is_selector = _node->is_selector();
_node->set_selector( ! is_selector );
- update_state();
+ update_state(_label != NULL);
}
}
}
@@ -68,12 +71,10 @@ NodeView::show_label(bool show)
= PtrCast<Machina::MidiAction>(_node->enter_action());
if (show) {
- if (action && action->event_size() >= 2
+ if (action && action->event_size() > 1
&& (action->event()[0] & 0xF0) == 0x90) {
-
- unsigned char note = action->event()[1];
- snprintf(str, 4, "%d", (int)note);
-
+ uint8_t note = action->event()[1];
+ snprintf(str, 4, "%d", note);
set_name(str);
}
} else {
@@ -83,7 +84,7 @@ NodeView::show_label(bool show)
void
-NodeView::update_state()
+NodeView::update_state(bool show_labels)
{
static const uint32_t active_color = 0xA0A0AAFF;
@@ -103,5 +104,8 @@ NodeView::update_state()
set_base_color(0x00A000FF);
set_border_width(_node->is_initial() ? 4.0 : 1.0);
+
+ if (show_labels)
+ show_label(true);
}
diff --git a/src/gui/NodeView.hpp b/src/gui/NodeView.hpp
index 82c1bdb..a0dd5b8 100644
--- a/src/gui/NodeView.hpp
+++ b/src/gui/NodeView.hpp
@@ -35,7 +35,7 @@ public:
void show_label(bool show);
- void update_state();
+ void update_state(bool show_labels);
private:
void handle_click(GdkEventButton* ev);