fix inverse solo push to work properly in both exclusive and non-exclusive solo modes
[ardour2.git] / gtk2_ardour / group_tabs.h
blobdbe3174f1b2129551299bda49705f9a12a06eb13
1 /*
2 Copyright (C) 2009 Paul Davis
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.
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.
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.
20 #include <gtkmm/menu.h>
21 #include "editor_component.h"
22 #include "cairo_widget.h"
24 namespace ARDOUR {
25 class Session;
26 class RouteGroup;
29 class Editor;
31 /** Parent class for tabs which represent route groups as coloured tabs;
32 * Currently used on the left-hand side of the editor and at the top of the mixer.
34 class GroupTabs : public CairoWidget, public EditorComponent
36 public:
37 GroupTabs (Editor *);
39 void set_session (ARDOUR::Session *);
41 protected:
43 struct Tab {
44 Tab () : group (0) {}
46 double from;
47 double to;
48 Gdk::Color colour; ///< colour
49 ARDOUR::RouteGroup* group; ///< route group
52 private:
53 /** Compute all the tabs for this widget.
54 * @return Tabs.
56 virtual std::list<Tab> compute_tabs () const = 0;
58 /** Draw a tab.
59 * @param cr Cairo context.
60 * @param t Tab.
62 virtual void draw_tab (cairo_t* cr, Tab const & t) const = 0;
64 /** @param x x coordinate
65 * @param y y coordinate
66 * @return x or y, depending on which is the primary coordinate for this widget.
68 virtual double primary_coordinate (double, double) const = 0;
70 virtual ARDOUR::RouteList routes_for_tab (Tab const * t) const = 0;
72 /** @return Size of the widget along the primary axis */
73 virtual double extent () const = 0;
75 /** @param g Route group, or 0.
76 * @return Menu to be popped up on right-click over the given route group.
78 virtual Gtk::Menu* get_menu (ARDOUR::RouteGroup* g) = 0;
80 virtual ARDOUR::RouteGroup* new_route_group () const = 0;
82 void render (cairo_t *);
83 void on_size_request (Gtk::Requisition *);
84 bool on_button_press_event (GdkEventButton *);
85 bool on_motion_notify_event (GdkEventMotion *);
86 bool on_button_release_event (GdkEventButton *);
88 Tab * click_to_tab (double, std::list<Tab>::iterator *, std::list<Tab>::iterator *);
90 std::list<Tab> _tabs; ///< current list of tabs
91 Tab* _dragging; ///< tab being dragged, or 0
92 bool _dragging_new_tab; ///< true if we're dragging a new tab
93 bool _drag_moved; ///< true if there has been movement during any current drag
94 double _drag_fixed; ///< the position of the fixed end of the tab being dragged
95 double _drag_moving; ///< the position of the moving end of the tab being dragged
96 double _drag_offset; ///< offset from the mouse to the end of the tab being dragged
97 double _drag_min; ///< minimum position for drag
98 double _drag_max; ///< maximum position for drag
99 double _drag_first; ///< first mouse pointer position during drag