fix peak-thread, GUI-thread race condition
[ardour.git] / gtk2_ardour / note_base.h
index f76c184a20cc164ffbe43e49cf94eaf7e0aa831c..01c85b07f0f406880871ac78ff3bcb4b9bd6af84 100644 (file)
@@ -41,7 +41,7 @@ namespace ArdourCanvas {
        class Text;
 }
 
-/** This manages all the event handling for any MIDI event on the canvas.
+/** Base class for canvas notes (sustained note rectangles and hit diamonds).
  *
  * This is not actually a canvas item itself to avoid the dreaded diamond
  * inheritance pattern, since various types of canvas items (Note (rect), Hit
@@ -51,11 +51,10 @@ namespace ArdourCanvas {
  * Note: Because of this, derived classes need to manually bounce events to
  * on_event, it won't happen automatically.
  */
-
 class NoteBase : public sigc::trackable
 {
   public:
-       typedef Evoral::Note<Evoral::MusicalTime> NoteType;
+       typedef Evoral::Note<Evoral::Beats> NoteType;
 
        NoteBase (MidiRegionView& region, bool, const boost::shared_ptr<NoteType> note = boost::shared_ptr<NoteType>());
        virtual ~NoteBase ();
@@ -91,6 +90,8 @@ class NoteBase : public sigc::trackable
        virtual void set_outline_color(uint32_t c) = 0;
        virtual void set_fill_color(uint32_t c) = 0;
 
+       virtual void set_ignore_events(bool ignore) = 0;
+
        virtual ArdourCanvas::Coord x0 () const = 0;
        virtual ArdourCanvas::Coord y0 () const = 0;
        virtual ArdourCanvas::Coord x1 () const = 0;
@@ -103,36 +104,28 @@ class NoteBase : public sigc::trackable
        MidiRegionView& region_view() const { return _region; }
 
        inline static uint32_t meter_style_fill_color(uint8_t vel, bool selected) {
-                if (selected) {
-                        if (vel < 64) {
-                                return UINT_INTERPOLATE(
-                                       ARDOUR_UI::config()->color ("selected midi note color min"),
-                                       ARDOUR_UI::config()->color ("selected midi note color mid"),
-                                       (vel / (double)63.0));
-                        } else {
-                                return UINT_INTERPOLATE(
-                                       ARDOUR_UI::config()->color ("selected midi note color mid"),
-                                       ARDOUR_UI::config()->color ("selected midi note color max"),
-                                       ((vel-64) / (double)63.0));
-                        }
-                } else {
-                        if (vel < 64) {
-                                return UINT_INTERPOLATE(
-                                       ARDOUR_UI::config()->color ("midi note color min"),
-                                       ARDOUR_UI::config()->color ("midi note color mid"),
-                                       (vel / (double)63.0));
-                        } else {
-                                return UINT_INTERPOLATE(
-                                       ARDOUR_UI::config()->color ("midi note color mid"),
-                                       ARDOUR_UI::config()->color ("midi note color max"),
-                                       ((vel-64) / (double)63.0));
-                        }
-                }
+               if (selected) {
+                       return ARDOUR_UI::config()->color_mod ("midi note selected", "midi note");
+               } else if (vel < 64) {
+                       return UINT_INTERPOLATE(
+                               ARDOUR_UI::config()->color_mod ("midi note min", "midi note"),
+                               ARDOUR_UI::config()->color_mod ("midi note mid", "midi note"),
+                               (vel / (double)63.0));
+               } else {
+                       return UINT_INTERPOLATE(
+                               ARDOUR_UI::config()->color_mod ("midi note mid", "midi note"),
+                               ARDOUR_UI::config()->color_mod ("midi note max", "midi note"),
+                               ((vel-64) / (double)63.0));
+               }
        }
 
        /// calculate outline colors from fill colors of notes
-       inline static uint32_t calculate_outline(uint32_t color) {
-               return UINT_INTERPOLATE(color, 0x000000ff, 0.5);
+       inline static uint32_t calculate_outline(uint32_t color, bool selected=false) {
+               if (selected) {
+                       return ARDOUR_UI::config()->color ("midi note selected outline");
+               } else {
+                       return UINT_INTERPOLATE(color, 0x000000ff, 0.5);
+               }
        }
 
        /// hue circle divided into 16 equal-looking parts, courtesy Thorsten Wilms