Ardour  9.0-pre0-582-g084a23a80d
group_tabs.h
Go to the documentation of this file.
1 /*
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>
6  *
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.
11  *
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.
16  *
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.
20  */
21 
22 #pragma once
23 
24 #include <gtkmm/menu.h>
25 
26 #include "ardour/session_handle.h"
27 #include "ardour/types.h"
28 
29 #include "gtkmm2ext/cairo_widget.h"
30 
31 #include "editor_component.h"
32 
33 namespace ARDOUR {
34  class Session;
35  class RouteGroup;
36 }
37 
38 class Editor;
39 class RouteGroupDialog;
40 
49 {
50 public:
52  virtual ~GroupTabs ();
53 
55 
63  Gtk::Menu* get_menu (ARDOUR::RouteGroup* g, bool tabArea = false);
64 
65  void run_new_group_dialog (ARDOUR::RouteList const *, bool with_master);
66 
67  void set_extent (double);
68  void set_offset (double);
69 
70  static void set_group_color (ARDOUR::RouteGroup *, uint32_t);
71  static std::string group_gui_id (ARDOUR::RouteGroup *);
72  static uint32_t group_color (ARDOUR::RouteGroup *);
73 
74 protected:
75 
76  struct Tab {
77  Tab () : group (0) {}
78 
79  double from;
80  double to;
81  uint32_t color;
83  };
84 
86  virtual double visible_extent () const = 0;
87 
89  double extent () const { return _extent < 0 ? visible_extent () : _extent; }
90 
92  double offset () const { return _offset; }
93 
94 private:
95  static void emit_gui_changed_for_members (std::shared_ptr<ARDOUR::RouteList>);
96 
100  virtual std::list<Tab> compute_tabs () const = 0;
101 
106  virtual void draw_tab (cairo_t* cr, Tab const & t) = 0;
107 
113  virtual double primary_coordinate (double x, double y) const = 0;
114 
115  virtual ARDOUR::RouteList routes_for_tab (Tab const * t) const = 0;
117  virtual ARDOUR::RouteList selected_routes () const = 0;
118 
120 
121  void new_from_selection (bool with_master);
122  void new_from_rec_enabled (bool with_master);
123  void new_from_soloed (bool with_master);
124 
125  void new_group_dialog_finished (int, RouteGroupDialog*, ARDOUR::RouteList const *, bool with_master) const;
127 
133  void activate_all ();
134  void disable_all ();
136 
137  void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*);
142 
145 
146  Tab * click_to_tab (double, std::list<Tab>::iterator *, std::list<Tab>::iterator *);
147 
149  void route_added_to_route_group (ARDOUR::RouteGroup *, std::weak_ptr<ARDOUR::Route>);
150  void route_removed_from_route_group (ARDOUR::RouteGroup *, std::weak_ptr<ARDOUR::Route>);
151 
152  void assign_group_to_master (uint32_t which, ARDOUR::RouteGroup*, bool rename_master) const;
153  void unassign_group_to_master (uint32_t which, ARDOUR::RouteGroup*) const;
154  void assign_selection_to_master (uint32_t which);
155  void assign_recenabled_to_master (uint32_t which);
156  void assign_soloed_to_master (uint32_t which);
157  void assign_some_to_master (uint32_t which, ARDOUR::RouteList, std::string vcaname = "");
158 
161 
163  std::list<Tab> _tabs;
168  bool _drag_moved;
169  double _drag_fixed;
170  double _drag_moving;
171  double _drag_offset;
172  double _drag_min;
173  double _drag_max;
174  double _drag_first;
175  double _extent;
176  double _offset;
177 
178  bool _hovering;
179 
181 
183  static std::list<Gdk::Color> _used_colors;
184 };
185 
Definition: editor.h:158
virtual ~GroupTabs()
bool on_button_press_event(GdkEventButton *)
This is a default handler for the signal signal_button_press_event().
bool on_motion_notify_event(GdkEventMotion *)
This is a default handler for the signal signal_motion_notify_event().
double extent() const
Definition: group_tabs.h:89
void add_new_from_items(Gtk::Menu_Helpers::MenuList &)
bool on_leave_notify_event(GdkEventCrossing *)
This is a default handler for the signal signal_leave_notify_event().
virtual void add_menu_items(Gtk::Menu *, ARDOUR::RouteGroup *)
Definition: group_tabs.h:116
void remove_group(ARDOUR::RouteGroup *)
void edit_group(ARDOUR::RouteGroup *)
Gtk::Menu * _menu
Definition: group_tabs.h:162
double _drag_moving
the position of the moving end of the tab being dragged
Definition: group_tabs.h:170
double _drag_first
first mouse pointer position during drag
Definition: group_tabs.h:174
void un_subgroup(ARDOUR::RouteGroup *)
void assign_some_to_master(uint32_t which, ARDOUR::RouteList, std::string vcaname="")
void activate_all()
double offset() const
Definition: group_tabs.h:92
static void emit_gui_changed_for_members(std::shared_ptr< ARDOUR::RouteList >)
virtual std::list< Tab > compute_tabs() const =0
std::list< Tab > _tabs
current list of tabs
Definition: group_tabs.h:163
void route_added_to_route_group(ARDOUR::RouteGroup *, std::weak_ptr< ARDOUR::Route >)
void new_group_dialog_finished(int, RouteGroupDialog *, ARDOUR::RouteList const *, bool with_master) const
double _drag_fixed
the position of the fixed end of the tab being dragged
Definition: group_tabs.h:169
void collect(ARDOUR::RouteGroup *)
void route_group_property_changed(ARDOUR::RouteGroup *)
virtual double primary_coordinate(double x, double y) const =0
virtual void draw_tab(cairo_t *cr, Tab const &t)=0
bool on_button_release_event(GdkEventButton *)
This is a default handler for the signal signal_button_release_event().
virtual ARDOUR::RouteList selected_routes() const =0
void set_extent(double)
static void set_group_color(ARDOUR::RouteGroup *, uint32_t)
Tab * click_to_tab(double, std::list< Tab >::iterator *, std::list< Tab >::iterator *)
void set_session(ARDOUR::Session *)
double _drag_offset
offset from the mouse to the end of the tab being dragged
Definition: group_tabs.h:171
double _drag_min
minimum position for drag
Definition: group_tabs.h:172
void assign_group_to_master(uint32_t which, ARDOUR::RouteGroup *, bool rename_master) const
Gtk::Menu * get_menu(ARDOUR::RouteGroup *g, bool tabArea=false)
void assign_selection_to_master(uint32_t which)
void route_removed_from_route_group(ARDOUR::RouteGroup *, std::weak_ptr< ARDOUR::Route >)
void new_from_soloed(bool with_master)
void set_offset(double)
ARDOUR::RouteList get_rec_enabled()
static uint32_t group_color(ARDOUR::RouteGroup *)
static std::list< Gdk::Color > _used_colors
Definition: group_tabs.h:183
bool on_enter_notify_event(GdkEventCrossing *)
This is a default handler for the signal signal_enter_notify_event().
void run_new_group_dialog(ARDOUR::RouteList const *, bool with_master)
static std::string group_gui_id(ARDOUR::RouteGroup *)
PBD::ScopedConnection _new_route_group_connection
Definition: group_tabs.h:180
ARDOUR::RouteList _initial_dragging_routes
Definition: group_tabs.h:166
bool _drag_moved
true if there has been movement during any current drag
Definition: group_tabs.h:168
void new_from_selection(bool with_master)
void assign_soloed_to_master(uint32_t which)
Tab * _dragging
tab being dragged, or 0
Definition: group_tabs.h:164
virtual ARDOUR::RouteList routes_for_tab(Tab const *t) const =0
virtual double visible_extent() const =0
void new_from_rec_enabled(bool with_master)
void render(Cairo::RefPtr< Cairo::Context > const &, cairo_rectangle_t *)
bool _dragging_new_tab
true if we're dragging a new tab
Definition: group_tabs.h:167
void disable_all()
double _offset
Definition: group_tabs.h:176
void edit_group_dialog_finished(int, RouteGroupDialog *) const
void unassign_group_to_master(uint32_t which, ARDOUR::RouteGroup *) const
double _extent
Definition: group_tabs.h:175
void on_size_request(Gtk::Requisition *)
This is a default handler for the signal signal_size_request().
void assign_recenabled_to_master(uint32_t which)
double _drag_max
maximum position for drag
Definition: group_tabs.h:173
void subgroup(ARDOUR::RouteGroup *, bool, ARDOUR::Placement)
void set_activation(ARDOUR::RouteGroup *, bool)
bool _hovering
Definition: group_tabs.h:178
ARDOUR::RouteList get_soloed()
std::list< std::shared_ptr< Route > > RouteList
uint32_t color
color
Definition: group_tabs.h:81
ARDOUR::RouteGroup * group
route group
Definition: group_tabs.h:82