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 "gtkmm2ext/cairo_widget.h"
30 class RouteGroupDialog;
32 /** Parent class for tabs which represent route groups as colored tabs;
33 * Currently used on the left-hand side of the editor and at the top of the mixer.
35 * This class also contains a fair bit of code to handle changes to route
36 * group colours; it seems a bit out of place, but I could not really think
37 * of a better place to put it.
39 class GroupTabs : public CairoWidget, public ARDOUR::SessionHandlePtr
43 virtual ~GroupTabs ();
45 void set_session (ARDOUR::Session *);
47 /** @param g Route group, or 0.
48 * @return Menu to be popped up on right-click over the given route group.
50 Gtk::Menu* get_menu (ARDOUR::RouteGroup* g, bool tabArea = false);
52 void run_new_group_dialog (ARDOUR::RouteList const *, bool with_master);
54 static void set_group_color (ARDOUR::RouteGroup *, uint32_t);
55 static std::string group_gui_id (ARDOUR::RouteGroup *);
56 static uint32_t group_color (ARDOUR::RouteGroup *);
65 uint32_t color; ///< color
66 ARDOUR::RouteGroup* group; ///< route group
70 static void emit_gui_changed_for_members (ARDOUR::RouteGroup *);
72 /** Compute all the tabs for this widget.
75 virtual std::list<Tab> compute_tabs () const = 0;
78 * @param cr Cairo context.
81 virtual void draw_tab (cairo_t* cr, Tab const & t) const = 0;
83 /** @param x x coordinate
84 * @param y y coordinate
85 * @return x or y, depending on which is the primary coordinate for this widget.
87 virtual double primary_coordinate (double, double) const = 0;
89 virtual ARDOUR::RouteList routes_for_tab (Tab const * t) const = 0;
91 /** @return Size of the widget along the primary axis */
92 virtual double extent () const = 0;
94 virtual void add_menu_items (Gtk::Menu *, ARDOUR::RouteGroup *) {}
95 virtual ARDOUR::RouteList selected_routes () const = 0;
97 void add_new_from_items (Gtk::Menu_Helpers::MenuList&);
99 void new_from_selection (bool with_master);
100 void new_from_rec_enabled (bool with_master);
101 void new_from_soloed (bool with_master);
103 void new_group_dialog_finished (int, RouteGroupDialog*, ARDOUR::RouteList const *, bool with_master) const;
104 void edit_group_dialog_finished (int, RouteGroupDialog*) const;
106 void collect (ARDOUR::RouteGroup *);
107 void set_activation (ARDOUR::RouteGroup *, bool);
108 void edit_group (ARDOUR::RouteGroup *);
109 void subgroup (ARDOUR::RouteGroup *, bool, ARDOUR::Placement);
110 void un_subgroup (ARDOUR::RouteGroup *);
111 void activate_all ();
113 void remove_group (ARDOUR::RouteGroup *);
115 void render (cairo_t *, cairo_rectangle_t*);
116 void on_size_request (Gtk::Requisition *);
117 bool on_button_press_event (GdkEventButton *);
118 bool on_motion_notify_event (GdkEventMotion *);
119 bool on_button_release_event (GdkEventButton *);
121 Tab * click_to_tab (double, std::list<Tab>::iterator *, std::list<Tab>::iterator *);
123 void route_group_property_changed (ARDOUR::RouteGroup *);
124 void route_added_to_route_group (ARDOUR::RouteGroup *, boost::weak_ptr<ARDOUR::Route>);
125 void route_removed_from_route_group (ARDOUR::RouteGroup *, boost::weak_ptr<ARDOUR::Route>);
127 void assign_group_to_master (uint32_t which, ARDOUR::RouteGroup*, bool rename_master) const;
128 void assign_selection_to_master (uint32_t which);
129 void assign_recenabled_to_master (uint32_t which);
130 void assign_soloed_to_master (uint32_t which);
131 void assign_some_to_master (uint32_t which, ARDOUR::RouteList);
133 ARDOUR::RouteList get_soloed ();
134 ARDOUR::RouteList get_rec_enabled ();
137 std::list<Tab> _tabs; ///< current list of tabs
138 Tab* _dragging; ///< tab being dragged, or 0
139 /** routes that were in the tab that is being dragged when the drag started */
140 ARDOUR::RouteList _initial_dragging_routes;
141 bool _dragging_new_tab; ///< true if we're dragging a new tab
142 bool _drag_moved; ///< true if there has been movement during any current drag
143 double _drag_fixed; ///< the position of the fixed end of the tab being dragged
144 double _drag_moving; ///< the position of the moving end of the tab being dragged
145 double _drag_offset; ///< offset from the mouse to the end of the tab being dragged
146 double _drag_min; ///< minimum position for drag
147 double _drag_max; ///< maximum position for drag
148 double _drag_first; ///< first mouse pointer position during drag
150 /** colors that have been used for new route group tabs */
151 static std::list<Gdk::Color> _used_colors;