2 * Copyright (C) 2009-2011 Carl Hetherington <carl@carlh.net>
3 * Copyright (C) 2009-2011 David Robillard <d@drobilla.net>
4 * Copyright (C) 2009-2017 Paul Davis <paul@linuxaudiosystems.com>
5 * Copyright (C) 2014-2017 Robin Gareus <robin@gareus.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #ifndef __gtk_ardour_group_tabs_h__
23 #define __gtk_ardour_group_tabs_h__
25 #include <gtkmm/menu.h>
26 #include "editor_component.h"
27 #include "gtkmm2ext/cairo_widget.h"
35 class RouteGroupDialog;
37 /** Parent class for tabs which represent route groups as colored tabs;
38 * Currently used on the left-hand side of the editor and at the top of the mixer.
40 * This class also contains a fair bit of code to handle changes to route
41 * group colours; it seems a bit out of place, but I could not really think
42 * of a better place to put it.
44 class GroupTabs : public CairoWidget, public ARDOUR::SessionHandlePtr
48 virtual ~GroupTabs ();
50 void set_session (ARDOUR::Session *);
52 /** @param g Route group, or 0.
53 * @return Menu to be popped up on right-click over the given route group.
55 Gtk::Menu* get_menu (ARDOUR::RouteGroup* g, bool tabArea = false);
57 void run_new_group_dialog (ARDOUR::RouteList const *, bool with_master);
59 static void set_group_color (ARDOUR::RouteGroup *, uint32_t);
60 static std::string group_gui_id (ARDOUR::RouteGroup *);
61 static uint32_t group_color (ARDOUR::RouteGroup *);
70 uint32_t color; ///< color
71 ARDOUR::RouteGroup* group; ///< route group
75 static void emit_gui_changed_for_members (boost::shared_ptr<ARDOUR::RouteList>);
77 /** Compute all the tabs for this widget.
80 virtual std::list<Tab> compute_tabs () const = 0;
83 * @param cr Cairo context.
86 virtual void draw_tab (cairo_t* cr, Tab const & t) = 0;
88 /** @param x x coordinate
89 * @param y y coordinate
90 * @return x or y, depending on which is the primary coordinate for this widget.
92 virtual double primary_coordinate (double, double) const = 0;
94 virtual ARDOUR::RouteList routes_for_tab (Tab const * t) const = 0;
96 /** @return Size of the widget along the primary axis */
97 virtual double extent () const = 0;
99 virtual void add_menu_items (Gtk::Menu *, ARDOUR::RouteGroup *) {}
100 virtual ARDOUR::RouteList selected_routes () const = 0;
102 void add_new_from_items (Gtk::Menu_Helpers::MenuList&);
104 void new_from_selection (bool with_master);
105 void new_from_rec_enabled (bool with_master);
106 void new_from_soloed (bool with_master);
108 void new_group_dialog_finished (int, RouteGroupDialog*, ARDOUR::RouteList const *, bool with_master) const;
109 void edit_group_dialog_finished (int, RouteGroupDialog*) const;
111 void collect (ARDOUR::RouteGroup *);
112 void set_activation (ARDOUR::RouteGroup *, bool);
113 void edit_group (ARDOUR::RouteGroup *);
114 void subgroup (ARDOUR::RouteGroup *, bool, ARDOUR::Placement);
115 void un_subgroup (ARDOUR::RouteGroup *);
116 void activate_all ();
118 void remove_group (ARDOUR::RouteGroup *);
120 void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*);
121 void on_size_request (Gtk::Requisition *);
122 bool on_button_press_event (GdkEventButton *);
123 bool on_motion_notify_event (GdkEventMotion *);
124 bool on_button_release_event (GdkEventButton *);
126 Tab * click_to_tab (double, std::list<Tab>::iterator *, std::list<Tab>::iterator *);
128 void route_group_property_changed (ARDOUR::RouteGroup *);
129 void route_added_to_route_group (ARDOUR::RouteGroup *, boost::weak_ptr<ARDOUR::Route>);
130 void route_removed_from_route_group (ARDOUR::RouteGroup *, boost::weak_ptr<ARDOUR::Route>);
132 void assign_group_to_master (uint32_t which, ARDOUR::RouteGroup*, bool rename_master) const;
133 void unassign_group_to_master (uint32_t which, ARDOUR::RouteGroup*) const;
134 void assign_selection_to_master (uint32_t which);
135 void assign_recenabled_to_master (uint32_t which);
136 void assign_soloed_to_master (uint32_t which);
137 void assign_some_to_master (uint32_t which, ARDOUR::RouteList, std::string vcaname = "");
139 ARDOUR::RouteList get_soloed ();
140 ARDOUR::RouteList get_rec_enabled ();
143 std::list<Tab> _tabs; ///< current list of tabs
144 Tab* _dragging; ///< tab being dragged, or 0
145 /** routes that were in the tab that is being dragged when the drag started */
146 ARDOUR::RouteList _initial_dragging_routes;
147 bool _dragging_new_tab; ///< true if we're dragging a new tab
148 bool _drag_moved; ///< true if there has been movement during any current drag
149 double _drag_fixed; ///< the position of the fixed end of the tab being dragged
150 double _drag_moving; ///< the position of the moving end of the tab being dragged
151 double _drag_offset; ///< offset from the mouse to the end of the tab being dragged
152 double _drag_min; ///< minimum position for drag
153 double _drag_max; ///< maximum position for drag
154 double _drag_first; ///< first mouse pointer position during drag
156 /** colors that have been used for new route group tabs */
157 static std::list<Gdk::Color> _used_colors;
160 #endif // __gtk_ardour_group_tabs_h__