convert codebase to use Temporal for various time types
[ardour.git] / libs / surfaces / push2 / mix.cc
index 1ec4868a6cbbb6164e3fa467470882b5853b75ef..22d4f330d7a243985840383357cbc3007e8cc505 100644 (file)
@@ -28,8 +28,8 @@
 #include "pbd/enumwriter.h"
 
 #include "midi++/parser.h"
-#include "timecode/time.h"
-#include "timecode/bbt_time.h"
+#include "temporal/time.h"
+#include "temporal/bbt_time.h"
 
 #include "ardour/async_midi_port.h"
 #include "ardour/audioengine.h"
@@ -43,7 +43,7 @@
 #include "ardour/utils.h"
 #include "ardour/vca_manager.h"
 
-#include "canvas/colors.h"
+#include "gtkmm2ext/colors.h"
 #include "canvas/line.h"
 #include "canvas/rectangle.h"
 #include "canvas/text.h"
 
 #include "pbd/i18n.h"
 
+#ifdef __APPLE__
+#define Rect ArdourCanvas::Rect
+#endif
+
 using namespace ARDOUR;
 using namespace std;
 using namespace PBD;
 using namespace Glib;
 using namespace ArdourSurface;
+using namespace Gtkmm2ext;
 using namespace ArdourCanvas;
 
 MixLayout::MixLayout (Push2& p, Session & s, std::string const & name)
@@ -73,7 +78,7 @@ MixLayout::MixLayout (Push2& p, Session & s, std::string const & name)
 {
        /* background */
 
-       bg = new Rectangle (this);
+       bg = new ArdourCanvas::Rectangle (this);
        bg->set (Rect (0, 0, display_width(), display_height()));
        bg->set_fill_color (p2.get_color (Push2::DarkBackground));
 
@@ -89,12 +94,12 @@ MixLayout::MixLayout (Push2& p, Session & s, std::string const & name)
 
                /* background for text labels for knob function */
 
-               Rectangle* r = new Rectangle (this);
+               ArdourCanvas::Rectangle* r = new ArdourCanvas::Rectangle (this);
                Coord x0 = 10 + (n*Push2Canvas::inter_button_spacing()) - 5;
                r->set (Rect (x0, 2, x0 + Push2Canvas::inter_button_spacing(), 2 + 21));
                upper_backgrounds.push_back (r);
 
-               r = new Rectangle (this);
+               r = new ArdourCanvas::Rectangle (this);
                r->set (Rect (x0, 137, x0 + Push2Canvas::inter_button_spacing(), 137 + 21));
                lower_backgrounds.push_back (r);
 
@@ -396,7 +401,7 @@ MixLayout::button_solo ()
        if (s) {
                boost::shared_ptr<AutomationControl> ac = s->solo_control();
                if (ac) {
-                       ac->set_value (!ac->get_value(), PBD::Controllable::UseGroup);
+                       session.set_control (ac, !ac->get_value(), PBD::Controllable::UseGroup);
                }
        }
 }
@@ -430,9 +435,9 @@ MixLayout::strip_vpot_touch (int n, bool touching)
                boost::shared_ptr<AutomationControl> ac = stripable[n]->gain_control();
                if (ac) {
                        if (touching) {
-                               ac->start_touch (session.audible_frame());
+                               ac->start_touch (session.audible_sample());
                        } else {
-                               ac->stop_touch (true, session.audible_frame());
+                               ac->stop_touch (session.audible_sample());
                        }
                }
        }
@@ -444,7 +449,7 @@ MixLayout::stripable_property_change (PropertyChange const& what_changed, uint32
        if (what_changed.contains (Properties::color)) {
                lower_backgrounds[which]->set_fill_color (stripable[which]->presentation_info().color());
 
-               if (stripable[which]->presentation_info().selected()) {
+               if (stripable[which]->is_selected()) {
                        lower_text[which]->set_fill_color (contrasting_text_color (stripable[which]->presentation_info().color()));
                        /* might not be a MIDI track, in which case this will
                           do nothing
@@ -463,7 +468,7 @@ MixLayout::stripable_property_change (PropertyChange const& what_changed, uint32
                        return;
                }
 
-               if (stripable[which]->presentation_info().selected()) {
+               if (stripable[which]->is_selected()) {
                        show_selection (which);
                } else {
                        hide_selection (which);
@@ -477,7 +482,7 @@ MixLayout::show_selection (uint32_t n)
 {
        lower_backgrounds[n]->show ();
        lower_backgrounds[n]->set_fill_color (stripable[n]->presentation_info().color());
-       lower_text[n]->set_color (ArdourCanvas::contrasting_text_color (lower_backgrounds[n]->fill_color()));
+       lower_text[n]->set_color (contrasting_text_color (lower_backgrounds[n]->fill_color()));
 }
 
 void
@@ -543,6 +548,11 @@ MixLayout::switch_bank (uint32_t base)
 
        if (!s[0]) {
                /* not even the first stripable exists, do nothing */
+               for (int n = 0; n < 8; ++n) {
+                       stripable[n].reset ();
+                       gain_meter[n]->knob->set_controllable (boost::shared_ptr<AutomationControl>());
+                       gain_meter[n]->meter->set_meter (0);
+               }
                return;
        }
 
@@ -559,6 +569,8 @@ MixLayout::switch_bank (uint32_t base)
                if (!stripable[n]) {
                        lower_text[n]->hide ();
                        hide_selection (n);
+                       gain_meter[n]->knob->set_controllable (boost::shared_ptr<AutomationControl>());
+                       gain_meter[n]->meter->set_meter (0);
                } else {
 
                        lower_text[n]->show ();
@@ -570,7 +582,7 @@ MixLayout::switch_bank (uint32_t base)
                        stripable[n]->solo_control()->Changed.connect (stripable_connections, invalidator (*this), boost::bind (&MixLayout::solo_changed, this, n), &p2);
                        stripable[n]->mute_control()->Changed.connect (stripable_connections, invalidator (*this), boost::bind (&MixLayout::mute_changed, this, n), &p2);
 
-                       if (stripable[n]->presentation_info().selected()) {
+                       if (stripable[n]->is_selected()) {
                                show_selection (n);
                        } else {
                                hide_selection (n);
@@ -660,7 +672,7 @@ MixLayout::button_select_release ()
 
        for (int n = 0; n < 8; ++n) {
                if (stripable[n]) {
-                       if (stripable[n]->presentation_info().selected()) {
+                       if (stripable[n]->is_selected()) {
                                        selected = n;
                                        break;
                        }