update drobilla's fascistic dir-locals.el to force emacs users into whitespace submis...
[ardour.git] / gtk2_ardour / time_axis_view_item.cc
index f0dd9a7984d79c56b064c107d8e2d663d877f0a5..8d3d408bc89ef23ad64964396f79cc33fd5614cf 100644 (file)
@@ -23,7 +23,8 @@
 #include "ardour/types.h"
 #include "ardour/ardour.h"
 
-#include <gtkmm2ext/utils.h>
+#include "gtkmm2ext/utils.h"
+#include "gtkmm2ext/gui_thread.h"
 
 #include "ardour_ui.h"
 /*
@@ -155,6 +156,7 @@ TimeAxisViewItem::init (
        last_item_width = 0;
        wide_enough_for_name = wide;
        high_enough_for_name = high;
+        rect_visible = true;
 
        if (duration == 0) {
                warning << "Time Axis Item Duration == 0" << endl;
@@ -224,6 +226,8 @@ TimeAxisViewItem::init (
 
        set_duration (item_duration, this);
        set_position (start, this);
+
+       Config->ParameterChanged.connect (*this, invalidator (*this), ui_bind (&TimeAxisViewItem::parameter_changed, this, _1), gui_context ());
 }
 
 TimeAxisViewItem::~TimeAxisViewItem()
@@ -231,6 +235,30 @@ TimeAxisViewItem::~TimeAxisViewItem()
        delete group;
 }
 
+void
+TimeAxisViewItem::hide_rect ()
+{
+        rect_visible = false;
+        set_frame_color ();
+
+        if (name_highlight) {
+                name_highlight->property_outline_what() = 0x0;
+                name_highlight->property_fill_color_rgba() = UINT_RGBA_CHANGE_A(fill_color,64);
+        }
+}
+
+void
+TimeAxisViewItem::show_rect ()
+{
+        rect_visible = true;
+        set_frame_color ();
+
+        if (name_highlight) {
+                name_highlight->property_outline_what() = 0x4;
+                name_highlight->property_fill_color_rgba() = fill_color;
+        }
+}
+
 
 /**
  * Set the position of this item on the timeline.
@@ -531,6 +559,7 @@ TimeAxisViewItem::set_height (double height)
        vestigial_frame->property_y2() = height - 1;
 
        update_name_pixbuf_visibility ();
+       set_colors ();
 }
 
 void
@@ -678,27 +707,61 @@ TimeAxisViewItem::set_colors()
 void
 TimeAxisViewItem::set_frame_color()
 {
+        uint32_t f = 0;
+
        if (!frame) {
                return;
        }
        
        if (_selected) {
+
+                f = ARDOUR_UI::config()->canvasvar_SelectedFrameBase.get();
+
                if (fill_opacity) {
-                       frame->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (ARDOUR_UI::config()->canvasvar_SelectedFrameBase.get(), fill_opacity);
-               } else {
-                       frame->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_SelectedFrameBase.get();
-               }
+                        f = UINT_RGBA_CHANGE_A (f, fill_opacity);
+               } 
+
+                if (!rect_visible) {
+                        f = UINT_RGBA_CHANGE_A (f, 0);
+                }
+
        } else {
+
                if (_recregion) {
-                       frame->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_RecordingRect.get();
+                       f = ARDOUR_UI::config()->canvasvar_RecordingRect.get();
                } else {
-                       if (fill_opacity) {
-                               frame->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (ARDOUR_UI::config()->canvasvar_FrameBase.get(), fill_opacity);
+                        
+                       if (high_enough_for_name && !Config->get_color_regions_using_track_color()) {
+                               f = ARDOUR_UI::config()->canvasvar_FrameBase.get();
                        } else {
-                               frame->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_FrameBase.get();
+                               f = fill_color;
                        }
-               }
+
+                       if (fill_opacity) {
+                               f = UINT_RGBA_CHANGE_A (f, fill_opacity);
+                       }
+
+                        if (!rect_visible) {
+                                f = UINT_RGBA_CHANGE_A (f, 0);
+                        }
+                }
        }
+
+        frame->property_fill_color_rgba() = f;
+
+        if (!_recregion) {
+                if (_selected) {
+                        f = ARDOUR_UI::config()->canvasvar_SelectedTimeAxisFrame.get();
+                } else {
+                        f = ARDOUR_UI::config()->canvasvar_TimeAxisFrame.get();
+                }
+                
+                if (!rect_visible) {
+                        f = UINT_RGBA_CHANGE_A (f, 64);
+                }
+                
+                frame->property_outline_color_rgba() = f;
+        }
 }
 
 /**
@@ -893,3 +956,10 @@ TimeAxisViewItem::update_name_pixbuf_visibility ()
        }
 }
 
+void
+TimeAxisViewItem::parameter_changed (string p)
+{
+       if (p == "color-regions-using-track-color") {
+               set_frame_color ();
+       }
+}