* 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
AutomationLine::show ()
{
if (_interpolation != AutomationList::Discrete)
if (_interpolation != AutomationList::Discrete) {
line->show();
}
if (points_visible) {
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;
if (_visible && _interpolation != AutomationList::Discrete)
if (_visible && _interpolation != AutomationList::Discrete) {
line->show();
}
}
@ -1201,8 +1203,9 @@ AutomationLine::show_all_control_points ()
void
AutomationLine::hide_all_but_selected_control_points ()
{
if (alist->interpolation() == AutomationList::Discrete)
if (alist->interpolation() == AutomationList::Discrete) {
return;
}
points_visible = false;
@ -1216,8 +1219,9 @@ AutomationLine::hide_all_but_selected_control_points ()
void
AutomationLine::track_entered()
{
if (alist->interpolation() != AutomationList::Discrete)
if (alist->interpolation() != AutomationList::Discrete) {
show_all_control_points();
}
}
void

View File

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

View File

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

View File

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

View File

@ -24,6 +24,8 @@
#include <string>
#include <evoral/TypeMap.hpp>
class Evoral::Parameter;
namespace ARDOUR {
/** 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;
uint32_t midi_event_type(uint8_t status) 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(const std::string& str) const;
std::string to_symbol(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(const std::string& str) 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; }

View File

@ -38,6 +38,12 @@ EventTypeMap::type_is_midi(uint32_t type) const
return (type >= MidiCCAutomation) && (type <= MidiChannelPressureAutomation);
}
bool
EventTypeMap::is_midi_parameter(const Evoral::Parameter& param)
{
return type_is_midi(param.type());
}
uint8_t
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) {
return _events.front()->value;
} else {
// hansfbaier: v--------- Why commented ???
// return _default_value;
return _events.front()->value;
}
@ -780,6 +781,7 @@ ControlList::unlocked_eval (double x) const
} else if (x == _events.front()->when) {
return _events.front()->value;
} else if (x < _events.front()->when) {
// hansfbaier: v--------- Why commented ???
// return _default_value;
return _events.front()->value;
}
@ -789,8 +791,9 @@ ControlList::unlocked_eval (double x) const
upos = _events.back()->when;
uval = _events.back()->value;
if (_interpolation == Discrete)
if (_interpolation == Discrete) {
return lval;
}
/* linear interpolation betweeen the two points
*/
@ -805,6 +808,7 @@ ControlList::unlocked_eval (double x) const
} else if (x == _events.front()->when) {
return _events.front()->value;
} else if (x < _events.front()->when) {
// hansfbaier: v--------- Why commented ???
// return _default_value;
return _events.front()->value;
}