* make MIDI-specific menu show up on all MIDI lanes

* style guide, comments and a little refactoring (remove duplication)


git-svn-id: svn://localhost/ardour2/branches/3.0@4422 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Hans Baier 2009-01-21 10:20:27 +00:00
parent 33852a0728
commit 5309c327ec
7 changed files with 52 additions and 33 deletions

View file

@ -116,8 +116,9 @@ AutomationLine::queue_reset ()
void void
AutomationLine::show () AutomationLine::show ()
{ {
if (_interpolation != AutomationList::Discrete) if (_interpolation != AutomationList::Discrete) {
line->show(); line->show();
}
if (points_visible) { if (points_visible) {
for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) { for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
@ -629,8 +630,9 @@ AutomationLine::determine_visible_control_points (ALPoints& points)
line->property_points() = line_points; line->property_points() = line_points;
if (_visible && _interpolation != AutomationList::Discrete) if (_visible && _interpolation != AutomationList::Discrete) {
line->show(); line->show();
}
} }
@ -1201,8 +1203,9 @@ AutomationLine::show_all_control_points ()
void void
AutomationLine::hide_all_but_selected_control_points () AutomationLine::hide_all_but_selected_control_points ()
{ {
if (alist->interpolation() == AutomationList::Discrete) if (alist->interpolation() == AutomationList::Discrete) {
return; return;
}
points_visible = false; points_visible = false;
@ -1216,8 +1219,9 @@ AutomationLine::hide_all_but_selected_control_points ()
void void
AutomationLine::track_entered() AutomationLine::track_entered()
{ {
if (alist->interpolation() != AutomationList::Discrete) if (alist->interpolation() != AutomationList::Discrete) {
show_all_control_points(); show_all_control_points();
}
} }
void void

View file

@ -106,8 +106,8 @@ class AutomationLine : public sigc::trackable, public PBD::StatefulThingWithGoin
string get_verbose_cursor_string (double) const; string get_verbose_cursor_string (double) const;
string fraction_to_string (double) const; string fraction_to_string (double) const;
double string_to_fraction (string const &) const; double string_to_fraction (string const &) const;
void view_to_model_y (double&) const; void view_to_model_y (double&) const;
void model_to_view_y (double&) const; void model_to_view_y (double&) const;
void set_list(boost::shared_ptr<ARDOUR::AutomationList> list); void set_list(boost::shared_ptr<ARDOUR::AutomationList> list);
boost::shared_ptr<ARDOUR::AutomationList> the_list() const { return alist; } boost::shared_ptr<ARDOUR::AutomationList> the_list() const { return alist; }
@ -129,23 +129,24 @@ class AutomationLine : public sigc::trackable, public PBD::StatefulThingWithGoin
protected: protected:
string _name; string _name;
guint32 _height; guint32 _height;
uint32_t _line_color; uint32_t _line_color;
boost::shared_ptr<ARDOUR::AutomationList> alist; boost::shared_ptr<ARDOUR::AutomationList> alist;
bool _visible : 1; bool _visible : 1;
bool _uses_gain_mapping : 1; bool _uses_gain_mapping : 1;
bool terminal_points_can_slide : 1; bool terminal_points_can_slide : 1;
bool update_pending : 1; bool update_pending : 1;
bool no_draw : 1; bool no_draw : 1;
bool points_visible : 1; bool points_visible : 1;
bool did_push; bool did_push;
ArdourCanvas::Group& _parent_group; ArdourCanvas::Group& _parent_group;
ArdourCanvas::Group* group; ArdourCanvas::Group* group;
ArdourCanvas::Line* line; /* line */ ArdourCanvas::Line* line; /* line */
ArdourCanvas::Points line_points; /* coordinates for canvas line */ ArdourCanvas::Points line_points; /* coordinates for canvas line */
std::vector<ControlPoint*> control_points; /* visible control points */ std::vector<ControlPoint*> control_points; /* visible control points */
struct ALPoint { struct ALPoint {

View file

@ -349,24 +349,27 @@ AutomationTimeAxisView::interpolation_changed ()
} }
} }
if (_line) if (_line) {
_line->set_interpolation(style); _line->set_interpolation(style);
}
} }
void void
AutomationTimeAxisView::set_interpolation (AutomationList::InterpolationStyle style) AutomationTimeAxisView::set_interpolation (AutomationList::InterpolationStyle style)
{ {
_control->list()->set_interpolation(style); _control->list()->set_interpolation(style);
if (_line) if (_line) {
_line->set_interpolation(style); _line->set_interpolation(style);
}
} }
void void
AutomationTimeAxisView::clear_clicked () AutomationTimeAxisView::clear_clicked ()
{ {
_session.begin_reversible_command (_("clear automation")); _session.begin_reversible_command (_("clear automation"));
if (_line) if (_line) {
_line->clear (); _line->clear ();
}
_session.commit_reversible_command (); _session.commit_reversible_command ();
} }
@ -524,8 +527,9 @@ AutomationTimeAxisView::build_display_menu ()
items.push_back (MenuElem (_("State"), *auto_state_menu)); items.push_back (MenuElem (_("State"), *auto_state_menu));
/* mode menu */ /* mode menu */
if (_control->parameter().type() == MidiCCAutomation) { if ( EventTypeMap::instance().is_midi_parameter(_control->parameter()) ) {
Menu* auto_mode_menu = manage (new Menu); Menu* auto_mode_menu = manage (new Menu);
auto_mode_menu->set_name ("ArdourContextMenu"); auto_mode_menu->set_name ("ArdourContextMenu");
MenuList& am_items = auto_mode_menu->items(); MenuList& am_items = auto_mode_menu->items();

View file

@ -469,11 +469,7 @@ MidiTimeAxisView::add_cc_track()
void void
MidiTimeAxisView::add_parameter_track(const Evoral::Parameter& param) MidiTimeAxisView::add_parameter_track(const Evoral::Parameter& param)
{ {
if ( param.type() != MidiCCAutomation && if ( !EventTypeMap::instance().is_midi_parameter(param) ) {
param.type() != MidiPgmChangeAutomation &&
param.type() != MidiPitchBenderAutomation &&
param.type() != MidiChannelPressureAutomation
) {
error << "MidiTimeAxisView: unknown automation child " error << "MidiTimeAxisView: unknown automation child "
<< ARDOUR::EventTypeMap::instance().to_symbol(param) << endmsg; << ARDOUR::EventTypeMap::instance().to_symbol(param) << endmsg;
return; return;

View file

@ -24,6 +24,8 @@
#include <string> #include <string>
#include <evoral/TypeMap.hpp> #include <evoral/TypeMap.hpp>
class Evoral::Parameter;
namespace ARDOUR { namespace ARDOUR {
/** This is the interface Ardour provides to Evoral about what /** This is the interface Ardour provides to Evoral about what
@ -35,10 +37,12 @@ public:
uint8_t parameter_midi_type(const Evoral::Parameter& param) const; uint8_t parameter_midi_type(const Evoral::Parameter& param) const;
uint32_t midi_event_type(uint8_t status) const; uint32_t midi_event_type(uint8_t status) const;
bool is_integer(const Evoral::Parameter& param) const; bool is_integer(const Evoral::Parameter& param) const;
Evoral::Parameter new_parameter(uint32_t type, uint8_t channel=0, uint32_t id=0) const; Evoral::Parameter new_parameter(uint32_t type, uint8_t channel=0, uint32_t id=0) const;
Evoral::Parameter new_parameter(const std::string& str) const; Evoral::Parameter new_parameter(const std::string& str) const;
std::string to_symbol(const Evoral::Parameter& param) const; std::string to_symbol(const Evoral::Parameter& param) const;
bool is_midi_parameter(const Evoral::Parameter& param);
static EventTypeMap& instance() { return event_type_map; } static EventTypeMap& instance() { return event_type_map; }

View file

@ -38,6 +38,12 @@ EventTypeMap::type_is_midi(uint32_t type) const
return (type >= MidiCCAutomation) && (type <= MidiChannelPressureAutomation); return (type >= MidiCCAutomation) && (type <= MidiChannelPressureAutomation);
} }
bool
EventTypeMap::is_midi_parameter(const Evoral::Parameter& param)
{
return type_is_midi(param.type());
}
uint8_t uint8_t
EventTypeMap::parameter_midi_type(const Evoral::Parameter& param) const EventTypeMap::parameter_midi_type(const Evoral::Parameter& param) const
{ {

View file

@ -770,6 +770,7 @@ ControlList::unlocked_eval (double x) const
if (x >= _events.front()->when) { if (x >= _events.front()->when) {
return _events.front()->value; return _events.front()->value;
} else { } else {
// hansfbaier: v--------- Why commented ???
// return _default_value; // return _default_value;
return _events.front()->value; return _events.front()->value;
} }
@ -780,6 +781,7 @@ ControlList::unlocked_eval (double x) const
} else if (x == _events.front()->when) { } else if (x == _events.front()->when) {
return _events.front()->value; return _events.front()->value;
} else if (x < _events.front()->when) { } else if (x < _events.front()->when) {
// hansfbaier: v--------- Why commented ???
// return _default_value; // return _default_value;
return _events.front()->value; return _events.front()->value;
} }
@ -789,8 +791,9 @@ ControlList::unlocked_eval (double x) const
upos = _events.back()->when; upos = _events.back()->when;
uval = _events.back()->value; uval = _events.back()->value;
if (_interpolation == Discrete) if (_interpolation == Discrete) {
return lval; return lval;
}
/* linear interpolation betweeen the two points /* linear interpolation betweeen the two points
*/ */
@ -805,6 +808,7 @@ ControlList::unlocked_eval (double x) const
} else if (x == _events.front()->when) { } else if (x == _events.front()->when) {
return _events.front()->value; return _events.front()->value;
} else if (x < _events.front()->when) { } else if (x < _events.front()->when) {
// hansfbaier: v--------- Why commented ???
// return _default_value; // return _default_value;
return _events.front()->value; return _events.front()->value;
} }