No-op: comments.
[ardour.git] / gtk2_ardour / group_tabs.h
1 /*
2     Copyright (C) 2009 Paul Davis 
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include <gtkmm/menu.h>
21 #include "cairo_widget.h"
22
23 namespace ARDOUR {
24         class Session;
25         class RouteGroup;
26 }
27
28 class Editor;
29
30 /** Parent class for tabs which represent route groups as coloured tabs;
31  *  Currently used on the left-hand side of the editor and at the top of the mixer.
32  */
33 class GroupTabs : public CairoWidget
34 {
35 public:
36         GroupTabs ();
37
38         void set_session (ARDOUR::Session *);
39
40 protected:
41
42         struct Tab {
43                 double from; ///< start coordinate
44                 double to; ///< end coordinate
45                 Gdk::Color colour; ///< colour
46                 ARDOUR::RouteGroup* group; ///< route group
47                 double first_ui_size; ///< GUI size of the first route in the group
48                 double last_ui_size; ///< GUI size of the last route in the group
49         };
50
51         ARDOUR::Session* _session; ///< our session
52
53 private:
54         /** Compute all the tabs for this widget.
55          *  @return Tabs.
56          */
57         virtual std::list<Tab> compute_tabs () const = 0;
58
59         /** Draw a tab.
60          *  @param cr Cairo context.
61          *  @param t Tab.
62          */
63         virtual void draw_tab (cairo_t* cr, Tab const & t) const = 0;
64
65         /** @param x x coordinate
66          *  @param y y coordinate
67          *  @return x or y, depending on which is the primary coordinate for this widget.
68          */
69         virtual double primary_coordinate (double, double) const = 0;
70
71         /** Take a list of tabs and alter the route groups to reflect the tabs.
72          *  @param tabs.
73          */
74         virtual void reflect_tabs (std::list<Tab> const & tabs) = 0;
75
76         /** @return Size of the widget along the primary axis */
77         virtual double extent () const = 0;
78
79         /** @param g Route group.
80          *  @return Menu to be popped up on right-click over the given route group.
81          */
82         virtual Gtk::Menu* get_menu (ARDOUR::RouteGroup* g) = 0;
83
84         void render (cairo_t *);
85         void on_size_request (Gtk::Requisition *);
86         bool on_button_press_event (GdkEventButton *);
87         bool on_motion_notify_event (GdkEventMotion *);
88         bool on_button_release_event (GdkEventButton *);
89
90         Tab * click_to_tab (double, Tab**, Tab**);
91
92         std::list<Tab> _tabs; ///< current list of tabs
93         Tab* _dragging; ///< tab being dragged, or 0
94         bool _drag_moved; ///< true if there has been movement during any current drag
95         bool _drag_from; ///< true if the drag is of the `from' end of the tab, otherwise it's the `to' end
96         double _drag_last; ///< last mouse pointer position during drag
97         double _drag_limit; ///< limit of the current drag
98 };