finalize (?) some details of note name display options
This commit is contained in:
parent
df95ec6b43
commit
194f0fbed6
@ -149,8 +149,7 @@ MidiTimeAxisView::parameter_changed (string const & param)
|
||||
{
|
||||
if (param == X_("note-name-display")) {
|
||||
if (_piano_roll_header) {
|
||||
_piano_roll_header->queue_resize ();
|
||||
_stripable->gui_changed ("visible_tracks", (void *) 0); /* EMIT SIGNAL */
|
||||
_piano_roll_header->instrument_info_change ();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -321,15 +320,16 @@ MidiTimeAxisView::set_route (std::shared_ptr<Route> rt)
|
||||
// model_name));
|
||||
|
||||
for (int i = 1; i < 17; i++){
|
||||
std::string text = "Channel " + std::to_string(i+1);
|
||||
std::string text = string_compose ("%1 %2", _("Channel "), i);
|
||||
_midnam_channel_selector.append_text_item (text);
|
||||
}
|
||||
_midnam_channel_selector.StateChanged.connect (sigc::mem_fun (*this, &MidiTimeAxisView::_midnam_channel_changed));
|
||||
if (gui_property (X_("midnam-channel")).empty()) {
|
||||
set_gui_property (X_("midnam-channel"), "1");
|
||||
_midnam_channel_selector.set_active("1");
|
||||
std::string str = string_compose ("%1 1", _("Channel "));
|
||||
set_gui_property (X_("midnam-channel"), str);
|
||||
_midnam_channel_selector.set_active (str);
|
||||
} else {
|
||||
_midnam_channel_selector.set_active(gui_property (X_("midnam-channel")));
|
||||
_midnam_channel_selector.set_active (gui_property (X_("midnam-channel")));
|
||||
}
|
||||
}
|
||||
|
||||
@ -338,7 +338,7 @@ MidiTimeAxisView::_midnam_channel_changed ()
|
||||
{
|
||||
set_gui_property (X_("midnam-channel"), _midnam_channel_selector.get_text());
|
||||
//std::cout << "midnam_changed(): " << _midnam_channel_selector.get_text() << std::endl;
|
||||
_piano_roll_header->queue_draw();
|
||||
_piano_roll_header->instrument_info_change ();
|
||||
}
|
||||
|
||||
void
|
||||
@ -479,7 +479,7 @@ MidiTimeAxisView::setup_midnam_patches ()
|
||||
model_changed (model);
|
||||
}
|
||||
|
||||
_piano_roll_header->queue_draw();
|
||||
_piano_roll_header->instrument_info_change ();
|
||||
}
|
||||
|
||||
void
|
||||
@ -513,7 +513,7 @@ MidiTimeAxisView::update_patch_selector ()
|
||||
_midnam_custom_device_mode_selector.show ();
|
||||
}
|
||||
}
|
||||
_piano_roll_header->queue_draw();
|
||||
_piano_roll_header->instrument_info_change ();
|
||||
|
||||
/* call _midnam_model_selector.set_text ()
|
||||
* and show/hide _midnam_custom_device_mode_selector
|
||||
@ -619,7 +619,8 @@ MidiTimeAxisView::model_changed (const std::string& m)
|
||||
if (patch_change_dialog ()) {
|
||||
patch_change_dialog ()->refresh ();
|
||||
}
|
||||
_piano_roll_header->queue_draw();
|
||||
|
||||
_piano_roll_header->instrument_info_change ();
|
||||
}
|
||||
|
||||
void
|
||||
@ -636,7 +637,7 @@ MidiTimeAxisView::custom_device_mode_changed(const std::string& mode)
|
||||
/* inform the backend, route owned instrument info */
|
||||
_route->instrument_info().set_external_instrument (model, mode);
|
||||
|
||||
_piano_roll_header->queue_draw();
|
||||
_piano_roll_header->instrument_info_change ();
|
||||
}
|
||||
|
||||
MidiStreamView*
|
||||
|
@ -69,7 +69,8 @@ PianoRollHeader::Color::set (const PianoRollHeader::Color& c)
|
||||
}
|
||||
|
||||
PianoRollHeader::PianoRollHeader(MidiStreamView& v)
|
||||
: _adj(v.note_range_adjustment)
|
||||
: have_note_names (false)
|
||||
, _adj(v.note_range_adjustment)
|
||||
, _view(v)
|
||||
, _font_descript ("Sans Bold")
|
||||
, _font_descript_big_c ("Sans")
|
||||
@ -178,7 +179,7 @@ PianoRollHeader::on_scroll_event (GdkEventScroll* ev)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
std::cout << "hilight_note: " << std::to_string(_highlighted_note) << " Hov_Note: " << std::to_string(_view.y_to_note(ev->y)) << " Val: " << _adj.get_value() << " upper: " << _adj.get_upper() << " lower: " << _adj.get_lower() << " page_size: "<< _adj.get_page_size () << std::endl;
|
||||
|
||||
_adj.value_changed ();
|
||||
queue_draw ();
|
||||
return true;
|
||||
@ -283,14 +284,16 @@ PianoRollHeader::on_expose_event (GdkEventExpose* ev)
|
||||
cr->rectangle (0,0,_scroomer_size, get_height () );
|
||||
cr->clip();
|
||||
|
||||
if (UIConfiguration::instance().get_note_name_display() != Editing::Never) {
|
||||
Editing::NoteNameDisplay nnd = UIConfiguration::instance().get_note_name_display();
|
||||
|
||||
if ((nnd == Editing::Always) || ((nnd == Editing::WithMIDNAM) && have_note_names)) {
|
||||
|
||||
/* Draw the actual text */
|
||||
|
||||
for (int i = lowest; i <= highest; ++i) {
|
||||
int size_x, size_y;
|
||||
double y = floor(_view.note_to_y(i)) - 0.5f;
|
||||
midnamName note = get_note_name (i);
|
||||
NoteName & note (note_names[i]);
|
||||
|
||||
_midnam_layout->set_text (note.name);
|
||||
|
||||
@ -433,18 +436,45 @@ PianoRollHeader::on_expose_event (GdkEventExpose* ev)
|
||||
return true;
|
||||
}
|
||||
|
||||
PianoRollHeader::midnamName
|
||||
void
|
||||
PianoRollHeader::instrument_info_change ()
|
||||
{
|
||||
have_note_names = false;
|
||||
|
||||
for (int i = 0; i < 128; ++i) {
|
||||
note_names[i] = get_note_name (i);
|
||||
|
||||
if (note_names[i].from_midnam) {
|
||||
have_note_names = true;
|
||||
}
|
||||
}
|
||||
|
||||
queue_resize ();
|
||||
|
||||
/* need this to get editor to potentially sync all
|
||||
track header widths if our piano roll header changes
|
||||
width.
|
||||
*/
|
||||
|
||||
_view.trackview().stripable()->gui_changed ("visible_tracks", (void *) 0); /* EMIT SIGNAL */
|
||||
}
|
||||
|
||||
PianoRollHeader::NoteName
|
||||
PianoRollHeader::get_note_name (int note)
|
||||
{
|
||||
using namespace MIDI::Name;
|
||||
std::string name;
|
||||
std::string note_n;
|
||||
midnamName rtn;
|
||||
NoteName rtn;
|
||||
|
||||
MidiTimeAxisView* mtv = dynamic_cast<MidiTimeAxisView*>(&_view.trackview());
|
||||
|
||||
if (mtv) {
|
||||
int midnam_channel = stoi(mtv->gui_property (X_("midnam-channel")))-1;
|
||||
string chn = mtv->gui_property (X_("midnam-channel"));
|
||||
int midnam_channel;
|
||||
|
||||
sscanf (chn.c_str(), "%*s %d", &midnam_channel);
|
||||
midnam_channel--;
|
||||
|
||||
name = mtv->route()->instrument_info ().get_note_name (
|
||||
0, //bank
|
||||
@ -605,7 +635,6 @@ PianoRollHeader::on_button_press_event (GdkEventButton* ev)
|
||||
_old_y = ev->y;
|
||||
_fract = _adj.get_value();
|
||||
_fract_top = _adj.get_value() + _adj.get_page_size();
|
||||
std::cerr << "scroomer drag ON\n";
|
||||
return true;
|
||||
}else {
|
||||
int note = _view.y_to_note(ev->y);
|
||||
@ -649,7 +678,6 @@ PianoRollHeader::on_button_release_event (GdkEventButton* ev)
|
||||
{
|
||||
if (_scroomer_drag){
|
||||
_scroomer_drag = false;
|
||||
std::cerr << "scroomer drag OFF\n";
|
||||
}
|
||||
int note = _view.y_to_note(ev->y);
|
||||
|
||||
@ -755,10 +783,12 @@ PianoRollHeader::invalidate_note_range (int lowest, int highest)
|
||||
void
|
||||
PianoRollHeader::on_size_request (Gtk::Requisition* r)
|
||||
{
|
||||
if (UIConfiguration::instance().get_note_name_display() == Editing::Never) {
|
||||
_scroomer_size = 15.f;
|
||||
} else {
|
||||
Editing::NoteNameDisplay nnd = UIConfiguration::instance().get_note_name_display();
|
||||
|
||||
if ((nnd == Editing::Always) || ((nnd == Editing::WithMIDNAM) && have_note_names)) {
|
||||
_scroomer_size = 60.f;
|
||||
} else {
|
||||
_scroomer_size = 20.f;
|
||||
}
|
||||
|
||||
float w = _scroomer_size + 20.f;
|
||||
|
@ -46,6 +46,8 @@ public:
|
||||
|
||||
void on_size_request(Gtk::Requisition*);
|
||||
|
||||
void instrument_info_change ();
|
||||
|
||||
void note_range_changed();
|
||||
void set_note_highlight (uint8_t note);
|
||||
|
||||
@ -65,13 +67,15 @@ public:
|
||||
sigc::signal<void,uint8_t> ExtendNoteSelection;
|
||||
|
||||
private:
|
||||
struct midnamName {
|
||||
struct NoteName {
|
||||
std::string name;
|
||||
bool from_midnam;
|
||||
};
|
||||
NoteName note_names[128];
|
||||
bool have_note_names;
|
||||
void set_min_page_size(double page_size);
|
||||
void render_scroomer(Cairo::RefPtr<Cairo::Context>);
|
||||
midnamName get_note_name (int note);
|
||||
NoteName get_note_name (int note);
|
||||
|
||||
Gtk::Adjustment& _adj;
|
||||
static Color white;
|
||||
|
Loading…
Reference in New Issue
Block a user