GenericUI: replace if() by assert()
[ardour.git] / gtk2_ardour / automation_line.cc
index 2094d43eff171c7f894ec663d1f1a354983da059..a422bf972331c5e284510b31a8200b481684ff60 100644 (file)
@@ -63,7 +63,7 @@
 #include "ardour/session.h"
 #include "ardour/value_as_string.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace std;
 using namespace ARDOUR;
@@ -86,6 +86,7 @@ AutomationLine::AutomationLine (const string&                              name,
        , _parent_group (parent)
        , _offset (0)
        , _maximum_time (max_framepos)
+       , _fill (false)
        , _desc (desc)
 {
        if (converter) {
@@ -171,7 +172,7 @@ AutomationLine::update_visibility ()
                        }
                } else if (_visible & SelectedControlPoints) {
                        for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
-                               if ((*i)->get_selected()) {
+                               if ((*i)->selected()) {
                                        (*i)->show ();
                                } else {
                                        (*i)->hide ();
@@ -229,6 +230,11 @@ AutomationLine::set_height (guint32 h)
                        (*i)->set_size (bsz);
                }
 
+               if (_fill) {
+                       line->set_fill_y1 (_height);
+               } else {
+                       line->set_fill_y1 (0);
+               }
                reset ();
        }
 }
@@ -238,6 +244,7 @@ AutomationLine::set_line_color (uint32_t color)
 {
        _line_color = color;
        line->set_outline_color (color);
+       line->set_fill_color ((color & 0xffff00) + 80); // XXX TODO configurable transparency
 }
 
 void
@@ -470,9 +477,9 @@ AutomationLine::start_drag_single (ControlPoint* cp, double x, float fraction)
        _drag_points.clear ();
        _drag_points.push_back (cp);
 
-       if (cp->get_selected ()) {
+       if (cp->selected ()) {
                for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
-                       if (*i != cp && (*i)->get_selected()) {
+                       if (*i != cp && (*i)->selected()) {
                                _drag_points.push_back (*i);
                        }
                }
@@ -546,8 +553,8 @@ AutomationLine::ContiguousControlPoints::compute_x_bounds (PublicEditor& e)
                        before_x = line.nth (front()->view_index() - 1)->get_x();
 
                        const framepos_t pos = e.pixel_to_sample(before_x);
-                       const Meter& meter = map.meter_at (pos);
-                       const framecnt_t len = ceil (meter.frames_per_bar (map.tempo_at (pos), e.session()->frame_rate())
+                       const Meter& meter = map.meter_at_frame (pos);
+                       const framecnt_t len = ceil (meter.frames_per_bar (map.tempo_at_frame (pos), e.session()->frame_rate())
                                        / (Timecode::BBT_Time::ticks_per_beat * meter.divisions_per_bar()) );
                        const double one_tick_in_pixels = e.sample_to_pixel_unrounded (len);
 
@@ -562,8 +569,8 @@ AutomationLine::ContiguousControlPoints::compute_x_bounds (PublicEditor& e)
                        after_x = line.nth (back()->view_index() + 1)->get_x();
 
                        const framepos_t pos = e.pixel_to_sample(after_x);
-                       const Meter& meter = map.meter_at (pos);
-                       const framecnt_t len = ceil (meter.frames_per_bar (map.tempo_at (pos), e.session()->frame_rate())
+                       const Meter& meter = map.meter_at_frame (pos);
+                       const framecnt_t len = ceil (meter.frames_per_bar (map.tempo_at_frame (pos), e.session()->frame_rate())
                                        / (Timecode::BBT_Time::ticks_per_beat * meter.divisions_per_bar()));
                        const double one_tick_in_pixels = e.sample_to_pixel_unrounded (len);