reinstate a canvas group where we reparent regions while dragging, so that they are...
[ardour.git] / gtk2_ardour / time_axis_view_item.h
index 3985b8ffd85f79952151460844e93c74256d52f1..cd813e17c930957af9f3109bfd4b138f08483c4f 100644 (file)
 #define __gtk_ardour_time_axis_view_item_h__
 
 #include <string>
-
-#include <libgnomecanvasmm/pixbuf.h>
-
+#include <gdk/gdk.h>
+#include <gdkmm/color.h>
+#include <pangomm/fontdescription.h>
 #include "pbd/signals.h"
-
 #include "selectable.h"
-#include "simplerect.h"
-#include "canvas.h"
 
 class TimeAxisView;
 
+namespace ArdourCanvas {
+       class Pixbuf;
+       class Rectangle;
+       class Item;
+       class Group;
+       class Text;
+}
+
 using ARDOUR::framepos_t;
 using ARDOUR::framecnt_t;
 
@@ -68,15 +73,18 @@ class TimeAxisViewItem : public Selectable, public PBD::ScopedConnectionList
        virtual void set_height(double h);
        void set_y (double);
        void set_color (Gdk::Color const &);
+       void set_name_text_color ();
+
+        uint32_t get_fill_color () const;
+       void visual_raise_to_top ();
 
        ArdourCanvas::Item* get_canvas_frame();
        ArdourCanvas::Group* get_canvas_group();
        ArdourCanvas::Item* get_name_highlight();
-       ArdourCanvas::Pixbuf* get_name_pixbuf();
 
-       virtual void set_samples_per_unit(double spu);
+       virtual void set_samples_per_pixel (double);
 
-       double get_samples_per_unit();
+       double get_samples_per_pixel () const;
 
        virtual void drag_start() { _dragging = true; }
        virtual void drag_end() { _dragging = false; }
@@ -108,6 +116,20 @@ class TimeAxisViewItem : public Selectable, public PBD::ScopedConnectionList
        static double NAME_HIGHLIGHT_SIZE;
        static double NAME_HIGHLIGHT_THRESH;
 
+        /* if this is 1.0, we move the right boundary
+          of the item frame so that it is 1 pixel
+          after the end of the item. This gives nice
+          effects when splitting items.
+          
+          if this is zero, the right edge coincides
+          with the end of the item, and things don't
+          look so nice. 
+          
+          this exists to allow easy debugging of the
+          two scenarios.
+       */
+       static const double RIGHT_EDGE_SHIFT;
+
        /**
         * Emitted when this Group has been removed.
         * This is different to the CatchDeletion signal in that this signal
@@ -153,16 +175,17 @@ class TimeAxisViewItem : public Selectable, public PBD::ScopedConnectionList
 
        TimeAxisViewItem (const TimeAxisViewItem&);
 
-       void init (const std::string&, double, Gdk::Color const &, framepos_t, framepos_t, Visibility, bool, bool);
+        void init (ArdourCanvas::Group*, double, Gdk::Color const &, framepos_t, framepos_t, Visibility, bool, bool);
+
+        virtual bool canvas_group_event (GdkEvent*);
 
        virtual void compute_colors (Gdk::Color const &);
        virtual void set_colors();
        virtual void set_frame_color();
+       virtual void set_frame_gradient ();
        void set_trim_handle_colors();
 
        virtual void reset_width_dependent_items (double);
-       void reset_name_width (double);
-       void update_name_pixbuf_visibility ();
 
        static gint idle_remove_this_item(TimeAxisViewItem*, void*);
 
@@ -190,8 +213,8 @@ class TimeAxisViewItem : public Selectable, public PBD::ScopedConnectionList
        /** indicates whether the min duration constraint is active */
        bool min_duration_active;
 
-       /** samples per canvas unit */
-       double samples_per_unit;
+       /** frames per canvas pixel */
+       double samples_per_pixel;
 
        /** should the item respond to events */
        bool _sensitive;
@@ -216,29 +239,24 @@ class TimeAxisViewItem : public Selectable, public PBD::ScopedConnectionList
        uint32_t selected_frame_color_r;
        uint32_t selected_frame_color_g;
        uint32_t selected_frame_color_b;
-       uint32_t label_color;
-
-       uint32_t handle_color_r;
-       uint32_t handle_color_g;
-       uint32_t handle_color_b;
-       uint32_t lock_handle_color_r;
-       uint32_t lock_handle_color_g;
-       uint32_t lock_handle_color_b;
+
        uint32_t last_item_width;
-       int name_pixbuf_width;
+       int name_text_width;
        bool wide_enough_for_name;
        bool high_enough_for_name;
         bool rect_visible;
 
        ArdourCanvas::Group*      group;
-       ArdourCanvas::SimpleRect* vestigial_frame;
-       ArdourCanvas::SimpleRect* frame;
-       ArdourCanvas::Pixbuf*     name_pixbuf;
-       ArdourCanvas::SimpleRect* name_highlight;
+       ArdourCanvas::Rectangle* vestigial_frame;
+       ArdourCanvas::Rectangle* frame;
+       ArdourCanvas::Text*      name_text;
+       ArdourCanvas::Rectangle* name_highlight;
 
        /* with these two values, if frame_handle_start == 0 then frame_handle_end will also be 0 */
-       ArdourCanvas::SimpleRect* frame_handle_start; ///< `frame' (fade) handle for the start of the item, or 0
-       ArdourCanvas::SimpleRect* frame_handle_end; ///< `frame' (fade) handle for the end of the item, or 0
+       ArdourCanvas::Rectangle* frame_handle_start; ///< `frame' (fade) handle for the start of the item, or 0
+       ArdourCanvas::Rectangle* frame_handle_end; ///< `frame' (fade) handle for the end of the item, or 0
+
+        bool frame_handle_crossing (GdkEvent*, ArdourCanvas::Rectangle*);
 
        double _height;
        Visibility visibility;
@@ -247,8 +265,11 @@ class TimeAxisViewItem : public Selectable, public PBD::ScopedConnectionList
        bool _dragging;
 
 private:
+        double _width;
 
        void parameter_changed (std::string);
+        void manage_name_highlight ();
+        void manage_name_text ();
 
 }; /* class TimeAxisViewItem */