aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2013-01-13 21:38:58 +0000
committerDavid Robillard <d@drobilla.net>2013-01-13 21:38:58 +0000
commitb0c2b11751b21d4f59ece43de0e4b673e344d965 (patch)
treef8ae60ed9b3fa1857114a3e7705c7e082f5fc915
parentac0438352410a5af5d64d2268d3541b47e8a2669 (diff)
downloadmachina-b0c2b11751b21d4f59ece43de0e4b673e344d965.tar.gz
machina-b0c2b11751b21d4f59ece43de0e4b673e344d965.tar.bz2
machina-b0c2b11751b21d4f59ece43de0e4b673e344d965.zip
Fancy labels.
git-svn-id: http://svn.drobilla.net/lad/trunk/machina@4966 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/gui/NodeView.cpp46
1 files changed, 28 insertions, 18 deletions
diff --git a/src/gui/NodeView.cpp b/src/gui/NodeView.cpp
index 38e5ea7..93902e8 100644
--- a/src/gui/NodeView.cpp
+++ b/src/gui/NodeView.cpp
@@ -41,17 +41,16 @@ NodeView::NodeView(Gtk::Window* window,
, _default_border_color(get_border_color())
, _default_fill_color(get_fill_color())
{
- signal_event().connect(
- sigc::mem_fun(this, &NodeView::on_event));
+ signal_event().connect(sigc::mem_fun(this, &NodeView::on_event));
MachinaCanvas* mcanvas = dynamic_cast<MachinaCanvas*>(&canvas);
if (is(mcanvas->app()->forge(), URIs::instance().machina_initial)) {
set_border_width(4.0);
- set_label("init");
+ const uint8_t alpha[] = { 0xCE, 0xB1, 0 };
+ set_label((const char*)alpha);
}
- node->signal_property.connect(
- sigc::mem_fun(this, &NodeView::on_property));
+ node->signal_property.connect(sigc::mem_fun(this, &NodeView::on_property));
for (const auto& p : node->properties()) {
on_property(p.first, p.second);
@@ -100,19 +99,28 @@ NodeView::on_event(GdkEvent* event)
return false;
}
-static std::string
-midi_note_name(uint8_t num)
+static void
+midi_note_name(uint8_t num, uint8_t buf[8])
{
- static const char* notes[] = {
- "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"
- };
-
- const uint8_t octave = num / 12;
- num -= octave * 12;
-
- static char str[8];
- snprintf(str, sizeof(str), "%s%d", notes[num], octave);
- return str;
+ static const char* notes = "CCDDEFFGGAAB";
+ static const bool is_sharp[] = { 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0 };
+
+ const uint8_t octave = num / 12;
+ const uint8_t id = num - octave * 12;
+ const uint8_t sub[] = { 0xE2, 0x82, uint8_t(0x80 + octave) };
+ const uint8_t sharp[] = { 0xE2, 0x99, 0xAF };
+
+ int b = 0;
+ buf[b++] = notes[id];
+ if (is_sharp[id]) {
+ for (unsigned s = 0; s < sizeof(sharp); ++s) {
+ buf[b++] = sharp[s];
+ }
+ }
+ for (unsigned s = 0; s < sizeof(sub); ++s) {
+ buf[b++] = sub[s];
+ }
+ buf[b++] = 0;
}
void
@@ -122,7 +130,9 @@ NodeView::show_label(bool show)
Raul::Atom note_number = _enter_action->get(
URIs::instance().machina_note_number);
if (note_number.is_valid()) {
- set_label(midi_note_name(note_number.get_int32()).c_str());
+ uint8_t buf[8];
+ midi_note_name(note_number.get_int32(), buf);
+ set_label((const char*)buf);
return;
}
}