Ardour  9.0-pre0-822-g12e3bc5c20
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 <ytkmm/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 
95 
96 private:
97  static void emit_gui_changed_for_members (std::shared_ptr<ARDOUR::RouteList>);
98 
102  virtual std::list<Tab> compute_tabs () const = 0;
103 
108  virtual void draw_tab (cairo_t* cr, Tab const & t) = 0;
109 
115  virtual double primary_coordinate (double x, double y) const = 0;
116 
117  virtual ARDOUR::RouteList routes_for_tab (Tab const * t) const = 0;
118  virtual void add_menu_items (Gtk::Menu *, ARDOUR::RouteGroup *) {}
119  virtual ARDOUR::RouteList selected_routes () const = 0;
120 
121  void add_new_from_items (Gtk::Menu_Helpers::MenuList&);
122 
123  void new_from_selection (bool with_master);
124  void new_from_rec_enabled (bool with_master);
125  void new_from_soloed (bool with_master);
126 
127  void new_group_dialog_finished (int, RouteGroupDialog*, ARDOUR::RouteList const *, bool with_master) const;
129 
135  void activate_all ();
136  void disable_all ();
138 
139  void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*);
140  void on_size_request (Gtk::Requisition *);
141  bool on_button_press_event (GdkEventButton *);
142  bool on_motion_notify_event (GdkEventMotion *);
143  bool on_button_release_event (GdkEventButton *);
144 
145  bool on_enter_notify_event (GdkEventCrossing*);
146  bool on_leave_notify_event (GdkEventCrossing*);
147 
148  Tab * click_to_tab (double, std::list<Tab>::iterator *, std::list<Tab>::iterator *);
149 
151  void route_added_to_route_group (ARDOUR::RouteGroup *, std::weak_ptr<ARDOUR::Route>);
152  void route_removed_from_route_group (ARDOUR::RouteGroup *, std::weak_ptr<ARDOUR::Route>);
153 
154  void assign_group_to_master (uint32_t which, ARDOUR::RouteGroup*, bool rename_master) const;
155  void unassign_group_to_master (uint32_t which, ARDOUR::RouteGroup*) const;
156  void assign_selection_to_master (uint32_t which);
157  void assign_recenabled_to_master (uint32_t which);
158  void assign_soloed_to_master (uint32_t which);
159  void assign_some_to_master (uint32_t which, ARDOUR::RouteList, std::string vcaname = "");
160 
163 
164  Gtk::Menu* _menu;
165  std::list<Tab> _tabs;
169  bool _drag_moved;
170  double _drag_fixed;
171  double _drag_moving;
172  double _drag_offset;
173  double _drag_min;
174  double _drag_max;
175  double _drag_first;
176  double _extent;
177  double _offset;
178 
179  bool _hovering;
180 
182 
184  static std::list<Gdk::Color> _used_colors;
185 };
186 
Definition: editor.h:159
virtual ~GroupTabs()
bool on_button_press_event(GdkEventButton *)
bool on_motion_notify_event(GdkEventMotion *)
double extent() const
Definition: group_tabs.h:89
void add_new_from_items(Gtk::Menu_Helpers::MenuList &)
bool on_leave_notify_event(GdkEventCrossing *)
virtual void add_menu_items(Gtk::Menu *, ARDOUR::RouteGroup *)
Definition: group_tabs.h:118
void remove_group(ARDOUR::RouteGroup *)
void edit_group(ARDOUR::RouteGroup *)
Gtk::Menu * _menu
Definition: group_tabs.h:164
double _drag_moving
the position of the moving end of the tab being dragged
Definition: group_tabs.h:171
double _drag_first
first mouse pointer position during drag
Definition: group_tabs.h:175
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:165
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:170
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 *)
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:172
double _drag_min
minimum position for drag
Definition: group_tabs.h:173
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:184
bool on_enter_notify_event(GdkEventCrossing *)
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:181
ARDOUR::RouteList _initial_dragging_routes
Definition: group_tabs.h:168
bool _drag_moved
true if there has been movement during any current drag
Definition: group_tabs.h:169
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:166
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:94
void disable_all()
double _offset
Definition: group_tabs.h:177
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:176
void on_size_request(Gtk::Requisition *)
void assign_recenabled_to_master(uint32_t which)
double _drag_max
maximum position for drag
Definition: group_tabs.h:174
void subgroup(ARDOUR::RouteGroup *, bool, ARDOUR::Placement)
void set_activation(ARDOUR::RouteGroup *, bool)
bool _hovering
Definition: group_tabs.h:179
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