* make MIDI-specific menu show up on all MIDI lanes
authorHans Baier <hansfbaier@googlemail.com>
Wed, 21 Jan 2009 10:20:27 +0000 (10:20 +0000)
committerHans Baier <hansfbaier@googlemail.com>
Wed, 21 Jan 2009 10:20:27 +0000 (10:20 +0000)
* style guide, comments and a little refactoring (remove duplication)

git-svn-id: svn://localhost/ardour2/branches/3.0@4422 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/automation_line.cc
gtk2_ardour/automation_line.h
gtk2_ardour/automation_time_axis.cc
gtk2_ardour/midi_time_axis.cc
libs/ardour/ardour/event_type_map.h
libs/ardour/event_type_map.cc
libs/evoral/src/ControlList.cpp

index f06cbee510c636336eeb5b1166f4ddf76a78c811..102a3fd29ca172c472ce28a7a981b07f87f5af2b 100644 (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
index 3444de3cb2c32e28b141cf1b60d911d105e8d4b9..6cf3b5ade6977b7137c1a846340cc0aa7041d7f9 100644 (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 {
index b7ed914926fc098aa7c17d2572bcabf2372d1e96..e3b5ee9f4cea06e909df794b6ae91d7af71c177d 100644 (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();
index 9f3da122c55aa511b1d275d0999cdbd0ab4e6487..c482c744cfeece5c27618af01f8c119bc0769a24 100644 (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;
index dfa11d640839bf167b667a53ad0b01cbb29cb5c0..d6f26aeac76477bcac7f21a49bfc09b1231b8c6d 100644 (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; }
 
index 39c2e3d6eb5b247483161bbed4947df7b7f1348d..a4d8317a42fe65658295bac3be8c05df86ddc32d 100644 (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
 {
index 5ec8c2dac99e4791a1412442b301d94afb174c76..022945b0f82baea2d9ef9473ba9e94a7bebd21de 100644 (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;
                }