change Metric element of a Canvas::Ruler item into a pointer internally
[ardour.git] / libs / canvas / canvas / canvas.h
index b15c2f4d5488bd57f2ae61b4975186b3ec9ae58c..c3ab322b67cf12079c277743c424650151d69f8d 100644 (file)
 
 namespace ArdourCanvas
 {
+struct Rect;
 
-class Rect;
-class Group;   
+class Item;
+class ScrollGroup;
 
 /** The base class for our different types of canvas.
  *
@@ -60,7 +61,7 @@ public:
        Canvas ();
        virtual ~Canvas () {}
 
-       /** called to request a redraw of an area of the canvas */
+       /** called to request a redraw of an area of the canvas in WINDOW coordinates */
        virtual void request_redraw (Rect const &) = 0;
        /** called to ask the canvas to request a particular size from its host */
        virtual void request_size (Duple) = 0;
@@ -77,7 +78,7 @@ public:
        void render (Rect const &, Cairo::RefPtr<Cairo::Context> const &) const;
 
        /** @return root group */
-       Group* root () {
+       Item* root () {
                return &_root;
        }
 
@@ -90,8 +91,6 @@ public:
 
         virtual Cairo::RefPtr<Cairo::Context> context () = 0;
 
-        Rect canvas_to_window (Rect const&, bool rounded = true) const;
-        Rect window_to_canvas (Rect const&) const;
         Duple canvas_to_window (Duple const&, bool rounded = true) const;
         Duple window_to_canvas (Duple const&) const;
 
@@ -108,25 +107,50 @@ public:
         }
 
         void scroll_to (Coord x, Coord y);
-        virtual Rect visible_area () const = 0;
+       void add_scroller (ScrollGroup& i);
+        
+        virtual Rect  visible_area () const = 0;
+        virtual Coord width () const = 0;
+        virtual Coord height () const = 0;
+
+       /** Store the coordinates of the mouse pointer in window coordinates in
+          @param winpos. Return true if the position was within the window,
+          false otherwise.
+       */
+       virtual bool get_mouse_position (Duple& winpos) const = 0;
+
+       /** Signal to be used by items that need to track the mouse position
+          within the window.
+       */
+       sigc::signal<void,Duple const&> MouseMotion;
+
+       /** Ensures that the position given by @param winpos (in window
+           coordinates) is within the current window area, possibly reduced by
+           @param border.
+       */
+       Duple clamp_to_window (Duple const& winpos, Duple border = Duple());
 
         void zoomed();
     
         std::string indent() const;
         std::string render_indent() const;
         void dump (std::ostream&) const;
+
+       /** Ask the canvas to pick the current item again, and generate
+           an enter event for it.
+       */
+       virtual void re_enter () = 0;
     
 protected:
        void queue_draw_item_area (Item *, Rect);
        
-       /** our root group */
-       RootGroup _root;
-
-        Coord _scroll_offset_x;
-        Coord _scroll_offset_y;
+       /** our root item */
+       Root _root;
 
         virtual void pick_current_item (int state) = 0;
         virtual void pick_current_item (Duple const &, int state) = 0;
+
+       std::list<ScrollGroup*> scrollers;
 };
 
 /** A canvas which renders onto a GTK EventBox */
@@ -145,8 +169,15 @@ public:
        Cairo::RefPtr<Cairo::Context> context ();
 
        Rect visible_area () const;
+       Coord width() const;
+       Coord height() const;
+
+       bool get_mouse_position (Duple& winpos) const;
+
+       void re_enter ();
 
 protected:
+       bool on_scroll_event (GdkEventScroll *);
        bool on_expose_event (GdkEventExpose *);
        bool on_button_press_event (GdkEventButton *);
        bool on_button_release_event (GdkEventButton* event);