-
Notifications
You must be signed in to change notification settings - Fork 0
/
chordchooser.cc
54 lines (41 loc) · 1.59 KB
/
chordchooser.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <gtkmm.h>
#include "songmodel.h"
#include "chordchooser.h"
ChordChooser::ChordChooser(const Gtk::Widget& parent, const Scale& scale, Chord& chord):Gtk::Popover(parent), scale(scale), chord(chord)
{
add(vbox);
rootgrid.set_column_homogeneous(true);
rootgrid.set_row_homogeneous(true);
vbox.pack_start(rootgrid);
vbox.pack_start(hsep);
vbox.pack_start(qualflow);
const static char* romannumeral[]={ "I", "I#", "II", "II#", "III", "III#", "IV", "IV#", "V", "V#", "VI", "VI#", "VII", "VII#" };
for (int i=0;i<12;i++) {
int offs=scale.get_display_offset_for_note(i);
Gtk::RadioButton* b=new Gtk::RadioButton(romannumeral[offs]);
b->set_group(rootgroup);
b->set_mode(false);
if (chord.get_root()==i)
b->set_active(true);
b->signal_toggled().connect([this, b, i]() {
if (b->get_active()) {
this->chord.set_root(i);
}
});
rootgrid.attach(*b, offs, (offs&1)^1, 2, 1);
}
const static char* qualitynames[]={ "Maj", "Min", "Maj6", "Min6", "Maj7", "Min7", "Dom7", "Sus2", "Sus4", "Dim" };
for (int i=0;i<10;i++) {
Gtk::RadioButton* b=new Gtk::RadioButton(qualitynames[i]);
b->set_group(qualgroup);
b->set_mode(false);
if (chord.get_quality()==Chord::Quality(i))
b->set_active(true);
b->signal_toggled().connect([this, b, i]() {
if (b->get_active())
this->chord.set_quality(Chord::Quality(i));
});
qualflow.insert(*b, i);
}
show_all_children();
}