Make MIDI regions translucent for internal tools.
authorDavid Robillard <d@drobilla.net>
Sat, 13 Dec 2014 01:22:16 +0000 (20:22 -0500)
committerDavid Robillard <d@drobilla.net>
Fri, 19 Dec 2014 01:23:23 +0000 (20:23 -0500)
gtk2_ardour/midi_region_view.cc
gtk2_ardour/midi_region_view.h
gtk2_ardour/time_axis_view_item.cc
gtk2_ardour/time_axis_view_item.h

index 197e19076124fd8344b73a1ee24e336deb21a11a..18ea905ce447bca4006e4b68a208ef700088ff92 100644 (file)
@@ -317,6 +317,10 @@ MidiRegionView::init (bool wfd)
                                               boost::bind (&MidiRegionView::snap_changed, this),
                                               gui_context());
 
+       trackview.editor().MouseModeChanged.connect(_mouse_mode_connection, invalidator (*this),
+                                                   boost::bind (&MidiRegionView::mouse_mode_changed, this),
+                                                   gui_context ());
+
        Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&MidiRegionView::parameter_changed, this, _1), gui_context());
        connect_to_diskstream ();
 
@@ -413,10 +417,6 @@ MidiRegionView::canvas_group_event(GdkEvent* ev)
 bool
 MidiRegionView::enter_notify (GdkEventCrossing* ev)
 {
-       trackview.editor().MouseModeChanged.connect (
-               _mouse_mode_connection, invalidator (*this), boost::bind (&MidiRegionView::mouse_mode_changed, this), gui_context ()
-               );
-
        enter_internal();
 
        _entered = true;
@@ -437,12 +437,17 @@ MidiRegionView::leave_notify (GdkEventCrossing*)
 void
 MidiRegionView::mouse_mode_changed ()
 {
-       if (trackview.editor().internal_editing()) {
-               // Switched in to internal editing mode while entered
-               enter_internal();
-       } else {
-               // Switched out of internal editing mode while entered
-               leave_internal();
+       // Adjust frame colour (become more transparent for internal tools)
+       set_frame_color();
+
+       if (_entered) {
+               if (trackview.editor().internal_editing()) {
+                       // Switched in to internal editing mode while entered
+                       enter_internal();
+               } else {
+                       // Switched out of internal editing mode while entered
+                       leave_internal();
+               }
        }
 }
 
@@ -3236,6 +3241,19 @@ MidiRegionView::note_mouse_position (float x_fraction, float /*y_fraction*/, boo
        }
 }
 
+uint32_t
+MidiRegionView::fill_opacity() const
+{
+       uint32_t a = RegionView::fill_opacity();
+       if (trackview.editor().current_mouse_mode() == MouseDraw ||
+           trackview.editor().current_mouse_mode() == MouseContent) {
+               /* Make rect more transparent when in an internal mode.  This should
+                  probably be configurable somehow. */
+               a /= 2;
+       }
+       return a;
+}
+
 void
 MidiRegionView::set_frame_color()
 {
@@ -3255,9 +3273,7 @@ MidiRegionView::set_frame_color()
                f = fill_color;
        }
 
-       if (!rect_visible) {
-               f = UINT_RGBA_CHANGE_A (f, 80);
-       }
+       f = UINT_RGBA_CHANGE_A (f, fill_opacity());
 
        frame->set_fill_color (f);
 }
index f9cc7c7299dd76c8917bb7804362e1b63bbfc7d3..74344380e0a5758c3bf49a7bb1b07af85375515b 100644 (file)
@@ -109,6 +109,8 @@ public:
        void set_frame_color();
        void color_handler ();
 
+       uint32_t fill_opacity() const;
+
        void show_step_edit_cursor (Evoral::MusicalTime pos);
        void move_step_edit_cursor (Evoral::MusicalTime pos);
        void hide_step_edit_cursor ();
index 2f860d897bfa10e29c760f637c9008ba50ad5d37..8c38293442eac78e840177a029177b4dd1254d2f 100644 (file)
@@ -184,7 +184,6 @@ TimeAxisViewItem::init (ArdourCanvas::Item* parent, double fpp, uint32_t base_co
        last_item_width = 0;
        wide_enough_for_name = wide;
        high_enough_for_name = high;
-        rect_visible = true;
        vestigial_frame = 0;
 
        if (duration == 0) {
@@ -287,30 +286,6 @@ TimeAxisViewItem::canvas_group_event (GdkEvent* /*ev*/)
        return false;
 }
 
-void
-TimeAxisViewItem::hide_rect ()
-{
-        rect_visible = false;
-        set_frame_color ();
-
-        if (name_highlight) {
-                name_highlight->set_outline_what (ArdourCanvas::Rectangle::What (0));
-                name_highlight->set_fill_color (UINT_RGBA_CHANGE_A (fill_color, 64));
-        }
-}
-
-void
-TimeAxisViewItem::show_rect ()
-{
-        rect_visible = true;
-        set_frame_color ();
-
-        if (name_highlight) {
-                name_highlight->set_outline_what (ArdourCanvas::Rectangle::TOP);
-                name_highlight->set_fill_color (fill_color);
-        }
-}
-
 /**
  * Set the position of this item on the timeline.
  *
@@ -719,13 +694,6 @@ TimeAxisViewItem::set_name_text_color ()
 uint32_t
 TimeAxisViewItem::fill_opacity () const
 {
-       if (!rect_visible) {
-               /* if the frame/rect is marked as "invisible", then the
-                  fill should be translucent.parent.
-               */
-               return 64;
-       }
-
        if (_dragging) {
                return 130;
        }
index 74a655a6c0e14e33c1dab7d165123998b316625f..576e2ae76a9a8f35bc9ebfc60fa6f8e04bea7182 100644 (file)
@@ -95,9 +95,6 @@ class TimeAxisViewItem : public Selectable, public PBD::ScopedConnectionList
        virtual void lower () { return; }
        virtual void lower_to_bottom () { return; }
 
-        virtual void hide_rect ();
-        virtual void show_rect ();
-
        /** @return true if the name area should respond to events */
        bool name_active() const { return name_connected; }
 
@@ -224,7 +221,6 @@ class TimeAxisViewItem : public Selectable, public PBD::ScopedConnectionList
        int name_text_width;
        bool wide_enough_for_name;
        bool high_enough_for_name;
-        bool rect_visible;
 
        ArdourCanvas::Container*      group;
        ArdourCanvas::Rectangle* vestigial_frame;