mechanism to allow Track (or other Route-derived type) to add its own processors...
[ardour.git] / gtk2_ardour / time_axis_view_item.cc
index 5a85005e3a1dcab8d0d28f2f759f734b7a2fa160..3f1adb9a1c19bf4bd6b8f5ac3bea9c1b8456708a 100644 (file)
@@ -32,7 +32,7 @@
 #include "canvas/rectangle.h"
 #include "canvas/debug.h"
 #include "canvas/text.h"
-#include "canvas/colors.h"
+#include "gtkmm2ext/colors.h"
 
 #include "ardour/profile.h"
 
@@ -43,7 +43,7 @@
 #include "utils.h"
 #include "rgb_macros.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace std;
 using namespace Editing;
@@ -66,22 +66,22 @@ double TimeAxisViewItem::NAME_HIGHLIGHT_THRESH;
 void
 TimeAxisViewItem::set_constant_heights ()
 {
-        NAME_FONT = Pango::FontDescription (UIConfiguration::instance().get_SmallFont());
+       NAME_FONT = Pango::FontDescription (UIConfiguration::instance().get_SmallFont());
 
-        Gtk::Window win;
-        Gtk::Label foo;
-        win.add (foo);
+       Gtk::Window win;
+       Gtk::Label foo;
+       win.add (foo);
 
-        Glib::RefPtr<Pango::Layout> layout = foo.create_pango_layout (X_("Hg")); /* ascender + descender */
-        int width = 0;
-        int height = 0;
+       Glib::RefPtr<Pango::Layout> layout = foo.create_pango_layout (X_("Hg")); /* ascender + descender */
+       int width = 0;
+       int height = 0;
 
-        layout->set_font_description (NAME_FONT);
-        get_pixel_size (layout, width, height);
+       layout->set_font_description (NAME_FONT);
+       get_pixel_size (layout, width, height);
 
-        layout = foo.create_pango_layout (X_("H")); /* just the ascender */
+       layout = foo.create_pango_layout (X_("H")); /* just the ascender */
 
-        NAME_HEIGHT = height;
+       NAME_HEIGHT = height;
 
        /* Config->get_show_name_highlight) == true:
                Y_OFFSET is measured from bottom of the time axis view item.
@@ -96,7 +96,7 @@ TimeAxisViewItem::set_constant_heights ()
                NAME_Y_OFFSET = 3;
                NAME_HIGHLIGHT_SIZE = 0;
        }
-        NAME_HIGHLIGHT_THRESH = NAME_HIGHLIGHT_SIZE * 3;
+       NAME_HIGHLIGHT_THRESH = NAME_HIGHLIGHT_SIZE * 3;
 }
 
 /**
@@ -160,7 +160,6 @@ TimeAxisViewItem::init (ArdourCanvas::Item* parent, double fpp, uint32_t base_co
 {
        group = new ArdourCanvas::Container (parent);
        CANVAS_DEBUG_NAME (group, string_compose ("TAVI group for %1", get_item_name()));
-       group->Event.connect (sigc::mem_fun (*this, &TimeAxisViewItem::canvas_group_event));
 
        fill_color = base_color;
        fill_color_name = "time axis view item base";
@@ -171,14 +170,12 @@ TimeAxisViewItem::init (ArdourCanvas::Item* parent, double fpp, uint32_t base_co
        position_locked = false;
        max_item_duration = ARDOUR::max_framepos;
        min_item_duration = 0;
-       show_vestigial = true;
        visibility = vis;
        _sensitive = true;
        name_text_width = 0;
        last_item_width = 0;
        wide_enough_for_name = wide;
        high_enough_for_name = high;
-       vestigial_frame = 0;
 
        if (duration == 0) {
                warning << "Time Axis Item Duration == 0" << endl;
@@ -191,6 +188,7 @@ TimeAxisViewItem::init (ArdourCanvas::Item* parent, double fpp, uint32_t base_co
                                                                         trackview.current_height()));
 
                frame->set_outline_what (ArdourCanvas::Rectangle::What (ArdourCanvas::Rectangle::LEFT|ArdourCanvas::Rectangle::RIGHT));
+               frame->show ();
 
                CANVAS_DEBUG_NAME (frame, string_compose ("frame for %1", get_item_name()));
 
@@ -207,8 +205,8 @@ TimeAxisViewItem::init (ArdourCanvas::Item* parent, double fpp, uint32_t base_co
                name_highlight = new ArdourCanvas::Rectangle (group);
                CANVAS_DEBUG_NAME (name_highlight, string_compose ("name highlight for %1", get_item_name()));
                name_highlight->set_data ("timeaxisviewitem", this);
-                name_highlight->set_outline_what (ArdourCanvas::Rectangle::TOP);
-                name_highlight->set_outline_color (RGBA_TO_UINT (0,0,0,255)); // this should use a theme color
+               name_highlight->set_outline_what (ArdourCanvas::Rectangle::TOP);
+               name_highlight->set_outline_color (RGBA_TO_UINT (0,0,0,255)); // this should use a theme color
 
        } else {
                name_highlight = 0;
@@ -248,12 +246,13 @@ TimeAxisViewItem::init (ArdourCanvas::Item* parent, double fpp, uint32_t base_co
                frame_handle_start = frame_handle_end = 0;
        }
 
-       set_color (base_color);
+       //set_color (base_color);
 
-       set_duration (item_duration, this);
-       set_position (start, this);
+       //set_duration (item_duration, this);
+       //set_position (start, this);
 
-       Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&TimeAxisViewItem::parameter_changed, this, _1), gui_context ());
+       group->Event.connect (sigc::mem_fun (*this, &TimeAxisViewItem::canvas_group_event));
+       //Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&TimeAxisViewItem::parameter_changed, this, _1), gui_context ());
        UIConfiguration::instance().ParameterChanged.connect (sigc::mem_fun (*this, &TimeAxisViewItem::parameter_changed));
 }
 
@@ -533,7 +532,7 @@ TimeAxisViewItem::set_name_text(const string& new_name)
        name_text_width = pixel_width (new_name, NAME_FONT) + 2;
        name_text->set (new_name);
        manage_name_text ();
-
+       manage_name_highlight ();
 }
 
 /**
@@ -544,7 +543,7 @@ TimeAxisViewItem::set_name_text(const string& new_name)
 void
 TimeAxisViewItem::set_height (double height)
 {
-        _height = height;
+       _height = height;
 
        manage_name_highlight ();
 
@@ -570,13 +569,6 @@ TimeAxisViewItem::set_height (double height)
                        selection_frame->set (frame->get().shrink (1.0));
                }
        }
-
-       if (vestigial_frame) {
-               vestigial_frame->set_y0 (0.0);
-               vestigial_frame->set_y1 (height);
-       }
-
-       set_colors ();
 }
 
 void
@@ -645,7 +637,7 @@ TimeAxisViewItem::set_colors()
        set_frame_color ();
 
        if (name_highlight) {
-                name_highlight->set_fill_color (fill_color);
+               name_highlight->set_fill_color (fill_color);
        }
 
        set_name_text_color ();
@@ -674,10 +666,10 @@ TimeAxisViewItem::set_name_text_color ()
                f = get_fill_color ();
        }
 
-       name_text->set_color (ArdourCanvas::contrasting_text_color (f));
+       name_text->set_color (contrasting_text_color (f));
 }
 
-ArdourCanvas::Color
+Gtkmm2ext::Color
 TimeAxisViewItem::get_fill_color () const
 {
        const std::string mod_name = (_dragging ? "dragging region" : fill_color_name);
@@ -722,20 +714,20 @@ TimeAxisViewItem::set_frame_gradient ()
        ArdourCanvas::Fill::StopList stops;
        double r, g, b, a;
        double h, s, v;
-       ArdourCanvas::Color f (get_fill_color());
+       Color f (get_fill_color());
 
        /* need to get alpha value */
-       ArdourCanvas::color_to_rgba (f, r, g, b, a);
+       color_to_rgba (f, r, g, b, a);
 
        stops.push_back (std::make_pair (0.0, f));
 
        /* now a darker version */
 
-       ArdourCanvas::color_to_hsv (f, h, s, v);
+       color_to_hsv (f, h, s, v);
 
        v = min (1.0, v * (1.0 - UIConfiguration::instance().get_timeline_item_gradient_depth()));
 
-       ArdourCanvas::Color darker = ArdourCanvas::hsva_to_color (h, s, v, a);
+       Color darker = hsva_to_color (h, s, v, a);
        stops.push_back (std::make_pair (1.0, darker));
 
        frame->set_gradient (stops, true);
@@ -823,21 +815,9 @@ TimeAxisViewItem::reset_width_dependent_items (double pixel_width)
 
        if (pixel_width < 2.0) {
 
-               if (show_vestigial) {
-
-                       if (!vestigial_frame) {
-                               vestigial_frame = new ArdourCanvas::Rectangle (group, ArdourCanvas::Rect (0.0, 0.0, 2.0, trackview.current_height()));
-                               CANVAS_DEBUG_NAME (vestigial_frame, string_compose ("vestigial frame for %1", get_item_name()));
-                               vestigial_frame->set_outline_color (UIConfiguration::instance().color ("vestigial frame"));
-                               vestigial_frame->set_fill_color (UIConfiguration::instance().color ("vestigial frame"));
-                               vestigial_frame->set_outline_what (ArdourCanvas::Rectangle::What (ArdourCanvas::Rectangle::LEFT|ArdourCanvas::Rectangle::RIGHT));
-                       }
-
-                       vestigial_frame->show();
-               }
-
                if (frame) {
-                       frame->hide();
+                       frame->set_outline (false);
+                       frame->set_x1 (std::max(1.0, pixel_width));
                }
 
                if (frame_handle_start) {
@@ -846,12 +826,8 @@ TimeAxisViewItem::reset_width_dependent_items (double pixel_width)
                }
 
        } else {
-               if (vestigial_frame) {
-                       vestigial_frame->hide();
-               }
-
                if (frame) {
-                       frame->show();
+                       frame->set_outline (true);
                        /* Note: x0 is always zero - the position is defined by
                         * the position of the group, not the frame.
                         */
@@ -877,6 +853,9 @@ TimeAxisViewItem::reset_width_dependent_items (double pixel_width)
                                frame_handle_end->set_x0 (pixel_width - (TimeAxisViewItem::GRAB_HANDLE_WIDTH));
                                frame_handle_end->set_x1 (pixel_width);
                                frame_handle_end->show();
+
+                               frame_handle_start->raise_to_top ();
+                               frame_handle_end->raise_to_top ();
                        }
                }
        }